Skip to content

Commit f7816ad

Browse files
committed
Merge tag 'for-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel: - introduce reboot mode driver - add DT support to max8903 - add power supply support for axp221 - misc fixes * tag 'for-v4.8' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: power: reset: add reboot mode driver dt-bindings: power: reset: add document for reboot-mode driver power_supply: fix return value of get_property power: qcom_smbb: Make an extcon for usb cable detection max8903: adds support for initiation via device tree max8903: adds documentation for device tree bindings. max8903: remove unnecessary 'out of memory' error message. max8903: removes non zero validity checks on gpios. max8903: adds requesting of gpios. max8903: cleans up confusing relationship between dc_valid, dok and dcm. max8903: store pointer to pdata instead of copying it. power_supply: bq27xxx_battery: Group register mappings into one table docs: Move brcm,bcm21664-resetmgr.txt power/reset: make syscon_poweroff() static power: axp20x_usb: Add support for usb power-supply on axp22x pmics power_supply: bq27xxx_battery: Index register numbers by enum power_supply: bq27xxx_battery: Fix copy/paste error in header comment MAINTAINERS: Add file patterns for power supply device tree bindings power: reset: keystone: Enable COMPILE_TEST
2 parents 6097d55 + 4fcd504 commit f7816ad

22 files changed

+775
-243
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Maxim Semiconductor MAX8903 Battery Charger bindings
2+
3+
Required properties:
4+
- compatible: "maxim,max8903" for MAX8903 Battery Charger
5+
- dok-gpios: Valid DC power has been detected (active low, input), optional if uok-gpios is provided
6+
- uok-gpios: Valid USB power has been detected (active low, input), optional if dok-gpios is provided
7+
8+
Optional properties:
9+
- cen-gpios: Charge enable pin (active low, output)
10+
- chg-gpios: Charger status pin (active low, input)
11+
- flt-gpios: Fault pin (active low, output)
12+
- dcm-gpios: Current limit mode setting (DC=1 or USB=0, output)
13+
- usus-gpios: USB suspend pin (active high, output)
14+
15+
16+
Example:
17+
18+
max8903-charger {
19+
compatible = "maxim,max8903";
20+
dok-gpios = <&gpio2 3 GPIO_ACTIVE_LOW>;
21+
flt-gpios = <&gpio2 2 GPIO_ACTIVE_LOW>;
22+
chg-gpios = <&gpio3 15 GPIO_ACTIVE_LOW>;
23+
cen-gpios = <&gpio2 5 GPIO_ACTIVE_LOW>;
24+
status = "okay";
25+
};
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
Generic reboot mode core map driver
2+
3+
This driver get reboot mode arguments and call the write
4+
interface to store the magic value in special register
5+
or ram. Then the bootloader can read it and take different
6+
action according to the argument stored.
7+
8+
All mode properties are vendor specific, it is a indication to tell
9+
the bootloader what to do when the system reboots, and should be named
10+
as mode-xxx = <magic> (xxx is mode name, magic should be a none-zero value).
11+
12+
For example modes common on Android platform:
13+
- mode-normal: Normal reboot mode, system reboot with command "reboot".
14+
- mode-recovery: Android Recovery mode, it is a mode to format the device or update a new image.
15+
- mode-bootloader: Android fastboot mode, it's a mode to re-flash partitions on the Android based device.
16+
- mode-loader: A bootloader mode, it's a mode used to download image on Rockchip platform,
17+
usually used in development.
18+
19+
Example:
20+
reboot-mode {
21+
mode-normal = <BOOT_NORMAL>;
22+
mode-recovery = <BOOT_RECOVERY>;
23+
mode-bootloader = <BOOT_FASTBOOT>;
24+
mode-loader = <BOOT_BL_DOWNLOAD>;
25+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
SYSCON reboot mode driver
2+
3+
This driver gets reboot mode magic value form reboot-mode driver
4+
and stores it in a SYSCON mapped register. Then the bootloader
5+
can read it and take different action according to the magic
6+
value stored.
7+
8+
This DT node should be represented as a sub-node of a "syscon", "simple-mfd"
9+
node.
10+
11+
Required properties:
12+
- compatible: should be "syscon-reboot-mode"
13+
- offset: offset in the register map for the storage register (in bytes)
14+
15+
Optional property:
16+
- mask: bits mask of the bits in the register to store the reboot mode magic value,
17+
default set to 0xffffffff if missing.
18+
19+
The rest of the properties should follow the generic reboot-mode description
20+
found in reboot-mode.txt
21+
22+
Example:
23+
pmu: pmu@20004000 {
24+
compatible = "rockchip,rk3066-pmu", "syscon", "simple-mfd";
25+
reg = <0x20004000 0x100>;
26+
27+
reboot-mode {
28+
compatible = "syscon-reboot-mode";
29+
offset = <0x40>;
30+
mode-normal = <BOOT_NORMAL>;
31+
mode-recovery = <BOOT_RECOVERY>;
32+
mode-bootloader = <BOOT_FASTBOOT>;
33+
mode-loader = <BOOT_BL_DOWNLOAD>;
34+
};
35+
};

Documentation/devicetree/bindings/power_supply/axp20x_usb_power.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
AXP20x USB power supply
22

33
Required Properties:
4-
-compatible: "x-powers,axp202-usb-power-supply"
4+
-compatible: One of: "x-powers,axp202-usb-power-supply"
5+
"x-powers,axp221-usb-power-supply"
56

67
This node is a subnode of the axp20x PMIC.
78

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9169,6 +9169,8 @@ M: David Woodhouse <[email protected]>
91699169
91709170
T: git git://git.infradead.org/battery-2.6.git
91719171
S: Maintained
9172+
F: Documentation/devicetree/bindings/power/
9173+
F: Documentation/devicetree/bindings/power_supply/
91729174
F: include/linux/power_supply.h
91739175
F: drivers/power/
91749176
X: drivers/power/avs/

drivers/power/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -394,6 +394,7 @@ config CHARGER_QCOM_SMBB
394394
tristate "Qualcomm Switch-Mode Battery Charger and Boost"
395395
depends on MFD_SPMI_PMIC || COMPILE_TEST
396396
depends on OF
397+
depends on EXTCON
397398
help
398399
Say Y to include support for the Switch-Mode Battery Charger and
399400
Boost (SMBB) hardware found in Qualcomm PM8941 PMICs. The charger

drivers/power/axp20x_usb_power.c

Lines changed: 69 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
#define AXP20X_VBUS_MON_VBUS_VALID BIT(3)
4343

4444
struct axp20x_usb_power {
45+
struct device_node *np;
4546
struct regmap *regmap;
4647
struct power_supply *supply;
4748
};
@@ -85,7 +86,12 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
8586

8687
switch (v & AXP20X_VBUS_CLIMIT_MASK) {
8788
case AXP20X_VBUC_CLIMIT_100mA:
88-
val->intval = 100000;
89+
if (of_device_is_compatible(power->np,
90+
"x-powers,axp202-usb-power-supply")) {
91+
val->intval = 100000;
92+
} else {
93+
val->intval = -1; /* No 100mA limit */
94+
}
8995
break;
9096
case AXP20X_VBUC_CLIMIT_500mA:
9197
val->intval = 500000;
@@ -122,16 +128,19 @@ static int axp20x_usb_power_get_property(struct power_supply *psy,
122128
break;
123129
}
124130

125-
ret = regmap_read(power->regmap, AXP20X_USB_OTG_STATUS, &v);
126-
if (ret)
127-
return ret;
131+
val->intval = POWER_SUPPLY_HEALTH_GOOD;
128132

129-
if (!(v & AXP20X_USB_STATUS_VBUS_VALID)) {
130-
val->intval = POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
131-
break;
132-
}
133+
if (of_device_is_compatible(power->np,
134+
"x-powers,axp202-usb-power-supply")) {
135+
ret = regmap_read(power->regmap,
136+
AXP20X_USB_OTG_STATUS, &v);
137+
if (ret)
138+
return ret;
133139

134-
val->intval = POWER_SUPPLY_HEALTH_GOOD;
140+
if (!(v & AXP20X_USB_STATUS_VBUS_VALID))
141+
val->intval =
142+
POWER_SUPPLY_HEALTH_UNSPEC_FAILURE;
143+
}
135144
break;
136145
case POWER_SUPPLY_PROP_PRESENT:
137146
val->intval = !!(input & AXP20X_PWR_STATUS_VBUS_PRESENT);
@@ -156,6 +165,14 @@ static enum power_supply_property axp20x_usb_power_properties[] = {
156165
POWER_SUPPLY_PROP_CURRENT_NOW,
157166
};
158167

168+
static enum power_supply_property axp22x_usb_power_properties[] = {
169+
POWER_SUPPLY_PROP_HEALTH,
170+
POWER_SUPPLY_PROP_PRESENT,
171+
POWER_SUPPLY_PROP_ONLINE,
172+
POWER_SUPPLY_PROP_VOLTAGE_MIN,
173+
POWER_SUPPLY_PROP_CURRENT_MAX,
174+
};
175+
159176
static const struct power_supply_desc axp20x_usb_power_desc = {
160177
.name = "axp20x-usb",
161178
.type = POWER_SUPPLY_TYPE_USB,
@@ -164,13 +181,25 @@ static const struct power_supply_desc axp20x_usb_power_desc = {
164181
.get_property = axp20x_usb_power_get_property,
165182
};
166183

184+
static const struct power_supply_desc axp22x_usb_power_desc = {
185+
.name = "axp20x-usb",
186+
.type = POWER_SUPPLY_TYPE_USB,
187+
.properties = axp22x_usb_power_properties,
188+
.num_properties = ARRAY_SIZE(axp22x_usb_power_properties),
189+
.get_property = axp20x_usb_power_get_property,
190+
};
191+
167192
static int axp20x_usb_power_probe(struct platform_device *pdev)
168193
{
169194
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
170195
struct power_supply_config psy_cfg = {};
171196
struct axp20x_usb_power *power;
172-
static const char * const irq_names[] = { "VBUS_PLUGIN",
173-
"VBUS_REMOVAL", "VBUS_VALID", "VBUS_NOT_VALID" };
197+
static const char * const axp20x_irq_names[] = { "VBUS_PLUGIN",
198+
"VBUS_REMOVAL", "VBUS_VALID", "VBUS_NOT_VALID", NULL };
199+
static const char * const axp22x_irq_names[] = {
200+
"VBUS_PLUGIN", "VBUS_REMOVAL", NULL };
201+
static const char * const *irq_names;
202+
const struct power_supply_desc *usb_power_desc;
174203
int i, irq, ret;
175204

176205
if (!of_device_is_available(pdev->dev.of_node))
@@ -185,31 +214,47 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
185214
if (!power)
186215
return -ENOMEM;
187216

217+
power->np = pdev->dev.of_node;
188218
power->regmap = axp20x->regmap;
189219

190-
/* Enable vbus valid checking */
191-
ret = regmap_update_bits(power->regmap, AXP20X_VBUS_MON,
192-
AXP20X_VBUS_MON_VBUS_VALID, AXP20X_VBUS_MON_VBUS_VALID);
193-
if (ret)
194-
return ret;
220+
if (of_device_is_compatible(power->np,
221+
"x-powers,axp202-usb-power-supply")) {
222+
/* Enable vbus valid checking */
223+
ret = regmap_update_bits(power->regmap, AXP20X_VBUS_MON,
224+
AXP20X_VBUS_MON_VBUS_VALID,
225+
AXP20X_VBUS_MON_VBUS_VALID);
226+
if (ret)
227+
return ret;
195228

196-
/* Enable vbus voltage and current measurement */
197-
ret = regmap_update_bits(power->regmap, AXP20X_ADC_EN1,
229+
/* Enable vbus voltage and current measurement */
230+
ret = regmap_update_bits(power->regmap, AXP20X_ADC_EN1,
198231
AXP20X_ADC_EN1_VBUS_CURR | AXP20X_ADC_EN1_VBUS_VOLT,
199232
AXP20X_ADC_EN1_VBUS_CURR | AXP20X_ADC_EN1_VBUS_VOLT);
200-
if (ret)
201-
return ret;
233+
if (ret)
234+
return ret;
235+
236+
usb_power_desc = &axp20x_usb_power_desc;
237+
irq_names = axp20x_irq_names;
238+
} else if (of_device_is_compatible(power->np,
239+
"x-powers,axp221-usb-power-supply")) {
240+
usb_power_desc = &axp22x_usb_power_desc;
241+
irq_names = axp22x_irq_names;
242+
} else {
243+
dev_err(&pdev->dev, "Unsupported AXP variant: %ld\n",
244+
axp20x->variant);
245+
return -EINVAL;
246+
}
202247

203248
psy_cfg.of_node = pdev->dev.of_node;
204249
psy_cfg.drv_data = power;
205250

206-
power->supply = devm_power_supply_register(&pdev->dev,
207-
&axp20x_usb_power_desc, &psy_cfg);
251+
power->supply = devm_power_supply_register(&pdev->dev, usb_power_desc,
252+
&psy_cfg);
208253
if (IS_ERR(power->supply))
209254
return PTR_ERR(power->supply);
210255

211256
/* Request irqs after registering, as irqs may trigger immediately */
212-
for (i = 0; i < ARRAY_SIZE(irq_names); i++) {
257+
for (i = 0; irq_names[i]; i++) {
213258
irq = platform_get_irq_byname(pdev, irq_names[i]);
214259
if (irq < 0) {
215260
dev_warn(&pdev->dev, "No IRQ for %s: %d\n",
@@ -229,6 +274,7 @@ static int axp20x_usb_power_probe(struct platform_device *pdev)
229274

230275
static const struct of_device_id axp20x_usb_power_match[] = {
231276
{ .compatible = "x-powers,axp202-usb-power-supply" },
277+
{ .compatible = "x-powers,axp221-usb-power-supply" },
232278
{ }
233279
};
234280
MODULE_DEVICE_TABLE(of, axp20x_usb_power_match);

0 commit comments

Comments
 (0)