Lines Matching +full:pmic +full:- +full:int +full:- +full:pin

2  * Copyright (c) 2019-2020 Peter Bigot Consulting, LLC
7 * SPDX-License-Identifier: Apache-2.0
62 typedef int (*regulator_dvs_state_set_t)(const struct device *dev,
65 typedef int (*regulator_ship_mode_t)(const struct device *dev);
67 /** @brief Driver-specific API functions to support parent regulator control. */
73 typedef int (*regulator_enable_t)(const struct device *dev);
74 typedef int (*regulator_disable_t)(const struct device *dev);
75 typedef unsigned int (*regulator_count_voltages_t)(const struct device *dev);
76 typedef int (*regulator_list_voltage_t)(const struct device *dev,
77 unsigned int idx, int32_t *volt_uv);
78 typedef int (*regulator_set_voltage_t)(const struct device *dev, int32_t min_uv,
80 typedef int (*regulator_get_voltage_t)(const struct device *dev,
82 typedef unsigned int (*regulator_count_current_limits_t)(const struct device *dev);
83 typedef int (*regulator_list_current_limit_t)(const struct device *dev,
84 unsigned int idx, int32_t *current_ua);
85 typedef int (*regulator_set_current_limit_t)(const struct device *dev,
87 typedef int (*regulator_get_current_limit_t)(const struct device *dev,
89 typedef int (*regulator_set_mode_t)(const struct device *dev,
91 typedef int (*regulator_get_mode_t)(const struct device *dev,
93 typedef int (*regulator_set_active_discharge_t)(const struct device *dev,
95 typedef int (*regulator_get_active_discharge_t)(const struct device *dev,
97 typedef int (*regulator_get_error_flags_t)(
100 /** @brief Driver-specific API functions to support regulator control. */
243 int refcnt;
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.
275 * @retval -errno Negative errno in case of failure.
277 int regulator_common_init(const struct device *dev, bool is_enabled);
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()
301 * @retval -ENOENT If minimum voltage is not specified.
303 static inline int regulator_common_get_min_voltage(const struct device *dev, int32_t *min_uv) in regulator_common_get_min_voltage()
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()
323 * @retval -ENOENT If maximum voltage is not specified.
325 static inline int regulator_common_get_max_voltage(const struct device *dev, int32_t *max_uv) in regulator_common_get_max_voltage()
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()
352 * configure specific output pins when entering low-power modes so that PMIC
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.
365 static inline int regulator_parent_dvs_state_set(const struct device *dev, in regulator_parent_dvs_state_set()
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()
382 * Exit from low power is normally by pin transition.
389 * @retval -ENOSYS If function is not implemented.
390 * @retval -errno In case of any other error.
392 static inline int regulator_parent_ship_mode(const struct device *dev) in regulator_parent_ship_mode()
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()
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
417 * @retval -errno Negative errno in case of failure.
418 * @retval -ENOTSUP If regulator enablement can not be controlled.
420 int regulator_enable(const struct device *dev);
437 * `regulator-always-on` will always stay enabled, and so this function will
445 * @retval -errno Negative errno in case of failure.
446 * @retval -ENOTSUP If regulator disablement can not be controlled.
448 int regulator_disable(const struct device *dev);
461 static inline unsigned int regulator_count_voltages(const struct device *dev) in regulator_count_voltages()
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()
486 * @retval -EINVAL If @p index does not correspond to a supported voltage.
488 static inline int regulator_list_voltage(const struct device *dev, in regulator_list_voltage()
489 unsigned int idx, int32_t *volt_uv) in regulator_list_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()
520 * voltage may be limited using `regulator-min-microvolt` and/or
521 * `regulator-max-microvolt` in devicetree.
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.
532 int regulator_set_voltage(const struct device *dev, int32_t min_uv,
542 * @retval -ENOSYS If function is not implemented.
543 * @retval -errno In case of any other error.
545 static inline int regulator_get_voltage(const struct device *dev, in regulator_get_voltage()
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()
569 static inline unsigned int regulator_count_current_limits(const struct device *dev) in regulator_count_current_limits()
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()
594 * @retval -EINVAL If @p index does not correspond to a supported current limit.
596 static inline int regulator_list_current_limit(const struct device *dev, in regulator_list_current_limit()
597 unsigned int idx, int32_t *current_ua) in regulator_list_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.
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.
626 int regulator_set_current_limit(const struct device *dev, int32_t min_ua,
636 * @retval -ENOSYS If function is not implemented.
637 * @retval -errno In case of any other error.
639 static inline int regulator_get_current_limit(const struct device *dev, in regulator_get_current_limit()
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()
657 * the regulator. Allowed modes may be limited using `regulator-allowed-modes`
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);
677 * @retval -ENOSYS If function is not implemented.
678 * @retval -errno In case of any other error.
680 static inline int regulator_get_mode(const struct device *dev, in regulator_get_mode()
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()
700 * @retval -ENOSYS If function is not implemented.
701 * @retval -errno In case of any other error.
703 static inline int regulator_set_active_discharge(const struct device *dev, in regulator_set_active_discharge()
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()
723 * @retval -ENOSYS If function is not implemented.
724 * @retval -errno In case of any other error.
726 static inline int regulator_get_active_discharge(const struct device *dev, in regulator_get_active_discharge()
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()
746 * @retval -ENOSYS If function is not implemented.
747 * @retval -errno In case of any other error.
749 static inline int regulator_get_error_flags(const struct device *dev, in regulator_get_error_flags()
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()