mu3d_hal_usb_drv.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. #ifndef MTK_USB_DRV_H
  2. #define MTK_USB_DRV_H
  3. #include "musb_core.h"
  4. /* #include "mu3d_hal_comm.h" */
  5. #define MAX_EP_NUM 8 /* each Tx / Rx */
  6. /* #define USB_BUF_SIZE 65536 */
  7. #define MAX_SLOT (2-1)
  8. #ifdef SUPPORT_U3
  9. /* EP0, TX, RX has separate SRAMs */
  10. #define USB_TX_FIFO_START_ADDRESS 0
  11. #define USB_RX_FIFO_START_ADDRESS 0
  12. #else
  13. /* EP0, TX, RX share one SRAM. 0-63 bytes are reserved for EP0 */
  14. #define USB_TX_FIFO_START_ADDRESS (64)
  15. #define USB_RX_FIFO_START_ADDRESS (64+512*MAX_EP_NUM)
  16. #endif
  17. #ifndef IRQ_USB_MC_NINT_CODE
  18. #define IRQ_USB_MC_NINT_CODE 8
  19. #endif
  20. #ifndef IRQ_USB_DMA_NINT_CODE
  21. #define IRQ_USB_DMA_NINT_CODE 9
  22. #endif
  23. /* IN, OUT pipe index for ep_number */
  24. typedef enum {
  25. USB_TX = 0,
  26. USB_RX
  27. } USB_DIR;
  28. /* CTRL, BULK, INTR, ISO endpoint */
  29. typedef enum {
  30. USB_CTRL = 0,
  31. USB_BULK = 2,
  32. USB_INTR = 3,
  33. USB_ISO = 1
  34. } TRANSFER_TYPE;
  35. typedef enum {
  36. SSUSB_SPEED_INACTIVE = 0,
  37. SSUSB_SPEED_FULL = 1,
  38. SSUSB_SPEED_HIGH = 3,
  39. SSUSB_SPEED_SUPER = 4,
  40. } USB_SPEED;
  41. typedef enum {
  42. EP0_IDLE = 0,
  43. EP0_TX,
  44. EP0_RX,
  45. } EP0_STATE;
  46. struct usb_ep_setting {
  47. TRANSFER_TYPE transfer_type;
  48. u32 fifoaddr;
  49. u32 fifosz;
  50. u32 maxp;
  51. USB_DIR dir;
  52. u32 enabled;
  53. };
  54. #if 0
  55. struct USB_TEST_SETTING {
  56. USB_SPEED speed;
  57. struct usb_ep_setting ep_setting[2 * MAX_EP_NUM + 1];
  58. };
  59. #endif
  60. /*
  61. * USB directions
  62. *
  63. * This bit flag is used in endpoint descriptors' bEndpointAddress field.
  64. * It's also one of three fields in control requests bRequestType.
  65. */
  66. #define USB_DIR_OUT 0 /* to device */
  67. #define USB_DIR_IN 0x80 /* to host */
  68. #define USB_DIR_MASK 0x80 /* to host */
  69. /*
  70. * USB request types
  71. */
  72. #define USB_TYPE_MASK (0x03 << 5)
  73. #define USB_TYPE_STANDARD (0x00 << 5)
  74. #define USB_TYPE_CLASS (0x01 << 5)
  75. #define USB_TYPE_VENDOR (0x02 << 5)
  76. #define USB_TYPE_RESERVED (0x03 << 5)
  77. /*
  78. * Standard requests
  79. */
  80. #define USB_REQ_GET_STATUS 0x00
  81. #define USB_REQ_CLEAR_FEATURE 0x01
  82. #define USB_REQ_SET_FEATURE 0x03
  83. #define USB_REQ_SET_ADDRESS 0x05
  84. #define USB_REQ_GET_DESCRIPTOR 0x06
  85. #define USB_REQ_SET_DESCRIPTOR 0x07
  86. #define USB_REQ_GET_CONFIGURATION 0x08
  87. #define USB_REQ_SET_CONFIGURATION 0x09
  88. #define USB_REQ_GET_INTERFACE 0x0A
  89. #define USB_REQ_SET_INTERFACE 0x0B
  90. #define USB_REQ_SYNCH_FRAME 0x0C
  91. #define USB_REQ_EP0_IN_STALL 0xFD
  92. #define USB_REQ_EP0_OUT_STALL 0xFE
  93. #define USB_REQ_EP0_STALL 0xFF
  94. void mu3d_hal_ssusb_en(struct musb *musb);
  95. void mu3d_hal_ssusb_dis(struct musb *musb);
  96. void mu3d_hal_rst_dev(struct musb *musb);
  97. int mu3d_hal_check_clk_sts(struct musb *musb);
  98. int mu3d_hal_link_up(struct musb *musb, int latch_val);
  99. void mu3d_hal_initr_dis(struct musb *musb);
  100. void mu3d_hal_clear_intr(struct musb *musb);
  101. void mu3d_hal_system_intr_en(struct musb *musb);
  102. int mu3d_hal_read_fifo_burst(struct musb *musb, int ep_num, u8 *buf);
  103. int mu3d_hal_read_fifo(struct musb_hw_ep *hw_ep, int ep_num, u8 *buf);
  104. int mu3d_hal_write_fifo_burst(struct musb *musb, int ep_num, int length, u8 *buf, int maxp);
  105. int mu3d_hal_write_fifo(struct musb_hw_ep *hw_ep, int ep_num, int length, u8 *buf, int maxp);
  106. void mu3d_hal_ep_enable(struct musb *musb, int ep_num, USB_DIR dir, TRANSFER_TYPE type, int maxp,
  107. int interval, int slot, int burst, int mult);
  108. void mu3d_hal_u2dev_connect(struct musb *musb);
  109. void mu3d_hal_u2dev_disconn(struct musb *musb);
  110. void mu3d_hal_u3dev_en(struct musb *musb);
  111. void mu3d_hal_u3dev_dis(struct musb *musb);
  112. void mu3d_hal_unfigured_ep(struct musb *musb);
  113. void mu3d_hal_unfigured_ep_num(struct musb *musb, int ep_num, USB_DIR dir);
  114. /* void mu3d_hal_set_speed(struct musb *musb, USB_SPEED usb_speed); */
  115. /* void mu3d_hal_det_speed(struct musb *musb, USB_SPEED speed, u8 det_speed); */
  116. /* void mu3d_hal_dft_reg(struct musb *musb); */
  117. #endif /* USB_DRV_H */