mt_spm_cpu.h 13 KB

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