boards: spresense: Support using GPIO for power control

Introduce CHIP_TYPE_GPIO to allow GPIO to be used for power control.
This commit is contained in:
SPRESENSE 2023-03-01 14:28:13 +09:00 committed by Alin Jerpelea
parent 4a405ca107
commit b60fbefabe
2 changed files with 15 additions and 0 deletions

View File

@ -29,6 +29,7 @@
#include <nuttx/irq.h>
#include <sys/boardctl.h>
#include <stdbool.h>
#include <arch/chip/pin.h>
#include "board_lcdpins.h"
@ -166,11 +167,13 @@
#define PMIC_TYPE_LSW (1u << 8)
#define PMIC_TYPE_GPO (1u << 9)
#define PMIC_TYPE_DDCLDO (1u << 10)
#define CHIP_TYPE_GPIO (1u << 11)
#define PMIC_GET_TYPE(v) ((v) & 0xff00)
#define PMIC_GET_CH(v) ((v) & 0x00ff)
#define PMIC_LSW(n) (PMIC_TYPE_LSW | (1u << (n)))
#define PMIC_GPO(n) (PMIC_TYPE_GPO | (1u << (n)))
#define PMIC_DDCLDO(n) (PMIC_TYPE_DDCLDO | (1u << (n)))
#define CHIP_GPIO(n) (CHIP_TYPE_GPIO | (n))
enum board_power_device
{

View File

@ -200,6 +200,9 @@ int board_power_control(int target, bool en)
pfunc = cxd56_pmic_set_ddc_ldo;
break;
#endif /* CONFIG_CXD56_PMIC */
case CHIP_TYPE_GPIO:
board_gpio_write(PMIC_GET_CH(target), en ? 1 : 0);
break;
default:
break;
}
@ -253,6 +256,10 @@ int board_power_control_tristate(int target, int value)
usleep(1);
}
}
else if (PMIC_GET_TYPE(target) == CHIP_TYPE_GPIO)
{
board_gpio_write(PMIC_GET_CH(target), value);
}
else
{
en = value ? true : false;
@ -274,6 +281,7 @@ bool board_power_monitor(int target)
{
bool ret = false;
bool (*pfunc)(uint8_t chset) = NULL;
int status;
switch (PMIC_GET_TYPE(target))
{
@ -288,6 +296,10 @@ bool board_power_monitor(int target)
pfunc = cxd56_pmic_get_ddc_ldo;
break;
#endif /* CONFIG_CXD56_PMIC */
case CHIP_TYPE_GPIO:
status = board_gpio_read(PMIC_GET_CH(target));
ret = (status == 1);
break;
default:
break;
}