isp1760-hcd.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  1. #ifndef _ISP1760_HCD_H_
  2. #define _ISP1760_HCD_H_
  3. /* exports for if */
  4. struct usb_hcd *isp1760_register(u64 res_start, u64 res_len, int irq,
  5. u64 irqflags, struct device *dev, const char *busname,
  6. unsigned int devflags);
  7. int init_kmem_once(void);
  8. void deinit_kmem_cache(void);
  9. /* EHCI capability registers */
  10. #define HC_CAPLENGTH 0x00
  11. #define HC_HCSPARAMS 0x04
  12. #define HC_HCCPARAMS 0x08
  13. /* EHCI operational registers */
  14. #define HC_USBCMD 0x20
  15. #define HC_USBSTS 0x24
  16. #define HC_FRINDEX 0x2c
  17. #define HC_CONFIGFLAG 0x60
  18. #define HC_PORTSC1 0x64
  19. #define HC_ISO_PTD_DONEMAP_REG 0x130
  20. #define HC_ISO_PTD_SKIPMAP_REG 0x134
  21. #define HC_ISO_PTD_LASTPTD_REG 0x138
  22. #define HC_INT_PTD_DONEMAP_REG 0x140
  23. #define HC_INT_PTD_SKIPMAP_REG 0x144
  24. #define HC_INT_PTD_LASTPTD_REG 0x148
  25. #define HC_ATL_PTD_DONEMAP_REG 0x150
  26. #define HC_ATL_PTD_SKIPMAP_REG 0x154
  27. #define HC_ATL_PTD_LASTPTD_REG 0x158
  28. /* Configuration Register */
  29. #define HC_HW_MODE_CTRL 0x300
  30. #define ALL_ATX_RESET (1 << 31)
  31. #define HW_ANA_DIGI_OC (1 << 15)
  32. #define HW_DATA_BUS_32BIT (1 << 8)
  33. #define HW_DACK_POL_HIGH (1 << 6)
  34. #define HW_DREQ_POL_HIGH (1 << 5)
  35. #define HW_INTR_HIGH_ACT (1 << 2)
  36. #define HW_INTR_EDGE_TRIG (1 << 1)
  37. #define HW_GLOBAL_INTR_EN (1 << 0)
  38. #define HC_CHIP_ID_REG 0x304
  39. #define HC_SCRATCH_REG 0x308
  40. #define HC_RESET_REG 0x30c
  41. #define SW_RESET_RESET_HC (1 << 1)
  42. #define SW_RESET_RESET_ALL (1 << 0)
  43. #define HC_BUFFER_STATUS_REG 0x334
  44. #define ATL_BUFFER 0x1
  45. #define INT_BUFFER 0x2
  46. #define ISO_BUFFER 0x4
  47. #define BUFFER_MAP 0x7
  48. #define HC_MEMORY_REG 0x33c
  49. #define ISP_BANK(x) ((x) << 16)
  50. #define HC_PORT1_CTRL 0x374
  51. #define PORT1_POWER (3 << 3)
  52. #define PORT1_INIT1 (1 << 7)
  53. #define PORT1_INIT2 (1 << 23)
  54. #define HW_OTG_CTRL_SET 0x374
  55. #define HW_OTG_CTRL_CLR 0x376
  56. /* Interrupt Register */
  57. #define HC_INTERRUPT_REG 0x310
  58. #define HC_INTERRUPT_ENABLE 0x314
  59. #define INTERRUPT_ENABLE_MASK (HC_INTL_INT | HC_ATL_INT | HC_EOT_INT)
  60. #define HC_ISO_INT (1 << 9)
  61. #define HC_ATL_INT (1 << 8)
  62. #define HC_INTL_INT (1 << 7)
  63. #define HC_EOT_INT (1 << 3)
  64. #define HC_SOT_INT (1 << 1)
  65. #define HC_ISO_IRQ_MASK_OR_REG 0x318
  66. #define HC_INT_IRQ_MASK_OR_REG 0x31C
  67. #define HC_ATL_IRQ_MASK_OR_REG 0x320
  68. #define HC_ISO_IRQ_MASK_AND_REG 0x324
  69. #define HC_INT_IRQ_MASK_AND_REG 0x328
  70. #define HC_ATL_IRQ_MASK_AND_REG 0x32C
  71. /* Register sets */
  72. #define HC_BEGIN_OF_ATL 0x0c00
  73. #define HC_BEGIN_OF_INT 0x0800
  74. #define HC_BEGIN_OF_ISO 0x0400
  75. #define HC_BEGIN_OF_PAYLOAD 0x1000
  76. /* urb state*/
  77. #define DELETE_URB (0x0008)
  78. #define NO_TRANSFER_ACTIVE (0xffffffff)
  79. #define ATL_REGS_OFFSET (0xc00)
  80. #define INT_REGS_OFFSET (0x800)
  81. /* Philips Transfer Descriptor (PTD) */
  82. struct ptd {
  83. __le32 dw0;
  84. __le32 dw1;
  85. __le32 dw2;
  86. __le32 dw3;
  87. __le32 dw4;
  88. __le32 dw5;
  89. __le32 dw6;
  90. __le32 dw7;
  91. };
  92. struct inter_packet_info {
  93. void *data_buffer;
  94. u32 payload;
  95. #define PTD_FIRE_NEXT (1 << 0)
  96. #define PTD_URB_FINISHED (1 << 1)
  97. struct urb *urb;
  98. struct isp1760_qh *qh;
  99. struct isp1760_qtd *qtd;
  100. };
  101. typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
  102. struct isp1760_qtd *qtd);
  103. #define isp1760_dbg(priv, fmt, args...) \
  104. dev_dbg(priv_to_hcd(priv)->self.controller, fmt, ##args)
  105. #define isp1760_info(priv, fmt, args...) \
  106. dev_info(priv_to_hcd(priv)->self.controller, fmt, ##args)
  107. #define isp1760_err(priv, fmt, args...) \
  108. dev_err(priv_to_hcd(priv)->self.controller, fmt, ##args)
  109. /*
  110. * Device flags that can vary from board to board. All of these
  111. * indicate the most "atypical" case, so that a devflags of 0 is
  112. * a sane default configuration.
  113. */
  114. #define ISP1760_FLAG_BUS_WIDTH_16 0x00000002 /* 16-bit data bus width */
  115. #define ISP1760_FLAG_OTG_EN 0x00000004 /* Port 1 supports OTG */
  116. #define ISP1760_FLAG_ANALOG_OC 0x00000008 /* Analog overcurrent */
  117. #define ISP1760_FLAG_DACK_POL_HIGH 0x00000010 /* DACK active high */
  118. #define ISP1760_FLAG_DREQ_POL_HIGH 0x00000020 /* DREQ active high */
  119. #define ISP1760_FLAG_ISP1761 0x00000040 /* Chip is ISP1761 */
  120. /* chip memory management */
  121. struct memory_chunk {
  122. unsigned int start;
  123. unsigned int size;
  124. unsigned int free;
  125. };
  126. /*
  127. * 60kb divided in:
  128. * - 32 blocks @ 256 bytes
  129. * - 20 blocks @ 1024 bytes
  130. * - 4 blocks @ 8192 bytes
  131. */
  132. #define BLOCK_1_NUM 32
  133. #define BLOCK_2_NUM 20
  134. #define BLOCK_3_NUM 4
  135. #define BLOCK_1_SIZE 256
  136. #define BLOCK_2_SIZE 1024
  137. #define BLOCK_3_SIZE 8192
  138. #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM)
  139. #define PAYLOAD_SIZE 0xf000
  140. /* I saw if some reloads if the pointer was negative */
  141. #define ISP1760_NULL_POINTER (0x400)
  142. /* ATL */
  143. /* DW0 */
  144. #define PTD_VALID 1
  145. #define PTD_LENGTH(x) (((u32) x) << 3)
  146. #define PTD_MAXPACKET(x) (((u32) x) << 18)
  147. #define PTD_MULTI(x) (((u32) x) << 29)
  148. #define PTD_ENDPOINT(x) (((u32) x) << 31)
  149. /* DW1 */
  150. #define PTD_DEVICE_ADDR(x) (((u32) x) << 3)
  151. #define PTD_PID_TOKEN(x) (((u32) x) << 10)
  152. #define PTD_TRANS_BULK ((u32) 2 << 12)
  153. #define PTD_TRANS_INT ((u32) 3 << 12)
  154. #define PTD_TRANS_SPLIT ((u32) 1 << 14)
  155. #define PTD_SE_USB_LOSPEED ((u32) 2 << 16)
  156. #define PTD_PORT_NUM(x) (((u32) x) << 18)
  157. #define PTD_HUB_NUM(x) (((u32) x) << 25)
  158. #define PTD_PING(x) (((u32) x) << 26)
  159. /* DW2 */
  160. #define PTD_RL_CNT(x) (((u32) x) << 25)
  161. #define PTD_DATA_START_ADDR(x) (((u32) x) << 8)
  162. #define BASE_ADDR 0x1000
  163. /* DW3 */
  164. #define PTD_CERR(x) (((u32) x) << 23)
  165. #define PTD_NAC_CNT(x) (((u32) x) << 19)
  166. #define PTD_ACTIVE ((u32) 1 << 31)
  167. #define PTD_DATA_TOGGLE(x) (((u32) x) << 25)
  168. #define DW3_HALT_BIT (1 << 30)
  169. #define DW3_ERROR_BIT (1 << 28)
  170. #define DW3_QTD_ACTIVE (1 << 31)
  171. #define INT_UNDERRUN (1 << 2)
  172. #define INT_BABBLE (1 << 1)
  173. #define INT_EXACT (1 << 0)
  174. #define DW1_GET_PID(x) (((x) >> 10) & 0x3)
  175. #define PTD_XFERRED_LENGTH(x) ((x) & 0x7fff)
  176. #define PTD_XFERRED_LENGTH_LO(x) ((x) & 0x7ff)
  177. #define SETUP_PID (2)
  178. #define IN_PID (1)
  179. #define OUT_PID (0)
  180. #define GET_QTD_TOKEN_TYPE(x) ((x) & 0x3)
  181. #define DATA_TOGGLE (1 << 31)
  182. #define GET_DATA_TOGGLE(x) ((x) >> 31)
  183. /* Errata 1 */
  184. #define RL_COUNTER (0)
  185. #define NAK_COUNTER (0)
  186. #define ERR_COUNTER (2)
  187. #define HC_ATL_PL_SIZE (8192)
  188. #endif