Skip to content

Commit 138eef8

Browse files
committed
soc: nxp: imx95: setup m7mix and wakeupmix power on in suspend mode
wakeupmix keep power on state is essential for system suspend mode, because of console uart locate in it. temporarily set the M7 mix to power on, further optimization will be carried out later Signed-off-by: Yongxu Wang <[email protected]>
1 parent 3c10388 commit 138eef8

File tree

2 files changed

+112
-0
lines changed

2 files changed

+112
-0
lines changed

soc/nxp/imx/imx9/imx95/m7/soc.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,10 +88,41 @@ static int soc_init(void)
8888
return ret;
8989
}
9090

91+
void pm_state_before(void)
92+
{
93+
struct scmi_cpu_pd_lpm_config cpu_pd_lpm_cfg;
94+
95+
/*
96+
* 1. Set M7 mix as power on state in suspend mode
97+
* 2. Keep wakeupmix power on whatever low power mode, as lpuart3(console) in there.
98+
* To do: in order to reduce power consumption, the M7 core in the i.MX95
99+
* should be powered down during suspend.
100+
* However, after being woken up by a wakeup source, the M7 CPU will restart
101+
* execution from the vector table address, which is not the desired behavior.
102+
* Instead, the vector value should be set to the address where the CPU
103+
* was before entering suspend, and the CPU state should be restored to
104+
* what it was prior to suspend.
105+
*/
106+
107+
cpu_pd_lpm_cfg.cpu_id = CPU_IDX_M7P;
108+
cpu_pd_lpm_cfg.num_cfg = 2;
109+
cpu_pd_lpm_cfg.cfgs[0].domainId = PWR_MIX_SLICE_IDX_M7;
110+
cpu_pd_lpm_cfg.cfgs[0].lpmSetting = SCMI_CPU_LPM_SETTING_ON_ALWAYS;
111+
cpu_pd_lpm_cfg.cfgs[0].retMask = 1U << PWR_MEM_SLICE_IDX_M7;
112+
cpu_pd_lpm_cfg.cfgs[1].domainId = PWR_MIX_SLICE_IDX_WAKEUP;
113+
cpu_pd_lpm_cfg.cfgs[1].lpmSetting = SCMI_CPU_LPM_SETTING_ON_ALWAYS;
114+
cpu_pd_lpm_cfg.cfgs[1].retMask = 0;
115+
116+
scmi_cpu_pd_lpm_set(&cpu_pd_lpm_cfg);
117+
}
118+
119+
91120
void pm_state_set(enum pm_state state, uint8_t substate_id)
92121
{
93122
struct scmi_cpu_sleep_mode_config cpu_cfg = {0};
94123

124+
pm_state_before();
125+
95126
/* iMX95 M7 core is based on ARMv7-M architecture. For this architecture,
96127
* the current implementation of arch_irq_lock of zephyr is based on BASEPRI,
97128
* which will only retain abnormal interrupts such as NMI,

soc/nxp/imx/imx9/imx95/scmi_cpu_soc.h

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,85 @@
2323
#define CPU_SLEEP_MODE_STOP 2U
2424
#define CPU_SLEEP_MODE_SUSPEND 3U
2525

26+
/*!
27+
* @name SCMI CPU LPM settings
28+
*/
29+
#define SCMI_CPU_LPM_SETTING_ON_NEVER 0U
30+
#define SCMI_CPU_LPM_SETTING_ON_RUN 1U
31+
#define SCMI_CPU_LPM_SETTING_ON_RUN_WAIT 2U
32+
#define SCMI_CPU_LPM_SETTING_ON_RUN_WAIT_STOP 3U
33+
#define SCMI_CPU_LPM_SETTING_ON_ALWAYS 4U
34+
35+
#define CPU_PER_LPI_IDX_GPIO1 0U
36+
#define CPU_PER_LPI_IDX_GPIO2 1U
37+
#define CPU_PER_LPI_IDX_GPIO3 2U
38+
#define CPU_PER_LPI_IDX_GPIO4 3U
39+
#define CPU_PER_LPI_IDX_GPIO5 4U
40+
#define CPU_PER_LPI_IDX_CAN1 5U
41+
#define CPU_PER_LPI_IDX_CAN2 6U
42+
#define CPU_PER_LPI_IDX_CAN3 7U
43+
#define CPU_PER_LPI_IDX_CAN4 8U
44+
#define CPU_PER_LPI_IDX_CAN5 9U
45+
#define CPU_PER_LPI_IDX_LPUART1 10U
46+
#define CPU_PER_LPI_IDX_LPUART2 11U
47+
#define CPU_PER_LPI_IDX_LPUART3 12U
48+
#define CPU_PER_LPI_IDX_LPUART4 13U
49+
#define CPU_PER_LPI_IDX_LPUART5 14U
50+
#define CPU_PER_LPI_IDX_LPUART6 15U
51+
#define CPU_PER_LPI_IDX_LPUART7 16U
52+
#define CPU_PER_LPI_IDX_LPUART8 17U
53+
#define CPU_PER_LPI_IDX_WDOG3 18U
54+
#define CPU_PER_LPI_IDX_WDOG4 19U
55+
#define CPU_PER_LPI_IDX_WDOG5 20U
56+
57+
58+
/* MIX definitions */
59+
#define PWR_NUM_MIX_SLICE 23U
60+
61+
#define PWR_MIX_SLICE_IDX_ANA 0U
62+
#define PWR_MIX_SLICE_IDX_AON 1U
63+
#define PWR_MIX_SLICE_IDX_BBSM 2U
64+
#define PWR_MIX_SLICE_IDX_CAMERA 3U
65+
#define PWR_MIX_SLICE_IDX_CCMSRCGPC 4U
66+
#define PWR_MIX_SLICE_IDX_A55C0 5U
67+
#define PWR_MIX_SLICE_IDX_A55C1 6U
68+
#define PWR_MIX_SLICE_IDX_A55C2 7U
69+
#define PWR_MIX_SLICE_IDX_A55C3 8U
70+
#define PWR_MIX_SLICE_IDX_A55C4 9U
71+
#define PWR_MIX_SLICE_IDX_A55C5 10U
72+
#define PWR_MIX_SLICE_IDX_A55P 11U
73+
#define PWR_MIX_SLICE_IDX_DDR 12U
74+
#define PWR_MIX_SLICE_IDX_DISPLAY 13U
75+
#define PWR_MIX_SLICE_IDX_GPU 14U
76+
#define PWR_MIX_SLICE_IDX_HSIO_TOP 15U
77+
#define PWR_MIX_SLICE_IDX_HSIO_WAON 16U
78+
#define PWR_MIX_SLICE_IDX_M7 17U
79+
#define PWR_MIX_SLICE_IDX_NETC 18U
80+
#define PWR_MIX_SLICE_IDX_NOC 19U
81+
#define PWR_MIX_SLICE_IDX_NPU 20U
82+
#define PWR_MIX_SLICE_IDX_VPU 21U
83+
#define PWR_MIX_SLICE_IDX_WAKEUP 22U
84+
85+
#define PWR_MEM_SLICE_IDX_AON 0U
86+
#define PWR_MEM_SLICE_IDX_CAMERA 1U
87+
#define PWR_MEM_SLICE_IDX_A55C0 2U
88+
#define PWR_MEM_SLICE_IDX_A55C1 3U
89+
#define PWR_MEM_SLICE_IDX_A55C2 4U
90+
#define PWR_MEM_SLICE_IDX_A55C3 5U
91+
#define PWR_MEM_SLICE_IDX_A55C4 6U
92+
#define PWR_MEM_SLICE_IDX_A55C5 7U
93+
#define PWR_MEM_SLICE_IDX_A55P 8U
94+
#define PWR_MEM_SLICE_IDX_A55L3 9U
95+
#define PWR_MEM_SLICE_IDX_DDR 10U
96+
#define PWR_MEM_SLICE_IDX_DISPLAY 11U
97+
#define PWR_MEM_SLICE_IDX_GPU 12U
98+
#define PWR_MEM_SLICE_IDX_HSIO 13U
99+
#define PWR_MEM_SLICE_IDX_M7 14U
100+
#define PWR_MEM_SLICE_IDX_NETC 15U
101+
#define PWR_MEM_SLICE_IDX_NOC1 16U
102+
#define PWR_MEM_SLICE_IDX_NOC2 17U
103+
#define PWR_MEM_SLICE_IDX_NPU 18U
104+
#define PWR_MEM_SLICE_IDX_VPU 19U
105+
#define PWR_MEM_SLICE_IDX_WAKEUP 20U
106+
26107
#endif /* ZEPHYR_NXP_IMX95_SCMI_CPU_SOC_H_ */

0 commit comments

Comments
 (0)