Skip to content

Commit 18b34b9

Browse files
committed
Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6
* 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6: (32 commits) regulator: twl4030 VAUX3 supports 3.0V regulator: Support disabling of unused regulators by machines regulator: Don't increment use_count for boot_on regulators twl4030-regulator: expose VPLL2 regulator: refcount fixes regulator: Don't warn if we failed to get a regulator regulator: Allow boot_on regulators to be disabled by clients regulator: Implement list_voltage for WM835x LDOs and DCDCs twl4030-regulator: list more VAUX4 voltages regulator: Don't warn on omitted voltage constraints regulator: Implement list_voltage() for WM8400 DCDCs and LDOs MMC: regulator utilities regulator: twl4030 voltage enumeration (v2) regulator: twl4030 regulators regulator: get_status() grows kerneldoc regulator: enumerate voltages (v2) regulator: Fix get_mode() for WM835x DCDCs regulator: Allow regulators to set the initial operating mode regulator: Suggest use of datasheet supply or pin names for consumers regulator: email - update email address and regulator webpage. ...
2 parents ca1ee21 + d6bb69c commit 18b34b9

22 files changed

Lines changed: 1220 additions & 117 deletions

File tree

‎Documentation/ABI/testing/sysfs-class-regulator‎

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ KernelVersion: 2.6.26
44
Contact: Liam Girdwood <lrg@slimlogic.co.uk>
55
Description:
66
Some regulator directories will contain a field called
7-
state. This reports the regulator enable status, for
8-
regulators which can report that value.
7+
state. This reports the regulator enable control, for
8+
regulators which can report that input value.
99

1010
This will be one of the following strings:
1111

@@ -14,16 +14,54 @@ Description:
1414
'unknown'
1515

1616
'enabled' means the regulator output is ON and is supplying
17-
power to the system.
17+
power to the system (assuming no error prevents it).
1818

1919
'disabled' means the regulator output is OFF and is not
20-
supplying power to the system..
20+
supplying power to the system (unless some non-Linux
21+
control has enabled it).
2122

2223
'unknown' means software cannot determine the state, or
2324
the reported state is invalid.
2425

2526
NOTE: this field can be used in conjunction with microvolts
26-
and microamps to determine regulator output levels.
27+
or microamps to determine configured regulator output levels.
28+
29+
30+
What: /sys/class/regulator/.../status
31+
Description:
32+
Some regulator directories will contain a field called
33+
"status". This reports the current regulator status, for
34+
regulators which can report that output value.
35+
36+
This will be one of the following strings:
37+
38+
off
39+
on
40+
error
41+
fast
42+
normal
43+
idle
44+
standby
45+
46+
"off" means the regulator is not supplying power to the
47+
system.
48+
49+
"on" means the regulator is supplying power to the system,
50+
and the regulator can't report a detailed operation mode.
51+
52+
"error" indicates an out-of-regulation status such as being
53+
disabled due to thermal shutdown, or voltage being unstable
54+
because of problems with the input power supply.
55+
56+
"fast", "normal", "idle", and "standby" are all detailed
57+
regulator operation modes (described elsewhere). They
58+
imply "on", but provide more detail.
59+
60+
Note that regulator status is a function of many inputs,
61+
not limited to control inputs from Linux. For example,
62+
the actual load presented may trigger "error" status; or
63+
a regulator may be enabled by another user, even though
64+
Linux did not enable it.
2765

2866

2967
What: /sys/class/regulator/.../type
@@ -58,7 +96,7 @@ Description:
5896
Some regulator directories will contain a field called
5997
microvolts. This holds the regulator output voltage setting
6098
measured in microvolts (i.e. E-6 Volts), for regulators
61-
which can report that voltage.
99+
which can report the control input for voltage.
62100

63101
NOTE: This value should not be used to determine the regulator
64102
output voltage level as this value is the same regardless of
@@ -73,7 +111,7 @@ Description:
73111
Some regulator directories will contain a field called
74112
microamps. This holds the regulator output current limit
75113
setting measured in microamps (i.e. E-6 Amps), for regulators
76-
which can report that current.
114+
which can report the control input for a current limit.
77115

78116
NOTE: This value should not be used to determine the regulator
79117
output current level as this value is the same regardless of
@@ -87,7 +125,7 @@ Contact: Liam Girdwood <lrg@slimlogic.co.uk>
87125
Description:
88126
Some regulator directories will contain a field called
89127
opmode. This holds the current regulator operating mode,
90-
for regulators which can report it.
128+
for regulators which can report that control input value.
91129

92130
The opmode value can be one of the following strings:
93131

@@ -101,7 +139,8 @@ Description:
101139

102140
NOTE: This value should not be used to determine the regulator
103141
output operating mode as this value is the same regardless of
104-
whether the regulator is enabled or disabled.
142+
whether the regulator is enabled or disabled. A "status"
143+
attribute may be available to determine the actual mode.
105144

106145

107146
What: /sys/class/regulator/.../min_microvolts

‎MAINTAINERS‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4847,7 +4847,7 @@ M: lrg@slimlogic.co.uk
48474847
P: Mark Brown
48484848
M: broonie@opensource.wolfsonmicro.com
48494849
W: http://opensource.wolfsonmicro.com/node/15
4850-
W: http://www.slimlogic.co.uk/?page_id=5
4850+
W: http://www.slimlogic.co.uk/?p=48
48514851
T: git kernel.org/pub/scm/linux/kernel/git/lrg/voltage-2.6.git
48524852
S: Supported
48534853

‎drivers/mfd/twl4030-core.c‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -592,11 +592,9 @@ add_children(struct twl4030_platform_data *pdata, unsigned long features)
592592

593593
/* maybe add LDOs that are omitted on cost-reduced parts */
594594
if (twl_has_regulator() && !(features & TPS_SUBSET)) {
595-
/*
596595
child = add_regulator(TWL4030_REG_VPLL2, pdata->vpll2);
597596
if (IS_ERR(child))
598597
return PTR_ERR(child);
599-
*/
600598

601599
child = add_regulator(TWL4030_REG_VMMC2, pdata->vmmc2);
602600
if (IS_ERR(child))

‎drivers/mmc/core/core.c‎

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include <linux/leds.h>
2222
#include <linux/scatterlist.h>
2323
#include <linux/log2.h>
24+
#include <linux/regulator/consumer.h>
2425

2526
#include <linux/mmc/card.h>
2627
#include <linux/mmc/host.h>
@@ -523,6 +524,105 @@ u32 mmc_vddrange_to_ocrmask(int vdd_min, int vdd_max)
523524
}
524525
EXPORT_SYMBOL(mmc_vddrange_to_ocrmask);
525526

527+
#ifdef CONFIG_REGULATOR
528+
529+
/**
530+
* mmc_regulator_get_ocrmask - return mask of supported voltages
531+
* @supply: regulator to use
532+
*
533+
* This returns either a negative errno, or a mask of voltages that
534+
* can be provided to MMC/SD/SDIO devices using the specified voltage
535+
* regulator. This would normally be called before registering the
536+
* MMC host adapter.
537+
*/
538+
int mmc_regulator_get_ocrmask(struct regulator *supply)
539+
{
540+
int result = 0;
541+
int count;
542+
int i;
543+
544+
count = regulator_count_voltages(supply);
545+
if (count < 0)
546+
return count;
547+
548+
for (i = 0; i < count; i++) {
549+
int vdd_uV;
550+
int vdd_mV;
551+
552+
vdd_uV = regulator_list_voltage(supply, i);
553+
if (vdd_uV <= 0)
554+
continue;
555+
556+
vdd_mV = vdd_uV / 1000;
557+
result |= mmc_vddrange_to_ocrmask(vdd_mV, vdd_mV);
558+
}
559+
560+
return result;
561+
}
562+
EXPORT_SYMBOL(mmc_regulator_get_ocrmask);
563+
564+
/**
565+
* mmc_regulator_set_ocr - set regulator to match host->ios voltage
566+
* @vdd_bit: zero for power off, else a bit number (host->ios.vdd)
567+
* @supply: regulator to use
568+
*
569+
* Returns zero on success, else negative errno.
570+
*
571+
* MMC host drivers may use this to enable or disable a regulator using
572+
* a particular supply voltage. This would normally be called from the
573+
* set_ios() method.
574+
*/
575+
int mmc_regulator_set_ocr(struct regulator *supply, unsigned short vdd_bit)
576+
{
577+
int result = 0;
578+
int min_uV, max_uV;
579+
int enabled;
580+
581+
enabled = regulator_is_enabled(supply);
582+
if (enabled < 0)
583+
return enabled;
584+
585+
if (vdd_bit) {
586+
int tmp;
587+
int voltage;
588+
589+
/* REVISIT mmc_vddrange_to_ocrmask() may have set some
590+
* bits this regulator doesn't quite support ... don't
591+
* be too picky, most cards and regulators are OK with
592+
* a 0.1V range goof (it's a small error percentage).
593+
*/
594+
tmp = vdd_bit - ilog2(MMC_VDD_165_195);
595+
if (tmp == 0) {
596+
min_uV = 1650 * 1000;
597+
max_uV = 1950 * 1000;
598+
} else {
599+
min_uV = 1900 * 1000 + tmp * 100 * 1000;
600+
max_uV = min_uV + 100 * 1000;
601+
}
602+
603+
/* avoid needless changes to this voltage; the regulator
604+
* might not allow this operation
605+
*/
606+
voltage = regulator_get_voltage(supply);
607+
if (voltage < 0)
608+
result = voltage;
609+
else if (voltage < min_uV || voltage > max_uV)
610+
result = regulator_set_voltage(supply, min_uV, max_uV);
611+
else
612+
result = 0;
613+
614+
if (result == 0 && !enabled)
615+
result = regulator_enable(supply);
616+
} else if (enabled) {
617+
result = regulator_disable(supply);
618+
}
619+
620+
return result;
621+
}
622+
EXPORT_SYMBOL(mmc_regulator_set_ocr);
623+
624+
#endif
625+
526626
/*
527627
* Mask off any voltages we don't support and select
528628
* the lowest voltage

‎drivers/regulator/Kconfig‎

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ config REGULATOR_DEBUG
2929
Say yes here to enable debugging support.
3030

3131
config REGULATOR_FIXED_VOLTAGE
32-
tristate
32+
tristate "Fixed voltage regulator support"
3333
default n
34+
help
35+
This driver provides support for fixed voltage regulators,
36+
useful for systems which use a combination of software
37+
managed regulators and simple non-configurable regulators.
3438

3539
config REGULATOR_VIRTUAL_CONSUMER
3640
tristate "Virtual regulator consumer support"
@@ -52,6 +56,13 @@ config REGULATOR_BQ24022
5256
charging select between 100 mA and 500 mA charging current
5357
limit.
5458

59+
config REGULATOR_TWL4030
60+
bool "TI TWL4030/TWL5030/TPS695x0 PMIC"
61+
depends on TWL4030_CORE
62+
help
63+
This driver supports the voltage regulators provided by
64+
this family of companion chips.
65+
5566
config REGULATOR_WM8350
5667
tristate "Wolfson Microelectroncis WM8350 AudioPlus PMIC"
5768
depends on MFD_WM8350

‎drivers/regulator/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ obj-$(CONFIG_REGULATOR_FIXED_VOLTAGE) += fixed.o
88
obj-$(CONFIG_REGULATOR_VIRTUAL_CONSUMER) += virtual.o
99

1010
obj-$(CONFIG_REGULATOR_BQ24022) += bq24022.o
11+
obj-$(CONFIG_REGULATOR_TWL4030) += twl4030-regulator.o
1112
obj-$(CONFIG_REGULATOR_WM8350) += wm8350-regulator.o
1213
obj-$(CONFIG_REGULATOR_WM8400) += wm8400-regulator.o
1314
obj-$(CONFIG_REGULATOR_DA903X) += da903x.o

‎drivers/regulator/bq24022.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ static int __init bq24022_probe(struct platform_device *pdev)
105105
ret = gpio_direction_output(pdata->gpio_iset2, 0);
106106
ret = gpio_direction_output(pdata->gpio_nce, 1);
107107

108-
bq24022 = regulator_register(&bq24022_desc, &pdev->dev, pdata);
108+
bq24022 = regulator_register(&bq24022_desc, &pdev->dev,
109+
pdata->init_data, pdata);
109110
if (IS_ERR(bq24022)) {
110111
dev_dbg(&pdev->dev, "couldn't register regulator\n");
111112
ret = PTR_ERR(bq24022);

0 commit comments

Comments
 (0)