aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/arm/mach-omap1/Makefile3
-rw-r--r--arch/arm/mach-omap1/board-ams-delta.c2
-rw-r--r--arch/arm/mach-omap1/board-generic.c4
-rw-r--r--arch/arm/mach-omap1/board-h2.c2
-rw-r--r--arch/arm/mach-omap1/board-h3.c2
-rw-r--r--arch/arm/mach-omap1/board-htcherald.c2
-rw-r--r--arch/arm/mach-omap1/board-innovator.c4
-rw-r--r--arch/arm/mach-omap1/board-nokia770.c2
-rw-r--r--arch/arm/mach-omap1/board-osk.c2
-rw-r--r--arch/arm/mach-omap1/board-palmte.c2
-rw-r--r--arch/arm/mach-omap1/board-palmtt.c2
-rw-r--r--arch/arm/mach-omap1/board-palmz71.c2
-rw-r--r--arch/arm/mach-omap1/board-sx1.c2
-rw-r--r--arch/arm/mach-omap1/board-voiceblue.c2
-rw-r--r--arch/arm/mach-omap1/usb.c530
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h42
-rw-r--r--arch/arm/plat-omap/usb.c535
17 files changed, 589 insertions, 551 deletions
diff --git a/arch/arm/mach-omap1/Makefile b/arch/arm/mach-omap1/Makefile
index ea231c7a550a..facfaeb1ae5c 100644
--- a/arch/arm/mach-omap1/Makefile
+++ b/arch/arm/mach-omap1/Makefile
@@ -23,6 +23,9 @@ obj-y += $(i2c-omap-m) $(i2c-omap-y)
23 23
24led-y := leds.o 24led-y := leds.o
25 25
26usb-fs-$(CONFIG_USB) := usb.o
27obj-y += $(usb-fs-m) $(usb-fs-y)
28
26# Specific board support 29# Specific board support
27obj-$(CONFIG_MACH_OMAP_H2) += board-h2.o board-h2-mmc.o 30obj-$(CONFIG_MACH_OMAP_H2) += board-h2.o board-h2-mmc.o
28obj-$(CONFIG_MACH_OMAP_INNOVATOR) += board-innovator.o 31obj-$(CONFIG_MACH_OMAP_INNOVATOR) += board-innovator.o
diff --git a/arch/arm/mach-omap1/board-ams-delta.c b/arch/arm/mach-omap1/board-ams-delta.c
index fdd1dd53fa9c..c6a81ff8c0d8 100644
--- a/arch/arm/mach-omap1/board-ams-delta.c
+++ b/arch/arm/mach-omap1/board-ams-delta.c
@@ -235,7 +235,7 @@ static void __init ams_delta_init(void)
235 /* Clear latch2 (NAND, LCD, modem enable) */ 235 /* Clear latch2 (NAND, LCD, modem enable) */
236 ams_delta_latch2_write(~0, 0); 236 ams_delta_latch2_write(~0, 0);
237 237
238 omap_usb_init(&ams_delta_usb_config); 238 omap1_usb_init(&ams_delta_usb_config);
239 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices)); 239 platform_add_devices(ams_delta_devices, ARRAY_SIZE(ams_delta_devices));
240 240
241#ifdef CONFIG_AMS_DELTA_FIQ 241#ifdef CONFIG_AMS_DELTA_FIQ
diff --git a/arch/arm/mach-omap1/board-generic.c b/arch/arm/mach-omap1/board-generic.c
index e1195a3467b8..e9ed8bff1ce3 100644
--- a/arch/arm/mach-omap1/board-generic.c
+++ b/arch/arm/mach-omap1/board-generic.c
@@ -72,12 +72,12 @@ static void __init omap_generic_init(void)
72 omap_cfg_reg(UART3_TX); 72 omap_cfg_reg(UART3_TX);
73 omap_cfg_reg(UART3_RX); 73 omap_cfg_reg(UART3_RX);
74 74
75 omap_usb_init(&generic1510_usb_config); 75 omap1_usb_init(&generic1510_usb_config);
76 } 76 }
77#endif 77#endif
78#if defined(CONFIG_ARCH_OMAP16XX) 78#if defined(CONFIG_ARCH_OMAP16XX)
79 if (!cpu_is_omap1510()) { 79 if (!cpu_is_omap1510()) {
80 omap_usb_init(&generic1610_usb_config); 80 omap1_usb_init(&generic1610_usb_config);
81 } 81 }
82#endif 82#endif
83 83
diff --git a/arch/arm/mach-omap1/board-h2.c b/arch/arm/mach-omap1/board-h2.c
index d1100e4f65ac..5f30188ade99 100644
--- a/arch/arm/mach-omap1/board-h2.c
+++ b/arch/arm/mach-omap1/board-h2.c
@@ -452,7 +452,7 @@ static void __init h2_init(void)
452 omap_serial_init(); 452 omap_serial_init();
453 omap_register_i2c_bus(1, 100, h2_i2c_board_info, 453 omap_register_i2c_bus(1, 100, h2_i2c_board_info,
454 ARRAY_SIZE(h2_i2c_board_info)); 454 ARRAY_SIZE(h2_i2c_board_info));
455 omap_usb_init(&h2_usb_config); 455 omap1_usb_init(&h2_usb_config);
456 h2_mmc_init(); 456 h2_mmc_init();
457} 457}
458 458
diff --git a/arch/arm/mach-omap1/board-h3.c b/arch/arm/mach-omap1/board-h3.c
index a53ab8297d25..0be1d3b8181d 100644
--- a/arch/arm/mach-omap1/board-h3.c
+++ b/arch/arm/mach-omap1/board-h3.c
@@ -405,7 +405,7 @@ static void __init h3_init(void)
405 omap_serial_init(); 405 omap_serial_init();
406 omap_register_i2c_bus(1, 100, h3_i2c_board_info, 406 omap_register_i2c_bus(1, 100, h3_i2c_board_info,
407 ARRAY_SIZE(h3_i2c_board_info)); 407 ARRAY_SIZE(h3_i2c_board_info));
408 omap_usb_init(&h3_usb_config); 408 omap1_usb_init(&h3_usb_config);
409 h3_mmc_init(); 409 h3_mmc_init();
410} 410}
411 411
diff --git a/arch/arm/mach-omap1/board-htcherald.c b/arch/arm/mach-omap1/board-htcherald.c
index 8e313b4b99a9..736e4c2064f6 100644
--- a/arch/arm/mach-omap1/board-htcherald.c
+++ b/arch/arm/mach-omap1/board-htcherald.c
@@ -287,7 +287,7 @@ static void __init htcherald_init(void)
287 htcherald_disable_watchdog(); 287 htcherald_disable_watchdog();
288 288
289 htcherald_usb_enable(); 289 htcherald_usb_enable();
290 omap_usb_init(&htcherald_usb_config); 290 omap1_usb_init(&htcherald_usb_config);
291} 291}
292 292
293static void __init htcherald_init_irq(void) 293static void __init htcherald_init_irq(void)
diff --git a/arch/arm/mach-omap1/board-innovator.c b/arch/arm/mach-omap1/board-innovator.c
index 5d12fd35681b..3c04e90fb85a 100644
--- a/arch/arm/mach-omap1/board-innovator.c
+++ b/arch/arm/mach-omap1/board-innovator.c
@@ -422,13 +422,13 @@ static void __init innovator_init(void)
422 422
423#ifdef CONFIG_ARCH_OMAP15XX 423#ifdef CONFIG_ARCH_OMAP15XX
424 if (cpu_is_omap1510()) { 424 if (cpu_is_omap1510()) {
425 omap_usb_init(&innovator1510_usb_config); 425 omap1_usb_init(&innovator1510_usb_config);
426 innovator_config[1].data = &innovator1510_lcd_config; 426 innovator_config[1].data = &innovator1510_lcd_config;
427 } 427 }
428#endif 428#endif
429#ifdef CONFIG_ARCH_OMAP16XX 429#ifdef CONFIG_ARCH_OMAP16XX
430 if (cpu_is_omap1610()) { 430 if (cpu_is_omap1610()) {
431 omap_usb_init(&h2_usb_config); 431 omap1_usb_init(&h2_usb_config);
432 innovator_config[1].data = &innovator1610_lcd_config; 432 innovator_config[1].data = &innovator1610_lcd_config;
433 } 433 }
434#endif 434#endif
diff --git a/arch/arm/mach-omap1/board-nokia770.c b/arch/arm/mach-omap1/board-nokia770.c
index 71e1a3fad0ea..c9e9e37c5676 100644
--- a/arch/arm/mach-omap1/board-nokia770.c
+++ b/arch/arm/mach-omap1/board-nokia770.c
@@ -386,7 +386,7 @@ static void __init omap_nokia770_init(void)
386 hwa742_dev_init(); 386 hwa742_dev_init();
387 ads7846_dev_init(); 387 ads7846_dev_init();
388 mipid_dev_init(); 388 mipid_dev_init();
389 omap_usb_init(&nokia770_usb_config); 389 omap1_usb_init(&nokia770_usb_config);
390 nokia770_mmc_init(); 390 nokia770_mmc_init();
391} 391}
392 392
diff --git a/arch/arm/mach-omap1/board-osk.c b/arch/arm/mach-omap1/board-osk.c
index 80d862001def..b28c46a9ecce 100644
--- a/arch/arm/mach-omap1/board-osk.c
+++ b/arch/arm/mach-omap1/board-osk.c
@@ -560,7 +560,7 @@ static void __init osk_init(void)
560 l |= (3 << 1); 560 l |= (3 << 1);
561 omap_writel(l, USB_TRANSCEIVER_CTRL); 561 omap_writel(l, USB_TRANSCEIVER_CTRL);
562 562
563 omap_usb_init(&osk_usb_config); 563 omap1_usb_init(&osk_usb_config);
564 564
565 /* irq for tps65010 chip */ 565 /* irq for tps65010 chip */
566 /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */ 566 /* bootloader effectively does: omap_cfg_reg(U19_1610_MPUIO1); */
diff --git a/arch/arm/mach-omap1/board-palmte.c b/arch/arm/mach-omap1/board-palmte.c
index 569b4c9085cd..51d5c4dc7967 100644
--- a/arch/arm/mach-omap1/board-palmte.c
+++ b/arch/arm/mach-omap1/board-palmte.c
@@ -359,7 +359,7 @@ static void __init omap_palmte_init(void)
359 spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info)); 359 spi_register_board_info(palmte_spi_info, ARRAY_SIZE(palmte_spi_info));
360 palmte_misc_gpio_setup(); 360 palmte_misc_gpio_setup();
361 omap_serial_init(); 361 omap_serial_init();
362 omap_usb_init(&palmte_usb_config); 362 omap1_usb_init(&palmte_usb_config);
363 omap_register_i2c_bus(1, 100, NULL, 0); 363 omap_register_i2c_bus(1, 100, NULL, 0);
364} 364}
365 365
diff --git a/arch/arm/mach-omap1/board-palmtt.c b/arch/arm/mach-omap1/board-palmtt.c
index 6ad49a2cc1a0..c0bcfc6119db 100644
--- a/arch/arm/mach-omap1/board-palmtt.c
+++ b/arch/arm/mach-omap1/board-palmtt.c
@@ -307,7 +307,7 @@ static void __init omap_palmtt_init(void)
307 307
308 spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo)); 308 spi_register_board_info(palmtt_boardinfo,ARRAY_SIZE(palmtt_boardinfo));
309 omap_serial_init(); 309 omap_serial_init();
310 omap_usb_init(&palmtt_usb_config); 310 omap1_usb_init(&palmtt_usb_config);
311 omap_register_i2c_bus(1, 100, NULL, 0); 311 omap_register_i2c_bus(1, 100, NULL, 0);
312} 312}
313 313
diff --git a/arch/arm/mach-omap1/board-palmz71.c b/arch/arm/mach-omap1/board-palmz71.c
index 6641de9257ef..f431b44a71e3 100644
--- a/arch/arm/mach-omap1/board-palmz71.c
+++ b/arch/arm/mach-omap1/board-palmz71.c
@@ -325,7 +325,7 @@ omap_palmz71_init(void)
325 325
326 spi_register_board_info(palmz71_boardinfo, 326 spi_register_board_info(palmz71_boardinfo,
327 ARRAY_SIZE(palmz71_boardinfo)); 327 ARRAY_SIZE(palmz71_boardinfo));
328 omap_usb_init(&palmz71_usb_config); 328 omap1_usb_init(&palmz71_usb_config);
329 omap_serial_init(); 329 omap_serial_init();
330 omap_register_i2c_bus(1, 100, NULL, 0); 330 omap_register_i2c_bus(1, 100, NULL, 0);
331 palmz71_gpio_setup(0); 331 palmz71_gpio_setup(0);
diff --git a/arch/arm/mach-omap1/board-sx1.c b/arch/arm/mach-omap1/board-sx1.c
index 2fb1e5f8e2ec..7b21190a914a 100644
--- a/arch/arm/mach-omap1/board-sx1.c
+++ b/arch/arm/mach-omap1/board-sx1.c
@@ -392,7 +392,7 @@ static void __init omap_sx1_init(void)
392 omap_board_config_size = ARRAY_SIZE(sx1_config); 392 omap_board_config_size = ARRAY_SIZE(sx1_config);
393 omap_serial_init(); 393 omap_serial_init();
394 omap_register_i2c_bus(1, 100, NULL, 0); 394 omap_register_i2c_bus(1, 100, NULL, 0);
395 omap_usb_init(&sx1_usb_config); 395 omap1_usb_init(&sx1_usb_config);
396 sx1_mmc_init(); 396 sx1_mmc_init();
397 397
398 /* turn on USB power */ 398 /* turn on USB power */
diff --git a/arch/arm/mach-omap1/board-voiceblue.c b/arch/arm/mach-omap1/board-voiceblue.c
index 87b9436fe7c0..78107543d59b 100644
--- a/arch/arm/mach-omap1/board-voiceblue.c
+++ b/arch/arm/mach-omap1/board-voiceblue.c
@@ -198,7 +198,7 @@ static void __init voiceblue_init(void)
198 omap_board_config = voiceblue_config; 198 omap_board_config = voiceblue_config;
199 omap_board_config_size = ARRAY_SIZE(voiceblue_config); 199 omap_board_config_size = ARRAY_SIZE(voiceblue_config);
200 omap_serial_init(); 200 omap_serial_init();
201 omap_usb_init(&voiceblue_usb_config); 201 omap1_usb_init(&voiceblue_usb_config);
202 omap_register_i2c_bus(1, 100, NULL, 0); 202 omap_register_i2c_bus(1, 100, NULL, 0);
203 203
204 /* There is a good chance board is going up, so enable power LED 204 /* There is a good chance board is going up, so enable power LED
diff --git a/arch/arm/mach-omap1/usb.c b/arch/arm/mach-omap1/usb.c
new file mode 100644
index 000000000000..19de03b074e3
--- /dev/null
+++ b/arch/arm/mach-omap1/usb.c
@@ -0,0 +1,530 @@
1/*
2 * Platform level USB initialization for FS USB OTG controller on omap1 and 24xx
3 *
4 * Copyright (C) 2004 Texas Instruments, Inc.
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#include <linux/module.h>
22#include <linux/kernel.h>
23#include <linux/init.h>
24#include <linux/platform_device.h>
25#include <linux/io.h>
26
27#include <asm/irq.h>
28
29#include <plat/mux.h>
30#include <plat/usb.h>
31
32/* These routines should handle the standard chip-specific modes
33 * for usb0/1/2 ports, covering basic mux and transceiver setup.
34 *
35 * Some board-*.c files will need to set up additional mux options,
36 * like for suspend handling, vbus sensing, GPIOs, and the D+ pullup.
37 */
38
39/* TESTED ON:
40 * - 1611B H2 (with usb1 mini-AB) using standard Mini-B or OTG cables
41 * - 5912 OSK OHCI (with usb0 standard-A), standard A-to-B cables
42 * - 5912 OSK UDC, with *nonstandard* A-to-A cable
43 * - 1510 Innovator UDC with bundled usb0 cable
44 * - 1510 Innovator OHCI with bundled usb1/usb2 cable
45 * - 1510 Innovator OHCI with custom usb0 cable, feeding 5V VBUS
46 * - 1710 custom development board using alternate pin group
47 * - 1710 H3 (with usb1 mini-AB) using standard Mini-B or OTG cables
48 */
49
50#define INT_USB_IRQ_GEN IH2_BASE + 20
51#define INT_USB_IRQ_NISO IH2_BASE + 30
52#define INT_USB_IRQ_ISO IH2_BASE + 29
53#define INT_USB_IRQ_HGEN INT_USB_HHC_1
54#define INT_USB_IRQ_OTG IH2_BASE + 8
55
56#ifdef CONFIG_USB_GADGET_OMAP
57
58static struct resource udc_resources[] = {
59 /* order is significant! */
60 { /* registers */
61 .start = UDC_BASE,
62 .end = UDC_BASE + 0xff,
63 .flags = IORESOURCE_MEM,
64 }, { /* general IRQ */
65 .start = INT_USB_IRQ_GEN,
66 .flags = IORESOURCE_IRQ,
67 }, { /* PIO IRQ */
68 .start = INT_USB_IRQ_NISO,
69 .flags = IORESOURCE_IRQ,
70 }, { /* SOF IRQ */
71 .start = INT_USB_IRQ_ISO,
72 .flags = IORESOURCE_IRQ,
73 },
74};
75
76static u64 udc_dmamask = ~(u32)0;
77
78static struct platform_device udc_device = {
79 .name = "omap_udc",
80 .id = -1,
81 .dev = {
82 .dma_mask = &udc_dmamask,
83 .coherent_dma_mask = 0xffffffff,
84 },
85 .num_resources = ARRAY_SIZE(udc_resources),
86 .resource = udc_resources,
87};
88
89static inline void udc_device_init(struct omap_usb_config *pdata)
90{
91 /* IRQ numbers for omap7xx */
92 if(cpu_is_omap7xx()) {
93 udc_resources[1].start = INT_7XX_USB_GENI;
94 udc_resources[2].start = INT_7XX_USB_NON_ISO;
95 udc_resources[3].start = INT_7XX_USB_ISO;
96 }
97 pdata->udc_device = &udc_device;
98}
99
100#else
101
102static inline void udc_device_init(struct omap_usb_config *pdata)
103{
104}
105
106#endif
107
108#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
109
110/* The dmamask must be set for OHCI to work */
111static u64 ohci_dmamask = ~(u32)0;
112
113static struct resource ohci_resources[] = {
114 {
115 .start = OMAP_OHCI_BASE,
116 .end = OMAP_OHCI_BASE + 0xff,
117 .flags = IORESOURCE_MEM,
118 },
119 {
120 .start = INT_USB_IRQ_HGEN,
121 .flags = IORESOURCE_IRQ,
122 },
123};
124
125static struct platform_device ohci_device = {
126 .name = "ohci",
127 .id = -1,
128 .dev = {
129 .dma_mask = &ohci_dmamask,
130 .coherent_dma_mask = 0xffffffff,
131 },
132 .num_resources = ARRAY_SIZE(ohci_resources),
133 .resource = ohci_resources,
134};
135
136static inline void ohci_device_init(struct omap_usb_config *pdata)
137{
138 if (cpu_is_omap7xx())
139 ohci_resources[1].start = INT_7XX_USB_HHC_1;
140 pdata->ohci_device = &ohci_device;
141}
142
143#else
144
145static inline void ohci_device_init(struct omap_usb_config *pdata)
146{
147}
148
149#endif
150
151#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
152
153static struct resource otg_resources[] = {
154 /* order is significant! */
155 {
156 .start = OTG_BASE,
157 .end = OTG_BASE + 0xff,
158 .flags = IORESOURCE_MEM,
159 }, {
160 .start = INT_USB_IRQ_OTG,
161 .flags = IORESOURCE_IRQ,
162 },
163};
164
165static struct platform_device otg_device = {
166 .name = "omap_otg",
167 .id = -1,
168 .num_resources = ARRAY_SIZE(otg_resources),
169 .resource = otg_resources,
170};
171
172static inline void otg_device_init(struct omap_usb_config *pdata)
173{
174 if (cpu_is_omap7xx())
175 otg_resources[1].start = INT_7XX_USB_OTG;
176 pdata->otg_device = &otg_device;
177}
178
179#else
180
181static inline void otg_device_init(struct omap_usb_config *pdata)
182{
183}
184
185#endif
186
187u32 __init omap1_usb0_init(unsigned nwires, unsigned is_device)
188{
189 u32 syscon1 = 0;
190
191 if (nwires == 0) {
192 if (!cpu_is_omap15xx()) {
193 u32 l;
194
195 /* pulldown D+/D- */
196 l = omap_readl(USB_TRANSCEIVER_CTRL);
197 l &= ~(3 << 1);
198 omap_writel(l, USB_TRANSCEIVER_CTRL);
199 }
200 return 0;
201 }
202
203 if (is_device) {
204 if (cpu_is_omap7xx()) {
205 omap_cfg_reg(AA17_7XX_USB_DM);
206 omap_cfg_reg(W16_7XX_USB_PU_EN);
207 omap_cfg_reg(W17_7XX_USB_VBUSI);
208 omap_cfg_reg(W18_7XX_USB_DMCK_OUT);
209 omap_cfg_reg(W19_7XX_USB_DCRST);
210 } else
211 omap_cfg_reg(W4_USB_PUEN);
212 }
213
214 if (nwires == 2) {
215 u32 l;
216
217 // omap_cfg_reg(P9_USB_DP);
218 // omap_cfg_reg(R8_USB_DM);
219
220 if (cpu_is_omap15xx()) {
221 /* This works on 1510-Innovator */
222 return 0;
223 }
224
225 /* NOTES:
226 * - peripheral should configure VBUS detection!
227 * - only peripherals may use the internal D+/D- pulldowns
228 * - OTG support on this port not yet written
229 */
230
231 /* Don't do this for omap7xx -- it causes USB to not work correctly */
232 if (!cpu_is_omap7xx()) {
233 l = omap_readl(USB_TRANSCEIVER_CTRL);
234 l &= ~(7 << 4);
235 if (!is_device)
236 l |= (3 << 1);
237 omap_writel(l, USB_TRANSCEIVER_CTRL);
238 }
239
240 return 3 << 16;
241 }
242
243 /* alternate pin config, external transceiver */
244 if (cpu_is_omap15xx()) {
245 printk(KERN_ERR "no usb0 alt pin config on 15xx\n");
246 return 0;
247 }
248
249 omap_cfg_reg(V6_USB0_TXD);
250 omap_cfg_reg(W9_USB0_TXEN);
251 omap_cfg_reg(W5_USB0_SE0);
252 if (nwires != 3)
253 omap_cfg_reg(Y5_USB0_RCV);
254
255 /* NOTE: SPEED and SUSP aren't configured here. OTG hosts
256 * may be able to use I2C requests to set those bits along
257 * with VBUS switching and overcurrent detection.
258 */
259
260 if (nwires != 6) {
261 u32 l;
262
263 l = omap_readl(USB_TRANSCEIVER_CTRL);
264 l &= ~CONF_USB2_UNI_R;
265 omap_writel(l, USB_TRANSCEIVER_CTRL);
266 }
267
268 switch (nwires) {
269 case 3:
270 syscon1 = 2;
271 break;
272 case 4:
273 syscon1 = 1;
274 break;
275 case 6:
276 syscon1 = 3;
277 {
278 u32 l;
279
280 omap_cfg_reg(AA9_USB0_VP);
281 omap_cfg_reg(R9_USB0_VM);
282 l = omap_readl(USB_TRANSCEIVER_CTRL);
283 l |= CONF_USB2_UNI_R;
284 omap_writel(l, USB_TRANSCEIVER_CTRL);
285 }
286 break;
287 default:
288 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
289 0, nwires);
290 }
291
292 return syscon1 << 16;
293}
294
295u32 __init omap1_usb1_init(unsigned nwires)
296{
297 u32 syscon1 = 0;
298
299 if (!cpu_is_omap15xx() && nwires != 6) {
300 u32 l;
301
302 l = omap_readl(USB_TRANSCEIVER_CTRL);
303 l &= ~CONF_USB1_UNI_R;
304 omap_writel(l, USB_TRANSCEIVER_CTRL);
305 }
306 if (nwires == 0)
307 return 0;
308
309 /* external transceiver */
310 omap_cfg_reg(USB1_TXD);
311 omap_cfg_reg(USB1_TXEN);
312 if (nwires != 3)
313 omap_cfg_reg(USB1_RCV);
314
315 if (cpu_is_omap15xx()) {
316 omap_cfg_reg(USB1_SEO);
317 omap_cfg_reg(USB1_SPEED);
318 // SUSP
319 } else if (cpu_is_omap1610() || cpu_is_omap5912()) {
320 omap_cfg_reg(W13_1610_USB1_SE0);
321 omap_cfg_reg(R13_1610_USB1_SPEED);
322 // SUSP
323 } else if (cpu_is_omap1710()) {
324 omap_cfg_reg(R13_1710_USB1_SE0);
325 // SUSP
326 } else {
327 pr_debug("usb%d cpu unrecognized\n", 1);
328 return 0;
329 }
330
331 switch (nwires) {
332 case 2:
333 goto bad;
334 case 3:
335 syscon1 = 2;
336 break;
337 case 4:
338 syscon1 = 1;
339 break;
340 case 6:
341 syscon1 = 3;
342 omap_cfg_reg(USB1_VP);
343 omap_cfg_reg(USB1_VM);
344 if (!cpu_is_omap15xx()) {
345 u32 l;
346
347 l = omap_readl(USB_TRANSCEIVER_CTRL);
348 l |= CONF_USB1_UNI_R;
349 omap_writel(l, USB_TRANSCEIVER_CTRL);
350 }
351 break;
352 default:
353bad:
354 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
355 1, nwires);
356 }
357
358 return syscon1 << 20;
359}
360
361u32 __init omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
362{
363 u32 syscon1 = 0;
364
365 /* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */
366 if (alt_pingroup || nwires == 0)
367 return 0;
368
369 if (!cpu_is_omap15xx() && nwires != 6) {
370 u32 l;
371
372 l = omap_readl(USB_TRANSCEIVER_CTRL);
373 l &= ~CONF_USB2_UNI_R;
374 omap_writel(l, USB_TRANSCEIVER_CTRL);
375 }
376
377 /* external transceiver */
378 if (cpu_is_omap15xx()) {
379 omap_cfg_reg(USB2_TXD);
380 omap_cfg_reg(USB2_TXEN);
381 omap_cfg_reg(USB2_SEO);
382 if (nwires != 3)
383 omap_cfg_reg(USB2_RCV);
384 /* there is no USB2_SPEED */
385 } else if (cpu_is_omap16xx()) {
386 omap_cfg_reg(V6_USB2_TXD);
387 omap_cfg_reg(W9_USB2_TXEN);
388 omap_cfg_reg(W5_USB2_SE0);
389 if (nwires != 3)
390 omap_cfg_reg(Y5_USB2_RCV);
391 // FIXME omap_cfg_reg(USB2_SPEED);
392 } else {
393 pr_debug("usb%d cpu unrecognized\n", 1);
394 return 0;
395 }
396
397 // omap_cfg_reg(USB2_SUSP);
398
399 switch (nwires) {
400 case 2:
401 goto bad;
402 case 3:
403 syscon1 = 2;
404 break;
405 case 4:
406 syscon1 = 1;
407 break;
408 case 5:
409 goto bad;
410 case 6:
411 syscon1 = 3;
412 if (cpu_is_omap15xx()) {
413 omap_cfg_reg(USB2_VP);
414 omap_cfg_reg(USB2_VM);
415 } else {
416 u32 l;
417
418 omap_cfg_reg(AA9_USB2_VP);
419 omap_cfg_reg(R9_USB2_VM);
420 l = omap_readl(USB_TRANSCEIVER_CTRL);
421 l |= CONF_USB2_UNI_R;
422 omap_writel(l, USB_TRANSCEIVER_CTRL);
423 }
424 break;
425 default:
426bad:
427 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
428 2, nwires);
429 }
430
431 return syscon1 << 24;
432}
433
434#ifdef CONFIG_ARCH_OMAP15XX
435
436/* ULPD_DPLL_CTRL */
437#define DPLL_IOB (1 << 13)
438#define DPLL_PLL_ENABLE (1 << 4)
439#define DPLL_LOCK (1 << 0)
440
441/* ULPD_APLL_CTRL */
442#define APLL_NDPLL_SWITCH (1 << 0)
443
444static void __init omap_1510_usb_init(struct omap_usb_config *config)
445{
446 unsigned int val;
447 u16 w;
448
449 config->usb0_init(config->pins[0], is_usb0_device(config));
450 config->usb1_init(config->pins[1]);
451 config->usb2_init(config->pins[2], 0);
452
453 val = omap_readl(MOD_CONF_CTRL_0) & ~(0x3f << 1);
454 val |= (config->hmc_mode << 1);
455 omap_writel(val, MOD_CONF_CTRL_0);
456
457 printk("USB: hmc %d", config->hmc_mode);
458 if (config->pins[0])
459 printk(", usb0 %d wires%s", config->pins[0],
460 is_usb0_device(config) ? " (dev)" : "");
461 if (config->pins[1])
462 printk(", usb1 %d wires", config->pins[1]);
463 if (config->pins[2])
464 printk(", usb2 %d wires", config->pins[2]);
465 printk("\n");
466
467 /* use DPLL for 48 MHz function clock */
468 pr_debug("APLL %04x DPLL %04x REQ %04x\n", omap_readw(ULPD_APLL_CTRL),
469 omap_readw(ULPD_DPLL_CTRL), omap_readw(ULPD_SOFT_REQ));
470
471 w = omap_readw(ULPD_APLL_CTRL);
472 w &= ~APLL_NDPLL_SWITCH;
473 omap_writew(w, ULPD_APLL_CTRL);
474
475 w = omap_readw(ULPD_DPLL_CTRL);
476 w |= DPLL_IOB | DPLL_PLL_ENABLE;
477 omap_writew(w, ULPD_DPLL_CTRL);
478
479 w = omap_readw(ULPD_SOFT_REQ);
480 w |= SOFT_UDC_REQ | SOFT_DPLL_REQ;
481 omap_writew(w, ULPD_SOFT_REQ);
482
483 while (!(omap_readw(ULPD_DPLL_CTRL) & DPLL_LOCK))
484 cpu_relax();
485
486#ifdef CONFIG_USB_GADGET_OMAP
487 if (config->register_dev) {
488 int status;
489
490 udc_device.dev.platform_data = config;
491 status = platform_device_register(&udc_device);
492 if (status)
493 pr_debug("can't register UDC device, %d\n", status);
494 /* udc driver gates 48MHz by D+ pullup */
495 }
496#endif
497
498#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
499 if (config->register_host) {
500 int status;
501
502 ohci_device.dev.platform_data = config;
503 status = platform_device_register(&ohci_device);
504 if (status)
505 pr_debug("can't register OHCI device, %d\n", status);
506 /* hcd explicitly gates 48MHz */
507 }
508#endif
509}
510
511#else
512static inline void omap_1510_usb_init(struct omap_usb_config *config) {}
513#endif
514
515void __init omap1_usb_init(struct omap_usb_config *pdata)
516{
517 pdata->usb0_init = omap1_usb0_init;
518 pdata->usb1_init = omap1_usb1_init;
519 pdata->usb2_init = omap1_usb2_init;
520 udc_device_init(pdata);
521 ohci_device_init(pdata);
522 otg_device_init(pdata);
523
524 if (cpu_is_omap7xx() || cpu_is_omap16xx())
525 omap_otg_init(pdata);
526 else if (cpu_is_omap15xx())
527 omap_1510_usb_init(pdata);
528 else
529 printk(KERN_ERR "USB: No init for your chip yet\n");
530}
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 9f792244e77c..2a9427c8cc48 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -81,8 +81,28 @@ extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata);
81 81
82#endif 82#endif
83 83
84
85/*
86 * FIXME correct answer depends on hmc_mode,
87 * as does (on omap1) any nonzero value for config->otg port number
88 */
89#ifdef CONFIG_USB_GADGET_OMAP
90#define is_usb0_device(config) 1
91#else
92#define is_usb0_device(config) 0
93#endif
94
84void omap_otg_init(struct omap_usb_config *config); 95void omap_otg_init(struct omap_usb_config *config);
85void omap_usb_init(struct omap_usb_config *pdata); 96
97#if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
98void omap1_usb_init(struct omap_usb_config *pdata);
99#else
100static inline void omap1_usb_init(struct omap_usb_config *pdata)
101{
102}
103#endif
104
105#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP_OTG_MODULE)
86void omap2_usbfs_init(struct omap_usb_config *pdata); 106void omap2_usbfs_init(struct omap_usb_config *pdata);
87#else 107#else
88static inline omap2_usbfs_init(struct omap_usb_config *pdata) 108static inline omap2_usbfs_init(struct omap_usb_config *pdata)
@@ -199,4 +219,24 @@ static inline omap2_usbfs_init(struct omap_usb_config *pdata)
199# define USB0PUENACTLOI (1 << 16) 219# define USB0PUENACTLOI (1 << 16)
200# define USBSTANDBYCTRL (1 << 15) 220# define USBSTANDBYCTRL (1 << 15)
201 221
222#if defined(CONFIG_ARCH_OMAP1) && defined(CONFIG_USB)
223u32 omap1_usb0_init(unsigned nwires, unsigned is_device);
224u32 omap1_usb1_init(unsigned nwires);
225u32 omap1_usb2_init(unsigned nwires, unsigned alt_pingroup);
226#else
227static inline u32 omap1_usb0_init(unsigned nwires, unsigned is_device)
228{
229 return 0;
230}
231static inline u32 omap1_usb1_init(unsigned nwires)
232{
233 return 0;
234
235}
236static inline u32 omap1_usb2_init(unsigned nwires, unsigned alt_pingroup)
237{
238 return 0;
239}
240#endif
241
202#endif /* __ASM_ARCH_OMAP_USB_H */ 242#endif /* __ASM_ARCH_OMAP_USB_H */
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
index 27b471ce11a0..f3570884883e 100644
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -22,434 +22,13 @@
22 22
23#include <linux/module.h> 23#include <linux/module.h>
24#include <linux/kernel.h> 24#include <linux/kernel.h>
25#include <linux/types.h>
26#include <linux/errno.h>
27#include <linux/init.h> 25#include <linux/init.h>
28#include <linux/platform_device.h> 26#include <linux/platform_device.h>
29#include <linux/usb/otg.h>
30#include <linux/io.h> 27#include <linux/io.h>
31 28
32#include <asm/irq.h>
33#include <asm/system.h>
34#include <mach/hardware.h>
35
36#include <plat/control.h>
37#include <plat/mux.h>
38#include <plat/usb.h> 29#include <plat/usb.h>
39#include <plat/board.h> 30#include <plat/board.h>
40 31
41#define INT_USB_IRQ_GEN IH2_BASE + 20
42#define INT_USB_IRQ_NISO IH2_BASE + 30
43#define INT_USB_IRQ_ISO IH2_BASE + 29
44#define INT_USB_IRQ_HGEN INT_USB_HHC_1
45#define INT_USB_IRQ_OTG IH2_BASE + 8
46
47/* These routines should handle the standard chip-specific modes
48 * for usb0/1/2 ports, covering basic mux and transceiver setup.
49 *
50 * Some board-*.c files will need to set up additional mux options,
51 * like for suspend handling, vbus sensing, GPIOs, and the D+ pullup.
52 */
53
54/* TESTED ON:
55 * - 1611B H2 (with usb1 mini-AB) using standard Mini-B or OTG cables
56 * - 5912 OSK OHCI (with usb0 standard-A), standard A-to-B cables
57 * - 5912 OSK UDC, with *nonstandard* A-to-A cable
58 * - 1510 Innovator UDC with bundled usb0 cable
59 * - 1510 Innovator OHCI with bundled usb1/usb2 cable
60 * - 1510 Innovator OHCI with custom usb0 cable, feeding 5V VBUS
61 * - 1710 custom development board using alternate pin group
62 * - 1710 H3 (with usb1 mini-AB) using standard Mini-B or OTG cables
63 */
64
65/*-------------------------------------------------------------------------*/
66
67#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP15XX)
68
69static u32 __init omap_usb0_init(unsigned nwires, unsigned is_device)
70{
71 u32 syscon1 = 0;
72
73 if (nwires == 0) {
74 if (!cpu_is_omap15xx()) {
75 u32 l;
76
77 /* pulldown D+/D- */
78 l = omap_readl(USB_TRANSCEIVER_CTRL);
79 l &= ~(3 << 1);
80 omap_writel(l, USB_TRANSCEIVER_CTRL);
81 }
82 return 0;
83 }
84
85 if (is_device) {
86 if (cpu_is_omap7xx()) {
87 omap_cfg_reg(AA17_7XX_USB_DM);
88 omap_cfg_reg(W16_7XX_USB_PU_EN);
89 omap_cfg_reg(W17_7XX_USB_VBUSI);
90 omap_cfg_reg(W18_7XX_USB_DMCK_OUT);
91 omap_cfg_reg(W19_7XX_USB_DCRST);
92 } else
93 omap_cfg_reg(W4_USB_PUEN);
94 }
95
96 if (nwires == 2) {
97 u32 l;
98
99 // omap_cfg_reg(P9_USB_DP);
100 // omap_cfg_reg(R8_USB_DM);
101
102 if (cpu_is_omap15xx()) {
103 /* This works on 1510-Innovator */
104 return 0;
105 }
106
107 /* NOTES:
108 * - peripheral should configure VBUS detection!
109 * - only peripherals may use the internal D+/D- pulldowns
110 * - OTG support on this port not yet written
111 */
112
113 /* Don't do this for omap7xx -- it causes USB to not work correctly */
114 if (!cpu_is_omap7xx()) {
115 l = omap_readl(USB_TRANSCEIVER_CTRL);
116 l &= ~(7 << 4);
117 if (!is_device)
118 l |= (3 << 1);
119 omap_writel(l, USB_TRANSCEIVER_CTRL);
120 }
121
122 return 3 << 16;
123 }
124
125 /* alternate pin config, external transceiver */
126 if (cpu_is_omap15xx()) {
127 printk(KERN_ERR "no usb0 alt pin config on 15xx\n");
128 return 0;
129 }
130
131 omap_cfg_reg(V6_USB0_TXD);
132 omap_cfg_reg(W9_USB0_TXEN);
133 omap_cfg_reg(W5_USB0_SE0);
134 if (nwires != 3)
135 omap_cfg_reg(Y5_USB0_RCV);
136
137 /* NOTE: SPEED and SUSP aren't configured here. OTG hosts
138 * may be able to use I2C requests to set those bits along
139 * with VBUS switching and overcurrent detection.
140 */
141
142 if (nwires != 6) {
143 u32 l;
144
145 l = omap_readl(USB_TRANSCEIVER_CTRL);
146 l &= ~CONF_USB2_UNI_R;
147 omap_writel(l, USB_TRANSCEIVER_CTRL);
148 }
149
150 switch (nwires) {
151 case 3:
152 syscon1 = 2;
153 break;
154 case 4:
155 syscon1 = 1;
156 break;
157 case 6:
158 syscon1 = 3;
159 {
160 u32 l;
161
162 omap_cfg_reg(AA9_USB0_VP);
163 omap_cfg_reg(R9_USB0_VM);
164 l = omap_readl(USB_TRANSCEIVER_CTRL);
165 l |= CONF_USB2_UNI_R;
166 omap_writel(l, USB_TRANSCEIVER_CTRL);
167 }
168 break;
169 default:
170 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
171 0, nwires);
172 }
173 return syscon1 << 16;
174}
175
176static u32 __init omap_usb1_init(unsigned nwires)
177{
178 u32 syscon1 = 0;
179
180 if (!cpu_is_omap15xx() && nwires != 6) {
181 u32 l;
182
183 l = omap_readl(USB_TRANSCEIVER_CTRL);
184 l &= ~CONF_USB1_UNI_R;
185 omap_writel(l, USB_TRANSCEIVER_CTRL);
186 }
187 if (nwires == 0)
188 return 0;
189
190 /* external transceiver */
191 omap_cfg_reg(USB1_TXD);
192 omap_cfg_reg(USB1_TXEN);
193 if (nwires != 3)
194 omap_cfg_reg(USB1_RCV);
195
196 if (cpu_is_omap15xx()) {
197 omap_cfg_reg(USB1_SEO);
198 omap_cfg_reg(USB1_SPEED);
199 // SUSP
200 } else if (cpu_is_omap1610() || cpu_is_omap5912()) {
201 omap_cfg_reg(W13_1610_USB1_SE0);
202 omap_cfg_reg(R13_1610_USB1_SPEED);
203 // SUSP
204 } else if (cpu_is_omap1710()) {
205 omap_cfg_reg(R13_1710_USB1_SE0);
206 // SUSP
207 } else {
208 pr_debug("usb%d cpu unrecognized\n", 1);
209 return 0;
210 }
211
212 switch (nwires) {
213 case 2:
214 goto bad;
215 case 3:
216 syscon1 = 2;
217 break;
218 case 4:
219 syscon1 = 1;
220 break;
221 case 6:
222 syscon1 = 3;
223 omap_cfg_reg(USB1_VP);
224 omap_cfg_reg(USB1_VM);
225 if (!cpu_is_omap15xx()) {
226 u32 l;
227
228 l = omap_readl(USB_TRANSCEIVER_CTRL);
229 l |= CONF_USB1_UNI_R;
230 omap_writel(l, USB_TRANSCEIVER_CTRL);
231 }
232 break;
233 default:
234bad:
235 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
236 1, nwires);
237 }
238 return syscon1 << 20;
239}
240
241static u32 __init omap_usb2_init(unsigned nwires, unsigned alt_pingroup)
242{
243 u32 syscon1 = 0;
244
245 /* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */
246 if (alt_pingroup || nwires == 0)
247 return 0;
248
249 if (!cpu_is_omap15xx() && nwires != 6) {
250 u32 l;
251
252 l = omap_readl(USB_TRANSCEIVER_CTRL);
253 l &= ~CONF_USB2_UNI_R;
254 omap_writel(l, USB_TRANSCEIVER_CTRL);
255 }
256
257 /* external transceiver */
258 if (cpu_is_omap15xx()) {
259 omap_cfg_reg(USB2_TXD);
260 omap_cfg_reg(USB2_TXEN);
261 omap_cfg_reg(USB2_SEO);
262 if (nwires != 3)
263 omap_cfg_reg(USB2_RCV);
264 /* there is no USB2_SPEED */
265 } else if (cpu_is_omap16xx()) {
266 omap_cfg_reg(V6_USB2_TXD);
267 omap_cfg_reg(W9_USB2_TXEN);
268 omap_cfg_reg(W5_USB2_SE0);
269 if (nwires != 3)
270 omap_cfg_reg(Y5_USB2_RCV);
271 // FIXME omap_cfg_reg(USB2_SPEED);
272 } else {
273 pr_debug("usb%d cpu unrecognized\n", 1);
274 return 0;
275 }
276 // omap_cfg_reg(USB2_SUSP);
277
278 switch (nwires) {
279 case 2:
280 goto bad;
281 case 3:
282 syscon1 = 2;
283 break;
284 case 4:
285 syscon1 = 1;
286 break;
287 case 5:
288 goto bad;
289 case 6:
290 syscon1 = 3;
291 if (cpu_is_omap15xx()) {
292 omap_cfg_reg(USB2_VP);
293 omap_cfg_reg(USB2_VM);
294 } else {
295 u32 l;
296
297 omap_cfg_reg(AA9_USB2_VP);
298 omap_cfg_reg(R9_USB2_VM);
299 l = omap_readl(USB_TRANSCEIVER_CTRL);
300 l |= CONF_USB2_UNI_R;
301 omap_writel(l, USB_TRANSCEIVER_CTRL);
302 }
303 break;
304 default:
305bad:
306 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
307 2, nwires);
308 }
309 return syscon1 << 24;
310}
311
312#else
313#define omap_usb0_init NULL
314#define omap_usb1_init NULL
315#define omap_usb2_init NULL
316#endif
317
318/*-------------------------------------------------------------------------*/
319
320#ifdef CONFIG_USB_GADGET_OMAP
321
322static struct resource udc_resources[] = {
323 /* order is significant! */
324 { /* registers */
325 .start = UDC_BASE,
326 .end = UDC_BASE + 0xff,
327 .flags = IORESOURCE_MEM,
328 }, { /* general IRQ */
329 .start = INT_USB_IRQ_GEN,
330 .flags = IORESOURCE_IRQ,
331 }, { /* PIO IRQ */
332 .start = INT_USB_IRQ_NISO,
333 .flags = IORESOURCE_IRQ,
334 }, { /* SOF IRQ */
335 .start = INT_USB_IRQ_ISO,
336 .flags = IORESOURCE_IRQ,
337 },
338};
339
340static u64 udc_dmamask = ~(u32)0;
341
342static struct platform_device udc_device = {
343 .name = "omap_udc",
344 .id = -1,
345 .dev = {
346 .dma_mask = &udc_dmamask,
347 .coherent_dma_mask = 0xffffffff,
348 },
349 .num_resources = ARRAY_SIZE(udc_resources),
350 .resource = udc_resources,
351};
352
353static inline void udc_device_init(struct omap_usb_config *pdata)
354{
355 pdata->udc_device = &udc_device;
356}
357
358#else
359
360static inline void udc_device_init(struct omap_usb_config *pdata)
361{
362}
363
364#endif
365
366#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
367
368/* The dmamask must be set for OHCI to work */
369static u64 ohci_dmamask = ~(u32)0;
370
371static struct resource ohci_resources[] = {
372 {
373 .start = OMAP_OHCI_BASE,
374 .end = OMAP_OHCI_BASE + 0xff,
375 .flags = IORESOURCE_MEM,
376 },
377 {
378 .start = INT_USB_IRQ_HGEN,
379 .flags = IORESOURCE_IRQ,
380 },
381};
382
383static struct platform_device ohci_device = {
384 .name = "ohci",
385 .id = -1,
386 .dev = {
387 .dma_mask = &ohci_dmamask,
388 .coherent_dma_mask = 0xffffffff,
389 },
390 .num_resources = ARRAY_SIZE(ohci_resources),
391 .resource = ohci_resources,
392};
393
394static inline void ohci_device_init(struct omap_usb_config *pdata)
395{
396 pdata->ohci_device = &ohci_device;
397}
398
399#else
400
401static inline void ohci_device_init(struct omap_usb_config *pdata)
402{
403}
404
405#endif
406
407#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
408
409static struct resource otg_resources[] = {
410 /* order is significant! */
411 {
412 .start = OTG_BASE,
413 .end = OTG_BASE + 0xff,
414 .flags = IORESOURCE_MEM,
415 }, {
416 .start = INT_USB_IRQ_OTG,
417 .flags = IORESOURCE_IRQ,
418 },
419};
420
421static struct platform_device otg_device = {
422 .name = "omap_otg",
423 .id = -1,
424 .num_resources = ARRAY_SIZE(otg_resources),
425 .resource = otg_resources,
426};
427
428static inline void otg_device_init(struct omap_usb_config *pdata)
429{
430 pdata->otg_device = &otg_device;
431}
432
433#else
434
435static inline void otg_device_init(struct omap_usb_config *pdata)
436{
437}
438
439#endif
440
441/*-------------------------------------------------------------------------*/
442
443// FIXME correct answer depends on hmc_mode,
444// as does (on omap1) any nonzero value for config->otg port number
445#ifdef CONFIG_USB_GADGET_OMAP
446#define is_usb0_device(config) 1
447#else
448#define is_usb0_device(config) 0
449#endif
450
451/*-------------------------------------------------------------------------*/
452
453#ifdef CONFIG_ARCH_OMAP_OTG 32#ifdef CONFIG_ARCH_OMAP_OTG
454 33
455void __init 34void __init
@@ -524,12 +103,6 @@ omap_otg_init(struct omap_usb_config *config)
524 103
525 syscon &= ~DEV_IDLE_EN; 104 syscon &= ~DEV_IDLE_EN;
526 udc_device->dev.platform_data = config; 105 udc_device->dev.platform_data = config;
527 /* IRQ numbers for omap7xx */
528 if(cpu_is_omap7xx()) {
529 udc_resources[1].start = INT_7XX_USB_GENI;
530 udc_resources[2].start = INT_7XX_USB_NON_ISO;
531 udc_resources[3].start = INT_7XX_USB_ISO;
532 }
533 status = platform_device_register(udc_device); 106 status = platform_device_register(udc_device);
534 if (status) 107 if (status)
535 pr_debug("can't register UDC device, %d\n", status); 108 pr_debug("can't register UDC device, %d\n", status);
@@ -542,8 +115,6 @@ omap_otg_init(struct omap_usb_config *config)
542 115
543 syscon &= ~HST_IDLE_EN; 116 syscon &= ~HST_IDLE_EN;
544 ohci_device->dev.platform_data = config; 117 ohci_device->dev.platform_data = config;
545 if (cpu_is_omap7xx())
546 ohci_resources[1].start = INT_7XX_USB_HHC_1;
547 status = platform_device_register(ohci_device); 118 status = platform_device_register(ohci_device);
548 if (status) 119 if (status)
549 pr_debug("can't register OHCI device, %d\n", status); 120 pr_debug("can't register OHCI device, %d\n", status);
@@ -556,8 +127,6 @@ omap_otg_init(struct omap_usb_config *config)
556 127
557 syscon &= ~OTG_IDLE_EN; 128 syscon &= ~OTG_IDLE_EN;
558 otg_device->dev.platform_data = config; 129 otg_device->dev.platform_data = config;
559 if (cpu_is_omap7xx())
560 otg_resources[1].start = INT_7XX_USB_OTG;
561 status = platform_device_register(otg_device); 130 status = platform_device_register(otg_device);
562 if (status) 131 if (status)
563 pr_debug("can't register OTG device, %d\n", status); 132 pr_debug("can't register OTG device, %d\n", status);
@@ -572,107 +141,3 @@ omap_otg_init(struct omap_usb_config *config)
572#else 141#else
573void omap_otg_init(struct omap_usb_config *config) {} 142void omap_otg_init(struct omap_usb_config *config) {}
574#endif 143#endif
575
576/*-------------------------------------------------------------------------*/
577
578#ifdef CONFIG_ARCH_OMAP15XX
579
580/* ULPD_DPLL_CTRL */
581#define DPLL_IOB (1 << 13)
582#define DPLL_PLL_ENABLE (1 << 4)
583#define DPLL_LOCK (1 << 0)
584
585/* ULPD_APLL_CTRL */
586#define APLL_NDPLL_SWITCH (1 << 0)
587
588
589static void __init omap_1510_usb_init(struct omap_usb_config *config)
590{
591 unsigned int val;
592 u16 w;
593
594 config->usb0_init(config->pins[0], is_usb0_device(config));
595 config->usb1_init(config->pins[1]);
596 config->usb2_init(config->pins[2], 0);
597
598 val = omap_readl(MOD_CONF_CTRL_0) & ~(0x3f << 1);
599 val |= (config->hmc_mode << 1);
600 omap_writel(val, MOD_CONF_CTRL_0);
601
602 printk("USB: hmc %d", config->hmc_mode);
603 if (config->pins[0])
604 printk(", usb0 %d wires%s", config->pins[0],
605 is_usb0_device(config) ? " (dev)" : "");
606 if (config->pins[1])
607 printk(", usb1 %d wires", config->pins[1]);
608 if (config->pins[2])
609 printk(", usb2 %d wires", config->pins[2]);
610 printk("\n");
611
612 /* use DPLL for 48 MHz function clock */
613 pr_debug("APLL %04x DPLL %04x REQ %04x\n", omap_readw(ULPD_APLL_CTRL),
614 omap_readw(ULPD_DPLL_CTRL), omap_readw(ULPD_SOFT_REQ));
615
616 w = omap_readw(ULPD_APLL_CTRL);
617 w &= ~APLL_NDPLL_SWITCH;
618 omap_writew(w, ULPD_APLL_CTRL);
619
620 w = omap_readw(ULPD_DPLL_CTRL);
621 w |= DPLL_IOB | DPLL_PLL_ENABLE;
622 omap_writew(w, ULPD_DPLL_CTRL);
623
624 w = omap_readw(ULPD_SOFT_REQ);
625 w |= SOFT_UDC_REQ | SOFT_DPLL_REQ;
626 omap_writew(w, ULPD_SOFT_REQ);
627
628 while (!(omap_readw(ULPD_DPLL_CTRL) & DPLL_LOCK))
629 cpu_relax();
630
631#ifdef CONFIG_USB_GADGET_OMAP
632 if (config->register_dev) {
633 int status;
634
635 udc_device.dev.platform_data = config;
636 status = platform_device_register(&udc_device);
637 if (status)
638 pr_debug("can't register UDC device, %d\n", status);
639 /* udc driver gates 48MHz by D+ pullup */
640 }
641#endif
642
643#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
644 if (config->register_host) {
645 int status;
646
647 ohci_device.dev.platform_data = config;
648 status = platform_device_register(&ohci_device);
649 if (status)
650 pr_debug("can't register OHCI device, %d\n", status);
651 /* hcd explicitly gates 48MHz */
652 }
653#endif
654}
655
656#else
657static inline void omap_1510_usb_init(struct omap_usb_config *config) {}
658#endif
659
660/*-------------------------------------------------------------------------*/
661
662void __init omap_usb_init(struct omap_usb_config *pdata)
663{
664 pdata->usb0_init = omap_usb0_init;
665 pdata->usb1_init = omap_usb1_init;
666 pdata->usb2_init = omap_usb2_init;
667 udc_device_init(pdata);
668 ohci_device_init(pdata);
669 otg_device_init(pdata);
670
671 if (cpu_is_omap7xx() || cpu_is_omap16xx())
672 omap_otg_init(pdata);
673 else if (cpu_is_omap15xx())
674 omap_1510_usb_init(pdata);
675 else
676 printk(KERN_ERR "USB: No init for your chip yet\n");
677}
678