0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef __REGULATOR_INTERNAL_H
0012 #define __REGULATOR_INTERNAL_H
0013
0014 #include <linux/suspend.h>
0015
0016 #define REGULATOR_STATES_NUM (PM_SUSPEND_MAX + 1)
0017
0018 #define rdev_crit(rdev, fmt, ...) \
0019 pr_crit("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
0020 #define rdev_err(rdev, fmt, ...) \
0021 pr_err("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
0022 #define rdev_warn(rdev, fmt, ...) \
0023 pr_warn("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
0024 #define rdev_info(rdev, fmt, ...) \
0025 pr_info("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
0026 #define rdev_dbg(rdev, fmt, ...) \
0027 pr_debug("%s: " fmt, rdev_get_name(rdev), ##__VA_ARGS__)
0028
0029 struct regulator_voltage {
0030 int min_uV;
0031 int max_uV;
0032 };
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045 struct regulator {
0046 struct device *dev;
0047 struct list_head list;
0048 unsigned int always_on:1;
0049 unsigned int bypass:1;
0050 unsigned int device_link:1;
0051 int uA_load;
0052 unsigned int enable_count;
0053 unsigned int deferred_disables;
0054 struct regulator_voltage voltage[REGULATOR_STATES_NUM];
0055 const char *supply_name;
0056 struct device_attribute dev_attr;
0057 struct regulator_dev *rdev;
0058 struct dentry *debugfs;
0059 };
0060
0061 extern struct class regulator_class;
0062
0063 static inline struct regulator_dev *dev_to_rdev(struct device *dev)
0064 {
0065 return container_of(dev, struct regulator_dev, dev);
0066 }
0067
0068 #ifdef CONFIG_OF
0069 struct regulator_dev *of_find_regulator_by_node(struct device_node *np);
0070 struct regulator_init_data *regulator_of_get_init_data(struct device *dev,
0071 const struct regulator_desc *desc,
0072 struct regulator_config *config,
0073 struct device_node **node);
0074
0075 struct regulator_dev *of_parse_coupled_regulator(struct regulator_dev *rdev,
0076 int index);
0077
0078 int of_get_n_coupled(struct regulator_dev *rdev);
0079
0080 bool of_check_coupling_data(struct regulator_dev *rdev);
0081
0082 #else
0083 static inline struct regulator_dev *
0084 of_find_regulator_by_node(struct device_node *np)
0085 {
0086 return NULL;
0087 }
0088
0089 static inline struct regulator_init_data *
0090 regulator_of_get_init_data(struct device *dev,
0091 const struct regulator_desc *desc,
0092 struct regulator_config *config,
0093 struct device_node **node)
0094 {
0095 return NULL;
0096 }
0097
0098 static inline struct regulator_dev *
0099 of_parse_coupled_regulator(struct regulator_dev *rdev,
0100 int index)
0101 {
0102 return NULL;
0103 }
0104
0105 static inline int of_get_n_coupled(struct regulator_dev *rdev)
0106 {
0107 return 0;
0108 }
0109
0110 static inline bool of_check_coupling_data(struct regulator_dev *rdev)
0111 {
0112 return false;
0113 }
0114
0115 #endif
0116 enum regulator_get_type {
0117 NORMAL_GET,
0118 EXCLUSIVE_GET,
0119 OPTIONAL_GET,
0120 MAX_GET_TYPE
0121 };
0122
0123 struct regulator *_regulator_get(struct device *dev, const char *id,
0124 enum regulator_get_type get_type);
0125 #endif