Lines Matching +full:usb +full:- +full:ehci

1 // SPDX-License-Identifier: GPL-2.0+
3 * Samsung Exynos USB HOST EHCI Controller
11 #include <linux/dma-mapping.h>
19 #include <linux/usb.h>
20 #include <linux/usb/hcd.h>
22 #include "ehci.h"
24 #define DRIVER_DESC "EHCI Exynos driver"
35 static const char hcd_name[] = "ehci-exynos";
47 #define to_exynos_ehci(hcd) (struct exynos_ehci_hcd *)(hcd_to_ehci(hcd)->priv)
58 num_phys = of_count_phandle_with_args(dev->of_node, "phys", in exynos_ehci_get_phy()
59 "#phy-cells"); in exynos_ehci_get_phy()
61 phy = devm_of_phy_get_by_index(dev, dev->of_node, phy_number); in exynos_ehci_get_phy()
64 exynos_ehci->phy[phy_number] = phy; in exynos_ehci_get_phy()
70 for_each_available_child_of_node(dev->of_node, child) { in exynos_ehci_get_phy()
81 return -EINVAL; in exynos_ehci_get_phy()
85 exynos_ehci->phy[phy_number] = phy; in exynos_ehci_get_phy()
88 if (ret == -EPROBE_DEFER) { in exynos_ehci_get_phy()
91 } else if (ret != -ENOSYS && ret != -ENODEV) { in exynos_ehci_get_phy()
100 exynos_ehci->legacy_phy = true; in exynos_ehci_get_phy()
112 if (!IS_ERR(exynos_ehci->phy[i])) in exynos_ehci_phy_enable()
113 ret = phy_power_on(exynos_ehci->phy[i]); in exynos_ehci_phy_enable()
115 for (i--; i >= 0; i--) in exynos_ehci_phy_enable()
116 if (!IS_ERR(exynos_ehci->phy[i])) in exynos_ehci_phy_enable()
117 phy_power_off(exynos_ehci->phy[i]); in exynos_ehci_phy_enable()
129 if (!IS_ERR(exynos_ehci->phy[i])) in exynos_ehci_phy_disable()
130 phy_power_off(exynos_ehci->phy[i]); in exynos_ehci_phy_disable()
138 if (!dev->of_node) in exynos_setup_vbus_gpio()
141 gpio = of_get_named_gpio(dev->of_node, "samsung,vbus-gpio", 0); in exynos_setup_vbus_gpio()
148 dev_err(dev, "can't request ehci vbus gpio %d", gpio); in exynos_setup_vbus_gpio()
155 struct ehci_hcd *ehci; in exynos_ehci_probe() local
161 * Right now device-tree probed devices don't get dma_mask set. in exynos_ehci_probe()
162 * Since shared usb code relies on it, set it here for now. in exynos_ehci_probe()
165 err = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in exynos_ehci_probe()
169 exynos_setup_vbus_gpio(&pdev->dev); in exynos_ehci_probe()
172 &pdev->dev, dev_name(&pdev->dev)); in exynos_ehci_probe()
174 dev_err(&pdev->dev, "Unable to create HCD\n"); in exynos_ehci_probe()
175 return -ENOMEM; in exynos_ehci_probe()
179 err = exynos_ehci_get_phy(&pdev->dev, exynos_ehci); in exynos_ehci_probe()
183 exynos_ehci->clk = devm_clk_get(&pdev->dev, "usbhost"); in exynos_ehci_probe()
185 if (IS_ERR(exynos_ehci->clk)) { in exynos_ehci_probe()
186 dev_err(&pdev->dev, "Failed to get usbhost clock\n"); in exynos_ehci_probe()
187 err = PTR_ERR(exynos_ehci->clk); in exynos_ehci_probe()
191 err = clk_prepare_enable(exynos_ehci->clk); in exynos_ehci_probe()
196 hcd->regs = devm_ioremap_resource(&pdev->dev, res); in exynos_ehci_probe()
197 if (IS_ERR(hcd->regs)) { in exynos_ehci_probe()
198 err = PTR_ERR(hcd->regs); in exynos_ehci_probe()
202 hcd->rsrc_start = res->start; in exynos_ehci_probe()
203 hcd->rsrc_len = resource_size(res); in exynos_ehci_probe()
211 err = exynos_ehci_phy_enable(&pdev->dev); in exynos_ehci_probe()
213 dev_err(&pdev->dev, "Failed to enable USB phy\n"); in exynos_ehci_probe()
217 ehci = hcd_to_ehci(hcd); in exynos_ehci_probe()
218 ehci->caps = hcd->regs; in exynos_ehci_probe()
222 * Exynos EHCI port subnodes and generic USB device bindings in exynos_ehci_probe()
224 exynos_ehci->of_node = pdev->dev.of_node; in exynos_ehci_probe()
225 if (exynos_ehci->legacy_phy) in exynos_ehci_probe()
226 pdev->dev.of_node = NULL; in exynos_ehci_probe()
229 writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); in exynos_ehci_probe()
233 dev_err(&pdev->dev, "Failed to add USB HCD\n"); in exynos_ehci_probe()
236 device_wakeup_enable(hcd->self.controller); in exynos_ehci_probe()
243 exynos_ehci_phy_disable(&pdev->dev); in exynos_ehci_probe()
244 pdev->dev.of_node = exynos_ehci->of_node; in exynos_ehci_probe()
246 clk_disable_unprepare(exynos_ehci->clk); in exynos_ehci_probe()
257 pdev->dev.of_node = exynos_ehci->of_node; in exynos_ehci_remove()
261 exynos_ehci_phy_disable(&pdev->dev); in exynos_ehci_remove()
263 clk_disable_unprepare(exynos_ehci->clk); in exynos_ehci_remove()
285 clk_disable_unprepare(exynos_ehci->clk); in exynos_ehci_suspend()
296 ret = clk_prepare_enable(exynos_ehci->clk); in exynos_ehci_resume()
302 dev_err(dev, "Failed to enable USB phy\n"); in exynos_ehci_resume()
303 clk_disable_unprepare(exynos_ehci->clk); in exynos_ehci_resume()
308 writel(EHCI_INSNREG00_ENABLE_DMA_BURST, EHCI_INSNREG00(hcd->regs)); in exynos_ehci_resume()
325 { .compatible = "samsung,exynos4210-ehci" },
336 .name = "exynos-ehci",
348 return -ENODEV; in ehci_exynos_init()
363 MODULE_ALIAS("platform:exynos-ehci");