wmt_plat.h 8.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /*
  2. * Copyright (C) 2011-2014 MediaTek Inc.
  3. *
  4. * This program is free software: you can redistribute it and/or modify it under the terms of the
  5. * GNU General Public License version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  8. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  9. * See the GNU General Public License for more details.
  10. *
  11. * You should have received a copy of the GNU General Public License along with this program.
  12. * If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /*! \file
  15. \brief Declaration of library functions
  16. Any definitions in this file will be shared among GLUE Layer and internal Driver Stack.
  17. */
  18. #ifndef _WMT_PLAT_H_
  19. #define _WMT_PLAT_H_
  20. #include "osal_typedef.h"
  21. #include "stp_exp.h"
  22. #include <mtk_wcn_cmb_stub.h>
  23. /* #include "mtk_wcn_consys_hw.h" */
  24. /*******************************************************************************
  25. * C O M P I L E R F L A G S
  26. ********************************************************************************
  27. */
  28. /*******************************************************************************
  29. * M A C R O S
  30. ********************************************************************************
  31. */
  32. #if 1 /* moved from wmt_exp.h */
  33. #ifndef DFT_TAG
  34. #define DFT_TAG "[WMT-DFT]"
  35. #endif
  36. #define WMT_PLAT_LOG_LOUD 4
  37. #define WMT_PLAT_LOG_DBG 3
  38. #define WMT_PLAT_LOG_INFO 2
  39. #define WMT_PLAT_LOG_WARN 1
  40. #define WMT_PLAT_LOG_ERR 0
  41. extern UINT32 wmtPlatLogLvl;
  42. #define WMT_PLAT_LOUD_FUNC(fmt, arg...) \
  43. do { \
  44. if (wmtPlatLogLvl >= WMT_PLAT_LOG_LOUD) \
  45. pr_debug(DFT_TAG "[L]%s:" fmt, __func__ , ##arg); \
  46. } while (0)
  47. #define WMT_PLAT_INFO_FUNC(fmt, arg...) \
  48. do { \
  49. if (wmtPlatLogLvl >= WMT_PLAT_LOG_INFO) \
  50. pr_debug(DFT_TAG "[I]%s:" fmt, __func__ , ##arg); \
  51. } while (0)
  52. #define WMT_PLAT_WARN_FUNC(fmt, arg...) \
  53. do { \
  54. if (wmtPlatLogLvl >= WMT_PLAT_LOG_WARN) \
  55. pr_warn(DFT_TAG "[W]%s:" fmt, __func__ , ##arg); \
  56. } while (0)
  57. #define WMT_PLAT_ERR_FUNC(fmt, arg...) \
  58. do { \
  59. if (wmtPlatLogLvl >= WMT_PLAT_LOG_ERR) \
  60. pr_err(DFT_TAG "[E]%s(%d):" fmt, __func__ , __LINE__, ##arg); \
  61. } while (0)
  62. #define WMT_PLAT_DBG_FUNC(fmt, arg...) \
  63. do { \
  64. if (wmtPlatLogLvl >= WMT_PLAT_LOG_DBG) \
  65. pr_debug(DFT_TAG "[D]%s:" fmt, __func__ , ##arg); \
  66. } while (0)
  67. #endif
  68. #define CFG_WMT_PS_SUPPORT 1 /* moved from wmt_exp.h */
  69. #define CFG_WMT_DUMP_INT_STATUS 0
  70. #define CONSYS_ENALBE_SET_JTAG 1
  71. /*******************************************************************************
  72. * C O N S T A N T S
  73. ********************************************************************************
  74. */
  75. /*******************************************************************************
  76. * D A T A T Y P E S
  77. ********************************************************************************
  78. */
  79. typedef enum _ENUM_FUNC_STATE_ {
  80. FUNC_ON = 0,
  81. FUNC_OFF = 1,
  82. FUNC_RST = 2,
  83. FUNC_STAT = 3,
  84. FUNC_CTRL_MAX,
  85. } ENUM_FUNC_STATE, *P_ENUM_FUNC_STATE;
  86. typedef enum _ENUM_PIN_ID_ {
  87. PIN_BGF_EINT = 0,
  88. PIN_I2S_GRP = 1,
  89. PIN_GPS_SYNC = 2,
  90. PIN_GPS_LNA = 3,
  91. #if CFG_WMT_LTE_COEX_HANDLING
  92. PIN_TDM_REQ = 4,
  93. #endif
  94. PIN_ID_MAX
  95. } ENUM_PIN_ID, *P_ENUM_PIN_ID;
  96. typedef enum _ENUM_PIN_STATE_ {
  97. PIN_STA_INIT = 0,
  98. PIN_STA_OUT_L = 1,
  99. PIN_STA_OUT_H = 2,
  100. PIN_STA_IN_L = 3,
  101. PIN_STA_MUX = 4,
  102. PIN_STA_EINT_EN = 5,
  103. PIN_STA_EINT_DIS = 6,
  104. PIN_STA_DEINIT = 7,
  105. PIN_STA_SHOW = 8,
  106. PIN_STA_MAX
  107. } ENUM_PIN_STATE, *P_ENUM_PIN_STATE;
  108. typedef enum _CMB_IF_TYPE_ {
  109. CMB_IF_UART = 0,
  110. CMB_IF_WIFI_SDIO = 1,
  111. CMB_IF_BGF_SDIO = 2,
  112. CMB_IF_BGWF_SDIO = 3,
  113. CMB_IF_TYPE_MAX
  114. } CMB_IF_TYPE, *P_CMB_IF_TYPE;
  115. typedef INT32(*fp_set_pin) (ENUM_PIN_STATE);
  116. typedef enum _ENUM_WL_OP_ {
  117. WL_OP_GET = 0,
  118. WL_OP_PUT = 1,
  119. WL_OP_MAX
  120. } ENUM_WL_OP, *P_ENUM_WL_OP;
  121. typedef enum _ENUM_PALDO_TYPE_ {
  122. BT_PALDO = 0,
  123. WIFI_PALDO = 1,
  124. FM_PALDO = 2,
  125. GPS_PALDO = 3,
  126. PMIC_CHIPID_PALDO = 4,
  127. WIFI_5G_PALDO = 5,
  128. PALDO_TYPE_MAX
  129. } ENUM_PALDO_TYPE, *P_ENUM_PALDO_TYPE;
  130. typedef enum _ENUM_PALDO_OP_ {
  131. PALDO_OFF = 0,
  132. PALDO_ON = 1,
  133. PALDO_OP_MAX
  134. } ENUM_PALDO_OP, *P_ENUM_PALDO_OP;
  135. typedef enum _ENUM_HOST_DUMP_STATE_T {
  136. STP_HOST_DUMP_NOT_START = 0,
  137. STP_HOST_DUMP_GET = 1,
  138. STP_HOST_DUMP_GET_DONE = 2,
  139. STP_HOST_DUMP_END = 3,
  140. STP_HOST_DUMP_MAX
  141. } ENUM_HOST_DUMP_STATE, *P_ENUM_HOST_DUMP_STATE_T;
  142. typedef enum _ENUM_FORCE_TRG_ASSERT_T {
  143. STP_FORCE_TRG_ASSERT_EMI = 0,
  144. STP_FORCE_TRG_ASSERT_DEBUG_PIN = 1,
  145. STP_FORCE_TRG_ASSERT_MAX = 2
  146. } ENUM_FORCE_TRG_ASSERT_T, *P_ENUM_FORCE_TRG_ASSERT_T;
  147. typedef enum _ENUM_CHIP_DUMP_STATE_T {
  148. STP_CHIP_DUMP_NOT_START = 0,
  149. STP_CHIP_DUMP_PUT = 1,
  150. STP_CHIP_DUMP_PUT_DONE = 2,
  151. STP_CHIP_DUMP_END = 3,
  152. STP_CHIP_DUMP_MAX
  153. } ENUM_CHIP_DUMP_STATE, *P_ENUM_CHIP_DUMP_STATE_T;
  154. typedef struct _EMI_CTRL_STATE_OFFSET_ {
  155. UINT32 emi_apmem_ctrl_state;
  156. UINT32 emi_apmem_ctrl_host_sync_state;
  157. UINT32 emi_apmem_ctrl_host_sync_num;
  158. UINT32 emi_apmem_ctrl_chip_sync_state;
  159. UINT32 emi_apmem_ctrl_chip_sync_num;
  160. UINT32 emi_apmem_ctrl_chip_sync_addr;
  161. UINT32 emi_apmem_ctrl_chip_sync_len;
  162. UINT32 emi_apmem_ctrl_chip_print_buff_start;
  163. UINT32 emi_apmem_ctrl_chip_print_buff_len;
  164. UINT32 emi_apmem_ctrl_chip_print_buff_idx;
  165. UINT32 emi_apmem_ctrl_chip_int_status;
  166. UINT32 emi_apmem_ctrl_chip_paded_dump_end;
  167. UINT32 emi_apmem_ctrl_host_outband_assert_w1;
  168. UINT32 emi_apmem_ctrl_chip_page_dump_num;
  169. } EMI_CTRL_STATE_OFFSET, *P_EMI_CTRL_STATE_OFFSET;
  170. typedef struct _BGF_IRQ_BALANCE_ {
  171. UINT32 counter;
  172. unsigned long flags;
  173. spinlock_t lock;
  174. } BGF_IRQ_BALANCE, *P_BGF_IRQ_BALANCE;
  175. typedef struct _CONSYS_EMI_ADDR_INFO_ {
  176. UINT32 emi_phy_addr;
  177. UINT32 paged_trace_off;
  178. UINT32 paged_dump_off;
  179. UINT32 full_dump_off;
  180. P_EMI_CTRL_STATE_OFFSET p_ecso;
  181. } CONSYS_EMI_ADDR_INFO, *P_CONSYS_EMI_ADDR_INFO;
  182. typedef struct _GPIO_TDM_REQ_INFO_ {
  183. UINT32 ant_sel_index;
  184. UINT32 gpio_number;
  185. UINT32 cr_address;
  186. } GPIO_TDM_REQ_INFO, *P_GPIO_TDM_REQ_INFO;
  187. typedef VOID(*irq_cb) (VOID);
  188. typedef INT32(*device_audio_if_cb) (CMB_STUB_AIF_X aif, MTK_WCN_BOOL share);
  189. typedef VOID(*func_ctrl_cb) (UINT32 on, UINT32 type);
  190. typedef long (*thermal_query_ctrl_cb) (VOID);
  191. typedef INT32(*deep_idle_ctrl_cb) (UINT32);
  192. /*******************************************************************************
  193. * E X T E R N A L R E F E R E N C E S
  194. ********************************************************************************
  195. */
  196. /*******************************************************************************
  197. * P U B L I C D A T A
  198. ********************************************************************************
  199. */
  200. extern UINT32 gWmtDbgLvl;
  201. extern struct device *wmt_dev;
  202. #ifdef CFG_WMT_READ_EFUSE_VCN33
  203. extern INT32 wmt_set_pmic_voltage(UINT32 level);
  204. #endif
  205. /*******************************************************************************
  206. * P R I V A T E D A T A
  207. ********************************************************************************
  208. */
  209. /*******************************************************************************
  210. * F U N C T I O N D E C L A R A T I O N S
  211. ********************************************************************************
  212. */
  213. INT32 wmt_plat_init(UINT32 co_clock_type);
  214. INT32 wmt_plat_deinit(VOID);
  215. INT32 wmt_plat_pwr_ctrl(ENUM_FUNC_STATE state);
  216. INT32 wmt_plat_gpio_ctrl(ENUM_PIN_ID id, ENUM_PIN_STATE state);
  217. INT32 wmt_plat_eirq_ctrl(ENUM_PIN_ID id, ENUM_PIN_STATE state);
  218. INT32 wmt_plat_wake_lock_ctrl(ENUM_WL_OP opId);
  219. INT32 wmt_plat_audio_ctrl(CMB_STUB_AIF_X state, CMB_STUB_AIF_CTRL ctrl);
  220. VOID wmt_plat_irq_cb_reg(irq_cb bgf_irq_cb);
  221. VOID wmt_plat_aif_cb_reg(device_audio_if_cb aif_ctrl_cb);
  222. VOID wmt_plat_func_ctrl_cb_reg(func_ctrl_cb subsys_func_ctrl);
  223. VOID wmt_plat_thermal_ctrl_cb_reg(thermal_query_ctrl_cb thermal_query_ctrl);
  224. VOID wmt_plat_deep_idle_ctrl_cb_reg(deep_idle_ctrl_cb deep_idle_ctrl);
  225. INT32 wmt_plat_soc_paldo_ctrl(ENUM_PALDO_TYPE ePt, ENUM_PALDO_OP ePo);
  226. UINT8 *wmt_plat_get_emi_virt_add(UINT32 offset);
  227. #if CONSYS_ENALBE_SET_JTAG
  228. UINT32 wmt_plat_jtag_flag_ctrl(UINT32 en);
  229. #endif
  230. #if CFG_WMT_DUMP_INT_STATUS
  231. VOID wmt_plat_BGF_irq_dump_status(VOID);
  232. MTK_WCN_BOOL wmt_plat_dump_BGF_irq_status(VOID);
  233. #endif
  234. P_CONSYS_EMI_ADDR_INFO wmt_plat_get_emi_phy_add(VOID);
  235. UINT32 wmt_plat_read_cpupcr(VOID);
  236. UINT32 wmt_plat_read_dmaregs(UINT32);
  237. INT32 wmt_plat_set_host_dump_state(ENUM_HOST_DUMP_STATE state);
  238. UINT32 wmt_plat_force_trigger_assert(ENUM_FORCE_TRG_ASSERT_T type);
  239. INT32 wmt_plat_update_host_sync_num(VOID);
  240. INT32 wmt_plat_get_dump_info(UINT32 offset);
  241. UINT32 wmt_plat_get_soc_chipid(VOID);
  242. #if CFG_WMT_LTE_COEX_HANDLING
  243. INT32 wmt_plat_get_tdm_antsel_index(VOID);
  244. #endif
  245. /*******************************************************************************
  246. * F U N C T I O N S
  247. ********************************************************************************
  248. */
  249. #endif /* _WMT_PLAT_H_ */