[ARM] pxa: update defconfig for Verdex Pro
[linux-2.6/verdex.git] / drivers / usb / host / ehci-w90x900.c
blobcfa21ea20f8281cec44721f7d6b1c7de6780ff63
1 /*
2 * linux/driver/usb/host/ehci-w90x900.c
4 * Copyright (c) 2008 Nuvoton technology corporation.
6 * Wan ZongShun <mcuos.com@gmail.com>
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.
14 #include <linux/platform_device.h>
16 /*ebable phy0 and phy1 for w90p910*/
17 #define ENPHY (0x01<<8)
18 #define PHY0_CTR (0xA4)
19 #define PHY1_CTR (0xA8)
21 static int __devinit usb_w90x900_probe(const struct hc_driver *driver,
22 struct platform_device *pdev)
24 struct usb_hcd *hcd;
25 struct ehci_hcd *ehci;
26 struct resource *res;
27 int retval = 0, irq;
28 unsigned long val;
31 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
32 if (!res) {
33 retval = -ENXIO;
34 goto err1;
37 hcd = usb_create_hcd(driver, &pdev->dev, "w90x900 EHCI");
38 if (!hcd) {
39 retval = -ENOMEM;
40 goto err1;
43 hcd->rsrc_start = res->start;
44 hcd->rsrc_len = res->end - res->start + 1;
46 if (!request_mem_region(hcd->rsrc_start, hcd->rsrc_len, hcd_name)) {
47 retval = -EBUSY;
48 goto err2;
51 hcd->regs = ioremap(hcd->rsrc_start, hcd->rsrc_len);
52 if (hcd->regs == NULL) {
53 retval = -EFAULT;
54 goto err3;
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));
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.
66 val = __raw_readl(ehci->regs+PHY0_CTR);
67 val |= ENPHY;
68 __raw_writel(val, ehci->regs+PHY0_CTR);
70 val = __raw_readl(ehci->regs+PHY1_CTR);
71 val |= ENPHY;
72 __raw_writel(val, ehci->regs+PHY1_CTR);
74 ehci->hcs_params = ehci_readl(ehci, &ehci->caps->hcs_params);
75 ehci->sbrn = 0x20;
77 irq = platform_get_irq(pdev, 0);
78 if (irq < 0)
79 goto err4;
81 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
82 if (retval != 0)
83 goto err4;
85 ehci_writel(ehci, 1, &ehci->regs->configured_flag);
87 return retval;
88 err4:
89 iounmap(hcd->regs);
90 err3:
91 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
92 err2:
93 usb_put_hcd(hcd);
94 err1:
95 return retval;
98 static
99 void usb_w90x900_remove(struct usb_hcd *hcd, struct platform_device *pdev)
101 usb_remove_hcd(hcd);
102 iounmap(hcd->regs);
103 release_mem_region(hcd->rsrc_start, hcd->rsrc_len);
104 usb_put_hcd(hcd);
107 static 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),
113 * generic hardware linkage
115 .irq = ehci_irq,
116 .flags = HCD_USB2|HCD_MEMORY,
119 * basic lifecycle operations
121 .reset = ehci_init,
122 .start = ehci_run,
124 .stop = ehci_stop,
125 .shutdown = ehci_shutdown,
128 * managing i/o requests and associated device resources
130 .urb_enqueue = ehci_urb_enqueue,
131 .urb_dequeue = ehci_urb_dequeue,
132 .endpoint_disable = ehci_endpoint_disable,
135 * scheduling support
137 .get_frame_number = ehci_get_frame,
140 * root hub support
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,
152 static int __devinit ehci_w90x900_probe(struct platform_device *pdev)
154 if (usb_disabled())
155 return -ENODEV;
157 return usb_w90x900_probe(&ehci_w90x900_hc_driver, pdev);
160 static int __devexit ehci_w90x900_remove(struct platform_device *pdev)
162 struct usb_hcd *hcd = platform_get_drvdata(pdev);
164 usb_w90x900_remove(hcd, pdev);
166 return 0;
169 static 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,
178 MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
179 MODULE_DESCRIPTION("w90p910 usb ehci driver!");
180 MODULE_LICENSE("GPL");
181 MODULE_ALIAS("platform:w90p910-ehci");