aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/host
diff options
context:
space:
mode:
authorManuel Lauss <mano@roarinelk.homelinux.net>2008-06-23 03:08:29 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2008-07-21 18:16:44 -0400
commit53c81a348fa1d21dd042d9c9a9f91795f83fed66 (patch)
treec4be28f2bf245dabf9031a3ef56e7d56f27630bb /drivers/usb/host
parente04199b2167e88f0e2d0410fafaa2c35ff7ba8c1 (diff)
USB: Au1xxx-usb: clean up ohci/ehci bus glue sources.
- Fold multiple probe/remove callbacks into one function; - minor style fixes, no functional changes. Tested on Au1200. Signed-off-by: Manuel Lauss <mano@roarinelk.homelinux.net> Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/usb/host')
-rw-r--r--drivers/usb/host/ehci-au1xxx.c276
-rw-r--r--drivers/usb/host/ohci-au1xxx.c268
2 files changed, 210 insertions, 334 deletions
diff --git a/drivers/usb/host/ehci-au1xxx.c b/drivers/usb/host/ehci-au1xxx.c
index 08a4335401a9..12ed80684ad1 100644
--- a/drivers/usb/host/ehci-au1xxx.c
+++ b/drivers/usb/host/ehci-au1xxx.c
@@ -19,236 +19,179 @@
19#define USB_MCFG_RDCOMB (1<<30) 19#define USB_MCFG_RDCOMB (1<<30)
20#define USB_MCFG_SSDEN (1<<23) 20#define USB_MCFG_SSDEN (1<<23)
21#define USB_MCFG_PHYPLLEN (1<<19) 21#define USB_MCFG_PHYPLLEN (1<<19)
22#define USB_MCFG_UCECLKEN (1<<18)
22#define USB_MCFG_EHCCLKEN (1<<17) 23#define USB_MCFG_EHCCLKEN (1<<17)
24#ifdef CONFIG_DMA_COHERENT
23#define USB_MCFG_UCAM (1<<7) 25#define USB_MCFG_UCAM (1<<7)
26#else
27#define USB_MCFG_UCAM (0)
28#endif
24#define USB_MCFG_EBMEN (1<<3) 29#define USB_MCFG_EBMEN (1<<3)
25#define USB_MCFG_EMEMEN (1<<2) 30#define USB_MCFG_EMEMEN (1<<2)
26 31
27#define USBH_ENABLE_CE (USB_MCFG_PHYPLLEN | USB_MCFG_EHCCLKEN) 32#define USBH_ENABLE_CE (USB_MCFG_PHYPLLEN | USB_MCFG_EHCCLKEN)
33#define USBH_ENABLE_INIT (USB_MCFG_PFEN | USB_MCFG_RDCOMB | \
34 USBH_ENABLE_CE | USB_MCFG_SSDEN | \
35 USB_MCFG_UCAM | USB_MCFG_EBMEN | \
36 USB_MCFG_EMEMEN)
28 37
29#ifdef CONFIG_DMA_COHERENT
30#define USBH_ENABLE_INIT (USBH_ENABLE_CE \
31 | USB_MCFG_PFEN | USB_MCFG_RDCOMB \
32 | USB_MCFG_SSDEN | USB_MCFG_UCAM \
33 | USB_MCFG_EBMEN | USB_MCFG_EMEMEN)
34#else
35#define USBH_ENABLE_INIT (USBH_ENABLE_CE \
36 | USB_MCFG_PFEN | USB_MCFG_RDCOMB \
37 | USB_MCFG_SSDEN \
38 | USB_MCFG_EBMEN | USB_MCFG_EMEMEN)
39#endif
40#define USBH_DISABLE (USB_MCFG_EBMEN | USB_MCFG_EMEMEN) 38#define USBH_DISABLE (USB_MCFG_EBMEN | USB_MCFG_EMEMEN)
41 39
42extern int usb_disabled(void); 40extern int usb_disabled(void);
43 41
44/*-------------------------------------------------------------------------*/ 42static void au1xxx_start_ehc(void)
45
46static void au1xxx_start_ehc(struct platform_device *dev)
47{ 43{
48 pr_debug(__FILE__ ": starting Au1xxx EHCI USB Controller\n"); 44 /* enable clock to EHCI block and HS PHY PLL*/
49 45 au_writel(au_readl(USB_HOST_CONFIG) | USBH_ENABLE_CE, USB_HOST_CONFIG);
50 /* write HW defaults again in case Yamon cleared them */ 46 au_sync();
51 if (au_readl(USB_HOST_CONFIG) == 0) {
52 au_writel(0x00d02000, USB_HOST_CONFIG);
53 au_readl(USB_HOST_CONFIG);
54 udelay(1000);
55 }
56 /* enable host controller */
57 au_writel(USBH_ENABLE_CE | au_readl(USB_HOST_CONFIG), USB_HOST_CONFIG);
58 au_readl(USB_HOST_CONFIG);
59 udelay(1000);
60 au_writel(USBH_ENABLE_INIT | au_readl(USB_HOST_CONFIG),
61 USB_HOST_CONFIG);
62 au_readl(USB_HOST_CONFIG);
63 udelay(1000); 47 udelay(1000);
64 48
65 pr_debug(__FILE__ ": Clock to USB host has been enabled\n"); 49 /* enable EHCI mmio */
50 au_writel(au_readl(USB_HOST_CONFIG) | USBH_ENABLE_INIT, USB_HOST_CONFIG);
51 au_sync();
52 udelay(1000);
66} 53}
67 54
68static void au1xxx_stop_ehc(struct platform_device *dev) 55static void au1xxx_stop_ehc(void)
69{ 56{
70 pr_debug(__FILE__ ": stopping Au1xxx EHCI USB Controller\n"); 57 unsigned long c;
71 58
72 /* Disable mem */ 59 /* Disable mem */
73 au_writel(~USBH_DISABLE & au_readl(USB_HOST_CONFIG), USB_HOST_CONFIG); 60 au_writel(au_readl(USB_HOST_CONFIG) & ~USBH_DISABLE, USB_HOST_CONFIG);
61 au_sync();
74 udelay(1000); 62 udelay(1000);
75 /* Disable clock */ 63
76 au_writel(~USB_MCFG_EHCCLKEN & au_readl(USB_HOST_CONFIG), 64 /* Disable EHC clock. If the HS PHY is unused disable it too. */
77 USB_HOST_CONFIG); 65 c = au_readl(USB_HOST_CONFIG) & ~USB_MCFG_EHCCLKEN;
78 au_readl(USB_HOST_CONFIG); 66 if (!(c & USB_MCFG_UCECLKEN)) /* UDC disabled? */
67 c &= ~USB_MCFG_PHYPLLEN; /* yes: disable HS PHY PLL */
68 au_writel(c, USB_HOST_CONFIG);
69 au_sync();
79} 70}
80 71
81/*-------------------------------------------------------------------------*/ 72static const struct hc_driver ehci_au1xxx_hc_driver = {
73 .description = hcd_name,
74 .product_desc = "Au1xxx EHCI",
75 .hcd_priv_size = sizeof(struct ehci_hcd),
82 76
83/* configure so an HC device and id are always provided */ 77 /*
84/* always called with process context; sleeping is OK */ 78 * generic hardware linkage
79 */
80 .irq = ehci_irq,
81 .flags = HCD_MEMORY | HCD_USB2,
85 82
86/** 83 /*
87 * usb_ehci_au1xxx_probe - initialize Au1xxx-based HCDs 84 * basic lifecycle operations
88 * Context: !in_interrupt() 85 *
89 * 86 * FIXME -- ehci_init() doesn't do enough here.
90 * Allocates basic resources for this USB host controller, and 87 * See ehci-ppc-soc for a complete implementation.
91 * then invokes the start() method for the HCD associated with it 88 */
92 * through the hotplug entry's driver_data. 89 .reset = ehci_init,
93 * 90 .start = ehci_run,
94 */ 91 .stop = ehci_stop,
95int usb_ehci_au1xxx_probe(const struct hc_driver *driver, 92 .shutdown = ehci_shutdown,
96 struct usb_hcd **hcd_out, struct platform_device *dev) 93
94 /*
95 * managing i/o requests and associated device resources
96 */
97 .urb_enqueue = ehci_urb_enqueue,
98 .urb_dequeue = ehci_urb_dequeue,
99 .endpoint_disable = ehci_endpoint_disable,
100
101 /*
102 * scheduling support
103 */
104 .get_frame_number = ehci_get_frame,
105
106 /*
107 * root hub support
108 */
109 .hub_status_data = ehci_hub_status_data,
110 .hub_control = ehci_hub_control,
111 .bus_suspend = ehci_bus_suspend,
112 .bus_resume = ehci_bus_resume,
113 .relinquish_port = ehci_relinquish_port,
114 .port_handed_over = ehci_port_handed_over,
115};
116
117static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
97{ 118{
98 int retval;
99 struct usb_hcd *hcd; 119 struct usb_hcd *hcd;
100 struct ehci_hcd *ehci; 120 struct ehci_hcd *ehci;
121 int ret;
101 122
102#if defined(CONFIG_SOC_AU1200) && defined(CONFIG_DMA_COHERENT) 123 if (usb_disabled())
124 return -ENODEV;
103 125
126#if defined(CONFIG_SOC_AU1200) && defined(CONFIG_DMA_COHERENT)
104 /* Au1200 AB USB does not support coherent memory */ 127 /* Au1200 AB USB does not support coherent memory */
105 if (!(read_c0_prid() & 0xff)) { 128 if (!(read_c0_prid() & 0xff)) {
106 pr_info("%s: this is chip revision AB!\n", dev->name); 129 printk(KERN_INFO "%s: this is chip revision AB!\n", pdev->name);
107 pr_info("%s: update your board or re-configure the kernel\n", 130 printk(KERN_INFO "%s: update your board or re-configure"
108 dev->name); 131 " the kernel\n", pdev->name);
109 return -ENODEV; 132 return -ENODEV;
110 } 133 }
111#endif 134#endif
112 135
113 au1xxx_start_ehc(dev); 136 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
114
115 if (dev->resource[1].flags != IORESOURCE_IRQ) {
116 pr_debug("resource[1] is not IORESOURCE_IRQ"); 137 pr_debug("resource[1] is not IORESOURCE_IRQ");
117 retval = -ENOMEM; 138 return -ENOMEM;
118 } 139 }
119 hcd = usb_create_hcd(driver, &dev->dev, "Au1xxx"); 140 hcd = usb_create_hcd(&ehci_au1xxx_hc_driver, &pdev->dev, "Au1xxx");
120 if (!hcd) 141 if (!hcd)
121 return -ENOMEM; 142 return -ENOMEM;
122 hcd->rsrc_start = dev->resource[0].start; 143
123 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1; 144 hcd->rsrc_start = pdev->resource[0].start;
145 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
124 146
125 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) { 147 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
126 pr_debug("request_mem_region failed"); 148 pr_debug("request_mem_region failed");
127 retval = -EBUSY; 149 ret = -EBUSY;
128 goto err1; 150 goto err1;
129 } 151 }
130 152
131 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len); 153 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
132 if (!hcd->regs) { 154 if (!hcd->regs) {
133 pr_debug("ioremap failed"); 155 pr_debug("ioremap failed");
134 retval = -ENOMEM; 156 ret = -ENOMEM;
135 goto err2; 157 goto err2;
136 } 158 }
137 159
160 au1xxx_start_ehc();
161
138 ehci = hcd_to_ehci(hcd); 162 ehci = hcd_to_ehci(hcd);
139 ehci->caps = hcd->regs; 163 ehci->caps = hcd->regs;
140 ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase)); 164 ehci->regs = hcd->regs + HC_LENGTH(readl(&ehci->caps->hc_capbase));
141 /* cache this readonly data; minimize chip reads */ 165 /* cache this readonly data; minimize chip reads */
142 ehci->hcs_params = readl(&ehci->caps->hcs_params); 166 ehci->hcs_params = readl(&ehci->caps->hcs_params);
143 167
144 /* ehci_hcd_init(hcd_to_ehci(hcd)); */ 168 ret = usb_add_hcd(hcd, pdev->resource[1].start,
145 169 IRQF_DISABLED | IRQF_SHARED);
146 retval = 170 if (ret == 0) {
147 usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED | IRQF_SHARED); 171 platform_set_drvdata(pdev, hcd);
148 if (retval == 0) 172 return ret;
149 return retval; 173 }
150 174
151 au1xxx_stop_ehc(dev); 175 au1xxx_stop_ehc();
152 iounmap(hcd->regs); 176 iounmap(hcd->regs);
153err2: 177err2:
154 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 178 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
155err1: 179err1:
156 usb_put_hcd(hcd); 180 usb_put_hcd(hcd);
157 return retval; 181 return ret;
158} 182}
159 183
160/* may be called without controller electrically present */ 184static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
161/* may be called with controller, bus, and devices active */
162
163/**
164 * usb_ehci_hcd_au1xxx_remove - shutdown processing for Au1xxx-based HCDs
165 * @dev: USB Host Controller being removed
166 * Context: !in_interrupt()
167 *
168 * Reverses the effect of usb_ehci_hcd_au1xxx_probe(), first invoking
169 * the HCD's stop() method. It is always called from a thread
170 * context, normally "rmmod", "apmd", or something similar.
171 *
172 */
173void usb_ehci_au1xxx_remove(struct usb_hcd *hcd, struct platform_device *dev)
174{ 185{
186 struct usb_hcd *hcd = platform_get_drvdata(pdev);
187
175 usb_remove_hcd(hcd); 188 usb_remove_hcd(hcd);
176 iounmap(hcd->regs); 189 iounmap(hcd->regs);
177 release_mem_region(hcd->rsrc_start, hcd->rsrc_len); 190 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
178 usb_put_hcd(hcd); 191 usb_put_hcd(hcd);
179 au1xxx_stop_ehc(dev); 192 au1xxx_stop_ehc();
180} 193 platform_set_drvdata(pdev, NULL);
181
182/*-------------------------------------------------------------------------*/
183 194
184static const struct hc_driver ehci_au1xxx_hc_driver = {
185 .description = hcd_name,
186 .product_desc = "Au1xxx EHCI",
187 .hcd_priv_size = sizeof(struct ehci_hcd),
188
189 /*
190 * generic hardware linkage
191 */
192 .irq = ehci_irq,
193 .flags = HCD_MEMORY | HCD_USB2,
194
195 /*
196 * basic lifecycle operations
197 *
198 * FIXME -- ehci_init() doesn't do enough here.
199 * See ehci-ppc-soc for a complete implementation.
200 */
201 .reset = ehci_init,
202 .start = ehci_run,
203 .stop = ehci_stop,
204 .shutdown = ehci_shutdown,
205
206 /*
207 * managing i/o requests and associated device resources
208 */
209 .urb_enqueue = ehci_urb_enqueue,
210 .urb_dequeue = ehci_urb_dequeue,
211 .endpoint_disable = ehci_endpoint_disable,
212
213 /*
214 * scheduling support
215 */
216 .get_frame_number = ehci_get_frame,
217
218 /*
219 * root hub support
220 */
221 .hub_status_data = ehci_hub_status_data,
222 .hub_control = ehci_hub_control,
223 .bus_suspend = ehci_bus_suspend,
224 .bus_resume = ehci_bus_resume,
225 .relinquish_port = ehci_relinquish_port,
226 .port_handed_over = ehci_port_handed_over,
227};
228
229/*-------------------------------------------------------------------------*/
230
231static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
232{
233 struct usb_hcd *hcd = NULL;
234 int ret;
235
236 pr_debug("In ehci_hcd_au1xxx_drv_probe\n");
237
238 if (usb_disabled())
239 return -ENODEV;
240
241 /* FIXME we only want one one probe() not two */
242 ret = usb_ehci_au1xxx_probe(&ehci_au1xxx_hc_driver, &hcd, pdev);
243 return ret;
244}
245
246static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
247{
248 struct usb_hcd *hcd = platform_get_drvdata(pdev);
249
250 /* FIXME we only want one one remove() not two */
251 usb_ehci_au1xxx_remove(hcd, pdev);
252 return 0; 195 return 0;
253} 196}
254 197
@@ -268,14 +211,17 @@ static int ehci_hcd_au1xxx_drv_resume(struct device *dev)
268 return 0; 211 return 0;
269} 212}
270*/ 213*/
271MODULE_ALIAS("platform:au1xxx-ehci"); 214
272static struct platform_driver ehci_hcd_au1xxx_driver = { 215static struct platform_driver ehci_hcd_au1xxx_driver = {
273 .probe = ehci_hcd_au1xxx_drv_probe, 216 .probe = ehci_hcd_au1xxx_drv_probe,
274 .remove = ehci_hcd_au1xxx_drv_remove, 217 .remove = ehci_hcd_au1xxx_drv_remove,
275 .shutdown = usb_hcd_platform_shutdown, 218 .shutdown = usb_hcd_platform_shutdown,
276 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */ 219 /*.suspend = ehci_hcd_au1xxx_drv_suspend, */
277 /*.resume = ehci_hcd_au1xxx_drv_resume, */ 220 /*.resume = ehci_hcd_au1xxx_drv_resume, */
278 .driver = { 221 .driver = {
279 .name = "au1xxx-ehci", 222 .name = "au1xxx-ehci",
223 .owner = THIS_MODULE,
280 } 224 }
281}; 225};
226
227MODULE_ALIAS("platform:au1xxx-ehci");
diff --git a/drivers/usb/host/ohci-au1xxx.c b/drivers/usb/host/ohci-au1xxx.c
index 68c17f5ea8ea..29c970ad487a 100644
--- a/drivers/usb/host/ohci-au1xxx.c
+++ b/drivers/usb/host/ohci-au1xxx.c
@@ -34,7 +34,8 @@
34#ifdef __LITTLE_ENDIAN 34#ifdef __LITTLE_ENDIAN
35#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C) 35#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C)
36#elif __BIG_ENDIAN 36#elif __BIG_ENDIAN
37#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | USBH_ENABLE_BE) 37#define USBH_ENABLE_INIT (USBH_ENABLE_CE | USBH_ENABLE_E | USBH_ENABLE_C | \
38 USBH_ENABLE_BE)
38#else 39#else
39#error not byte order defined 40#error not byte order defined
40#endif 41#endif
@@ -46,213 +47,87 @@
46#define USB_MCFG_RDCOMB (1<<30) 47#define USB_MCFG_RDCOMB (1<<30)
47#define USB_MCFG_SSDEN (1<<23) 48#define USB_MCFG_SSDEN (1<<23)
48#define USB_MCFG_OHCCLKEN (1<<16) 49#define USB_MCFG_OHCCLKEN (1<<16)
50#ifdef CONFIG_DMA_COHERENT
49#define USB_MCFG_UCAM (1<<7) 51#define USB_MCFG_UCAM (1<<7)
52#else
53#define USB_MCFG_UCAM (0)
54#endif
50#define USB_MCFG_OBMEN (1<<1) 55#define USB_MCFG_OBMEN (1<<1)
51#define USB_MCFG_OMEMEN (1<<0) 56#define USB_MCFG_OMEMEN (1<<0)
52 57
53#define USBH_ENABLE_CE USB_MCFG_OHCCLKEN 58#define USBH_ENABLE_CE USB_MCFG_OHCCLKEN
54#ifdef CONFIG_DMA_COHERENT 59
55#define USBH_ENABLE_INIT (USB_MCFG_OHCCLKEN \ 60#define USBH_ENABLE_INIT (USB_MCFG_PFEN | USB_MCFG_RDCOMB | \
56 | USB_MCFG_PFEN | USB_MCFG_RDCOMB \ 61 USBH_ENABLE_CE | USB_MCFG_SSDEN | \
57 | USB_MCFG_SSDEN | USB_MCFG_UCAM \ 62 USB_MCFG_UCAM | \
58 | USB_MCFG_OBMEN | USB_MCFG_OMEMEN) 63 USB_MCFG_OBMEN | USB_MCFG_OMEMEN)
59#else 64
60#define USBH_ENABLE_INIT (USB_MCFG_OHCCLKEN \
61 | USB_MCFG_PFEN | USB_MCFG_RDCOMB \
62 | USB_MCFG_SSDEN \
63 | USB_MCFG_OBMEN | USB_MCFG_OMEMEN)
64#endif
65#define USBH_DISABLE (USB_MCFG_OBMEN | USB_MCFG_OMEMEN) 65#define USBH_DISABLE (USB_MCFG_OBMEN | USB_MCFG_OMEMEN)
66 66
67#endif /* Au1200 */ 67#endif /* Au1200 */
68 68
69extern int usb_disabled(void); 69extern int usb_disabled(void);
70 70
71/*-------------------------------------------------------------------------*/ 71static void au1xxx_start_ohc(void)
72
73static void au1xxx_start_ohc(struct platform_device *dev)
74{ 72{
75 printk(KERN_DEBUG __FILE__
76 ": starting Au1xxx OHCI USB Controller\n");
77
78 /* enable host controller */ 73 /* enable host controller */
79
80#ifndef CONFIG_SOC_AU1200 74#ifndef CONFIG_SOC_AU1200
81
82 au_writel(USBH_ENABLE_CE, USB_HOST_CONFIG); 75 au_writel(USBH_ENABLE_CE, USB_HOST_CONFIG);
83 udelay(1000); 76 au_sync();
84 au_writel(USBH_ENABLE_INIT, USB_HOST_CONFIG);
85 udelay(1000); 77 udelay(1000);
86 78
87#else /* Au1200 */ 79 au_writel(au_readl(USB_HOST_CONFIG) | USBH_ENABLE_INIT, USB_HOST_CONFIG);
88 80 au_sync();
89 /* write HW defaults again in case Yamon cleared them */
90 if (au_readl(USB_HOST_CONFIG) == 0) {
91 au_writel(0x00d02000, USB_HOST_CONFIG);
92 au_readl(USB_HOST_CONFIG);
93 udelay(1000);
94 }
95 au_writel(USBH_ENABLE_CE | au_readl(USB_HOST_CONFIG), USB_HOST_CONFIG);
96 au_readl(USB_HOST_CONFIG);
97 udelay(1000); 81 udelay(1000);
98 au_writel(USBH_ENABLE_INIT | au_readl(USB_HOST_CONFIG), USB_HOST_CONFIG);
99 au_readl(USB_HOST_CONFIG);
100 udelay(1000);
101
102#endif /* Au1200 */
103 82
104#ifndef CONFIG_SOC_AU1200
105 /* wait for reset complete (read register twice; see au1500 errata) */ 83 /* wait for reset complete (read register twice; see au1500 errata) */
106 while (au_readl(USB_HOST_CONFIG), 84 while (au_readl(USB_HOST_CONFIG),
107 !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD)) 85 !(au_readl(USB_HOST_CONFIG) & USBH_ENABLE_RD))
108#endif
109 udelay(1000); 86 udelay(1000);
110 87
111 printk(KERN_DEBUG __FILE__
112 ": Clock to USB host has been enabled \n");
113}
114
115static void au1xxx_stop_ohc(struct platform_device *dev)
116{
117 printk(KERN_DEBUG __FILE__
118 ": stopping Au1xxx OHCI USB Controller\n");
119
120#ifndef CONFIG_SOC_AU1200
121
122 /* Disable clock */
123 au_writel(au_readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
124
125#else /* Au1200 */ 88#else /* Au1200 */
126 89 au_writel(au_readl(USB_HOST_CONFIG) | USBH_ENABLE_CE, USB_HOST_CONFIG);
127 /* Disable mem */ 90 au_sync();
128 au_writel(~USBH_DISABLE & au_readl(USB_HOST_CONFIG), USB_HOST_CONFIG);
129 udelay(1000); 91 udelay(1000);
130 /* Disable clock */ 92
131 au_writel(~USBH_ENABLE_CE & au_readl(USB_HOST_CONFIG), USB_HOST_CONFIG); 93 au_writel(au_readl(USB_HOST_CONFIG) | USBH_ENABLE_INIT, USB_HOST_CONFIG);
132 au_readl(USB_HOST_CONFIG); 94 au_sync();
95 udelay(2000);
133#endif /* Au1200 */ 96#endif /* Au1200 */
134} 97}
135 98
136 99static void au1xxx_stop_ohc(void)
137/*-------------------------------------------------------------------------*/
138
139/* configure so an HC device and id are always provided */
140/* always called with process context; sleeping is OK */
141
142
143/**
144 * usb_ohci_au1xxx_probe - initialize Au1xxx-based HCDs
145 * Context: !in_interrupt()
146 *
147 * Allocates basic resources for this USB host controller, and
148 * then invokes the start() method for the HCD associated with it
149 * through the hotplug entry's driver_data.
150 *
151 */
152static int usb_ohci_au1xxx_probe(const struct hc_driver *driver,
153 struct platform_device *dev)
154{ 100{
155 int retval; 101#ifdef CONFIG_SOC_AU1200
156 struct usb_hcd *hcd; 102 /* Disable mem */
157 103 au_writel(au_readl(USB_HOST_CONFIG) & ~USBH_DISABLE, USB_HOST_CONFIG);
158#if defined(CONFIG_SOC_AU1200) && defined(CONFIG_DMA_COHERENT) 104 au_sync();
159 /* Au1200 AB USB does not support coherent memory */ 105 udelay(1000);
160 if (!(read_c0_prid() & 0xff)) {
161 pr_info("%s: this is chip revision AB !!\n",
162 dev->name);
163 pr_info("%s: update your board or re-configure the kernel\n",
164 dev->name);
165 return -ENODEV;
166 }
167#endif 106#endif
168 107 /* Disable clock */
169 if (dev->resource[1].flags != IORESOURCE_IRQ) { 108 au_writel(au_readl(USB_HOST_CONFIG) & ~USBH_ENABLE_CE, USB_HOST_CONFIG);
170 pr_debug("resource[1] is not IORESOURCE_IRQ\n"); 109 au_sync();
171 return -ENOMEM;
172 }
173
174 hcd = usb_create_hcd(driver, &dev->dev, "au1xxx");
175 if (!hcd)
176 return -ENOMEM;
177 hcd->rsrc_start = dev->resource[0].start;
178 hcd->rsrc_len = dev->resource[0].end - dev->resource[0].start + 1;
179
180 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
181 pr_debug("request_mem_region failed\n");
182 retval = -EBUSY;
183 goto err1;
184 }
185
186 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
187 if (!hcd->regs) {
188 pr_debug("ioremap failed\n");
189 retval = -ENOMEM;
190 goto err2;
191 }
192
193 au1xxx_start_ohc(dev);
194 ohci_hcd_init(hcd_to_ohci(hcd));
195
196 retval = usb_add_hcd(hcd, dev->resource[1].start, IRQF_DISABLED | IRQF_SHARED);
197 if (retval == 0)
198 return retval;
199
200 au1xxx_stop_ohc(dev);
201 iounmap(hcd->regs);
202 err2:
203 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
204 err1:
205 usb_put_hcd(hcd);
206 return retval;
207}
208
209
210/* may be called without controller electrically present */
211/* may be called with controller, bus, and devices active */
212
213/**
214 * usb_hcd_au1xxx_remove - shutdown processing for Au1xxx-based HCDs
215 * @dev: USB Host Controller being removed
216 * Context: !in_interrupt()
217 *
218 * Reverses the effect of usb_hcd_au1xxx_probe(), first invoking
219 * the HCD's stop() method. It is always called from a thread
220 * context, normally "rmmod", "apmd", or something similar.
221 *
222 */
223static void usb_ohci_au1xxx_remove(struct usb_hcd *hcd, struct platform_device *dev)
224{
225 usb_remove_hcd(hcd);
226 au1xxx_stop_ohc(dev);
227 iounmap(hcd->regs);
228 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
229 usb_put_hcd(hcd);
230} 110}
231 111
232/*-------------------------------------------------------------------------*/ 112static int __devinit ohci_au1xxx_start(struct usb_hcd *hcd)
233
234static int __devinit
235ohci_au1xxx_start (struct usb_hcd *hcd)
236{ 113{
237 struct ohci_hcd *ohci = hcd_to_ohci (hcd); 114 struct ohci_hcd *ohci = hcd_to_ohci(hcd);
238 int ret; 115 int ret;
239 116
240 ohci_dbg (ohci, "ohci_au1xxx_start, ohci:%p", ohci); 117 ohci_dbg(ohci, "ohci_au1xxx_start, ohci:%p", ohci);
241 118
242 if ((ret = ohci_init (ohci)) < 0) 119 if ((ret = ohci_init(ohci)) < 0)
243 return ret; 120 return ret;
244 121
245 if ((ret = ohci_run (ohci)) < 0) { 122 if ((ret = ohci_run(ohci)) < 0) {
246 err ("can't start %s", hcd->self.bus_name); 123 err ("can't start %s", hcd->self.bus_name);
247 ohci_stop (hcd); 124 ohci_stop(hcd);
248 return ret; 125 return ret;
249 } 126 }
250 127
251 return 0; 128 return 0;
252} 129}
253 130
254/*-------------------------------------------------------------------------*/
255
256static const struct hc_driver ohci_au1xxx_hc_driver = { 131static const struct hc_driver ohci_au1xxx_hc_driver = {
257 .description = hcd_name, 132 .description = hcd_name,
258 .product_desc = "Au1xxx OHCI", 133 .product_desc = "Au1xxx OHCI",
@@ -296,18 +171,66 @@ static const struct hc_driver ohci_au1xxx_hc_driver = {
296 .start_port_reset = ohci_start_port_reset, 171 .start_port_reset = ohci_start_port_reset,
297}; 172};
298 173
299/*-------------------------------------------------------------------------*/
300
301static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev) 174static int ohci_hcd_au1xxx_drv_probe(struct platform_device *pdev)
302{ 175{
303 int ret; 176 int ret;
304 177 struct usb_hcd *hcd;
305 pr_debug ("In ohci_hcd_au1xxx_drv_probe");
306 178
307 if (usb_disabled()) 179 if (usb_disabled())
308 return -ENODEV; 180 return -ENODEV;
309 181
310 ret = usb_ohci_au1xxx_probe(&ohci_au1xxx_hc_driver, pdev); 182#if defined(CONFIG_SOC_AU1200) && defined(CONFIG_DMA_COHERENT)
183 /* Au1200 AB USB does not support coherent memory */
184 if (!(read_c0_prid() & 0xff)) {
185 printk(KERN_INFO "%s: this is chip revision AB !!\n",
186 pdev->name);
187 printk(KERN_INFO "%s: update your board or re-configure "
188 "the kernel\n", pdev->name);
189 return -ENODEV;
190 }
191#endif
192
193 if (pdev->resource[1].flags != IORESOURCE_IRQ) {
194 pr_debug("resource[1] is not IORESOURCE_IRQ\n");
195 return -ENOMEM;
196 }
197
198 hcd = usb_create_hcd(&ohci_au1xxx_hc_driver, &pdev->dev, "au1xxx");
199 if (!hcd)
200 return -ENOMEM;
201
202 hcd->rsrc_start = pdev->resource[0].start;
203 hcd->rsrc_len = pdev->resource[0].end - pdev->resource[0].start + 1;
204
205 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
206 pr_debug("request_mem_region failed\n");
207 ret = -EBUSY;
208 goto err1;
209 }
210
211 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
212 if (!hcd->regs) {
213 pr_debug("ioremap failed\n");
214 ret = -ENOMEM;
215 goto err2;
216 }
217
218 au1xxx_start_ohc();
219 ohci_hcd_init(hcd_to_ohci(hcd));
220
221 ret = usb_add_hcd(hcd, pdev->resource[1].start,
222 IRQF_DISABLED | IRQF_SHARED);
223 if (ret == 0) {
224 platform_set_drvdata(pdev, hcd);
225 return ret;
226 }
227
228 au1xxx_stop_ohc();
229 iounmap(hcd->regs);
230err2:
231 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
232err1:
233 usb_put_hcd(hcd);
311 return ret; 234 return ret;
312} 235}
313 236
@@ -315,9 +238,16 @@ static int ohci_hcd_au1xxx_drv_remove(struct platform_device *pdev)
315{ 238{
316 struct usb_hcd *hcd = platform_get_drvdata(pdev); 239 struct usb_hcd *hcd = platform_get_drvdata(pdev);
317 240
318 usb_ohci_au1xxx_remove(hcd, pdev); 241 usb_remove_hcd(hcd);
242 au1xxx_stop_ohc();
243 iounmap(hcd->regs);
244 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
245 usb_put_hcd(hcd);
246 platform_set_drvdata(pdev, NULL);
247
319 return 0; 248 return 0;
320} 249}
250
321 /*TBD*/ 251 /*TBD*/
322/*static int ohci_hcd_au1xxx_drv_suspend(struct platform_device *dev) 252/*static int ohci_hcd_au1xxx_drv_suspend(struct platform_device *dev)
323{ 253{