isp1760-hcd.h 5.2 KB

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