aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTony Lindgren <tony@atomide.com>2010-07-05 09:31:29 -0400
committerTony Lindgren <tony@atomide.com>2010-07-05 09:31:29 -0400
commitb5e8905bcd7a794b667f6d5eabcb036f25358fdb (patch)
treef4e488d39bb59d57ca8cff6a45df29624fcd6049
parentdba638d22d5af5486a861e08ab46e57abef7049a (diff)
omap: Move omap2 FS USB platform init code into mach-omap2/usb-fs.c
Move omap2 FS USB platform init code into mach-omap2/usb-fs.c. This will allow further work later on to use omap hwmod for initializing the device. Cc: David Brownell <dbrownell@users.sourceforge.net> Signed-off-by: Tony Lindgren <tony@atomide.com>
-rw-r--r--arch/arm/mach-omap2/Makefile2
-rw-r--r--arch/arm/mach-omap2/board-2430sdp.c2
-rw-r--r--arch/arm/mach-omap2/board-apollon.c2
-rw-r--r--arch/arm/mach-omap2/board-h4.c2
-rw-r--r--arch/arm/mach-omap2/usb-fs.c345
-rw-r--r--arch/arm/plat-omap/include/plat/board.h8
-rw-r--r--arch/arm/plat-omap/include/plat/usb.h7
-rw-r--r--arch/arm/plat-omap/usb.c267
8 files changed, 429 insertions, 206 deletions
diff --git a/arch/arm/mach-omap2/Makefile b/arch/arm/mach-omap2/Makefile
index 6c6d7c6f7aee..3b384188e28e 100644
--- a/arch/arm/mach-omap2/Makefile
+++ b/arch/arm/mach-omap2/Makefile
@@ -149,6 +149,8 @@ obj-$(CONFIG_MACH_OMAP3517EVM) += board-am3517evm.o
149obj-$(CONFIG_MACH_SBC3530) += board-omap3stalker.o \ 149obj-$(CONFIG_MACH_SBC3530) += board-omap3stalker.o \
150 hsmmc.o 150 hsmmc.o
151# Platform specific device init code 151# Platform specific device init code
152usbfs-$(CONFIG_ARCH_OMAP_OTG) := usb-fs.o
153obj-y += $(usbfs-m) $(usbfs-y)
152obj-y += usb-musb.o 154obj-y += usb-musb.o
153obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o 155obj-$(CONFIG_MACH_OMAP2_TUSB6010) += usb-tusb6010.o
154obj-y += usb-ehci.o 156obj-y += usb-ehci.o
diff --git a/arch/arm/mach-omap2/board-2430sdp.c b/arch/arm/mach-omap2/board-2430sdp.c
index a11a575745e4..ec920c90a526 100644
--- a/arch/arm/mach-omap2/board-2430sdp.c
+++ b/arch/arm/mach-omap2/board-2430sdp.c
@@ -226,7 +226,7 @@ static void __init omap_2430sdp_init(void)
226 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices)); 226 platform_add_devices(sdp2430_devices, ARRAY_SIZE(sdp2430_devices));
227 omap_serial_init(); 227 omap_serial_init();
228 omap2_hsmmc_init(mmc); 228 omap2_hsmmc_init(mmc);
229 omap_usb_init(&sdp2430_usb_config); 229 omap2_usbfs_init(&sdp2430_usb_config);
230 usb_musb_init(&musb_board_data); 230 usb_musb_init(&musb_board_data);
231 board_smc91x_init(); 231 board_smc91x_init();
232 232
diff --git a/arch/arm/mach-omap2/board-apollon.c b/arch/arm/mach-omap2/board-apollon.c
index aa69fb999748..987b24d400a8 100644
--- a/arch/arm/mach-omap2/board-apollon.c
+++ b/arch/arm/mach-omap2/board-apollon.c
@@ -306,7 +306,7 @@ static void __init apollon_usb_init(void)
306 omap_cfg_reg(P21_242X_GPIO12); 306 omap_cfg_reg(P21_242X_GPIO12);
307 gpio_request(12, "USB suspend"); 307 gpio_request(12, "USB suspend");
308 gpio_direction_output(12, 0); 308 gpio_direction_output(12, 0);
309 omap_usb_init(&apollon_usb_config); 309 omap2_usbfs_init(&apollon_usb_config);
310} 310}
311 311
312static void __init omap_apollon_init(void) 312static void __init omap_apollon_init(void)
diff --git a/arch/arm/mach-omap2/board-h4.c b/arch/arm/mach-omap2/board-h4.c
index 0665f2c8dc8e..54a231c7465e 100644
--- a/arch/arm/mach-omap2/board-h4.c
+++ b/arch/arm/mach-omap2/board-h4.c
@@ -362,7 +362,7 @@ static void __init omap_h4_init(void)
362 ARRAY_SIZE(h4_i2c_board_info)); 362 ARRAY_SIZE(h4_i2c_board_info));
363 363
364 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices)); 364 platform_add_devices(h4_devices, ARRAY_SIZE(h4_devices));
365 omap_usb_init(&h4_usb_config); 365 omap2_usbfs_init(&h4_usb_config);
366 omap_serial_init(); 366 omap_serial_init();
367} 367}
368 368
diff --git a/arch/arm/mach-omap2/usb-fs.c b/arch/arm/mach-omap2/usb-fs.c
new file mode 100644
index 000000000000..f63e5766b6bc
--- /dev/null
+++ b/arch/arm/mach-omap2/usb-fs.c
@@ -0,0 +1,345 @@
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/types.h>
24#include <linux/errno.h>
25#include <linux/init.h>
26#include <linux/platform_device.h>
27
28#include <asm/irq.h>
29
30#include <plat/control.h>
31#include <plat/mux.h>
32#include <plat/usb.h>
33#include <plat/board.h>
34
35#define INT_USB_IRQ_GEN INT_24XX_USB_IRQ_GEN
36#define INT_USB_IRQ_NISO INT_24XX_USB_IRQ_NISO
37#define INT_USB_IRQ_ISO INT_24XX_USB_IRQ_ISO
38#define INT_USB_IRQ_HGEN INT_24XX_USB_IRQ_HGEN
39#define INT_USB_IRQ_OTG INT_24XX_USB_IRQ_OTG
40
41#if defined(CONFIG_ARCH_OMAP2)
42
43#ifdef CONFIG_USB_GADGET_OMAP
44
45static struct resource udc_resources[] = {
46 /* order is significant! */
47 { /* registers */
48 .start = UDC_BASE,
49 .end = UDC_BASE + 0xff,
50 .flags = IORESOURCE_MEM,
51 }, { /* general IRQ */
52 .start = INT_USB_IRQ_GEN,
53 .flags = IORESOURCE_IRQ,
54 }, { /* PIO IRQ */
55 .start = INT_USB_IRQ_NISO,
56 .flags = IORESOURCE_IRQ,
57 }, { /* SOF IRQ */
58 .start = INT_USB_IRQ_ISO,
59 .flags = IORESOURCE_IRQ,
60 },
61};
62
63static u64 udc_dmamask = ~(u32)0;
64
65static struct platform_device udc_device = {
66 .name = "omap_udc",
67 .id = -1,
68 .dev = {
69 .dma_mask = &udc_dmamask,
70 .coherent_dma_mask = 0xffffffff,
71 },
72 .num_resources = ARRAY_SIZE(udc_resources),
73 .resource = udc_resources,
74};
75
76static inline void udc_device_init(struct omap_usb_config *pdata)
77{
78 pdata->udc_device = &udc_device;
79}
80
81#else
82
83static inline void udc_device_init(struct omap_usb_config *pdata)
84{
85}
86
87#endif
88
89#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
90
91/* The dmamask must be set for OHCI to work */
92static u64 ohci_dmamask = ~(u32)0;
93
94static struct resource ohci_resources[] = {
95 {
96 .start = OMAP_OHCI_BASE,
97 .end = OMAP_OHCI_BASE + 0xff,
98 .flags = IORESOURCE_MEM,
99 },
100 {
101 .start = INT_USB_IRQ_HGEN,
102 .flags = IORESOURCE_IRQ,
103 },
104};
105
106static struct platform_device ohci_device = {
107 .name = "ohci",
108 .id = -1,
109 .dev = {
110 .dma_mask = &ohci_dmamask,
111 .coherent_dma_mask = 0xffffffff,
112 },
113 .num_resources = ARRAY_SIZE(ohci_resources),
114 .resource = ohci_resources,
115};
116
117static inline void ohci_device_init(struct omap_usb_config *pdata)
118{
119 pdata->ohci_device = &ohci_device;
120}
121
122#else
123
124static inline void ohci_device_init(struct omap_usb_config *pdata)
125{
126}
127
128#endif
129
130#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
131
132static struct resource otg_resources[] = {
133 /* order is significant! */
134 {
135 .start = OTG_BASE,
136 .end = OTG_BASE + 0xff,
137 .flags = IORESOURCE_MEM,
138 }, {
139 .start = INT_USB_IRQ_OTG,
140 .flags = IORESOURCE_IRQ,
141 },
142};
143
144static struct platform_device otg_device = {
145 .name = "omap_otg",
146 .id = -1,
147 .num_resources = ARRAY_SIZE(otg_resources),
148 .resource = otg_resources,
149};
150
151static inline void otg_device_init(struct omap_usb_config *pdata)
152{
153 pdata->otg_device = &otg_device;
154}
155
156#else
157
158static inline void otg_device_init(struct omap_usb_config *pdata)
159{
160}
161
162#endif
163
164static void omap2_usb_devconf_clear(u8 port, u32 mask)
165{
166 u32 r;
167
168 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
169 r &= ~USBTXWRMODEI(port, mask);
170 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
171}
172
173static void omap2_usb_devconf_set(u8 port, u32 mask)
174{
175 u32 r;
176
177 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
178 r |= USBTXWRMODEI(port, mask);
179 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
180}
181
182static void omap2_usb2_disable_5pinbitll(void)
183{
184 u32 r;
185
186 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
187 r &= ~(USBTXWRMODEI(2, USB_BIDIR_TLL) | USBT2TLL5PI);
188 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
189}
190
191static void omap2_usb2_enable_5pinunitll(void)
192{
193 u32 r;
194
195 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
196 r |= USBTXWRMODEI(2, USB_UNIDIR_TLL) | USBT2TLL5PI;
197 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
198}
199
200static u32 __init omap2_usb0_init(unsigned nwires, unsigned is_device)
201{
202 u32 syscon1 = 0;
203
204 omap2_usb_devconf_clear(0, USB_BIDIR_TLL);
205
206 if (nwires == 0)
207 return 0;
208
209 if (is_device)
210 omap_cfg_reg(J20_24XX_USB0_PUEN);
211
212 omap_cfg_reg(K18_24XX_USB0_DAT);
213 omap_cfg_reg(K19_24XX_USB0_TXEN);
214 omap_cfg_reg(J14_24XX_USB0_SE0);
215 if (nwires != 3)
216 omap_cfg_reg(J18_24XX_USB0_RCV);
217
218 switch (nwires) {
219 case 3:
220 syscon1 = 2;
221 omap2_usb_devconf_set(0, USB_BIDIR);
222 break;
223 case 4:
224 syscon1 = 1;
225 omap2_usb_devconf_set(0, USB_BIDIR);
226 break;
227 case 6:
228 syscon1 = 3;
229 omap_cfg_reg(J19_24XX_USB0_VP);
230 omap_cfg_reg(K20_24XX_USB0_VM);
231 omap2_usb_devconf_set(0, USB_UNIDIR);
232 break;
233 default:
234 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
235 0, nwires);
236 }
237
238 return syscon1 << 16;
239}
240
241static u32 __init omap2_usb1_init(unsigned nwires)
242{
243 u32 syscon1 = 0;
244
245 omap2_usb_devconf_clear(1, USB_BIDIR_TLL);
246
247 if (nwires == 0)
248 return 0;
249
250 /* NOTE: board-specific code must set up pin muxing for usb1,
251 * since each signal could come out on either of two balls.
252 */
253
254 switch (nwires) {
255 case 2:
256 /* NOTE: board-specific code must override this setting if
257 * this TLL link is not using DP/DM
258 */
259 syscon1 = 1;
260 omap2_usb_devconf_set(1, USB_BIDIR_TLL);
261 break;
262 case 3:
263 syscon1 = 2;
264 omap2_usb_devconf_set(1, USB_BIDIR);
265 break;
266 case 4:
267 syscon1 = 1;
268 omap2_usb_devconf_set(1, USB_BIDIR);
269 break;
270 case 6:
271 default:
272 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
273 1, nwires);
274 }
275
276 return syscon1 << 20;
277}
278
279static u32 __init omap2_usb2_init(unsigned nwires, unsigned alt_pingroup)
280{
281 u32 syscon1 = 0;
282
283 omap2_usb2_disable_5pinbitll();
284 alt_pingroup = 0;
285
286 /* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */
287 if (alt_pingroup || nwires == 0)
288 return 0;
289
290 omap_cfg_reg(Y11_24XX_USB2_DAT);
291 omap_cfg_reg(AA10_24XX_USB2_SE0);
292 if (nwires > 2)
293 omap_cfg_reg(AA12_24XX_USB2_TXEN);
294 if (nwires > 3)
295 omap_cfg_reg(AA6_24XX_USB2_RCV);
296
297 switch (nwires) {
298 case 2:
299 /* NOTE: board-specific code must override this setting if
300 * this TLL link is not using DP/DM
301 */
302 syscon1 = 1;
303 omap2_usb_devconf_set(2, USB_BIDIR_TLL);
304 break;
305 case 3:
306 syscon1 = 2;
307 omap2_usb_devconf_set(2, USB_BIDIR);
308 break;
309 case 4:
310 syscon1 = 1;
311 omap2_usb_devconf_set(2, USB_BIDIR);
312 break;
313 case 5:
314 omap_cfg_reg(AA4_24XX_USB2_TLLSE0);
315 /* NOTE: board-specific code must override this setting if
316 * this TLL link is not using DP/DM. Something must also
317 * set up OTG_SYSCON2.HMC_TLL{ATTACH,SPEED}
318 */
319 syscon1 = 3;
320 omap2_usb2_enable_5pinunitll();
321 break;
322 case 6:
323 default:
324 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
325 2, nwires);
326 }
327
328 return syscon1 << 24;
329}
330
331void __init omap2_usbfs_init(struct omap_usb_config *pdata)
332{
333 if (!cpu_is_omap24xx())
334 return;
335
336 pdata->usb0_init = omap2_usb0_init;
337 pdata->usb1_init = omap2_usb1_init;
338 pdata->usb2_init = omap2_usb2_init;
339 udc_device_init(pdata);
340 ohci_device_init(pdata);
341 otg_device_init(pdata);
342 omap_otg_init(pdata);
343}
344
345#endif
diff --git a/arch/arm/plat-omap/include/plat/board.h b/arch/arm/plat-omap/include/plat/board.h
index 5cd622039da0..3cf4fa25ab3d 100644
--- a/arch/arm/plat-omap/include/plat/board.h
+++ b/arch/arm/plat-omap/include/plat/board.h
@@ -85,6 +85,14 @@ struct omap_usb_config {
85 * 6 == 6 wire unidirectional (or TLL) 85 * 6 == 6 wire unidirectional (or TLL)
86 */ 86 */
87 u8 pins[3]; 87 u8 pins[3];
88
89 struct platform_device *udc_device;
90 struct platform_device *ohci_device;
91 struct platform_device *otg_device;
92
93 u32 (*usb0_init)(unsigned nwires, unsigned is_device);
94 u32 (*usb1_init)(unsigned nwires);
95 u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
88}; 96};
89 97
90struct omap_lcd_config { 98struct omap_lcd_config {
diff --git a/arch/arm/plat-omap/include/plat/usb.h b/arch/arm/plat-omap/include/plat/usb.h
index 98eef5360e6d..9f792244e77c 100644
--- a/arch/arm/plat-omap/include/plat/usb.h
+++ b/arch/arm/plat-omap/include/plat/usb.h
@@ -81,7 +81,14 @@ extern void usb_ohci_init(const struct ohci_hcd_omap_platform_data *pdata);
81 81
82#endif 82#endif
83 83
84void omap_otg_init(struct omap_usb_config *config);
84void omap_usb_init(struct omap_usb_config *pdata); 85void omap_usb_init(struct omap_usb_config *pdata);
86void omap2_usbfs_init(struct omap_usb_config *pdata);
87#else
88static inline omap2_usbfs_init(struct omap_usb_config *pdata)
89{
90}
91#endif
85 92
86/*-------------------------------------------------------------------------*/ 93/*-------------------------------------------------------------------------*/
87 94
diff --git a/arch/arm/plat-omap/usb.c b/arch/arm/plat-omap/usb.c
index 9c4929a33e52..27b471ce11a0 100644
--- a/arch/arm/plat-omap/usb.c
+++ b/arch/arm/plat-omap/usb.c
@@ -38,25 +38,12 @@
38#include <plat/usb.h> 38#include <plat/usb.h>
39#include <plat/board.h> 39#include <plat/board.h>
40 40
41#ifdef CONFIG_ARCH_OMAP1
42
43#define INT_USB_IRQ_GEN IH2_BASE + 20 41#define INT_USB_IRQ_GEN IH2_BASE + 20
44#define INT_USB_IRQ_NISO IH2_BASE + 30 42#define INT_USB_IRQ_NISO IH2_BASE + 30
45#define INT_USB_IRQ_ISO IH2_BASE + 29 43#define INT_USB_IRQ_ISO IH2_BASE + 29
46#define INT_USB_IRQ_HGEN INT_USB_HHC_1 44#define INT_USB_IRQ_HGEN INT_USB_HHC_1
47#define INT_USB_IRQ_OTG IH2_BASE + 8 45#define INT_USB_IRQ_OTG IH2_BASE + 8
48 46
49#else
50
51#define INT_USB_IRQ_GEN INT_24XX_USB_IRQ_GEN
52#define INT_USB_IRQ_NISO INT_24XX_USB_IRQ_NISO
53#define INT_USB_IRQ_ISO INT_24XX_USB_IRQ_ISO
54#define INT_USB_IRQ_HGEN INT_24XX_USB_IRQ_HGEN
55#define INT_USB_IRQ_OTG INT_24XX_USB_IRQ_OTG
56
57#endif
58
59
60/* These routines should handle the standard chip-specific modes 47/* These routines should handle the standard chip-specific modes
61 * for usb0/1/2 ports, covering basic mux and transceiver setup. 48 * for usb0/1/2 ports, covering basic mux and transceiver setup.
62 * 49 *
@@ -79,90 +66,10 @@
79 66
80#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP15XX) 67#if defined(CONFIG_ARCH_OMAP_OTG) || defined(CONFIG_ARCH_OMAP15XX)
81 68
82static void omap2_usb_devconf_clear(u8 port, u32 mask)
83{
84 u32 r;
85
86 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
87 r &= ~USBTXWRMODEI(port, mask);
88 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
89}
90
91static void omap2_usb_devconf_set(u8 port, u32 mask)
92{
93 u32 r;
94
95 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
96 r |= USBTXWRMODEI(port, mask);
97 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
98}
99
100static void omap2_usb2_disable_5pinbitll(void)
101{
102 u32 r;
103
104 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
105 r &= ~(USBTXWRMODEI(2, USB_BIDIR_TLL) | USBT2TLL5PI);
106 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
107}
108
109static void omap2_usb2_enable_5pinunitll(void)
110{
111 u32 r;
112
113 r = omap_ctrl_readl(OMAP2_CONTROL_DEVCONF0);
114 r |= USBTXWRMODEI(2, USB_UNIDIR_TLL) | USBT2TLL5PI;
115 omap_ctrl_writel(r, OMAP2_CONTROL_DEVCONF0);
116}
117
118static u32 __init omap2_usb0_init(unsigned nwires, unsigned is_device)
119{
120 u32 syscon1 = 0;
121
122 omap2_usb_devconf_clear(0, USB_BIDIR_TLL);
123
124 if (nwires == 0)
125 return 0;
126
127 if (is_device)
128 omap_cfg_reg(J20_24XX_USB0_PUEN);
129
130 omap_cfg_reg(K18_24XX_USB0_DAT);
131 omap_cfg_reg(K19_24XX_USB0_TXEN);
132 omap_cfg_reg(J14_24XX_USB0_SE0);
133 if (nwires != 3)
134 omap_cfg_reg(J18_24XX_USB0_RCV);
135
136 switch (nwires) {
137 case 3:
138 syscon1 = 2;
139 omap2_usb_devconf_set(0, USB_BIDIR);
140 break;
141 case 4:
142 syscon1 = 1;
143 omap2_usb_devconf_set(0, USB_BIDIR);
144 break;
145 case 6:
146 syscon1 = 3;
147 omap_cfg_reg(J19_24XX_USB0_VP);
148 omap_cfg_reg(K20_24XX_USB0_VM);
149 omap2_usb_devconf_set(0, USB_UNIDIR);
150 break;
151 default:
152 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
153 0, nwires);
154 }
155
156 return syscon1 << 16;
157}
158
159static u32 __init omap_usb0_init(unsigned nwires, unsigned is_device) 69static u32 __init omap_usb0_init(unsigned nwires, unsigned is_device)
160{ 70{
161 u32 syscon1 = 0; 71 u32 syscon1 = 0;
162 72
163 if (cpu_is_omap24xx())
164 return omap2_usb0_init(nwires, is_device);
165
166 if (nwires == 0) { 73 if (nwires == 0) {
167 if (!cpu_is_omap15xx()) { 74 if (!cpu_is_omap15xx()) {
168 u32 l; 75 u32 l;
@@ -266,51 +173,10 @@ static u32 __init omap_usb0_init(unsigned nwires, unsigned is_device)
266 return syscon1 << 16; 173 return syscon1 << 16;
267} 174}
268 175
269static u32 __init omap2_usb1_init(unsigned nwires)
270{
271 u32 syscon1 = 0;
272
273 omap2_usb_devconf_clear(1, USB_BIDIR_TLL);
274
275 if (nwires == 0)
276 return 0;
277
278 /* NOTE: board-specific code must set up pin muxing for usb1,
279 * since each signal could come out on either of two balls.
280 */
281
282 switch (nwires) {
283 case 2:
284 /* NOTE: board-specific code must override this setting if
285 * this TLL link is not using DP/DM
286 */
287 syscon1 = 1;
288 omap2_usb_devconf_set(1, USB_BIDIR_TLL);
289 break;
290 case 3:
291 syscon1 = 2;
292 omap2_usb_devconf_set(1, USB_BIDIR);
293 break;
294 case 4:
295 syscon1 = 1;
296 omap2_usb_devconf_set(1, USB_BIDIR);
297 break;
298 case 6:
299 default:
300 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
301 1, nwires);
302 }
303
304 return syscon1 << 20;
305}
306
307static u32 __init omap_usb1_init(unsigned nwires) 176static u32 __init omap_usb1_init(unsigned nwires)
308{ 177{
309 u32 syscon1 = 0; 178 u32 syscon1 = 0;
310 179
311 if (cpu_is_omap24xx())
312 return omap2_usb1_init(nwires);
313
314 if (!cpu_is_omap15xx() && nwires != 6) { 180 if (!cpu_is_omap15xx() && nwires != 6) {
315 u32 l; 181 u32 l;
316 182
@@ -372,65 +238,10 @@ bad:
372 return syscon1 << 20; 238 return syscon1 << 20;
373} 239}
374 240
375static u32 __init omap2_usb2_init(unsigned nwires, unsigned alt_pingroup)
376{
377 u32 syscon1 = 0;
378
379 omap2_usb2_disable_5pinbitll();
380 alt_pingroup = 0;
381
382 /* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */
383 if (alt_pingroup || nwires == 0)
384 return 0;
385
386 omap_cfg_reg(Y11_24XX_USB2_DAT);
387 omap_cfg_reg(AA10_24XX_USB2_SE0);
388 if (nwires > 2)
389 omap_cfg_reg(AA12_24XX_USB2_TXEN);
390 if (nwires > 3)
391 omap_cfg_reg(AA6_24XX_USB2_RCV);
392
393 switch (nwires) {
394 case 2:
395 /* NOTE: board-specific code must override this setting if
396 * this TLL link is not using DP/DM
397 */
398 syscon1 = 1;
399 omap2_usb_devconf_set(2, USB_BIDIR_TLL);
400 break;
401 case 3:
402 syscon1 = 2;
403 omap2_usb_devconf_set(2, USB_BIDIR);
404 break;
405 case 4:
406 syscon1 = 1;
407 omap2_usb_devconf_set(2, USB_BIDIR);
408 break;
409 case 5:
410 omap_cfg_reg(AA4_24XX_USB2_TLLSE0);
411 /* NOTE: board-specific code must override this setting if
412 * this TLL link is not using DP/DM. Something must also
413 * set up OTG_SYSCON2.HMC_TLL{ATTACH,SPEED}
414 */
415 syscon1 = 3;
416 omap2_usb2_enable_5pinunitll();
417 break;
418 case 6:
419 default:
420 printk(KERN_ERR "illegal usb%d %d-wire transceiver\n",
421 2, nwires);
422 }
423
424 return syscon1 << 24;
425}
426
427static u32 __init omap_usb2_init(unsigned nwires, unsigned alt_pingroup) 241static u32 __init omap_usb2_init(unsigned nwires, unsigned alt_pingroup)
428{ 242{
429 u32 syscon1 = 0; 243 u32 syscon1 = 0;
430 244
431 if (cpu_is_omap24xx())
432 return omap2_usb2_init(nwires, alt_pingroup);
433
434 /* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */ 245 /* NOTE omap1 erratum: must leave USB2_UNI_R set if usb0 in use */
435 if (alt_pingroup || nwires == 0) 246 if (alt_pingroup || nwires == 0)
436 return 0; 247 return 0;
@@ -498,6 +309,10 @@ bad:
498 return syscon1 << 24; 309 return syscon1 << 24;
499} 310}
500 311
312#else
313#define omap_usb0_init NULL
314#define omap_usb1_init NULL
315#define omap_usb2_init NULL
501#endif 316#endif
502 317
503/*-------------------------------------------------------------------------*/ 318/*-------------------------------------------------------------------------*/
@@ -535,6 +350,17 @@ static struct platform_device udc_device = {
535 .resource = udc_resources, 350 .resource = udc_resources,
536}; 351};
537 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
538#endif 364#endif
539 365
540#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 366#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
@@ -565,6 +391,17 @@ static struct platform_device ohci_device = {
565 .resource = ohci_resources, 391 .resource = ohci_resources,
566}; 392};
567 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
568#endif 405#endif
569 406
570#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG) 407#if defined(CONFIG_USB_OTG) && defined(CONFIG_ARCH_OMAP_OTG)
@@ -588,6 +425,17 @@ static struct platform_device otg_device = {
588 .resource = otg_resources, 425 .resource = otg_resources,
589}; 426};
590 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
591#endif 439#endif
592 440
593/*-------------------------------------------------------------------------*/ 441/*-------------------------------------------------------------------------*/
@@ -622,9 +470,9 @@ omap_otg_init(struct omap_usb_config *config)
622 /* pin muxing and transceiver pinouts */ 470 /* pin muxing and transceiver pinouts */
623 if (config->pins[0] > 2) /* alt pingroup 2 */ 471 if (config->pins[0] > 2) /* alt pingroup 2 */
624 alt_pingroup = 1; 472 alt_pingroup = 1;
625 syscon |= omap_usb0_init(config->pins[0], is_usb0_device(config)); 473 syscon |= config->usb0_init(config->pins[0], is_usb0_device(config));
626 syscon |= omap_usb1_init(config->pins[1]); 474 syscon |= config->usb1_init(config->pins[1]);
627 syscon |= omap_usb2_init(config->pins[2], alt_pingroup); 475 syscon |= config->usb2_init(config->pins[2], alt_pingroup);
628 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1)); 476 pr_debug("OTG_SYSCON_1 = %08x\n", omap_readl(OTG_SYSCON_1));
629 omap_writel(syscon, OTG_SYSCON_1); 477 omap_writel(syscon, OTG_SYSCON_1);
630 478
@@ -672,15 +520,17 @@ omap_otg_init(struct omap_usb_config *config)
672 520
673#ifdef CONFIG_USB_GADGET_OMAP 521#ifdef CONFIG_USB_GADGET_OMAP
674 if (config->otg || config->register_dev) { 522 if (config->otg || config->register_dev) {
523 struct platform_device *udc_device = config->udc_device;
524
675 syscon &= ~DEV_IDLE_EN; 525 syscon &= ~DEV_IDLE_EN;
676 udc_device.dev.platform_data = config; 526 udc_device->dev.platform_data = config;
677 /* IRQ numbers for omap7xx */ 527 /* IRQ numbers for omap7xx */
678 if(cpu_is_omap7xx()) { 528 if(cpu_is_omap7xx()) {
679 udc_resources[1].start = INT_7XX_USB_GENI; 529 udc_resources[1].start = INT_7XX_USB_GENI;
680 udc_resources[2].start = INT_7XX_USB_NON_ISO; 530 udc_resources[2].start = INT_7XX_USB_NON_ISO;
681 udc_resources[3].start = INT_7XX_USB_ISO; 531 udc_resources[3].start = INT_7XX_USB_ISO;
682 } 532 }
683 status = platform_device_register(&udc_device); 533 status = platform_device_register(udc_device);
684 if (status) 534 if (status)
685 pr_debug("can't register UDC device, %d\n", status); 535 pr_debug("can't register UDC device, %d\n", status);
686 } 536 }
@@ -688,11 +538,13 @@ omap_otg_init(struct omap_usb_config *config)
688 538
689#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE) 539#if defined(CONFIG_USB_OHCI_HCD) || defined(CONFIG_USB_OHCI_HCD_MODULE)
690 if (config->otg || config->register_host) { 540 if (config->otg || config->register_host) {
541 struct platform_device *ohci_device = config->ohci_device;
542
691 syscon &= ~HST_IDLE_EN; 543 syscon &= ~HST_IDLE_EN;
692 ohci_device.dev.platform_data = config; 544 ohci_device->dev.platform_data = config;
693 if (cpu_is_omap7xx()) 545 if (cpu_is_omap7xx())
694 ohci_resources[1].start = INT_7XX_USB_HHC_1; 546 ohci_resources[1].start = INT_7XX_USB_HHC_1;
695 status = platform_device_register(&ohci_device); 547 status = platform_device_register(ohci_device);
696 if (status) 548 if (status)
697 pr_debug("can't register OHCI device, %d\n", status); 549 pr_debug("can't register OHCI device, %d\n", status);
698 } 550 }
@@ -700,11 +552,13 @@ omap_otg_init(struct omap_usb_config *config)
700 552
701#ifdef CONFIG_USB_OTG 553#ifdef CONFIG_USB_OTG
702 if (config->otg) { 554 if (config->otg) {
555 struct platform_device *otg_device = config->otg_device;
556
703 syscon &= ~OTG_IDLE_EN; 557 syscon &= ~OTG_IDLE_EN;
704 otg_device.dev.platform_data = config; 558 otg_device->dev.platform_data = config;
705 if (cpu_is_omap7xx()) 559 if (cpu_is_omap7xx())
706 otg_resources[1].start = INT_7XX_USB_OTG; 560 otg_resources[1].start = INT_7XX_USB_OTG;
707 status = platform_device_register(&otg_device); 561 status = platform_device_register(otg_device);
708 if (status) 562 if (status)
709 pr_debug("can't register OTG device, %d\n", status); 563 pr_debug("can't register OTG device, %d\n", status);
710 } 564 }
@@ -716,7 +570,7 @@ omap_otg_init(struct omap_usb_config *config)
716} 570}
717 571
718#else 572#else
719static inline void omap_otg_init(struct omap_usb_config *config) {} 573void omap_otg_init(struct omap_usb_config *config) {}
720#endif 574#endif
721 575
722/*-------------------------------------------------------------------------*/ 576/*-------------------------------------------------------------------------*/
@@ -737,9 +591,9 @@ static void __init omap_1510_usb_init(struct omap_usb_config *config)
737 unsigned int val; 591 unsigned int val;
738 u16 w; 592 u16 w;
739 593
740 omap_usb0_init(config->pins[0], is_usb0_device(config)); 594 config->usb0_init(config->pins[0], is_usb0_device(config));
741 omap_usb1_init(config->pins[1]); 595 config->usb1_init(config->pins[1]);
742 omap_usb2_init(config->pins[2], 0); 596 config->usb2_init(config->pins[2], 0);
743 597
744 val = omap_readl(MOD_CONF_CTRL_0) & ~(0x3f << 1); 598 val = omap_readl(MOD_CONF_CTRL_0) & ~(0x3f << 1);
745 val |= (config->hmc_mode << 1); 599 val |= (config->hmc_mode << 1);
@@ -807,7 +661,14 @@ static inline void omap_1510_usb_init(struct omap_usb_config *config) {}
807 661
808void __init omap_usb_init(struct omap_usb_config *pdata) 662void __init omap_usb_init(struct omap_usb_config *pdata)
809{ 663{
810 if (cpu_is_omap7xx() || cpu_is_omap16xx() || cpu_is_omap24xx()) 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())
811 omap_otg_init(pdata); 672 omap_otg_init(pdata);
812 else if (cpu_is_omap15xx()) 673 else if (cpu_is_omap15xx())
813 omap_1510_usb_init(pdata); 674 omap_1510_usb_init(pdata);