Commit | Line | Data |
---|---|---|
571a354b LG |
1 | /* |
2 | * driver.h -- SoC Regulator driver support. | |
3 | * | |
4 | * Copyright (C) 2007, 2008 Wolfson Microelectronics PLC. | |
5 | * | |
6 | * Author: Liam Girdwood <lg@opensource.wolfsonmicro.com> | |
7 | * | |
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. | |
11 | * | |
12 | * Regulator Driver Interface. | |
13 | */ | |
14 | ||
15 | #ifndef __LINUX_REGULATOR_DRIVER_H_ | |
16 | #define __LINUX_REGULATOR_DRIVER_H_ | |
17 | ||
18 | #include <linux/device.h> | |
19 | #include <linux/regulator/consumer.h> | |
20 | ||
571a354b | 21 | struct regulator_dev; |
a5766f11 | 22 | struct regulator_init_data; |
571a354b LG |
23 | |
24 | /** | |
25 | * struct regulator_ops - regulator operations. | |
26 | * | |
c8e7e464 MB |
27 | * This struct describes regulator operations which can be implemented by |
28 | * regulator chip drivers. | |
29 | * | |
30 | * @enable: Enable the regulator. | |
31 | * @disable: Disable the regulator. | |
32 | * @is_enabled: Return 1 if the reguator is enabled, 0 otherwise. | |
33 | * | |
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. | |
37 | * | |
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. | |
41 | * | |
42 | * @set_current_limit: Configure a limit for a current-limited regulator. | |
43 | * @get_current_limit: Get the limit for a current-limited regulator. | |
44 | * | |
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. | |
49 | * | |
50 | * @set_suspend_voltage: Set the voltage for the regulator when the system | |
51 | * is suspended. | |
52 | * @set_suspend_enable: Mark the regulator as enabled when the system is | |
53 | * suspended. | |
54 | * @set_suspend_disable: Mark the regulator as disabled when the system is | |
55 | * suspended. | |
56 | * @set_suspend_mode: Set the operating mode for the regulator when the | |
57 | * system is suspended. | |
571a354b LG |
58 | */ |
59 | struct regulator_ops { | |
60 | ||
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 *); | |
64 | ||
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 *); | |
69 | ||
70 | /* enable/disable regulator */ | |
71 | int (*enable) (struct regulator_dev *); | |
72 | int (*disable) (struct regulator_dev *); | |
73 | int (*is_enabled) (struct regulator_dev *); | |
74 | ||
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 *); | |
78 | ||
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); | |
82 | ||
83 | /* the operations below are for configuration of regulator state when | |
3de89609 | 84 | * its parent PMIC enters a global STANDBY/HIBERNATE state */ |
571a354b LG |
85 | |
86 | /* set regulator suspend voltage */ | |
87 | int (*set_suspend_voltage) (struct regulator_dev *, int uV); | |
88 | ||
89 | /* enable/disable regulator in suspend state */ | |
90 | int (*set_suspend_enable) (struct regulator_dev *); | |
91 | int (*set_suspend_disable) (struct regulator_dev *); | |
92 | ||
93 | /* set regulator suspend operating mode (defined in regulator.h) */ | |
94 | int (*set_suspend_mode) (struct regulator_dev *, unsigned int mode); | |
95 | }; | |
96 | ||
97 | /* | |
98 | * Regulators can either control voltage or current. | |
99 | */ | |
100 | enum regulator_type { | |
101 | REGULATOR_VOLTAGE, | |
102 | REGULATOR_CURRENT, | |
103 | }; | |
104 | ||
105 | /** | |
106 | * struct regulator_desc - Regulator descriptor | |
107 | * | |
c8e7e464 MB |
108 | * Each regulator registered with the core is described with a structure of |
109 | * this type. | |
110 | * | |
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. | |
571a354b LG |
116 | */ |
117 | struct regulator_desc { | |
118 | const char *name; | |
119 | int id; | |
120 | struct regulator_ops *ops; | |
121 | int irq; | |
122 | enum regulator_type type; | |
123 | struct module *owner; | |
124 | }; | |
125 | ||
571a354b | 126 | struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc, |
a5766f11 | 127 | struct device *dev, void *driver_data); |
571a354b LG |
128 | void regulator_unregister(struct regulator_dev *rdev); |
129 | ||
130 | int regulator_notifier_call_chain(struct regulator_dev *rdev, | |
131 | unsigned long event, void *data); | |
132 | ||
133 | void *rdev_get_drvdata(struct regulator_dev *rdev); | |
a5766f11 | 134 | struct device *rdev_get_dev(struct regulator_dev *rdev); |
571a354b LG |
135 | int rdev_get_id(struct regulator_dev *rdev); |
136 | ||
a5766f11 LG |
137 | void *regulator_get_init_drvdata(struct regulator_init_data *reg_init_data); |
138 | ||
571a354b | 139 | #endif |