1 /* SPDX-License-Identifier: GPL-2.0-or-later */
3 * internal.h -- Voltage/Current Regulator framework internal code
5 * Copyright 2007, 2008 Wolfson Microelectronics PLC.
6 * Copyright 2008 SlimLogic Ltd.
8 * Author: Liam Girdwood <lrg@slimlogic.co.uk>
11 #ifndef __REGULATOR_INTERNAL_H
12 #define __REGULATOR_INTERNAL_H
14 #include <linux/suspend.h>
16 #define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
18 struct regulator_voltage {
26 * One for each consumer device.
27 * @voltage - a voltage array for each state of runtime, i.e.:
36 struct list_head list;
37 unsigned int always_on:1;
38 unsigned int bypass:1;
40 unsigned int enable_count;
41 unsigned int deferred_disables;
42 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
43 const char *supply_name;
44 struct device_attribute dev_attr;
45 struct regulator_dev *rdev;
46 struct dentry *debugfs;
49 extern struct class regulator_class;
51 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
53 return container_of(dev, struct regulator_dev, dev);
57 struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
58 struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
59 const struct regulator_desc *desc,
60 struct regulator_config *config,
61 struct device_node **node);
63 struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
66 int of_get_n_coupled(struct regulator_dev *rdev);
68 bool of_check_coupling_data(struct regulator_dev *rdev);
71 static inline struct regulator_dev *
72 of_find_regulator_by_node(struct device_node *np)
77 static inline struct regulator_init_data *
78 regulator_of_get_init_data(struct device *dev,
79 const struct regulator_desc *desc,
80 struct regulator_config *config,
81 struct device_node **node)
86 static inline struct regulator_dev *
87 of_parse_coupled_regulator(struct regulator_dev *rdev,
93 static inline int of_get_n_coupled(struct regulator_dev *rdev)
98 static inline bool of_check_coupling_data(struct regulator_dev *rdev)
104 enum regulator_get_type {
111 struct regulator *_regulator_get(struct device *dev, const char *id,
112 enum regulator_get_type get_type);