Skip to content

Commit 0a9c0f4

Browse files
sreeramIfxnashif
authored andcommitted
soc: infineon: Support for power management on 20829
- Initial changes in board, dts, and soc files to support system power management Signed-off-by: Sreeram Tatapudi <[email protected]>
1 parent 041f982 commit 0a9c0f4

File tree

9 files changed

+113
-1
lines changed

9 files changed

+113
-1
lines changed

boards/infineon/cyw920829m2evk_02/cyw920829m2evk_02.dts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,10 @@ uart2: &scb2 {
8181
status = "okay";
8282
};
8383

84+
&mcwdt0 {
85+
status = "okay";
86+
};
87+
8488
&bluetooth {
8589
status = "okay";
8690
};

boards/infineon/cyw920829m2evk_02/cyw920829m2evk_02_defconfig

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
#
55

66
# General configuration
7-
CONFIG_CORTEX_M_SYSTICK=y
87
CONFIG_BUILD_OUTPUT_HEX=y
98
CONFIG_BUILD_OUTPUT_BIN=y
109

dts/arm/infineon/cat1b/cyw20829/cyw20829.dtsi

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,21 @@
1616
device_type = "cpu";
1717
compatible = "arm,cortex-m33";
1818
reg = <0>;
19+
cpu-power-states = <&idle &suspend_to_ram>;
20+
};
21+
22+
power-states {
23+
idle: idle {
24+
compatible = "zephyr,power-state";
25+
power-state-name = "suspend-to-idle";
26+
min-residency-us = <1000000>;
27+
};
28+
29+
suspend_to_ram: suspend_to_ram {
30+
compatible = "zephyr,power-state";
31+
power-state-name = "suspend-to-ram";
32+
min-residency-us = <2000000>;
33+
};
1934
};
2035
};
2136

modules/hal_infineon/mtb-pdl-cat1/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ if(CONFIG_SOC_FAMILY_INFINEON_CAT1B)
9090
zephyr_library_sources(${pdl_drv_dir}/source/cy_systick_v2.c)
9191
zephyr_library_sources(${pdl_drv_dir}/source/cy_syspm_v2.c)
9292
zephyr_library_sources(${pdl_drv_dir}/source/cy_syspm_btss.c)
93+
zephyr_library_sources(${pdl_drv_dir}/source/cy_syspm_ppu.c)
94+
zephyr_library_sources(${pdl_drv_dir}/source/ppu_v1.c)
9395
endif()
9496
zephyr_library_sources(${pdl_drv_dir}/source/cy_syslib.c)
9597
zephyr_library_sources(${pdl_drv_dir}/source/cy_syspm.c)

soc/infineon/cat1b/cyw20829/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ zephyr_sources(soc.c)
55
zephyr_sources(app_header.c)
66
zephyr_include_directories(.)
77

8+
zephyr_sources_ifdef(CONFIG_PM power.c)
9+
810
# CAT1B family defines
911
zephyr_compile_definitions_ifdef(CONFIG_SOC_FAMILY_INFINEON_CAT1 CY_USING_HAL)
1012
zephyr_compile_definitions_ifdef(CONFIG_SOC_FAMILY_INFINEON_CAT1B COMPONENT_CAT1B)

soc/infineon/cat1b/cyw20829/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ config SOC_SERIES_CYW20829
1212
select CPU_HAS_FPU
1313
select DYNAMIC_INTERRUPTS
1414
select HAS_SEGGER_RTT if ZEPHYR_SEGGER_MODULE
15+
select HAS_PM

soc/infineon/cat1b/cyw20829/Kconfig.defconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@
66

77
if SOC_DIE_CYW20829
88

9+
config INFINEON_CAT1_LP_TIMER
10+
bool
11+
12+
config CORTEX_M_SYSTICK
13+
default n if INFINEON_CAT1_LP_TIMER
14+
915
config NUM_IRQS
1016
default 70
1117

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2021 Cypress Semiconductor Corporation (an Infineon company) or
3+
* an affiliate of Cypress Semiconductor Corporation
4+
*
5+
* SPDX-License-Identifier: Apache-2.0
6+
*/
7+
8+
#include <zephyr/kernel.h>
9+
#include <zephyr/device.h>
10+
#include <zephyr/pm/pm.h>
11+
#include <zephyr/logging/log.h>
12+
13+
#include <cyhal_syspm.h>
14+
#include <cyhal_lptimer.h>
15+
16+
LOG_MODULE_REGISTER(soc_power, CONFIG_SOC_LOG_LEVEL);
17+
18+
/*
19+
* Called from pm_system_suspend(int32_t ticks) in subsys/power.c
20+
* For deep sleep pm_system_suspend has executed all the driver
21+
* power management call backs.
22+
*/
23+
void pm_state_set(enum pm_state state, uint8_t substate_id)
24+
{
25+
ARG_UNUSED(substate_id);
26+
27+
/* Set BASEPRI to 0 */
28+
irq_unlock(0);
29+
30+
switch (state) {
31+
case PM_STATE_SUSPEND_TO_IDLE:
32+
LOG_DBG("Entering PM state suspend to idle");
33+
cyhal_syspm_sleep();
34+
break;
35+
case PM_STATE_SUSPEND_TO_RAM:
36+
LOG_DBG("Entering PM state suspend to RAM");
37+
cyhal_syspm_deepsleep();
38+
39+
/*
40+
* The HAL function doesn't clear this bit. It is a problem
41+
* if the Zephyr idle function executes the wfi instruction
42+
* with this bit set. We will always clear it here to avoid
43+
* that situation.
44+
*/
45+
SCB_SCR &= (uint32_t)~SCB_SCR_SLEEPDEEP_Msk;
46+
break;
47+
default:
48+
LOG_DBG("Unsupported power state %u", state);
49+
break;
50+
}
51+
}
52+
53+
void pm_state_exit_post_ops(enum pm_state state, uint8_t substate_id)
54+
{
55+
ARG_UNUSED(substate_id);
56+
57+
switch (state) {
58+
case PM_STATE_SUSPEND_TO_IDLE:
59+
case PM_STATE_SUSPEND_TO_RAM:
60+
break;
61+
62+
default:
63+
break;
64+
}
65+
}
66+
67+
int ifx_pm_init(void)
68+
{
69+
/* System Domain Idle Power Mode Configuration */
70+
Cy_SysPm_SetDeepSleepMode(CY_SYSPM_MODE_DEEPSLEEP);
71+
72+
return cyhal_syspm_init();
73+
}

soc/infineon/cat1b/cyw20829/soc.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,13 @@
1111
#include <zephyr/device.h>
1212
#include <zephyr/init.h>
1313
#include <zephyr/kernel.h>
14+
1415
#include <cy_sysint.h>
1516
#include <system_cat1b.h>
1617
#include "cy_pdl.h"
1718

19+
extern int ifx_pm_init(void);
20+
1821
cy_en_sysint_status_t Cy_SysInt_Init(const cy_stc_sysint_t *config, cy_israddress userIsr)
1922
{
2023
CY_ASSERT_L3(CY_SYSINT_IS_PRIORITY_VALID(config->intrPriority));
@@ -94,3 +97,10 @@ static int init_cycfg_platform_wrapper(void)
9497
}
9598

9699
SYS_INIT(init_cycfg_platform_wrapper, PRE_KERNEL_1, 0);
100+
101+
#ifdef CONFIG_PM
102+
void soc_early_init_hook(void)
103+
{
104+
ifx_pm_init();
105+
}
106+
#endif

0 commit comments

Comments
 (0)