I was able to get my LDO3 set-mode commands to run upon entering/exiting sleep, but POWER_ENABLE_MOCI is staying at 3.3V, and I’m not seeing a reduction in power. I modified the board_trans_resource_power function in my SCUFW board.c file (see below).
/*--------------------------------------------------------------------------*/
/* Transition external board-level supply for board component */
/*--------------------------------------------------------------------------*/
void board_trans_resource_power(sc_rm_idx_t idx, sc_rm_idx_t rsrc_idx,
sc_pm_power_mode_t from_mode, sc_pm_power_mode_t to_mode)
{
static uint32_t ldo3_mode = 0U;
board_print(1, "board_trans_resource_power(%d, %s, %u, %u)\n", idx,
rnames[rsrc_idx], from_mode, to_mode);
/* Init PMIC */
pmic_init();
/* Process resource */
if (pmic_ver.device_id != 0U)
{
sc_err_t err = SC_ERR_NONE;
switch (idx)
{
case BRD_R_BOARD_R0 : /* Apalis ethernet PHY power rail */
if (to_mode > SC_PM_PW_MODE_OFF)
{
/* KSZ 9031 power-up sequence */
BRD_ERR(PMIC_SET_VOLTAGE(PMIC_0_ADDR, PF8100_LDO4,
3300, REG_RUN_MODE));
BRD_ERR(PMIC_SET_MODE(PMIC_0_ADDR, PF8100_LDO4,
RUN_EN_STBY_EN));
BRD_ERR(PMIC_SET_VOLTAGE(PMIC_1_ADDR, PF8100_SW7,
1200, REG_RUN_MODE));
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_SW7,
RUN_EN_STBY_EN));
}
else
{
/* KSZ 9031 power-down sequence */
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_SW7,
RUN_OFF_STBY_OFF));
BRD_ERR(PMIC_SET_MODE(PMIC_0_ADDR, PF8100_LDO4,
RUN_OFF_STBY_OFF));
}
break;
case BRD_R_BOARD_R1 : /* Apalis external RGMII interface in 3.3V */
if (to_mode > SC_PM_PW_MODE_OFF)
{
/*
* We set 5V here so the LDO1 runs in load switch (LS) mode
* so the output voltage follows exactly the input voltage
* that is the module supply voltage, 3.3V.
* This is needed because this LDO is fused to run in normal
* mode and not like PMIC_0_ADDR, PF8100_LDO4 in LS mode
*/
BRD_ERR(PMIC_SET_VOLTAGE(PMIC_1_ADDR, PF8100_LDO1,
5000, REG_RUN_MODE));
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO1,
RUN_EN_STBY_EN));
/* Turn on the peripheral power-rails (controlled by PMIC LDO3) */
always_print("NEW: turn on PF8100_LDO3\n");
if (PMIC_GET_MODE(PMIC_1_ADDR, PF8100_LDO3, &ldo3_mode) == SC_ERR_NONE) {
always_print("ldo3_mode: 0x%x\n", ldo3_mode);
}
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO3, RUN_EN_STBY_EN));
if (PMIC_GET_MODE(PMIC_1_ADDR, PF8100_LDO3, &ldo3_mode) == SC_ERR_NONE) {
always_print("ldo3_mode: 0x%x\n", ldo3_mode);
}
}
else
{
/* Turn off the peripheral power-rails when entering sleep (controlled by PMIC LDO3) */
if (to_mode == SC_PM_PW_MODE_OFF) {
always_print("NEW: turn off PF8100_LDO3\n");
if (PMIC_GET_MODE(PMIC_1_ADDR, PF8100_LDO3, &ldo3_mode) == SC_ERR_NONE) {
always_print("ldo3_mode: 0x%x\n", ldo3_mode);
}
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO3, RUN_OFF_STBY_OFF));
if (PMIC_GET_MODE(PMIC_1_ADDR, PF8100_LDO3, &ldo3_mode) == SC_ERR_NONE) {
always_print("ldo3_mode: 0x%x\n", ldo3_mode);
}
}
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO1,
RUN_OFF_STBY_OFF));
}
break;
case BRD_R_BOARD_R2 : /* Apalis external RGMII interface in 1.8V */
if (to_mode > SC_PM_PW_MODE_OFF)
{
BRD_ERR(PMIC_SET_VOLTAGE(PMIC_1_ADDR, PF8100_LDO1,
1800, REG_RUN_MODE));
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO1,
RUN_EN_STBY_EN));
}
else
{
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO1,
RUN_OFF_STBY_OFF));
}
break;
case BRD_R_BOARD_R3 : /* Apalis external RGMII interface in 2.5V */
if (to_mode > SC_PM_PW_MODE_OFF)
{
BRD_ERR(PMIC_SET_VOLTAGE(PMIC_1_ADDR, PF8100_LDO1,
2500, REG_RUN_MODE));
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO1,
RUN_EN_STBY_EN));
}
else
{
BRD_ERR(PMIC_SET_MODE(PMIC_1_ADDR, PF8100_LDO1,
RUN_OFF_STBY_OFF));
}
break;
default :
; /* Intentional empty default */
break;
}
}
}
The PMIC_SET_MODE operation on LDO3 appears to work, as when I read it back the value has changed. Here is the output log from the SCU-FW debug uart going into and out-of sleep:
board_trans_resource_power(4, BOARD_R1, 3, 0)
NEW: turn off PF8100_LDO3
ldo3_mode: 0x3
ldo3_mode: 0x0
ipc_err: bad service (1)
ipc_err: bad service (1)
ipc_err: bad service (1)
board_trans_resource_power(4, BOARD_R1, 0, 3)
NEW: turn on PF8100_LDO3
ldo3_mode: 0x0
ldo3_mode: 0x3