Merge tag 'ceph-for-4.13-rc8' of git://github.com/ceph/ceph-client
[linux/fpc-iii.git] / drivers / usb / host / ehci-w90x900.c
blob63b9d0c67963094f15ba9950c9f85c1126f3a0db
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/dma-mapping.h>
15 #include <linux/io.h>
16 #include <linux/kernel.h>
17 #include <linux/module.h>
18 #include <linux/of.h>
19 #include <linux/platform_device.h>
20 #include <linux/usb.h>
21 #include <linux/usb/hcd.h>
23 #include "ehci.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 ehci_w90x900_probe(struct platform_device *pdev)
38 struct usb_hcd *hcd;
39 struct ehci_hcd *ehci;
40 struct resource *res;
41 int retval = 0, irq;
42 unsigned long val;
44 hcd = usb_create_hcd(&ehci_w90x900_hc_driver,
45 &pdev->dev, "w90x900 EHCI");
46 if (!hcd) {
47 retval = -ENOMEM;
48 goto err1;
51 res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
52 hcd->regs = devm_ioremap_resource(&pdev->dev, res);
53 if (IS_ERR(hcd->regs)) {
54 retval = PTR_ERR(hcd->regs);
55 goto err2;
57 hcd->rsrc_start = res->start;
58 hcd->rsrc_len = resource_size(res);
60 ehci = hcd_to_ehci(hcd);
61 ehci->caps = hcd->regs;
62 ehci->regs = hcd->regs +
63 HC_LENGTH(ehci, ehci_readl(ehci, &ehci->caps->hc_capbase));
65 /* enable PHY 0,1,the regs only apply to w90p910
66 * 0xA4,0xA8 were offsets of PHY0 and PHY1 controller of
67 * w90p910 IC relative to ehci->regs.
69 val = __raw_readl(ehci->regs+PHY0_CTR);
70 val |= ENPHY;
71 __raw_writel(val, ehci->regs+PHY0_CTR);
73 val = __raw_readl(ehci->regs+PHY1_CTR);
74 val |= ENPHY;
75 __raw_writel(val, ehci->regs+PHY1_CTR);
77 irq = platform_get_irq(pdev, 0);
78 if (irq < 0) {
79 retval = irq;
80 goto err2;
83 retval = usb_add_hcd(hcd, irq, IRQF_SHARED);
84 if (retval != 0)
85 goto err2;
87 device_wakeup_enable(hcd->self.controller);
88 return retval;
89 err2:
90 usb_put_hcd(hcd);
91 err1:
92 return retval;
95 static int ehci_w90x900_remove(struct platform_device *pdev)
97 struct usb_hcd *hcd = platform_get_drvdata(pdev);
99 usb_remove_hcd(hcd);
100 usb_put_hcd(hcd);
102 return 0;
105 static struct platform_driver ehci_hcd_w90x900_driver = {
106 .probe = ehci_w90x900_probe,
107 .remove = ehci_w90x900_remove,
108 .driver = {
109 .name = "w90x900-ehci",
113 static int __init ehci_w90X900_init(void)
115 if (usb_disabled())
116 return -ENODEV;
118 pr_info("%s: " DRIVER_DESC "\n", hcd_name);
120 ehci_init_driver(&ehci_w90x900_hc_driver, NULL);
121 return platform_driver_register(&ehci_hcd_w90x900_driver);
123 module_init(ehci_w90X900_init);
125 static void __exit ehci_w90X900_cleanup(void)
127 platform_driver_unregister(&ehci_hcd_w90x900_driver);
129 module_exit(ehci_w90X900_cleanup);
131 MODULE_DESCRIPTION(DRIVER_DESC);
132 MODULE_AUTHOR("Wan ZongShun <mcuos.com@gmail.com>");
133 MODULE_ALIAS("platform:w90p910-ehci");
134 MODULE_LICENSE("GPL v2");