c2k_hw.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. #ifndef C2K_HW_H
  2. #define C2K_HW_H
  3. #include <linux/interrupt.h>
  4. #include "core.h"
  5. #define GPIO_C2K_UNKNOWN (-1)
  6. #ifndef CONFIG_EVDO_DT_VIA_SUPPORT
  7. #define AP_USING_REGISTER (0xFFFFFF)
  8. #endif
  9. #define GPIO_C2K_VALID(gpio) ((gpio == GPIO_C2K_UNKNOWN) ? 0 : 1)
  10. #ifdef CONFIG_EVDO_DT_VIA_SUPPORT
  11. #define MDM_MMC_ID "mmc2"
  12. #else
  13. #define MDM_MMC_ID "mmc3"
  14. #endif
  15. /******************Gpio Config *************************/
  16. #include <linux/gpio.h>
  17. /*#include <mt-plat/eint.h>*/
  18. #if defined(CONFIG_MTK_LEGACY)
  19. #include <cust_gpio_usage.h>
  20. #endif
  21. #include "modem_sdio.h"
  22. #ifdef CONFIG_EVDO_DT_VIA_SUPPORT
  23. #define GPIO_C2K_MDM_PWR_EN GPIO_VIA_MDM_PWR_EN
  24. #define GPIO_C2K_MDM_PWR_IND GPIO_C2K_UNKNOWN
  25. #define GPIO_C2K_MDM_RST GPIO_VIA_MDM_RST
  26. #define GPIO_C2K_MDM_RST_IND GPIO_VIA_MDM_RST_IND
  27. #define GPIO_C2K_MDM_RST_IND_POLAR 0
  28. #define GPIO_C2K_MDM_BOOT_SEL GPIO_C2K_UNKNOWN
  29. #define GPIO_C2K_MDM_ETS_SEL GPIO_VIA_ETS_SEL
  30. #define GPIO_C2K_SDIO_AP_RDY GPIO_VIA_AP_RDY
  31. #define GPIO_C2K_SDIO_MDM_RDY GPIO_VIA_MDM_RDY
  32. #define GPIO_C2K_SDIO_AP_WAKE_MDM GPIO_VIA_AP_WAKE_MDM
  33. #define GPIO_C2K_SDIO_MDM_WAKE_AP GPIO_VIA_MDM_WAKE_AP
  34. #define GPIO_C2K_SDIO_SYNC_POLAR 0
  35. #ifdef GPIO_VIA_CBP_BCKUP_1
  36. #define GPIO_C2K_CRASH_CBP GPIO_VIA_CBP_BCKUP_1
  37. #else
  38. #define GPIO_C2K_CRASH_CBP GPIO_C2K_UNKNOWN
  39. #endif
  40. #define GPIO_C2K_SDIO_DATA_ACK GPIO_VIA_SDIO_ACK
  41. #define GPIO_C2K_SDIO_DATA_ACK_POLAR 0
  42. #define GPIO_C2K_SDIO_FLOW_CTRL GPIO_VIA_FLOW_CTRL
  43. #define GPIO_C2K_SDIO_FLOW_CTRL_POLAR 1
  44. /*level shift maybe not used*/
  45. #define GPIO_C2K_MC3_EN_N GPIO_C2K_UNKNOWN
  46. #define GPIO_C2K_SD_SEL_N GPIO_C2K_UNKNOWN
  47. #else /*CONFIG_EVDO_DT_VIA_SUPPORT */
  48. /*We actually only use EINT, no real GPIO. So no GPIO dws setting.*/
  49. #define GPIO_C2K_MDM_RST_IND 208 /*EINT NUM, not GPIO num */
  50. #define GPIO_C2K_SDIO_MDM_RDY 211 /*EINT NUM, not GPIO num */
  51. #define GPIO_C2K_SDIO_MDM_WAKE_AP 212 /*EINT NUM, not GPIO num */
  52. #define GPIO_C2K_EXCEPTION 210 /*EINT NUM, not GPIO num */
  53. #define GPIO_C2K_MDM_RST_IND_POLAR 0
  54. #define GPIO_C2K_SDIO_SYNC_POLAR 0
  55. #define GPIO_C2K_MDM_PWR_EN GPIO_C2K_UNKNOWN
  56. #define GPIO_C2K_MDM_PWR_IND GPIO_C2K_UNKNOWN
  57. #define GPIO_C2K_MDM_RST GPIO_C2K_UNKNOWN
  58. #define GPIO_C2K_MDM_BOOT_SEL GPIO_C2K_UNKNOWN
  59. #define GPIO_C2K_MDM_ETS_SEL AP_USING_REGISTER
  60. #define GPIO_C2K_SDIO_AP_RDY AP_USING_REGISTER
  61. #define GPIO_C2K_SDIO_AP_WAKE_MDM AP_USING_REGISTER
  62. #define GPIO_C2K_CRASH_CBP GPIO_C2K_UNKNOWN
  63. #define GPIO_C2K_SDIO_DATA_ACK GPIO_C2K_UNKNOWN
  64. #define GPIO_C2K_SDIO_DATA_ACK_POLAR 0
  65. #define GPIO_C2K_SDIO_FLOW_CTRL GPIO_C2K_UNKNOWN
  66. #define GPIO_C2K_SDIO_FLOW_CTRL_POLAR 1
  67. /*level shift maybe not used*/
  68. #define GPIO_C2K_MC3_EN_N GPIO_C2K_UNKNOWN
  69. #define GPIO_C2K_SD_SEL_N GPIO_C2K_UNKNOWN
  70. #endif
  71. /******************Gpio Function ***********************/
  72. /*config the gpio to be input for irq if the SOC need*/
  73. int c2k_gpio_direction_input_for_irq(int gpio);
  74. int c2k_gpio_direction_output(int gpio, int value);
  75. int c2k_gpio_get_value(int gpio);
  76. int c2k_gpio_to_irq(int gpio);
  77. int c2k_irq_to_gpio(int irq);
  78. int c2k_gpio_set_irq_type(int gpio, unsigned int type);
  79. int c2k_gpio_request_irq(int gpio, irq_handler_t handler, unsigned long flags,
  80. const char *name, void *dev);
  81. void c2k_gpio_irq_mask(int gpio);
  82. void c2k_gpio_irq_unmask(int gpio);
  83. #ifndef CONFIG_EVDO_DT_VIA_SUPPORT
  84. int c2k_gpio_to_ls(int gpio);
  85. int c2k_ap_wake_cp(int value);
  86. int c2k_ap_ready_indicate(int value);
  87. #endif
  88. /*********************Sync Control ************************/
  89. /*notifer events */
  90. #define ASC_NTF_TX_READY 0x0001 /*notifie CBP is ready to work */
  91. #define ASC_NTF_TX_UNREADY 0x0002 /*notifie CBP is not ready to work */
  92. #define ASC_NTF_RX_PREPARE 0x1001 /*notifier the device active to receive data from CBP */
  93. #define ASC_NTF_RX_POST 0x1002 /*notifer the device CBP stop tx data */
  94. #define ASC_NAME_LEN (64)
  95. /*used to register handle*/
  96. struct asc_config {
  97. int gpio_ready;
  98. int gpio_wake;
  99. /*the level which indicate ap is ready */
  100. int polar;
  101. char name[ASC_NAME_LEN];
  102. };
  103. /*Used to registe user according to handle*/
  104. struct asc_infor {
  105. void *data;
  106. int (*notifier)(int, void *);
  107. char name[ASC_NAME_LEN];
  108. };
  109. #define CBP_TX_HD_NAME "TxHdCbp"
  110. #define CBP_TX_USER_NAME "cbp"
  111. #define USB_RX_HD_NAME "RxHdUsb"
  112. #define USB_RX_USER_NAME "usb"
  113. #define UART_RX_HD_NAME "RxHdUart"
  114. #define UART_RX_USER_NAME "uart"
  115. #define SDIO_RX_HD_NAME "RxHdSdio"
  116. #define SDIO_RX_USER_NAME "sdio"
  117. #define RAWBULK_RX_USER_NAME "rawbulk"
  118. #define ASC_PATH(hd, user) hd"."user
  119. int asc_tx_register_handle(struct asc_config *cfg);
  120. int asc_tx_add_user(const char *name, struct asc_infor *infor);
  121. void asc_tx_del_user(const char *path);
  122. int asc_tx_get_ready(const char *path, int sync);
  123. int asc_tx_put_ready(const char *path, int sync);
  124. int asc_tx_auto_ready(const char *name, int sync);
  125. int asc_tx_ready_count(const char *name, int inc);
  126. int asc_tx_check_ready(const char *name);
  127. int asc_tx_set_auto_delay(const char *name, int delay);
  128. int asc_tx_user_count(const char *path);
  129. void asc_tx_reset(const char *name);
  130. int asc_rx_register_handle(struct asc_config *cfg);
  131. int asc_rx_add_user(const char *name, struct asc_infor *infor);
  132. void asc_rx_del_user(const char *path);
  133. int asc_rx_confirm_ready(const char *name, int ready);
  134. void asc_rx_reset(const char *name);
  135. int asc_rx_check_on_start(const char *name);
  136. /*******************************Power Control *********************************/
  137. /*modem event notification values */
  138. enum clock_event_nofitiers {
  139. MDM_EVT_NOTIFY_POWER_ON = 0,
  140. MDM_EVT_NOTIFY_POWER_OFF,
  141. MDM_EVT_NOTIFY_RESET_ON,
  142. MDM_EVT_NOTIFY_RESET_OFF,
  143. MDM_EVT_NOTIFY_HD_ERR,
  144. MDM_EVT_NOTIFY_HD_ENHANCE,
  145. MDM_EVT_NOTIFY_IPOH,
  146. MDM_EVT_NOTIFY_WDT,
  147. MDM_EVT_NOTIFY_EXCP,
  148. MDM_EVT_NOTIFY_NUM
  149. };
  150. void modem_notify_event(int event);
  151. int modem_register_notifier(struct notifier_block *nb);
  152. int modem_unregister_notifier(struct notifier_block *nb);
  153. void c2k_reset_tx_gpio_ready(int gpio);
  154. extern unsigned int mt_gpio_to_irq(unsigned int gpio);
  155. #endif