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

1 // SPDX-License-Identifier: GPL-1.0+
6 * (C) Copyright 2000-2002 David Brownell <dbrownell@users.sourceforge.net>
7 * (C) Copyright 2002 Hewlett-Packard Company
14 * Modified for LH7A404 from ohci-sa1111.c
17 * Modified for pxa27x from ohci-lh7a404.c
18 * by Nick Bane <nick@cecomputing.co.uk> 26-8-2004
25 #include <linux/dma-mapping.h>
31 #include <linux/platform_data/usb-ohci-pxa27x.h>
46 * UHC: USB Host Controller (OHCI-like) register definitions
111 #define UHCHIE_RWIE (1 << 7) /* Remote Wake-up IntEn */
126 #define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)(hcd_to_ohci(hcd)->priv)
129 PMM_NPS_MODE -- PMM Non-power switching mode
130 Ports are powered continuously.
132 PMM_GLOBAL_MODE -- PMM global switching mode
133 All ports are powered at the same time.
135 PMM_PERPORT_MODE -- PMM per port switching mode
136 Ports are powered individually.
140 uint32_t uhcrhda = __raw_readl(pxa_ohci->mmio_base + UHCRHDA); in pxa27x_ohci_select_pmm()
141 uint32_t uhcrhdb = __raw_readl(pxa_ohci->mmio_base + UHCRHDB); in pxa27x_ohci_select_pmm()
159 "Invalid mode %d, set to non-power switch mode.\n", in pxa27x_ohci_select_pmm()
165 __raw_writel(uhcrhda, pxa_ohci->mmio_base + UHCRHDA); in pxa27x_ohci_select_pmm()
166 __raw_writel(uhcrhdb, pxa_ohci->mmio_base + UHCRHDB); in pxa27x_ohci_select_pmm()
173 struct regulator *vbus = pxa_ohci->vbus[port]; in pxa27x_ohci_set_vbus_power()
179 if (enable && !pxa_ohci->vbus_enabled[port]) in pxa27x_ohci_set_vbus_power()
181 else if (!enable && pxa_ohci->vbus_enabled[port]) in pxa27x_ohci_set_vbus_power()
187 pxa_ohci->vbus_enabled[port] = enable; in pxa27x_ohci_set_vbus_power()
202 return -EPIPE; in pxa27x_ohci_hub_control()
207 ret = pxa27x_ohci_set_vbus_power(pxa_ohci, wIndex - 1, in pxa27x_ohci_hub_control()
216 /*-------------------------------------------------------------------------*/
221 uint32_t uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR); in pxa27x_setup_hc()
222 uint32_t uhcrhda = __raw_readl(pxa_ohci->mmio_base + UHCRHDA); in pxa27x_setup_hc()
224 if (inf->flags & ENABLE_PORT1) in pxa27x_setup_hc()
227 if (inf->flags & ENABLE_PORT2) in pxa27x_setup_hc()
230 if (inf->flags & ENABLE_PORT3) in pxa27x_setup_hc()
233 if (inf->flags & POWER_CONTROL_LOW) in pxa27x_setup_hc()
236 if (inf->flags & POWER_SENSE_LOW) in pxa27x_setup_hc()
239 if (inf->flags & NO_OC_PROTECTION) in pxa27x_setup_hc()
244 if (inf->flags & OC_MODE_PERPORT) in pxa27x_setup_hc()
249 if (inf->power_on_delay) { in pxa27x_setup_hc()
251 uhcrhda |= UHCRHDA_POTPGT(inf->power_on_delay / 2); in pxa27x_setup_hc()
254 __raw_writel(uhchr, pxa_ohci->mmio_base + UHCHR); in pxa27x_setup_hc()
255 __raw_writel(uhcrhda, pxa_ohci->mmio_base + UHCRHDA); in pxa27x_setup_hc()
260 uint32_t uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR); in pxa27x_reset_hc()
262 __raw_writel(uhchr | UHCHR_FHR, pxa_ohci->mmio_base + UHCHR); in pxa27x_reset_hc()
264 __raw_writel(uhchr & ~UHCHR_FHR, pxa_ohci->mmio_base + UHCHR); in pxa27x_reset_hc()
275 retval = clk_prepare_enable(pxa_ohci->clk); in pxa27x_start_hc()
281 uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR) | UHCHR_FSBIR; in pxa27x_start_hc()
282 __raw_writel(uhchr, pxa_ohci->mmio_base + UHCHR); in pxa27x_start_hc()
284 while (__raw_readl(pxa_ohci->mmio_base + UHCHR) & UHCHR_FSBIR) in pxa27x_start_hc()
289 if (inf->init) in pxa27x_start_hc()
290 retval = inf->init(dev); in pxa27x_start_hc()
293 clk_disable_unprepare(pxa_ohci->clk); in pxa27x_start_hc()
297 uhchr = __raw_readl(pxa_ohci->mmio_base + UHCHR) & ~UHCHR_SSE; in pxa27x_start_hc()
298 __raw_writel(uhchr, pxa_ohci->mmio_base + UHCHR); in pxa27x_start_hc()
299 __raw_writel(UHCHIE_UPRIE | UHCHIE_RWIE, pxa_ohci->mmio_base + UHCHIE); in pxa27x_start_hc()
313 if (inf->exit) in pxa27x_stop_hc()
314 inf->exit(dev); in pxa27x_stop_hc()
319 uhccoms = __raw_readl(pxa_ohci->mmio_base + UHCCOMS) | 0x01; in pxa27x_stop_hc()
320 __raw_writel(uhccoms, pxa_ohci->mmio_base + UHCCOMS); in pxa27x_stop_hc()
323 clk_disable_unprepare(pxa_ohci->clk); in pxa27x_stop_hc()
328 { .compatible = "marvell,pxa-ohci" },
336 struct device_node *np = pdev->dev.of_node; in ohci_pxa_of_init()
344 /* Right now device-tree probed devices don't get dma_mask set. in ohci_pxa_of_init()
348 ret = dma_coerce_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(32)); in ohci_pxa_of_init()
352 pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); in ohci_pxa_of_init()
354 return -ENOMEM; in ohci_pxa_of_init()
356 if (of_property_read_bool(np, "marvell,enable-port1")) in ohci_pxa_of_init()
357 pdata->flags |= ENABLE_PORT1; in ohci_pxa_of_init()
358 if (of_property_read_bool(np, "marvell,enable-port2")) in ohci_pxa_of_init()
359 pdata->flags |= ENABLE_PORT2; in ohci_pxa_of_init()
360 if (of_property_read_bool(np, "marvell,enable-port3")) in ohci_pxa_of_init()
361 pdata->flags |= ENABLE_PORT3; in ohci_pxa_of_init()
362 if (of_property_read_bool(np, "marvell,port-sense-low")) in ohci_pxa_of_init()
363 pdata->flags |= POWER_SENSE_LOW; in ohci_pxa_of_init()
364 if (of_property_read_bool(np, "marvell,power-control-low")) in ohci_pxa_of_init()
365 pdata->flags |= POWER_CONTROL_LOW; in ohci_pxa_of_init()
366 if (of_property_read_bool(np, "marvell,no-oc-protection")) in ohci_pxa_of_init()
367 pdata->flags |= NO_OC_PROTECTION; in ohci_pxa_of_init()
368 if (of_property_read_bool(np, "marvell,oc-mode-perport")) in ohci_pxa_of_init()
369 pdata->flags |= OC_MODE_PERPORT; in ohci_pxa_of_init()
370 if (!of_property_read_u32(np, "marvell,power-on-delay", &tmp)) in ohci_pxa_of_init()
371 pdata->power_on_delay = tmp; in ohci_pxa_of_init()
372 if (!of_property_read_u32(np, "marvell,port-mode", &tmp)) in ohci_pxa_of_init()
373 pdata->port_mode = tmp; in ohci_pxa_of_init()
374 if (!of_property_read_u32(np, "marvell,power-budget", &tmp)) in ohci_pxa_of_init()
375 pdata->power_budget = tmp; in ohci_pxa_of_init()
377 pdev->dev.platform_data = pdata; in ohci_pxa_of_init()
388 /*-------------------------------------------------------------------------*/
395 * ohci_hcd_pxa27x_probe - initialize pxa27x-based HCDs
419 inf = dev_get_platdata(&pdev->dev); in ohci_hcd_pxa27x_probe()
422 return -ENODEV; in ohci_hcd_pxa27x_probe()
430 usb_clk = devm_clk_get(&pdev->dev, NULL); in ohci_hcd_pxa27x_probe()
434 hcd = usb_create_hcd(&ohci_pxa27x_hc_driver, &pdev->dev, "pxa27x"); in ohci_hcd_pxa27x_probe()
436 return -ENOMEM; in ohci_hcd_pxa27x_probe()
438 hcd->regs = devm_platform_get_and_ioremap_resource(pdev, 0, &r); in ohci_hcd_pxa27x_probe()
439 if (IS_ERR(hcd->regs)) { in ohci_hcd_pxa27x_probe()
440 retval = PTR_ERR(hcd->regs); in ohci_hcd_pxa27x_probe()
443 hcd->rsrc_start = r->start; in ohci_hcd_pxa27x_probe()
444 hcd->rsrc_len = resource_size(r); in ohci_hcd_pxa27x_probe()
448 pxa_ohci->clk = usb_clk; in ohci_hcd_pxa27x_probe()
449 pxa_ohci->mmio_base = (void __iomem *)hcd->regs; in ohci_hcd_pxa27x_probe()
454 if (!(inf->flags & (ENABLE_PORT1 << i))) in ohci_hcd_pxa27x_probe()
458 pxa_ohci->vbus[i] = devm_regulator_get(&pdev->dev, name); in ohci_hcd_pxa27x_probe()
461 retval = pxa27x_start_hc(pxa_ohci, &pdev->dev); in ohci_hcd_pxa27x_probe()
468 pxa27x_ohci_select_pmm(pxa_ohci, inf->port_mode); in ohci_hcd_pxa27x_probe()
470 if (inf->power_budget) in ohci_hcd_pxa27x_probe()
471 hcd->power_budget = inf->power_budget; in ohci_hcd_pxa27x_probe()
475 ohci->num_ports = 3; in ohci_hcd_pxa27x_probe()
479 device_wakeup_enable(hcd->self.controller); in ohci_hcd_pxa27x_probe()
483 pxa27x_stop_hc(pxa_ohci, &pdev->dev); in ohci_hcd_pxa27x_probe()
494 * ohci_hcd_pxa27x_remove - shutdown processing for pxa27x-based HCDs
510 pxa27x_stop_hc(pxa_ohci, &pdev->dev); in ohci_hcd_pxa27x_remove()
518 /*-------------------------------------------------------------------------*/
530 if (time_before(jiffies, ohci->next_statechange)) in ohci_hcd_pxa27x_drv_suspend()
532 ohci->next_statechange = jiffies; in ohci_hcd_pxa27x_drv_suspend()
550 if (time_before(jiffies, ohci->next_statechange)) in ohci_hcd_pxa27x_drv_resume()
552 ohci->next_statechange = jiffies; in ohci_hcd_pxa27x_drv_resume()
559 pxa27x_ohci_select_pmm(pxa_ohci, inf->port_mode); in ohci_hcd_pxa27x_drv_resume()
576 .name = "pxa27x-ohci",
591 return -ENODEV; in ohci_pxa27x_init()
608 MODULE_ALIAS("platform:pxa27x-ohci");