Skip to content

Commit 2f5c2f2

Browse files
committed
soc: ti: cc23x0: Add conditions for RTC as timer in power.c
In power management, add conditions to handle the case where RTC is used as main timer. Signed-off-by: Stoyan Bogdanov <sbogdanov@baylibre.com>
1 parent ed7b870 commit 2f5c2f2

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

soc/ti/simplelink/cc23x0/power.c

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const PowerCC23X0_Config PowerCC23X0_config = {
3636

3737
#ifdef CONFIG_PM
3838

39+
#ifndef CONFIG_CC23X0_RTC_TIMER
40+
3941
#define MAX_SYSTIMER_DELTA 0xFFBFFFFFU
4042
#define RTC_TO_SYSTIM_TICKS 8U
4143
#define SYSTIM_CH_STEP 4U
@@ -44,9 +46,13 @@ const PowerCC23X0_Config PowerCC23X0_config = {
4446
#define SYSTIM_CH_CNT 5U
4547
#define RTC_NEXT(val, now) (((val - PowerCC23X0_WAKEDELAYSTANDBY) >> SYSTIM_TO_RTC_SHIFT) + now)
4648

49+
#endif
50+
4751
static void pm_cc23x0_enter_standby(void);
4852
static int power_initialize(void);
4953
extern int_fast16_t PowerCC23X0_notify(uint_fast16_t eventType);
54+
55+
#ifndef CONFIG_CC23X0_RTC_TIMER
5056
static void pm_cc23x0_systim_standby_restore(void);
5157

5258
/* Global to stash the SysTimer timeouts while we enter standby */
@@ -66,7 +72,9 @@ const uint8_t systim_offset[SYSTIM_CH_CNT] = {
6672
2, /* 250ns -> 1us */
6773
2 /* 250ns -> 1us */
6874
};
75+
#endif
6976

77+
#ifndef CONFIG_CC23X0_RTC_TIMER
7078
static void pm_cc23x0_systim_standby_restore(void)
7179
{
7280
HWREG(RTC_BASE + RTC_O_ARMCLR) = RTC_ARMCLR_CH0_CLR;
@@ -93,9 +101,11 @@ static void pm_cc23x0_systim_standby_restore(void)
93101

94102
HwiP_restore(key);
95103
}
104+
#endif
96105

97106
static void pm_cc23x0_enter_standby(void)
98107
{
108+
#ifndef CONFIG_CC23X0_RTC_TIMER
99109
uint32_t rtc_now = 0;
100110
uint32_t systim_now = 0;
101111
uint32_t systim_next = MAX_SYSTIMER_DELTA;
@@ -142,8 +152,9 @@ static void pm_cc23x0_enter_standby(void)
142152
HwiP_clearInterrupt(INT_CPUIRQ16);
143153
rtc_now = HWREG(RTC_BASE + RTC_O_TIME8U);
144154
HWREG(RTC_BASE + RTC_O_CH0CC8U) = RTC_NEXT(systim_next, rtc_now);
145-
155+
#endif
146156
Power_sleep(PowerLPF3_STANDBY);
157+
#ifndef CONFIG_CC23X0_RTC_TIMER
147158
pm_cc23x0_systim_standby_restore();
148159
} else if (idle) {
149160
__WFI();
@@ -153,6 +164,7 @@ static void pm_cc23x0_enter_standby(void)
153164
}
154165

155166
HwiP_restore(key);
167+
#endif
156168
}
157169

158170
void pm_state_set(enum pm_state state, uint8_t substate_id)

0 commit comments

Comments
 (0)