aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/ABI/testing/sysfs-class-regulator136
-rw-r--r--Documentation/DocBook/Makefile2
-rw-r--r--Documentation/DocBook/regulator.tmpl304
-rw-r--r--drivers/Makefile4
-rw-r--r--drivers/regulator/core.c474
-rw-r--r--drivers/regulator/da903x.c12
-rw-r--r--include/linux/regulator/consumer.h8
-rw-r--r--include/linux/regulator/driver.h37
-rw-r--r--include/linux/regulator/machine.h41
9 files changed, 746 insertions, 272 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-regulator b/Documentation/ABI/testing/sysfs-class-regulator
index 3731f6f29bcb..873ef1fc1569 100644
--- a/Documentation/ABI/testing/sysfs-class-regulator
+++ b/Documentation/ABI/testing/sysfs-class-regulator
@@ -3,8 +3,9 @@ Date: April 2008
3KernelVersion: 2.6.26 3KernelVersion: 2.6.26
4Contact: Liam Girdwood <lrg@slimlogic.co.uk> 4Contact: Liam Girdwood <lrg@slimlogic.co.uk>
5Description: 5Description:
6 Each regulator directory will contain a field called 6 Some regulator directories will contain a field called
7 state. This holds the regulator output state. 7 state. This reports the regulator enable status, for
8 regulators which can report that value.
8 9
9 This will be one of the following strings: 10 This will be one of the following strings:
10 11
@@ -18,7 +19,8 @@ Description:
18 'disabled' means the regulator output is OFF and is not 19 'disabled' means the regulator output is OFF and is not
19 supplying power to the system.. 20 supplying power to the system..
20 21
21 'unknown' means software cannot determine the state. 22 'unknown' means software cannot determine the state, or
23 the reported state is invalid.
22 24
23 NOTE: this field can be used in conjunction with microvolts 25 NOTE: this field can be used in conjunction with microvolts
24 and microamps to determine regulator output levels. 26 and microamps to determine regulator output levels.
@@ -53,9 +55,10 @@ Date: April 2008
53KernelVersion: 2.6.26 55KernelVersion: 2.6.26
54Contact: Liam Girdwood <lrg@slimlogic.co.uk> 56Contact: Liam Girdwood <lrg@slimlogic.co.uk>
55Description: 57Description:
56 Each regulator directory will contain a field called 58 Some regulator directories will contain a field called
57 microvolts. This holds the regulator output voltage setting 59 microvolts. This holds the regulator output voltage setting
58 measured in microvolts (i.e. E-6 Volts). 60 measured in microvolts (i.e. E-6 Volts), for regulators
61 which can report that voltage.
59 62
60 NOTE: This value should not be used to determine the regulator 63 NOTE: This value should not be used to determine the regulator
61 output voltage level as this value is the same regardless of 64 output voltage level as this value is the same regardless of
@@ -67,9 +70,10 @@ Date: April 2008
67KernelVersion: 2.6.26 70KernelVersion: 2.6.26
68Contact: Liam Girdwood <lrg@slimlogic.co.uk> 71Contact: Liam Girdwood <lrg@slimlogic.co.uk>
69Description: 72Description:
70 Each regulator directory will contain a field called 73 Some regulator directories will contain a field called
71 microamps. This holds the regulator output current limit 74 microamps. This holds the regulator output current limit
72 setting measured in microamps (i.e. E-6 Amps). 75 setting measured in microamps (i.e. E-6 Amps), for regulators
76 which can report that current.
73 77
74 NOTE: This value should not be used to determine the regulator 78 NOTE: This value should not be used to determine the regulator
75 output current level as this value is the same regardless of 79 output current level as this value is the same regardless of
@@ -81,8 +85,9 @@ Date: April 2008
81KernelVersion: 2.6.26 85KernelVersion: 2.6.26
82Contact: Liam Girdwood <lrg@slimlogic.co.uk> 86Contact: Liam Girdwood <lrg@slimlogic.co.uk>
83Description: 87Description:
84 Each regulator directory will contain a field called 88 Some regulator directories will contain a field called
85 opmode. This holds the regulator operating mode setting. 89 opmode. This holds the current regulator operating mode,
90 for regulators which can report it.
86 91
87 The opmode value can be one of the following strings: 92 The opmode value can be one of the following strings:
88 93
@@ -92,7 +97,7 @@ Description:
92 'standby' 97 'standby'
93 'unknown' 98 'unknown'
94 99
95 The modes are described in include/linux/regulator/regulator.h 100 The modes are described in include/linux/regulator/consumer.h
96 101
97 NOTE: This value should not be used to determine the regulator 102 NOTE: This value should not be used to determine the regulator
98 output operating mode as this value is the same regardless of 103 output operating mode as this value is the same regardless of
@@ -104,9 +109,10 @@ Date: April 2008
104KernelVersion: 2.6.26 109KernelVersion: 2.6.26
105Contact: Liam Girdwood <lrg@slimlogic.co.uk> 110Contact: Liam Girdwood <lrg@slimlogic.co.uk>
106Description: 111Description:
107 Each regulator directory will contain a field called 112 Some regulator directories will contain a field called
108 min_microvolts. This holds the minimum safe working regulator 113 min_microvolts. This holds the minimum safe working regulator
109 output voltage setting for this domain measured in microvolts. 114 output voltage setting for this domain measured in microvolts,
115 for regulators which support voltage constraints.
110 116
111 NOTE: this will return the string 'constraint not defined' if 117 NOTE: this will return the string 'constraint not defined' if
112 the power domain has no min microvolts constraint defined by 118 the power domain has no min microvolts constraint defined by
@@ -118,9 +124,10 @@ Date: April 2008
118KernelVersion: 2.6.26 124KernelVersion: 2.6.26
119Contact: Liam Girdwood <lrg@slimlogic.co.uk> 125Contact: Liam Girdwood <lrg@slimlogic.co.uk>
120Description: 126Description:
121 Each regulator directory will contain a field called 127 Some regulator directories will contain a field called
122 max_microvolts. This holds the maximum safe working regulator 128 max_microvolts. This holds the maximum safe working regulator
123 output voltage setting for this domain measured in microvolts. 129 output voltage setting for this domain measured in microvolts,
130 for regulators which support voltage constraints.
124 131
125 NOTE: this will return the string 'constraint not defined' if 132 NOTE: this will return the string 'constraint not defined' if
126 the power domain has no max microvolts constraint defined by 133 the power domain has no max microvolts constraint defined by
@@ -132,10 +139,10 @@ Date: April 2008
132KernelVersion: 2.6.26 139KernelVersion: 2.6.26
133Contact: Liam Girdwood <lrg@slimlogic.co.uk> 140Contact: Liam Girdwood <lrg@slimlogic.co.uk>
134Description: 141Description:
135 Each regulator directory will contain a field called 142 Some regulator directories will contain a field called
136 min_microamps. This holds the minimum safe working regulator 143 min_microamps. This holds the minimum safe working regulator
137 output current limit setting for this domain measured in 144 output current limit setting for this domain measured in
138 microamps. 145 microamps, for regulators which support current constraints.
139 146
140 NOTE: this will return the string 'constraint not defined' if 147 NOTE: this will return the string 'constraint not defined' if
141 the power domain has no min microamps constraint defined by 148 the power domain has no min microamps constraint defined by
@@ -147,10 +154,10 @@ Date: April 2008
147KernelVersion: 2.6.26 154KernelVersion: 2.6.26
148Contact: Liam Girdwood <lrg@slimlogic.co.uk> 155Contact: Liam Girdwood <lrg@slimlogic.co.uk>
149Description: 156Description:
150 Each regulator directory will contain a field called 157 Some regulator directories will contain a field called
151 max_microamps. This holds the maximum safe working regulator 158 max_microamps. This holds the maximum safe working regulator
152 output current limit setting for this domain measured in 159 output current limit setting for this domain measured in
153 microamps. 160 microamps, for regulators which support current constraints.
154 161
155 NOTE: this will return the string 'constraint not defined' if 162 NOTE: this will return the string 'constraint not defined' if
156 the power domain has no max microamps constraint defined by 163 the power domain has no max microamps constraint defined by
@@ -185,7 +192,7 @@ Date: April 2008
185KernelVersion: 2.6.26 192KernelVersion: 2.6.26
186Contact: Liam Girdwood <lrg@slimlogic.co.uk> 193Contact: Liam Girdwood <lrg@slimlogic.co.uk>
187Description: 194Description:
188 Each regulator directory will contain a field called 195 Some regulator directories will contain a field called
189 requested_microamps. This holds the total requested load 196 requested_microamps. This holds the total requested load
190 current in microamps for this regulator from all its consumer 197 current in microamps for this regulator from all its consumer
191 devices. 198 devices.
@@ -204,125 +211,102 @@ Date: May 2008
204KernelVersion: 2.6.26 211KernelVersion: 2.6.26
205Contact: Liam Girdwood <lrg@slimlogic.co.uk> 212Contact: Liam Girdwood <lrg@slimlogic.co.uk>
206Description: 213Description:
207 Each regulator directory will contain a field called 214 Some regulator directories will contain a field called
208 suspend_mem_microvolts. This holds the regulator output 215 suspend_mem_microvolts. This holds the regulator output
209 voltage setting for this domain measured in microvolts when 216 voltage setting for this domain measured in microvolts when
210 the system is suspended to memory. 217 the system is suspended to memory, for voltage regulators
211 218 implementing suspend voltage configuration constraints.
212 NOTE: this will return the string 'not defined' if
213 the power domain has no suspend to memory voltage defined by
214 platform code.
215 219
216What: /sys/class/regulator/.../suspend_disk_microvolts 220What: /sys/class/regulator/.../suspend_disk_microvolts
217Date: May 2008 221Date: May 2008
218KernelVersion: 2.6.26 222KernelVersion: 2.6.26
219Contact: Liam Girdwood <lrg@slimlogic.co.uk> 223Contact: Liam Girdwood <lrg@slimlogic.co.uk>
220Description: 224Description:
221 Each regulator directory will contain a field called 225 Some regulator directories will contain a field called
222 suspend_disk_microvolts. This holds the regulator output 226 suspend_disk_microvolts. This holds the regulator output
223 voltage setting for this domain measured in microvolts when 227 voltage setting for this domain measured in microvolts when
224 the system is suspended to disk. 228 the system is suspended to disk, for voltage regulators
225 229 implementing suspend voltage configuration constraints.
226 NOTE: this will return the string 'not defined' if
227 the power domain has no suspend to disk voltage defined by
228 platform code.
229 230
230What: /sys/class/regulator/.../suspend_standby_microvolts 231What: /sys/class/regulator/.../suspend_standby_microvolts
231Date: May 2008 232Date: May 2008
232KernelVersion: 2.6.26 233KernelVersion: 2.6.26
233Contact: Liam Girdwood <lrg@slimlogic.co.uk> 234Contact: Liam Girdwood <lrg@slimlogic.co.uk>
234Description: 235Description:
235 Each regulator directory will contain a field called 236 Some regulator directories will contain a field called
236 suspend_standby_microvolts. This holds the regulator output 237 suspend_standby_microvolts. This holds the regulator output
237 voltage setting for this domain measured in microvolts when 238 voltage setting for this domain measured in microvolts when
238 the system is suspended to standby. 239 the system is suspended to standby, for voltage regulators
239 240 implementing suspend voltage configuration constraints.
240 NOTE: this will return the string 'not defined' if
241 the power domain has no suspend to standby voltage defined by
242 platform code.
243 241
244What: /sys/class/regulator/.../suspend_mem_mode 242What: /sys/class/regulator/.../suspend_mem_mode
245Date: May 2008 243Date: May 2008
246KernelVersion: 2.6.26 244KernelVersion: 2.6.26
247Contact: Liam Girdwood <lrg@slimlogic.co.uk> 245Contact: Liam Girdwood <lrg@slimlogic.co.uk>
248Description: 246Description:
249 Each regulator directory will contain a field called 247 Some regulator directories will contain a field called
250 suspend_mem_mode. This holds the regulator operating mode 248 suspend_mem_mode. This holds the regulator operating mode
251 setting for this domain when the system is suspended to 249 setting for this domain when the system is suspended to
252 memory. 250 memory, for regulators implementing suspend mode
253 251 configuration constraints.
254 NOTE: this will return the string 'not defined' if
255 the power domain has no suspend to memory mode defined by
256 platform code.
257 252
258What: /sys/class/regulator/.../suspend_disk_mode 253What: /sys/class/regulator/.../suspend_disk_mode
259Date: May 2008 254Date: May 2008
260KernelVersion: 2.6.26 255KernelVersion: 2.6.26
261Contact: Liam Girdwood <lrg@slimlogic.co.uk> 256Contact: Liam Girdwood <lrg@slimlogic.co.uk>
262Description: 257Description:
263 Each regulator directory will contain a field called 258 Some regulator directories will contain a field called
264 suspend_disk_mode. This holds the regulator operating mode 259 suspend_disk_mode. This holds the regulator operating mode
265 setting for this domain when the system is suspended to disk. 260 setting for this domain when the system is suspended to disk,
266 261 for regulators implementing suspend mode configuration
267 NOTE: this will return the string 'not defined' if 262 constraints.
268 the power domain has no suspend to disk mode defined by
269 platform code.
270 263
271What: /sys/class/regulator/.../suspend_standby_mode 264What: /sys/class/regulator/.../suspend_standby_mode
272Date: May 2008 265Date: May 2008
273KernelVersion: 2.6.26 266KernelVersion: 2.6.26
274Contact: Liam Girdwood <lrg@slimlogic.co.uk> 267Contact: Liam Girdwood <lrg@slimlogic.co.uk>
275Description: 268Description:
276 Each regulator directory will contain a field called 269 Some regulator directories will contain a field called
277 suspend_standby_mode. This holds the regulator operating mode 270 suspend_standby_mode. This holds the regulator operating mode
278 setting for this domain when the system is suspended to 271 setting for this domain when the system is suspended to
279 standby. 272 standby, for regulators implementing suspend mode
280 273 configuration constraints.
281 NOTE: this will return the string 'not defined' if
282 the power domain has no suspend to standby mode defined by
283 platform code.
284 274
285What: /sys/class/regulator/.../suspend_mem_state 275What: /sys/class/regulator/.../suspend_mem_state
286Date: May 2008 276Date: May 2008
287KernelVersion: 2.6.26 277KernelVersion: 2.6.26
288Contact: Liam Girdwood <lrg@slimlogic.co.uk> 278Contact: Liam Girdwood <lrg@slimlogic.co.uk>
289Description: 279Description:
290 Each regulator directory will contain a field called 280 Some regulator directories will contain a field called
291 suspend_mem_state. This holds the regulator operating state 281 suspend_mem_state. This holds the regulator operating state
292 when suspended to memory. 282 when suspended to memory, for regulators implementing suspend
293 283 configuration constraints.
294 This will be one of the following strings:
295 284
296 'enabled' 285 This will be one of the same strings reported by
297 'disabled' 286 the "state" attribute.
298 'not defined'
299 287
300What: /sys/class/regulator/.../suspend_disk_state 288What: /sys/class/regulator/.../suspend_disk_state
301Date: May 2008 289Date: May 2008
302KernelVersion: 2.6.26 290KernelVersion: 2.6.26
303Contact: Liam Girdwood <lrg@slimlogic.co.uk> 291Contact: Liam Girdwood <lrg@slimlogic.co.uk>
304Description: 292Description:
305 Each regulator directory will contain a field called 293 Some regulator directories will contain a field called
306 suspend_disk_state. This holds the regulator operating state 294 suspend_disk_state. This holds the regulator operating state
307 when suspended to disk. 295 when suspended to disk, for regulators implementing
308 296 suspend configuration constraints.
309 This will be one of the following strings:
310 297
311 'enabled' 298 This will be one of the same strings reported by
312 'disabled' 299 the "state" attribute.
313 'not defined'
314 300
315What: /sys/class/regulator/.../suspend_standby_state 301What: /sys/class/regulator/.../suspend_standby_state
316Date: May 2008 302Date: May 2008
317KernelVersion: 2.6.26 303KernelVersion: 2.6.26
318Contact: Liam Girdwood <lrg@slimlogic.co.uk> 304Contact: Liam Girdwood <lrg@slimlogic.co.uk>
319Description: 305Description:
320 Each regulator directory will contain a field called 306 Some regulator directories will contain a field called
321 suspend_standby_state. This holds the regulator operating 307 suspend_standby_state. This holds the regulator operating
322 state when suspended to standby. 308 state when suspended to standby, for regulators implementing
323 309 suspend configuration constraints.
324 This will be one of the following strings:
325 310
326 'enabled' 311 This will be one of the same strings reported by
327 'disabled' 312 the "state" attribute.
328 'not defined'
diff --git a/Documentation/DocBook/Makefile b/Documentation/DocBook/Makefile
index 0a08126d3094..dc3154e49279 100644
--- a/Documentation/DocBook/Makefile
+++ b/Documentation/DocBook/Makefile
@@ -12,7 +12,7 @@ DOCBOOKS := z8530book.xml mcabook.xml \
12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \ 12 kernel-api.xml filesystems.xml lsm.xml usb.xml kgdb.xml \
13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \ 13 gadget.xml libata.xml mtdnand.xml librs.xml rapidio.xml \
14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \ 14 genericirq.xml s390-drivers.xml uio-howto.xml scsi.xml \
15 mac80211.xml debugobjects.xml sh.xml 15 mac80211.xml debugobjects.xml sh.xml regulator.xml
16 16
17### 17###
18# The build process is as follows (targets): 18# The build process is as follows (targets):
diff --git a/Documentation/DocBook/regulator.tmpl b/Documentation/DocBook/regulator.tmpl
new file mode 100644
index 000000000000..53f4f8d3b810
--- /dev/null
+++ b/Documentation/DocBook/regulator.tmpl
@@ -0,0 +1,304 @@
1<?xml version="1.0" encoding="UTF-8"?>
2<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" []>
4
5<book id="regulator-api">
6 <bookinfo>
7 <title>Voltage and current regulator API</title>
8
9 <authorgroup>
10 <author>
11 <firstname>Liam</firstname>
12 <surname>Girdwood</surname>
13 <affiliation>
14 <address>
15 <email>lrg@slimlogic.co.uk</email>
16 </address>
17 </affiliation>
18 </author>
19 <author>
20 <firstname>Mark</firstname>
21 <surname>Brown</surname>
22 <affiliation>
23 <orgname>Wolfson Microelectronics</orgname>
24 <address>
25 <email>broonie@opensource.wolfsonmicro.com</email>
26 </address>
27 </affiliation>
28 </author>
29 </authorgroup>
30
31 <copyright>
32 <year>2007-2008</year>
33 <holder>Wolfson Microelectronics</holder>
34 </copyright>
35 <copyright>
36 <year>2008</year>
37 <holder>Liam Girdwood</holder>
38 </copyright>
39
40 <legalnotice>
41 <para>
42 This documentation is free software; you can redistribute
43 it and/or modify it under the terms of the GNU General Public
44 License version 2 as published by the Free Software Foundation.
45 </para>
46
47 <para>
48 This program is distributed in the hope that it will be
49 useful, but WITHOUT ANY WARRANTY; without even the implied
50 warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
51 See the GNU General Public License for more details.
52 </para>
53
54 <para>
55 You should have received a copy of the GNU General Public
56 License along with this program; if not, write to the Free
57 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
58 MA 02111-1307 USA
59 </para>
60
61 <para>
62 For more details see the file COPYING in the source
63 distribution of Linux.
64 </para>
65 </legalnotice>
66 </bookinfo>
67
68<toc></toc>
69
70 <chapter id="intro">
71 <title>Introduction</title>
72 <para>
73 This framework is designed to provide a standard kernel
74 interface to control voltage and current regulators.
75 </para>
76 <para>
77 The intention is to allow systems to dynamically control
78 regulator power output in order to save power and prolong
79 battery life. This applies to both voltage regulators (where
80 voltage output is controllable) and current sinks (where current
81 limit is controllable).
82 </para>
83 <para>
84 Note that additional (and currently more complete) documentation
85 is available in the Linux kernel source under
86 <filename>Documentation/power/regulator</filename>.
87 </para>
88
89 <sect1 id="glossary">
90 <title>Glossary</title>
91 <para>
92 The regulator API uses a number of terms which may not be
93 familiar:
94 </para>
95 <glossary>
96
97 <glossentry>
98 <glossterm>Regulator</glossterm>
99 <glossdef>
100 <para>
101 Electronic device that supplies power to other devices. Most
102 regulators can enable and disable their output and some can also
103 control their output voltage or current.
104 </para>
105 </glossdef>
106 </glossentry>
107
108 <glossentry>
109 <glossterm>Consumer</glossterm>
110 <glossdef>
111 <para>
112 Electronic device which consumes power provided by a regulator.
113 These may either be static, requiring only a fixed supply, or
114 dynamic, requiring active management of the regulator at
115 runtime.
116 </para>
117 </glossdef>
118 </glossentry>
119
120 <glossentry>
121 <glossterm>Power Domain</glossterm>
122 <glossdef>
123 <para>
124 The electronic circuit supplied by a given regulator, including
125 the regulator and all consumer devices. The configuration of
126 the regulator is shared between all the components in the
127 circuit.
128 </para>
129 </glossdef>
130 </glossentry>
131
132 <glossentry>
133 <glossterm>Power Management Integrated Circuit</glossterm>
134 <acronym>PMIC</acronym>
135 <glossdef>
136 <para>
137 An IC which contains numerous regulators and often also other
138 subsystems. In an embedded system the primary PMIC is often
139 equivalent to a combination of the PSU and southbridge in a
140 desktop system.
141 </para>
142 </glossdef>
143 </glossentry>
144 </glossary>
145 </sect1>
146 </chapter>
147
148 <chapter id="consumer">
149 <title>Consumer driver interface</title>
150 <para>
151 This offers a similar API to the kernel clock framework.
152 Consumer drivers use <link
153 linkend='API-regulator-get'>get</link> and <link
154 linkend='API-regulator-put'>put</link> operations to acquire and
155 release regulators. Functions are
156 provided to <link linkend='API-regulator-enable'>enable</link>
157 and <link linkend='API-regulator-disable'>disable</link> the
158 reguator and to get and set the runtime parameters of the
159 regulator.
160 </para>
161 <para>
162 When requesting regulators consumers use symbolic names for their
163 supplies, such as "Vcc", which are mapped into actual regulator
164 devices by the machine interface.
165 </para>
166 <para>
167 A stub version of this API is provided when the regulator
168 framework is not in use in order to minimise the need to use
169 ifdefs.
170 </para>
171
172 <sect1 id="consumer-enable">
173 <title>Enabling and disabling</title>
174 <para>
175 The regulator API provides reference counted enabling and
176 disabling of regulators. Consumer devices use the <function><link
177 linkend='API-regulator-enable'>regulator_enable</link></function>
178 and <function><link
179 linkend='API-regulator-disable'>regulator_disable</link>
180 </function> functions to enable and disable regulators. Calls
181 to the two functions must be balanced.
182 </para>
183 <para>
184 Note that since multiple consumers may be using a regulator and
185 machine constraints may not allow the regulator to be disabled
186 there is no guarantee that calling
187 <function>regulator_disable</function> will actually cause the
188 supply provided by the regulator to be disabled. Consumer
189 drivers should assume that the regulator may be enabled at all
190 times.
191 </para>
192 </sect1>
193
194 <sect1 id="consumer-config">
195 <title>Configuration</title>
196 <para>
197 Some consumer devices may need to be able to dynamically
198 configure their supplies. For example, MMC drivers may need to
199 select the correct operating voltage for their cards. This may
200 be done while the regulator is enabled or disabled.
201 </para>
202 <para>
203 The <function><link
204 linkend='API-regulator-set-voltage'>regulator_set_voltage</link>
205 </function> and <function><link
206 linkend='API-regulator-set-current-limit'
207 >regulator_set_current_limit</link>
208 </function> functions provide the primary interface for this.
209 Both take ranges of voltages and currents, supporting drivers
210 that do not require a specific value (eg, CPU frequency scaling
211 normally permits the CPU to use a wider range of supply
212 voltages at lower frequencies but does not require that the
213 supply voltage be lowered). Where an exact value is required
214 both minimum and maximum values should be identical.
215 </para>
216 </sect1>
217
218 <sect1 id="consumer-callback">
219 <title>Callbacks</title>
220 <para>
221 Callbacks may also be <link
222 linkend='API-regulator-register-notifier'>registered</link>
223 for events such as regulation failures.
224 </para>
225 </sect1>
226 </chapter>
227
228 <chapter id="driver">
229 <title>Regulator driver interface</title>
230 <para>
231 Drivers for regulator chips <link
232 linkend='API-regulator-register'>register</link> the regulators
233 with the regulator core, providing operations structures to the
234 core. A <link
235 linkend='API-regulator-notifier-call-chain'>notifier</link> interface
236 allows error conditions to be reported to the core.
237 </para>
238 <para>
239 Registration should be triggered by explicit setup done by the
240 platform, supplying a <link
241 linkend='API-struct-regulator-init-data'>struct
242 regulator_init_data</link> for the regulator containing
243 <link linkend='machine-constraint'>constraint</link> and
244 <link linkend='machine-supply'>supply</link> information.
245 </para>
246 </chapter>
247
248 <chapter id="machine">
249 <title>Machine interface</title>
250 <para>
251 This interface provides a way to define how regulators are
252 connected to consumers on a given system and what the valid
253 operating parameters are for the system.
254 </para>
255
256 <sect1 id="machine-supply">
257 <title>Supplies</title>
258 <para>
259 Regulator supplies are specified using <link
260 linkend='API-struct-regulator-consumer-supply'>struct
261 regulator_consumer_supply</link>. This is done at
262 <link linkend='driver'>driver registration
263 time</link> as part of the machine constraints.
264 </para>
265 </sect1>
266
267 <sect1 id="machine-constraint">
268 <title>Constraints</title>
269 <para>
270 As well as definining the connections the machine interface
271 also provides constraints definining the operations that
272 clients are allowed to perform and the parameters that may be
273 set. This is required since generally regulator devices will
274 offer more flexibility than it is safe to use on a given
275 system, for example supporting higher supply voltages than the
276 consumers are rated for.
277 </para>
278 <para>
279 This is done at <link linkend='driver'>driver
280 registration time</link> by providing a <link
281 linkend='API-struct-regulation-constraints'>struct
282 regulation_constraints</link>.
283 </para>
284 <para>
285 The constraints may also specify an initial configuration for the
286 regulator in the constraints, which is particularly useful for
287 use with static consumers.
288 </para>
289 </sect1>
290 </chapter>
291
292 <chapter id="api">
293 <title>API reference</title>
294 <para>
295 Due to limitations of the kernel documentation framework and the
296 existing layout of the source code the entire regulator API is
297 documented here.
298 </para>
299!Iinclude/linux/regulator/consumer.h
300!Iinclude/linux/regulator/machine.h
301!Iinclude/linux/regulator/driver.h
302!Edrivers/regulator/core.c
303 </chapter>
304</book>
diff --git a/drivers/Makefile b/drivers/Makefile
index e121b66ef082..6326f4dbbdab 100644
--- a/drivers/Makefile
+++ b/drivers/Makefile
@@ -18,6 +18,9 @@ obj-$(CONFIG_ARM_AMBA) += amba/
18 18
19obj-$(CONFIG_XEN) += xen/ 19obj-$(CONFIG_XEN) += xen/
20 20
21# regulators early, since some subsystems rely on them to initialize
22obj-$(CONFIG_REGULATOR) += regulator/
23
21# char/ comes before serial/ etc so that the VT console is the boot-time 24# char/ comes before serial/ etc so that the VT console is the boot-time
22# default. 25# default.
23obj-y += char/ 26obj-y += char/
@@ -101,5 +104,4 @@ obj-$(CONFIG_PPC_PS3) += ps3/
101obj-$(CONFIG_OF) += of/ 104obj-$(CONFIG_OF) += of/
102obj-$(CONFIG_SSB) += ssb/ 105obj-$(CONFIG_SSB) += ssb/
103obj-$(CONFIG_VIRTIO) += virtio/ 106obj-$(CONFIG_VIRTIO) += virtio/
104obj-$(CONFIG_REGULATOR) += regulator/
105obj-$(CONFIG_STAGING) += staging/ 107obj-$(CONFIG_STAGING) += staging/
diff --git a/drivers/regulator/core.c b/drivers/regulator/core.c
index 02a774424e8d..f511a406fcaa 100644
--- a/drivers/regulator/core.c
+++ b/drivers/regulator/core.c
@@ -29,7 +29,7 @@ static DEFINE_MUTEX(regulator_list_mutex);
29static LIST_HEAD(regulator_list); 29static LIST_HEAD(regulator_list);
30static LIST_HEAD(regulator_map_list); 30static LIST_HEAD(regulator_map_list);
31 31
32/** 32/*
33 * struct regulator_dev 33 * struct regulator_dev
34 * 34 *
35 * Voltage / Current regulator class device. One for each regulator. 35 * Voltage / Current regulator class device. One for each regulator.
@@ -56,7 +56,7 @@ struct regulator_dev {
56 void *reg_data; /* regulator_dev data */ 56 void *reg_data; /* regulator_dev data */
57}; 57};
58 58
59/** 59/*
60 * struct regulator_map 60 * struct regulator_map
61 * 61 *
62 * Used to provide symbolic supply names to devices. 62 * Used to provide symbolic supply names to devices.
@@ -79,7 +79,7 @@ struct regulator {
79 int uA_load; 79 int uA_load;
80 int min_uV; 80 int min_uV;
81 int max_uV; 81 int max_uV;
82 int enabled; /* client has called enabled */ 82 int enabled; /* count of client enables */
83 char *supply_name; 83 char *supply_name;
84 struct device_attribute dev_attr; 84 struct device_attribute dev_attr;
85 struct regulator_dev *rdev; 85 struct regulator_dev *rdev;
@@ -174,6 +174,16 @@ static int regulator_check_current_limit(struct regulator_dev *rdev,
174/* operating mode constraint check */ 174/* operating mode constraint check */
175static int regulator_check_mode(struct regulator_dev *rdev, int mode) 175static int regulator_check_mode(struct regulator_dev *rdev, int mode)
176{ 176{
177 switch (mode) {
178 case REGULATOR_MODE_FAST:
179 case REGULATOR_MODE_NORMAL:
180 case REGULATOR_MODE_IDLE:
181 case REGULATOR_MODE_STANDBY:
182 break;
183 default:
184 return -EINVAL;
185 }
186
177 if (!rdev->constraints) { 187 if (!rdev->constraints) {
178 printk(KERN_ERR "%s: no constraints for %s\n", __func__, 188 printk(KERN_ERR "%s: no constraints for %s\n", __func__,
179 rdev->desc->name); 189 rdev->desc->name);
@@ -232,6 +242,7 @@ static ssize_t regulator_uV_show(struct device *dev,
232 242
233 return ret; 243 return ret;
234} 244}
245static DEVICE_ATTR(microvolts, 0444, regulator_uV_show, NULL);
235 246
236static ssize_t regulator_uA_show(struct device *dev, 247static ssize_t regulator_uA_show(struct device *dev,
237 struct device_attribute *attr, char *buf) 248 struct device_attribute *attr, char *buf)
@@ -240,6 +251,7 @@ static ssize_t regulator_uA_show(struct device *dev,
240 251
241 return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev)); 252 return sprintf(buf, "%d\n", _regulator_get_current_limit(rdev));
242} 253}
254static DEVICE_ATTR(microamps, 0444, regulator_uA_show, NULL);
243 255
244static ssize_t regulator_name_show(struct device *dev, 256static ssize_t regulator_name_show(struct device *dev,
245 struct device_attribute *attr, char *buf) 257 struct device_attribute *attr, char *buf)
@@ -257,12 +269,8 @@ static ssize_t regulator_name_show(struct device *dev,
257 return sprintf(buf, "%s\n", name); 269 return sprintf(buf, "%s\n", name);
258} 270}
259 271
260static ssize_t regulator_opmode_show(struct device *dev, 272static ssize_t regulator_print_opmode(char *buf, int mode)
261 struct device_attribute *attr, char *buf)
262{ 273{
263 struct regulator_dev *rdev = dev_get_drvdata(dev);
264 int mode = _regulator_get_mode(rdev);
265
266 switch (mode) { 274 switch (mode) {
267 case REGULATOR_MODE_FAST: 275 case REGULATOR_MODE_FAST:
268 return sprintf(buf, "fast\n"); 276 return sprintf(buf, "fast\n");
@@ -276,12 +284,17 @@ static ssize_t regulator_opmode_show(struct device *dev,
276 return sprintf(buf, "unknown\n"); 284 return sprintf(buf, "unknown\n");
277} 285}
278 286
279static ssize_t regulator_state_show(struct device *dev, 287static ssize_t regulator_opmode_show(struct device *dev,
280 struct device_attribute *attr, char *buf) 288 struct device_attribute *attr, char *buf)
281{ 289{
282 struct regulator_dev *rdev = dev_get_drvdata(dev); 290 struct regulator_dev *rdev = dev_get_drvdata(dev);
283 int state = _regulator_is_enabled(rdev);
284 291
292 return regulator_print_opmode(buf, _regulator_get_mode(rdev));
293}
294static DEVICE_ATTR(opmode, 0444, regulator_opmode_show, NULL);
295
296static ssize_t regulator_print_state(char *buf, int state)
297{
285 if (state > 0) 298 if (state > 0)
286 return sprintf(buf, "enabled\n"); 299 return sprintf(buf, "enabled\n");
287 else if (state == 0) 300 else if (state == 0)
@@ -290,6 +303,15 @@ static ssize_t regulator_state_show(struct device *dev,
290 return sprintf(buf, "unknown\n"); 303 return sprintf(buf, "unknown\n");
291} 304}
292 305
306static ssize_t regulator_state_show(struct device *dev,
307 struct device_attribute *attr, char *buf)
308{
309 struct regulator_dev *rdev = dev_get_drvdata(dev);
310
311 return regulator_print_state(buf, _regulator_is_enabled(rdev));
312}
313static DEVICE_ATTR(state, 0444, regulator_state_show, NULL);
314
293static ssize_t regulator_min_uA_show(struct device *dev, 315static ssize_t regulator_min_uA_show(struct device *dev,
294 struct device_attribute *attr, char *buf) 316 struct device_attribute *attr, char *buf)
295{ 317{
@@ -300,6 +322,7 @@ static ssize_t regulator_min_uA_show(struct device *dev,
300 322
301 return sprintf(buf, "%d\n", rdev->constraints->min_uA); 323 return sprintf(buf, "%d\n", rdev->constraints->min_uA);
302} 324}
325static DEVICE_ATTR(min_microamps, 0444, regulator_min_uA_show, NULL);
303 326
304static ssize_t regulator_max_uA_show(struct device *dev, 327static ssize_t regulator_max_uA_show(struct device *dev,
305 struct device_attribute *attr, char *buf) 328 struct device_attribute *attr, char *buf)
@@ -311,6 +334,7 @@ static ssize_t regulator_max_uA_show(struct device *dev,
311 334
312 return sprintf(buf, "%d\n", rdev->constraints->max_uA); 335 return sprintf(buf, "%d\n", rdev->constraints->max_uA);
313} 336}
337static DEVICE_ATTR(max_microamps, 0444, regulator_max_uA_show, NULL);
314 338
315static ssize_t regulator_min_uV_show(struct device *dev, 339static ssize_t regulator_min_uV_show(struct device *dev,
316 struct device_attribute *attr, char *buf) 340 struct device_attribute *attr, char *buf)
@@ -322,6 +346,7 @@ static ssize_t regulator_min_uV_show(struct device *dev,
322 346
323 return sprintf(buf, "%d\n", rdev->constraints->min_uV); 347 return sprintf(buf, "%d\n", rdev->constraints->min_uV);
324} 348}
349static DEVICE_ATTR(min_microvolts, 0444, regulator_min_uV_show, NULL);
325 350
326static ssize_t regulator_max_uV_show(struct device *dev, 351static ssize_t regulator_max_uV_show(struct device *dev,
327 struct device_attribute *attr, char *buf) 352 struct device_attribute *attr, char *buf)
@@ -333,6 +358,7 @@ static ssize_t regulator_max_uV_show(struct device *dev,
333 358
334 return sprintf(buf, "%d\n", rdev->constraints->max_uV); 359 return sprintf(buf, "%d\n", rdev->constraints->max_uV);
335} 360}
361static DEVICE_ATTR(max_microvolts, 0444, regulator_max_uV_show, NULL);
336 362
337static ssize_t regulator_total_uA_show(struct device *dev, 363static ssize_t regulator_total_uA_show(struct device *dev,
338 struct device_attribute *attr, char *buf) 364 struct device_attribute *attr, char *buf)
@@ -347,6 +373,7 @@ static ssize_t regulator_total_uA_show(struct device *dev,
347 mutex_unlock(&rdev->mutex); 373 mutex_unlock(&rdev->mutex);
348 return sprintf(buf, "%d\n", uA); 374 return sprintf(buf, "%d\n", uA);
349} 375}
376static DEVICE_ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL);
350 377
351static ssize_t regulator_num_users_show(struct device *dev, 378static ssize_t regulator_num_users_show(struct device *dev,
352 struct device_attribute *attr, char *buf) 379 struct device_attribute *attr, char *buf)
@@ -374,153 +401,106 @@ static ssize_t regulator_suspend_mem_uV_show(struct device *dev,
374{ 401{
375 struct regulator_dev *rdev = dev_get_drvdata(dev); 402 struct regulator_dev *rdev = dev_get_drvdata(dev);
376 403
377 if (!rdev->constraints)
378 return sprintf(buf, "not defined\n");
379 return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV); 404 return sprintf(buf, "%d\n", rdev->constraints->state_mem.uV);
380} 405}
406static DEVICE_ATTR(suspend_mem_microvolts, 0444,
407 regulator_suspend_mem_uV_show, NULL);
381 408
382static ssize_t regulator_suspend_disk_uV_show(struct device *dev, 409static ssize_t regulator_suspend_disk_uV_show(struct device *dev,
383 struct device_attribute *attr, char *buf) 410 struct device_attribute *attr, char *buf)
384{ 411{
385 struct regulator_dev *rdev = dev_get_drvdata(dev); 412 struct regulator_dev *rdev = dev_get_drvdata(dev);
386 413
387 if (!rdev->constraints)
388 return sprintf(buf, "not defined\n");
389 return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV); 414 return sprintf(buf, "%d\n", rdev->constraints->state_disk.uV);
390} 415}
416static DEVICE_ATTR(suspend_disk_microvolts, 0444,
417 regulator_suspend_disk_uV_show, NULL);
391 418
392static ssize_t regulator_suspend_standby_uV_show(struct device *dev, 419static ssize_t regulator_suspend_standby_uV_show(struct device *dev,
393 struct device_attribute *attr, char *buf) 420 struct device_attribute *attr, char *buf)
394{ 421{
395 struct regulator_dev *rdev = dev_get_drvdata(dev); 422 struct regulator_dev *rdev = dev_get_drvdata(dev);
396 423
397 if (!rdev->constraints)
398 return sprintf(buf, "not defined\n");
399 return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV); 424 return sprintf(buf, "%d\n", rdev->constraints->state_standby.uV);
400} 425}
401 426static DEVICE_ATTR(suspend_standby_microvolts, 0444,
402static ssize_t suspend_opmode_show(struct regulator_dev *rdev, 427 regulator_suspend_standby_uV_show, NULL);
403 unsigned int mode, char *buf)
404{
405 switch (mode) {
406 case REGULATOR_MODE_FAST:
407 return sprintf(buf, "fast\n");
408 case REGULATOR_MODE_NORMAL:
409 return sprintf(buf, "normal\n");
410 case REGULATOR_MODE_IDLE:
411 return sprintf(buf, "idle\n");
412 case REGULATOR_MODE_STANDBY:
413 return sprintf(buf, "standby\n");
414 }
415 return sprintf(buf, "unknown\n");
416}
417 428
418static ssize_t regulator_suspend_mem_mode_show(struct device *dev, 429static ssize_t regulator_suspend_mem_mode_show(struct device *dev,
419 struct device_attribute *attr, char *buf) 430 struct device_attribute *attr, char *buf)
420{ 431{
421 struct regulator_dev *rdev = dev_get_drvdata(dev); 432 struct regulator_dev *rdev = dev_get_drvdata(dev);
422 433
423 if (!rdev->constraints) 434 return regulator_print_opmode(buf,
424 return sprintf(buf, "not defined\n"); 435 rdev->constraints->state_mem.mode);
425 return suspend_opmode_show(rdev,
426 rdev->constraints->state_mem.mode, buf);
427} 436}
437static DEVICE_ATTR(suspend_mem_mode, 0444,
438 regulator_suspend_mem_mode_show, NULL);
428 439
429static ssize_t regulator_suspend_disk_mode_show(struct device *dev, 440static ssize_t regulator_suspend_disk_mode_show(struct device *dev,
430 struct device_attribute *attr, char *buf) 441 struct device_attribute *attr, char *buf)
431{ 442{
432 struct regulator_dev *rdev = dev_get_drvdata(dev); 443 struct regulator_dev *rdev = dev_get_drvdata(dev);
433 444
434 if (!rdev->constraints) 445 return regulator_print_opmode(buf,
435 return sprintf(buf, "not defined\n"); 446 rdev->constraints->state_disk.mode);
436 return suspend_opmode_show(rdev,
437 rdev->constraints->state_disk.mode, buf);
438} 447}
448static DEVICE_ATTR(suspend_disk_mode, 0444,
449 regulator_suspend_disk_mode_show, NULL);
439 450
440static ssize_t regulator_suspend_standby_mode_show(struct device *dev, 451static ssize_t regulator_suspend_standby_mode_show(struct device *dev,
441 struct device_attribute *attr, char *buf) 452 struct device_attribute *attr, char *buf)
442{ 453{
443 struct regulator_dev *rdev = dev_get_drvdata(dev); 454 struct regulator_dev *rdev = dev_get_drvdata(dev);
444 455
445 if (!rdev->constraints) 456 return regulator_print_opmode(buf,
446 return sprintf(buf, "not defined\n"); 457 rdev->constraints->state_standby.mode);
447 return suspend_opmode_show(rdev,
448 rdev->constraints->state_standby.mode, buf);
449} 458}
459static DEVICE_ATTR(suspend_standby_mode, 0444,
460 regulator_suspend_standby_mode_show, NULL);
450 461
451static ssize_t regulator_suspend_mem_state_show(struct device *dev, 462static ssize_t regulator_suspend_mem_state_show(struct device *dev,
452 struct device_attribute *attr, char *buf) 463 struct device_attribute *attr, char *buf)
453{ 464{
454 struct regulator_dev *rdev = dev_get_drvdata(dev); 465 struct regulator_dev *rdev = dev_get_drvdata(dev);
455 466
456 if (!rdev->constraints) 467 return regulator_print_state(buf,
457 return sprintf(buf, "not defined\n"); 468 rdev->constraints->state_mem.enabled);
458
459 if (rdev->constraints->state_mem.enabled)
460 return sprintf(buf, "enabled\n");
461 else
462 return sprintf(buf, "disabled\n");
463} 469}
470static DEVICE_ATTR(suspend_mem_state, 0444,
471 regulator_suspend_mem_state_show, NULL);
464 472
465static ssize_t regulator_suspend_disk_state_show(struct device *dev, 473static ssize_t regulator_suspend_disk_state_show(struct device *dev,
466 struct device_attribute *attr, char *buf) 474 struct device_attribute *attr, char *buf)
467{ 475{
468 struct regulator_dev *rdev = dev_get_drvdata(dev); 476 struct regulator_dev *rdev = dev_get_drvdata(dev);
469 477
470 if (!rdev->constraints) 478 return regulator_print_state(buf,
471 return sprintf(buf, "not defined\n"); 479 rdev->constraints->state_disk.enabled);
472
473 if (rdev->constraints->state_disk.enabled)
474 return sprintf(buf, "enabled\n");
475 else
476 return sprintf(buf, "disabled\n");
477} 480}
481static DEVICE_ATTR(suspend_disk_state, 0444,
482 regulator_suspend_disk_state_show, NULL);
478 483
479static ssize_t regulator_suspend_standby_state_show(struct device *dev, 484static ssize_t regulator_suspend_standby_state_show(struct device *dev,
480 struct device_attribute *attr, char *buf) 485 struct device_attribute *attr, char *buf)
481{ 486{
482 struct regulator_dev *rdev = dev_get_drvdata(dev); 487 struct regulator_dev *rdev = dev_get_drvdata(dev);
483 488
484 if (!rdev->constraints) 489 return regulator_print_state(buf,
485 return sprintf(buf, "not defined\n"); 490 rdev->constraints->state_standby.enabled);
486
487 if (rdev->constraints->state_standby.enabled)
488 return sprintf(buf, "enabled\n");
489 else
490 return sprintf(buf, "disabled\n");
491} 491}
492static DEVICE_ATTR(suspend_standby_state, 0444,
493 regulator_suspend_standby_state_show, NULL);
492 494
495
496/*
497 * These are the only attributes are present for all regulators.
498 * Other attributes are a function of regulator functionality.
499 */
493static struct device_attribute regulator_dev_attrs[] = { 500static struct device_attribute regulator_dev_attrs[] = {
494 __ATTR(name, 0444, regulator_name_show, NULL), 501 __ATTR(name, 0444, regulator_name_show, NULL),
495 __ATTR(microvolts, 0444, regulator_uV_show, NULL),
496 __ATTR(microamps, 0444, regulator_uA_show, NULL),
497 __ATTR(opmode, 0444, regulator_opmode_show, NULL),
498 __ATTR(state, 0444, regulator_state_show, NULL),
499 __ATTR(min_microvolts, 0444, regulator_min_uV_show, NULL),
500 __ATTR(min_microamps, 0444, regulator_min_uA_show, NULL),
501 __ATTR(max_microvolts, 0444, regulator_max_uV_show, NULL),
502 __ATTR(max_microamps, 0444, regulator_max_uA_show, NULL),
503 __ATTR(requested_microamps, 0444, regulator_total_uA_show, NULL),
504 __ATTR(num_users, 0444, regulator_num_users_show, NULL), 502 __ATTR(num_users, 0444, regulator_num_users_show, NULL),
505 __ATTR(type, 0444, regulator_type_show, NULL), 503 __ATTR(type, 0444, regulator_type_show, NULL),
506 __ATTR(suspend_mem_microvolts, 0444,
507 regulator_suspend_mem_uV_show, NULL),
508 __ATTR(suspend_disk_microvolts, 0444,
509 regulator_suspend_disk_uV_show, NULL),
510 __ATTR(suspend_standby_microvolts, 0444,
511 regulator_suspend_standby_uV_show, NULL),
512 __ATTR(suspend_mem_mode, 0444,
513 regulator_suspend_mem_mode_show, NULL),
514 __ATTR(suspend_disk_mode, 0444,
515 regulator_suspend_disk_mode_show, NULL),
516 __ATTR(suspend_standby_mode, 0444,
517 regulator_suspend_standby_mode_show, NULL),
518 __ATTR(suspend_mem_state, 0444,
519 regulator_suspend_mem_state_show, NULL),
520 __ATTR(suspend_disk_state, 0444,
521 regulator_suspend_disk_state_show, NULL),
522 __ATTR(suspend_standby_state, 0444,
523 regulator_suspend_standby_state_show, NULL),
524 __ATTR_NULL, 504 __ATTR_NULL,
525}; 505};
526 506
@@ -675,7 +655,8 @@ static void print_constraints(struct regulator_dev *rdev)
675 655
676/** 656/**
677 * set_machine_constraints - sets regulator constraints 657 * set_machine_constraints - sets regulator constraints
678 * @regulator: regulator source 658 * @rdev: regulator source
659 * @constraints: constraints to apply
679 * 660 *
680 * Allows platform initialisation code to define and constrain 661 * Allows platform initialisation code to define and constrain
681 * regulator circuits e.g. valid voltage/current ranges, etc. NOTE: 662 * regulator circuits e.g. valid voltage/current ranges, etc. NOTE:
@@ -750,8 +731,8 @@ out:
750 731
751/** 732/**
752 * set_supply - set regulator supply regulator 733 * set_supply - set regulator supply regulator
753 * @regulator: regulator name 734 * @rdev: regulator name
754 * @supply: supply regulator name 735 * @supply_rdev: supply regulator name
755 * 736 *
756 * Called by platform initialisation code to set the supply regulator for this 737 * Called by platform initialisation code to set the supply regulator for this
757 * regulator. This ensures that a regulators supply will also be enabled by the 738 * regulator. This ensures that a regulators supply will also be enabled by the
@@ -778,9 +759,9 @@ out:
778 759
779/** 760/**
780 * set_consumer_device_supply: Bind a regulator to a symbolic supply 761 * set_consumer_device_supply: Bind a regulator to a symbolic supply
781 * @regulator: regulator source 762 * @rdev: regulator source
782 * @dev: device the supply applies to 763 * @consumer_dev: device the supply applies to
783 * @supply: symbolic name for supply 764 * @supply: symbolic name for supply
784 * 765 *
785 * Allows platform initialisation code to map physical regulator 766 * Allows platform initialisation code to map physical regulator
786 * sources to symbolic names for supplies for use by devices. Devices 767 * sources to symbolic names for supplies for use by devices. Devices
@@ -795,6 +776,20 @@ static int set_consumer_device_supply(struct regulator_dev *rdev,
795 if (supply == NULL) 776 if (supply == NULL)
796 return -EINVAL; 777 return -EINVAL;
797 778
779 list_for_each_entry(node, &regulator_map_list, list) {
780 if (consumer_dev != node->dev)
781 continue;
782 if (strcmp(node->supply, supply) != 0)
783 continue;
784
785 dev_dbg(consumer_dev, "%s/%s is '%s' supply; fail %s/%s\n",
786 dev_name(&node->regulator->dev),
787 node->regulator->desc->name,
788 supply,
789 dev_name(&rdev->dev), rdev->desc->name);
790 return -EBUSY;
791 }
792
798 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL); 793 node = kmalloc(sizeof(struct regulator_map), GFP_KERNEL);
799 if (node == NULL) 794 if (node == NULL)
800 return -ENOMEM; 795 return -ENOMEM;
@@ -963,16 +958,13 @@ void regulator_put(struct regulator *regulator)
963 if (regulator == NULL || IS_ERR(regulator)) 958 if (regulator == NULL || IS_ERR(regulator))
964 return; 959 return;
965 960
966 if (regulator->enabled) {
967 printk(KERN_WARNING "Releasing supply %s while enabled\n",
968 regulator->supply_name);
969 WARN_ON(regulator->enabled);
970 regulator_disable(regulator);
971 }
972
973 mutex_lock(&regulator_list_mutex); 961 mutex_lock(&regulator_list_mutex);
974 rdev = regulator->rdev; 962 rdev = regulator->rdev;
975 963
964 if (WARN(regulator->enabled, "Releasing supply %s while enabled\n",
965 regulator->supply_name))
966 _regulator_disable(rdev);
967
976 /* remove any sysfs entries */ 968 /* remove any sysfs entries */
977 if (regulator->dev) { 969 if (regulator->dev) {
978 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name); 970 sysfs_remove_link(&rdev->dev.kobj, regulator->supply_name);
@@ -1034,29 +1026,26 @@ static int _regulator_enable(struct regulator_dev *rdev)
1034 * regulator_enable - enable regulator output 1026 * regulator_enable - enable regulator output
1035 * @regulator: regulator source 1027 * @regulator: regulator source
1036 * 1028 *
1037 * Enable the regulator output at the predefined voltage or current value. 1029 * Request that the regulator be enabled with the regulator output at
1030 * the predefined voltage or current value. Calls to regulator_enable()
1031 * must be balanced with calls to regulator_disable().
1032 *
1038 * NOTE: the output value can be set by other drivers, boot loader or may be 1033 * NOTE: the output value can be set by other drivers, boot loader or may be
1039 * hardwired in the regulator. 1034 * hardwired in the regulator.
1040 * NOTE: calls to regulator_enable() must be balanced with calls to
1041 * regulator_disable().
1042 */ 1035 */
1043int regulator_enable(struct regulator *regulator) 1036int regulator_enable(struct regulator *regulator)
1044{ 1037{
1045 int ret; 1038 struct regulator_dev *rdev = regulator->rdev;
1046 1039 int ret = 0;
1047 if (regulator->enabled) {
1048 printk(KERN_CRIT "Regulator %s already enabled\n",
1049 regulator->supply_name);
1050 WARN_ON(regulator->enabled);
1051 return 0;
1052 }
1053 1040
1054 mutex_lock(&regulator->rdev->mutex); 1041 mutex_lock(&rdev->mutex);
1055 regulator->enabled = 1; 1042 if (regulator->enabled == 0)
1056 ret = _regulator_enable(regulator->rdev); 1043 ret = _regulator_enable(rdev);
1057 if (ret != 0) 1044 else if (regulator->enabled < 0)
1058 regulator->enabled = 0; 1045 ret = -EIO;
1059 mutex_unlock(&regulator->rdev->mutex); 1046 if (ret == 0)
1047 regulator->enabled++;
1048 mutex_unlock(&rdev->mutex);
1060 return ret; 1049 return ret;
1061} 1050}
1062EXPORT_SYMBOL_GPL(regulator_enable); 1051EXPORT_SYMBOL_GPL(regulator_enable);
@@ -1100,27 +1089,31 @@ static int _regulator_disable(struct regulator_dev *rdev)
1100 * regulator_disable - disable regulator output 1089 * regulator_disable - disable regulator output
1101 * @regulator: regulator source 1090 * @regulator: regulator source
1102 * 1091 *
1103 * Disable the regulator output voltage or current. 1092 * Disable the regulator output voltage or current. Calls to
1104 * NOTE: this will only disable the regulator output if no other consumer 1093 * regulator_enable() must be balanced with calls to
1105 * devices have it enabled.
1106 * NOTE: calls to regulator_enable() must be balanced with calls to
1107 * regulator_disable(). 1094 * regulator_disable().
1095 *
1096 * NOTE: this will only disable the regulator output if no other consumer
1097 * devices have it enabled, the regulator device supports disabling and
1098 * machine constraints permit this operation.
1108 */ 1099 */
1109int regulator_disable(struct regulator *regulator) 1100int regulator_disable(struct regulator *regulator)
1110{ 1101{
1111 int ret; 1102 struct regulator_dev *rdev = regulator->rdev;
1112 1103 int ret = 0;
1113 if (!regulator->enabled) {
1114 printk(KERN_ERR "%s: not in use by this consumer\n",
1115 __func__);
1116 return 0;
1117 }
1118 1104
1119 mutex_lock(&regulator->rdev->mutex); 1105 mutex_lock(&rdev->mutex);
1120 regulator->enabled = 0; 1106 if (regulator->enabled == 1) {
1121 regulator->uA_load = 0; 1107 ret = _regulator_disable(rdev);
1122 ret = _regulator_disable(regulator->rdev); 1108 if (ret == 0)
1123 mutex_unlock(&regulator->rdev->mutex); 1109 regulator->uA_load = 0;
1110 } else if (WARN(regulator->enabled <= 0,
1111 "unbalanced disables for supply %s\n",
1112 regulator->supply_name))
1113 ret = -EIO;
1114 if (ret == 0)
1115 regulator->enabled--;
1116 mutex_unlock(&rdev->mutex);
1124 return ret; 1117 return ret;
1125} 1118}
1126EXPORT_SYMBOL_GPL(regulator_disable); 1119EXPORT_SYMBOL_GPL(regulator_disable);
@@ -1196,7 +1189,13 @@ out:
1196 * regulator_is_enabled - is the regulator output enabled 1189 * regulator_is_enabled - is the regulator output enabled
1197 * @regulator: regulator source 1190 * @regulator: regulator source
1198 * 1191 *
1199 * Returns zero for disabled otherwise return number of enable requests. 1192 * Returns positive if the regulator driver backing the source/client
1193 * has requested that the device be enabled, zero if it hasn't, else a
1194 * negative errno code.
1195 *
1196 * Note that the device backing this regulator handle can have multiple
1197 * users, so it might be enabled even if regulator_enable() was never
1198 * called for this particular source.
1200 */ 1199 */
1201int regulator_is_enabled(struct regulator *regulator) 1200int regulator_is_enabled(struct regulator *regulator)
1202{ 1201{
@@ -1219,7 +1218,7 @@ EXPORT_SYMBOL_GPL(regulator_is_enabled);
1219 * 1218 *
1220 * NOTE: If the regulator is shared between several devices then the lowest 1219 * NOTE: If the regulator is shared between several devices then the lowest
1221 * request voltage that meets the system constraints will be used. 1220 * request voltage that meets the system constraints will be used.
1222 * NOTE: Regulator system constraints must be set for this regulator before 1221 * Regulator system constraints must be set for this regulator before
1223 * calling this function otherwise this call will fail. 1222 * calling this function otherwise this call will fail.
1224 */ 1223 */
1225int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV) 1224int regulator_set_voltage(struct regulator *regulator, int min_uV, int max_uV)
@@ -1493,7 +1492,8 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
1493 mode = rdev->desc->ops->get_optimum_mode(rdev, 1492 mode = rdev->desc->ops->get_optimum_mode(rdev,
1494 input_uV, output_uV, 1493 input_uV, output_uV,
1495 total_uA_load); 1494 total_uA_load);
1496 if (ret <= 0) { 1495 ret = regulator_check_mode(rdev, mode);
1496 if (ret < 0) {
1497 printk(KERN_ERR "%s: failed to get optimum mode for %s @" 1497 printk(KERN_ERR "%s: failed to get optimum mode for %s @"
1498 " %d uA %d -> %d uV\n", __func__, rdev->desc->name, 1498 " %d uA %d -> %d uV\n", __func__, rdev->desc->name,
1499 total_uA_load, input_uV, output_uV); 1499 total_uA_load, input_uV, output_uV);
@@ -1501,7 +1501,7 @@ int regulator_set_optimum_mode(struct regulator *regulator, int uA_load)
1501 } 1501 }
1502 1502
1503 ret = rdev->desc->ops->set_mode(rdev, mode); 1503 ret = rdev->desc->ops->set_mode(rdev, mode);
1504 if (ret <= 0) { 1504 if (ret < 0) {
1505 printk(KERN_ERR "%s: failed to set optimum mode %x for %s\n", 1505 printk(KERN_ERR "%s: failed to set optimum mode %x for %s\n",
1506 __func__, mode, rdev->desc->name); 1506 __func__, mode, rdev->desc->name);
1507 goto out; 1507 goto out;
@@ -1516,7 +1516,7 @@ EXPORT_SYMBOL_GPL(regulator_set_optimum_mode);
1516/** 1516/**
1517 * regulator_register_notifier - register regulator event notifier 1517 * regulator_register_notifier - register regulator event notifier
1518 * @regulator: regulator source 1518 * @regulator: regulator source
1519 * @notifier_block: notifier block 1519 * @nb: notifier block
1520 * 1520 *
1521 * Register notifier block to receive regulator events. 1521 * Register notifier block to receive regulator events.
1522 */ 1522 */
@@ -1531,7 +1531,7 @@ EXPORT_SYMBOL_GPL(regulator_register_notifier);
1531/** 1531/**
1532 * regulator_unregister_notifier - unregister regulator event notifier 1532 * regulator_unregister_notifier - unregister regulator event notifier
1533 * @regulator: regulator source 1533 * @regulator: regulator source
1534 * @notifier_block: notifier block 1534 * @nb: notifier block
1535 * 1535 *
1536 * Unregister regulator event notifier block. 1536 * Unregister regulator event notifier block.
1537 */ 1537 */
@@ -1697,9 +1697,9 @@ EXPORT_SYMBOL_GPL(regulator_bulk_free);
1697 1697
1698/** 1698/**
1699 * regulator_notifier_call_chain - call regulator event notifier 1699 * regulator_notifier_call_chain - call regulator event notifier
1700 * @regulator: regulator source 1700 * @rdev: regulator source
1701 * @event: notifier block 1701 * @event: notifier block
1702 * @data: 1702 * @data: callback-specific data.
1703 * 1703 *
1704 * Called by regulator drivers to notify clients a regulator event has 1704 * Called by regulator drivers to notify clients a regulator event has
1705 * occurred. We also notify regulator clients downstream. 1705 * occurred. We also notify regulator clients downstream.
@@ -1713,10 +1713,122 @@ int regulator_notifier_call_chain(struct regulator_dev *rdev,
1713} 1713}
1714EXPORT_SYMBOL_GPL(regulator_notifier_call_chain); 1714EXPORT_SYMBOL_GPL(regulator_notifier_call_chain);
1715 1715
1716/*
1717 * To avoid cluttering sysfs (and memory) with useless state, only
1718 * create attributes that can be meaningfully displayed.
1719 */
1720static int add_regulator_attributes(struct regulator_dev *rdev)
1721{
1722 struct device *dev = &rdev->dev;
1723 struct regulator_ops *ops = rdev->desc->ops;
1724 int status = 0;
1725
1726 /* some attributes need specific methods to be displayed */
1727 if (ops->get_voltage) {
1728 status = device_create_file(dev, &dev_attr_microvolts);
1729 if (status < 0)
1730 return status;
1731 }
1732 if (ops->get_current_limit) {
1733 status = device_create_file(dev, &dev_attr_microamps);
1734 if (status < 0)
1735 return status;
1736 }
1737 if (ops->get_mode) {
1738 status = device_create_file(dev, &dev_attr_opmode);
1739 if (status < 0)
1740 return status;
1741 }
1742 if (ops->is_enabled) {
1743 status = device_create_file(dev, &dev_attr_state);
1744 if (status < 0)
1745 return status;
1746 }
1747
1748 /* some attributes are type-specific */
1749 if (rdev->desc->type == REGULATOR_CURRENT) {
1750 status = device_create_file(dev, &dev_attr_requested_microamps);
1751 if (status < 0)
1752 return status;
1753 }
1754
1755 /* all the other attributes exist to support constraints;
1756 * don't show them if there are no constraints, or if the
1757 * relevant supporting methods are missing.
1758 */
1759 if (!rdev->constraints)
1760 return status;
1761
1762 /* constraints need specific supporting methods */
1763 if (ops->set_voltage) {
1764 status = device_create_file(dev, &dev_attr_min_microvolts);
1765 if (status < 0)
1766 return status;
1767 status = device_create_file(dev, &dev_attr_max_microvolts);
1768 if (status < 0)
1769 return status;
1770 }
1771 if (ops->set_current_limit) {
1772 status = device_create_file(dev, &dev_attr_min_microamps);
1773 if (status < 0)
1774 return status;
1775 status = device_create_file(dev, &dev_attr_max_microamps);
1776 if (status < 0)
1777 return status;
1778 }
1779
1780 /* suspend mode constraints need multiple supporting methods */
1781 if (!(ops->set_suspend_enable && ops->set_suspend_disable))
1782 return status;
1783
1784 status = device_create_file(dev, &dev_attr_suspend_standby_state);
1785 if (status < 0)
1786 return status;
1787 status = device_create_file(dev, &dev_attr_suspend_mem_state);
1788 if (status < 0)
1789 return status;
1790 status = device_create_file(dev, &dev_attr_suspend_disk_state);
1791 if (status < 0)
1792 return status;
1793
1794 if (ops->set_suspend_voltage) {
1795 status = device_create_file(dev,
1796 &dev_attr_suspend_standby_microvolts);
1797 if (status < 0)
1798 return status;
1799 status = device_create_file(dev,
1800 &dev_attr_suspend_mem_microvolts);
1801 if (status < 0)
1802 return status;
1803 status = device_create_file(dev,
1804 &dev_attr_suspend_disk_microvolts);
1805 if (status < 0)
1806 return status;
1807 }
1808
1809 if (ops->set_suspend_mode) {
1810 status = device_create_file(dev,
1811 &dev_attr_suspend_standby_mode);
1812 if (status < 0)
1813 return status;
1814 status = device_create_file(dev,
1815 &dev_attr_suspend_mem_mode);
1816 if (status < 0)
1817 return status;
1818 status = device_create_file(dev,
1819 &dev_attr_suspend_disk_mode);
1820 if (status < 0)
1821 return status;
1822 }
1823
1824 return status;
1825}
1826
1716/** 1827/**
1717 * regulator_register - register regulator 1828 * regulator_register - register regulator
1718 * @regulator: regulator source 1829 * @regulator_desc: regulator to register
1719 * @reg_data: private regulator data 1830 * @dev: struct device for the regulator
1831 * @driver_data: private regulator data
1720 * 1832 *
1721 * Called by regulator drivers to register a regulator. 1833 * Called by regulator drivers to register a regulator.
1722 * Returns 0 on success. 1834 * Returns 0 on success.
@@ -1761,45 +1873,37 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1761 /* preform any regulator specific init */ 1873 /* preform any regulator specific init */
1762 if (init_data->regulator_init) { 1874 if (init_data->regulator_init) {
1763 ret = init_data->regulator_init(rdev->reg_data); 1875 ret = init_data->regulator_init(rdev->reg_data);
1764 if (ret < 0) { 1876 if (ret < 0)
1765 kfree(rdev); 1877 goto clean;
1766 rdev = ERR_PTR(ret);
1767 goto out;
1768 }
1769 }
1770
1771 /* set regulator constraints */
1772 ret = set_machine_constraints(rdev, &init_data->constraints);
1773 if (ret < 0) {
1774 kfree(rdev);
1775 rdev = ERR_PTR(ret);
1776 goto out;
1777 } 1878 }
1778 1879
1779 /* register with sysfs */ 1880 /* register with sysfs */
1780 rdev->dev.class = &regulator_class; 1881 rdev->dev.class = &regulator_class;
1781 rdev->dev.parent = dev; 1882 rdev->dev.parent = dev;
1782 snprintf(rdev->dev.bus_id, sizeof(rdev->dev.bus_id), 1883 dev_set_name(&rdev->dev, "regulator.%d",
1783 "regulator.%d", atomic_inc_return(&regulator_no) - 1); 1884 atomic_inc_return(&regulator_no) - 1);
1784 ret = device_register(&rdev->dev); 1885 ret = device_register(&rdev->dev);
1785 if (ret != 0) { 1886 if (ret != 0)
1786 kfree(rdev); 1887 goto clean;
1787 rdev = ERR_PTR(ret);
1788 goto out;
1789 }
1790 1888
1791 dev_set_drvdata(&rdev->dev, rdev); 1889 dev_set_drvdata(&rdev->dev, rdev);
1792 1890
1891 /* set regulator constraints */
1892 ret = set_machine_constraints(rdev, &init_data->constraints);
1893 if (ret < 0)
1894 goto scrub;
1895
1896 /* add attributes supported by this regulator */
1897 ret = add_regulator_attributes(rdev);
1898 if (ret < 0)
1899 goto scrub;
1900
1793 /* set supply regulator if it exists */ 1901 /* set supply regulator if it exists */
1794 if (init_data->supply_regulator_dev) { 1902 if (init_data->supply_regulator_dev) {
1795 ret = set_supply(rdev, 1903 ret = set_supply(rdev,
1796 dev_get_drvdata(init_data->supply_regulator_dev)); 1904 dev_get_drvdata(init_data->supply_regulator_dev));
1797 if (ret < 0) { 1905 if (ret < 0)
1798 device_unregister(&rdev->dev); 1906 goto scrub;
1799 kfree(rdev);
1800 rdev = ERR_PTR(ret);
1801 goto out;
1802 }
1803 } 1907 }
1804 1908
1805 /* add consumers devices */ 1909 /* add consumers devices */
@@ -1811,10 +1915,7 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1811 for (--i; i >= 0; i--) 1915 for (--i; i >= 0; i--)
1812 unset_consumer_device_supply(rdev, 1916 unset_consumer_device_supply(rdev,
1813 init_data->consumer_supplies[i].dev); 1917 init_data->consumer_supplies[i].dev);
1814 device_unregister(&rdev->dev); 1918 goto scrub;
1815 kfree(rdev);
1816 rdev = ERR_PTR(ret);
1817 goto out;
1818 } 1919 }
1819 } 1920 }
1820 1921
@@ -1822,12 +1923,19 @@ struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
1822out: 1923out:
1823 mutex_unlock(&regulator_list_mutex); 1924 mutex_unlock(&regulator_list_mutex);
1824 return rdev; 1925 return rdev;
1926
1927scrub:
1928 device_unregister(&rdev->dev);
1929clean:
1930 kfree(rdev);
1931 rdev = ERR_PTR(ret);
1932 goto out;
1825} 1933}
1826EXPORT_SYMBOL_GPL(regulator_register); 1934EXPORT_SYMBOL_GPL(regulator_register);
1827 1935
1828/** 1936/**
1829 * regulator_unregister - unregister regulator 1937 * regulator_unregister - unregister regulator
1830 * @regulator: regulator source 1938 * @rdev: regulator to unregister
1831 * 1939 *
1832 * Called by regulator drivers to unregister a regulator. 1940 * Called by regulator drivers to unregister a regulator.
1833 */ 1941 */
@@ -1846,7 +1954,7 @@ void regulator_unregister(struct regulator_dev *rdev)
1846EXPORT_SYMBOL_GPL(regulator_unregister); 1954EXPORT_SYMBOL_GPL(regulator_unregister);
1847 1955
1848/** 1956/**
1849 * regulator_suspend_prepare: prepare regulators for system wide suspend 1957 * regulator_suspend_prepare - prepare regulators for system wide suspend
1850 * @state: system suspend state 1958 * @state: system suspend state
1851 * 1959 *
1852 * Configure each regulator with it's suspend operating parameters for state. 1960 * Configure each regulator with it's suspend operating parameters for state.
@@ -1882,7 +1990,7 @@ EXPORT_SYMBOL_GPL(regulator_suspend_prepare);
1882 1990
1883/** 1991/**
1884 * rdev_get_drvdata - get rdev regulator driver data 1992 * rdev_get_drvdata - get rdev regulator driver data
1885 * @regulator: regulator 1993 * @rdev: regulator
1886 * 1994 *
1887 * Get rdev regulator driver private data. This call can be used in the 1995 * Get rdev regulator driver private data. This call can be used in the
1888 * regulator driver context. 1996 * regulator driver context.
@@ -1919,7 +2027,7 @@ EXPORT_SYMBOL_GPL(regulator_set_drvdata);
1919 2027
1920/** 2028/**
1921 * regulator_get_id - get regulator ID 2029 * regulator_get_id - get regulator ID
1922 * @regulator: regulator 2030 * @rdev: regulator
1923 */ 2031 */
1924int rdev_get_id(struct regulator_dev *rdev) 2032int rdev_get_id(struct regulator_dev *rdev)
1925{ 2033{
diff --git a/drivers/regulator/da903x.c b/drivers/regulator/da903x.c
index 773b29cec8be..fe77730a7edb 100644
--- a/drivers/regulator/da903x.c
+++ b/drivers/regulator/da903x.c
@@ -102,7 +102,7 @@ static int da903x_set_ldo_voltage(struct regulator_dev *rdev,
102 uint8_t val, mask; 102 uint8_t val, mask;
103 103
104 if (check_range(info, min_uV, max_uV)) { 104 if (check_range(info, min_uV, max_uV)) {
105 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 105 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
106 return -EINVAL; 106 return -EINVAL;
107 } 107 }
108 108
@@ -159,7 +159,7 @@ static int da903x_is_enabled(struct regulator_dev *rdev)
159 if (ret) 159 if (ret)
160 return ret; 160 return ret;
161 161
162 return reg_val & (1 << info->enable_bit); 162 return !!(reg_val & (1 << info->enable_bit));
163} 163}
164 164
165/* DA9030 specific operations */ 165/* DA9030 specific operations */
@@ -172,7 +172,7 @@ static int da9030_set_ldo1_15_voltage(struct regulator_dev *rdev,
172 int ret; 172 int ret;
173 173
174 if (check_range(info, min_uV, max_uV)) { 174 if (check_range(info, min_uV, max_uV)) {
175 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 175 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
176 return -EINVAL; 176 return -EINVAL;
177 } 177 }
178 178
@@ -199,7 +199,7 @@ static int da9030_set_ldo14_voltage(struct regulator_dev *rdev,
199 int thresh; 199 int thresh;
200 200
201 if (check_range(info, min_uV, max_uV)) { 201 if (check_range(info, min_uV, max_uV)) {
202 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 202 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
203 return -EINVAL; 203 return -EINVAL;
204 } 204 }
205 205
@@ -248,7 +248,7 @@ static int da9034_set_dvc_voltage(struct regulator_dev *rdev,
248 int ret; 248 int ret;
249 249
250 if (check_range(info, min_uV, max_uV)) { 250 if (check_range(info, min_uV, max_uV)) {
251 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 251 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
252 return -EINVAL; 252 return -EINVAL;
253 } 253 }
254 254
@@ -273,7 +273,7 @@ static int da9034_set_ldo12_voltage(struct regulator_dev *rdev,
273 uint8_t val, mask; 273 uint8_t val, mask;
274 274
275 if (check_range(info, min_uV, max_uV)) { 275 if (check_range(info, min_uV, max_uV)) {
276 pr_err("invalid voltage range (%d, %d) uV", min_uV, max_uV); 276 pr_err("invalid voltage range (%d, %d) uV\n", min_uV, max_uV);
277 return -EINVAL; 277 return -EINVAL;
278 } 278 }
279 279
diff --git a/include/linux/regulator/consumer.h b/include/linux/regulator/consumer.h
index afdc4558bb94..801bf77ff4e2 100644
--- a/include/linux/regulator/consumer.h
+++ b/include/linux/regulator/consumer.h
@@ -104,10 +104,10 @@ struct regulator;
104/** 104/**
105 * struct regulator_bulk_data - Data used for bulk regulator operations. 105 * struct regulator_bulk_data - Data used for bulk regulator operations.
106 * 106 *
107 * @supply The name of the supply. Initialised by the user before 107 * @supply: The name of the supply. Initialised by the user before
108 * using the bulk regulator APIs. 108 * using the bulk regulator APIs.
109 * @consumer The regulator consumer for the supply. This will be managed 109 * @consumer: The regulator consumer for the supply. This will be managed
110 * by the bulk API. 110 * by the bulk API.
111 * 111 *
112 * The regulator APIs provide a series of regulator_bulk_() API calls as 112 * The regulator APIs provide a series of regulator_bulk_() API calls as
113 * a convenience to consumers which require multiple supplies. This 113 * a convenience to consumers which require multiple supplies. This
diff --git a/include/linux/regulator/driver.h b/include/linux/regulator/driver.h
index e37d80561985..2dae05705f13 100644
--- a/include/linux/regulator/driver.h
+++ b/include/linux/regulator/driver.h
@@ -24,7 +24,33 @@ struct regulator_init_data;
24/** 24/**
25 * struct regulator_ops - regulator operations. 25 * struct regulator_ops - regulator operations.
26 * 26 *
27 * This struct describes regulator operations. 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 regulator 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_limit: Configure a limit for a current-limited regulator.
39 * @get_current_limit: Get the limit for a current-limited regulator.
40 *
41 * @set_mode: Set the operating mode for the regulator.
42 * @get_mode: Get the current operating mode for the regulator.
43 * @get_optimum_mode: Get the most efficient operating mode for the regulator
44 * when running with the specified parameters.
45 *
46 * @set_suspend_voltage: Set the voltage for the regulator when the system
47 * is suspended.
48 * @set_suspend_enable: Mark the regulator as enabled when the system is
49 * suspended.
50 * @set_suspend_disable: Mark the regulator as disabled when the system is
51 * suspended.
52 * @set_suspend_mode: Set the operating mode for the regulator when the
53 * system is suspended.
28 */ 54 */
29struct regulator_ops { 55struct regulator_ops {
30 56
@@ -75,6 +101,15 @@ enum regulator_type {
75/** 101/**
76 * struct regulator_desc - Regulator descriptor 102 * struct regulator_desc - Regulator descriptor
77 * 103 *
104 * Each regulator registered with the core is described with a structure of
105 * this type.
106 *
107 * @name: Identifying name for the regulator.
108 * @id: Numerical identifier for the regulator.
109 * @ops: Regulator operations table.
110 * @irq: Interrupt number for the regulator.
111 * @type: Indicates if the regulator is a voltage or current regulator.
112 * @owner: Module providing the regulator, used for refcounting.
78 */ 113 */
79struct regulator_desc { 114struct regulator_desc {
80 const char *name; 115 const char *name;
diff --git a/include/linux/regulator/machine.h b/include/linux/regulator/machine.h
index c6d69331a81e..3794773b23d2 100644
--- a/include/linux/regulator/machine.h
+++ b/include/linux/regulator/machine.h
@@ -44,6 +44,10 @@ struct regulator;
44 * struct regulator_state - regulator state during low power syatem states 44 * struct regulator_state - regulator state during low power syatem states
45 * 45 *
46 * This describes a regulators state during a system wide low power state. 46 * This describes a regulators state during a system wide low power state.
47 *
48 * @uV: Operating voltage during suspend.
49 * @mode: Operating mode during suspend.
50 * @enabled: Enabled during suspend.
47 */ 51 */
48struct regulator_state { 52struct regulator_state {
49 int uV; /* suspend voltage */ 53 int uV; /* suspend voltage */
@@ -55,6 +59,30 @@ struct regulator_state {
55 * struct regulation_constraints - regulator operating constraints. 59 * struct regulation_constraints - regulator operating constraints.
56 * 60 *
57 * This struct describes regulator and board/machine specific constraints. 61 * This struct describes regulator and board/machine specific constraints.
62 *
63 * @name: Descriptive name for the constraints, used for display purposes.
64 *
65 * @min_uV: Smallest voltage consumers may set.
66 * @max_uV: Largest voltage consumers may set.
67 *
68 * @min_uA: Smallest consumers consumers may set.
69 * @max_uA: Largest current consumers may set.
70 *
71 * @valid_modes_mask: Mask of modes which may be configured by consumers.
72 * @valid_ops_mask: Operations which may be performed by consumers.
73 *
74 * @always_on: Set if the regulator should never be disabled.
75 * @boot_on: Set if the regulator is enabled when the system is initially
76 * started.
77 * @apply_uV: Apply the voltage constraint when initialising.
78 *
79 * @input_uV: Input voltage for regulator when supplied by another regulator.
80 *
81 * @state_disk: State for regulator when system is suspended in disk mode.
82 * @state_mem: State for regulator when system is suspended in mem mode.
83 * @state_standby: State for regulator when system is suspended in standby
84 * mode.
85 * @initial_state: Suspend state to set by default.
58 */ 86 */
59struct regulation_constraints { 87struct regulation_constraints {
60 88
@@ -93,6 +121,9 @@ struct regulation_constraints {
93 * struct regulator_consumer_supply - supply -> device mapping 121 * struct regulator_consumer_supply - supply -> device mapping
94 * 122 *
95 * This maps a supply name to a device. 123 * This maps a supply name to a device.
124 *
125 * @dev: Device structure for the consumer.
126 * @supply: Name for the supply.
96 */ 127 */
97struct regulator_consumer_supply { 128struct regulator_consumer_supply {
98 struct device *dev; /* consumer */ 129 struct device *dev; /* consumer */
@@ -103,6 +134,16 @@ struct regulator_consumer_supply {
103 * struct regulator_init_data - regulator platform initialisation data. 134 * struct regulator_init_data - regulator platform initialisation data.
104 * 135 *
105 * Initialisation constraints, our supply and consumers supplies. 136 * Initialisation constraints, our supply and consumers supplies.
137 *
138 * @supply_regulator_dev: Parent regulator (if any).
139 *
140 * @constraints: Constraints. These must be specified for the regulator to
141 * be usable.
142 * @num_consumer_supplies: Number of consumer device supplies.
143 * @consumer_supplies: Consumer device supply configuration.
144 *
145 * @regulator_init: Callback invoked when the regulator has been registered.
146 * @driver_data: Data passed to regulator_init.
106 */ 147 */
107struct regulator_init_data { 148struct regulator_init_data {
108 struct device *supply_regulator_dev; /* or NULL for LINE */ 149 struct device *supply_regulator_dev; /* or NULL for LINE */