aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorWan ZongShun <mcuos.com@gmail.com>2009-06-12 21:14:28 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-09-23 09:46:20 -0400
commit586dfc8cafc25cf785332fdfe9530f392e26f30d (patch)
tree25d20588dffab4d257cedd33bc7e4d583f2fb527 /drivers
parentb95cd7ec3e93bae199e820bd65b21b23e4538acc (diff)
USB: Add nuvoton Ehci driver for w90p910 platform
Add ehci support for w90p910 platform. Signed-off-by: Wan ZongShun <mcuos.com@gmail.com> Cc: David Brownell <david-b@pacbell.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/usb/Kconfig2
-rw-r--r--drivers/usb/host/Kconfig6
-rw-r--r--drivers/usb/host/ehci-hcd.c5
-rw-r--r--drivers/usb/host/ehci-w90x900.c181
4 files changed, 194 insertions, 0 deletions
diff --git a/drivers/usb/Kconfig b/drivers/usb/Kconfig
index dcd49f1e96d0..93cee3e5ca58 100644
--- a/drivers/usb/Kconfig
+++ b/drivers/usb/Kconfig
@@ -39,6 +39,7 @@ config USB_ARCH_HAS_OHCI
39 default y if ARCH_AT91 39 default y if ARCH_AT91
40 default y if ARCH_PNX4008 && I2C 40 default y if ARCH_PNX4008 && I2C
41 default y if MFD_TC6393XB 41 default y if MFD_TC6393XB
42 default y if ARCH_W90X900
42 # PPC: 43 # PPC:
43 default y if STB03xxx 44 default y if STB03xxx
44 default y if PPC_MPC52xx 45 default y if PPC_MPC52xx
@@ -58,6 +59,7 @@ config USB_ARCH_HAS_EHCI
58 default y if PPC_83xx 59 default y if PPC_83xx
59 default y if SOC_AU1200 60 default y if SOC_AU1200
60 default y if ARCH_IXP4XX 61 default y if ARCH_IXP4XX
62 default y if ARCH_W90X900
61 default PCI 63 default PCI
62 64
63# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface. 65# ARM SA1111 chips have a non-PCI based "OHCI-compatible" USB host interface.
diff --git a/drivers/usb/host/Kconfig b/drivers/usb/host/Kconfig
index f21ca7d27a43..41b8d7de2e07 100644
--- a/drivers/usb/host/Kconfig
+++ b/drivers/usb/host/Kconfig
@@ -113,6 +113,12 @@ config USB_EHCI_HCD_PPC_OF
113 Enables support for the USB controller present on the PowerPC 113 Enables support for the USB controller present on the PowerPC
114 OpenFirmware platform bus. 114 OpenFirmware platform bus.
115 115
116config USB_W90X900_EHCI
117 bool "W90X900(W90P910) EHCI support"
118 depends on USB_EHCI_HCD && ARCH_W90X900
119 ---help---
120 Enables support for the W90X900 USB controller
121
116config USB_OXU210HP_HCD 122config USB_OXU210HP_HCD
117 tristate "OXU210HP HCD support" 123 tristate "OXU210HP HCD support"
118 depends on USB 124 depends on USB
diff --git a/drivers/usb/host/ehci-hcd.c b/drivers/usb/host/ehci-hcd.c
index 11c627ce6022..54715b875759 100644
--- a/drivers/usb/host/ehci-hcd.c
+++ b/drivers/usb/host/ehci-hcd.c
@@ -1117,6 +1117,11 @@ MODULE_LICENSE ("GPL");
1117#define PLATFORM_DRIVER ixp4xx_ehci_driver 1117#define PLATFORM_DRIVER ixp4xx_ehci_driver
1118#endif 1118#endif
1119 1119
1120#ifdef CONFIG_USB_W90X900_EHCI
1121#include "ehci-w90x900.c"
1122#define PLATFORM_DRIVER ehci_hcd_w90x900_driver
1123#endif
1124
1120#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \ 1125#if !defined(PCI_DRIVER) && !defined(PLATFORM_DRIVER) && \
1121 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER) 1126 !defined(PS3_SYSTEM_BUS_DRIVER) && !defined(OF_PLATFORM_DRIVER)
1122#error "missing bus glue for ehci-hcd" 1127#error "missing bus glue for ehci-hcd"
diff --git a/drivers/usb/host/ehci-w90x900.c b/drivers/usb/host/ehci-w90x900.c
new file mode 100644
index 000000000000..cfa21ea20f82
--- /dev/null
+++ b/drivers/usb/host/ehci-w90x900.c
@@ -0,0 +1,181 @@
1/*
2 * linux/driver/usb/host/ehci-w90x900.c
3 *
4 * Copyright (c) 2008 Nuvoton technology corporation.
5 *
6 * Wan ZongShun <mcuos.com@gmail.com>
7 *
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation;version 2 of the License.
11 *
12 */
13
14#include <linux/platform_device.h>
15
16/*ebable phy0 and phy1 for w90p910*/
17#define ENPHY (0x01<<8)
18#define PHY0_CTR (0xA4)
19#define PHY1_CTR (0xA8)
20
21static int __devinit usb_w90x900_probe(const struct hc_driver *driver,
22 struct platform_device *pdev)
23{
24 struct usb_hcd *hcd;
25 struct ehci_hcd *ehci;
26 struct resource *res;
27 int retval = 0, irq;
28 unsigned long val;
29
30
31 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
32 if (!res) {
33 retval = -ENXIO;
34 goto err1;
35 }
36
37 hcd = usb_create_hcd(driver, &pdev->dev, "w90x900 EHCI");
38 if (!hcd) {
39 retval = -ENOMEM;
40 goto err1;
41 }
42
43 hcd->rsrc_start = res->start;
44 hcd->rsrc_len = res->end - res->start + 1;
45
46 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
47 retval = -EBUSY;
48 goto err2;
49 }
50
51 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
52 if (hcd->regs == NULL) {
53 retval = -EFAULT;
54 goto err3;
55 }
56
57 ehci = hcd_to_ehci(hcd);
58 ehci->caps = hcd->regs;
59 ehci->regs = hcd->regs +
60 HC_LENGTH(ehci_readl(ehci, &ehci->caps->hc_capbase));
61
62 /* enable PHY 0,1,the regs only apply to w90p910
63 * 0xA4,0xA8 were offsets of PHY0 and PHY1 controller of
64 * w90p910 IC relative to ehci->regs.
65 */
66 val = __raw_readl(ehci->regs+PHY0_CTR);
67 val |= ENPHY;
68 __raw_writel(val, ehci->regs+PHY0_CTR);
69
70 val = __raw_readl(ehci->regs+PHY1_CTR);
71 val |= ENPHY;
72 __raw_writel(val, ehci->regs+PHY1_CTR);
73
74 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
75 ehci->sbrn = 0x20;
76
77 irq = platform_get_irq(pdev, 0);
78 if (irq < 0)
79 goto err4;
80
81 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
82 if (retval != 0)
83 goto err4;
84
85 ehci_writel(ehci, 1, &ehci->regs->configured_flag);
86
87 return retval;
88err4:
89 iounmap(hcd->regs);
90err3:
91 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
92err2:
93 usb_put_hcd(hcd);
94err1:
95 return retval;
96}
97
98static
99void usb_w90x900_remove(struct usb_hcd *hcd, struct platform_device *pdev)
100{
101 usb_remove_hcd(hcd);
102 iounmap(hcd->regs);
103 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
104 usb_put_hcd(hcd);
105}
106
107static const struct hc_driver ehci_w90x900_hc_driver = {
108 .description = hcd_name,
109 .product_desc = "Nuvoton w90x900 EHCI Host Controller",
110 .hcd_priv_size = sizeof(struct ehci_hcd),
111
112 /*
113 * generic hardware linkage
114 */
115 .irq = ehci_irq,
116 .flags = HCD_USB2|HCD_MEMORY,
117
118 /*
119 * basic lifecycle operations
120 */
121 .reset = ehci_init,
122 .start = ehci_run,
123
124 .stop = ehci_stop,
125 .shutdown = ehci_shutdown,
126
127 /*
128 * managing i/o requests and associated device resources
129 */
130 .urb_enqueue = ehci_urb_enqueue,
131 .urb_dequeue = ehci_urb_dequeue,
132 .endpoint_disable = ehci_endpoint_disable,
133
134 /*
135 * scheduling support
136 */
137 .get_frame_number = ehci_get_frame,
138
139 /*
140 * root hub support
141 */
142 .hub_status_data = ehci_hub_status_data,
143 .hub_control = ehci_hub_control,
144#ifdef CONFIG_PM
145 .bus_suspend = ehci_bus_suspend,
146 .bus_resume = ehci_bus_resume,
147#endif
148 .relinquish_port = ehci_relinquish_port,
149 .port_handed_over = ehci_port_handed_over,
150};
151
152static int __devinit ehci_w90x900_probe(struct platform_device *pdev)
153{
154 if (usb_disabled())
155 return -ENODEV;
156
157 return usb_w90x900_probe(&ehci_w90x900_hc_driver, pdev);
158}
159
160static int __devexit ehci_w90x900_remove(struct platform_device *pdev)
161{
162 struct usb_hcd *hcd = platform_get_drvdata(pdev);
163
164 usb_w90x900_remove(hcd, pdev);
165
166 return 0;
167}
168
169static struct platform_driver ehci_hcd_w90x900_driver = {
170 .probe = ehci_w90x900_probe,
171 .remove = __devexit_p(ehci_w90x900_remove),
172 .driver = {
173 .name = "w90x900-ehci",
174 .owner = THIS_MODULE,
175 },
176};
177
178MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
179MODULE_DESCRIPTION("w90p910 usb ehci driver!");
180MODULE_LICENSE("GPL");
181MODULE_ALIAS("platform:w90p910-ehci");