diff options
Diffstat (limited to 'include/linux/regulator')
-rw-r--r-- | include/linux/regulator/driver.h | 73 | ||||
-rw-r--r-- | include/linux/regulator/fixed.h | 7 | ||||
-rw-r--r-- | include/linux/regulator/of_regulator.h | 18 | ||||
-rw-r--r-- | include/linux/regulator/tps62360.h | 6 | ||||
-rw-r--r-- | include/linux/regulator/tps65090-regulator.h | 50 |
5 files changed, 141 insertions, 13 deletions
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h index fa8b55b8191c..b0432cc2b169 100644 --- a/include/linux/regulator/driver.h +++ b/include/linux/regulator/driver.h | |||
@@ -19,6 +19,7 @@ | |||
19 | #include <linux/notifier.h> | 19 | #include <linux/notifier.h> |
20 | #include <linux/regulator/consumer.h> | 20 | #include <linux/regulator/consumer.h> |
21 | 21 | ||
22 | struct regmap; | ||
22 | struct regulator_dev; | 23 | struct regulator_dev; |
23 | struct regulator_init_data; | 24 | struct regulator_init_data; |
24 | 25 | ||
@@ -45,6 +46,7 @@ enum regulator_status { | |||
45 | * The driver should select the voltage closest to min_uV. | 46 | * The driver should select the voltage closest to min_uV. |
46 | * @set_voltage_sel: Set the voltage for the regulator using the specified | 47 | * @set_voltage_sel: Set the voltage for the regulator using the specified |
47 | * selector. | 48 | * selector. |
49 | * @map_voltage: Convert a voltage into a selector | ||
48 | * @get_voltage: Return the currently configured voltage for the regulator. | 50 | * @get_voltage: Return the currently configured voltage for the regulator. |
49 | * @get_voltage_sel: Return the currently configured voltage selector for the | 51 | * @get_voltage_sel: Return the currently configured voltage selector for the |
50 | * regulator. | 52 | * regulator. |
@@ -90,6 +92,7 @@ struct regulator_ops { | |||
90 | /* get/set regulator voltage */ | 92 | /* get/set regulator voltage */ |
91 | int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV, | 93 | int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV, |
92 | unsigned *selector); | 94 | unsigned *selector); |
95 | int (*map_voltage)(struct regulator_dev *, int min_uV, int max_uV); | ||
93 | int (*set_voltage_sel) (struct regulator_dev *, unsigned selector); | 96 | int (*set_voltage_sel) (struct regulator_dev *, unsigned selector); |
94 | int (*get_voltage) (struct regulator_dev *); | 97 | int (*get_voltage) (struct regulator_dev *); |
95 | int (*get_voltage_sel) (struct regulator_dev *); | 98 | int (*get_voltage_sel) (struct regulator_dev *); |
@@ -148,19 +151,30 @@ enum regulator_type { | |||
148 | }; | 151 | }; |
149 | 152 | ||
150 | /** | 153 | /** |
151 | * struct regulator_desc - Regulator descriptor | 154 | * struct regulator_desc - Static regulator descriptor |
152 | * | 155 | * |
153 | * Each regulator registered with the core is described with a structure of | 156 | * Each regulator registered with the core is described with a |
154 | * this type. | 157 | * structure of this type and a struct regulator_config. This |
158 | * structure contains the non-varying parts of the regulator | ||
159 | * description. | ||
155 | * | 160 | * |
156 | * @name: Identifying name for the regulator. | 161 | * @name: Identifying name for the regulator. |
157 | * @supply_name: Identifying the regulator supply | 162 | * @supply_name: Identifying the regulator supply |
158 | * @id: Numerical identifier for the regulator. | 163 | * @id: Numerical identifier for the regulator. |
159 | * @n_voltages: Number of selectors available for ops.list_voltage(). | ||
160 | * @ops: Regulator operations table. | 164 | * @ops: Regulator operations table. |
161 | * @irq: Interrupt number for the regulator. | 165 | * @irq: Interrupt number for the regulator. |
162 | * @type: Indicates if the regulator is a voltage or current regulator. | 166 | * @type: Indicates if the regulator is a voltage or current regulator. |
163 | * @owner: Module providing the regulator, used for refcounting. | 167 | * @owner: Module providing the regulator, used for refcounting. |
168 | * | ||
169 | * @n_voltages: Number of selectors available for ops.list_voltage(). | ||
170 | * | ||
171 | * @min_uV: Voltage given by the lowest selector (if linear mapping) | ||
172 | * @uV_step: Voltage increase with each selector (if linear mapping) | ||
173 | * | ||
174 | * @vsel_reg: Register for selector when using regulator_regmap_X_voltage_ | ||
175 | * @vsel_mask: Mask for register bitfield used for selector | ||
176 | * @enable_reg: Register for control when using regmap enable/disable ops | ||
177 | * @enable_mask: Mask for control when using regmap enable/disable ops | ||
164 | */ | 178 | */ |
165 | struct regulator_desc { | 179 | struct regulator_desc { |
166 | const char *name; | 180 | const char *name; |
@@ -171,6 +185,36 @@ struct regulator_desc { | |||
171 | int irq; | 185 | int irq; |
172 | enum regulator_type type; | 186 | enum regulator_type type; |
173 | struct module *owner; | 187 | struct module *owner; |
188 | |||
189 | unsigned int min_uV; | ||
190 | unsigned int uV_step; | ||
191 | |||
192 | unsigned int vsel_reg; | ||
193 | unsigned int vsel_mask; | ||
194 | unsigned int enable_reg; | ||
195 | unsigned int enable_mask; | ||
196 | }; | ||
197 | |||
198 | /** | ||
199 | * struct regulator_config - Dynamic regulator descriptor | ||
200 | * | ||
201 | * Each regulator registered with the core is described with a | ||
202 | * structure of this type and a struct regulator_desc. This structure | ||
203 | * contains the runtime variable parts of the regulator description. | ||
204 | * | ||
205 | * @dev: struct device for the regulator | ||
206 | * @init_data: platform provided init data, passed through by driver | ||
207 | * @driver_data: private regulator data | ||
208 | * @of_node: OpenFirmware node to parse for device tree bindings (may be | ||
209 | * NULL). | ||
210 | * @regmap: regmap to use for core regmap helpers | ||
211 | */ | ||
212 | struct regulator_config { | ||
213 | struct device *dev; | ||
214 | const struct regulator_init_data *init_data; | ||
215 | void *driver_data; | ||
216 | struct device_node *of_node; | ||
217 | struct regmap *regmap; | ||
174 | }; | 218 | }; |
175 | 219 | ||
176 | /* | 220 | /* |
@@ -184,7 +228,7 @@ struct regulator_desc { | |||
184 | * no other direct access). | 228 | * no other direct access). |
185 | */ | 229 | */ |
186 | struct regulator_dev { | 230 | struct regulator_dev { |
187 | struct regulator_desc *desc; | 231 | const struct regulator_desc *desc; |
188 | int exclusive; | 232 | int exclusive; |
189 | u32 use_count; | 233 | u32 use_count; |
190 | u32 open_count; | 234 | u32 open_count; |
@@ -201,6 +245,7 @@ struct regulator_dev { | |||
201 | struct device dev; | 245 | struct device dev; |
202 | struct regulation_constraints *constraints; | 246 | struct regulation_constraints *constraints; |
203 | struct regulator *supply; /* for tree */ | 247 | struct regulator *supply; /* for tree */ |
248 | struct regmap *regmap; | ||
204 | 249 | ||
205 | struct delayed_work disable_work; | 250 | struct delayed_work disable_work; |
206 | int deferred_disables; | 251 | int deferred_disables; |
@@ -210,9 +255,9 @@ struct regulator_dev { | |||
210 | struct dentry *debugfs; | 255 | struct dentry *debugfs; |
211 | }; | 256 | }; |
212 | 257 | ||
213 | struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, | 258 | struct regulator_dev * |
214 | struct device *dev, const struct regulator_init_data *init_data, | 259 | regulator_register(const struct regulator_desc *regulator_desc, |
215 | void *driver_data, struct device_node *of_node); | 260 | const struct regulator_config *config); |
216 | void regulator_unregister(struct regulator_dev *rdev); | 261 | void regulator_unregister(struct regulator_dev *rdev); |
217 | 262 | ||
218 | int regulator_notifier_call_chain(struct regulator_dev *rdev, | 263 | int regulator_notifier_call_chain(struct regulator_dev *rdev, |
@@ -224,6 +269,18 @@ int rdev_get_id(struct regulator_dev *rdev); | |||
224 | 269 | ||
225 | int regulator_mode_to_status(unsigned int); | 270 | int regulator_mode_to_status(unsigned int); |
226 | 271 | ||
272 | int regulator_list_voltage_linear(struct regulator_dev *rdev, | ||
273 | unsigned int selector); | ||
274 | int regulator_map_voltage_linear(struct regulator_dev *rdev, | ||
275 | int min_uV, int max_uV); | ||
276 | int regulator_map_voltage_iterate(struct regulator_dev *rdev, | ||
277 | int min_uV, int max_uV); | ||
278 | int regulator_get_voltage_sel_regmap(struct regulator_dev *rdev); | ||
279 | int regulator_set_voltage_sel_regmap(struct regulator_dev *rdev, unsigned sel); | ||
280 | int regulator_is_enabled_regmap(struct regulator_dev *rdev); | ||
281 | int regulator_enable_regmap(struct regulator_dev *rdev); | ||
282 | int regulator_disable_regmap(struct regulator_dev *rdev); | ||
283 | |||
227 | void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); | 284 | void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); |
228 | 285 | ||
229 | #endif | 286 | #endif |
diff --git a/include/linux/regulator/fixed.h b/include/linux/regulator/fixed.h index 936a7d8c11a9..f83f7440b488 100644 --- a/include/linux/regulator/fixed.h +++ b/include/linux/regulator/fixed.h | |||
@@ -26,6 +26,12 @@ struct regulator_init_data; | |||
26 | * @gpio: GPIO to use for enable control | 26 | * @gpio: GPIO to use for enable control |
27 | * set to -EINVAL if not used | 27 | * set to -EINVAL if not used |
28 | * @startup_delay: Start-up time in microseconds | 28 | * @startup_delay: Start-up time in microseconds |
29 | * @gpio_is_open_drain: Gpio pin is open drain or normal type. | ||
30 | * If it is open drain type then HIGH will be set | ||
31 | * through PULL-UP with setting gpio as input | ||
32 | * and low will be set as gpio-output with driven | ||
33 | * to low. For non-open-drain case, the gpio will | ||
34 | * will be in output and drive to low/high accordingly. | ||
29 | * @enable_high: Polarity of enable GPIO | 35 | * @enable_high: Polarity of enable GPIO |
30 | * 1 = Active high, 0 = Active low | 36 | * 1 = Active high, 0 = Active low |
31 | * @enabled_at_boot: Whether regulator has been enabled at | 37 | * @enabled_at_boot: Whether regulator has been enabled at |
@@ -43,6 +49,7 @@ struct fixed_voltage_config { | |||
43 | int microvolts; | 49 | int microvolts; |
44 | int gpio; | 50 | int gpio; |
45 | unsigned startup_delay; | 51 | unsigned startup_delay; |
52 | unsigned gpio_is_open_drain:1; | ||
46 | unsigned enable_high:1; | 53 | unsigned enable_high:1; |
47 | unsigned enabled_at_boot:1; | 54 | unsigned enabled_at_boot:1; |
48 | struct regulator_init_data *init_data; | 55 | struct regulator_init_data *init_data; |
diff --git a/include/linux/regulator/of_regulator.h b/include/linux/regulator/of_regulator.h index 769704f296e5..f9217965aaa3 100644 --- a/include/linux/regulator/of_regulator.h +++ b/include/linux/regulator/of_regulator.h | |||
@@ -6,10 +6,20 @@ | |||
6 | #ifndef __LINUX_OF_REG_H | 6 | #ifndef __LINUX_OF_REG_H |
7 | #define __LINUX_OF_REG_H | 7 | #define __LINUX_OF_REG_H |
8 | 8 | ||
9 | struct of_regulator_match { | ||
10 | const char *name; | ||
11 | void *driver_data; | ||
12 | struct regulator_init_data *init_data; | ||
13 | struct device_node *of_node; | ||
14 | }; | ||
15 | |||
9 | #if defined(CONFIG_OF) | 16 | #if defined(CONFIG_OF) |
10 | extern struct regulator_init_data | 17 | extern struct regulator_init_data |
11 | *of_get_regulator_init_data(struct device *dev, | 18 | *of_get_regulator_init_data(struct device *dev, |
12 | struct device_node *node); | 19 | struct device_node *node); |
20 | extern int of_regulator_match(struct device *dev, struct device_node *node, | ||
21 | struct of_regulator_match *matches, | ||
22 | unsigned int num_matches); | ||
13 | #else | 23 | #else |
14 | static inline struct regulator_init_data | 24 | static inline struct regulator_init_data |
15 | *of_get_regulator_init_data(struct device *dev, | 25 | *of_get_regulator_init_data(struct device *dev, |
@@ -17,6 +27,14 @@ static inline struct regulator_init_data | |||
17 | { | 27 | { |
18 | return NULL; | 28 | return NULL; |
19 | } | 29 | } |
30 | |||
31 | static inline int of_regulator_match(struct device *dev, | ||
32 | struct device_node *node, | ||
33 | struct of_regulator_match *matches, | ||
34 | unsigned int num_matches) | ||
35 | { | ||
36 | return 0; | ||
37 | } | ||
20 | #endif /* CONFIG_OF */ | 38 | #endif /* CONFIG_OF */ |
21 | 39 | ||
22 | #endif /* __LINUX_OF_REG_H */ | 40 | #endif /* __LINUX_OF_REG_H */ |
diff --git a/include/linux/regulator/tps62360.h b/include/linux/regulator/tps62360.h index 6a5c1b2c751e..a4c49394c497 100644 --- a/include/linux/regulator/tps62360.h +++ b/include/linux/regulator/tps62360.h | |||
@@ -26,13 +26,10 @@ | |||
26 | #ifndef __LINUX_REGULATOR_TPS62360_H | 26 | #ifndef __LINUX_REGULATOR_TPS62360_H |
27 | #define __LINUX_REGULATOR_TPS62360_H | 27 | #define __LINUX_REGULATOR_TPS62360_H |
28 | 28 | ||
29 | #include <linux/regulator/machine.h> | ||
30 | |||
31 | /* | 29 | /* |
32 | * struct tps62360_regulator_platform_data - tps62360 regulator platform data. | 30 | * struct tps62360_regulator_platform_data - tps62360 regulator platform data. |
33 | * | 31 | * |
34 | * @reg_init_data: The regulator init data. | 32 | * @reg_init_data: The regulator init data. |
35 | * @en_force_pwm: Enable force pwm or not. | ||
36 | * @en_discharge: Enable discharge the output capacitor via internal | 33 | * @en_discharge: Enable discharge the output capacitor via internal |
37 | * register. | 34 | * register. |
38 | * @en_internal_pulldn: internal pull down enable or not. | 35 | * @en_internal_pulldn: internal pull down enable or not. |
@@ -44,8 +41,7 @@ | |||
44 | * @vsel1_def_state: Default state of vsel1. 1 if it is high else 0. | 41 | * @vsel1_def_state: Default state of vsel1. 1 if it is high else 0. |
45 | */ | 42 | */ |
46 | struct tps62360_regulator_platform_data { | 43 | struct tps62360_regulator_platform_data { |
47 | struct regulator_init_data reg_init_data; | 44 | struct regulator_init_data *reg_init_data; |
48 | bool en_force_pwm; | ||
49 | bool en_discharge; | 45 | bool en_discharge; |
50 | bool en_internal_pulldn; | 46 | bool en_internal_pulldn; |
51 | int vsel0_gpio; | 47 | int vsel0_gpio; |
diff --git a/include/linux/regulator/tps65090-regulator.h b/include/linux/regulator/tps65090-regulator.h new file mode 100644 index 000000000000..0fa04b64db3e --- /dev/null +++ b/include/linux/regulator/tps65090-regulator.h | |||
@@ -0,0 +1,50 @@ | |||
1 | /* | ||
2 | * Regulator driver interface for TI TPS65090 PMIC family | ||
3 | * | ||
4 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | ||
5 | |||
6 | * This program is free software; you can redistribute it and/or modify it | ||
7 | * under the terms and conditions of the GNU General Public License, | ||
8 | * version 2, as published by the Free Software Foundation. | ||
9 | |||
10 | * This program is distributed in the hope it will be useful, but WITHOUT | ||
11 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
12 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
13 | * more details. | ||
14 | |||
15 | * You should have received a copy of the GNU General Public License | ||
16 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
17 | */ | ||
18 | |||
19 | #ifndef __REGULATOR_TPS65090_H | ||
20 | #define __REGULATOR_TPS65090_H | ||
21 | |||
22 | #include <linux/regulator/machine.h> | ||
23 | |||
24 | #define tps65090_rails(_name) "tps65090_"#_name | ||
25 | |||
26 | enum { | ||
27 | TPS65090_ID_DCDC1, | ||
28 | TPS65090_ID_DCDC2, | ||
29 | TPS65090_ID_DCDC3, | ||
30 | TPS65090_ID_FET1, | ||
31 | TPS65090_ID_FET2, | ||
32 | TPS65090_ID_FET3, | ||
33 | TPS65090_ID_FET4, | ||
34 | TPS65090_ID_FET5, | ||
35 | TPS65090_ID_FET6, | ||
36 | TPS65090_ID_FET7, | ||
37 | }; | ||
38 | |||
39 | /* | ||
40 | * struct tps65090_regulator_platform_data | ||
41 | * | ||
42 | * @regulator: The regulator init data. | ||
43 | * @slew_rate_uV_per_us: Slew rate microvolt per microsec. | ||
44 | */ | ||
45 | |||
46 | struct tps65090_regulator_platform_data { | ||
47 | struct regulator_init_data regulator; | ||
48 | }; | ||
49 | |||
50 | #endif /* __REGULATOR_TPS65090_H */ | ||