regulator.tmpl 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  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. <book id="regulator-api">
  5. <bookinfo>
  6. <title>Voltage and current regulator API</title>
  7. <authorgroup>
  8. <author>
  9. <firstname>Liam</firstname>
  10. <surname>Girdwood</surname>
  11. <affiliation>
  12. <address>
  13. <email>lrg@slimlogic.co.uk</email>
  14. </address>
  15. </affiliation>
  16. </author>
  17. <author>
  18. <firstname>Mark</firstname>
  19. <surname>Brown</surname>
  20. <affiliation>
  21. <orgname>Wolfson Microelectronics</orgname>
  22. <address>
  23. <email>broonie@opensource.wolfsonmicro.com</email>
  24. </address>
  25. </affiliation>
  26. </author>
  27. </authorgroup>
  28. <copyright>
  29. <year>2007-2008</year>
  30. <holder>Wolfson Microelectronics</holder>
  31. </copyright>
  32. <copyright>
  33. <year>2008</year>
  34. <holder>Liam Girdwood</holder>
  35. </copyright>
  36. <legalnotice>
  37. <para>
  38. This documentation is free software; you can redistribute
  39. it and/or modify it under the terms of the GNU General Public
  40. License version 2 as published by the Free Software Foundation.
  41. </para>
  42. <para>
  43. This program is distributed in the hope that it will be
  44. useful, but WITHOUT ANY WARRANTY; without even the implied
  45. warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  46. See the GNU General Public License for more details.
  47. </para>
  48. <para>
  49. You should have received a copy of the GNU General Public
  50. License along with this program; if not, write to the Free
  51. Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  52. MA 02111-1307 USA
  53. </para>
  54. <para>
  55. For more details see the file COPYING in the source
  56. distribution of Linux.
  57. </para>
  58. </legalnotice>
  59. </bookinfo>
  60. <toc></toc>
  61. <chapter id="intro">
  62. <title>Introduction</title>
  63. <para>
  64. This framework is designed to provide a standard kernel
  65. interface to control voltage and current regulators.
  66. </para>
  67. <para>
  68. The intention is to allow systems to dynamically control
  69. regulator power output in order to save power and prolong
  70. battery life. This applies to both voltage regulators (where
  71. voltage output is controllable) and current sinks (where current
  72. limit is controllable).
  73. </para>
  74. <para>
  75. Note that additional (and currently more complete) documentation
  76. is available in the Linux kernel source under
  77. <filename>Documentation/power/regulator</filename>.
  78. </para>
  79. <sect1 id="glossary">
  80. <title>Glossary</title>
  81. <para>
  82. The regulator API uses a number of terms which may not be
  83. familiar:
  84. </para>
  85. <glossary>
  86. <glossentry>
  87. <glossterm>Regulator</glossterm>
  88. <glossdef>
  89. <para>
  90. Electronic device that supplies power to other devices. Most
  91. regulators can enable and disable their output and some can also
  92. control their output voltage or current.
  93. </para>
  94. </glossdef>
  95. </glossentry>
  96. <glossentry>
  97. <glossterm>Consumer</glossterm>
  98. <glossdef>
  99. <para>
  100. Electronic device which consumes power provided by a regulator.
  101. These may either be static, requiring only a fixed supply, or
  102. dynamic, requiring active management of the regulator at
  103. runtime.
  104. </para>
  105. </glossdef>
  106. </glossentry>
  107. <glossentry>
  108. <glossterm>Power Domain</glossterm>
  109. <glossdef>
  110. <para>
  111. The electronic circuit supplied by a given regulator, including
  112. the regulator and all consumer devices. The configuration of
  113. the regulator is shared between all the components in the
  114. circuit.
  115. </para>
  116. </glossdef>
  117. </glossentry>
  118. <glossentry>
  119. <glossterm>Power Management Integrated Circuit</glossterm>
  120. <acronym>PMIC</acronym>
  121. <glossdef>
  122. <para>
  123. An IC which contains numerous regulators and often also other
  124. subsystems. In an embedded system the primary PMIC is often
  125. equivalent to a combination of the PSU and southbridge in a
  126. desktop system.
  127. </para>
  128. </glossdef>
  129. </glossentry>
  130. </glossary>
  131. </sect1>
  132. </chapter>
  133. <chapter id="consumer">
  134. <title>Consumer driver interface</title>
  135. <para>
  136. This offers a similar API to the kernel clock framework.
  137. Consumer drivers use <link
  138. linkend='API-regulator-get'>get</link> and <link
  139. linkend='API-regulator-put'>put</link> operations to acquire and
  140. release regulators. Functions are
  141. provided to <link linkend='API-regulator-enable'>enable</link>
  142. and <link linkend='API-regulator-disable'>disable</link> the
  143. regulator and to get and set the runtime parameters of the
  144. regulator.
  145. </para>
  146. <para>
  147. When requesting regulators consumers use symbolic names for their
  148. supplies, such as "Vcc", which are mapped into actual regulator
  149. devices by the machine interface.
  150. </para>
  151. <para>
  152. A stub version of this API is provided when the regulator
  153. framework is not in use in order to minimise the need to use
  154. ifdefs.
  155. </para>
  156. <sect1 id="consumer-enable">
  157. <title>Enabling and disabling</title>
  158. <para>
  159. The regulator API provides reference counted enabling and
  160. disabling of regulators. Consumer devices use the <function><link
  161. linkend='API-regulator-enable'>regulator_enable</link></function>
  162. and <function><link
  163. linkend='API-regulator-disable'>regulator_disable</link>
  164. </function> functions to enable and disable regulators. Calls
  165. to the two functions must be balanced.
  166. </para>
  167. <para>
  168. Note that since multiple consumers may be using a regulator and
  169. machine constraints may not allow the regulator to be disabled
  170. there is no guarantee that calling
  171. <function>regulator_disable</function> will actually cause the
  172. supply provided by the regulator to be disabled. Consumer
  173. drivers should assume that the regulator may be enabled at all
  174. times.
  175. </para>
  176. </sect1>
  177. <sect1 id="consumer-config">
  178. <title>Configuration</title>
  179. <para>
  180. Some consumer devices may need to be able to dynamically
  181. configure their supplies. For example, MMC drivers may need to
  182. select the correct operating voltage for their cards. This may
  183. be done while the regulator is enabled or disabled.
  184. </para>
  185. <para>
  186. The <function><link
  187. linkend='API-regulator-set-voltage'>regulator_set_voltage</link>
  188. </function> and <function><link
  189. linkend='API-regulator-set-current-limit'
  190. >regulator_set_current_limit</link>
  191. </function> functions provide the primary interface for this.
  192. Both take ranges of voltages and currents, supporting drivers
  193. that do not require a specific value (eg, CPU frequency scaling
  194. normally permits the CPU to use a wider range of supply
  195. voltages at lower frequencies but does not require that the
  196. supply voltage be lowered). Where an exact value is required
  197. both minimum and maximum values should be identical.
  198. </para>
  199. </sect1>
  200. <sect1 id="consumer-callback">
  201. <title>Callbacks</title>
  202. <para>
  203. Callbacks may also be <link
  204. linkend='API-regulator-register-notifier'>registered</link>
  205. for events such as regulation failures.
  206. </para>
  207. </sect1>
  208. </chapter>
  209. <chapter id="driver">
  210. <title>Regulator driver interface</title>
  211. <para>
  212. Drivers for regulator chips <link
  213. linkend='API-regulator-register'>register</link> the regulators
  214. with the regulator core, providing operations structures to the
  215. core. A <link
  216. linkend='API-regulator-notifier-call-chain'>notifier</link> interface
  217. allows error conditions to be reported to the core.
  218. </para>
  219. <para>
  220. Registration should be triggered by explicit setup done by the
  221. platform, supplying a <link
  222. linkend='API-struct-regulator-init-data'>struct
  223. regulator_init_data</link> for the regulator containing
  224. <link linkend='machine-constraint'>constraint</link> and
  225. <link linkend='machine-supply'>supply</link> information.
  226. </para>
  227. </chapter>
  228. <chapter id="machine">
  229. <title>Machine interface</title>
  230. <para>
  231. This interface provides a way to define how regulators are
  232. connected to consumers on a given system and what the valid
  233. operating parameters are for the system.
  234. </para>
  235. <sect1 id="machine-supply">
  236. <title>Supplies</title>
  237. <para>
  238. Regulator supplies are specified using <link
  239. linkend='API-struct-regulator-consumer-supply'>struct
  240. regulator_consumer_supply</link>. This is done at
  241. <link linkend='driver'>driver registration
  242. time</link> as part of the machine constraints.
  243. </para>
  244. </sect1>
  245. <sect1 id="machine-constraint">
  246. <title>Constraints</title>
  247. <para>
  248. As well as defining the connections the machine interface
  249. also provides constraints defining the operations that
  250. clients are allowed to perform and the parameters that may be
  251. set. This is required since generally regulator devices will
  252. offer more flexibility than it is safe to use on a given
  253. system, for example supporting higher supply voltages than the
  254. consumers are rated for.
  255. </para>
  256. <para>
  257. This is done at <link linkend='driver'>driver
  258. registration time</link> by providing a <link
  259. linkend='API-struct-regulation-constraints'>struct
  260. regulation_constraints</link>.
  261. </para>
  262. <para>
  263. The constraints may also specify an initial configuration for the
  264. regulator in the constraints, which is particularly useful for
  265. use with static consumers.
  266. </para>
  267. </sect1>
  268. </chapter>
  269. <chapter id="api">
  270. <title>API reference</title>
  271. <para>
  272. Due to limitations of the kernel documentation framework and the
  273. existing layout of the source code the entire regulator API is
  274. documented here.
  275. </para>
  276. !Iinclude/linux/regulator/consumer.h
  277. !Iinclude/linux/regulator/machine.h
  278. !Iinclude/linux/regulator/driver.h
  279. !Edrivers/regulator/core.c
  280. </chapter>
  281. </book>