22 #include <linux/device.h>
23 #include <linux/signal.h>
28 #include <mach/hardware.h>
35 #define UHCREV (0x0000)
36 #define UHCHCON (0x0004)
37 #define UHCCOMS (0x0008)
38 #define UHCINTS (0x000C)
39 #define UHCINTE (0x0010)
40 #define UHCINTD (0x0014)
41 #define UHCHCCA (0x0018)
42 #define UHCPCED (0x001C)
43 #define UHCCHED (0x0020)
44 #define UHCCCED (0x0024)
45 #define UHCBHED (0x0028)
46 #define UHCBCED (0x002C)
47 #define UHCDHEAD (0x0030)
48 #define UHCFMI (0x0034)
49 #define UHCFMR (0x0038)
50 #define UHCFMN (0x003C)
51 #define UHCPERS (0x0040)
52 #define UHCLS (0x0044)
54 #define UHCRHDA (0x0048)
55 #define UHCRHDA_NOCP (1 << 12)
56 #define UHCRHDA_OCPM (1 << 11)
57 #define UHCRHDA_POTPGT(x) \
60 #define UHCRHDB (0x004C)
61 #define UHCRHS (0x0050)
62 #define UHCRHPS1 (0x0054)
63 #define UHCRHPS2 (0x0058)
64 #define UHCRHPS3 (0x005C)
66 #define UHCSTAT (0x0060)
67 #define UHCSTAT_UPS3 (1 << 16)
68 #define UHCSTAT_SBMAI (1 << 15)
69 #define UHCSTAT_SBTAI (1 << 14)
70 #define UHCSTAT_UPRI (1 << 13)
71 #define UHCSTAT_UPS2 (1 << 12)
72 #define UHCSTAT_UPS1 (1 << 11)
73 #define UHCSTAT_HTA (1 << 10)
74 #define UHCSTAT_HBA (1 << 8)
75 #define UHCSTAT_RWUE (1 << 7)
77 #define UHCHR (0x0064)
78 #define UHCHR_SSEP3 (1 << 11)
79 #define UHCHR_SSEP2 (1 << 10)
80 #define UHCHR_SSEP1 (1 << 9)
81 #define UHCHR_PCPL (1 << 7)
82 #define UHCHR_PSPL (1 << 6)
83 #define UHCHR_SSE (1 << 5)
84 #define UHCHR_UIT (1 << 4)
85 #define UHCHR_SSDC (1 << 3)
86 #define UHCHR_CGR (1 << 2)
87 #define UHCHR_FHR (1 << 1)
88 #define UHCHR_FSBIR (1 << 0)
90 #define UHCHIE (0x0068)
91 #define UHCHIE_UPS3IE (1 << 14)
92 #define UHCHIE_UPRIE (1 << 13)
93 #define UHCHIE_UPS2IE (1 << 12)
94 #define UHCHIE_UPS1IE (1 << 11)
95 #define UHCHIE_TAIE (1 << 10)
97 #define UHCHIE_HBAIE (1 << 8)
98 #define UHCHIE_RWIE (1 << 7)
100 #define UHCHIT (0x006C)
102 #define PXA_UHC_MAX_PORTNUM 3
113 #define to_pxa27x_ohci(hcd) (struct pxa27x_ohci *)hcd_to_ohci(hcd)
142 uhcrhdb |= (0x7<<17);
146 "Invalid mode %d, set to non-power switch mode.\n",
201 static inline void pxa27x_reset_hc(
struct pxa27x_ohci *ohci)
213 #define pxa27x_clear_otgph() do {} while (0)
224 clk_prepare_enable(ohci->
clk);
226 pxa27x_reset_hc(ohci);
234 pxa27x_setup_hc(ohci, inf);
237 retval = inf->
init(dev);
267 pxa27x_reset_hc(ohci);
274 clk_disable_unprepare(ohci->
clk);
300 if (!pdev->
dev.dma_mask)
301 pdev->
dev.dma_mask = &pxa_ohci_dma_mask;
321 if (!of_property_read_u32(np,
"marvell,power-on-delay", &tmp))
323 if (!of_property_read_u32(np,
"marvell,port-mode", &tmp))
325 if (!of_property_read_u32(np,
"marvell,power-budget", &tmp))
363 retval = ohci_pxa_of_init(pdev);
367 inf = pdev->
dev.platform_data;
374 pr_err(
"no resource of IORESOURCE_IRQ");
380 return PTR_ERR(usb_clk);
390 pr_err(
"no resource of IORESOURCE_MEM");
395 hcd->rsrc_start = r->
start;
396 hcd->rsrc_len = resource_size(r);
399 pr_debug(
"request_mem_region failed");
404 hcd->regs =
ioremap(hcd->rsrc_start, hcd->rsrc_len);
417 if ((retval = pxa27x_start_hc(ohci, &pdev->
dev)) < 0) {
423 pxa27x_ohci_select_pmm(ohci, inf->
port_mode);
428 ohci_hcd_init(hcd_to_ohci(hcd));
434 pxa27x_stop_hc(ohci, &pdev->
dev);
465 pxa27x_stop_hc(ohci, &pdev->
dev);
475 ohci_pxa27x_start (
struct usb_hcd *hcd)
477 struct ohci_hcd *ohci = hcd_to_ohci (hcd);
480 ohci_dbg (ohci,
"ohci_pxa27x_start, ohci:%p", ohci);
485 if ((ret = ohci_init(ohci)) < 0)
488 if ((ret = ohci_run (ohci)) < 0) {
489 dev_err(hcd->self.controller,
"can't start %s",
500 static const struct hc_driver ohci_pxa27x_hc_driver = {
501 .description = hcd_name,
502 .product_desc =
"PXA27x OHCI",
509 .flags = HCD_USB11 | HCD_MEMORY,
514 .start = ohci_pxa27x_start,
516 .shutdown = ohci_shutdown,
521 .urb_enqueue = ohci_urb_enqueue,
522 .urb_dequeue = ohci_urb_dequeue,
523 .endpoint_disable = ohci_endpoint_disable,
528 .get_frame_number = ohci_get_frame,
533 .hub_status_data = ohci_hub_status_data,
534 .hub_control = ohci_hub_control,
536 .bus_suspend = ohci_bus_suspend,
537 .bus_resume = ohci_bus_resume,
546 pr_debug (
"In ohci_hcd_pxa27x_drv_probe");
556 struct usb_hcd *hcd = platform_get_drvdata(pdev);
559 platform_set_drvdata(pdev,
NULL);
564 static int ohci_hcd_pxa27x_drv_suspend(
struct device *dev)
573 pxa27x_stop_hc(ohci, dev);
577 static int ohci_hcd_pxa27x_drv_resume(
struct device *dev)
588 if ((status = pxa27x_start_hc(ohci, dev)) < 0)
592 pxa27x_ohci_select_pmm(ohci, inf->
port_mode);
594 ohci_finish_controller_resume(hcd);
598 static const struct dev_pm_ops ohci_hcd_pxa27x_pm_ops = {
599 .
suspend = ohci_hcd_pxa27x_drv_suspend,
600 .resume = ohci_hcd_pxa27x_drv_resume,
608 .probe = ohci_hcd_pxa27x_drv_probe,
609 .remove = ohci_hcd_pxa27x_drv_remove,
612 .name =
"pxa27x-ohci",
616 .pm = &ohci_hcd_pxa27x_pm_ops,