drivers: regulator: npm1300: Added ship mode

npm1300 ship mode entry added

Signed-off-by: Andy Sinclair <andy.sinclair@nordicsemi.no>
This commit is contained in:
Andy Sinclair 2023-07-14 13:47:22 +01:00 committed by Fabio Baltieri
commit 024196be9d

View file

@ -33,6 +33,7 @@ enum npm1300_gpio_type {
/* nPM1300 regulator base addresses */ /* nPM1300 regulator base addresses */
#define BUCK_BASE 0x04U #define BUCK_BASE 0x04U
#define LDSW_BASE 0x08U #define LDSW_BASE 0x08U
#define SHIP_BASE 0x0BU
/* nPM1300 regulator register offsets */ /* nPM1300 regulator register offsets */
#define BUCK_OFFSET_EN_SET 0x00U #define BUCK_OFFSET_EN_SET 0x00U
@ -57,7 +58,11 @@ enum npm1300_gpio_type {
#define LDSW_OFFSET_LDOSEL 0x08U #define LDSW_OFFSET_LDOSEL 0x08U
#define LDSW_OFFSET_VOUTSEL 0x0CU #define LDSW_OFFSET_VOUTSEL 0x0CU
/* nPM1300 ship register offsets */
#define SHIP_OFFSET_SHIP 0x02U
struct regulator_npm1300_pconfig { struct regulator_npm1300_pconfig {
const struct device *mfd;
struct gpio_dt_spec dvs_state_pins[5]; struct gpio_dt_spec dvs_state_pins[5];
}; };
@ -440,8 +445,16 @@ int regulator_npm1300_dvs_state_set(const struct device *dev, regulator_dvs_stat
return 0; return 0;
} }
int regulator_npm1300_ship_mode(const struct device *dev)
{
const struct regulator_npm1300_pconfig *pconfig = dev->config;
return mfd_npm1300_reg_write(pconfig->mfd, SHIP_BASE, SHIP_OFFSET_SHIP, 1U);
}
static const struct regulator_parent_driver_api parent_api = { static const struct regulator_parent_driver_api parent_api = {
.dvs_state_set = regulator_npm1300_dvs_state_set, .dvs_state_set = regulator_npm1300_dvs_state_set,
.ship_mode = regulator_npm1300_ship_mode,
}; };
int regulator_npm1300_common_init(const struct device *dev) int regulator_npm1300_common_init(const struct device *dev)
@ -540,6 +553,7 @@ static const struct regulator_driver_api api = {.enable = regulator_npm1300_enab
#define REGULATOR_NPM1300_DEFINE_ALL(inst) \ #define REGULATOR_NPM1300_DEFINE_ALL(inst) \
static const struct regulator_npm1300_pconfig config_##inst = { \ static const struct regulator_npm1300_pconfig config_##inst = { \
.mfd = DEVICE_DT_GET(DT_INST_PARENT(inst)), \
.dvs_state_pins = {GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 0, {0}), \ .dvs_state_pins = {GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 0, {0}), \
GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 1, {0}), \ GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 1, {0}), \
GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 2, {0}), \ GPIO_DT_SPEC_INST_GET_BY_IDX_OR(inst, dvs_gpios, 2, {0}), \