From 8403fe650325a66a41e1cd4f9cc4833d4ed2d4df Mon Sep 17 00:00:00 2001 From: SPRESENSE <41312067+SPRESENSE@users.noreply.github.com> Date: Wed, 19 May 2021 17:48:18 +0900 Subject: [PATCH] boards: spresense: Fix PMIC setting during boot-up When RTC clock is still unstable, the continuous PMIC settings may not be reflected. This commit adds a delay time to avoid such problem. --- boards/arm/cxd56xx/spresense/src/cxd56_power.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/boards/arm/cxd56xx/spresense/src/cxd56_power.c b/boards/arm/cxd56xx/spresense/src/cxd56_power.c index 7a02860059..b1370c37e8 100644 --- a/boards/arm/cxd56xx/spresense/src/cxd56_power.c +++ b/boards/arm/cxd56xx/spresense/src/cxd56_power.c @@ -205,6 +205,13 @@ int board_power_control(int target, bool en) if (pfunc) { ret = pfunc(PMIC_GET_CH(target), en); + + /* If RTC clock is unstable, delay 1 tick for PMIC setting. */ + + if (!g_rtc_enabled) + { + usleep(1); + } } return ret; @@ -236,6 +243,13 @@ int board_power_control_tristate(int target, int value) /* set HiZ to PMIC GPO channel */ ret = cxd56_pmic_set_gpo_hiz(PMIC_GET_CH(target)); + + /* If RTC clock is unstable, delay 1 tick for PMIC setting. */ + + if (!g_rtc_enabled) + { + usleep(1); + } } else {