musb.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /*
  3. * 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. #ifndef __LINUX_USB_MUSB_H
  11. #define __LINUX_USB_MUSB_H
  12. /* The USB role is defined by the connector used on the board, so long as
  13. * standards are being followed. (Developer boards sometimes won't.)
  14. */
  15. enum musb_mode {
  16. MUSB_UNDEFINED = 0,
  17. MUSB_HOST, /* A or Mini-A connector */
  18. MUSB_PERIPHERAL, /* B or Mini-B connector */
  19. MUSB_OTG /* Mini-AB connector */
  20. };
  21. struct clk;
  22. enum musb_fifo_style {
  23. FIFO_RXTX,
  24. FIFO_TX,
  25. FIFO_RX
  26. } __attribute__ ((packed));
  27. enum musb_buf_mode {
  28. BUF_SINGLE,
  29. BUF_DOUBLE
  30. } __attribute__ ((packed));
  31. struct musb_fifo_cfg {
  32. u8 hw_ep_num;
  33. enum musb_fifo_style style;
  34. enum musb_buf_mode mode;
  35. u16 maxpacket;
  36. };
  37. #define MUSB_EP_FIFO(ep, st, m, pkt) \
  38. { \
  39. .hw_ep_num = ep, \
  40. .style = st, \
  41. .mode = m, \
  42. .maxpacket = pkt, \
  43. }
  44. #define MUSB_EP_FIFO_SINGLE(ep, st, pkt) \
  45. MUSB_EP_FIFO(ep, st, BUF_SINGLE, pkt)
  46. #define MUSB_EP_FIFO_DOUBLE(ep, st, pkt) \
  47. MUSB_EP_FIFO(ep, st, BUF_DOUBLE, pkt)
  48. struct musb_hdrc_eps_bits {
  49. const char name[16];
  50. u8 bits;
  51. };
  52. struct musb_hdrc_config {
  53. struct musb_fifo_cfg *fifo_cfg; /* board fifo configuration */
  54. unsigned fifo_cfg_size; /* size of the fifo configuration */
  55. /* MUSB configuration-specific details */
  56. unsigned multipoint:1; /* multipoint device */
  57. unsigned dyn_fifo:1 __deprecated; /* supports dynamic fifo sizing */
  58. /* need to explicitly de-assert the port reset after resume? */
  59. unsigned host_port_deassert_reset_at_resume:1;
  60. u8 num_eps; /* number of endpoints _with_ ep0 */
  61. u8 ram_bits; /* ram address size */
  62. u32 maximum_speed;
  63. };
  64. struct musb_hdrc_platform_data {
  65. /* MUSB_HOST, MUSB_PERIPHERAL, or MUSB_OTG */
  66. u8 mode;
  67. /* for clk_get() */
  68. const char *clock;
  69. /* (HOST or OTG) switch VBUS on/off */
  70. int (*set_vbus)(struct device *dev, int is_on);
  71. /* (HOST or OTG) mA/2 power supplied on (default = 8mA) */
  72. u8 power;
  73. /* (PERIPHERAL) mA/2 max power consumed (default = 100mA) */
  74. u8 min_power;
  75. /* (HOST or OTG) msec/2 after VBUS on till power good */
  76. u8 potpgt;
  77. /* (HOST or OTG) program PHY for external Vbus */
  78. unsigned extvbus:1;
  79. /* Power the device on or off */
  80. int (*set_power)(int state);
  81. /* MUSB configuration-specific details */
  82. const struct musb_hdrc_config *config;
  83. /* Architecture specific board data */
  84. void *board_data;
  85. /* Platform specific struct musb_ops pointer */
  86. const void *platform_ops;
  87. };
  88. enum musb_vbus_id_status {
  89. MUSB_UNKNOWN = 0,
  90. MUSB_ID_GROUND,
  91. MUSB_ID_FLOAT,
  92. MUSB_VBUS_VALID,
  93. MUSB_VBUS_OFF,
  94. };
  95. #if IS_ENABLED(CONFIG_USB_MUSB_HDRC)
  96. int musb_mailbox(enum musb_vbus_id_status status);
  97. #else
  98. static inline int musb_mailbox(enum musb_vbus_id_status status)
  99. {
  100. return 0;
  101. }
  102. #endif
  103. /* TUSB 6010 support */
  104. #define TUSB6010_OSCCLK_60 16667 /* psec/clk @ 60.0 MHz */
  105. #define TUSB6010_REFCLK_24 41667 /* psec/clk @ 24.0 MHz XI */
  106. #define TUSB6010_REFCLK_19 52083 /* psec/clk @ 19.2 MHz CLKIN */
  107. #ifdef CONFIG_ARCH_OMAP2
  108. extern int __init tusb6010_setup_interface(
  109. struct musb_hdrc_platform_data *data,
  110. unsigned ps_refclk, unsigned waitpin,
  111. unsigned async_cs, unsigned sync_cs,
  112. unsigned irq, unsigned dmachan);
  113. extern int tusb6010_platform_retime(unsigned is_refclk);
  114. #endif /* OMAP2 */
  115. #endif /* __LINUX_USB_MUSB_H */