Lines Matching +full:generic +full:- +full:ohci

1 // SPDX-License-Identifier: GPL-2.0
3 * Generic platform ohci driver
6 * Copyright 2011-2012 Hauke Mehrtens <hauke@hauke-m.de>
9 * Derived from the OCHI-SSB driver
10 * Derived from the OHCI-PCI driver
12 * Copyright 2000-2002 David Brownell
18 #include <linux/dma-mapping.h>
33 #include "ohci.h"
35 #define DRIVER_DESC "OHCI generic platform driver"
37 #define hcd_to_ohci_priv(h) ((struct ohci_platform_priv *)hcd_to_ohci(h)->priv)
50 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) { in ohci_platform_power_on()
51 ret = clk_prepare_enable(priv->clks[clk]); in ohci_platform_power_on()
59 while (--clk >= 0) in ohci_platform_power_on()
60 clk_disable_unprepare(priv->clks[clk]); in ohci_platform_power_on()
71 for (clk = OHCI_MAX_CLKS - 1; clk >= 0; clk--) in ohci_platform_power_off()
72 if (priv->clks[clk]) in ohci_platform_power_off()
73 clk_disable_unprepare(priv->clks[clk]); in ohci_platform_power_off()
79 .product_desc = "Generic Platform OHCI controller",
93 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); in ohci_platform_probe()
95 struct ohci_hcd *ohci; in ohci_platform_probe() local
99 return -ENODEV; in ohci_platform_probe()
108 err = dma_coerce_mask_and_coherent(&dev->dev, DMA_BIT_MASK(32)); in ohci_platform_probe()
116 hcd = usb_create_hcd(&ohci_platform_hc_driver, &dev->dev, in ohci_platform_probe()
117 dev_name(&dev->dev)); in ohci_platform_probe()
119 return -ENOMEM; in ohci_platform_probe()
122 dev->dev.platform_data = pdata; in ohci_platform_probe()
124 ohci = hcd_to_ohci(hcd); in ohci_platform_probe()
126 if (pdata == &ohci_platform_defaults && dev->dev.of_node) { in ohci_platform_probe()
127 if (of_property_read_bool(dev->dev.of_node, "big-endian-regs")) in ohci_platform_probe()
128 ohci->flags |= OHCI_QUIRK_BE_MMIO; in ohci_platform_probe()
130 if (of_property_read_bool(dev->dev.of_node, "big-endian-desc")) in ohci_platform_probe()
131 ohci->flags |= OHCI_QUIRK_BE_DESC; in ohci_platform_probe()
133 if (of_property_read_bool(dev->dev.of_node, "big-endian")) in ohci_platform_probe()
134 ohci->flags |= OHCI_QUIRK_BE_MMIO | OHCI_QUIRK_BE_DESC; in ohci_platform_probe()
136 if (of_property_read_bool(dev->dev.of_node, "no-big-frame-no")) in ohci_platform_probe()
137 ohci->flags |= OHCI_QUIRK_FRAME_NO; in ohci_platform_probe()
139 if (of_property_read_bool(dev->dev.of_node, in ohci_platform_probe()
140 "remote-wakeup-connected")) in ohci_platform_probe()
141 ohci->hc_control = OHCI_CTRL_RWC; in ohci_platform_probe()
143 of_property_read_u32(dev->dev.of_node, "num-ports", in ohci_platform_probe()
144 &ohci->num_ports); in ohci_platform_probe()
147 priv->clks[clk] = of_clk_get(dev->dev.of_node, clk); in ohci_platform_probe()
148 if (IS_ERR(priv->clks[clk])) { in ohci_platform_probe()
149 err = PTR_ERR(priv->clks[clk]); in ohci_platform_probe()
150 if (err == -EPROBE_DEFER) in ohci_platform_probe()
152 priv->clks[clk] = NULL; in ohci_platform_probe()
157 priv->resets = devm_reset_control_array_get_optional_shared( in ohci_platform_probe()
158 &dev->dev); in ohci_platform_probe()
159 if (IS_ERR(priv->resets)) { in ohci_platform_probe()
160 err = PTR_ERR(priv->resets); in ohci_platform_probe()
164 err = reset_control_deassert(priv->resets); in ohci_platform_probe()
169 if (pdata->big_endian_desc) in ohci_platform_probe()
170 ohci->flags |= OHCI_QUIRK_BE_DESC; in ohci_platform_probe()
171 if (pdata->big_endian_mmio) in ohci_platform_probe()
172 ohci->flags |= OHCI_QUIRK_BE_MMIO; in ohci_platform_probe()
173 if (pdata->no_big_frame_no) in ohci_platform_probe()
174 ohci->flags |= OHCI_QUIRK_FRAME_NO; in ohci_platform_probe()
175 if (pdata->num_ports) in ohci_platform_probe()
176 ohci->num_ports = pdata->num_ports; in ohci_platform_probe()
179 if (ohci->flags & OHCI_QUIRK_BE_MMIO) { in ohci_platform_probe()
180 dev_err(&dev->dev, in ohci_platform_probe()
182 err = -EINVAL; in ohci_platform_probe()
187 if (ohci->flags & OHCI_QUIRK_BE_DESC) { in ohci_platform_probe()
188 dev_err(&dev->dev, in ohci_platform_probe()
190 err = -EINVAL; in ohci_platform_probe()
195 pm_runtime_set_active(&dev->dev); in ohci_platform_probe()
196 pm_runtime_enable(&dev->dev); in ohci_platform_probe()
197 if (pdata->power_on) { in ohci_platform_probe()
198 err = pdata->power_on(dev); in ohci_platform_probe()
203 hcd->regs = devm_platform_get_and_ioremap_resource(dev, 0, &res_mem); in ohci_platform_probe()
204 if (IS_ERR(hcd->regs)) { in ohci_platform_probe()
205 err = PTR_ERR(hcd->regs); in ohci_platform_probe()
208 hcd->rsrc_start = res_mem->start; in ohci_platform_probe()
209 hcd->rsrc_len = resource_size(res_mem); in ohci_platform_probe()
211 hcd->tpl_support = of_usb_host_tpl_support(dev->dev.of_node); in ohci_platform_probe()
217 device_wakeup_enable(hcd->self.controller); in ohci_platform_probe()
224 if (pdata->power_off) in ohci_platform_probe()
225 pdata->power_off(dev); in ohci_platform_probe()
227 pm_runtime_disable(&dev->dev); in ohci_platform_probe()
228 reset_control_assert(priv->resets); in ohci_platform_probe()
230 while (--clk >= 0) in ohci_platform_probe()
231 clk_put(priv->clks[clk]); in ohci_platform_probe()
234 dev->dev.platform_data = NULL; in ohci_platform_probe()
244 struct usb_ohci_pdata *pdata = dev_get_platdata(&dev->dev); in ohci_platform_remove()
248 pm_runtime_get_sync(&dev->dev); in ohci_platform_remove()
251 if (pdata->power_off) in ohci_platform_remove()
252 pdata->power_off(dev); in ohci_platform_remove()
254 reset_control_assert(priv->resets); in ohci_platform_remove()
256 for (clk = 0; clk < OHCI_MAX_CLKS && priv->clks[clk]; clk++) in ohci_platform_remove()
257 clk_put(priv->clks[clk]); in ohci_platform_remove()
261 pm_runtime_put_sync(&dev->dev); in ohci_platform_remove()
262 pm_runtime_disable(&dev->dev); in ohci_platform_remove()
265 dev->dev.platform_data = NULL; in ohci_platform_remove()
272 struct usb_ohci_pdata *pdata = dev->platform_data; in ohci_platform_suspend()
281 if (pdata->power_suspend) in ohci_platform_suspend()
282 pdata->power_suspend(pdev); in ohci_platform_suspend()
293 if (pdata->power_on) { in ohci_platform_resume_common()
294 int err = pdata->power_on(pdev); in ohci_platform_resume_common()
320 { .compatible = "generic-ohci", },
321 { .compatible = "cavium,octeon-6335-ohci", },
322 { .compatible = "ti,ohci-omap3", },
328 { "ohci-platform", 0 },
350 .name = "ohci-platform",
362 return -ENODEV; in ohci_platform_init()