Lines Matching +full:npm6001 +full:- +full:regulator

3  * SPDX-License-Identifier: Apache-2.0
11 #include <zephyr/drivers/regulator.h>
12 #include <zephyr/dt-bindings/regulator/npm6001.h>
17 /* nPM6001 voltage sources */
27 /* nPM6001 regulator related registers */
53 /* nPM6001 LDO0VOUT values */
61 /* nPM6001 BUCKXCONFPWMMODE fields */
66 /* nPM6001 OVERRIDEPWRUPBUCK fields */
105 return -EINVAL; in regulator_npm6001_ldo0_list_voltage()
117 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_buck012_set_voltage()
123 if (ret == -EINVAL) { in regulator_npm6001_buck012_set_voltage()
128 ret = i2c_reg_read_byte_dt(&config->i2c, conf_reg, &conf); in regulator_npm6001_buck012_set_voltage()
134 ret = i2c_reg_write_byte_dt(&config->i2c, conf_reg, in regulator_npm6001_buck012_set_voltage()
146 ret = i2c_write_dt(&config->i2c, buf, sizeof(buf)); in regulator_npm6001_buck012_set_voltage()
151 ret = i2c_reg_write_byte_dt(&config->i2c, NPM6001_TASKS_UPDATE_VOUTPWM, 1U); in regulator_npm6001_buck012_set_voltage()
158 ret = i2c_reg_write_byte_dt(&config->i2c, conf_reg, conf); in regulator_npm6001_buck012_set_voltage()
170 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_buck3_set_voltage()
176 if (ret == -EINVAL) { in regulator_npm6001_buck3_set_voltage()
181 ret = i2c_reg_read_byte_dt(&config->i2c, NPM6001_BUCK3CONFPWMMODE, &conf); in regulator_npm6001_buck3_set_voltage()
187 ret = i2c_reg_write_byte_dt(&config->i2c, NPM6001_BUCK3CONFPWMMODE, in regulator_npm6001_buck3_set_voltage()
194 ret = i2c_reg_write_byte_dt(&config->i2c, NPM6001_BUCK3VOUT, (uint8_t)idx); in regulator_npm6001_buck3_set_voltage()
201 ret = i2c_reg_write_byte_dt(&config->i2c, NPM6001_BUCK3CONFPWMMODE, conf); in regulator_npm6001_buck3_set_voltage()
213 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_ldo0_set_voltage()
225 return -EINVAL; in regulator_npm6001_ldo0_set_voltage()
228 return i2c_reg_write_byte_dt(&config->i2c, NPM6001_LDO0VOUT, val); in regulator_npm6001_ldo0_set_voltage()
235 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_buck0123_get_voltage()
239 ret = i2c_reg_read_byte_dt(&config->i2c, vout_reg, &idx); in regulator_npm6001_buck0123_get_voltage()
249 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_ldo0_get_voltage()
253 ret = i2c_reg_read_byte_dt(&config->i2c, NPM6001_LDO0VOUT, &val); in regulator_npm6001_ldo0_get_voltage()
267 return -EINVAL; in regulator_npm6001_ldo0_get_voltage()
272 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_count_voltages()
274 switch (config->source) { in regulator_npm6001_count_voltages()
297 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_list_voltage()
299 switch (config->source) { in regulator_npm6001_list_voltage()
322 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_set_voltage()
324 switch (config->source) { in regulator_npm6001_set_voltage()
343 return -EINVAL; in regulator_npm6001_set_voltage()
355 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_get_voltage()
357 switch (config->source) { in regulator_npm6001_get_voltage()
384 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_set_mode()
388 return -ENOTSUP; in regulator_npm6001_set_mode()
391 switch (config->source) { in regulator_npm6001_set_mode()
405 return -ENOTSUP; in regulator_npm6001_set_mode()
408 return i2c_reg_update_byte_dt(&config->i2c, conf_reg, in regulator_npm6001_set_mode()
415 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_get_mode()
419 switch (config->source) { in regulator_npm6001_get_mode()
433 return -ENOTSUP; in regulator_npm6001_get_mode()
436 ret = i2c_reg_read_byte_dt(&config->i2c, conf_reg, &conf); in regulator_npm6001_get_mode()
449 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_enable()
451 switch (config->source) { in regulator_npm6001_enable()
453 return i2c_reg_update_byte_dt(&config->i2c, NPM6001_OVERRIDEPWRUPBUCK, in regulator_npm6001_enable()
456 return i2c_reg_update_byte_dt(&config->i2c, NPM6001_OVERRIDEPWRUPBUCK, in regulator_npm6001_enable()
459 return i2c_reg_write_byte_dt(&config->i2c, NPM6001_TASKS_START_BUCK3, 1U); in regulator_npm6001_enable()
461 return i2c_reg_write_byte_dt(&config->i2c, NPM6001_TASKS_START_LDO0, 1U); in regulator_npm6001_enable()
463 return i2c_reg_write_byte_dt(&config->i2c, NPM6001_TASKS_START_LDO1, 1U); in regulator_npm6001_enable()
471 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_disable()
473 switch (config->source) { in regulator_npm6001_disable()
475 return i2c_reg_update_byte_dt(&config->i2c, NPM6001_OVERRIDEPWRUPBUCK, in regulator_npm6001_disable()
479 return i2c_reg_update_byte_dt(&config->i2c, NPM6001_OVERRIDEPWRUPBUCK, in regulator_npm6001_disable()
483 return i2c_reg_write_byte_dt(&config->i2c, NPM6001_TASKS_STOP_BUCK3, 1U); in regulator_npm6001_disable()
485 return i2c_reg_write_byte_dt(&config->i2c, NPM6001_TASKS_STOP_LDO0, 1U); in regulator_npm6001_disable()
487 return i2c_reg_write_byte_dt(&config->i2c, NPM6001_TASKS_STOP_LDO1, 1U); in regulator_npm6001_disable()
496 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_get_error_flags()
503 ret = i2c_reg_read_byte_dt(&config->i2c, NPM6001_EVENTS_THWARN, &val); in regulator_npm6001_get_error_flags()
510 ret = i2c_reg_write_byte_dt(&config->i2c, NPM6001_EVENTS_THWARN, 0U); in regulator_npm6001_get_error_flags()
519 switch (config->source) { in regulator_npm6001_get_error_flags()
536 ret = i2c_reg_read_byte_dt(&config->i2c, oc_reg, &val); in regulator_npm6001_get_error_flags()
543 ret = i2c_reg_write_byte_dt(&config->i2c, oc_reg, 0U); in regulator_npm6001_get_error_flags()
556 const struct regulator_npm6001_config *config = dev->config; in regulator_npm6001_init()
561 if (!i2c_is_ready_dt(&config->i2c)) { in regulator_npm6001_init()
562 return -ENODEV; in regulator_npm6001_init()
566 is_enabled = (config->source == NPM6001_SOURCE_BUCK1) || in regulator_npm6001_init()
567 (config->source == NPM6001_SOURCE_BUCK2); in regulator_npm6001_init()
572 static DEVICE_API(regulator, api) = {