mt_spm.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. #ifndef _MT_SPM_
  2. #define _MT_SPM_
  3. #include <linux/kernel.h>
  4. #include <linux/io.h>
  5. #ifdef CONFIG_OF
  6. extern void __iomem *spm_base;
  7. extern void __iomem *scp_i2c0_base;
  8. extern void __iomem *scp_i2c1_base;
  9. extern void __iomem *scp_i2c2_base;
  10. extern u32 spm_irq_0;
  11. extern u32 spm_irq_1;
  12. extern u32 spm_irq_2;
  13. extern u32 spm_irq_3;
  14. extern u32 spm_irq_4;
  15. extern u32 spm_irq_5;
  16. extern u32 spm_irq_6;
  17. extern u32 spm_irq_7;
  18. #undef SPM_BASE
  19. #define SPM_BASE spm_base
  20. #else
  21. /* #include <mach/mt_reg_base.h> */
  22. #endif
  23. /* #include <mach/mt_irq.h> */
  24. #include <mt-plat/sync_write.h>
  25. #include <mt-plat/mt_io.h>
  26. /**************************************
  27. * Config and Parameter
  28. **************************************/
  29. /* ****: for bring up */
  30. #ifdef CONFIG_OF /* device tree */
  31. #undef SPM_I2C0_BASE
  32. #undef SPM_I2C1_BASE
  33. #undef SPM_I2C2_BASE
  34. #define SPM_I2C0_BASE scp_i2c0_base
  35. #define SPM_I2C1_BASE scp_i2c1_base
  36. #define SPM_I2C2_BASE scp_i2c2_base
  37. #define SPM_IRQ0_ID spm_irq_0
  38. #define SPM_IRQ1_ID spm_irq_1
  39. #define SPM_IRQ2_ID spm_irq_2
  40. #define SPM_IRQ3_ID spm_irq_3
  41. #define SPM_IRQ4_ID spm_irq_4
  42. #define SPM_IRQ5_ID spm_irq_5
  43. #define SPM_IRQ6_ID spm_irq_6
  44. #define SPM_IRQ7_ID spm_irq_7
  45. #else /* no device tree: 6795: 163+32=195, 6735: 165+32=197 */
  46. #define SPM_BASE SLEEP_BASE
  47. /* 6735 no SCP, so no peripheral i2c interface */
  48. #define SPM_I2C0_BASE 0xF0059C00 /* SCP_I2C0_BASE */
  49. #define SPM_I2C1_BASE 0xF0059C00 /* SCP_I2C1_BASE */
  50. #define SPM_I2C2_BASE 0xF0059C00 /* SCP_I2C2_BASE */
  51. #define SPM_IRQ0_ID 195 /* SLEEP_IRQ_BIT0_ID */
  52. #define SPM_IRQ1_ID 196 /* SLEEP_IRQ_BIT1_ID */
  53. #define SPM_IRQ2_ID 197 /* SLEEP_IRQ_BIT2_ID */
  54. #define SPM_IRQ3_ID 198 /* SLEEP_IRQ_BIT3_ID */
  55. #define SPM_IRQ4_ID 199 /* SLEEP_IRQ_BIT4_ID */
  56. #define SPM_IRQ5_ID 200 /* SLEEP_IRQ_BIT5_ID */
  57. #define SPM_IRQ6_ID 201 /* SLEEP_IRQ_BIT6_ID */
  58. #define SPM_IRQ7_ID 202 /* SLEEP_IRQ_BIT7_ID */
  59. #endif
  60. /**************************************
  61. * Define and Declare
  62. **************************************/
  63. #define SPM_POWERON_CONFIG_SET (SPM_BASE + 0x000)
  64. #define SPM_POWER_ON_VAL0 (SPM_BASE + 0x010)
  65. #define SPM_POWER_ON_VAL1 (SPM_BASE + 0x014)
  66. #define SPM_CLK_SETTLE (SPM_BASE + 0x100)
  67. #define SPM_CA7_CPU0_PWR_CON (SPM_BASE + 0x200)
  68. #define SPM_CA7_DBG_PWR_CON (SPM_BASE + 0x204)
  69. #define SPM_CA7_CPUTOP_PWR_CON (SPM_BASE + 0x208)
  70. #define SPM_VDE_PWR_CON (SPM_BASE + 0x210)
  71. #define SPM_MFG_PWR_CON (SPM_BASE + 0x214)
  72. #define SPM_CA7_CPU1_PWR_CON (SPM_BASE + 0x218)
  73. #define SPM_CA7_CPU2_PWR_CON (SPM_BASE + 0x21c)
  74. #define SPM_CA7_CPU3_PWR_CON (SPM_BASE + 0x220)
  75. #define SPM_VEN_PWR_CON (SPM_BASE + 0x230)
  76. #define SPM_IFR_PWR_CON (SPM_BASE + 0x234)
  77. #define SPM_ISP_PWR_CON (SPM_BASE + 0x238)
  78. #define SPM_DIS_PWR_CON (SPM_BASE + 0x23c)
  79. #define SPM_DPY_PWR_CON (SPM_BASE + 0x240)
  80. #define SPM_CA7_CPUTOP_L2_PDN (SPM_BASE + 0x244)
  81. #define SPM_CA7_CPUTOP_L2_SLEEP (SPM_BASE + 0x248)
  82. #define SPM_CA7_CPU0_L1_PDN (SPM_BASE + 0x25c)
  83. #define SPM_CA7_CPU1_L1_PDN (SPM_BASE + 0x264)
  84. #define SPM_CA7_CPU2_L1_PDN (SPM_BASE + 0x26c)
  85. #define SPM_CA7_CPU3_L1_PDN (SPM_BASE + 0x274)
  86. #define SPM_GCPU_SRAM_CON (SPM_BASE + 0x27c)
  87. #define SPM_CONN_PWR_CON (SPM_BASE + 0x280)
  88. #define SPM_MD_PWR_CON (SPM_BASE + 0x284)
  89. #define SPM_MCU_PWR_CON (SPM_BASE + 0x290)
  90. #define SPM_IFR_SRAMROM_CON (SPM_BASE + 0x294)
  91. #define SPM_MJC_PWR_CON (SPM_BASE + 0x298)
  92. #define SPM_AUDIO_PWR_CON (SPM_BASE + 0x29c)
  93. #define SPM_CA15_CPU0_PWR_CON (SPM_BASE + 0x2a0)
  94. #define SPM_CA15_CPU1_PWR_CON (SPM_BASE + 0x2a4)
  95. #define SPM_CA15_CPU2_PWR_CON (SPM_BASE + 0x2a8)
  96. #define SPM_CA15_CPU3_PWR_CON (SPM_BASE + 0x2ac)
  97. #define SPM_CA15_CPUTOP_PWR_CON (SPM_BASE + 0x2b0)
  98. #define SPM_CA15_L1_PWR_CON (SPM_BASE + 0x2b4)
  99. #define SPM_CA15_L2_PWR_CON (SPM_BASE + 0x2b8)
  100. #define SPM_MFG_2D_PWR_CON (SPM_BASE + 0x2c0) /* Need to remove in K2 */
  101. #define SPM_MFG_ASYNC_PWR_CON (SPM_BASE + 0x2c4) /* mt6735 */
  102. #define SPM_MD32_SRAM_CON (SPM_BASE + 0x2c8)
  103. #define SPM_ARMPLL_DIV_PWR_CON (SPM_BASE + 0x2cc)
  104. #define SPM_MD2_PWR_CON (SPM_BASE + 0x2d0)
  105. #define SPM_C2K_PWR_CON (SPM_BASE + 0x2d4) /* mt6735 */
  106. #define SPM_INFRA_MD_PWR_CON (SPM_BASE + 0x2d8) /* mt6735 */
  107. #define SPM_CPU_EXT_ISO (SPM_BASE + 0x2dc) /* mt6735 */
  108. #define SPM_PCM_CON0 (SPM_BASE + 0x310)
  109. #define SPM_PCM_CON1 (SPM_BASE + 0x314)
  110. #define SPM_PCM_IM_PTR (SPM_BASE + 0x318)
  111. #define SPM_PCM_IM_LEN (SPM_BASE + 0x31c)
  112. #define SPM_PCM_REG_DATA_INI (SPM_BASE + 0x320)
  113. #define SPM_PCM_EVENT_VECTOR0 (SPM_BASE + 0x340)
  114. #define SPM_PCM_EVENT_VECTOR1 (SPM_BASE + 0x344)
  115. #define SPM_PCM_EVENT_VECTOR2 (SPM_BASE + 0x348)
  116. #define SPM_PCM_EVENT_VECTOR3 (SPM_BASE + 0x34c)
  117. #define SPM_PCM_MAS_PAUSE_MASK (SPM_BASE + 0x354)
  118. #define SPM_PCM_PWR_IO_EN (SPM_BASE + 0x358)
  119. #define SPM_PCM_TIMER_VAL (SPM_BASE + 0x35c)
  120. #define SPM_PCM_TIMER_OUT (SPM_BASE + 0x360)
  121. #define SPM_PCM_REG0_DATA (SPM_BASE + 0x380)
  122. #define SPM_PCM_REG1_DATA (SPM_BASE + 0x384)
  123. #define SPM_PCM_REG2_DATA (SPM_BASE + 0x388)
  124. #define SPM_PCM_REG3_DATA (SPM_BASE + 0x38c)
  125. #define SPM_PCM_REG4_DATA (SPM_BASE + 0x390)
  126. #define SPM_PCM_REG5_DATA (SPM_BASE + 0x394)
  127. #define SPM_PCM_REG6_DATA (SPM_BASE + 0x398)
  128. #define SPM_PCM_REG7_DATA (SPM_BASE + 0x39c)
  129. #define SPM_PCM_REG8_DATA (SPM_BASE + 0x3a0)
  130. #define SPM_PCM_REG9_DATA (SPM_BASE + 0x3a4)
  131. #define SPM_PCM_REG10_DATA (SPM_BASE + 0x3a8)
  132. #define SPM_PCM_REG11_DATA (SPM_BASE + 0x3ac)
  133. #define SPM_PCM_REG12_DATA (SPM_BASE + 0x3b0)
  134. #define SPM_PCM_REG13_DATA (SPM_BASE + 0x3b4)
  135. #define SPM_PCM_REG14_DATA (SPM_BASE + 0x3b8)
  136. #define SPM_PCM_REG15_DATA (SPM_BASE + 0x3bc)
  137. #define SPM_PCM_EVENT_REG_STA (SPM_BASE + 0x3c0)
  138. #define SPM_PCM_FSM_STA (SPM_BASE + 0x3c4)
  139. #define SPM_PCM_IM_HOST_RW_PTR (SPM_BASE + 0x3c8)
  140. #define SPM_PCM_IM_HOST_RW_DAT (SPM_BASE + 0x3cc)
  141. #define SPM_PCM_EVENT_VECTOR4 (SPM_BASE + 0x3d0)
  142. #define SPM_PCM_EVENT_VECTOR5 (SPM_BASE + 0x3d4)
  143. #define SPM_PCM_EVENT_VECTOR6 (SPM_BASE + 0x3d8)
  144. #define SPM_PCM_EVENT_VECTOR7 (SPM_BASE + 0x3dc)
  145. #define SPM_PCM_SW_INT_SET (SPM_BASE + 0x3e0)
  146. #define SPM_PCM_SW_INT_CLEAR (SPM_BASE + 0x3e4)
  147. #define SPM_PCM_REG12_MASK (SPM_BASE + 0x3e8)
  148. #define SPM_CLK_CON (SPM_BASE + 0x400)
  149. #define SPM_SLEEP_DUAL_VCORE_PWR_CON (SPM_BASE + 0x404)
  150. #define SPM_SLEEP_PTPOD2_CON (SPM_BASE + 0x408)
  151. #define SPM_APMCU_PWRCTL (SPM_BASE + 0x600)
  152. #define SPM_AP_DVFS_CON_SET (SPM_BASE + 0x604)
  153. #define SPM_AP_STANBY_CON (SPM_BASE + 0x608) /* mt6735 */
  154. #define SPM_PWR_STATUS (SPM_BASE + 0x60c)
  155. #define SPM_PWR_STATUS_2ND (SPM_BASE + 0x610)
  156. /* #define SPM_AP_BSI_REQ (SPM_BASE + 0x614) */
  157. #define SPM_SLEEP_MDBSI_CON (SPM_BASE + 0x614) /* mt6735 */
  158. #define SPM_BSI_GEN (SPM_BASE + 0x620) /* mt6735 */
  159. #define SPM_BSI_EN_SR (SPM_BASE + 0x624) /* mt6735 */
  160. #define SPM_BSI_CLK_SR (SPM_BASE + 0x628) /* mt6735 */
  161. #define SPM_BSI_DO_SR (SPM_BASE + 0x62c) /* mt6735 */
  162. #define SPM_BSI_D1_SR (SPM_BASE + 0x630) /* mt6735 */
  163. #define SPM_BSI_D2_SR (SPM_BASE + 0x634) /* mt6735 */
  164. #define SPM_AP_SEMA (SPM_BASE + 0x638) /* mt6735 */
  165. #define SPM_SPM_SEMA (SPM_BASE + 0x63c) /* mt6735 */
  166. #define SPM_SLEEP_TIMER_STA (SPM_BASE + 0x720)
  167. #define SPM_SLEEP_TWAM_CON (SPM_BASE + 0x760)
  168. #define SPM_SLEEP_TWAM_STATUS0 (SPM_BASE + 0x764)
  169. #define SPM_SLEEP_TWAM_STATUS1 (SPM_BASE + 0x768)
  170. #define SPM_SLEEP_TWAM_STATUS2 (SPM_BASE + 0x76c)
  171. #define SPM_SLEEP_TWAM_STATUS3 (SPM_BASE + 0x770)
  172. #define SPM_SLEEP_TWAM_CURR_STATUS0 (SPM_BASE + 0x774)
  173. #define SPM_SLEEP_TWAM_CURR_STATUS1 (SPM_BASE + 0x778)
  174. #define SPM_SLEEP_TWAM_CURR_STATUS2 (SPM_BASE + 0x77C)
  175. #define SPM_SLEEP_TWAM_CURR_STATUS3 (SPM_BASE + 0x780)
  176. #define SPM_SLEEP_TWAM_TIMER_OUT (SPM_BASE + 0x784)
  177. #define SPM_SLEEP_TWAM_WINDOW_LEN (SPM_BASE + 0x788)
  178. #define SPM_SLEEP_IDLE_SEL (SPM_BASE + 0x78C)
  179. #define SPM_SLEEP_WAKEUP_EVENT_MASK (SPM_BASE + 0x810)
  180. #define SPM_SLEEP_CPU_WAKEUP_EVENT (SPM_BASE + 0x814)
  181. #define SPM_SLEEP_MD32_WAKEUP_EVENT_MASK (SPM_BASE + 0x818)
  182. #define SPM_PCM_WDT_TIMER_VAL (SPM_BASE + 0x824)
  183. #define SPM_PCM_WDT_TIMER_OUT (SPM_BASE + 0x828)
  184. #define SPM_PCM_MD32_MAILBOX (SPM_BASE + 0x830)
  185. #define SPM_PCM_MD32_IRQ (SPM_BASE + 0x834)
  186. #define SPM_SLEEP_ISR_MASK (SPM_BASE + 0x900)
  187. #define SPM_SLEEP_ISR_STATUS (SPM_BASE + 0x904)
  188. #define SPM_SLEEP_ISR_RAW_STA (SPM_BASE + 0x910)
  189. #define SPM_SLEEP_MD32_ISR_RAW_STA (SPM_BASE + 0x914)
  190. #define SPM_SLEEP_WAKEUP_MISC (SPM_BASE + 0x918)
  191. #define SPM_SLEEP_BUS_PROTECT_RDY (SPM_BASE + 0x91c)
  192. #define SPM_SLEEP_SUBSYS_IDLE_STA (SPM_BASE + 0x920)
  193. #define SPM_PCM_RESERVE (SPM_BASE + 0xb00)
  194. #define SPM_PCM_RESERVE2 (SPM_BASE + 0xb04)
  195. #define SPM_PCM_FLAGS (SPM_BASE + 0xb08)
  196. #define SPM_PCM_SRC_REQ (SPM_BASE + 0xb0c)
  197. #define SPM_PCM_RESERVE3 (SPM_BASE + 0xb14)
  198. #define SPM_PCM_RESERVE4 (SPM_BASE + 0xb18)
  199. #define SPM_PCM_DEBUG_CON (SPM_BASE + 0xb20)
  200. #define SPM_CA7_CPU0_IRQ_MASK (SPM_BASE + 0xb30)
  201. #define SPM_CA7_CPU1_IRQ_MASK (SPM_BASE + 0xb34)
  202. #define SPM_CA7_CPU2_IRQ_MASK (SPM_BASE + 0xb38)
  203. #define SPM_CA7_CPU3_IRQ_MASK (SPM_BASE + 0xb3c)
  204. #define SPM_CA15_CPU0_IRQ_MASK (SPM_BASE + 0xb40)
  205. #define SPM_CA15_CPU1_IRQ_MASK (SPM_BASE + 0xb44)
  206. #define SPM_CA15_CPU2_IRQ_MASK (SPM_BASE + 0xb48)
  207. #define SPM_CA15_CPU3_IRQ_MASK (SPM_BASE + 0xb4c)
  208. #define SPM_PCM_PASR_DPD_0 (SPM_BASE + 0xb60)
  209. #define SPM_PCM_PASR_DPD_1 (SPM_BASE + 0xb64)
  210. #define SPM_PCM_PASR_DPD_2 (SPM_BASE + 0xb68)
  211. #define SPM_PCM_PASR_DPD_3 (SPM_BASE + 0xb6c)
  212. #define SPM_SLEEP_CA7_WFI0_EN (SPM_BASE + 0xf00)
  213. #define SPM_SLEEP_CA7_WFI1_EN (SPM_BASE + 0xf04)
  214. #define SPM_SLEEP_CA7_WFI2_EN (SPM_BASE + 0xf08)
  215. #define SPM_SLEEP_CA7_WFI3_EN (SPM_BASE + 0xf0c)
  216. #define SPM_SLEEP_CA15_WFI0_EN (SPM_BASE + 0xf10)
  217. #define SPM_SLEEP_CA15_WFI1_EN (SPM_BASE + 0xf14)
  218. #define SPM_SLEEP_CA15_WFI2_EN (SPM_BASE + 0xf18)
  219. #define SPM_SLEEP_CA15_WFI3_EN (SPM_BASE + 0xf1c)
  220. #define SPM_PROJECT_CODE 0xb16
  221. #define SPM_REGWR_EN (1U << 0)
  222. #define SPM_REGWR_CFG_KEY (SPM_PROJECT_CODE << 16)
  223. /* PCM Flags store in PCM_RESERVE4(0xB18)*/
  224. #define SPM_CPU_PDN_DIS (1U << 0)
  225. #define SPM_INFRA_PDN_DIS (1U << 1)
  226. #define SPM_DDRPHY_PDN_DIS (1U << 2)
  227. #define SPM_PASR_DIS (1U << 4)
  228. #define SPM_MD_VRF18_DIS (1U << 5) /* mt6735 */
  229. #define SPM_MEMPLL_CG_EN (1U << 6) /* mt6735 */
  230. /* #define SPM_MEMPLL_RESET (1U << 7)//mt6735 no use */
  231. #define SPM_VCORE_DVFS_EN (1U << 8) /* mt6735 */
  232. #define SPM_CPU_DVS_DIS (1U << 9)
  233. #define SPM_IFRA_MD_PDN_DIS (1U << 10) /* mt6735 */
  234. #define SPM_VCORE_DVS_EVENT_DIS (1U << 11) /* mt6735 */
  235. #define SPM_DDR_HIGH_SPEED (1U << 12) /* mt6735 no use */
  236. #define SPM_DISABLE_ATF_ABORT (1U << 13) /* mt6735 */
  237. #define SPM_DRAM_RANK1_ADDR_SEL0 (1U << 19) /* 0x60000000, 0x70000000 */
  238. #define SPM_DRAM_RANK1_ADDR_SEL1 (1U << 20) /* 0x80000000 */
  239. #define SPM_DRAM_RANK1_ADDR_SEL2 (1U << 21) /* 0xc0000000 */
  240. #define SPM_DRAM_RANK1_ADDR_SEL3 (1U << 24) /* 0xa0000000 */
  241. #define SPM_BUCK_SEL (1U << 26) /* mt6753 use */
  242. /******/
  243. /* Wakeup Source */
  244. enum SPM_WAKE_SRC_LIST {
  245. WAKE_SRC_SPM_MERGE = (1U << 0), /* PCM timer, TWAM or CPU */
  246. WAKE_SRC_LTE_PTP = (1U << 1),
  247. WAKE_SRC_KP = (1U << 2),
  248. WAKE_SRC_WDT = (1U << 3),
  249. WAKE_SRC_GPT = (1U << 4),
  250. WAKE_SRC_EINT = (1U << 5),
  251. WAKE_SRC_CONN_WDT = (1U << 6),
  252. WAKE_SRC_CCIF0_MD = (1U << 7),
  253. WAKE_SRC_CCIF1_MD = (1U << 8),
  254. WAKE_SRC_LOW_BAT = (1U << 9),
  255. WAKE_SRC_CONN2AP = (1U << 10),
  256. WAKE_SRC_F26M_WAKE = (1U << 11),
  257. WAKE_SRC_F26M_SLEEP = (1U << 12),
  258. WAKE_SRC_PCM_WDT = (1U << 13),
  259. WAKE_SRC_USB_CD = (1U << 14),
  260. WAKE_SRC_USB_PDN = (1U << 15),
  261. WAKE_SRC_LTE_WAKE = (1U << 16),
  262. WAKE_SRC_LTE_SLEEP = (1U << 17),
  263. WAKE_SRC_SEJ = (1U << 18),
  264. WAKE_SRC_UART0 = (1U << 19),
  265. WAKE_SRC_AFE = (1U << 20),
  266. WAKE_SRC_THERM = (1U << 21),
  267. WAKE_SRC_CIRQ = (1U << 22),
  268. WAKE_SRC_MD1_VRF18_WAKE = (1U << 23),
  269. WAKE_SRC_SYSPWREQ = (1U << 24),
  270. WAKE_SRC_MD_WDT = (1U << 25),
  271. WAKE_SRC_C2K_WDT = (1U << 26),
  272. WAKE_SRC_CLDMA_MD = (1U << 27),
  273. WAKE_SRC_MD1_VRF18_SLEEP = (1U << 28),
  274. WAKE_SRC_CPU_IRQ = (1U << 29),
  275. WAKE_SRC_APSRC_WAKE = (1U << 30),
  276. WAKE_SRC_APSRC_SLEEP = (1U << 31)
  277. };
  278. typedef enum {
  279. WR_NONE = 0,
  280. WR_UART_BUSY = 1,
  281. WR_PCM_ASSERT = 2,
  282. WR_PCM_TIMER = 3,
  283. WR_WAKE_SRC = 4,
  284. WR_UNKNOWN = 5,
  285. } wake_reason_t;
  286. struct twam_sig {
  287. u32 sig0; /* signal 0: config or status */
  288. u32 sig1; /* signal 1: config or status */
  289. u32 sig2; /* signal 2: config or status */
  290. u32 sig3; /* signal 3: config or status */
  291. };
  292. enum spm_clk_buf_pad_id {
  293. BSI_EN_SR = 0,
  294. BSI_CLK_SR = 1,
  295. BSI_D0_SR = 2,
  296. BSI_D1_SR = 3,
  297. BSI_D2_SR = 4,
  298. };
  299. typedef void (*twam_handler_t) (struct twam_sig *twamsig);
  300. /* for power management init */
  301. extern int spm_module_init(void);
  302. /* for ANC in talking */
  303. extern void spm_mainpll_on_request(const char *drv_name);
  304. extern void spm_mainpll_on_unrequest(const char *drv_name);
  305. /* for TWAM in MET */
  306. extern void spm_twam_register_handler(twam_handler_t handler);
  307. extern void spm_twam_enable_monitor(const struct twam_sig *twamsig,
  308. bool speed_mode, unsigned int window_len);
  309. extern void spm_twam_disable_monitor(void);
  310. /* for Vcore DVFS */
  311. extern void spm_go_to_vcore_dvfs(u32 spm_flags, u32 spm_data);
  312. extern int spm_set_vcore_dvs_voltage(unsigned int opp);
  313. extern char *spm_dump_vcore_dvs_regs(char *p);
  314. /* for AP BSI Generator */
  315. void spm_ap_bsi_gen(unsigned int *clk_buf_cfg);
  316. unsigned int spm_get_cpu_pwr_status(void);
  317. /**************************************
  318. * Macro and Inline
  319. **************************************/
  320. #define spm_read(addr) __raw_readl(IOMEM(addr))
  321. #define spm_write(addr, val) mt_reg_sync_writel(val, addr)
  322. #define is_cpu_pdn(flags) (!((flags) & SPM_CPU_PDN_DIS))
  323. #define is_infra_pdn(flags) (!((flags) & SPM_INFRA_PDN_DIS))
  324. #define is_ddrphy_pdn(flags) (!((flags) & SPM_DDRPHY_PDN_DIS))
  325. #define is_dualvcore_pdn(flags) (!((flags) & SPM_DUALVCORE_PDN_DIS))
  326. #define get_high_cnt(sigsta) ((sigsta) & 0x3ff)
  327. #define get_high_percent(sigsta) ((get_high_cnt(sigsta) * 100 + 511) / 1023)
  328. #define get_percent(sigsta, tick) ((sigsta * 100) / tick)
  329. #endif