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/dma-mapping.h>
16 #include <linux/kernel.h>
17 #include <linux/module.h>
19 #include <linux/platform_device.h>
20 #include <linux/usb.h>
21 #include <linux/usb/hcd.h>
25 /* enable phy0 and phy1 for w90p910 */
26 #define ENPHY (0x01<<8)
27 #define PHY0_CTR (0xA4)
28 #define PHY1_CTR (0xA8)
30 #define DRIVER_DESC "EHCI w90x900 driver"
32 static const char hcd_name
[] = "ehci-w90x900 ";
34 static struct hc_driver __read_mostly ehci_w90x900_hc_driver
;
36 static int usb_w90x900_probe(const struct hc_driver
*driver
,
37 struct platform_device
*pdev
)
40 struct ehci_hcd
*ehci
;
46 res
= platform_get_resource(pdev
, IORESOURCE_MEM
, 0);
52 hcd
= usb_create_hcd(driver
, &pdev
->dev
, "w90x900 EHCI");
58 hcd
->rsrc_start
= res
->start
;
59 hcd
->rsrc_len
= resource_size(res
);
61 hcd
->regs
= devm_ioremap_resource(&pdev
->dev
, res
);
62 if (IS_ERR(hcd
->regs
)) {
63 retval
= PTR_ERR(hcd
->regs
);
67 ehci
= hcd_to_ehci(hcd
);
68 ehci
->caps
= hcd
->regs
;
69 ehci
->regs
= hcd
->regs
+
70 HC_LENGTH(ehci
, ehci_readl(ehci
, &ehci
->caps
->hc_capbase
));
72 /* enable PHY 0,1,the regs only apply to w90p910
73 * 0xA4,0xA8 were offsets of PHY0 and PHY1 controller of
74 * w90p910 IC relative to ehci->regs.
76 val
= __raw_readl(ehci
->regs
+PHY0_CTR
);
78 __raw_writel(val
, ehci
->regs
+PHY0_CTR
);
80 val
= __raw_readl(ehci
->regs
+PHY1_CTR
);
82 __raw_writel(val
, ehci
->regs
+PHY1_CTR
);
84 irq
= platform_get_irq(pdev
, 0);
88 retval
= usb_add_hcd(hcd
, irq
, IRQF_SHARED
);
92 device_wakeup_enable(hcd
->self
.controller
);
100 static void usb_w90x900_remove(struct usb_hcd
*hcd
,
101 struct platform_device
*pdev
)
107 static int ehci_w90x900_probe(struct platform_device
*pdev
)
112 return usb_w90x900_probe(&ehci_w90x900_hc_driver
, pdev
);
115 static int ehci_w90x900_remove(struct platform_device
*pdev
)
117 struct usb_hcd
*hcd
= platform_get_drvdata(pdev
);
119 usb_w90x900_remove(hcd
, pdev
);
124 static struct platform_driver ehci_hcd_w90x900_driver
= {
125 .probe
= ehci_w90x900_probe
,
126 .remove
= ehci_w90x900_remove
,
128 .name
= "w90x900-ehci",
129 .owner
= THIS_MODULE
,
133 static int __init
ehci_w90X900_init(void)
138 pr_info("%s: " DRIVER_DESC
"\n", hcd_name
);
140 ehci_init_driver(&ehci_w90x900_hc_driver
, NULL
);
141 return platform_driver_register(&ehci_hcd_w90x900_driver
);
143 module_init(ehci_w90X900_init
);
145 static void __exit
ehci_w90X900_cleanup(void)
147 platform_driver_unregister(&ehci_hcd_w90x900_driver
);
149 module_exit(ehci_w90X900_cleanup
);
151 MODULE_DESCRIPTION(DRIVER_DESC
);
152 MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
153 MODULE_ALIAS("platform:w90p910-ehci");
154 MODULE_LICENSE("GPL v2");