hv_drv_UsbMusb.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. * @file hv_drv_UsbMusb.h
  3. * @brief This is used to for host and peripheral modes of the driver for
  4. * Inventra (Multidrop) Highspeed Dual-Role Controllers: (M)HDRC.
  5. *
  6. * Board initialization should put one of these into dev->platform_data,
  7. * probably on some platform_device named "musb-hdrc". It encapsulates
  8. * key configuration differences between boards.
  9. *
  10. * @author HiView SoC Software Team
  11. * @version 1.0.0
  12. * @date 2022-06-15
  13. */
  14. #ifndef __HV_DRV_USB_MUSB_H_
  15. #define __HV_DRV_USB_MUSB_H_
  16. #include "hv_drv_UsbCompat.h"
  17. /* The USB role is defined by the connector used on the board, so long as
  18. * standards are being followed. (Developer boards sometimes won't.)
  19. */
  20. enum musb_mode {
  21. MUSB_UNDEFINED = 0,
  22. MUSB_HOST, /* A or Mini-A connector */
  23. MUSB_PERIPHERAL, /* B or Mini-B connector */
  24. MUSB_OTG /* Mini-AB connector */
  25. };
  26. struct clk;
  27. enum musb_fifo_style {
  28. FIFO_RXTX,
  29. FIFO_TX,
  30. FIFO_RX
  31. } __attribute__ ((packed));
  32. enum musb_buf_mode {
  33. BUF_SINGLE,
  34. BUF_DOUBLE
  35. } __attribute__ ((packed));
  36. struct musb_fifo_cfg {
  37. u8 hw_ep_num;
  38. enum musb_fifo_style style;
  39. enum musb_buf_mode mode;
  40. u16 maxpacket;
  41. };
  42. #define MUSB_EP_FIFO(ep, st, m, pkt) \
  43. { \
  44. .hw_ep_num = ep, \
  45. .style = st, \
  46. .mode = m, \
  47. .maxpacket = pkt, \
  48. }
  49. #define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \
  50. MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
  51. #define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \
  52. MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
  53. struct musb_hdrc_eps_bits {
  54. const char name[16];
  55. u8 bits;
  56. };
  57. struct musb_hdrc_config {
  58. struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */
  59. unsigned fifo_cfg_size; /* size of the fifo configuration */
  60. /* MUSB configuration-specific details */
  61. unsigned multipoint:1; /* multipoint device */
  62. unsigned dyn_fifo:1; /* supports dynamic fifo sizing */
  63. unsigned soft_con:1; /* soft connect required */
  64. unsigned utm_16:1; /* utm data witdh is 16 bits */
  65. unsigned big_endian:1; /* true if CPU uses big-endian */
  66. unsigned mult_bulk_tx:1; /* Tx ep required for multbulk pkts */
  67. unsigned mult_bulk_rx:1; /* Rx ep required for multbulk pkts */
  68. unsigned high_iso_tx:1; /* Tx ep required for HB iso */
  69. unsigned high_iso_rx:1; /* Rx ep required for HD iso */
  70. unsigned dma:1; /* supports DMA */
  71. unsigned vendor_req:1; /* vendor registers required */
  72. u8 num_eps; /* number of endpoints _with_ ep0 */
  73. u8 dma_channels; /* number of dma channels */
  74. u8 dyn_fifo_size; /* dynamic size in bytes */
  75. u8 vendor_ctrl; /* vendor control reg width */
  76. u8 vendor_stat; /* vendor status reg witdh */
  77. u8 dma_req_chan; /* bitmask for required dma channels */
  78. u8 ram_bits; /* ram address size */
  79. struct musb_hdrc_eps_bits *eps_bits;
  80. };
  81. struct musb_hdrc_platform_data {
  82. /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
  83. u8 mode;
  84. /* for clk_get() */
  85. const char *clock;
  86. /* (HOST or OTG) switch VBUS on/off */
  87. int (*set_vbus)(struct device *dev, int is_on);
  88. /* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
  89. u8 power;
  90. /* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
  91. u8 min_power;
  92. /* (HOST or OTG) msec/2 after VBUS on till power good */
  93. u8 potpgt;
  94. /* (HOST or OTG) program PHY for external Vbus */
  95. unsigned extvbus:1;
  96. /* Power the device on or off */
  97. int (*set_power)(int state);
  98. /* MUSB configuration-specific details */
  99. struct musb_hdrc_config *config;
  100. /* Architecture specific board data */
  101. void *board_data;
  102. /* Platform specific struct musb_ops pointer */
  103. const void *platform_ops;
  104. };
  105. /*
  106. * U-Boot specfic stuff
  107. */
  108. int musb_register(struct musb_hdrc_platform_data *plat, void *bdata, void *ctl_regs);
  109. #endif