Commit | Line | Data |
---|---|---|
76fa9a24 JC |
1 | /* |
2 | * EHCI HCD (Host Controller Driver) for USB. | |
3 | * | |
76fa9a24 JC |
4 | * Bus Glue for AMD Alchemy Au1xxx |
5 | * | |
6 | * Based on "ohci-au1xxx.c" by Matt Porter <mporter@kernel.crashing.org> | |
7 | * | |
8 | * Modified for AMD Alchemy Au1200 EHC | |
9 | * by K.Boge <karsten.boge@amd.com> | |
10 | * | |
11 | * This file is licenced under the GPL. | |
12 | */ | |
13 | ||
14 | #include <linux/platform_device.h> | |
15 | #include <asm/mach-au1x00/au1000.h> | |
16 | ||
76fa9a24 | 17 | |
76fa9a24 JC |
18 | extern int usb_disabled(void); |
19 | ||
9757de38 ML |
20 | static int au1xxx_ehci_setup(struct usb_hcd *hcd) |
21 | { | |
22 | struct ehci_hcd *ehci = hcd_to_ehci(hcd); | |
1a49e2ac AS |
23 | int ret; |
24 | ||
25 | ehci->caps = hcd->regs; | |
26 | ret = ehci_setup(hcd); | |
9757de38 ML |
27 | |
28 | ehci->need_io_watchdog = 0; | |
29 | return ret; | |
30 | } | |
31 | ||
53c81a34 ML |
32 | static const struct hc_driver ehci_au1xxx_hc_driver = { |
33 | .description = hcd_name, | |
34 | .product_desc = "Au1xxx EHCI", | |
35 | .hcd_priv_size = sizeof(struct ehci_hcd), | |
76fa9a24 | 36 | |
53c81a34 ML |
37 | /* |
38 | * generic hardware linkage | |
39 | */ | |
40 | .irq = ehci_irq, | |
41 | .flags = HCD_MEMORY | HCD_USB2, | |
76fa9a24 | 42 | |
53c81a34 ML |
43 | /* |
44 | * basic lifecycle operations | |
45 | * | |
46 | * FIXME -- ehci_init() doesn't do enough here. | |
47 | * See ehci-ppc-soc for a complete implementation. | |
48 | */ | |
9757de38 | 49 | .reset = au1xxx_ehci_setup, |
53c81a34 ML |
50 | .start = ehci_run, |
51 | .stop = ehci_stop, | |
52 | .shutdown = ehci_shutdown, | |
53 | ||
54 | /* | |
55 | * managing i/o requests and associated device resources | |
56 | */ | |
57 | .urb_enqueue = ehci_urb_enqueue, | |
58 | .urb_dequeue = ehci_urb_dequeue, | |
59 | .endpoint_disable = ehci_endpoint_disable, | |
b18ffd49 | 60 | .endpoint_reset = ehci_endpoint_reset, |
53c81a34 ML |
61 | |
62 | /* | |
63 | * scheduling support | |
64 | */ | |
65 | .get_frame_number = ehci_get_frame, | |
66 | ||
67 | /* | |
68 | * root hub support | |
69 | */ | |
70 | .hub_status_data = ehci_hub_status_data, | |
71 | .hub_control = ehci_hub_control, | |
72 | .bus_suspend = ehci_bus_suspend, | |
73 | .bus_resume = ehci_bus_resume, | |
74 | .relinquish_port = ehci_relinquish_port, | |
75 | .port_handed_over = ehci_port_handed_over, | |
914b7012 AS |
76 | |
77 | .clear_tt_buffer_complete = ehci_clear_tt_buffer_complete, | |
53c81a34 ML |
78 | }; |
79 | ||
80 | static int ehci_hcd_au1xxx_drv_probe(struct platform_device *pdev) | |
76fa9a24 | 81 | { |
76fa9a24 | 82 | struct usb_hcd *hcd; |
1f141ca2 | 83 | struct resource *res; |
53c81a34 | 84 | int ret; |
76fa9a24 | 85 | |
53c81a34 ML |
86 | if (usb_disabled()) |
87 | return -ENODEV; | |
76fa9a24 | 88 | |
53c81a34 | 89 | if (pdev->resource[1].flags != IORESOURCE_IRQ) { |
76fa9a24 | 90 | pr_debug("resource[1] is not IORESOURCE_IRQ"); |
53c81a34 | 91 | return -ENOMEM; |
76fa9a24 | 92 | } |
53c81a34 | 93 | hcd = usb_create_hcd(&ehci_au1xxx_hc_driver, &pdev->dev, "Au1xxx"); |
76fa9a24 JC |
94 | if (!hcd) |
95 | return -ENOMEM; | |
53c81a34 | 96 | |
1f141ca2 HS |
97 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
98 | hcd->rsrc_start = res->start; | |
99 | hcd->rsrc_len = resource_size(res); | |
76fa9a24 | 100 | |
8ca41ae3 | 101 | hcd->regs = devm_request_and_ioremap(&pdev->dev, res); |
76fa9a24 | 102 | if (!hcd->regs) { |
8ca41ae3 | 103 | pr_debug("devm_request_and_ioremap failed"); |
53c81a34 | 104 | ret = -ENOMEM; |
8ca41ae3 | 105 | goto err1; |
76fa9a24 JC |
106 | } |
107 | ||
ce6bc922 ML |
108 | if (alchemy_usb_control(ALCHEMY_USB_EHCI0, 1)) { |
109 | printk(KERN_INFO "%s: controller init failed!\n", pdev->name); | |
110 | ret = -ENODEV; | |
8ca41ae3 | 111 | goto err1; |
ce6bc922 | 112 | } |
53c81a34 | 113 | |
53c81a34 | 114 | ret = usb_add_hcd(hcd, pdev->resource[1].start, |
b5dd18d8 | 115 | IRQF_SHARED); |
53c81a34 ML |
116 | if (ret == 0) { |
117 | platform_set_drvdata(pdev, hcd); | |
118 | return ret; | |
119 | } | |
76fa9a24 | 120 | |
ce6bc922 | 121 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); |
76fa9a24 JC |
122 | err1: |
123 | usb_put_hcd(hcd); | |
53c81a34 | 124 | return ret; |
76fa9a24 JC |
125 | } |
126 | ||
53c81a34 | 127 | static int ehci_hcd_au1xxx_drv_remove(struct platform_device *pdev) |
76fa9a24 | 128 | { |
53c81a34 ML |
129 | struct usb_hcd *hcd = platform_get_drvdata(pdev); |
130 | ||
76fa9a24 | 131 | usb_remove_hcd(hcd); |
ce6bc922 | 132 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); |
76fa9a24 | 133 | usb_put_hcd(hcd); |
53c81a34 | 134 | platform_set_drvdata(pdev, NULL); |
76fa9a24 | 135 | |
76fa9a24 JC |
136 | return 0; |
137 | } | |
138 | ||
42bfc7b4 | 139 | #ifdef CONFIG_PM |
807fcb5e | 140 | static int ehci_hcd_au1xxx_drv_suspend(struct device *dev) |
76fa9a24 | 141 | { |
807fcb5e | 142 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
c5cf9212 AS |
143 | bool do_wakeup = device_may_wakeup(dev); |
144 | int rc; | |
42bfc7b4 | 145 | |
c5cf9212 | 146 | rc = ehci_suspend(hcd, do_wakeup); |
ce6bc922 | 147 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 0); |
a7535ac0 | 148 | |
42bfc7b4 | 149 | return rc; |
76fa9a24 | 150 | } |
42bfc7b4 | 151 | |
807fcb5e | 152 | static int ehci_hcd_au1xxx_drv_resume(struct device *dev) |
76fa9a24 | 153 | { |
807fcb5e | 154 | struct usb_hcd *hcd = dev_get_drvdata(dev); |
42bfc7b4 | 155 | |
ce6bc922 | 156 | alchemy_usb_control(ALCHEMY_USB_EHCI0, 1); |
c5cf9212 | 157 | ehci_resume(hcd, false); |
76fa9a24 JC |
158 | |
159 | return 0; | |
160 | } | |
42bfc7b4 | 161 | |
47145210 | 162 | static const struct dev_pm_ops au1xxx_ehci_pmops = { |
807fcb5e ML |
163 | .suspend = ehci_hcd_au1xxx_drv_suspend, |
164 | .resume = ehci_hcd_au1xxx_drv_resume, | |
165 | }; | |
166 | ||
167 | #define AU1XXX_EHCI_PMOPS &au1xxx_ehci_pmops | |
168 | ||
42bfc7b4 | 169 | #else |
807fcb5e | 170 | #define AU1XXX_EHCI_PMOPS NULL |
42bfc7b4 | 171 | #endif |
53c81a34 | 172 | |
d14feb5e | 173 | static struct platform_driver ehci_hcd_au1xxx_driver = { |
53c81a34 ML |
174 | .probe = ehci_hcd_au1xxx_drv_probe, |
175 | .remove = ehci_hcd_au1xxx_drv_remove, | |
176 | .shutdown = usb_hcd_platform_shutdown, | |
d14feb5e | 177 | .driver = { |
53c81a34 ML |
178 | .name = "au1xxx-ehci", |
179 | .owner = THIS_MODULE, | |
807fcb5e | 180 | .pm = AU1XXX_EHCI_PMOPS, |
d14feb5e | 181 | } |
76fa9a24 | 182 | }; |
53c81a34 ML |
183 | |
184 | MODULE_ALIAS("platform:au1xxx-ehci"); |