Lines Matching +full:wakeup +full:- +full:source +full:- +full:id

3  * SPDX-License-Identifier: Apache-2.0
14 #include <zephyr/dt-bindings/regulator/npm2100.h>
110 uint8_t source; member
142 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_count_voltages()
144 switch (config->source) { in regulator_npm2100_count_voltages()
157 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_list_voltage()
159 switch (config->source) { in regulator_npm2100_list_voltage()
165 return -EINVAL; in regulator_npm2100_list_voltage()
171 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_set_voltage()
175 switch (config->source) { in regulator_npm2100_set_voltage()
178 if (ret == -EINVAL) { in regulator_npm2100_set_voltage()
182 ret = i2c_reg_write_byte_dt(&config->i2c, BOOST_VOUT, idx); in regulator_npm2100_set_voltage()
188 return i2c_reg_write_byte_dt(&config->i2c, BOOST_VOUTSEL, 1U); in regulator_npm2100_set_voltage()
192 if (ret == -EINVAL) { in regulator_npm2100_set_voltage()
196 return i2c_reg_write_byte_dt(&config->i2c, LDOSW_VOUT, idx); in regulator_npm2100_set_voltage()
199 return -ENODEV; in regulator_npm2100_set_voltage()
205 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_get_voltage()
209 switch (config->source) { in regulator_npm2100_get_voltage()
211 ret = i2c_reg_read_byte_dt(&config->i2c, BOOST_VOUTSEL, &idx); in regulator_npm2100_get_voltage()
218 ret = i2c_reg_read_byte_dt(&config->i2c, BOOST_VOUT, &idx); in regulator_npm2100_get_voltage()
227 ret = i2c_reg_read_byte_dt(&config->i2c, BOOST_STATUS1, &idx); in regulator_npm2100_get_voltage()
234 ret = i2c_reg_read_byte_dt(&config->i2c, BOOST_VSET0, &idx); in regulator_npm2100_get_voltage()
243 ret = i2c_reg_read_byte_dt(&config->i2c, BOOST_VSET1, &idx); in regulator_npm2100_get_voltage()
252 ret = i2c_reg_read_byte_dt(&config->i2c, LDOSW_VOUT, &idx); in regulator_npm2100_get_voltage()
260 return -ENODEV; in regulator_npm2100_get_voltage()
266 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_count_currents()
267 const struct regulator_npm2100_data *data = dev->data; in regulator_npm2100_count_currents()
269 switch (config->source) { in regulator_npm2100_count_currents()
273 if (data->ldsw_mode) { in regulator_npm2100_count_currents()
286 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_list_currents()
287 const struct regulator_npm2100_data *data = dev->data; in regulator_npm2100_list_currents()
289 switch (config->source) { in regulator_npm2100_list_currents()
293 if (data->ldsw_mode) { in regulator_npm2100_list_currents()
300 return -EINVAL; in regulator_npm2100_list_currents()
306 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_set_current()
307 const struct regulator_npm2100_data *data = dev->data; in regulator_npm2100_set_current()
312 switch (config->source) { in regulator_npm2100_set_current()
315 if (ret == -EINVAL) { in regulator_npm2100_set_current()
320 return i2c_reg_write_byte_dt(&config->i2c, BOOST_CTRLSET, BIT(3)); in regulator_npm2100_set_current()
322 return i2c_reg_write_byte_dt(&config->i2c, BOOST_CTRLCLR, BIT(3)); in regulator_npm2100_set_current()
325 if (data->ldsw_mode) { in regulator_npm2100_set_current()
336 if (ret == -EINVAL) { in regulator_npm2100_set_current()
340 return i2c_reg_update_byte_dt(&config->i2c, LDOSW_PRGOCP, BIT_MASK(3) << shift, in regulator_npm2100_set_current()
344 return -ENODEV; in regulator_npm2100_set_current()
350 const struct regulator_npm2100_config *config = dev->config; in set_boost_mode()
371 return -ENOTSUP; in set_boost_mode()
384 int ret = i2c_reg_update_byte_dt(&config->i2c, BOOST_OPER, in set_boost_mode()
407 return -ENOTSUP; in set_boost_mode()
411 if (config->mode_gpios.port == NULL) { in set_boost_mode()
412 return -EINVAL; in set_boost_mode()
415 return i2c_reg_write_byte_dt(&config->i2c, BOOST_PIN, reg); in set_boost_mode()
420 const struct regulator_npm2100_config *config = dev->config; in get_boost_mode()
424 ret = i2c_reg_read_byte_dt(&config->i2c, BOOST_STATUS0, &reg); in get_boost_mode()
449 return -ENOTSUP; in get_boost_mode()
457 const struct regulator_npm2100_config *config = dev->config; in get_ldosw_mode()
461 ret = i2c_reg_read_byte_dt(&config->i2c, LDOSW_STATUS, &reg); in get_ldosw_mode()
482 const struct regulator_npm2100_config *config = dev->config; in set_ldosw_gpio_mode()
485 ret = i2c_reg_update_byte_dt(&config->i2c, LDOSW_GPIO, LDOSW_GPIO_PINACT_MASK, inact | act); in set_ldosw_gpio_mode()
491 return i2c_reg_write_byte_dt(&config->i2c, LDOSW_SEL, LDOSW_SEL_OPER_PIN | ldsw); in set_ldosw_gpio_mode()
496 const struct regulator_npm2100_config *config = dev->config; in set_ldosw_mode()
497 struct regulator_npm2100_data *data = dev->data; in set_ldosw_mode()
503 data->ldsw_mode = ldsw != 0; in set_ldosw_mode()
509 return i2c_reg_write_byte_dt(&config->i2c, LDOSW_SEL, in set_ldosw_mode()
512 return i2c_reg_write_byte_dt(&config->i2c, LDOSW_SEL, in set_ldosw_mode()
515 return i2c_reg_write_byte_dt(&config->i2c, LDOSW_SEL, in set_ldosw_mode()
518 return -ENOTSUP; in set_ldosw_mode()
523 if (config->mode_gpios.port == NULL) { in set_ldosw_mode()
524 return -EINVAL; in set_ldosw_mode()
538 return -ENOTSUP; in set_ldosw_mode()
544 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_set_mode()
546 switch (config->source) { in regulator_npm2100_set_mode()
552 return -ENOTSUP; in regulator_npm2100_set_mode()
558 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_get_mode()
560 switch (config->source) { in regulator_npm2100_get_mode()
566 return -ENOTSUP; in regulator_npm2100_get_mode()
572 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_enable()
574 if (config->source != NPM2100_SOURCE_LDOSW) { in regulator_npm2100_enable()
578 return i2c_reg_write_byte_dt(&config->i2c, LDOSW_ENABLE, 1U); in regulator_npm2100_enable()
583 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_disable()
585 if (config->source != NPM2100_SOURCE_LDOSW) { in regulator_npm2100_disable()
589 return i2c_reg_write_byte_dt(&config->i2c, LDOSW_ENABLE, 0U); in regulator_npm2100_disable()
594 const struct regulator_npm2100_config *config = dev->config; in init_pin_ctrl()
596 if (spec->port == NULL) { in init_pin_ctrl()
606 uint8_t pin = spec->pin << 1U; in init_pin_ctrl()
607 uint8_t offset = ((spec->dt_flags & GPIO_ACTIVE_LOW) != 0U) ? 0U : 1U; in init_pin_ctrl()
609 switch (config->source) { in init_pin_ctrl()
611 return i2c_reg_write_byte_dt(&config->i2c, BOOST_GPIO, pin + offset + 1U); in init_pin_ctrl()
613 return i2c_reg_update_byte_dt(&config->i2c, LDOSW_GPIO, LDOSW_GPIO_PIN_MASK, in init_pin_ctrl()
616 return -ENODEV; in init_pin_ctrl()
622 const struct regulator_npm2100_pconfig *pconfig = dev->config; in regulator_npm2100_dvs_state_set()
627 spec = &pconfig->dvs_state_pins[idx]; in regulator_npm2100_dvs_state_set()
629 if (spec->port != NULL) { in regulator_npm2100_dvs_state_set()
643 const struct regulator_npm2100_pconfig *pconfig = dev->config; in regulator_npm2100_ship_mode()
645 /* Ensure shiphold button is enabled so that wakeup will work */ in regulator_npm2100_ship_mode()
646 int ret = i2c_reg_write_byte_dt(&pconfig->i2c, RESET_WRITESTICKY, 0); in regulator_npm2100_ship_mode()
652 ret = i2c_reg_write_byte_dt(&pconfig->i2c, RESET_STROBESTICKY, 1U); in regulator_npm2100_ship_mode()
657 return i2c_reg_write_byte_dt(&pconfig->i2c, SHIP_TASK_SHIP, 1U); in regulator_npm2100_ship_mode()
668 const struct regulator_npm2100_pconfig *pconfig = dev->config; in regulator_npm2100_common_init()
673 spec = &pconfig->dvs_state_pins[idx]; in regulator_npm2100_common_init()
675 if (spec->port != NULL) { in regulator_npm2100_common_init()
677 return -ENODEV; in regulator_npm2100_common_init()
692 const struct regulator_npm2100_config *config = dev->config; in regulator_npm2100_init()
695 if (!i2c_is_ready_dt(&config->i2c)) { in regulator_npm2100_init()
696 return -ENODEV; in regulator_npm2100_init()
700 ret = init_pin_ctrl(dev, &config->mode_gpios); in regulator_npm2100_init()
706 if (config->source == NPM2100_SOURCE_BOOST) { in regulator_npm2100_init()
708 &config->i2c, BOOST_OPER, in regulator_npm2100_init()
709 FIELD_PREP(BOOST_OPER_DPSTIMER_MASK, config->dps_timer)); in regulator_npm2100_init()
714 ret = i2c_reg_write_byte_dt(&config->i2c, BOOST_LIMIT, config->dps_pulse_limit); in regulator_npm2100_init()
723 if (config->ldosw_wd_reset) { in regulator_npm2100_init()
724 ret = i2c_reg_write_byte_dt(&config->i2c, RESET_ALTCONFIG, in regulator_npm2100_init()
734 ret = i2c_reg_read_byte_dt(&config->i2c, LDOSW_ENABLE, &enabled); in regulator_npm2100_init()
755 #define REGULATOR_NPM2100_DEFINE(node_id, id, _source) \ argument
756 static struct regulator_npm2100_data data_##id; \
758 static const struct regulator_npm2100_config config_##id = { \
761 .source = _source, \
770 DEVICE_DT_DEFINE(node_id, regulator_npm2100_init, NULL, &data_##id, &config_##id, \
773 #define REGULATOR_NPM2100_DEFINE_COND(inst, child, source) \ argument
775 (REGULATOR_NPM2100_DEFINE(DT_INST_CHILD(inst, child), child##inst, source)), \