Lines Matching +full:pxau2o +full:- +full:ehci

1 // SPDX-License-Identifier: GPL-2.0+
20 #include "ehci.h"
27 #define hcd_to_ehci_hcd_mv(h) ((struct ehci_hcd_mv *)hcd_to_ehci(h)->priv)
30 /* Which mode does this ehci running OTG/Host ? */
49 retval = clk_prepare_enable(ehci_mv->clk); in mv_ehci_enable()
53 retval = phy_init(ehci_mv->phy); in mv_ehci_enable()
55 clk_disable_unprepare(ehci_mv->clk); in mv_ehci_enable()
62 phy_exit(ehci_mv->phy); in mv_ehci_disable()
63 clk_disable_unprepare(ehci_mv->clk); in mv_ehci_disable()
68 struct device *dev = hcd->self.controller; in mv_ehci_reset()
70 struct ehci_hcd *ehci = hcd_to_ehci(hcd); in mv_ehci_reset() local
75 dev_err(dev, "Can not find private ehci data\n"); in mv_ehci_reset()
76 return -ENODEV; in mv_ehci_reset()
79 hcd->has_tt = 1; in mv_ehci_reset()
85 if (of_usb_get_phy_mode(dev->of_node) == USBPHY_INTERFACE_MODE_HSIC) { in mv_ehci_reset()
86 status = ehci_readl(ehci, &ehci->regs->port_status[0]); in mv_ehci_reset()
88 ehci_writel(ehci, status, &ehci->regs->port_status[0]); in mv_ehci_reset()
90 ehci_writel(ehci, status, &ehci->regs->port_status[0]); in mv_ehci_reset()
105 struct mv_usb_platform_data *pdata = dev_get_platdata(&pdev->dev); in mv_ehci_probe()
107 struct ehci_hcd *ehci; in mv_ehci_probe() local
115 return -ENODEV; in mv_ehci_probe()
117 hcd = usb_create_hcd(&ehci_platform_hc_driver, &pdev->dev, dev_name(&pdev->dev)); in mv_ehci_probe()
119 return -ENOMEM; in mv_ehci_probe()
124 ehci_mv->mode = MV_USB_MODE_HOST; in mv_ehci_probe()
126 ehci_mv->mode = pdata->mode; in mv_ehci_probe()
127 ehci_mv->set_vbus = pdata->set_vbus; in mv_ehci_probe()
130 ehci_mv->phy = devm_phy_optional_get(&pdev->dev, "usb"); in mv_ehci_probe()
131 if (IS_ERR(ehci_mv->phy)) { in mv_ehci_probe()
132 retval = PTR_ERR(ehci_mv->phy); in mv_ehci_probe()
133 if (retval != -EPROBE_DEFER) in mv_ehci_probe()
134 dev_err(&pdev->dev, "Failed to get phy.\n"); in mv_ehci_probe()
138 ehci_mv->clk = devm_clk_get(&pdev->dev, NULL); in mv_ehci_probe()
139 if (IS_ERR(ehci_mv->clk)) { in mv_ehci_probe()
140 dev_err(&pdev->dev, "error getting clock\n"); in mv_ehci_probe()
141 retval = PTR_ERR(ehci_mv->clk); in mv_ehci_probe()
145 ehci_mv->base = devm_platform_get_and_ioremap_resource(pdev, 0, &r); in mv_ehci_probe()
146 if (IS_ERR(ehci_mv->base)) { in mv_ehci_probe()
147 retval = PTR_ERR(ehci_mv->base); in mv_ehci_probe()
153 dev_err(&pdev->dev, "init phy error %d\n", retval); in mv_ehci_probe()
157 ehci_mv->cap_regs = in mv_ehci_probe()
158 (void __iomem *) ((unsigned long) ehci_mv->base + U2x_CAPREGS_OFFSET); in mv_ehci_probe()
159 offset = readl(ehci_mv->cap_regs) & CAPLENGTH_MASK; in mv_ehci_probe()
160 ehci_mv->op_regs = in mv_ehci_probe()
161 (void __iomem *) ((unsigned long) ehci_mv->cap_regs + offset); in mv_ehci_probe()
163 hcd->rsrc_start = r->start; in mv_ehci_probe()
164 hcd->rsrc_len = resource_size(r); in mv_ehci_probe()
165 hcd->regs = ehci_mv->op_regs; in mv_ehci_probe()
170 hcd->irq = retval; in mv_ehci_probe()
172 ehci = hcd_to_ehci(hcd); in mv_ehci_probe()
173 ehci->caps = (struct ehci_caps __iomem *) ehci_mv->cap_regs; in mv_ehci_probe()
175 if (ehci_mv->mode == MV_USB_MODE_OTG) { in mv_ehci_probe()
176 ehci_mv->otg = devm_usb_get_phy(&pdev->dev, USB_PHY_TYPE_USB2); in mv_ehci_probe()
177 if (IS_ERR(ehci_mv->otg)) { in mv_ehci_probe()
178 retval = PTR_ERR(ehci_mv->otg); in mv_ehci_probe()
180 if (retval == -ENXIO) in mv_ehci_probe()
181 dev_info(&pdev->dev, "MV_USB_MODE_OTG " in mv_ehci_probe()
184 dev_err(&pdev->dev, in mv_ehci_probe()
189 retval = otg_set_host(ehci_mv->otg->otg, &hcd->self); in mv_ehci_probe()
191 dev_err(&pdev->dev, in mv_ehci_probe()
193 retval = -ENODEV; in mv_ehci_probe()
199 if (ehci_mv->set_vbus) in mv_ehci_probe()
200 ehci_mv->set_vbus(1); in mv_ehci_probe()
202 retval = usb_add_hcd(hcd, hcd->irq, IRQF_SHARED); in mv_ehci_probe()
204 dev_err(&pdev->dev, in mv_ehci_probe()
208 device_wakeup_enable(hcd->self.controller); in mv_ehci_probe()
211 if (of_usb_get_phy_mode(pdev->dev.of_node) == USBPHY_INTERFACE_MODE_HSIC) { in mv_ehci_probe()
212 status = ehci_readl(ehci, &ehci->regs->port_status[0]); in mv_ehci_probe()
216 ehci_writel(ehci, status, &ehci->regs->port_status[0]); in mv_ehci_probe()
219 dev_info(&pdev->dev, in mv_ehci_probe()
220 "successful find EHCI device with regs 0x%p irq %d" in mv_ehci_probe()
221 " working in %s mode\n", hcd->regs, hcd->irq, in mv_ehci_probe()
222 ehci_mv->mode == MV_USB_MODE_OTG ? "OTG" : "Host"); in mv_ehci_probe()
227 if (ehci_mv->set_vbus) in mv_ehci_probe()
228 ehci_mv->set_vbus(0); in mv_ehci_probe()
242 if (hcd->rh_registered) in mv_ehci_remove()
245 if (!IS_ERR_OR_NULL(ehci_mv->otg)) in mv_ehci_remove()
246 otg_set_host(ehci_mv->otg->otg, NULL); in mv_ehci_remove()
248 if (ehci_mv->mode == MV_USB_MODE_HOST) { in mv_ehci_remove()
249 if (ehci_mv->set_vbus) in mv_ehci_remove()
250 ehci_mv->set_vbus(0); in mv_ehci_remove()
259 {"pxa-u2oehci", 0},
260 {"pxa-sph", 0},
268 if (!hcd->rh_registered) in mv_ehci_shutdown()
271 if (hcd->driver->shutdown) in mv_ehci_shutdown()
272 hcd->driver->shutdown(hcd); in mv_ehci_shutdown()
276 { .compatible = "marvell,pxau2o-ehci", },
285 .name = "mv-ehci",
295 return -ENODEV; in ehci_platform_init()
308 MODULE_DESCRIPTION("Marvell EHCI driver");
311 MODULE_ALIAS("mv-ehci");