Lines Matching +full:regulator +full:- +full:initial +full:- +full:mode
2 * Copyright (c) 2019-2020 Peter Bigot Consulting, LLC
7 * SPDX-License-Identifier: Apache-2.0
14 * @brief Regulator Interface
15 * @defgroup regulator_interface Regulator Interface
36 /** Opaque type to store regulator DVS states */
39 /** Opaque type to store regulator modes */
42 /** Opaque bit map for regulator error flags (see @ref REGULATOR_ERRORS) */
46 * @name Regulator error flags.
67 /** @brief Driver-specific API functions to support parent regulator control. */
90 regulator_mode_t mode);
92 regulator_mode_t *mode);
100 /** @brief Driver-specific API functions to support regulator control. */
120 * @name Regulator flags
124 /** Indicates regulator must stay always ON */
126 /** Indicates regulator must be initialized ON */
128 /** Indicates if regulator must be enabled when initialized */
130 /** Regulator active discharge state mask */
132 /** Regulator active discharge state flag position*/
134 /** Disable regulator active discharge */
136 /** Enable regulator active discharge */
138 /** Leave regulator active discharge state as default */
140 /** Regulator active discharge set bits */
143 /** Regulator active discharge get bits */
146 /** Indicates regulator must be initialized OFF */
151 /** Indicates initial mode is unknown/not specified */
155 * @brief Common regulator config.
164 /** Initial voltage, in microvolts. */
170 /** Initial current, in microamps. */
180 /** Regulator initial mode */
233 * @brief Common regulator data.
247 * @brief Initialize common regulator data.
251 * @param dev Regulator device instance.
256 * @brief Common function to initialize the regulator at init time.
258 * This function needs to be called after drivers initialize the regulator. It
261 * - Automatically enable the regulator if it is set to `regulator-boot-on`
262 * or `regulator-always-on` and increase its usage count.
263 * - Automatically disable the regulator if it is set to `regulator-boot-off`.
264 * - Configure the regulator mode if `regulator-initial-mode` is set.
265 * - Ensure regulator voltage is set to a valid range.
270 * @param dev Regulator device instance
271 * @param is_enabled Indicate if the regulator is enabled by default in
275 * @retval -errno Negative errno in case of failure.
280 * @brief Check if regulator is expected to be enabled at init time.
282 * @param dev Regulator device instance
283 * @return true If regulator needs to be enabled at init time.
284 * @return false If regulator does not need to be enabled at init time.
289 (const struct regulator_common_config *)dev->config; in regulator_common_is_init_enabled()
291 return (config->flags & REGULATOR_INIT_ENABLED) != 0U; in regulator_common_is_init_enabled()
297 * @param dev Regulator device instance.
301 * @retval -ENOENT If minimum voltage is not specified.
306 (const struct regulator_common_config *)dev->config; in regulator_common_get_min_voltage()
308 if (config->min_uv == INT32_MIN) { in regulator_common_get_min_voltage()
309 return -ENOENT; in regulator_common_get_min_voltage()
312 *min_uv = config->min_uv; in regulator_common_get_min_voltage()
319 * @param dev Regulator device instance.
323 * @retval -ENOENT If maximum voltage is not specified.
328 (const struct regulator_common_config *)dev->config; in regulator_common_get_max_voltage()
330 if (config->max_uv == INT32_MAX) { in regulator_common_get_max_voltage()
331 return -ENOENT; in regulator_common_get_max_voltage()
334 *max_uv = config->max_uv; in regulator_common_get_max_voltage()
341 * @brief Regulator Parent Interface
342 * @defgroup regulator_parent_interface Regulator Parent Interface
352 * configure specific output pins when entering low-power modes so that PMIC
356 * @param dev Parent regulator device instance.
360 * @retval -ENOTSUP If given state is not supported.
361 * @retval -EPERM If state can't be changed by software.
362 * @retval -ENOSYS If function is not implemented.
363 * @retval -errno In case of any other error.
369 (const struct regulator_parent_driver_api *)dev->api; in regulator_parent_dvs_state_set()
371 if (api->dvs_state_set == NULL) { in regulator_parent_dvs_state_set()
372 return -ENOSYS; in regulator_parent_dvs_state_set()
375 return api->dvs_state_set(dev, state); in regulator_parent_dvs_state_set()
379 * @brief Enter ship mode.
381 * Some PMICs feature a ship mode, which allows the system to save power.
384 * This API can be used when ship mode needs to be entered.
386 * @param dev Parent regulator device instance.
389 * @retval -ENOSYS If function is not implemented.
390 * @retval -errno In case of any other error.
395 (const struct regulator_parent_driver_api *)dev->api; in regulator_parent_ship_mode()
397 if (api->ship_mode == NULL) { in regulator_parent_ship_mode()
398 return -ENOSYS; in regulator_parent_ship_mode()
401 return api->ship_mode(dev); in regulator_parent_ship_mode()
407 * @brief Enable a regulator.
409 * Reference-counted request that a regulator be turned on. A regulator is
411 * are always on, or configured in devicetree with `regulator-always-on` will
414 * @param dev Regulator device instance
416 * @retval 0 If regulator has been successfully enabled.
417 * @retval -errno Negative errno in case of failure.
418 * @retval -ENOTSUP If regulator enablement can not be controlled.
423 * @brief Check if a regulator is enabled.
425 * @param dev Regulator device instance.
427 * @retval true If regulator is enabled.
428 * @retval false If regulator is disabled.
433 * @brief Disable a regulator.
435 * Release a regulator after a previous regulator_enable() completed
437 * `regulator-always-on` will always stay enabled, and so this function will
442 * @param dev Regulator device instance.
444 * @retval 0 If regulator has been successfully disabled.
445 * @retval -errno Negative errno in case of failure.
446 * @retval -ENOTSUP If regulator disablement can not be controlled.
453 * Each voltage level supported by a regulator gets an index, starting from
457 * @param dev Regulator device instance.
464 (const struct regulator_driver_api *)dev->api; in regulator_count_voltages()
466 if (api->count_voltages == NULL) { in regulator_count_voltages()
470 return api->count_voltages(dev); in regulator_count_voltages()
476 * Each voltage level supported by a regulator gets an index, starting from
480 * @param dev Regulator device instance.
486 * @retval -EINVAL If @p index does not correspond to a supported voltage.
492 (const struct regulator_driver_api *)dev->api; in regulator_list_voltage()
494 if (api->list_voltage == NULL) { in regulator_list_voltage()
495 return -EINVAL; in regulator_list_voltage()
498 return api->list_voltage(dev, idx, volt_uv); in regulator_list_voltage()
504 * @param dev Regulator device instance.
519 * voltage. The voltage will be applied to the active or selected mode. Output
520 * voltage may be limited using `regulator-min-microvolt` and/or
521 * `regulator-max-microvolt` in devicetree.
523 * @param dev Regulator device instance.
528 * @retval -EINVAL If the given voltage window is not valid.
529 * @retval -ENOSYS If function is not implemented.
530 * @retval -errno In case of any other error.
538 * @param dev Regulator device instance.
542 * @retval -ENOSYS If function is not implemented.
543 * @retval -errno In case of any other error.
549 (const struct regulator_driver_api *)dev->api; in regulator_get_voltage()
551 if (api->get_voltage == NULL) { in regulator_get_voltage()
552 return -ENOSYS; in regulator_get_voltage()
555 return api->get_voltage(dev, volt_uv); in regulator_get_voltage()
561 * Each current limit level supported by a regulator gets an index, starting from
565 * @param dev Regulator device instance.
572 (const struct regulator_driver_api *)dev->api; in regulator_count_current_limits()
574 if (api->count_current_limits == NULL) { in regulator_count_current_limits()
578 return api->count_current_limits(dev); in regulator_count_current_limits()
584 * Each current limit level supported by a regulator gets an index, starting from
588 * @param dev Regulator device instance.
594 * @retval -EINVAL If @p index does not correspond to a supported current limit.
600 (const struct regulator_driver_api *)dev->api; in regulator_list_current_limit()
602 if (api->list_current_limit == NULL) { in regulator_list_current_limit()
603 return -EINVAL; in regulator_list_current_limit()
606 return api->list_current_limit(dev, idx, current_ua); in regulator_list_current_limit()
614 * configured current limit. Current may be limited using `current-min-microamp`
615 * and/or `current-max-microamp` in Devicetree.
617 * @param dev Regulator device instance.
622 * @retval -EINVAL If the given current limit window is not valid.
623 * @retval -ENOSYS If function is not implemented.
624 * @retval -errno In case of any other error.
632 * @param dev Regulator device instance.
636 * @retval -ENOSYS If function is not implemented.
637 * @retval -errno In case of any other error.
643 (const struct regulator_driver_api *)dev->api; in regulator_get_current_limit()
645 if (api->get_current_limit == NULL) { in regulator_get_current_limit()
646 return -ENOSYS; in regulator_get_current_limit()
649 return api->get_current_limit(dev, curr_ua); in regulator_get_current_limit()
653 * @brief Set mode.
656 * configuration or better power savings. This API will apply a mode for
657 * the regulator. Allowed modes may be limited using `regulator-allowed-modes`
660 * @param dev Regulator device instance.
661 * @param mode Mode to select for this regulator.
664 * @retval -ENOTSUP If mode is not supported.
665 * @retval -ENOSYS If function is not implemented.
666 * @retval -errno In case of any other error.
668 int regulator_set_mode(const struct device *dev, regulator_mode_t mode);
671 * @brief Get mode.
673 * @param dev Regulator device instance.
674 * @param[out] mode Where mode will be stored.
677 * @retval -ENOSYS If function is not implemented.
678 * @retval -errno In case of any other error.
681 regulator_mode_t *mode) in regulator_get_mode() argument
684 (const struct regulator_driver_api *)dev->api; in regulator_get_mode()
686 if (api->get_mode == NULL) { in regulator_get_mode()
687 return -ENOSYS; in regulator_get_mode()
690 return api->get_mode(dev, mode); in regulator_get_mode()
696 * @param dev Regulator device instance.
700 * @retval -ENOSYS If function is not implemented.
701 * @retval -errno In case of any other error.
707 (const struct regulator_driver_api *)dev->api; in regulator_set_active_discharge()
709 if (api->set_active_discharge == NULL) { in regulator_set_active_discharge()
710 return -ENOSYS; in regulator_set_active_discharge()
713 return api->set_active_discharge(dev, active_discharge); in regulator_set_active_discharge()
719 * @param dev Regulator device instance.
723 * @retval -ENOSYS If function is not implemented.
724 * @retval -errno In case of any other error.
730 (const struct regulator_driver_api *)dev->api; in regulator_get_active_discharge()
732 if (api->get_active_discharge == NULL) { in regulator_get_active_discharge()
733 return -ENOSYS; in regulator_get_active_discharge()
736 return api->get_active_discharge(dev, active_discharge); in regulator_get_active_discharge()
742 * @param dev Regulator device instance.
746 * @retval -ENOSYS If function is not implemented.
747 * @retval -errno In case of any other error.
753 (const struct regulator_driver_api *)dev->api; in regulator_get_error_flags()
755 if (api->get_error_flags == NULL) { in regulator_get_error_flags()
756 return -ENOSYS; in regulator_get_error_flags()
759 return api->get_error_flags(dev, flags); in regulator_get_error_flags()