File Index
Files and directories
Sign in
FILE

coupler.h

File preview with syntax highlighting.

linux-6.19.14/include/linux/regulator/coupler.h C
  1/* SPDX-License-Identifier: GPL-2.0 */
  2/*
  3 * coupler.h -- SoC Regulator support, coupler API.
  4 *
  5 * Regulator Coupler Interface.
  6 */
  7
  8#ifndef __LINUX_REGULATOR_COUPLER_H_
  9#define __LINUX_REGULATOR_COUPLER_H_
 10
 11#include <linux/errno.h>
 12#include <linux/types.h>
 13#include <linux/suspend.h>
 14
 15struct regulator_coupler;
 16struct regulator_dev;
 17
 18/**
 19 * struct regulator_coupler - customized regulator's coupler
 20 *
 21 * Regulator's coupler allows to customize coupling algorithm.
 22 *
 23 * @list: couplers list entry
 24 * @attach_regulator: Callback invoked on creation of a coupled regulator,
 25 *                    couples are unresolved at this point. The callee should
 26 *                    check that it could handle the regulator and return 0 on
 27 *                    success, -errno on failure and 1 if given regulator is
 28 *                    not suitable for this coupler (case of having multiple
 29 *                    regulators in a system). Callback shall be implemented.
 30 * @detach_regulator: Callback invoked on destruction of a coupled regulator.
 31 *                    This callback is optional and could be NULL.
 32 * @balance_voltage: Callback invoked when voltage of a coupled regulator is
 33 *                   changing. Called with all of the coupled rdev's being held
 34 *                   under "consumer lock". The callee should perform voltage
 35 *                   balancing, changing voltage of the coupled regulators as
 36 *                   needed. It's up to the coupler to verify the voltage
 37 *                   before changing it in hardware, i.e. coupler should
 38 *                   check consumer's min/max and etc. This callback is
 39 *                   optional and could be NULL, in which case a generic
 40 *                   voltage balancer will be used.
 41 */
 42struct regulator_coupler {
 43	struct list_head list;
 44
 45	int (*attach_regulator)(struct regulator_coupler *coupler,
 46				struct regulator_dev *rdev);
 47	int (*detach_regulator)(struct regulator_coupler *coupler,
 48				struct regulator_dev *rdev);
 49	int (*balance_voltage)(struct regulator_coupler *coupler,
 50			       struct regulator_dev *rdev,
 51			       suspend_state_t state);
 52};
 53
 54#ifdef CONFIG_REGULATOR
 55int regulator_coupler_register(struct regulator_coupler *coupler);
 56int regulator_check_consumers(struct regulator_dev *rdev,
 57			      int *min_uV, int *max_uV,
 58			      suspend_state_t state);
 59int regulator_check_voltage(struct regulator_dev *rdev,
 60			    int *min_uV, int *max_uV);
 61int regulator_get_voltage_rdev(struct regulator_dev *rdev);
 62int regulator_set_voltage_rdev(struct regulator_dev *rdev,
 63			       int min_uV, int max_uV,
 64			       suspend_state_t state);
 65int regulator_do_balance_voltage(struct regulator_dev *rdev,
 66				 suspend_state_t state, bool skip_coupled);
 67#else
 68static inline int regulator_coupler_register(struct regulator_coupler *coupler)
 69{
 70	return 0;
 71}
 72static inline int regulator_check_consumers(struct regulator_dev *rdev,
 73					    int *min_uV, int *max_uV,
 74					    suspend_state_t state)
 75{
 76	return -EINVAL;
 77}
 78static inline int regulator_check_voltage(struct regulator_dev *rdev,
 79					  int *min_uV, int *max_uV)
 80{
 81	return -EINVAL;
 82}
 83static inline int regulator_get_voltage_rdev(struct regulator_dev *rdev)
 84{
 85	return -EINVAL;
 86}
 87static inline int regulator_set_voltage_rdev(struct regulator_dev *rdev,
 88					     int min_uV, int max_uV,
 89					     suspend_state_t state)
 90{
 91	return -EINVAL;
 92}
 93static inline int regulator_do_balance_voltage(struct regulator_dev *rdev,
 94					       suspend_state_t state,
 95					       bool skip_coupled)
 96{
 97	return -EINVAL;
 98}
 99#endif
100
101#endif
~/ Read-only file preview.