voltage and current regulator API

Every A is sacred...
A Dynamic Voltage and Current Regulator Control Interface for the Linux Kernel.
Liam Girdwood
www.wolfsonmicro.com
Outline
•
•
2
Introduction to Regulator Based Systems.
•
Real World Examples
–
Static & Dynamic System Power
–
CPUfreq & CPU Idle
–
Regulator Basics & Power Domains
–
LCD Backlight
–
PMP / Internet Tablet Example –
Audio
Kernel Regulator Framework
–
NAND/NOR
–
Consumer Interface
•
Resources & Status
–
Regulator Driver Interface
•
Thanks
–
Machine Interface
–
sysfs Interface (ABI)
•
Q & A
www.wolfsonmicro.com
Introduction to Regulator Based Systems
3
www.wolfsonmicro.com
Static & Dynamic System Power
•
Semiconductor power consumption has two components – static and dynamic.
Power(Total) = P(static) + P(dynamic) •
Static power is leakage current. – Smaller than dynamic power when system is active.
– Main power drain in system standby state.
•
Dynamic power is active current.
– Signals switching. (e.g. clocks)
– Analog circuits changing state (e.g. audio playback).
Power(dynamic) = CV2F • Regulators can be used to save static and dynamic power
4
www.wolfsonmicro.com
Regulator Basics
Software
Control
Input Power
Battery
Line
USB
Regulator
Output Power
Regulator
Device
Regulator
• Regulates the output power from input power.
– Voltage control – “input is 5V output is 1.8V”
– Current limiting – “limit output current to 20mA max”
– Simple switch – “switch output power on/off”
5
www.wolfsonmicro.com
Power Domains
Domain 1
Regulator­1
Regulator­2
Domain 2
Domain 3
Regulator­3
Consumer­E
Consumer­A
Consumer­C
Consumer­B
Consumer­D
Regulator­1 supplies Domain 1
Regulator­2 supplies Domain 2
Regulator­3 supplies Domain 3
• Power domain supplied power by the output of a – regulator, – switch – or by another power domain.
• Has power constraints to protect hardware. 6
www.wolfsonmicro.com
System Architecture (PMP, Internet Tablet)
Key
Dig Power Dyn
A/RF Power Dyn
Audio
Codec
Communications
FM­Tuner
BT
System
NOR / NAND
CPU (DVFS)
DDR
Touchscreen
TV­Out
LCD
Backlight
WIFI
HDD
USB
PMIC
7
Display
Device
Dig Power Static
Storage
Regulator
Battery
Mains
USB
www.wolfsonmicro.com
System Architecture (PMP, Internet Tablet)
Key
LDO­1
DCDC­1
Dig Power Dyn
System
A/RF Power Dyn NOR / NAND
Codec
Audio
LDO­2
LDO­5
LDO­12
Communications
LDO­4
CPU (DVFS)
DDR
LDO­8
LDO­6
TV­Out
LCD
BT
DCDC­3
Backlight
WIFI
HDD
USB
PMIC
8
LDO­7
Touchscreen
FM­Tuner
LDO­3
DCDC­2
Display
Device
Dig Power Static
LDO­11
LDO­9
DCDC­4
Storage
Regulator
DCDC­5
Battery
Mains
USB
www.wolfsonmicro.com
Kernel Regulator Framework
9
www.wolfsonmicro.com
Regulator Framework – What is it ?
•
Designed to provide a standard kernel interface to control voltage and current regulators.
•
Allow systems to dynamically control regulator power output in order to save power and prolong battery life.
•
Applies to both – voltage regulators (where voltage output is controllable)
– current sinks (where current limit is controllable)
•
Divided into four separate interfaces.
– Consumer interface for device drivers
– Regulator drivers interface for regulator drivers
– Machine interface for board configuration
– sysfs interface for userspace 10
www.wolfsonmicro.com
Regulator Consumer Interface
•
Consumers are client device drivers that use regulator(s) to control their power supply.
•
Consumers are constrained by the constraints of the power domain they are on
– Consumers can't request power settings that may damage themselves, other consumers or the system.
•
Classified into two types
– Static (only need to enable/disable)
– Dynamic (need to change voltage/ current limit)
11
www.wolfsonmicro.com
Regulator Consumer Interface ­ Basics
•
Access to regulator is by regulator = regulator_get(dev, "Vcc");
regulator_put(regulator);
•
Enable and disable
int regulator_enable(regulator);
int regulator_disable(regulator);
int regulator_force_disable(regulator);
•
Status
int regulator_is_enabled(regulator);
12
www.wolfsonmicro.com
Regulator Consumer Interface ­ Voltage
•
Consumers can request their supply voltage with
int regulator_set_voltage(struct regulator *regulator, int
min_uV, int max_uV);
•
Constraints are checked before changing voltage.
regulator_set_voltage(regulator, 100000, 150000);
•
Supply voltage can be found with
int regulator_get_voltage(struct regulator *regulator);
13
www.wolfsonmicro.com
Regulator Consumer Interface – Current Limit
•
Consumers can request their supply current limit with
int regulator_set_current_limit(struct regulator *regulator,
int min_uA, int max_uA);
•
Constraints are checked before changing current limit.
regulator_set_current_limit(regulator, 1000, 2000);
•
Supply current limit can be found with
int regulator_get_current_limit(struct regulator *regulator);
14
www.wolfsonmicro.com
Regulator Consumer Interface – Op Mode
100
•
Regulators are not 100% efficient.
•
Efficiency can vary depending on load.
•
Regulators can change op mode to increase efficiency.
90
Efficiency (%)
80
70
60
50
40
30
Normal Mode
20
Idle Mode
10
0
1
10
100
1000
Load (mA)
15
www.wolfsonmicro.com
Regulator Consumer Interface – Op Mode
Consumer with 10mA load:­
100
90
70% @ Normal = ~13mA
Efficiency (%)
80
70
60
50
Saving ~2mA
40
30
90% @ Idle = ~11mA
Normal Mode
20
Idle Mode
10
0
1
10
100
1000
Load (mA)
We sum total load for regulators > 1 consumer before changing mode.
Optimum efficiency can be requested by calling
regulator_set_optimum_mode(regulator, 10000); // 10mA
16
www.wolfsonmicro.com
Regulator Consumer Interface ­ Events
•
Regulator hardware can notify software of certain events.
– Regulator failures.
– Over temperature.
•
17
Consumers can then handle as required.
www.wolfsonmicro.com
Regulator Consumer Interface ­ Summary
•
Consumer registration
regulator_get(), regulator_put()
•
Regulator output power control and status.
regulator_enable(), regulator_disable(), regulator_force_disable(),
regulator_is_enabled()
•
Regulator output voltage control and status
regulator_set_voltage(), regulator_get_voltage()
•
Regulator output current limit control and status
regulator_set_current_limit(), regulator_get_current_limit()
•
Regulator operating mode control and status
regulator_set_mode(), regulator_get_mode(), regulator_set_optimum_mode()
•
Regulator events
regulator_register_notifier(), regulator_unregister_notifier()
18
www.wolfsonmicro.com
Regulator Driver Interface
•
Regulator drivers must be registered with the framework before they can be used by consumers.
struct regulator_dev *regulator_register(struct regulator_desc
*regulator_desc, void *reg_data);
void regulator_unregister(struct regulator_dev *rdev);
•
Events can be propagated to consumers
int regulator_notifier_call_chain(struct regulator_dev *rdev,
unsigned long event, void *data);
19
www.wolfsonmicro.com
Regulator Driver Interface ­ Operations
struct regulator_ops {
/* get/set regulator voltage */
int (*set_voltage) (struct regulator_dev *, int min_uV, int max_uV);
int (*get_voltage) (struct regulator_dev *);
/* get/set regulator current */
int (*set_current_limit) (struct regulator_dev *,
int min_uA, int max_uA);
int (*get_current_limit) (struct regulator_dev *);
/* enable/disable regulator */
int (*enable) (struct regulator_dev *);
int (*disable) (struct regulator_dev *);
int (*is_enabled) (struct regulator_dev *);
/* get/set regulator operating mode (defined in regulator.h) */
int (*set_mode) (struct regulator_dev *, unsigned int mode);
unsigned int (*get_mode) (struct regulator_dev *);
/* get most efficient regulator operating mode for load */
unsigned int (*get_optimum_mode) (struct regulator_dev *, int input_uV,
int output_uV, int load_uA);
};
20
www.wolfsonmicro.com
Regulator Driver Interface ­ Summary
• Regulator drivers can register their services with the core.
regulator_register(), regulator_unregister()
• Regulators can send events to the core and hence to all consumers.
regulator_notifier_call_chain()
• Regulator driver private data.
rdev_get_drvdata()
21
www.wolfsonmicro.com
Machine Driver Interface
• Fabric driver that is machine specific and describes
– Power domains
“Regulator 1 supplies consumers x,y,z.”
– Power domain suppliers
“Regulator 1 is supplied by default (Line/Battery/USB).” OR
“Regulator 1 is supplied by regulator 2.”
– Power domain constraints
“Regulator 1 output must be >= 1.6V and <=1.8V”
22
www.wolfsonmicro.com
Machine Driver Interface
Fabric that glues regulators to consumer devices
e.g. NAND is supplied by LDO1
Input Power
LDO1
Output Power
NAND
This attaches LDO1 to supply power to the NAND “Vcc” supply pin(s).
regulator_set_device_supply (“LDO1”, dev, “Vcc”);
23
www.wolfsonmicro.com
Machine Driver Interface ­ Constraints
• Defines safe operating limits for power domain.
• Prevents system damage through unsafe consumer requests.
struct regulation_constraints audio_avdd = {
.min_uV = 3300000,
.max_uV = 3300000,
.valid_modes_mask = REGULATOR_MODE_NORMAL,
.apply_uV = 1,
};
regulator_set_platform_constraints(regulator, &audio_avdd);
24
www.wolfsonmicro.com
Machine Driver Interface (cont)
Domain 1
Regulator­1
Domain 2
Regulator­2
Consumer­A
Consumer­C
Consumer­B
Consumer­D
•
Some regulators are supplied power by other regulators.
•
Ensure regulator 1 is enabled before trying to enable regulator 2. regulator_set_supply(“Regulator-2”, “Regulator-1”);
25
www.wolfsonmicro.com
Machine Interface ­ Summary
• Regulator ­­> consumer device mapping
regulator_set_device_supply()
• Regulator ­> regulator mapping
regulator_set_supply(), regulator_get_supply()
• Regulator “Power Domain” constraints.
regulator_set_platform_constraints()
26
www.wolfsonmicro.com
ABI – sysfs Interface
• Exports regulator and consumer information to user space
• Is read only
– Voltage
– Current limit
– State
– Operating Mode
– Constraints
• Could be used to provide more power usage info to powertop
27
www.wolfsonmicro.com
Real World Examples
28
www.wolfsonmicro.com
Use case – CPUfreq & CPUIdle
• CPUfreq scales CPU frequency to meet processing demands
– Voltage can also be scaled with frequency.
– Increased with frequency to increase performance/stability.
– Decreased with frequency to save power.
regulator_set_voltage(regulator, 1600000, 1600000); //1.6V • CPU Idle can place the CPU in numerous low power idle states.
– Idle states draw less power and may take advantage of regulator efficiency by changing regulator operating mode. regulator_set_optimum_mode(regulator, 10000); // 10mA
29
www.wolfsonmicro.com
Use Case – LCD Backlight
• LCD back lighting is usually a significant drain of system power.
• Power can be saved by lowering brightness when it's possible to do so.
– e.g. Some backlights are based on white LED's and can have brightness changed by changing current.
regulator_set_current_limit(regulator, 10000, 10000);
30
www.wolfsonmicro.com
Use Case ­ Audio
• Audio hardware consumes requires analog power when there is no audio playback or capture.
• Power could be saved when idle by turning off analog supplies when not in use.
• Power could additionally be saved by turning off components that are not being used in the current use case
– FM­Tuner could be disabled when MP3's are played.
– Speaker Amp can be disabled when Headphones are used. regulator_enable(regulator)
regulator_disable(regulator)
31
www.wolfsonmicro.com
Use Case ­ NAND/NOR
• NAND & NOR devices consume more power during IO than idle.
• NAND/NOR consumer driver can change regulator operating mode to gain efficiency savings when idle.
regulator_set_optimum_mode(regulator, 1000); // 1mA
State
Max Load (mA)
Read/Write
35
Erase
40
Erase + rw
55
Idle
1
NAND / NOR chip max load (from datasheet)
32
www.wolfsonmicro.com
Resources
•
Stable core code working on several machines.
•
Currently supports Freescale MC13783, Wolfson WM8350 & WM8400.
•
Working with mm kernel by providing patches to the Andrew Morton.
•
Project website :­ http://opensource.wolfsonmicro.com/node/15
•
git ­ http://opensource.wolfsonmicro.com/cgi­bin/gitweb.cgi
33
www.wolfsonmicro.com
Thanks
Laura Lawrence
Rob Herring
Nancy Chen
Mark Brown
Greg Kroah­Hartman
Andrew Morton
David Brownell
Sam Ravnborg
Kevin Hillman
Ian Brockbank
Grant More
34
www.wolfsonmicro.com
Q & A
Questions & Answers
35
www.wolfsonmicro.com