aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-omap/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/arm/plat-omap/usb.c')
-rw-r--r--arch/arm/plat-omap/usb.c267
1 files changed, 64 insertions, 203 deletions
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);