aboutsummaryrefslogtreecommitdiffstats
path: root/Documentation/power
diff options
context:
space:
mode:
Diffstat (limited to 'Documentation/power')
-rw-r--r--Documentation/power/00-INDEX4
-rw-r--r--Documentation/power/apm-acpi.txt32
-rw-r--r--Documentation/power/pm.txt257
-rw-r--r--Documentation/power/pm_qos_interface.txt7
-rw-r--r--Documentation/power/power_supply_class.txt4
-rw-r--r--Documentation/power/regulator/consumer.txt182
-rw-r--r--Documentation/power/regulator/machine.txt101
-rw-r--r--Documentation/power/regulator/overview.txt171
-rw-r--r--Documentation/power/regulator/regulator.txt30
9 files changed, 528 insertions, 260 deletions
diff --git a/Documentation/power/00-INDEX b/Documentation/power/00-INDEX
index a55d7f1c836d..fb742c213c9e 100644
--- a/Documentation/power/00-INDEX
+++ b/Documentation/power/00-INDEX
@@ -1,5 +1,7 @@
100-INDEX 100-INDEX
2 - This file 2 - This file
3apm-acpi.txt
4 - basic info about the APM and ACPI support.
3basic-pm-debugging.txt 5basic-pm-debugging.txt
4 - Debugging suspend and resume 6 - Debugging suspend and resume
5devices.txt 7devices.txt
@@ -14,8 +16,6 @@ notifiers.txt
14 - Registering suspend notifiers in device drivers 16 - Registering suspend notifiers in device drivers
15pci.txt 17pci.txt
16 - How the PCI Subsystem Does Power Management 18 - How the PCI Subsystem Does Power Management
17pm.txt
18 - info on Linux power management support.
19pm_qos_interface.txt 19pm_qos_interface.txt
20 - info on Linux PM Quality of Service interface 20 - info on Linux PM Quality of Service interface
21power_supply_class.txt 21power_supply_class.txt
diff --git a/Documentation/power/apm-acpi.txt b/Documentation/power/apm-acpi.txt
new file mode 100644
index 000000000000..1bd799dc17e8
--- /dev/null
+++ b/Documentation/power/apm-acpi.txt
@@ -0,0 +1,32 @@
1APM or ACPI?
2------------
3If you have a relatively recent x86 mobile, desktop, or server system,
4odds are it supports either Advanced Power Management (APM) or
5Advanced Configuration and Power Interface (ACPI). ACPI is the newer
6of the two technologies and puts power management in the hands of the
7operating system, allowing for more intelligent power management than
8is possible with BIOS controlled APM.
9
10The best way to determine which, if either, your system supports is to
11build a kernel with both ACPI and APM enabled (as of 2.3.x ACPI is
12enabled by default). If a working ACPI implementation is found, the
13ACPI driver will override and disable APM, otherwise the APM driver
14will be used.
15
16No, sorry, you cannot have both ACPI and APM enabled and running at
17once. Some people with broken ACPI or broken APM implementations
18would like to use both to get a full set of working features, but you
19simply cannot mix and match the two. Only one power management
20interface can be in control of the machine at once. Think about it..
21
22User-space Daemons
23------------------
24Both APM and ACPI rely on user-space daemons, apmd and acpid
25respectively, to be completely functional. Obtain both of these
26daemons from your Linux distribution or from the Internet (see below)
27and be sure that they are started sometime in the system boot process.
28Go ahead and start both. If ACPI or APM is not available on your
29system the associated daemon will exit gracefully.
30
31 apmd: http://worldvisions.ca/~apenwarr/apmd/
32 acpid: http://acpid.sf.net/
diff --git a/Documentation/power/pm.txt b/Documentation/power/pm.txt
deleted file mode 100644
index be841507e43f..000000000000
--- a/Documentation/power/pm.txt
+++ /dev/null
@@ -1,257 +0,0 @@
1 Linux Power Management Support
2
3This document briefly describes how to use power management with your
4Linux system and how to add power management support to Linux drivers.
5
6APM or ACPI?
7------------
8If you have a relatively recent x86 mobile, desktop, or server system,
9odds are it supports either Advanced Power Management (APM) or
10Advanced Configuration and Power Interface (ACPI). ACPI is the newer
11of the two technologies and puts power management in the hands of the
12operating system, allowing for more intelligent power management than
13is possible with BIOS controlled APM.
14
15The best way to determine which, if either, your system supports is to
16build a kernel with both ACPI and APM enabled (as of 2.3.x ACPI is
17enabled by default). If a working ACPI implementation is found, the
18ACPI driver will override and disable APM, otherwise the APM driver
19will be used.
20
21No, sorry, you cannot have both ACPI and APM enabled and running at
22once. Some people with broken ACPI or broken APM implementations
23would like to use both to get a full set of working features, but you
24simply cannot mix and match the two. Only one power management
25interface can be in control of the machine at once. Think about it..
26
27User-space Daemons
28------------------
29Both APM and ACPI rely on user-space daemons, apmd and acpid
30respectively, to be completely functional. Obtain both of these
31daemons from your Linux distribution or from the Internet (see below)
32and be sure that they are started sometime in the system boot process.
33Go ahead and start both. If ACPI or APM is not available on your
34system the associated daemon will exit gracefully.
35
36 apmd: http://worldvisions.ca/~apenwarr/apmd/
37 acpid: http://acpid.sf.net/
38
39Driver Interface -- OBSOLETE, DO NOT USE!
40----------------*************************
41
42Note: pm_register(), pm_access(), pm_dev_idle() and friends are
43obsolete. Please do not use them. Instead you should properly hook
44your driver into the driver model, and use its suspend()/resume()
45callbacks to do this kind of stuff.
46
47If you are writing a new driver or maintaining an old driver, it
48should include power management support. Without power management
49support, a single driver may prevent a system with power management
50capabilities from ever being able to suspend (safely).
51
52Overview:
531) Register each instance of a device with "pm_register"
542) Call "pm_access" before accessing the hardware.
55 (this will ensure that the hardware is awake and ready)
563) Your "pm_callback" is called before going into a
57 suspend state (ACPI D1-D3) or after resuming (ACPI D0)
58 from a suspend.
594) Call "pm_dev_idle" when the device is not being used
60 (optional but will improve device idle detection)
615) When unloaded, unregister the device with "pm_unregister"
62
63/*
64 * Description: Register a device with the power-management subsystem
65 *
66 * Parameters:
67 * type - device type (PCI device, system device, ...)
68 * id - instance number or unique identifier
69 * cback - request handler callback (suspend, resume, ...)
70 *
71 * Returns: Registered PM device or NULL on error
72 *
73 * Examples:
74 * dev = pm_register(PM_SYS_DEV, PM_SYS_VGA, vga_callback);
75 *
76 * struct pci_dev *pci_dev = pci_find_dev(...);
77 * dev = pm_register(PM_PCI_DEV, PM_PCI_ID(pci_dev), callback);
78 */
79struct pm_dev *pm_register(pm_dev_t type, unsigned long id, pm_callback cback);
80
81/*
82 * Description: Unregister a device with the power management subsystem
83 *
84 * Parameters:
85 * dev - PM device previously returned from pm_register
86 */
87void pm_unregister(struct pm_dev *dev);
88
89/*
90 * Description: Unregister all devices with a matching callback function
91 *
92 * Parameters:
93 * cback - previously registered request callback
94 *
95 * Notes: Provided for easier porting from old APM interface
96 */
97void pm_unregister_all(pm_callback cback);
98
99/*
100 * Power management request callback
101 *
102 * Parameters:
103 * dev - PM device previously returned from pm_register
104 * rqst - request type
105 * data - data, if any, associated with the request
106 *
107 * Returns: 0 if the request is successful
108 * EINVAL if the request is not supported
109 * EBUSY if the device is now busy and cannot handle the request
110 * ENOMEM if the device was unable to handle the request due to memory
111 *
112 * Details: The device request callback will be called before the
113 * device/system enters a suspend state (ACPI D1-D3) or
114 * or after the device/system resumes from suspend (ACPI D0).
115 * For PM_SUSPEND, the ACPI D-state being entered is passed
116 * as the "data" argument to the callback. The device
117 * driver should save (PM_SUSPEND) or restore (PM_RESUME)
118 * device context when the request callback is called.
119 *
120 * Once a driver returns 0 (success) from a suspend
121 * request, it should not process any further requests or
122 * access the device hardware until a call to "pm_access" is made.
123 */
124typedef int (*pm_callback)(struct pm_dev *dev, pm_request_t rqst, void *data);
125
126Driver Details
127--------------
128This is just a quick Q&A as a stopgap until a real driver writers'
129power management guide is available.
130
131Q: When is a device suspended?
132
133Devices can be suspended based on direct user request (eg. laptop lid
134closes), system power policy (eg. sleep after 30 minutes of console
135inactivity), or device power policy (eg. power down device after 5
136minutes of inactivity)
137
138Q: Must a driver honor a suspend request?
139
140No, a driver can return -EBUSY from a suspend request and this
141will stop the system from suspending. When a suspend request
142fails, all suspended devices are resumed and the system continues
143to run. Suspend can be retried at a later time.
144
145Q: Can the driver block suspend/resume requests?
146
147Yes, a driver can delay its return from a suspend or resume
148request until the device is ready to handle requests. It
149is advantageous to return as quickly as possible from a
150request as suspend/resume are done serially.
151
152Q: What context is a suspend/resume initiated from?
153
154A suspend or resume is initiated from a kernel thread context.
155It is safe to block, allocate memory, initiate requests
156or anything else you can do within the kernel.
157
158Q: Will requests continue to arrive after a suspend?
159
160Possibly. It is the driver's responsibility to queue(*),
161fail, or drop any requests that arrive after returning
162success to a suspend request. It is important that the
163driver not access its device until after it receives
164a resume request as the device's bus may no longer
165be active.
166
167(*) If a driver queues requests for processing after
168 resume be aware that the device, network, etc.
169 might be in a different state than at suspend time.
170 It's probably better to drop requests unless
171 the driver is a storage device.
172
173Q: Do I have to manage bus-specific power management registers
174
175No. It is the responsibility of the bus driver to manage
176PCI, USB, etc. power management registers. The bus driver
177or the power management subsystem will also enable any
178wake-on functionality that the device has.
179
180Q: So, really, what do I need to do to support suspend/resume?
181
182You need to save any device context that would
183be lost if the device was powered off and then restore
184it at resume time. When ACPI is active, there are
185three levels of device suspend states; D1, D2, and D3.
186(The suspend state is passed as the "data" argument
187to the device callback.) With D3, the device is powered
188off and loses all context, D1 and D2 are shallower power
189states and require less device context to be saved. To
190play it safe, just save everything at suspend and restore
191everything at resume.
192
193Q: Where do I store device context for suspend?
194
195Anywhere in memory, kmalloc a buffer or store it
196in the device descriptor. You are guaranteed that the
197contents of memory will be restored and accessible
198before resume, even when the system suspends to disk.
199
200Q: What do I need to do for ACPI vs. APM vs. etc?
201
202Drivers need not be aware of the specific power management
203technology that is active. They just need to be aware
204of when the overlying power management system requests
205that they suspend or resume.
206
207Q: What about device dependencies?
208
209When a driver registers a device, the power management
210subsystem uses the information provided to build a
211tree of device dependencies (eg. USB device X is on
212USB controller Y which is on PCI bus Z) When power
213management wants to suspend a device, it first sends
214a suspend request to its driver, then the bus driver,
215and so on up to the system bus. Device resumes
216proceed in the opposite direction.
217
218Q: Who do I contact for additional information about
219 enabling power management for my specific driver/device?
220
221ACPI Development mailing list: linux-acpi@vger.kernel.org
222
223System Interface -- OBSOLETE, DO NOT USE!
224----------------*************************
225If you are providing new power management support to Linux (ie.
226adding support for something like APM or ACPI), you should
227communicate with drivers through the existing generic power
228management interface.
229
230/*
231 * Send a request to all devices
232 *
233 * Parameters:
234 * rqst - request type
235 * data - data, if any, associated with the request
236 *
237 * Returns: 0 if the request is successful
238 * See "pm_callback" return for errors
239 *
240 * Details: Walk list of registered devices and call pm_send
241 * for each until complete or an error is encountered.
242 * If an error is encountered for a suspend request,
243 * return all devices to the state they were in before
244 * the suspend request.
245 */
246int pm_send_all(pm_request_t rqst, void *data);
247
248/*
249 * Find a matching device
250 *
251 * Parameters:
252 * type - device type (PCI device, system device, or 0 to match all devices)
253 * from - previous match or NULL to start from the beginning
254 *
255 * Returns: Matching device or NULL if none found
256 */
257struct pm_dev *pm_find(pm_dev_t type, struct pm_dev *from);
diff --git a/Documentation/power/pm_qos_interface.txt b/Documentation/power/pm_qos_interface.txt
index 49adb1a33514..c40866e8b957 100644
--- a/Documentation/power/pm_qos_interface.txt
+++ b/Documentation/power/pm_qos_interface.txt
@@ -1,4 +1,4 @@
1PM quality of Service interface. 1PM Quality Of Service Interface.
2 2
3This interface provides a kernel and user mode interface for registering 3This interface provides a kernel and user mode interface for registering
4performance expectations by drivers, subsystems and user space applications on 4performance expectations by drivers, subsystems and user space applications on
@@ -7,6 +7,11 @@ one of the parameters.
7Currently we have {cpu_dma_latency, network_latency, network_throughput} as the 7Currently we have {cpu_dma_latency, network_latency, network_throughput} as the
8initial set of pm_qos parameters. 8initial set of pm_qos parameters.
9 9
10Each parameters have defined units:
11 * latency: usec
12 * timeout: usec
13 * throughput: kbs (kilo bit / sec)
14
10The infrastructure exposes multiple misc device nodes one per implemented 15The infrastructure exposes multiple misc device nodes one per implemented
11parameter. The set of parameters implement is defined by pm_qos_power_init() 16parameter. The set of parameters implement is defined by pm_qos_power_init()
12and pm_qos_params.h. This is done because having the available parameters 17and pm_qos_params.h. This is done because having the available parameters
diff --git a/Documentation/power/power_supply_class.txt b/Documentation/power/power_supply_class.txt
index a8686e5a6857..c6cd4956047c 100644
--- a/Documentation/power/power_supply_class.txt
+++ b/Documentation/power/power_supply_class.txt
@@ -101,6 +101,10 @@ of charge when battery became full/empty". It also could mean "value of
101charge when battery considered full/empty at given conditions (temperature, 101charge when battery considered full/empty at given conditions (temperature,
102age)". I.e. these attributes represents real thresholds, not design values. 102age)". I.e. these attributes represents real thresholds, not design values.
103 103
104CHARGE_COUNTER - the current charge counter (in µAh). This could easily
105be negative; there is no empty or full value. It is only useful for
106relative, time-based measurements.
107
104ENERGY_FULL, ENERGY_EMPTY - same as above but for energy. 108ENERGY_FULL, ENERGY_EMPTY - same as above but for energy.
105 109
106CAPACITY - capacity in percents. 110CAPACITY - capacity in percents.
diff --git a/Documentation/power/regulator/consumer.txt b/Documentation/power/regulator/consumer.txt
new file mode 100644
index 000000000000..82b7a43aadba
--- /dev/null
+++ b/Documentation/power/regulator/consumer.txt
@@ -0,0 +1,182 @@
1Regulator Consumer Driver Interface
2===================================
3
4This text describes the regulator interface for consumer device drivers.
5Please see overview.txt for a description of the terms used in this text.
6
7
81. Consumer Regulator Access (static & dynamic drivers)
9=======================================================
10
11A consumer driver can get access to it's supply regulator by calling :-
12
13regulator = regulator_get(dev, "Vcc");
14
15The consumer passes in it's struct device pointer and power supply ID. The core
16then finds the correct regulator by consulting a machine specific lookup table.
17If the lookup is successful then this call will return a pointer to the struct
18regulator that supplies this consumer.
19
20To release the regulator the consumer driver should call :-
21
22regulator_put(regulator);
23
24Consumers can be supplied by more than one regulator e.g. codec consumer with
25analog and digital supplies :-
26
27digital = regulator_get(dev, "Vcc"); /* digital core */
28analog = regulator_get(dev, "Avdd"); /* analog */
29
30The regulator access functions regulator_get() and regulator_put() will
31usually be called in your device drivers probe() and remove() respectively.
32
33
342. Regulator Output Enable & Disable (static & dynamic drivers)
35====================================================================
36
37A consumer can enable it's power supply by calling:-
38
39int regulator_enable(regulator);
40
41NOTE: The supply may already be enabled before regulator_enabled() is called.
42This may happen if the consumer shares the regulator or the regulator has been
43previously enabled by bootloader or kernel board initialization code.
44
45A consumer can determine if a regulator is enabled by calling :-
46
47int regulator_is_enabled(regulator);
48
49This will return > zero when the regulator is enabled.
50
51
52A consumer can disable it's supply when no longer needed by calling :-
53
54int regulator_disable(regulator);
55
56NOTE: This may not disable the supply if it's shared with other consumers. The
57regulator will only be disabled when the enabled reference count is zero.
58
59Finally, a regulator can be forcefully disabled in the case of an emergency :-
60
61int regulator_force_disable(regulator);
62
63NOTE: this will immediately and forcefully shutdown the regulator output. All
64consumers will be powered off.
65
66
673. Regulator Voltage Control & Status (dynamic drivers)
68======================================================
69
70Some consumer drivers need to be able to dynamically change their supply
71voltage to match system operating points. e.g. CPUfreq drivers can scale
72voltage along with frequency to save power, SD drivers may need to select the
73correct card voltage, etc.
74
75Consumers can control their supply voltage by calling :-
76
77int regulator_set_voltage(regulator, min_uV, max_uV);
78
79Where min_uV and max_uV are the minimum and maximum acceptable voltages in
80microvolts.
81
82NOTE: this can be called when the regulator is enabled or disabled. If called
83when enabled, then the voltage changes instantly, otherwise the voltage
84configuration changes and the voltage is physically set when the regulator is
85next enabled.
86
87The regulators configured voltage output can be found by calling :-
88
89int regulator_get_voltage(regulator);
90
91NOTE: get_voltage() will return the configured output voltage whether the
92regulator is enabled or disabled and should NOT be used to determine regulator
93output state. However this can be used in conjunction with is_enabled() to
94determine the regulator physical output voltage.
95
96
974. Regulator Current Limit Control & Status (dynamic drivers)
98===========================================================
99
100Some consumer drivers need to be able to dynamically change their supply
101current limit to match system operating points. e.g. LCD backlight driver can
102change the current limit to vary the backlight brightness, USB drivers may want
103to set the limit to 500mA when supplying power.
104
105Consumers can control their supply current limit by calling :-
106
107int regulator_set_current_limit(regulator, min_uV, max_uV);
108
109Where min_uA and max_uA are the minimum and maximum acceptable current limit in
110microamps.
111
112NOTE: this can be called when the regulator is enabled or disabled. If called
113when enabled, then the current limit changes instantly, otherwise the current
114limit configuration changes and the current limit is physically set when the
115regulator is next enabled.
116
117A regulators current limit can be found by calling :-
118
119int regulator_get_current_limit(regulator);
120
121NOTE: get_current_limit() will return the current limit whether the regulator
122is enabled or disabled and should not be used to determine regulator current
123load.
124
125
1265. Regulator Operating Mode Control & Status (dynamic drivers)
127=============================================================
128
129Some consumers can further save system power by changing the operating mode of
130their supply regulator to be more efficient when the consumers operating state
131changes. e.g. consumer driver is idle and subsequently draws less current
132
133Regulator operating mode can be changed indirectly or directly.
134
135Indirect operating mode control.
136--------------------------------
137Consumer drivers can request a change in their supply regulator operating mode
138by calling :-
139
140int regulator_set_optimum_mode(struct regulator *regulator, int load_uA);
141
142This will cause the core to recalculate the total load on the regulator (based
143on all it's consumers) and change operating mode (if necessary and permitted)
144to best match the current operating load.
145
146The load_uA value can be determined from the consumers datasheet. e.g.most
147datasheets have tables showing the max current consumed in certain situations.
148
149Most consumers will use indirect operating mode control since they have no
150knowledge of the regulator or whether the regulator is shared with other
151consumers.
152
153Direct operating mode control.
154------------------------------
155Bespoke or tightly coupled drivers may want to directly control regulator
156operating mode depending on their operating point. This can be achieved by
157calling :-
158
159int regulator_set_mode(struct regulator *regulator, unsigned int mode);
160unsigned int regulator_get_mode(struct regulator *regulator);
161
162Direct mode will only be used by consumers that *know* about the regulator and
163are not sharing the regulator with other consumers.
164
165
1666. Regulator Events
167===================
168Regulators can notify consumers of external events. Events could be received by
169consumers under regulator stress or failure conditions.
170
171Consumers can register interest in regulator events by calling :-
172
173int regulator_register_notifier(struct regulator *regulator,
174 struct notifier_block *nb);
175
176Consumers can uregister interest by calling :-
177
178int regulator_unregister_notifier(struct regulator *regulator,
179 struct notifier_block *nb);
180
181Regulators use the kernel notifier framework to send event to thier interested
182consumers.
diff --git a/Documentation/power/regulator/machine.txt b/Documentation/power/regulator/machine.txt
new file mode 100644
index 000000000000..c9a35665cf70
--- /dev/null
+++ b/Documentation/power/regulator/machine.txt
@@ -0,0 +1,101 @@
1Regulator Machine Driver Interface
2===================================
3
4The regulator machine driver interface is intended for board/machine specific
5initialisation code to configure the regulator subsystem. Typical things that
6machine drivers would do are :-
7
8 1. Regulator -> Device mapping.
9 2. Regulator supply configuration.
10 3. Power Domain constraint setting.
11
12
13
141. Regulator -> device mapping
15==============================
16Consider the following machine :-
17
18 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
19 |
20 +-> [Consumer B @ 3.3V]
21
22The drivers for consumers A & B must be mapped to the correct regulator in
23order to control their power supply. This mapping can be achieved in machine
24initialisation code by calling :-
25
26int regulator_set_device_supply(const char *regulator, struct device *dev,
27 const char *supply);
28
29and is shown with the following code :-
30
31regulator_set_device_supply("Regulator-1", devB, "Vcc");
32regulator_set_device_supply("Regulator-2", devA, "Vcc");
33
34This maps Regulator-1 to the 'Vcc' supply for Consumer B and maps Regulator-2
35to the 'Vcc' supply for Consumer A.
36
37
382. Regulator supply configuration.
39==================================
40Consider the following machine (again) :-
41
42 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
43 |
44 +-> [Consumer B @ 3.3V]
45
46Regulator-1 supplies power to Regulator-2. This relationship must be registered
47with the core so that Regulator-1 is also enabled when Consumer A enables it's
48supply (Regulator-2).
49
50This relationship can be register with the core via :-
51
52int regulator_set_supply(const char *regulator, const char *regulator_supply);
53
54In this example we would use the following code :-
55
56regulator_set_supply("Regulator-2", "Regulator-1");
57
58Relationships can be queried by calling :-
59
60const char *regulator_get_supply(const char *regulator);
61
62
633. Power Domain constraint setting.
64===================================
65Each power domain within a system has physical constraints on voltage and
66current. This must be defined in software so that the power domain is always
67operated within specifications.
68
69Consider the following machine (again) :-
70
71 Regulator-1 -+-> Regulator-2 --> [Consumer A @ 1.8 - 2.0V]
72 |
73 +-> [Consumer B @ 3.3V]
74
75This gives us two regulators and two power domains:
76
77 Domain 1: Regulator-2, Consumer B.
78 Domain 2: Consumer A.
79
80Constraints can be registered by calling :-
81
82int regulator_set_platform_constraints(const char *regulator,
83 struct regulation_constraints *constraints);
84
85The example is defined as follows :-
86
87struct regulation_constraints domain_1 = {
88 .min_uV = 3300000,
89 .max_uV = 3300000,
90 .valid_modes_mask = REGULATOR_MODE_NORMAL,
91};
92
93struct regulation_constraints domain_2 = {
94 .min_uV = 1800000,
95 .max_uV = 2000000,
96 .valid_ops_mask = REGULATOR_CHANGE_VOLTAGE,
97 .valid_modes_mask = REGULATOR_MODE_NORMAL,
98};
99
100regulator_set_platform_constraints("Regulator-1", &domain_1);
101regulator_set_platform_constraints("Regulator-2", &domain_2);
diff --git a/Documentation/power/regulator/overview.txt b/Documentation/power/regulator/overview.txt
new file mode 100644
index 000000000000..bdcb332bd7fb
--- /dev/null
+++ b/Documentation/power/regulator/overview.txt
@@ -0,0 +1,171 @@
1Linux voltage and current regulator framework
2=============================================
3
4About
5=====
6
7This framework is designed to provide a standard kernel interface to control
8voltage and current regulators.
9
10The intention is to allow systems to dynamically control regulator power output
11in order to save power and prolong battery life. This applies to both voltage
12regulators (where voltage output is controllable) and current sinks (where
13current limit is controllable).
14
15(C) 2008 Wolfson Microelectronics PLC.
16Author: Liam Girdwood <lg@opensource.wolfsonmicro.com>
17
18
19Nomenclature
20============
21
22Some terms used in this document:-
23
24 o Regulator - Electronic device that supplies power to other devices.
25 Most regulators can enable and disable their output whilst
26 some can control their output voltage and or current.
27
28 Input Voltage -> Regulator -> Output Voltage
29
30
31 o PMIC - Power Management IC. An IC that contains numerous regulators
32 and often contains other susbsystems.
33
34
35 o Consumer - Electronic device that is supplied power by a regulator.
36 Consumers can be classified into two types:-
37
38 Static: consumer does not change it's supply voltage or
39 current limit. It only needs to enable or disable it's
40 power supply. It's supply voltage is set by the hardware,
41 bootloader, firmware or kernel board initialisation code.
42
43 Dynamic: consumer needs to change it's supply voltage or
44 current limit to meet operation demands.
45
46
47 o Power Domain - Electronic circuit that is supplied it's input power by the
48 output power of a regulator, switch or by another power
49 domain.
50
51 The supply regulator may be behind a switch(s). i.e.
52
53 Regulator -+-> Switch-1 -+-> Switch-2 --> [Consumer A]
54 | |
55 | +-> [Consumer B], [Consumer C]
56 |
57 +-> [Consumer D], [Consumer E]
58
59 That is one regulator and three power domains:
60
61 Domain 1: Switch-1, Consumers D & E.
62 Domain 2: Switch-2, Consumers B & C.
63 Domain 3: Consumer A.
64
65 and this represents a "supplies" relationship:
66
67 Domain-1 --> Domain-2 --> Domain-3.
68
69 A power domain may have regulators that are supplied power
70 by other regulators. i.e.
71
72 Regulator-1 -+-> Regulator-2 -+-> [Consumer A]
73 |
74 +-> [Consumer B]
75
76 This gives us two regulators and two power domains:
77
78 Domain 1: Regulator-2, Consumer B.
79 Domain 2: Consumer A.
80
81 and a "supplies" relationship:
82
83 Domain-1 --> Domain-2
84
85
86 o Constraints - Constraints are used to define power levels for performance
87 and hardware protection. Constraints exist at three levels:
88
89 Regulator Level: This is defined by the regulator hardware
90 operating parameters and is specified in the regulator
91 datasheet. i.e.
92
93 - voltage output is in the range 800mV -> 3500mV.
94 - regulator current output limit is 20mA @ 5V but is
95 10mA @ 10V.
96
97 Power Domain Level: This is defined in software by kernel
98 level board initialisation code. It is used to constrain a
99 power domain to a particular power range. i.e.
100
101 - Domain-1 voltage is 3300mV
102 - Domain-2 voltage is 1400mV -> 1600mV
103 - Domain-3 current limit is 0mA -> 20mA.
104
105 Consumer Level: This is defined by consumer drivers
106 dynamically setting voltage or current limit levels.
107
108 e.g. a consumer backlight driver asks for a current increase
109 from 5mA to 10mA to increase LCD illumination. This passes
110 to through the levels as follows :-
111
112 Consumer: need to increase LCD brightness. Lookup and
113 request next current mA value in brightness table (the
114 consumer driver could be used on several different
115 personalities based upon the same reference device).
116
117 Power Domain: is the new current limit within the domain
118 operating limits for this domain and system state (e.g.
119 battery power, USB power)
120
121 Regulator Domains: is the new current limit within the
122 regulator operating parameters for input/ouput voltage.
123
124 If the regulator request passes all the constraint tests
125 then the new regulator value is applied.
126
127
128Design
129======
130
131The framework is designed and targeted at SoC based devices but may also be
132relevant to non SoC devices and is split into the following four interfaces:-
133
134
135 1. Consumer driver interface.
136
137 This uses a similar API to the kernel clock interface in that consumer
138 drivers can get and put a regulator (like they can with clocks atm) and
139 get/set voltage, current limit, mode, enable and disable. This should
140 allow consumers complete control over their supply voltage and current
141 limit. This also compiles out if not in use so drivers can be reused in
142 systems with no regulator based power control.
143
144 See Documentation/power/regulator/consumer.txt
145
146 2. Regulator driver interface.
147
148 This allows regulator drivers to register their regulators and provide
149 operations to the core. It also has a notifier call chain for propagating
150 regulator events to clients.
151
152 See Documentation/power/regulator/regulator.txt
153
154 3. Machine interface.
155
156 This interface is for machine specific code and allows the creation of
157 voltage/current domains (with constraints) for each regulator. It can
158 provide regulator constraints that will prevent device damage through
159 overvoltage or over current caused by buggy client drivers. It also
160 allows the creation of a regulator tree whereby some regulators are
161 supplied by others (similar to a clock tree).
162
163 See Documentation/power/regulator/machine.txt
164
165 4. Userspace ABI.
166
167 The framework also exports a lot of useful voltage/current/opmode data to
168 userspace via sysfs. This could be used to help monitor device power
169 consumption and status.
170
171 See Documentation/ABI/testing/regulator-sysfs.txt
diff --git a/Documentation/power/regulator/regulator.txt b/Documentation/power/regulator/regulator.txt
new file mode 100644
index 000000000000..a69050143592
--- /dev/null
+++ b/Documentation/power/regulator/regulator.txt
@@ -0,0 +1,30 @@
1Regulator Driver Interface
2==========================
3
4The regulator driver interface is relatively simple and designed to allow
5regulator drivers to register their services with the core framework.
6
7
8Registration
9============
10
11Drivers can register a regulator by calling :-
12
13struct regulator_dev *regulator_register(struct regulator_desc *regulator_desc,
14 void *reg_data);
15
16This will register the regulators capabilities and operations the regulator
17core. The core does not touch reg_data (private to regulator driver).
18
19Regulators can be unregistered by calling :-
20
21void regulator_unregister(struct regulator_dev *rdev);
22
23
24Regulator Events
25================
26Regulators can send events (e.g. over temp, under voltage, etc) to consumer
27drivers by calling :-
28
29int regulator_notifier_call_chain(struct regulator_dev *rdev,
30 unsigned long event, void *data);