musbfsh_icusb.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. * ICUSB - for MUSB Host Driver defines
  3. *
  4. * Copyright 2015 Mediatek Inc.
  5. * Marvin Lin <marvin.lin@mediatek.com>
  6. * Arvin Wang <arvin.wang@mediatek.com>
  7. * Vincent Fan <vincent.fan@mediatek.com>
  8. * Bryant Lu <bryant.lu@mediatek.com>
  9. * Yu-Chang Wang <yu-chang.wang@mediatek.com>
  10. * Macpaul Lin <macpaul.lin@mediatek.com>
  11. *
  12. * This program is free software; you can redistribute it and/or
  13. * modify it under the terms of the GNU General Public License
  14. * version 2 as published by the Free Software Foundation.
  15. *
  16. * This program is distributed in the hope that it will be useful, but
  17. * WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  19. * General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program.
  23. *
  24. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
  25. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  26. * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN
  27. * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
  28. * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  29. * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  30. * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
  31. * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  32. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
  33. * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. */
  35. #ifndef _MUSBFSH_ICUSB_H
  36. #define _MUSBFSH_ICUSB_H
  37. enum PHY_VOLTAGE_TYPE {
  38. VOL_18 = 0,
  39. VOL_33,
  40. VOL_50,
  41. };
  42. enum SESSION_CONTROL_ACTION {
  43. STOP_SESSION = 0,
  44. START_SESSION,
  45. };
  46. enum WAIT_DISCONNECT_DONE_ACTION {
  47. WAIT_DISCONNECT_DONE_DFT_ACTION = 0,
  48. };
  49. #define IC_USB_CMD_LEN 255
  50. struct IC_USB_CMD {
  51. unsigned char type;
  52. unsigned char length;
  53. unsigned char data[IC_USB_CMD_LEN];
  54. };
  55. enum IC_USB_CMD_TYPE {
  56. USB11_SESSION_CONTROL = 0,
  57. USB11_INIT_PHY_BY_VOLTAGE,
  58. USB11_WAIT_DISCONNECT_DONE,
  59. };
  60. /* ICUSB feature list */
  61. /* --- sysfs controlable feature --- */
  62. #define MTK_ICUSB_POWER_AND_RESUME_TIME_NEOGO_SUPPORT
  63. #define MTK_ICUSB_SKIP_SESSION_REQ
  64. #define MTK_ICUSB_SKIP_ENABLE_SESSION
  65. #define MTK_ICUSB_SKIP_MAC_INIT
  66. #define MTK_ICUSB_RESISTOR_CONTROL
  67. #define MTK_ICUSB_HW_DBG
  68. /* #define MTK_ICUSB_SKIP_PORT_PM */
  69. /* --- non sysfs controlable feature --- */
  70. /* #define MTK_ICUSB_TAKE_WAKE_LOCK */
  71. /* #define MTK_ICUSB_BABBLE_RECOVER */
  72. struct my_attr {
  73. struct attribute attr;
  74. int value;
  75. };
  76. /* power neogo */
  77. #define IC_USB_REQ_TYPE_GET_IFACE_POWER 0xC0 /* Get interface power */
  78. #define IC_USB_REQ_TYPE_SET_IFACE_POWER 0x40 /* Set interface power */
  79. #define IC_USB_REQ_GET_IFACE_POWER 0x01 /* Get interface power */
  80. #define IC_USB_REQ_SET_IFACE_POWER 0x02 /* Set interface power */
  81. #define IC_USB_WVALUE_POWER_NEGOTIATION 0
  82. #define IC_USB_WINDEX_POWER_NEGOTIATION 0
  83. #define IC_USB_LEN_POWER_NEGOTIATION 2
  84. #define IC_USB_PREFER_CLASSB_ENABLE_BIT 0x80
  85. #define IC_USB_RETRIES_POWER_NEGOTIATION 3
  86. #define IC_USB_CLASSB (1<<1)
  87. #define IC_USB_CLASSC (1<<2)
  88. #define IC_USB_CURRENT 100 /* in 2 mA unit, 100 denotes 200 mA */
  89. /* resume_time neogo */
  90. #define IC_USB_REQ_TYPE_GET_INTERFACE_RESUME_TIME 0xC0
  91. #define IC_USB_REQ_GET_INTERFACE_RESUME_TIME 0x03
  92. #define IC_USB_WVALUE_RESUME_TIME_NEGOTIATION 0
  93. #define IC_USB_WINDEX_RESUME_TIME_NEGOTIATION 0
  94. #define IC_USB_LEN_RESUME_TIME_NEGOTIATION 3
  95. #define IC_USB_RETRIES_RESUME_TIME_NEGOTIATION 3
  96. /* == =================== */
  97. /* ic_usb_status : */
  98. /* Byte4 : wait disconnect status */
  99. /* Byte3 Byte2 : get interface power reqest data field */
  100. /* Byte1 : power negotiation result */
  101. /* */
  102. /* ===================== */
  103. #define PREFER_VOL_STS_SHIFT (0)
  104. #define PREFER_VOL_STS_MSK (0x3)
  105. #define PREFER_VOL_NOT_INITED 0x0
  106. #define PREFER_VOL_PWR_NEG_FAIL 0x1
  107. #define PREFER_VOL_PWR_NEG_OK 0x2
  108. #define PREFER_VOL_CLASS_SHIFT (8)
  109. #define PREFER_VOL_CLASS_MSK (0xff)
  110. #define USB_PORT1_STS_SHIFT (24)
  111. #define USB_PORT1_STS_MSK (0xf)
  112. #define USB_PORT1_DISCONNECTING 0x0
  113. #define USB_PORT1_DISCONNECT_DONE 0x1
  114. #define USB_PORT1_CONNECT 0x2
  115. extern struct my_attr power_resume_time_neogo_attr;
  116. extern struct my_attr skip_session_req_attr;
  117. extern struct my_attr skip_enable_session_attr;
  118. extern struct my_attr skip_mac_init_attr;
  119. extern struct my_attr resistor_control_attr;
  120. extern struct my_attr hw_dbg_attr;
  121. extern struct my_attr skip_port_pm_attr;
  122. extern void musbfsh_start_session(void);
  123. extern void musbfsh_start_session_pure(void);
  124. extern void musbfsh_stop_session(void);
  125. extern void musbfsh_init_phy_by_voltage(enum PHY_VOLTAGE_TYPE);
  126. extern enum PHY_VOLTAGE_TYPE get_usb11_phy_voltage(void);
  127. extern void mt65xx_usb11_mac_reset_and_phy_stress_set(void);
  128. extern int is_usb11_enabled(void);
  129. #define MYDBG(fmt, args...) pr_warn("MTK_ICUSB [DBG], <%s(), %d> " fmt, \
  130. __func__, __LINE__, ## args)
  131. #endif