usb.h 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. /*
  2. * FIXME correct answer depends on hmc_mode,
  3. * as does (on omap1) any nonzero value for config->otg port number
  4. */
  5. #ifdef CONFIG_USB_GADGET_OMAP
  6. #define is_usb0_device(config) 1
  7. #else
  8. #define is_usb0_device(config) 0
  9. #endif
  10. struct omap_usb_config {
  11. /* Configure drivers according to the connectors on your board:
  12. * - "A" connector (rectagular)
  13. * ... for host/OHCI use, set "register_host".
  14. * - "B" connector (squarish) or "Mini-B"
  15. * ... for device/gadget use, set "register_dev".
  16. * - "Mini-AB" connector (very similar to Mini-B)
  17. * ... for OTG use as device OR host, initialize "otg"
  18. */
  19. unsigned register_host:1;
  20. unsigned register_dev:1;
  21. u8 otg; /* port number, 1-based: usb1 == 2 */
  22. u8 hmc_mode;
  23. /* implicitly true if otg: host supports remote wakeup? */
  24. u8 rwc;
  25. /* signaling pins used to talk to transceiver on usbN:
  26. * 0 == usbN unused
  27. * 2 == usb0-only, using internal transceiver
  28. * 3 == 3 wire bidirectional
  29. * 4 == 4 wire bidirectional
  30. * 6 == 6 wire unidirectional (or TLL)
  31. */
  32. u8 pins[3];
  33. struct platform_device *udc_device;
  34. struct platform_device *ohci_device;
  35. struct platform_device *otg_device;
  36. u32 (*usb0_init)(unsigned nwires, unsigned is_device);
  37. u32 (*usb1_init)(unsigned nwires);
  38. u32 (*usb2_init)(unsigned nwires, unsigned alt_pingroup);
  39. int (*ocpi_enable)(void);
  40. };
  41. void omap_otg_init(struct omap_usb_config *config);
  42. #if defined(CONFIG_USB) || defined(CONFIG_USB_MODULE)
  43. void omap1_usb_init(struct omap_usb_config *pdata);
  44. #else
  45. static inline void omap1_usb_init(struct omap_usb_config *pdata)
  46. {
  47. }
  48. #endif
  49. #define OMAP1_OTG_BASE 0xfffb0400
  50. #define OMAP1_UDC_BASE 0xfffb4000
  51. #define OMAP1_OHCI_BASE 0xfffba000
  52. #define OMAP2_OHCI_BASE 0x4805e000
  53. #define OMAP2_UDC_BASE 0x4805e200
  54. #define OMAP2_OTG_BASE 0x4805e300
  55. #define OTG_BASE OMAP1_OTG_BASE
  56. #define UDC_BASE OMAP1_UDC_BASE
  57. #define OMAP_OHCI_BASE OMAP1_OHCI_BASE
  58. /*
  59. * OTG and transceiver registers, for OMAPs starting with ARM926
  60. */
  61. #define OTG_REV (OTG_BASE + 0x00)
  62. #define OTG_SYSCON_1 (OTG_BASE + 0x04)
  63. # define USB2_TRX_MODE(w) (((w)>>24)&0x07)
  64. # define USB1_TRX_MODE(w) (((w)>>20)&0x07)
  65. # define USB0_TRX_MODE(w) (((w)>>16)&0x07)
  66. # define OTG_IDLE_EN (1 << 15)
  67. # define HST_IDLE_EN (1 << 14)
  68. # define DEV_IDLE_EN (1 << 13)
  69. # define OTG_RESET_DONE (1 << 2)
  70. # define OTG_SOFT_RESET (1 << 1)
  71. #define OTG_SYSCON_2 (OTG_BASE + 0x08)
  72. # define OTG_EN (1 << 31)
  73. # define USBX_SYNCHRO (1 << 30)
  74. # define OTG_MST16 (1 << 29)
  75. # define SRP_GPDATA (1 << 28)
  76. # define SRP_GPDVBUS (1 << 27)
  77. # define SRP_GPUVBUS(w) (((w)>>24)&0x07)
  78. # define A_WAIT_VRISE(w) (((w)>>20)&0x07)
  79. # define B_ASE_BRST(w) (((w)>>16)&0x07)
  80. # define SRP_DPW (1 << 14)
  81. # define SRP_DATA (1 << 13)
  82. # define SRP_VBUS (1 << 12)
  83. # define OTG_PADEN (1 << 10)
  84. # define HMC_PADEN (1 << 9)
  85. # define UHOST_EN (1 << 8)
  86. # define HMC_TLLSPEED (1 << 7)
  87. # define HMC_TLLATTACH (1 << 6)
  88. # define OTG_HMC(w) (((w)>>0)&0x3f)
  89. #define OTG_CTRL (OTG_BASE + 0x0c)
  90. # define OTG_USB2_EN (1 << 29)
  91. # define OTG_USB2_DP (1 << 28)
  92. # define OTG_USB2_DM (1 << 27)
  93. # define OTG_USB1_EN (1 << 26)
  94. # define OTG_USB1_DP (1 << 25)
  95. # define OTG_USB1_DM (1 << 24)
  96. # define OTG_USB0_EN (1 << 23)
  97. # define OTG_USB0_DP (1 << 22)
  98. # define OTG_USB0_DM (1 << 21)
  99. # define OTG_ASESSVLD (1 << 20)
  100. # define OTG_BSESSEND (1 << 19)
  101. # define OTG_BSESSVLD (1 << 18)
  102. # define OTG_VBUSVLD (1 << 17)
  103. # define OTG_ID (1 << 16)
  104. # define OTG_DRIVER_SEL (1 << 15)
  105. # define OTG_A_SETB_HNPEN (1 << 12)
  106. # define OTG_A_BUSREQ (1 << 11)
  107. # define OTG_B_HNPEN (1 << 9)
  108. # define OTG_B_BUSREQ (1 << 8)
  109. # define OTG_BUSDROP (1 << 7)
  110. # define OTG_PULLDOWN (1 << 5)
  111. # define OTG_PULLUP (1 << 4)
  112. # define OTG_DRV_VBUS (1 << 3)
  113. # define OTG_PD_VBUS (1 << 2)
  114. # define OTG_PU_VBUS (1 << 1)
  115. # define OTG_PU_ID (1 << 0)
  116. #define OTG_IRQ_EN (OTG_BASE + 0x10) /* 16-bit */
  117. # define DRIVER_SWITCH (1 << 15)
  118. # define A_VBUS_ERR (1 << 13)
  119. # define A_REQ_TMROUT (1 << 12)
  120. # define A_SRP_DETECT (1 << 11)
  121. # define B_HNP_FAIL (1 << 10)
  122. # define B_SRP_TMROUT (1 << 9)
  123. # define B_SRP_DONE (1 << 8)
  124. # define B_SRP_STARTED (1 << 7)
  125. # define OPRT_CHG (1 << 0)
  126. #define OTG_IRQ_SRC (OTG_BASE + 0x14) /* 16-bit */
  127. // same bits as in IRQ_EN
  128. #define OTG_OUTCTRL (OTG_BASE + 0x18) /* 16-bit */
  129. # define OTGVPD (1 << 14)
  130. # define OTGVPU (1 << 13)
  131. # define OTGPUID (1 << 12)
  132. # define USB2VDR (1 << 10)
  133. # define USB2PDEN (1 << 9)
  134. # define USB2PUEN (1 << 8)
  135. # define USB1VDR (1 << 6)
  136. # define USB1PDEN (1 << 5)
  137. # define USB1PUEN (1 << 4)
  138. # define USB0VDR (1 << 2)
  139. # define USB0PDEN (1 << 1)
  140. # define USB0PUEN (1 << 0)
  141. #define OTG_TEST (OTG_BASE + 0x20) /* 16-bit */
  142. #define OTG_VENDOR_CODE (OTG_BASE + 0xfc) /* 16-bit */
  143. /*-------------------------------------------------------------------------*/
  144. /* OMAP1 */
  145. #define USB_TRANSCEIVER_CTRL (0xfffe1000 + 0x0064)
  146. # define CONF_USB2_UNI_R (1 << 8)
  147. # define CONF_USB1_UNI_R (1 << 7)
  148. # define CONF_USB_PORT0_R(x) (((x)>>4)&0x7)
  149. # define CONF_USB0_ISOLATE_R (1 << 3)
  150. # define CONF_USB_PWRDN_DM_R (1 << 2)
  151. # define CONF_USB_PWRDN_DP_R (1 << 1)