Skip to content

Commit 8649efb

Browse files
committed
Merge tag 'for-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel: "Core: - Add over-current health state - Add standard, adaptive and custom charge types - Add new properties for start/end charge threshold New Drivers / Hardware: - UCS1002 Programmable USB Port Power Controller - Ingenic JZ47xx Battery Fuel Gauge - AXP20x USB Power: Add AXP813 support - AT91 poweroff: Add SAM9X60 support - OLPC battery: Add XO-1.5 and XO-1.75 support Misc Changes: - syscon-reboot: support mask property - AXP288 fuel gauge: Blacklist ACEPC T8/T11. Looks like some vendor thought it's a good idea to build a desktop system with a fuel gauge, that slowly "discharges"... - cpcap-battery: Fix calculation errors - misc fixes" * tag 'for-v5.2' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (54 commits) power: supply: olpc_battery: force the le/be casts power: supply: ucs1002: Fix build error without CONFIG_REGULATOR power: supply: ucs1002: Fix wrong return value checking power: supply: Add driver for Microchip UCS1002 dt-bindings: power: supply: Add bindings for Microchip UCS1002 power: supply: core: Add POWER_SUPPLY_HEALTH_OVERCURRENT constant power: supply: core: fix clang -Wunsequenced power: supply: core: Add missing documentation for CHARGE_CONTROL_* properties power: supply: core: Add CHARGE_CONTROL_{START_THRESHOLD,END_THRESHOLD} properties power: supply: core: Add Standard, Adaptive, and Custom charge types power: supply: axp288_fuel_gauge: Add ACEPC T8 and T11 mini PCs to the blacklist power: supply: bq27xxx_battery: Notify also about status changes power: supply: olpc_battery: Have the framework register sysfs files for us power: supply: olpc_battery: Add OLPC XO 1.75 support power: supply: olpc_battery: Avoid using platform_info power: supply: olpc_battery: Use devm_power_supply_register() power: supply: olpc_battery: Move priv data to a struct power: supply: olpc_battery: Use DT to get battery version x86/platform/olpc: Use a correct version when making up a battery node x86/platform/olpc: Trivial code move in DT fixup ...
2 parents 5fd09ba + baf5964 commit 8649efb

33 files changed

Lines changed: 1611 additions & 271 deletions

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

Lines changed: 48 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,15 +114,60 @@ Description:
114114
Access: Read
115115
Valid values: Represented in microamps
116116

117+
What: /sys/class/power_supply/<supply_name>/charge_control_limit
118+
Date: Oct 2012
119+
Contact: linux-pm@vger.kernel.org
120+
Description:
121+
Maximum allowable charging current. Used for charge rate
122+
throttling for thermal cooling or improving battery health.
123+
124+
Access: Read, Write
125+
Valid values: Represented in microamps
126+
127+
What: /sys/class/power_supply/<supply_name>/charge_control_limit_max
128+
Date: Oct 2012
129+
Contact: linux-pm@vger.kernel.org
130+
Description:
131+
Maximum legal value for the charge_control_limit property.
132+
133+
Access: Read
134+
Valid values: Represented in microamps
135+
136+
What: /sys/class/power_supply/<supply_name>/charge_control_start_threshold
137+
Date: April 2019
138+
Contact: linux-pm@vger.kernel.org
139+
Description:
140+
Represents a battery percentage level, below which charging will
141+
begin.
142+
143+
Access: Read, Write
144+
Valid values: 0 - 100 (percent)
145+
146+
What: /sys/class/power_supply/<supply_name>/charge_control_end_threshold
147+
Date: April 2019
148+
Contact: linux-pm@vger.kernel.org
149+
Description:
150+
Represents a battery percentage level, above which charging will
151+
stop.
152+
153+
Access: Read, Write
154+
Valid values: 0 - 100 (percent)
155+
117156
What: /sys/class/power_supply/<supply_name>/charge_type
118157
Date: July 2009
119158
Contact: linux-pm@vger.kernel.org
120159
Description:
121160
Represents the type of charging currently being applied to the
122-
battery.
161+
battery. "Trickle", "Fast", and "Standard" all mean different
162+
charging speeds. "Adaptive" means that the charger uses some
163+
algorithm to adjust the charge rate dynamically, without
164+
any user configuration required. "Custom" means that the charger
165+
uses the charge_control_* properties as configuration for some
166+
different algorithm.
123167

124-
Access: Read
125-
Valid values: "Unknown", "N/A", "Trickle", "Fast"
168+
Access: Read, Write
169+
Valid values: "Unknown", "N/A", "Trickle", "Fast", "Standard",
170+
"Adaptive", "Custom"
126171

127172
What: /sys/class/power_supply/<supply_name>/charge_term_current
128173
Date: July 2014

‎Documentation/devicetree/bindings/arm/atmel-sysregs.txt‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ SHDWC SAMA5D2-Compatible Shutdown Controller
8484
1) shdwc node
8585

8686
required properties:
87-
- compatible: should be "atmel,sama5d2-shdwc".
87+
- compatible: should be "atmel,sama5d2-shdwc" or "microchip,sam9x60-shdwc".
8888
- reg: should contain registers location and length
8989
- clocks: phandle to input clock.
9090
- #address-cells: should be one. The cell is the wake-up input index.
@@ -96,6 +96,9 @@ optional properties:
9696
microseconds. It's usually a board-related property.
9797
- atmel,wakeup-rtc-timer: boolean to enable Real-Time Clock wake-up.
9898

99+
optional microchip,sam9x60-shdwc properties:
100+
- atmel,wakeup-rtt-timer: boolean to enable Real-time Timer Wake-up.
101+
99102
The node contains child nodes for each wake-up input that the platform uses.
100103

101104
2) input nodes

‎Documentation/devicetree/bindings/power/reset/syscon-reboot.txt‎

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,20 @@ Generic SYSCON mapped register reset driver
33
This is a generic reset driver using syscon to map the reset register.
44
The reset is generally performed with a write to the reset register
55
defined by the register map pointed by syscon reference plus the offset
6-
with the mask defined in the reboot node.
6+
with the value and mask defined in the reboot node.
77

88
Required properties:
99
- compatible: should contain "syscon-reboot"
1010
- regmap: this is phandle to the register map node
1111
- offset: offset in the register map for the reboot register (in bytes)
12-
- mask: the reset value written to the reboot register (32 bit access)
12+
- value: the reset value written to the reboot register (32 bit access)
13+
14+
Optional properties:
15+
- mask: update only the register bits defined by the mask (32 bit)
16+
17+
Legacy usage:
18+
If a node doesn't contain a value property but contains a mask property, the
19+
mask property is used as the value.
1320

1421
Default will be little endian mode, 32 bit access only.
1522

‎Documentation/devicetree/bindings/power/supply/axp20x_usb_power.txt‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Required Properties:
44
-compatible: One of: "x-powers,axp202-usb-power-supply"
55
"x-powers,axp221-usb-power-supply"
66
"x-powers,axp223-usb-power-supply"
7+
"x-powers,axp813-usb-power-supply"
78

89
The AXP223 PMIC shares most of its behaviour with the AXP221 but has slight
910
variations such as the former being able to set the VBUS power supply max

‎Documentation/devicetree/bindings/power/supply/gpio-charger.txt‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,17 @@ Required properties :
1414
usb-cdp (USB charging downstream port)
1515
usb-aca (USB accessory charger adapter)
1616

17+
Optional properties:
18+
- charge-status-gpios: GPIO indicating whether a battery is charging.
19+
1720
Example:
1821

1922
usb_charger: charger {
2023
compatible = "gpio-charger";
2124
charger-type = "usb-sdp";
22-
gpios = <&gpf0 2 0 0 0>;
23-
}
25+
gpios = <&gpd 28 GPIO_ACTIVE_LOW>;
26+
charge-status-gpios = <&gpc 27 GPIO_ACTIVE_LOW>;
27+
};
2428

2529
battery {
2630
power-supplies = <&usb_charger>;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
* Ingenic JZ47xx battery bindings
2+
3+
Required properties:
4+
5+
- compatible: Must be "ingenic,jz4740-battery".
6+
- io-channels: phandle and IIO specifier pair to the IIO device.
7+
Format described in iio-bindings.txt.
8+
- monitored-battery: phandle to a "simple-battery" compatible node.
9+
10+
The "monitored-battery" property must be a phandle to a node using the format
11+
described in battery.txt, with the following properties being required:
12+
13+
- voltage-min-design-microvolt: Drained battery voltage.
14+
- voltage-max-design-microvolt: Fully charged battery voltage.
15+
16+
Example:
17+
18+
#include <dt-bindings/iio/adc/ingenic,adc.h>
19+
20+
simple_battery: battery {
21+
compatible = "simple-battery";
22+
voltage-min-design-microvolt = <3600000>;
23+
voltage-max-design-microvolt = <4200000>;
24+
};
25+
26+
ingenic_battery {
27+
compatible = "ingenic,jz4740-battery";
28+
io-channels = <&adc INGENIC_ADC_BATTERY>;
29+
io-channel-names = "battery";
30+
monitored-battery = <&simple_battery>;
31+
};

Documentation/devicetree/bindings/power/supply/ltc3651-charger.txt renamed to Documentation/devicetree/bindings/power/supply/lt3651-charger.txt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,16 @@
1-
ltc3651-charger
1+
Analog Devices LT3651 Charger Power Supply bindings: lt3651-charger
22

33
Required properties:
4-
- compatible: "lltc,ltc3651-charger"
4+
- compatible: Should contain one of the following:
5+
* "lltc,ltc3651-charger", (DEPRECATED: Use "lltc,lt3651-charger")
6+
* "lltc,lt3651-charger"
57
- lltc,acpr-gpios: Connect to ACPR output. See remark below.
68

79
Optional properties:
810
- lltc,fault-gpios: Connect to FAULT output. See remark below.
911
- lltc,chrg-gpios: Connect to CHRG output. See remark below.
1012

11-
The ltc3651 outputs are open-drain type and active low. The driver assumes the
13+
The lt3651 outputs are open-drain type and active low. The driver assumes the
1214
GPIO reports "active" when the output is asserted, so if the pins have been
1315
connected directly, the GPIO flags should be set to active low also.
1416

@@ -20,7 +22,7 @@ attributes to detect changes.
2022
Example:
2123

2224
charger: battery-charger {
23-
compatible = "lltc,ltc3651-charger";
25+
compatible = "lltc,lt3651-charger";
2426
lltc,acpr-gpios = <&gpio0 68 GPIO_ACTIVE_LOW>;
2527
lltc,fault-gpios = <&gpio0 64 GPIO_ACTIVE_LOW>;
2628
lltc,chrg-gpios = <&gpio0 63 GPIO_ACTIVE_LOW>;
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
Microchip UCS1002 USB Port Power Controller
2+
3+
Required properties:
4+
- compatible : Should be "microchip,ucs1002";
5+
- reg : I2C slave address
6+
7+
Optional properties:
8+
- interrupts : A list of interrupts lines present (could be either
9+
corresponding to A_DET# pin, ALERT# pin, or both)
10+
- interrupt-names : A list of interrupt names. Should contain (if
11+
present):
12+
- "a_det" for line connected to A_DET# pin
13+
- "alert" for line connected to ALERT# pin
14+
Both are expected to be IRQ_TYPE_EDGE_BOTH
15+
Example:
16+
17+
&i2c3 {
18+
charger@32 {
19+
compatible = "microchip,ucs1002";
20+
pinctrl-names = "default";
21+
pinctrl-0 = <&pinctrl_ucs1002_pins>;
22+
reg = <0x32>;
23+
interrupts-extended = <&gpio5 2 IRQ_TYPE_EDGE_BOTH>,
24+
<&gpio3 21 IRQ_TYPE_EDGE_BOTH>;
25+
interrupt-names = "a_det", "alert";
26+
};
27+
};

‎Documentation/devicetree/bindings/power/supply/olpc_battery.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ OLPC battery
22
~~~~~~~~~~~~
33

44
Required properties:
5-
- compatible : "olpc,xo1-battery"
5+
- compatible : "olpc,xo1-battery" or "olpc,xo1.5-battery"

‎arch/x86/platform/olpc/olpc_dt.c‎

Lines changed: 71 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -220,52 +220,93 @@ static u32 __init olpc_dt_get_board_revision(void)
220220
return be32_to_cpu(rev);
221221
}
222222

223+
int olpc_dt_compatible_match(phandle node, const char *compat)
224+
{
225+
char buf[64], *p;
226+
int plen, len;
227+
228+
plen = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf));
229+
if (plen <= 0)
230+
return 0;
231+
232+
len = strlen(compat);
233+
for (p = buf; p < buf + plen; p += strlen(p) + 1) {
234+
if (strcmp(p, compat) == 0)
235+
return 1;
236+
}
237+
238+
return 0;
239+
}
240+
223241
void __init olpc_dt_fixup(void)
224242
{
225-
int r;
226-
char buf[64];
227243
phandle node;
228244
u32 board_rev;
229245

230246
node = olpc_dt_finddevice("/battery@0");
231247
if (!node)
232248
return;
233249

234-
/*
235-
* If the battery node has a compatible property, we are running a new
236-
* enough firmware and don't have fixups to make.
237-
*/
238-
r = olpc_dt_getproperty(node, "compatible", buf, sizeof(buf));
239-
if (r > 0)
240-
return;
241-
242-
pr_info("PROM DT: Old firmware detected, applying fixes\n");
243-
244-
/* Add olpc,xo1-battery compatible marker to battery node */
245-
olpc_dt_interpret("\" /battery@0\" find-device"
246-
" \" olpc,xo1-battery\" +compatible"
247-
" device-end");
248-
249250
board_rev = olpc_dt_get_board_revision();
250251
if (!board_rev)
251252
return;
252253

253254
if (board_rev >= olpc_board_pre(0xd0)) {
254-
/* XO-1.5: add dcon device */
255-
olpc_dt_interpret("\" /pci/display@1\" find-device"
256-
" new-device"
257-
" \" dcon\" device-name \" olpc,xo1-dcon\" +compatible"
258-
" finish-device device-end");
255+
/* XO-1.5 */
256+
257+
if (olpc_dt_compatible_match(node, "olpc,xo1.5-battery"))
258+
return;
259+
260+
/* Add olpc,xo1.5-battery compatible marker to battery node */
261+
olpc_dt_interpret("\" /battery@0\" find-device");
262+
olpc_dt_interpret(" \" olpc,xo1.5-battery\" +compatible");
263+
olpc_dt_interpret("device-end");
264+
265+
if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) {
266+
/*
267+
* If we have a olpc,xo1-battery compatible, then we're
268+
* running a new enough firmware that already has
269+
* the dcon node.
270+
*/
271+
return;
272+
}
273+
274+
/* Add dcon device */
275+
olpc_dt_interpret("\" /pci/display@1\" find-device");
276+
olpc_dt_interpret(" new-device");
277+
olpc_dt_interpret(" \" dcon\" device-name");
278+
olpc_dt_interpret(" \" olpc,xo1-dcon\" +compatible");
279+
olpc_dt_interpret(" finish-device");
280+
olpc_dt_interpret("device-end");
259281
} else {
260-
/* XO-1: add dcon device, mark RTC as olpc,xo1-rtc */
261-
olpc_dt_interpret("\" /pci/display@1,1\" find-device"
262-
" new-device"
263-
" \" dcon\" device-name \" olpc,xo1-dcon\" +compatible"
264-
" finish-device device-end"
265-
" \" /rtc\" find-device"
266-
" \" olpc,xo1-rtc\" +compatible"
267-
" device-end");
282+
/* XO-1 */
283+
284+
if (olpc_dt_compatible_match(node, "olpc,xo1-battery")) {
285+
/*
286+
* If we have a olpc,xo1-battery compatible, then we're
287+
* running a new enough firmware that already has
288+
* the dcon and RTC nodes.
289+
*/
290+
return;
291+
}
292+
293+
/* Add dcon device, mark RTC as olpc,xo1-rtc */
294+
olpc_dt_interpret("\" /pci/display@1,1\" find-device");
295+
olpc_dt_interpret(" new-device");
296+
olpc_dt_interpret(" \" dcon\" device-name");
297+
olpc_dt_interpret(" \" olpc,xo1-dcon\" +compatible");
298+
olpc_dt_interpret(" finish-device");
299+
olpc_dt_interpret("device-end");
300+
301+
olpc_dt_interpret("\" /rtc\" find-device");
302+
olpc_dt_interpret(" \" olpc,xo1-rtc\" +compatible");
303+
olpc_dt_interpret("device-end");
268304
}
305+
306+
/* Add olpc,xo1-battery compatible marker to battery node */
307+
olpc_dt_interpret("\" /battery@0\" find-device");
308+
olpc_dt_interpret(" \" olpc,xo1-battery\" +compatible");
309+
olpc_dt_interpret("device-end");
269310
}
270311

271312
void __init olpc_dt_build_devicetree(void)

0 commit comments

Comments
 (0)