diff options
Diffstat (limited to 'arch/mips/ath79/dev-usb.c')
-rw-r--r-- | arch/mips/ath79/dev-usb.c | 90 |
1 files changed, 56 insertions, 34 deletions
diff --git a/arch/mips/ath79/dev-usb.c b/arch/mips/ath79/dev-usb.c index 36e9570e7bc4..072bb9be2304 100644 --- a/arch/mips/ath79/dev-usb.c +++ b/arch/mips/ath79/dev-usb.c | |||
@@ -25,17 +25,7 @@ | |||
25 | #include "common.h" | 25 | #include "common.h" |
26 | #include "dev-usb.h" | 26 | #include "dev-usb.h" |
27 | 27 | ||
28 | static struct resource ath79_ohci_resources[] = { | 28 | static struct resource ath79_ohci_resources[2]; |
29 | [0] = { | ||
30 | /* .start and .end fields are filled dynamically */ | ||
31 | .flags = IORESOURCE_MEM, | ||
32 | }, | ||
33 | [1] = { | ||
34 | .start = ATH79_MISC_IRQ_OHCI, | ||
35 | .end = ATH79_MISC_IRQ_OHCI, | ||
36 | .flags = IORESOURCE_IRQ, | ||
37 | }, | ||
38 | }; | ||
39 | 29 | ||
40 | static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32); | 30 | static u64 ath79_ohci_dmamask = DMA_BIT_MASK(32); |
41 | 31 | ||
@@ -54,17 +44,7 @@ static struct platform_device ath79_ohci_device = { | |||
54 | }, | 44 | }, |
55 | }; | 45 | }; |
56 | 46 | ||
57 | static struct resource ath79_ehci_resources[] = { | 47 | static struct resource ath79_ehci_resources[2]; |
58 | [0] = { | ||
59 | /* .start and .end fields are filled dynamically */ | ||
60 | .flags = IORESOURCE_MEM, | ||
61 | }, | ||
62 | [1] = { | ||
63 | .start = ATH79_CPU_IRQ_USB, | ||
64 | .end = ATH79_CPU_IRQ_USB, | ||
65 | .flags = IORESOURCE_IRQ, | ||
66 | }, | ||
67 | }; | ||
68 | 48 | ||
69 | static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32); | 49 | static u64 ath79_ehci_dmamask = DMA_BIT_MASK(32); |
70 | 50 | ||
@@ -90,6 +70,20 @@ static struct platform_device ath79_ehci_device = { | |||
90 | }, | 70 | }, |
91 | }; | 71 | }; |
92 | 72 | ||
73 | static void __init ath79_usb_init_resource(struct resource res[2], | ||
74 | unsigned long base, | ||
75 | unsigned long size, | ||
76 | int irq) | ||
77 | { | ||
78 | res[0].flags = IORESOURCE_MEM; | ||
79 | res[0].start = base; | ||
80 | res[0].end = base + size - 1; | ||
81 | |||
82 | res[1].flags = IORESOURCE_IRQ; | ||
83 | res[1].start = irq; | ||
84 | res[1].end = irq; | ||
85 | } | ||
86 | |||
93 | #define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \ | 87 | #define AR71XX_USB_RESET_MASK (AR71XX_RESET_USB_HOST | \ |
94 | AR71XX_RESET_USB_PHY | \ | 88 | AR71XX_RESET_USB_PHY | \ |
95 | AR71XX_RESET_USB_OHCI_DLL) | 89 | AR71XX_RESET_USB_OHCI_DLL) |
@@ -114,12 +108,12 @@ static void __init ath79_usb_setup(void) | |||
114 | 108 | ||
115 | mdelay(900); | 109 | mdelay(900); |
116 | 110 | ||
117 | ath79_ohci_resources[0].start = AR71XX_OHCI_BASE; | 111 | ath79_usb_init_resource(ath79_ohci_resources, AR71XX_OHCI_BASE, |
118 | ath79_ohci_resources[0].end = AR71XX_OHCI_BASE + AR71XX_OHCI_SIZE - 1; | 112 | AR71XX_OHCI_SIZE, ATH79_MISC_IRQ_OHCI); |
119 | platform_device_register(&ath79_ohci_device); | 113 | platform_device_register(&ath79_ohci_device); |
120 | 114 | ||
121 | ath79_ehci_resources[0].start = AR71XX_EHCI_BASE; | 115 | ath79_usb_init_resource(ath79_ehci_resources, AR71XX_EHCI_BASE, |
122 | ath79_ehci_resources[0].end = AR71XX_EHCI_BASE + AR71XX_EHCI_SIZE - 1; | 116 | AR71XX_EHCI_SIZE, ATH79_CPU_IRQ_USB); |
123 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1; | 117 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v1; |
124 | platform_device_register(&ath79_ehci_device); | 118 | platform_device_register(&ath79_ehci_device); |
125 | } | 119 | } |
@@ -143,8 +137,8 @@ static void __init ar7240_usb_setup(void) | |||
143 | 137 | ||
144 | iounmap(usb_ctrl_base); | 138 | iounmap(usb_ctrl_base); |
145 | 139 | ||
146 | ath79_ohci_resources[0].start = AR7240_OHCI_BASE; | 140 | ath79_usb_init_resource(ath79_ohci_resources, AR7240_OHCI_BASE, |
147 | ath79_ohci_resources[0].end = AR7240_OHCI_BASE + AR7240_OHCI_SIZE - 1; | 141 | AR7240_OHCI_SIZE, ATH79_CPU_IRQ_USB); |
148 | platform_device_register(&ath79_ohci_device); | 142 | platform_device_register(&ath79_ohci_device); |
149 | } | 143 | } |
150 | 144 | ||
@@ -159,8 +153,8 @@ static void __init ar724x_usb_setup(void) | |||
159 | ath79_device_reset_clear(AR724X_RESET_USB_PHY); | 153 | ath79_device_reset_clear(AR724X_RESET_USB_PHY); |
160 | mdelay(10); | 154 | mdelay(10); |
161 | 155 | ||
162 | ath79_ehci_resources[0].start = AR724X_EHCI_BASE; | 156 | ath79_usb_init_resource(ath79_ehci_resources, AR724X_EHCI_BASE, |
163 | ath79_ehci_resources[0].end = AR724X_EHCI_BASE + AR724X_EHCI_SIZE - 1; | 157 | AR724X_EHCI_SIZE, ATH79_CPU_IRQ_USB); |
164 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | 158 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; |
165 | platform_device_register(&ath79_ehci_device); | 159 | platform_device_register(&ath79_ehci_device); |
166 | } | 160 | } |
@@ -176,8 +170,8 @@ static void __init ar913x_usb_setup(void) | |||
176 | ath79_device_reset_clear(AR913X_RESET_USB_PHY); | 170 | ath79_device_reset_clear(AR913X_RESET_USB_PHY); |
177 | mdelay(10); | 171 | mdelay(10); |
178 | 172 | ||
179 | ath79_ehci_resources[0].start = AR913X_EHCI_BASE; | 173 | ath79_usb_init_resource(ath79_ehci_resources, AR913X_EHCI_BASE, |
180 | ath79_ehci_resources[0].end = AR913X_EHCI_BASE + AR913X_EHCI_SIZE - 1; | 174 | AR913X_EHCI_SIZE, ATH79_CPU_IRQ_USB); |
181 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | 175 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; |
182 | platform_device_register(&ath79_ehci_device); | 176 | platform_device_register(&ath79_ehci_device); |
183 | } | 177 | } |
@@ -193,8 +187,34 @@ static void __init ar933x_usb_setup(void) | |||
193 | ath79_device_reset_clear(AR933X_RESET_USB_PHY); | 187 | ath79_device_reset_clear(AR933X_RESET_USB_PHY); |
194 | mdelay(10); | 188 | mdelay(10); |
195 | 189 | ||
196 | ath79_ehci_resources[0].start = AR933X_EHCI_BASE; | 190 | ath79_usb_init_resource(ath79_ehci_resources, AR933X_EHCI_BASE, |
197 | ath79_ehci_resources[0].end = AR933X_EHCI_BASE + AR933X_EHCI_SIZE - 1; | 191 | AR933X_EHCI_SIZE, ATH79_CPU_IRQ_USB); |
192 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | ||
193 | platform_device_register(&ath79_ehci_device); | ||
194 | } | ||
195 | |||
196 | static void __init ar934x_usb_setup(void) | ||
197 | { | ||
198 | u32 bootstrap; | ||
199 | |||
200 | bootstrap = ath79_reset_rr(AR934X_RESET_REG_BOOTSTRAP); | ||
201 | if (bootstrap & AR934X_BOOTSTRAP_USB_MODE_DEVICE) | ||
202 | return; | ||
203 | |||
204 | ath79_device_reset_set(AR934X_RESET_USBSUS_OVERRIDE); | ||
205 | udelay(1000); | ||
206 | |||
207 | ath79_device_reset_clear(AR934X_RESET_USB_PHY); | ||
208 | udelay(1000); | ||
209 | |||
210 | ath79_device_reset_clear(AR934X_RESET_USB_PHY_ANALOG); | ||
211 | udelay(1000); | ||
212 | |||
213 | ath79_device_reset_clear(AR934X_RESET_USB_HOST); | ||
214 | udelay(1000); | ||
215 | |||
216 | ath79_usb_init_resource(ath79_ehci_resources, AR934X_EHCI_BASE, | ||
217 | AR934X_EHCI_SIZE, ATH79_CPU_IRQ_USB); | ||
198 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; | 218 | ath79_ehci_device.dev.platform_data = &ath79_ehci_pdata_v2; |
199 | platform_device_register(&ath79_ehci_device); | 219 | platform_device_register(&ath79_ehci_device); |
200 | } | 220 | } |
@@ -211,6 +231,8 @@ void __init ath79_register_usb(void) | |||
211 | ar913x_usb_setup(); | 231 | ar913x_usb_setup(); |
212 | else if (soc_is_ar933x()) | 232 | else if (soc_is_ar933x()) |
213 | ar933x_usb_setup(); | 233 | ar933x_usb_setup(); |
234 | else if (soc_is_ar934x()) | ||
235 | ar934x_usb_setup(); | ||
214 | else | 236 | else |
215 | BUG(); | 237 | BUG(); |
216 | } | 238 | } |