upower_defs.h 27 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. /* SPDX-License-Identifier: BSD-3-Clause */
  2. /**
  3. * Copyright 2019-2024 NXP
  4. *
  5. * KEYWORDS: micro-power uPower driver API
  6. * -----------------------------------------------------------------------------
  7. * PURPOSE: uPower driver API #defines and typedefs shared with the firmware
  8. * -----------------------------------------------------------------------------
  9. * PARAMETERS:
  10. * PARAM NAME RANGE:DESCRIPTION: DEFAULTS: UNITS
  11. * -----------------------------------------------------------------------------
  12. * REUSE ISSUES: no reuse issues
  13. */
  14. #ifndef UPWR_DEFS_H
  15. #define UPWR_DEFS_H
  16. #include <stdint.h>
  17. #ifndef UPWR_PMC_SWT_WORDS
  18. #define UPWR_PMC_SWT_WORDS (1U)
  19. #endif
  20. #ifndef UPWR_PMC_MEM_WORDS
  21. #define UPWR_PMC_MEM_WORDS (2U)
  22. #endif
  23. /* ****************************************************************************
  24. * DOWNSTREAM MESSAGES - COMMANDS/FUNCTIONS
  25. * ****************************************************************************
  26. */
  27. #define UPWR_SRVGROUP_BITS (4U)
  28. #define UPWR_FUNCTION_BITS (4U)
  29. #define UPWR_PWDOMAIN_BITS (4U)
  30. #define UPWR_HEADER_BITS \
  31. (UPWR_SRVGROUP_BITS + UPWR_FUNCTION_BITS + UPWR_PWDOMAIN_BITS)
  32. #define UPWR_ARG_BITS (32U - UPWR_HEADER_BITS)
  33. #if ((UPWR_ARG_BITS & 1U) > 0U)
  34. #error "UPWR_ARG_BITS must be an even number"
  35. #endif
  36. #define UPWR_ARG64_BITS (64U - UPWR_HEADER_BITS)
  37. #define UPWR_HALF_ARG_BITS (UPWR_ARG_BITS >> 1U)
  38. #define UPWR_DUAL_OFFSET_BITS ((UPWR_ARG_BITS + 32U) >> 1U)
  39. /*
  40. * message header: header fields common to all downstream messages.
  41. */
  42. struct upwr_msg_hdr {
  43. uint32_t domain : UPWR_PWDOMAIN_BITS; /* power domain */
  44. uint32_t srvgrp : UPWR_SRVGROUP_BITS; /* service group */
  45. uint32_t function : UPWR_FUNCTION_BITS; /* function */
  46. uint32_t arg : UPWR_ARG_BITS; /* function-specific argument */
  47. };
  48. /* generic 1-word downstream message format */
  49. typedef union {
  50. struct upwr_msg_hdr hdr;
  51. uint32_t word; /* message first word */
  52. } upwr_down_1w_msg;
  53. /* generic 2-word downstream message format */
  54. typedef struct {
  55. struct upwr_msg_hdr hdr;
  56. uint32_t word2; /* message second word */
  57. } upwr_down_2w_msg;
  58. /* message format for functions that receive a pointer/offset */
  59. typedef struct {
  60. struct upwr_msg_hdr hdr;
  61. uint32_t ptr; /* config struct offset */
  62. } upwr_pointer_msg;
  63. /* message format for functions that receive 2 pointers/offsets */
  64. typedef union {
  65. struct upwr_msg_hdr hdr;
  66. struct {
  67. uint64_t rsv : UPWR_HEADER_BITS;
  68. uint64_t ptr0 : UPWR_DUAL_OFFSET_BITS;
  69. uint64_t ptr1 : UPWR_DUAL_OFFSET_BITS;
  70. } ptrs;
  71. } upwr_2pointer_msg;
  72. #define UPWR_SG_EXCEPT (0U) /* 0 = exception */
  73. #define UPWR_SG_PWRMGMT (1U) /* 1 = power management */
  74. #define UPWR_SG_DELAYM (2U) /* 2 = delay measurement */
  75. #define UPWR_SG_VOLTM (3U) /* 3 = voltage measurement */
  76. #define UPWR_SG_CURRM (4U) /* 4 = current measurement */
  77. #define UPWR_SG_TEMPM (5U) /* 5 = temperature measurement */
  78. #define UPWR_SG_DIAG (6U) /* 6 = diagnostic */
  79. #define UPWR_SG_COUNT (7U)
  80. typedef uint32_t upwr_sg_t;
  81. /* *************************************************************************
  82. * Initialization - downstream
  83. ***************************************************************************/
  84. typedef upwr_down_1w_msg upwr_start_msg; /* start command message */
  85. typedef upwr_down_1w_msg upwr_power_on_msg; /* power on command message */
  86. typedef upwr_down_1w_msg upwr_boot_start_msg; /* boot start command message */
  87. typedef union {
  88. struct upwr_msg_hdr hdr;
  89. upwr_power_on_msg power_on;
  90. upwr_boot_start_msg boot_start;
  91. upwr_start_msg start;
  92. } upwr_startup_down_msg;
  93. /* *************************************************************************
  94. * Service Group EXCEPTION - downstream
  95. ***************************************************************************/
  96. #define UPWR_XCP_INIT (0U) /* 0 = init msg (not a service request itself) */
  97. #define UPWR_XCP_PING (0U) /* 0 = also ping request, since its response isan init msg */
  98. #define UPWR_XCP_START (1U) /* 1 = service start: upwr_start *(not a service request itself) */
  99. #define UPWR_XCP_SHUTDOWN (2U) /* 2 = service shutdown: upwr_xcp_shutdown */
  100. #define UPWR_XCP_CONFIG (3U) /* 3 = uPower configuration: upwr_xcp_config */
  101. #define UPWR_XCP_SW_ALARM (4U) /* 4 = uPower software alarm: upwr_xcp_sw_alarm */
  102. #define UPWR_XCP_I2C (5U) /* 5 = I2C access: upwr_xcp_i2c_access */
  103. #define UPWR_XCP_SPARE_6 (6U) /* 6 = spare */
  104. #define UPWR_XCP_SET_DDR_RETN (7U) /* 7 = set/clear ddr retention */
  105. #define UPWR_XCP_SET_RTD_APD_LLWU (8U) /* 8 = set/clear rtd/apd llwu */
  106. #define UPWR_XCP_SPARE_8 (8U) /* 8 = spare */
  107. #define UPWR_XCP_SET_RTD_USE_DDR (9U) /* 9 = M33 core set it is using DDR or not */
  108. #define UPWR_XCP_SPARE_9 (9U) /* 9 = spare */
  109. #define UPWR_XCP_SPARE_10 (10U) /* 10 = spare */
  110. #define UPWR_XCP_SET_MIPI_DSI_ENA (10U) /* 10 = set/clear mipi dsi ena */
  111. #define UPWR_XCP_SPARE_11 (11U) /* 11 = spare */
  112. #define UPWR_XCP_GET_MIPI_DSI_ENA (11U) /* 11 = get mipi dsi ena status */
  113. #define UPWR_XCP_SPARE_12 (12U) /* 12 = spare */
  114. #define UPWR_XCP_SET_OSC_MODE (12U) /* 12 = set uPower OSC mode, high or low */
  115. #define UPWR_XCP_SPARE_13 (13U) /* 13 = spare */
  116. #define UPWR_XCP_SPARE_14 (14U) /* 14 = spare */
  117. #define UPWR_XCP_SPARE_15 (15U) /* 15 = spare */
  118. #define UPWR_XCP_F_COUNT (16U)
  119. typedef uint32_t upwr_xcp_f_t;
  120. typedef upwr_down_1w_msg upwr_xcp_ping_msg;
  121. typedef upwr_down_1w_msg upwr_xcp_shutdown_msg;
  122. typedef upwr_power_on_msg upwr_xcp_power_on_msg;
  123. typedef upwr_boot_start_msg upwr_xcp_boot_start_msg;
  124. typedef upwr_start_msg upwr_xcp_start_msg;
  125. typedef upwr_down_2w_msg upwr_xcp_config_msg;
  126. typedef upwr_down_1w_msg upwr_xcp_swalarm_msg;
  127. typedef upwr_down_1w_msg upwr_xcp_ddr_retn_msg;
  128. typedef upwr_down_1w_msg upwr_xcp_set_mipi_dsi_ena_msg;
  129. typedef upwr_down_1w_msg upwr_xcp_get_mipi_dsi_ena_msg;
  130. typedef upwr_down_1w_msg upwr_xcp_rtd_use_ddr_msg;
  131. typedef upwr_down_1w_msg upwr_xcp_rtd_apd_llwu_msg;
  132. typedef upwr_down_1w_msg upwr_xcp_set_osc_mode_msg;
  133. typedef upwr_pointer_msg upwr_xcp_i2c_msg;
  134. /* structure pointed by message upwr_xcp_i2c_msg */
  135. typedef struct {
  136. uint16_t addr;
  137. int8_t data_size;
  138. uint8_t subaddr_size;
  139. uint32_t subaddr;
  140. uint32_t data;
  141. } upwr_i2c_access;
  142. /* Exception all messages */
  143. typedef union {
  144. struct upwr_msg_hdr hdr; /* message header */
  145. upwr_xcp_ping_msg ping; /* ping */
  146. upwr_xcp_start_msg start; /* service start */
  147. upwr_xcp_shutdown_msg shutdown; /* shutdown */
  148. upwr_xcp_boot_start_msg bootstart; /* boot start */
  149. upwr_xcp_config_msg config; /* uPower configuration */
  150. upwr_xcp_swalarm_msg swalarm; /* software alarm */
  151. upwr_xcp_i2c_msg i2c; /* I2C access */
  152. upwr_xcp_ddr_retn_msg set_ddr_retn; /* set ddr retention msg */
  153. upwr_xcp_set_mipi_dsi_ena_msg set_mipi_dsi_ena; /* set mipi dsi ena msg */
  154. upwr_xcp_get_mipi_dsi_ena_msg get_mipi_dsi_ena; /* get mipi dsi ena msg */
  155. upwr_xcp_rtd_use_ddr_msg set_rtd_use_ddr; /* set rtd is using ddr msg */
  156. upwr_xcp_rtd_apd_llwu_msg set_llwu; /* set rtd/apd llwu msg */
  157. upwr_xcp_set_osc_mode_msg set_osc_mode; /* set osc_mode msg */
  158. } upwr_xcp_msg;
  159. /* structure pointed by message upwr_volt_dva_req_id_msg */
  160. typedef struct {
  161. uint32_t id_word0;
  162. uint32_t id_word1;
  163. uint32_t mode;
  164. } upwr_dva_id_struct;
  165. /**
  166. * PMIC voltage accuracy is 12.5 mV, 12500 uV
  167. */
  168. #define PMIC_VOLTAGE_MIN_STEP 12500U
  169. /* *************************************************************************
  170. * Service Group POWER MANAGEMENT - downstream
  171. ***************************************************************************/
  172. #define UPWR_PWM_REGCFG (0U) /* 0 = regulator config: upwr_pwm_reg_config */
  173. #define UPWR_PWM_DEVMODE (0U) /* deprecated, for old compile */
  174. #define UPWR_PWM_VOLT (1U) /* 1 = voltage change: upwr_pwm_chng_reg_voltage */
  175. #define UPWR_PWM_SWITCH (2U) /* 2 = switch control: upwr_pwm_chng_switch_mem */
  176. #define UPWR_PWM_PWR_ON (3U) /* 3 = switch/RAM/ROM power on: upwr_pwm_power_on */
  177. #define UPWR_PWM_PWR_OFF (4U) /* 4 = switch/RAM/ROM power off: upwr_pwm_power_off */
  178. #define UPWR_PWM_RETAIN (5U) /* 5 = retain memory array: upwr_pwm_mem_retain */
  179. #define UPWR_PWM_DOM_BIAS (6U) /* 6 = Domain bias control: upwr_pwm_chng_dom_bias */
  180. #define UPWR_PWM_MEM_BIAS (7U) /* 7 = Memory bias control: upwr_pwm_chng_mem_bias */
  181. #define UPWR_PWM_PMICCFG (8U) /* 8 = PMIC configuration: upwr_pwm_pmic_config */
  182. #define UPWR_PWM_PMICMOD (8U) /* deprecated, for old compile */
  183. #define UPWR_PWM_PES (9U) /* 9 so far, no use */
  184. #define UPWR_PWM_CONFIG (10U) /* 10= apply power mode defined configuration */
  185. #define UPWR_PWM_CFGPTR (11U) /* 11= configuration pointer */
  186. #define UPWR_PWM_DOM_PWRON (12U) /* 12 = domain power on: upwr_pwm_dom_power_on */
  187. #define UPWR_PWM_BOOT (13U) /* 13 = boot start: upwr_pwm_boot_start */
  188. #define UPWR_PWM_FREQ (14U) /* 14 = domain frequency setup */
  189. #define UPWR_PWM_PARAM (15U) /* 15 = power management parameters */
  190. #define UPWR_PWM_F_COUNT (16U)
  191. typedef uint32_t upwr_pwm_f_t;
  192. #define MAX_PMETER_SSEL 7U
  193. #define UPWR_VTM_CHNG_PMIC_RAIL_VOLT (0U) /* 0 = change pmic rail voltage */
  194. #define UPWR_VTM_GET_PMIC_RAIL_VOLT (1U) /* 1 = get pmic rail voltage */
  195. #define UPWR_VTM_PMIC_CONFIG (2U) /* 2 = configure PMIC IC */
  196. #define UPWR_VTM_DVA_DUMP_INFO (3U) /* 3 = dump dva information */
  197. #define UPWR_VTM_DVA_REQ_ID (4U) /* 4 = dva request ID array */
  198. #define UPWR_VTM_DVA_REQ_DOMAIN (5U) /* 5 = dva request domain */
  199. #define UPWR_VTM_DVA_REQ_SOC (6U) /* 6 = dva request the whole SOC */
  200. #define UPWR_VTM_PMETER_MEAS (7U) /* 7 = pmeter measure */
  201. #define UPWR_VTM_VMETER_MEAS (8U) /* 8 = vmeter measure */
  202. #define UPWR_VTM_PMIC_COLD_RESET (9U) /* 9 = pmic cold reset */
  203. #define UPWR_VTM_SET_DVFS_PMIC_RAIL (10U) /* 10 = set which domain use which pmic rail, for DVFS use */
  204. #define UPWR_VTM_SET_PMIC_MODE (11U) /* 11 = set pmic mode */
  205. #define UPWR_VTM_F_COUNT (16U)
  206. typedef uint32_t upwr_volt_f_t;
  207. #define VMETER_SEL_RTD 0U
  208. #define VMETER_SEL_LDO 1U
  209. #define VMETER_SEL_APD 2U
  210. #define VMETER_SEL_AVD 3U
  211. #define VMETER_SEL_MAX 3U
  212. /**
  213. * The total TSEL count is 256
  214. */
  215. #define MAX_TEMP_TSEL 256U
  216. /**
  217. * Support 3 temperature sensor, sensor 0, 1, 2
  218. */
  219. #define MAX_TEMP_SENSOR 2U
  220. #define UPWR_TEMP_GET_CUR_TEMP (0U) /* 0 = get current temperature */
  221. #define UPWR_TEMP_F_COUNT (1U)
  222. typedef uint32_t upwr_temp_f_t;
  223. #define UPWR_DMETER_GET_DELAY_MARGIN (0U) /* 0 = get delay margin */
  224. #define UPWR_DMETER_SET_DELAY_MARGIN (1U) /* 1 = set delay margin */
  225. #define UPWR_PMON_REQ (2U) /* 2 = process monitor service */
  226. #define UPWR_DMETER_F_COUNT (3U)
  227. typedef uint32_t upwr_dmeter_f_t;
  228. typedef upwr_down_1w_msg upwr_volt_pmeter_meas_msg;
  229. typedef upwr_down_1w_msg upwr_volt_pmic_set_mode_msg;
  230. typedef upwr_down_1w_msg upwr_volt_vmeter_meas_msg;
  231. struct upwr_reg_config_t {
  232. uint32_t reg;
  233. };
  234. /* set of 32 switches */
  235. struct upwr_switch_board_t {
  236. uint32_t on; /* Switch on state,1 bit per instance */
  237. uint32_t mask; /* actuation mask, 1 bit per instance */
  238. };
  239. /* set of 32 RAM/ROM switches */
  240. struct upwr_mem_switches_t {
  241. uint32_t array; /* RAM/ROM array state, 1 bit per instance */
  242. uint32_t perif; /* RAM/ROM peripheral state, 1 bit per instance */
  243. uint32_t mask; /* actuation mask, 1 bit per instance */
  244. };
  245. typedef upwr_down_1w_msg upwr_pwm_dom_pwron_msg; /* domain power on message */
  246. typedef upwr_down_1w_msg upwr_pwm_boot_start_msg; /* boot start message */
  247. /* functions with complex arguments use the pointer message formats: */
  248. typedef upwr_pointer_msg upwr_pwm_retain_msg;
  249. typedef upwr_pointer_msg upwr_pwm_pmode_cfg_msg;
  250. #if (UPWR_ARG_BITS < UPWR_DOMBIAS_ARG_BITS)
  251. #if ((UPWR_ARG_BITS + 32) < UPWR_DOMBIAS_ARG_BITS)
  252. #error "too few message bits for domain bias argument"
  253. #endif
  254. #endif
  255. /* service upwr_pwm_chng_dom_bias message argument fields */
  256. #define UPWR_DOMBIAS_MODE_BITS (2U)
  257. #define UPWR_DOMBIAS_RBB_BITS (8U)
  258. #define UPWR_DOMBIAS_RSV_BITS (14U)
  259. #define UPWR_DOMBIAS_ARG_BITS (UPWR_DOMBIAS_RSV_BITS + \
  260. (2U * UPWR_DOMBIAS_MODE_BITS) + \
  261. (4U * UPWR_DOMBIAS_RBB_BITS) + 2U)
  262. /*
  263. * upwr_pwm_dom_bias_args is an SoC-dependent message,
  264. */
  265. typedef struct {
  266. uint32_t: 12U; /* TODO: find a way to use UPWR_HEADER_BITS */
  267. uint32_t dommode : UPWR_DOMBIAS_MODE_BITS;
  268. uint32_t avdmode : UPWR_DOMBIAS_MODE_BITS;
  269. uint32_t domapply : 1U;
  270. uint32_t avdapply : 1U;
  271. uint32_t rsv : UPWR_DOMBIAS_RSV_BITS;
  272. uint32_t domrbbn : UPWR_DOMBIAS_RBB_BITS; /* RTD/APD back bias N-well */
  273. uint32_t domrbbp : UPWR_DOMBIAS_RBB_BITS; /* RTD/APD back bias P-well */
  274. uint32_t avdrbbn : UPWR_DOMBIAS_RBB_BITS; /* AVD back bias N-well */
  275. uint32_t avdrbbp : UPWR_DOMBIAS_RBB_BITS; /* AVD back bias P-well */
  276. } upwr_pwm_dom_bias_args;
  277. typedef union {
  278. struct upwr_msg_hdr hdr; /* message header */
  279. struct {
  280. upwr_pwm_dom_bias_args B;
  281. } args;
  282. } upwr_pwm_dom_bias_msg;
  283. /* service upwr_pwm_chng_mem_bias message argument fields */
  284. /*
  285. * upwr_pwm_mem_bias_args is an SoC-dependent message,
  286. * defined in upower_soc_defs.h
  287. */
  288. typedef struct {
  289. uint32_t: 12U; /* TODO: find a way to use UPWR_HEADER_BITS */
  290. uint32_t en : 1U;
  291. uint32_t rsv : 19U;
  292. } upwr_pwm_mem_bias_args;
  293. typedef union {
  294. struct upwr_msg_hdr hdr; /* message header */
  295. struct {
  296. upwr_pwm_mem_bias_args B;
  297. } args;
  298. } upwr_pwm_mem_bias_msg;
  299. typedef upwr_pointer_msg upwr_pwm_pes_seq_msg;
  300. /* upwr_pwm_reg_config-specific message format */
  301. typedef upwr_pointer_msg upwr_pwm_regcfg_msg;
  302. /* upwr_volt_pmic_volt-specific message format */
  303. typedef union {
  304. struct upwr_msg_hdr hdr; /* message header */
  305. struct {
  306. uint32_t rsv : UPWR_HEADER_BITS;
  307. uint32_t domain : 8U;
  308. uint32_t rail : 8U;
  309. } args;
  310. } upwr_volt_dom_pmic_rail_msg;
  311. typedef union {
  312. struct upwr_msg_hdr hdr;
  313. struct {
  314. uint32_t rsv : UPWR_HEADER_BITS;
  315. uint32_t rail : 4U; /* pmic rail id */
  316. uint32_t volt : 12U; /* voltage value, accurate to mV, support 0~3.3V */
  317. } args;
  318. } upwr_volt_pmic_set_volt_msg;
  319. typedef union {
  320. struct upwr_msg_hdr hdr;
  321. struct {
  322. uint32_t rsv : UPWR_HEADER_BITS;
  323. uint32_t rail : 16U; /* pmic rail id */
  324. } args;
  325. } upwr_volt_pmic_get_volt_msg;
  326. typedef union {
  327. struct upwr_msg_hdr hdr;
  328. struct {
  329. uint32_t rsv :UPWR_HEADER_BITS;
  330. uint32_t domain : 8U;
  331. uint32_t mode : 8U; /* work mode */
  332. } args;
  333. } upwr_volt_dva_req_domain_msg;
  334. typedef union {
  335. struct upwr_msg_hdr hdr;
  336. struct {
  337. uint32_t rsv : UPWR_HEADER_BITS;
  338. uint32_t mode : 16U; /* work mode */
  339. } args;
  340. } upwr_volt_dva_req_soc_msg;
  341. typedef union {
  342. struct upwr_msg_hdr hdr;
  343. struct {
  344. uint32_t rsv : UPWR_HEADER_BITS;
  345. uint32_t addr_offset : 16U; /* addr_offset to 0x28330000 */
  346. } args;
  347. } upwr_volt_dva_dump_info_msg;
  348. typedef upwr_pointer_msg upwr_volt_pmiccfg_msg;
  349. typedef upwr_pointer_msg upwr_volt_dva_req_id_msg;
  350. typedef upwr_down_1w_msg upwr_volt_pmic_cold_reset_msg;
  351. /* upwr_pwm_volt-specific message format */
  352. typedef union {
  353. struct upwr_msg_hdr hdr;
  354. struct {
  355. uint32_t rsv : UPWR_HEADER_BITS;
  356. uint32_t reg : UPWR_HALF_ARG_BITS; /* regulator id */
  357. uint32_t volt : UPWR_HALF_ARG_BITS; /* voltage value */
  358. } args;
  359. } upwr_pwm_volt_msg;
  360. /* upwr_pwm_freq_setup-specific message format */
  361. /**
  362. * DVA adjust stage
  363. */
  364. #define DVA_ADJUST_STAGE_INVALID 0U
  365. /* first stage, gross adjust, for increase frequency use */
  366. #define DVA_ADJUST_STAGE_ONE 1U
  367. /* second stage, fine adjust for increase frequency use */
  368. #define DVA_ADJUST_STAGE_TWO 2U
  369. /* combine first + second stage, for descrese frequency use */
  370. #define DVA_ADJUST_STAGE_FULL 3U
  371. /**
  372. * This message structure is used for DVFS feature
  373. * 1. Because user may use different PMIC or different board,
  374. * the pmic regulator of RTD/APD may change,
  375. * so, user need to tell uPower the regulator number.
  376. * The number must be matched with PMIC IC and board.
  377. * use 4 bits for pmic regulator, support to 16 regulator.
  378. *
  379. * use 2 bits for DVA stage
  380. *
  381. * use 10 bits for target frequency, accurate to MHz, support to 1024 MHz
  382. */
  383. typedef union {
  384. struct upwr_msg_hdr hdr;
  385. struct {
  386. uint32_t rsv : UPWR_HEADER_BITS;
  387. uint32_t rail : 4; /* pmic regulator */
  388. uint32_t stage : 2; /* DVA stage */
  389. uint32_t target_freq : 10; /* target frequency */
  390. } args;
  391. } upwr_pwm_freq_msg;
  392. typedef upwr_down_2w_msg upwr_pwm_param_msg;
  393. /* upwr_pwm_pmiccfg-specific message format */
  394. typedef upwr_pointer_msg upwr_pwm_pmiccfg_msg;
  395. /* functions that pass a pointer use message format upwr_pointer_msg */
  396. typedef upwr_pointer_msg upwr_pwm_cfgptr_msg;
  397. /* functions that pass 2 pointers use message format upwr_2pointer_msg
  398. */
  399. typedef upwr_2pointer_msg upwr_pwm_switch_msg;
  400. typedef upwr_2pointer_msg upwr_pwm_pwron_msg;
  401. typedef upwr_2pointer_msg upwr_pwm_pwroff_msg;
  402. /* Power Management all messages */
  403. typedef union {
  404. struct upwr_msg_hdr hdr; /* message header */
  405. upwr_pwm_param_msg param; /* power management parameters */
  406. upwr_pwm_dom_bias_msg dom_bias; /* domain bias message */
  407. upwr_pwm_mem_bias_msg mem_bias; /* memory bias message */
  408. upwr_pwm_pes_seq_msg pes; /* PE seq. message */
  409. upwr_pwm_pmode_cfg_msg pmode; /* power mode config message */
  410. upwr_pwm_regcfg_msg regcfg; /* regulator config message */
  411. upwr_pwm_volt_msg volt; /* set voltage message */
  412. upwr_pwm_freq_msg freq; /* set frequency message */
  413. upwr_pwm_switch_msg switches; /* switch control message */
  414. upwr_pwm_pwron_msg pwron; /* switch/RAM/ROM power on message */
  415. upwr_pwm_pwroff_msg pwroff; /* switch/RAM/ROM power off message */
  416. upwr_pwm_retain_msg retain; /* memory retain message */
  417. upwr_pwm_cfgptr_msg cfgptr; /* configuration pointer message*/
  418. upwr_pwm_dom_pwron_msg dompwron; /* domain power on message */
  419. upwr_pwm_boot_start_msg boot; /* boot start message */
  420. } upwr_pwm_msg;
  421. typedef union {
  422. struct upwr_msg_hdr hdr; /* message header */
  423. upwr_volt_pmic_set_volt_msg set_pmic_volt; /* set pmic voltage message */
  424. upwr_volt_pmic_get_volt_msg get_pmic_volt; /* set pmic voltage message */
  425. upwr_volt_pmic_set_mode_msg set_pmic_mode; /* set pmic mode message */
  426. upwr_volt_pmiccfg_msg pmiccfg; /* PMIC configuration message */
  427. upwr_volt_dom_pmic_rail_msg dom_pmic_rail; /* domain bias message */
  428. upwr_volt_dva_dump_info_msg dva_dump_info; /* dump dva info message */
  429. upwr_volt_dva_req_id_msg dva_req_id; /* dump dva request id array message */
  430. upwr_volt_dva_req_domain_msg dva_req_domain; /* dump dva request domain message */
  431. upwr_volt_dva_req_soc_msg dva_req_soc; /* dump dva request whole soc message */
  432. upwr_volt_pmeter_meas_msg pmeter_meas_msg; /* pmeter measure message */
  433. upwr_volt_vmeter_meas_msg vmeter_meas_msg; /* vmeter measure message */
  434. upwr_volt_pmic_cold_reset_msg cold_reset_msg; /* pmic cold reset message */
  435. } upwr_volt_msg;
  436. typedef union {
  437. struct upwr_msg_hdr hdr;
  438. struct {
  439. uint32_t rsv : UPWR_HEADER_BITS;
  440. uint32_t sensor_id : 16U; /* temperature sensor id */
  441. } args;
  442. } upwr_temp_get_cur_temp_msg;
  443. typedef union {
  444. struct upwr_msg_hdr hdr;
  445. struct {
  446. uint32_t rsv : UPWR_HEADER_BITS;
  447. uint32_t index : 8U; /* the delay meter index */
  448. uint32_t path : 8U; /* the critical path number */
  449. } args;
  450. } upwr_dmeter_get_delay_margin_msg;
  451. #define MAX_DELAY_MARGIN 63U
  452. #define MAX_DELAY_CRITICAL_PATH 7U
  453. #define MAX_DELAY_METER_NUM 1U
  454. typedef union {
  455. struct upwr_msg_hdr hdr;
  456. struct {
  457. uint32_t rsv : UPWR_HEADER_BITS;
  458. uint32_t index: 4U; /* the delay meter index */
  459. uint32_t path: 4U; /* the critical path number */
  460. uint32_t dm: 8U; /* the delay margin value of delay meter */
  461. } args;
  462. } upwr_dmeter_set_delay_margin_msg;
  463. #define MAX_PMON_CHAIN_SEL 1U
  464. typedef union {
  465. struct upwr_msg_hdr hdr;
  466. struct {
  467. uint32_t rsv : UPWR_HEADER_BITS;
  468. uint32_t chain_sel : 16U; /* the process monitor delay chain sel */
  469. } args;
  470. } upwr_pmon_msg;
  471. typedef union {
  472. struct upwr_msg_hdr hdr; /* message header */
  473. upwr_temp_get_cur_temp_msg get_temp_msg; /* get current temperature message */
  474. } upwr_temp_msg;
  475. typedef union {
  476. struct upwr_msg_hdr hdr; /* message header */
  477. upwr_dmeter_get_delay_margin_msg get_margin_msg; /* get delay margin message */
  478. upwr_dmeter_set_delay_margin_msg set_margin_msg; /* set delay margin message */
  479. upwr_pmon_msg pmon_msg; /* process monitor message */
  480. } upwr_dmeter_msg;
  481. typedef upwr_down_2w_msg upwr_down_max_msg; /* longest downstream msg */
  482. /*
  483. * upwr_dom_bias_cfg_t and upwr_mem_bias_cfg_t are SoC-dependent structs,
  484. * defined in upower_soc_defs.h
  485. */
  486. /* Power and mem switches */
  487. typedef struct {
  488. volatile struct upwr_switch_board_t swt_board[UPWR_PMC_SWT_WORDS];
  489. volatile struct upwr_mem_switches_t swt_mem[UPWR_PMC_MEM_WORDS];
  490. } swt_config_t;
  491. /* *************************************************************************
  492. * Service Group DIAGNOSE - downstream
  493. ***************************************************************************/
  494. /* Diagnose Functions */
  495. #define UPWR_DGN_MODE (0U) /* 0 = diagnose mode: upwr_dgn_mode */
  496. #define UPWR_DGN_F_COUNT (1U)
  497. #define UPWR_DGN_BUFFER_EN (2U)
  498. typedef uint32_t upwr_dgn_f_t;
  499. #define UPWR_DGN_ALL2ERR (0U) /* record all until an error occurs, freeze recording on error */
  500. #define UPWR_DGN_ALL2HLT (1U) /* record all until an error occurs, halt core on error */
  501. #define UPWR_DGN_ALL (2U) /* trace, warnings, errors, task state recorded */
  502. #define UPWR_DGN_MAX UPWR_DGN_ALL
  503. #define UPWR_DGN_TRACE (3U) /* trace, warnings, errors recorded */
  504. #define UPWR_DGN_SRVREQ (4U) /* service request activity recorded */
  505. #define UPWR_DGN_WARN (5U) /* warnings and errors recorded */
  506. #define UPWR_DGN_ERROR (6U) /* only errors recorded */
  507. #define UPWR_DGN_NONE (7U) /* no diagnostic recorded */
  508. #define UPWR_DGN_COUNT (8U)
  509. typedef uint32_t upwr_dgn_mode_t;
  510. typedef upwr_down_1w_msg upwr_dgn_mode_msg;
  511. typedef union {
  512. struct upwr_msg_hdr hdr;
  513. upwr_dgn_mode_msg mode_msg;
  514. } upwr_dgn_msg;
  515. typedef struct {
  516. struct upwr_msg_hdr hdr;
  517. uint32_t buf_addr;
  518. } upwr_dgn_v2_msg;
  519. /* diagnostics log types in the shared RAM log buffer */
  520. typedef enum {
  521. DGN_LOG_NONE = 0x00000000,
  522. DGN_LOG_INFO = 0x10000000,
  523. DGN_LOG_ERROR = 0x20000000,
  524. DGN_LOG_ASSERT = 0x30000000,
  525. DGN_LOG_EXCEPT = 0x40000000,
  526. DGN_LOG_EVENT = 0x50000000, // old event trace
  527. DGN_LOG_EVENTNEW = 0x60000000, // new event trace
  528. DGN_LOG_SERVICE = 0x70000000,
  529. DGN_LOG_TASKDEF = 0x80000000,
  530. DGN_LOG_TASKEXE = 0x90000000,
  531. DGN_LOG_MUTEX = 0xA0000000,
  532. DGN_LOG_SEMAPH = 0xB0000000,
  533. DGN_LOG_TIMER = 0xC0000000,
  534. DGN_LOG_CALLTRACE = 0xD0000000,
  535. DGN_LOG_DATA = 0xE0000000,
  536. DGN_LOG_PCTRACE = 0xF0000000
  537. } upwr_dgn_log_t;
  538. /* ****************************************************************************
  539. * UPSTREAM MESSAGES - RESPONSES
  540. * ****************************************************************************
  541. */
  542. /* generic ok/ko response message */
  543. #define UPWR_RESP_ERR_BITS (4U)
  544. #define UPWR_RESP_HDR_BITS (UPWR_RESP_ERR_BITS+\
  545. UPWR_SRVGROUP_BITS+UPWR_FUNCTION_BITS)
  546. #define UPWR_RESP_RET_BITS (32U - UPWR_RESP_HDR_BITS)
  547. #define UPWR_RESP_OK (0U) /* no error */
  548. #define UPWR_RESP_SG_BUSY (1U) /* service group is busy */
  549. #define UPWR_RESP_SHUTDOWN (2U) /* services not up or shutting down */
  550. #define UPWR_RESP_BAD_REQ (3U) /* invalid request */
  551. #define UPWR_RESP_BAD_STATE (4U) /* system state doesn't allow perform the request */
  552. #define UPWR_RESP_UNINSTALLD (5U) /* service or function not installed */
  553. #define UPWR_RESP_UNINSTALLED (5U) /* service or function not installed (alias) */
  554. #define UPWR_RESP_RESOURCE (6U) /* resource not available */
  555. #define UPWR_RESP_TIMEOUT (7U) /* service timeout */
  556. #define UPWR_RESP_COUNT (8U)
  557. typedef uint32_t upwr_resp_t;
  558. struct upwr_resp_hdr {
  559. uint32_t errcode : UPWR_RESP_ERR_BITS;
  560. uint32_t srvgrp : UPWR_SRVGROUP_BITS; /* service group */
  561. uint32_t function: UPWR_FUNCTION_BITS;
  562. uint32_t ret : UPWR_RESP_RET_BITS; /* return value, if any */
  563. };
  564. /* generic 1-word upstream message format */
  565. typedef union {
  566. struct upwr_resp_hdr hdr;
  567. uint32_t word;
  568. } upwr_resp_msg;
  569. /* generic 2-word upstream message format */
  570. typedef struct {
  571. struct upwr_resp_hdr hdr;
  572. uint32_t word2; /* message second word */
  573. } upwr_up_2w_msg;
  574. typedef upwr_up_2w_msg upwr_up_max_msg;
  575. /* *************************************************************************
  576. * Exception/Initialization - upstream
  577. ***************************************************************************/
  578. #define UPWR_SOC_BITS (7U)
  579. #define UPWR_VMINOR_BITS (4U)
  580. #define UPWR_VFIXES_BITS (4U)
  581. #define UPWR_VMAJOR_BITS \
  582. (32U - UPWR_HEADER_BITS - UPWR_SOC_BITS - UPWR_VMINOR_BITS - UPWR_VFIXES_BITS)
  583. typedef struct {
  584. uint32_t soc_id;
  585. uint32_t vmajor;
  586. uint32_t vminor;
  587. uint32_t vfixes;
  588. } upwr_code_vers_t;
  589. /* message sent by firmware initialization, received by upwr_init */
  590. typedef union {
  591. struct upwr_resp_hdr hdr;
  592. struct {
  593. uint32_t rsv : UPWR_RESP_HDR_BITS;
  594. uint32_t soc : UPWR_SOC_BITS; /* SoC identification */
  595. uint32_t vmajor : UPWR_VMAJOR_BITS; /* firmware major version */
  596. uint32_t vminor : UPWR_VMINOR_BITS; /* firmware minor version */
  597. uint32_t vfixes : UPWR_VFIXES_BITS; /* firmware fixes version */
  598. } args;
  599. } upwr_init_msg;
  600. /* message sent by firmware when the core platform is powered up */
  601. typedef upwr_resp_msg upwr_power_up_msg;
  602. /* message sent by firmware when the core reset is released for boot */
  603. typedef upwr_resp_msg upwr_boot_up_msg;
  604. /* message sent by firmware when ready for service requests */
  605. #define UPWR_RAM_VMINOR_BITS (7)
  606. #define UPWR_RAM_VFIXES_BITS (6)
  607. #define UPWR_RAM_VMAJOR_BITS (32 - UPWR_HEADER_BITS \
  608. - UPWR_RAM_VFIXES_BITS - UPWR_RAM_VMINOR_BITS)
  609. typedef union {
  610. struct upwr_resp_hdr hdr;
  611. struct {
  612. uint32_t rsv : UPWR_RESP_HDR_BITS;
  613. uint32_t vmajor : UPWR_RAM_VMAJOR_BITS; /* RAM fw major version */
  614. uint32_t vminor : UPWR_RAM_VMINOR_BITS; /* RAM fw minor version */
  615. uint32_t vfixes : UPWR_RAM_VFIXES_BITS; /* RAM fw fixes version */
  616. } args;
  617. } upwr_ready_msg;
  618. /* message sent by firmware when shutdown finishes */
  619. typedef upwr_resp_msg upwr_shutdown_msg;
  620. typedef union {
  621. struct upwr_resp_hdr hdr;
  622. upwr_init_msg init;
  623. upwr_power_up_msg pwrup;
  624. upwr_boot_up_msg booted;
  625. upwr_ready_msg ready;
  626. } upwr_startup_up_msg;
  627. /* message sent by firmware for uPower config setting */
  628. typedef upwr_resp_msg upwr_config_resp_msg;
  629. /* message sent by firmware for uPower alarm */
  630. typedef upwr_resp_msg upwr_alarm_resp_msg;
  631. /* *************************************************************************
  632. * Power Management - upstream
  633. ***************************************************************************/
  634. typedef upwr_resp_msg upwr_param_resp_msg;
  635. enum work_mode {
  636. OVER_DRIVE,
  637. NORMAL_DRIVE,
  638. LOW_DRIVE
  639. };
  640. #define UTIMER3_MAX_COUNT 0xFFFFU
  641. #endif /* UPWR_DEFS_H */