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 #define rdev_crit(rdev, fmt, ...) \
19 pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
20 #define rdev_err(rdev, fmt, ...) \
21 pr_err("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
22 #define rdev_warn(rdev, fmt, ...) \
23 pr_warn("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
24 #define rdev_info(rdev, fmt, ...) \
25 pr_info("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
26 #define rdev_dbg(rdev, fmt, ...) \
27 pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
29 struct regulator_voltage {
37 * One for each consumer device.
38 * @voltage - a voltage array for each state of runtime, i.e.:
47 struct list_head list;
48 unsigned int always_on:1;
49 unsigned int bypass:1;
50 unsigned int device_link:1;
52 unsigned int enable_count;
53 unsigned int deferred_disables;
54 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
55 const char *supply_name;
56 struct device_attribute dev_attr;
57 struct regulator_dev *rdev;
58 struct dentry *debugfs;
61 extern struct class regulator_class;
63 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
65 return container_of(dev, struct regulator_dev, dev);
69 struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
70 struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
71 const struct regulator_desc *desc,
72 struct regulator_config *config,
73 struct device_node **node);
75 struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
78 int of_get_n_coupled(struct regulator_dev *rdev);
80 bool of_check_coupling_data(struct regulator_dev *rdev);
83 static inline struct regulator_dev *
84 of_find_regulator_by_node(struct device_node *np)
89 static inline struct regulator_init_data *
90 regulator_of_get_init_data(struct device *dev,
91 const struct regulator_desc *desc,
92 struct regulator_config *config,
93 struct device_node **node)
98 static inline struct regulator_dev *
99 of_parse_coupled_regulator(struct regulator_dev *rdev,
105 static inline int of_get_n_coupled(struct regulator_dev *rdev)
110 static inline bool of_check_coupling_data(struct regulator_dev *rdev)
116 enum regulator_get_type {
123 struct regulator *_regulator_get(struct device *dev, const char *id,
124 enum regulator_get_type get_type);
125 int _regulator_bulk_get(struct device *dev, int num_consumers,
126 struct regulator_bulk_data *consumers, enum regulator_get_type get_type);