Lines Matching +full:self +full:- +full:powered

1 // SPDX-License-Identifier: GPL-1.0+
6 * (C) Copyright 2000-2005 David Brownell
7 * (C) Copyright 2002 Hewlett-Packard Company
13 * and on ohci-sa1111.c by Christopher Hoover <ch@hpl.hp.com>
19 #include <linux/dma-mapping.h>
35 #include <asm/mach-types.h>
43 /* OMAP-1510 OHCI has its own MMU for DMA */
63 static const char hcd_name[] = "ohci-omap";
67 ((struct ohci_omap_priv *)hcd_to_ohci(h)->priv)
72 clk_enable(priv->usb_dc_ck); in omap_ohci_clock_power()
73 clk_enable(priv->usb_host_ck); in omap_ohci_clock_power()
77 clk_disable(priv->usb_host_ck); in omap_ohci_clock_power()
78 clk_disable(priv->usb_dc_ck); in omap_ohci_clock_power()
83 * Board specific gang-switched transceiver power on/off.
93 else if (priv->power) in omap_ohci_transceiver_power()
94 gpiod_set_value_cansleep(priv->power, 0); in omap_ohci_transceiver_power()
100 else if (priv->power) in omap_ohci_transceiver_power()
101 gpiod_set_value_cansleep(priv->power, 1); in omap_ohci_transceiver_power()
109 * OMAP-1510 specific Local Bus clock on/off
124 * OMAP-1510 specific Local Bus initialization
126 * See also arch/mach-omap/memory.h for __virt_to_dma() and
167 const unsigned port = hcd->self.otg_port - 1; in start_hnp()
171 otg_start_hnp(hcd->usb_phy->otg); in start_hnp()
174 hcd->usb_phy->otg->state = OTG_STATE_A_SUSPEND; in start_hnp()
175 writel (RH_PS_PSS, &ohci->regs->roothub.portstatus [port]); in start_hnp()
184 /*-------------------------------------------------------------------------*/
189 struct omap_usb_config *config = dev_get_platdata(hcd->self.controller); in ohci_omap_reset()
191 int need_transceiver = (config->otg != 0); in ohci_omap_reset()
194 dev_dbg(hcd->self.controller, "starting USB Controller\n"); in ohci_omap_reset()
196 if (config->otg) { in ohci_omap_reset()
197 hcd->self.otg_port = config->otg; in ohci_omap_reset()
199 hcd->power_budget = 8; in ohci_omap_reset()
202 /* boards can use OTG transceivers in non-OTG modes */ in ohci_omap_reset()
207 if (config->ocpi_enable) in ohci_omap_reset()
208 config->ocpi_enable(); in ohci_omap_reset()
212 hcd->usb_phy = usb_get_phy(USB_PHY_TYPE_USB2); in ohci_omap_reset()
213 if (!IS_ERR_OR_NULL(hcd->usb_phy)) { in ohci_omap_reset()
214 int status = otg_set_host(hcd->usb_phy->otg, in ohci_omap_reset()
215 &ohci_to_hcd(ohci)->self); in ohci_omap_reset()
216 dev_dbg(hcd->self.controller, "init %s phy, status %d\n", in ohci_omap_reset()
217 hcd->usb_phy->label, status); in ohci_omap_reset()
219 usb_put_phy(hcd->usb_phy); in ohci_omap_reset()
223 return -EPROBE_DEFER; in ohci_omap_reset()
225 hcd->skip_phy_initialization = 1; in ohci_omap_reset()
226 ohci->start_hnp = start_hnp; in ohci_omap_reset()
241 if (config->otg || config->rwc) { in ohci_omap_reset()
242 ohci->hc_control = OHCI_CTRL_RWC; in ohci_omap_reset()
243 writel(OHCI_CTRL_RWC, &ohci->regs->control); in ohci_omap_reset()
246 /* board-specific power switching and overcurrent support */ in ohci_omap_reset()
255 ohci_to_hcd(ohci)->power_budget = 250; in ohci_omap_reset()
265 ohci_writel(ohci, rh, &ohci->regs->roothub.a); in ohci_omap_reset()
266 ohci->flags &= ~OHCI_QUIRK_HUB_POWER; in ohci_omap_reset()
268 /* We require a self-powered hub, which should have in ohci_omap_reset()
270 ohci_to_hcd(ohci)->power_budget = 0; in ohci_omap_reset()
284 /*-------------------------------------------------------------------------*/
287 * ohci_hcd_omap_probe - initialize OMAP-based HCDs
300 if (pdev->num_resources != 2) { in ohci_hcd_omap_probe()
301 dev_err(&pdev->dev, "invalid num_resources: %i\n", in ohci_hcd_omap_probe()
302 pdev->num_resources); in ohci_hcd_omap_probe()
303 return -ENODEV; in ohci_hcd_omap_probe()
306 if (pdev->resource[0].flags != IORESOURCE_MEM in ohci_hcd_omap_probe()
307 || pdev->resource[1].flags != IORESOURCE_IRQ) { in ohci_hcd_omap_probe()
308 dev_err(&pdev->dev, "invalid resource type\n"); in ohci_hcd_omap_probe()
309 return -ENODEV; in ohci_hcd_omap_probe()
312 hcd = usb_create_hcd(&ohci_omap_hc_driver, &pdev->dev, in ohci_hcd_omap_probe()
313 dev_name(&pdev->dev)); in ohci_hcd_omap_probe()
315 return -ENOMEM; in ohci_hcd_omap_probe()
317 hcd->rsrc_start = pdev->resource[0].start; in ohci_hcd_omap_probe()
318 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1; in ohci_hcd_omap_probe()
322 priv->power = devm_gpiod_get_optional(&pdev->dev, "power", GPIOD_ASIS); in ohci_hcd_omap_probe()
323 if (IS_ERR(priv->power)) { in ohci_hcd_omap_probe()
324 retval = PTR_ERR(priv->power); in ohci_hcd_omap_probe()
327 if (priv->power) in ohci_hcd_omap_probe()
328 gpiod_set_consumer_name(priv->power, "OHCI power"); in ohci_hcd_omap_probe()
335 priv->overcurrent = devm_gpiod_get_optional(&pdev->dev, "overcurrent", in ohci_hcd_omap_probe()
337 if (IS_ERR(priv->overcurrent)) { in ohci_hcd_omap_probe()
338 retval = PTR_ERR(priv->overcurrent); in ohci_hcd_omap_probe()
341 if (priv->overcurrent) in ohci_hcd_omap_probe()
342 gpiod_set_consumer_name(priv->overcurrent, "OHCI overcurrent"); in ohci_hcd_omap_probe()
344 priv->usb_host_ck = clk_get(&pdev->dev, "usb_hhc_ck"); in ohci_hcd_omap_probe()
345 if (IS_ERR(priv->usb_host_ck)) { in ohci_hcd_omap_probe()
346 retval = PTR_ERR(priv->usb_host_ck); in ohci_hcd_omap_probe()
351 priv->usb_dc_ck = clk_get(&pdev->dev, "usb_dc_ck"); in ohci_hcd_omap_probe()
353 priv->usb_dc_ck = clk_get(&pdev->dev, "lb_ck"); in ohci_hcd_omap_probe()
355 if (IS_ERR(priv->usb_dc_ck)) { in ohci_hcd_omap_probe()
356 retval = PTR_ERR(priv->usb_dc_ck); in ohci_hcd_omap_probe()
360 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { in ohci_hcd_omap_probe()
361 dev_dbg(&pdev->dev, "request_mem_region failed\n"); in ohci_hcd_omap_probe()
362 retval = -EBUSY; in ohci_hcd_omap_probe()
366 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); in ohci_hcd_omap_probe()
367 if (!hcd->regs) { in ohci_hcd_omap_probe()
368 dev_err(&pdev->dev, "can't ioremap OHCI HCD\n"); in ohci_hcd_omap_probe()
369 retval = -ENOMEM; in ohci_hcd_omap_probe()
375 retval = -ENXIO; in ohci_hcd_omap_probe()
382 device_wakeup_enable(hcd->self.controller); in ohci_hcd_omap_probe()
385 iounmap(hcd->regs); in ohci_hcd_omap_probe()
387 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); in ohci_hcd_omap_probe()
389 clk_put(priv->usb_dc_ck); in ohci_hcd_omap_probe()
391 clk_put(priv->usb_host_ck); in ohci_hcd_omap_probe()
401 * ohci_hcd_omap_remove - shutdown processing for OMAP-based HCDs
414 dev_dbg(hcd->self.controller, "stopping USB Controller\n"); in ohci_hcd_omap_remove()
417 if (!IS_ERR_OR_NULL(hcd->usb_phy)) { in ohci_hcd_omap_remove()
418 (void) otg_set_host(hcd->usb_phy->otg, 0); in ohci_hcd_omap_remove()
419 usb_put_phy(hcd->usb_phy); in ohci_hcd_omap_remove()
421 iounmap(hcd->regs); in ohci_hcd_omap_remove()
422 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); in ohci_hcd_omap_remove()
423 clk_put(priv->usb_dc_ck); in ohci_hcd_omap_remove()
424 clk_put(priv->usb_host_ck); in ohci_hcd_omap_remove()
429 /*-------------------------------------------------------------------------*/
438 bool do_wakeup = device_may_wakeup(&pdev->dev); in ohci_omap_suspend()
441 if (time_before(jiffies, ohci->next_statechange)) in ohci_omap_suspend()
443 ohci->next_statechange = jiffies; in ohci_omap_suspend()
459 if (time_before(jiffies, ohci->next_statechange)) in ohci_omap_resume()
461 ohci->next_statechange = jiffies; in ohci_omap_resume()
470 /*-------------------------------------------------------------------------*/
497 return -ENODEV; in ohci_omap_init()