isp1760-hcd.h 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. #ifndef _ISP1760_HCD_H_
  2. #define _ISP1760_HCD_H_
  3. /* exports for if */
  4. struct usb_hcd *isp1760_register(phys_addr_t res_start, resource_size_t res_len,
  5. int irq, unsigned long irqflags,
  6. struct device *dev, const char *busname,
  7. unsigned int devflags);
  8. int init_kmem_once(void);
  9. void deinit_kmem_cache(void);
  10. /* EHCI capability registers */
  11. #define HC_CAPLENGTH 0x00
  12. #define HC_HCSPARAMS 0x04
  13. #define HC_HCCPARAMS 0x08
  14. /* EHCI operational registers */
  15. #define HC_USBCMD 0x20
  16. #define HC_USBSTS 0x24
  17. #define HC_FRINDEX 0x2c
  18. #define HC_CONFIGFLAG 0x60
  19. #define HC_PORTSC1 0x64
  20. #define HC_ISO_PTD_DONEMAP_REG 0x130
  21. #define HC_ISO_PTD_SKIPMAP_REG 0x134
  22. #define HC_ISO_PTD_LASTPTD_REG 0x138
  23. #define HC_INT_PTD_DONEMAP_REG 0x140
  24. #define HC_INT_PTD_SKIPMAP_REG 0x144
  25. #define HC_INT_PTD_LASTPTD_REG 0x148
  26. #define HC_ATL_PTD_DONEMAP_REG 0x150
  27. #define HC_ATL_PTD_SKIPMAP_REG 0x154
  28. #define HC_ATL_PTD_LASTPTD_REG 0x158
  29. /* Configuration Register */
  30. #define HC_HW_MODE_CTRL 0x300
  31. #define ALL_ATX_RESET (1 << 31)
  32. #define HW_ANA_DIGI_OC (1 << 15)
  33. #define HW_DATA_BUS_32BIT (1 << 8)
  34. #define HW_DACK_POL_HIGH (1 << 6)
  35. #define HW_DREQ_POL_HIGH (1 << 5)
  36. #define HW_INTR_HIGH_ACT (1 << 2)
  37. #define HW_INTR_EDGE_TRIG (1 << 1)
  38. #define HW_GLOBAL_INTR_EN (1 << 0)
  39. #define HC_CHIP_ID_REG 0x304
  40. #define HC_SCRATCH_REG 0x308
  41. #define HC_RESET_REG 0x30c
  42. #define SW_RESET_RESET_HC (1 << 1)
  43. #define SW_RESET_RESET_ALL (1 << 0)
  44. #define HC_BUFFER_STATUS_REG 0x334
  45. #define ISO_BUF_FILL (1 << 2)
  46. #define INT_BUF_FILL (1 << 1)
  47. #define ATL_BUF_FILL (1 << 0)
  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 HC_ISO_INT (1 << 9)
  60. #define HC_ATL_INT (1 << 8)
  61. #define HC_INTL_INT (1 << 7)
  62. #define HC_EOT_INT (1 << 3)
  63. #define HC_SOT_INT (1 << 1)
  64. #define INTERRUPT_ENABLE_MASK (HC_INTL_INT | HC_ATL_INT)
  65. #define INTERRUPT_ENABLE_SOT_MASK (HC_SOT_INT)
  66. #define HC_ISO_IRQ_MASK_OR_REG 0x318
  67. #define HC_INT_IRQ_MASK_OR_REG 0x31C
  68. #define HC_ATL_IRQ_MASK_OR_REG 0x320
  69. #define HC_ISO_IRQ_MASK_AND_REG 0x324
  70. #define HC_INT_IRQ_MASK_AND_REG 0x328
  71. #define HC_ATL_IRQ_MASK_AND_REG 0x32C
  72. /* urb state*/
  73. #define DELETE_URB (0x0008)
  74. #define NO_TRANSFER_ACTIVE (0xffffffff)
  75. /* Philips Proprietary Transfer Descriptor (PTD) */
  76. typedef __u32 __bitwise __dw;
  77. struct ptd {
  78. __dw dw0;
  79. __dw dw1;
  80. __dw dw2;
  81. __dw dw3;
  82. __dw dw4;
  83. __dw dw5;
  84. __dw dw6;
  85. __dw dw7;
  86. };
  87. #define PTD_OFFSET 0x0400
  88. #define ISO_PTD_OFFSET 0x0400
  89. #define INT_PTD_OFFSET 0x0800
  90. #define ATL_PTD_OFFSET 0x0c00
  91. #define PAYLOAD_OFFSET 0x1000
  92. struct slotinfo {
  93. struct isp1760_qh *qh;
  94. struct isp1760_qtd *qtd;
  95. };
  96. typedef void (packet_enqueue)(struct usb_hcd *hcd, struct isp1760_qh *qh,
  97. struct isp1760_qtd *qtd);
  98. /*
  99. * Device flags that can vary from board to board. All of these
  100. * indicate the most "atypical" case, so that a devflags of 0 is
  101. * a sane default configuration.
  102. */
  103. #define ISP1760_FLAG_BUS_WIDTH_16 0x00000002 /* 16-bit data bus width */
  104. #define ISP1760_FLAG_OTG_EN 0x00000004 /* Port 1 supports OTG */
  105. #define ISP1760_FLAG_ANALOG_OC 0x00000008 /* Analog overcurrent */
  106. #define ISP1760_FLAG_DACK_POL_HIGH 0x00000010 /* DACK active high */
  107. #define ISP1760_FLAG_DREQ_POL_HIGH 0x00000020 /* DREQ active high */
  108. #define ISP1760_FLAG_ISP1761 0x00000040 /* Chip is ISP1761 */
  109. #define ISP1760_FLAG_INTR_POL_HIGH 0x00000080 /* Interrupt polarity active high */
  110. #define ISP1760_FLAG_INTR_EDGE_TRIG 0x00000100 /* Interrupt edge triggered */
  111. /* chip memory management */
  112. struct memory_chunk {
  113. unsigned int start;
  114. unsigned int size;
  115. unsigned int free;
  116. };
  117. /*
  118. * 60kb divided in:
  119. * - 32 blocks @ 256 bytes
  120. * - 20 blocks @ 1024 bytes
  121. * - 4 blocks @ 8192 bytes
  122. */
  123. #define BLOCK_1_NUM 32
  124. #define BLOCK_2_NUM 20
  125. #define BLOCK_3_NUM 4
  126. #define BLOCK_1_SIZE 256
  127. #define BLOCK_2_SIZE 1024
  128. #define BLOCK_3_SIZE 8192
  129. #define BLOCKS (BLOCK_1_NUM + BLOCK_2_NUM + BLOCK_3_NUM)
  130. #define MAX_PAYLOAD_SIZE BLOCK_3_SIZE
  131. #define PAYLOAD_AREA_SIZE 0xf000
  132. /* ATL */
  133. /* DW0 */
  134. #define DW0_VALID_BIT 1
  135. #define FROM_DW0_VALID(x) ((x) & 0x01)
  136. #define TO_DW0_LENGTH(x) (((u32) x) << 3)
  137. #define TO_DW0_MAXPACKET(x) (((u32) x) << 18)
  138. #define TO_DW0_MULTI(x) (((u32) x) << 29)
  139. #define TO_DW0_ENDPOINT(x) (((u32) x) << 31)
  140. /* DW1 */
  141. #define TO_DW1_DEVICE_ADDR(x) (((u32) x) << 3)
  142. #define TO_DW1_PID_TOKEN(x) (((u32) x) << 10)
  143. #define DW1_TRANS_BULK ((u32) 2 << 12)
  144. #define DW1_TRANS_INT ((u32) 3 << 12)
  145. #define DW1_TRANS_SPLIT ((u32) 1 << 14)
  146. #define DW1_SE_USB_LOSPEED ((u32) 2 << 16)
  147. #define TO_DW1_PORT_NUM(x) (((u32) x) << 18)
  148. #define TO_DW1_HUB_NUM(x) (((u32) x) << 25)
  149. /* DW2 */
  150. #define TO_DW2_DATA_START_ADDR(x) (((u32) x) << 8)
  151. #define TO_DW2_RL(x) ((x) << 25)
  152. #define FROM_DW2_RL(x) (((x) >> 25) & 0xf)
  153. /* DW3 */
  154. #define FROM_DW3_NRBYTESTRANSFERRED(x) ((x) & 0x7fff)
  155. #define FROM_DW3_SCS_NRBYTESTRANSFERRED(x) ((x) & 0x07ff)
  156. #define TO_DW3_NAKCOUNT(x) ((x) << 19)
  157. #define FROM_DW3_NAKCOUNT(x) (((x) >> 19) & 0xf)
  158. #define TO_DW3_CERR(x) ((x) << 23)
  159. #define FROM_DW3_CERR(x) (((x) >> 23) & 0x3)
  160. #define TO_DW3_DATA_TOGGLE(x) ((x) << 25)
  161. #define FROM_DW3_DATA_TOGGLE(x) (((x) >> 25) & 0x1)
  162. #define TO_DW3_PING(x) ((x) << 26)
  163. #define FROM_DW3_PING(x) (((x) >> 26) & 0x1)
  164. #define DW3_ERROR_BIT (1 << 28)
  165. #define DW3_BABBLE_BIT (1 << 29)
  166. #define DW3_HALT_BIT (1 << 30)
  167. #define DW3_ACTIVE_BIT (1 << 31)
  168. #define INT_UNDERRUN (1 << 2)
  169. #define INT_BABBLE (1 << 1)
  170. #define INT_EXACT (1 << 0)
  171. #define SETUP_PID (2)
  172. #define IN_PID (1)
  173. #define OUT_PID (0)
  174. /* Errata 1 */
  175. #define RL_COUNTER (0)
  176. #define NAK_COUNTER (0)
  177. #define ERR_COUNTER (2)
  178. #endif /* _ISP1760_HCD_H_ */