2 * driver.h -- SoC Regulator driver support.
4 * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC.
6 * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com>
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License version 2 as
10 * published by the Free Software Foundation.
12 * Regulator Driver Interface.
15 #ifndef __LINUX_REGULATOR_DRIVER_H_
16 #define __LINUX_REGULATOR_DRIVER_H_
18 #include <linux/device.h>
19 #include <linux/regulator/consumer.h>
22 struct regulator_init_data;
25 * struct regulator_ops - regulator operations.
27 * This struct describes regulator operations which can be implemented by
28 * regulator chip drivers.
30 * @enable: Enable the regulator.
31 * @disable: Disable the regulator.
32 * @is_enabled: Return 1 if the reguator is enabled, 0 otherwise.
34 * @set_voltage: Set the voltage for the regulator within the range specified.
35 * The driver should select the voltage closest to min_uV.
36 * @get_voltage: Return the currently configured voltage for the regulator.
38 * @set_current: Set the current for the regulator within the range specified.
39 * The driver should select the current closest to min_uA.
40 * @get_current: Return the currently configured current for the regulator.
42 * @set_current_limit: Configure a limit for a current-limited regulator.
43 * @get_current_limit: Get the limit for a current-limited regulator.
45 * @set_mode: Set the operating mode for the regulator.
46 * @get_mode: Get the current operating mode for the regulator.
47 * @get_optimum_mode: Get the most efficient operating mode for the regulator
48 * when running with the specified parameters.
50 * @set_suspend_voltage: Set the voltage for the regulator when the system
52 * @set_suspend_enable: Mark the regulator as enabled when the system is
54 * @set_suspend_disable: Mark the regulator as disabled when the system is
56 * @set_suspend_mode: Set the operating mode for the regulator when the
57 * system is suspended.
59 struct regulator_ops {
61 /* get/set regulator voltage */
62 int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV);
63 int (*get_voltage) (struct regulator_dev *);
65 /* get/set regulator current */
66 int (*set_current_limit) (struct regulator_dev *,
67 int min_uA, int max_uA);
68 int (*get_current_limit) (struct regulator_dev *);
70 /* enable/disable regulator */
71 int (*enable) (struct regulator_dev *);
72 int (*disable) (struct regulator_dev *);
73 int (*is_enabled) (struct regulator_dev *);
75 /* get/set regulator operating mode (defined in regulator.h) */
76 int (*set_mode) (struct regulator_dev *, unsigned int mode);
77 unsigned int (*get_mode) (struct regulator_dev *);
79 /* get most efficient regulator operating mode for load */
80 unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,
81 int output_uV, int load_uA);
83 /* the operations below are for configuration of regulator state when
84 * its parent PMIC enters a global STANDBY/HIBERNATE state */
86 /* set regulator suspend voltage */
87 int (*set_suspend_voltage) (struct regulator_dev *, int uV);
89 /* enable/disable regulator in suspend state */
90 int (*set_suspend_enable) (struct regulator_dev *);
91 int (*set_suspend_disable) (struct regulator_dev *);
93 /* set regulator suspend operating mode (defined in regulator.h) */
94 int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode);
98 * Regulators can either control voltage or current.
100 enum regulator_type {
106 * struct regulator_desc - Regulator descriptor
108 * Each regulator registered with the core is described with a structure of
111 * @name: Identifying name for the regulator.
112 * @id: Numerical identifier for the regulator.
113 * @ops: Regulator operations table.
114 * @type: Indicates if the regulator is a voltage or current regulator.
115 * @owner: Module providing the regulator, used for refcounting.
117 struct regulator_desc {
120 struct regulator_ops *ops;
122 enum regulator_type type;
123 struct module *owner;
126 struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
127 struct device *dev, void *driver_data);
128 void regulator_unregister(struct regulator_dev *rdev);
130 int regulator_notifier_call_chain(struct regulator_dev *rdev,
131 unsigned long event, void *data);
133 void *rdev_get_drvdata(struct regulator_dev *rdev);
134 struct device *rdev_get_dev(struct regulator_dev *rdev);
135 int rdev_get_id(struct regulator_dev *rdev);
137 void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data);