|
18 | 18 |
|
19 | 19 | extern sys_snode_t soc_node; |
20 | 20 |
|
21 | | -static void common_suspend(void) |
| 21 | +static void nrf_power_down_cache(void) |
22 | 22 | { |
23 | | - if (IS_ENABLED(CONFIG_DCACHE)) { |
24 | | - /* Flush, disable and power down DCACHE */ |
25 | | - sys_cache_data_flush_all(); |
26 | | - sys_cache_data_disable(); |
27 | | - nrf_memconf_ramblock_control_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, |
28 | | - RAMBLOCK_CONTROL_BIT_DCACHE, false); |
29 | | - } |
| 23 | + static const uint32_t msk = |
| 24 | + (IS_ENABLED(CONFIG_DCACHE) ? BIT(RAMBLOCK_CONTROL_BIT_DCACHE) : 0) | |
| 25 | + (IS_ENABLED(CONFIG_ICACHE) ? BIT(RAMBLOCK_CONTROL_BIT_ICACHE) : 0); |
30 | 26 |
|
31 | | - if (IS_ENABLED(CONFIG_ICACHE)) { |
32 | | - /* Disable and power down ICACHE */ |
33 | | - sys_cache_instr_disable(); |
34 | | - nrf_memconf_ramblock_control_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, |
35 | | - RAMBLOCK_CONTROL_BIT_ICACHE, false); |
| 27 | + if (msk == 0) { |
| 28 | + return; |
36 | 29 | } |
37 | 30 |
|
38 | | - soc_lrcconf_poweron_release(&soc_node, NRF_LRCCONF_POWER_DOMAIN_0); |
| 31 | + /* Functions are non-empty only if cache is enabled. |
| 32 | + * Data cache disabling include flushing. |
| 33 | + */ |
| 34 | + sys_cache_data_disable(); |
| 35 | + sys_cache_instr_disable(); |
| 36 | + nrf_memconf_ramblock_control_mask_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, msk, false); |
39 | 37 | } |
40 | 38 |
|
41 | | -static void common_resume(void) |
| 39 | +void nrf_power_up_cache(void) |
42 | 40 | { |
43 | | - if (IS_ENABLED(CONFIG_ICACHE)) { |
44 | | - /* Power up and re-enable ICACHE */ |
45 | | - nrf_memconf_ramblock_control_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, |
46 | | - RAMBLOCK_CONTROL_BIT_ICACHE, true); |
47 | | - sys_cache_instr_enable(); |
48 | | - } |
| 41 | + static const uint32_t msk = |
| 42 | + (IS_ENABLED(CONFIG_DCACHE) ? BIT(RAMBLOCK_CONTROL_BIT_DCACHE) : 0) | |
| 43 | + (IS_ENABLED(CONFIG_ICACHE) ? BIT(RAMBLOCK_CONTROL_BIT_ICACHE) : 0); |
49 | 44 |
|
50 | | - if (IS_ENABLED(CONFIG_DCACHE)) { |
51 | | - /* Power up and re-enable DCACHE */ |
52 | | - nrf_memconf_ramblock_control_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, |
53 | | - RAMBLOCK_CONTROL_BIT_DCACHE, true); |
54 | | - sys_cache_data_enable(); |
| 45 | + if (msk == 0) { |
| 46 | + return; |
55 | 47 | } |
56 | 48 |
|
| 49 | + nrf_memconf_ramblock_control_mask_enable_set(NRF_MEMCONF, RAMBLOCK_POWER_ID, msk, true); |
| 50 | + sys_cache_instr_enable(); |
| 51 | + sys_cache_data_enable(); |
| 52 | +} |
| 53 | + |
| 54 | +static void common_suspend(void) |
| 55 | +{ |
| 56 | + soc_lrcconf_poweron_release(&soc_node, NRF_LRCCONF_POWER_DOMAIN_0); |
| 57 | + nrf_power_down_cache(); |
| 58 | +} |
| 59 | + |
| 60 | +static void common_resume(void) |
| 61 | +{ |
| 62 | + /* Common part does not include cache enabling. In case of s2ram it is done |
| 63 | + * as early as possible to speed up the process. |
| 64 | + */ |
57 | 65 | soc_lrcconf_poweron_request(&soc_node, NRF_LRCCONF_POWER_DOMAIN_0); |
58 | 66 | } |
59 | 67 |
|
@@ -112,6 +120,7 @@ static void s2idle_exit(uint8_t substate_id) |
112 | 120 | case 1: /* Substate for idle with cache retained - not implemented yet. */ |
113 | 121 | break; |
114 | 122 | case 2: /* Substate for idle with cache disabled. */ |
| 123 | + nrf_power_up_cache(); |
115 | 124 | common_resume(); |
116 | 125 | #if !defined(CONFIG_SOC_NRF54H20_CPURAD) |
117 | 126 | soc_lrcconf_poweron_release(&soc_node, NRF_LRCCONF_POWER_MAIN); |
|
0 commit comments