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.
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;
39 unsigned int device_link:1;
41 unsigned int enable_count;
42 unsigned int deferred_disables;
43 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
44 const char *supply_name;
45 struct device_attribute dev_attr;
46 struct regulator_dev *rdev;
47 struct dentry *debugfs;
50 extern struct class regulator_class;
52 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
54 return container_of(dev, struct regulator_dev, dev);
58 struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
59 struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
60 const struct regulator_desc *desc,
61 struct regulator_config *config,
62 struct device_node **node);
64 struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
67 int of_get_n_coupled(struct regulator_dev *rdev);
69 bool of_check_coupling_data(struct regulator_dev *rdev);
72 static inline struct regulator_dev *
73 of_find_regulator_by_node(struct device_node *np)
78 static inline struct regulator_init_data *
79 regulator_of_get_init_data(struct device *dev,
80 const struct regulator_desc *desc,
81 struct regulator_config *config,
82 struct device_node **node)
87 static inline struct regulator_dev *
88 of_parse_coupled_regulator(struct regulator_dev *rdev,
94 static inline int of_get_n_coupled(struct regulator_dev *rdev)
99 static inline bool of_check_coupling_data(struct regulator_dev *rdev)
105 enum regulator_get_type {
112 struct regulator *_regulator_get(struct device *dev, const char *id,
113 enum regulator_get_type get_type);