diff options
Diffstat (limited to 'include/linux/regulator/driver.h')
-rw-r--r-- | include/linux/regulator/driver.h | 73 |
1 files changed, 65 insertions, 8 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 |