Refer to self-linux-2.6.32.61 \ Documentation \ power \ regulator
I. Introduction
The power frame can dynamically adjust the power output to save power.
Ii. Basic Terms
Electronic devices that supply power from other devices. Some power supplies have switching and control output voltage and current.
- PMIC (Power Management IC)
Power management chip, meaning multiple power sources and even other subsystems.
The devices powered by regulator are collectively referred to as consumer, which can be divided into static and dynamic devices.
Static: you do not need to change the voltage and current. You only need to switch the power supply. It is usually set in the bootloader, firmware, and kernel board phases.
Dynamic: changes the voltage and current as needed.
The input circuit consists of the output of the power supply or other power supply fields.
The power supply is after the switch, as shown in:
Regulator-+-> Switch-1-+-> Switch-2 --> [Consumer A]
|
| +-> [Consumer B], [Consumer C]
|
+-> [Consumer D], [Consumer E]
It is a power supply and three power supply domains:
Domain 1: Switch-1, Consumers D & E.
Domain 2: Switch-2, Consumers B & C.
Domain 3: Consumer.
The three of them have an output relationship (the output of 1 serves as the input of 2 and the output of 2 serves as the input of 3 ):
Domain-1 --> Domain-2 --> Domain-3.
The power supply of one Power Supply domain can also be provided by other power sources, such:
Regulator-1-+-> Regulator-2-+-> [Consumer A]
|
+-> [Consumer B]
There are two power domains:
Domain 1: Regulator-2, Consumer B.
Domain 2: Consumer.
Its output relationship:
Domain-1 --> Domain-2
Constraints, used to define power characteristics and protection hardware, can be divided into the following three aspects:
Regulator Level:
Defines the parameter specifications of the power supply hardware, such:
-Voltage output is in the range 800mV-> 3500mV.
-Regulator current output limit is 20mA @ 5 V but is 10mA @ 10 V.
Power Domain Level:
Defined by the kernel board initialization code, which limits the power range of the power supply domain, such:
-Domain-1 voltage is 3300mV
-Domain-2 voltage is 1400mV-> 1600mV
-Domain-3 current limit is 0mA-> 20mA.
Consumer Level:
The current and voltage are dynamically adjusted by the driver.
Constraints:
E.g. a consumer backlight driver asks for a current increase from 5mA to 10mA to increase LCD illumination. This passes to through the levels as follows :-
Consumer: need to increase LCD brightness. Lookup and request next current mA value in brightness table (the consumer driver cocould be used on several different personalities based upon the same reference device ).
Power Domain: is the new current limit within the domain operating limits for this domain and system state (e. g. battery power, USB power)
Regulator Domains: is the new current limit within the regulator operating parameters for input/output voltage.
If the regulator request passes all the constraint tests then the new regulator value is applied.
Iii. Regulator Consumer Driver Interface
- Consumer Regulator Access (static & dynamic drivers)
Regulator = regulator_get (dev, "Vcc ");
Use this interface to obtain the corresponding regulator of the driver. Dev is the device pointer of the driver, and "Vcc" is the power ID. The kernel looks up the table and finds the regulator corresponding to the power ID.
Regulator_put (regulator );
Use this interface to release the regulator.
Regulator_get and regulator_put are usually called in probe and remove of driver.
- Regulator Output Enable & Disable (static & dynamic drivers)
Int regulator_enable (regulator );
This interface enables power output.
Note: The power output may have been enabled before this function is called.
NOTE: The supply may already be enabled before regulator_enabled () is called.
This may happen if the consumer shares the regulator or the regulator has been
Previusly enabled by bootloader or kernel board initialization code.
Int regulator_is_enabled (regulator );
This interface is used to determine whether the power output is enabled. Enabled when the return value is greater than 0.
Int regulator_disable (regulator );
Use this interface to turn off the power output.
Note: after this function is called, the power supply may not be immediately shut down, and a shared power supply scenario exists.
NOTE: This may not disable the supply if it's shared with other consumers.
Regulator will only be disabled when the enabled reference count is zero.
Int regulator_force_disable (regulator );
Use this interface to immediately turn off the power supply.
- Regulator Voltage Control & Status (dynamic drivers)
Int regulator_set_voltage (regulator, min_uV, max_uV );
This interface can be used to adjust the minimum and maximum output voltage.
Note: Call time
NOTE: this can be called when the regulator is enabled or disabled. If called
When enabled, then the voltage changes instantly, otherwise the voltage
Configuration changes and the voltage is physically set when the regulator is
Next enabled.
Int regulator_get_voltage (regulator );
This interface is used to obtain the configured output voltage.
NOTE: get_voltage () will return the configured output voltage whether
Regulator is enabled or disabled and shoshould NOT be used to determine regulator
Output state. However this can be used in conjunction with is_enabled ()
Determine the regulator physical output voltage.
Iv. Regulator Machine Driver Interface
The previously mentioned power field has a topological structure. when the power of the child node is turned on, a series of parent nodes will also be turned on, which will be mentioned in the following regulator machine:
1 Regulator Machine Driver Interface 2 ====================================== = 3 4 The regulator machine driver interface is intended for board/machine specific 5 initialisation code to configure the regulator subsystem. 6 7 Consider the following machine: -8 9 Regulator-1-+-> Regulator-2 --> [Consumer A @ 1.8-2.0 V] 10 | 11 +-> [Consumer B @ 3.3 V] 12 13 drivers for consumers A & B must be mapped to the correct regulator in14 order to control their power supply. this mapping can be achieved in machine15 initialisation code by creating a struct before for16 each regulator.17 18 struct failed {19 struct device * dev;/* consumer */20 const char * supply; /* consumer supply-e.g. "vcc" */21}; 22 23 e.g. for the machine above24 25 static struct regulator_consumer_supply regulator1_consumers [] = {26 {27. dev = & platform_consumerB_device.dev, 28. supply = "Vcc", 29 },}; 30 31 static struct regulator_consumer_supply regulator2_consumers [] = {32 {33. dev = & platform_consumerA_device.dev, 34. supply = "Vcc", 35 },}; 36 37 This maps Regulator-1 to the 'vcc' supply for Consumer B and maps Regulator-238 to the 'vcc' supply for Consumer A.39 40 Constraints can now be registered by defining a struct regulator_init_data41 for each regulator power domain. this structure also maps the consumers42 to their supply regulator:-43 44 static struct regulator_init_data regulator1_data = {45. constraints = {46. min_uV = 3300000,47. max_uV = 3300000,48. valid_modes_mask = REGULATOR_MODE_NORMAL, 49}, 50. num_consumer_supplies = ARRAY_SIZE (regulator1_consumers), 51. consumer_supplies = regulator1_consumers, 52}; 53 54 Regulator-1 supplies power to Regulator-2. this relationship must be registered55 with the core so that Regulator-1 is also enabled when Consumer A enables it 's56 supply (Regulator-2 ). the supply regulator is set by the supply_regulator_dev57 field below:-58 59 static struct regulator_init_data regulator2_data = {60. supply_regulator_dev = & platform_regulator1_device.dev, 61. constraints = {62. min_uV = 1800000,63. max_uV = 2000000,64. valid_ops_mask = REGULATOR_CHANGE_VOLTAGE, 65. valid_modes_mask = REGULATOR_MODE_NORMAL, 66}, 67. num_consumer_supplies = ARRAY_SIZE (regulator2_consumers), 68. consumer_supplies = regulator2_consumers, 69}; 70 71 Finally the regulator devices must be registered in the usual manner.72 73 static struct platform_device regulator_devices [] = {74 {75. name = "regulator", 76. id = dsp__1, 77. dev = {78. platform_data = & regulator1_data, 79}, 80}, 81 {82. name = "regulator", 83. id = dsp__2, 84. dev = {85. platform_data = & regulator2_data, 86}, 87}, 88}; 89/* register regulator 1 device */90 platform_device_register (& regulator_devices [0]); 91 92/* register regulator 2 device */93 platform_device_register (& regulator_devices [1]);Regulator machine driver interface