platform.h 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*
  2. SiI8348 Linux Driver
  3. Copyright (C) 2013 Silicon Image, Inc.
  4. This program is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU General Public License as
  6. published by the Free Software Foundation version 2.
  7. This program is distributed AS-IS WITHOUT ANY WARRANTY of any
  8. kind, whether express or implied; INCLUDING without the implied warranty
  9. of MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE or NON-INFRINGEMENT. See
  10. the GNU General Public License for more details at http://www.gnu.org/licenses/gpl-2.0.html.
  11. */
  12. #if !defined(PLATFORM_H)
  13. #define PLATFORM_H
  14. #define DEVICE_ID_8348 0x8348
  15. #define DEVICE_ID_8346 0x8346
  16. #define DEBUG_I2C_WRITE 1
  17. #define DEBUG_I2C_READ 0
  18. #define MAX_DEBUG_TRANSFER_SIZE 16
  19. #define LCD_TEXT_LENGTH_MAX 16
  20. enum dbg_msg_level {
  21. DBG_MSG_LEVEL_ERR = 0
  22. ,DBG_MSG_LEVEL_WARN
  23. ,DBG_MSG_LEVEL_INFO
  24. ,DBG_MSG_LEVEL_GPIO
  25. ,DBG_MSG_LEVEL_EDID_READ
  26. ,DBG_MSG_LEVEL_EDID_INFO
  27. };
  28. typedef enum
  29. {
  30. HAL_RET_SUCCESS,
  31. HAL_RET_FAILURE,
  32. HAL_RET_PARAMETER_ERROR,
  33. HAL_RET_NO_DEVICE,
  34. HAL_RET_DEVICE_NOT_OPEN,
  35. HAL_RET_NOT_INITIALIZED,
  36. HAL_RET_OUT_OF_RESOURCES,
  37. HAL_RET_TIMEOUT,
  38. HAL_RET_ALREADY_INITIALIZED
  39. } halReturn_t;
  40. typedef enum
  41. {
  42. MHL_GPIO_RESET,
  43. MHL_GPIO_POWER,
  44. MHL_GPIO_EINT,
  45. MHL_GPIO_DPI,
  46. MHL_GPIO_I2S,
  47. } mhl_gpio_name;
  48. typedef enum
  49. {
  50. MHL_GPIO_DEFAULT,
  51. MHL_PGIO_INPUT,
  52. MHL_GPIO_OUTPUT_LOW,
  53. MHL_GPIO_OUTPUT_HIGH,
  54. MHL_PGIO_FUNCTION_MODE
  55. }mhl_gpio_mode;
  56. /*#define DEBUG*/
  57. #if defined(DEBUG)
  58. void print_formatted_debug_msg(int level,
  59. char *file_spec, const char *func_name,
  60. int line_num,
  61. char *fmt, ...);
  62. void dump_i2c_transfer(void *context, u8 page, u8 offset,
  63. u16 count, u8 *values, bool write);
  64. #define MHL_TX_DBG_GPIO(driver_context, fmt, arg...) \
  65. print_formatted_debug_msg(DBG_MSG_LEVEL_GPIO, \
  66. NULL, __func__, __LINE__, \
  67. fmt, ## arg);
  68. #define MHL_TX_EDID_READ(context,fmt,arg...) \
  69. print_formatted_debug_msg(DBG_MSG_LEVEL_EDID_READ, \
  70. NULL, __func__, __LINE__, \
  71. fmt, ## arg);
  72. #define MHL_TX_EDID_INFO(context,fmt,arg...) \
  73. print_formatted_debug_msg(DBG_MSG_LEVEL_EDID_INFO, \
  74. NULL, __func__, __LINE__, \
  75. fmt, ## arg);
  76. #define MHL_TX_DBG_INFO(driver_context, fmt, arg...) \
  77. print_formatted_debug_msg(DBG_MSG_LEVEL_GPIO, \
  78. NULL, __func__, __LINE__, \
  79. fmt, ## arg);
  80. #define MHL_TX_DBG_WARN(driver_context, fmt, arg...) \
  81. print_formatted_debug_msg(DBG_MSG_LEVEL_WARN, \
  82. NULL, __func__, __LINE__, \
  83. fmt, ## arg);
  84. #define MHL_TX_DBG_ERR(driver_context, fmt, arg...) \
  85. print_formatted_debug_msg(DBG_MSG_LEVEL_ERR, \
  86. NULL, __func__, __LINE__, \
  87. fmt, ## arg);
  88. #define DUMP_I2C_TRANSFER(context, page, offset, count, values, write_flag) \
  89. //dump_i2c_transfer(context, page, offset, count, values, write_flag);
  90. #define DEBUG_PRINT_WRAPPER(...) \
  91. print_formatted_debug_msg(DBG_MSG_LEVEL_ERR, \
  92. __FILE__, __func__, \
  93. __LINE__, __VA_ARGS__);
  94. #define APP_DEBUG_PRINT(x) DEBUG_PRINT_WRAPPER x
  95. #define PP_DEBUG_PRINT(x) DEBUG_PRINT_WRAPPER x
  96. #define PIXCLK_DEBUG_PRINT(x) DEBUG_PRINT_WRAPPER x
  97. #define ERROR_DEBUG_PRINT(x) DEBUG_PRINT_WRAPPER x
  98. #define TX_EDID_PRINT(x) DEBUG_PRINT_WRAPPER x
  99. #define TX_DEBUG_PRINT(x) DEBUG_PRINT_WRAPPER x
  100. #define TX_PRUNE_PRINT(x) DEBUG_PRINT_WRAPPER x
  101. #define EDID_DEBUG_PRINT(x) DEBUG_PRINT_WRAPPER x
  102. #define TX_EDID_PRINT_SIMPLE(x) DEBUG_PRINT_WRAPPER x
  103. #else
  104. #define MHL_TX_DBG_INFO(driver_context, fmt, ...)
  105. #define MHL_TX_DBG_WARN(driver_context, fmt, ...)
  106. #define MHL_TX_DBG_ERR(driver_context, fmt, ...)
  107. #define MHL_TX_EDID_INFO(context,fmt,arg...)
  108. #define MHL_TX_EDID_READ(context,fmt,arg...)
  109. #define DUMP_I2C_TRANSFER(context, page, offset, count, values, write_flag)
  110. #define APP_DEBUG_PRINT(x)
  111. #define PP_DEBUG_PRINT(x)
  112. #define PIXCLK_DEBUG_PRINT(x)
  113. #define ERROR_DEBUG_PRINT(x)
  114. #define TX_EDID_PRINT(x)
  115. #define TX_DEBUG_PRINT(x)
  116. #define TX_PRUNE_PRINT(x)
  117. #define EDID_DEBUG_PRINT(x)
  118. #define TX_EDID_PRINT_SIMPLE(x)
  119. #endif
  120. enum vbus_power_state {
  121. VBUS_OFF,
  122. VBUS_ON
  123. };
  124. void mhl_tx_vbus_control(enum vbus_power_state power_state);
  125. /*
  126. struct platform_reg_pair{
  127. uint8_t slave_addr;
  128. uint8_t offset;
  129. };
  130. struct platform_signals_list {
  131. char *name;
  132. int16_t gpio_number;
  133. struct platform_reg_pair gpio_reg_PCA950x;
  134. uint8_t gpio_mask_PCA950x;
  135. bool *param;
  136. };
  137. */
  138. //int gpio_expander_init(struct mhl_dev_context *dev_context);
  139. //void gpio_expander_reset(void);
  140. bool is_reset_on_exit_requested(void);
  141. int mhl_tx_write_reg(void *drv_context, u8 page, u8 offset, u8 value);
  142. int mhl_tx_read_reg(void *drv_context, u8 page, u8 offset);
  143. int mhl_tx_write_reg_block(void *drv_context, u8 page, u8 offset, u16 count, u8 *values);
  144. int mhl_tx_read_reg_block(void *drv_context, u8 page, u8 offset, u8 count, u8 *values);
  145. int mhl_tx_modify_reg(void *drv_context, u8 page, u8 offset, u8 mask, u8 value);
  146. //void lcd_set_video(char *video);
  147. //void lcd_set_audio(char *audio);
  148. //void lcd_set_video_audio(char *video, char *audio);
  149. int is_interrupt_asserted(void);
  150. //int get_config(void *dev_context, int config_idx);
  151. //#define GPIO_LED_ON 0
  152. //#define GPIO_LED_OFF 1
  153. //void set_pin_impl(void *dev_context, int pin_idx, int value,const char *function_name,int line_num);
  154. //#define set_pin(dev_context,pin_idx,value) set_pin_impl(dev_context, pin_idx, value,__FUNCTION__,__LINE__)
  155. /*
  156. typedef enum {
  157. LED_MHL = 0,
  158. LED_USB,
  159. LED_SRC_VBUS_ON,
  160. LED_SINK_VBUS_ON,
  161. LED_3D,
  162. LED_PKD_PXL,
  163. LED_HDCP_ON,
  164. LED_D0,
  165. LED_D2 = 8,
  166. LED_D3,
  167. LED_SPR_0,
  168. LED_SPR_1,
  169. LED_SPR_2,
  170. AUD_CTRL_0,
  171. AUD_CTRL_1,
  172. VID_CTRL_RSVD,
  173. VID_CTRL_0 = 16,
  174. VID_CTRL_1,
  175. VID_CTRL_2,
  176. VID_CTRL_3,
  177. VID_CTRL_4,
  178. VID_CTRL_5,
  179. VID_CTRL_3D_0,
  180. VID_CTRL_3D_1,
  181. VBUS_EN = 24,
  182. DS_PWR_1A_EN,
  183. DBG_MSGS,
  184. RSVD,
  185. I2C_SCL,
  186. I2C_SDA,
  187. SIIMON_REQ_N,
  188. VID_CTRL_INT,
  189. TX2MHLRX_PWR_M = 32,
  190. M2U_VBUS_CTRL_M,
  191. B_RST_M_N,
  192. SIIMON_GNT_N,
  193. LCD_PWM0_STB,
  194. LCD_RS,
  195. LCD_CSB,
  196. LCD_RESET,
  197. AUD_CTRL,
  198. VID_CTRL_ALL,
  199. TX_HW_RESET
  200. }GPIO_INDICES;
  201. */
  202. void register_mhl_eint(void);
  203. #endif /* if !defined(PLATFORM_H) */