Skip to content

Commit 17d4ded

Browse files
committed
Merge tag 'for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply
Pull power supply and reset updates from Sebastian Reichel: - power-supply core support for automatic handling of constant battery data supplied by firmware - generic-adc-battery: major cleanup - axp288_charger: fix ACPI issues on x86 Android tablets - rk817: cleanup and fix handling for low state of charge * tag 'for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (26 commits) power: supply: rk817: Fix low SOC bugs power: supply: rk817: Drop unneeded debugging code power: supply: axp288_charger: Use alt usb-id extcon on some x86 android tablets power: supply: generic-adc-battery: style fixes power: supply: generic-adc-battery: improve error message power: supply: generic-adc-battery: update copyright info power: supply: generic-adc-battery: add DT support power: supply: generic-adc-battery: add temperature support power: supply: generic-adc-battery: simplify read_channel logic power: supply: generic-adc-battery: use simple-battery API power: supply: generic-adc-battery: drop memory alloc error message power: supply: generic-adc-battery: drop charge now support power: supply: generic-adc-battery: drop jitter delay support power: supply: generic-adc-battery: fix unit scaling power: supply: generic-adc-battery: convert to managed resources power: supply: core: auto-exposure of simple-battery data dt-bindings: power: supply: adc-battery: add binding power: supply: bq256xx: Support to disable charger power: supply: charger-manager: Use of_property_read_bool() for boolean properties power: reset: qcom-pon: drop of_match_ptr for ID table ...
2 parents e81507a + baba131 commit 17d4ded

17 files changed

+412
-253
lines changed
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/power/supply/adc-battery.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: ADC battery
8+
9+
maintainers:
10+
- Sebastian Reichel <sre@kernel.org>
11+
12+
description:
13+
Basic battery capacity meter, which only reports basic battery data
14+
via ADC channels and optionally indicate that the battery is full by
15+
polling a GPIO line.
16+
17+
The voltage is expected to be measured between the battery terminals
18+
and mandatory. The optional current/power channel is expected to
19+
monitor the current/power flowing out of the battery. Last but not
20+
least the temperature channel is supposed to measure the battery
21+
temperature.
22+
23+
allOf:
24+
- $ref: power-supply.yaml#
25+
26+
properties:
27+
compatible:
28+
const: adc-battery
29+
30+
charged-gpios:
31+
description:
32+
GPIO which signals that the battery is fully charged. The GPIO is
33+
often provided by charger ICs, that are not software controllable.
34+
maxItems: 1
35+
36+
io-channels:
37+
minItems: 1
38+
maxItems: 4
39+
40+
io-channel-names:
41+
minItems: 1
42+
items:
43+
- const: voltage
44+
- enum: [ current, power, temperature ]
45+
- enum: [ power, temperature ]
46+
- const: temperature
47+
48+
monitored-battery: true
49+
50+
required:
51+
- compatible
52+
- io-channels
53+
- io-channel-names
54+
- monitored-battery
55+
56+
unevaluatedProperties: false
57+
58+
examples:
59+
- |
60+
#include <dt-bindings/gpio/gpio.h>
61+
62+
fuel-gauge {
63+
compatible = "adc-battery";
64+
charged-gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
65+
io-channels = <&adc 13>, <&adc 37>;
66+
io-channel-names = "voltage", "current";
67+
68+
power-supplies = <&charger>;
69+
monitored-battery = <&battery>;
70+
};

drivers/power/reset/qcom-pon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ static struct platform_driver pm8916_pon_driver = {
9191
.probe = pm8916_pon_probe,
9292
.driver = {
9393
.name = "pm8916-pon",
94-
.of_match_table = of_match_ptr(pm8916_pon_id_table),
94+
.of_match_table = pm8916_pon_id_table,
9595
},
9696
};
9797
module_platform_driver(pm8916_pon_driver);

drivers/power/supply/axp288_charger.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -836,6 +836,7 @@ static int axp288_charger_probe(struct platform_device *pdev)
836836
struct device *dev = &pdev->dev;
837837
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
838838
struct power_supply_config charger_cfg = {};
839+
const char *extcon_name = NULL;
839840
unsigned int val;
840841

841842
/*
@@ -872,8 +873,18 @@ static int axp288_charger_probe(struct platform_device *pdev)
872873
return PTR_ERR(info->cable.edev);
873874
}
874875

875-
if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) {
876-
info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME);
876+
/*
877+
* On devices with broken ACPI GPIO event handlers there also is no ACPI
878+
* "INT3496" (USB_HOST_EXTCON_HID) device. x86-android-tablets.ko
879+
* instantiates an "intel-int3496" extcon on these devs as a workaround.
880+
*/
881+
if (acpi_quirk_skip_gpio_event_handlers())
882+
extcon_name = "intel-int3496";
883+
else if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1))
884+
extcon_name = USB_HOST_EXTCON_NAME;
885+
886+
if (extcon_name) {
887+
info->otg.cable = extcon_get_extcon_dev(extcon_name);
877888
if (IS_ERR(info->otg.cable)) {
878889
dev_err_probe(dev, PTR_ERR(info->otg.cable),
879890
"extcon_get_extcon_dev(%s) failed\n",

drivers/power/supply/bq24257_charger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1140,7 +1140,7 @@ static const struct i2c_device_id bq24257_i2c_ids[] = {
11401140
};
11411141
MODULE_DEVICE_TABLE(i2c, bq24257_i2c_ids);
11421142

1143-
static const struct of_device_id bq24257_of_match[] = {
1143+
static const struct of_device_id bq24257_of_match[] __maybe_unused = {
11441144
{ .compatible = "ti,bq24250", },
11451145
{ .compatible = "ti,bq24251", },
11461146
{ .compatible = "ti,bq24257", },

drivers/power/supply/bq256xx_charger.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@
7070
#define BQ25611D_VBATREG_THRESH_uV 4290000
7171
#define BQ25618_VBATREG_THRESH_uV 4300000
7272

73+
#define BQ256XX_CHG_CONFIG_MASK BIT(4)
74+
#define BQ256XX_CHG_CONFIG_BIT_SHIFT 4
75+
7376
#define BQ256XX_ITERM_MASK GENMASK(3, 0)
7477
#define BQ256XX_ITERM_STEP_uA 60000
7578
#define BQ256XX_ITERM_OFFSET_uA 60000
@@ -259,6 +262,7 @@ struct bq256xx_device {
259262
* @bq256xx_set_iterm: pointer to instance specific set_iterm function
260263
* @bq256xx_set_iprechg: pointer to instance specific set_iprechg function
261264
* @bq256xx_set_vindpm: pointer to instance specific set_vindpm function
265+
* @bq256xx_set_charge_type: pointer to instance specific set_charge_type function
262266
*
263267
* @bq256xx_def_ichg: default ichg value in microamps
264268
* @bq256xx_def_iindpm: default iindpm value in microamps
@@ -290,6 +294,7 @@ struct bq256xx_chip_info {
290294
int (*bq256xx_set_iterm)(struct bq256xx_device *bq, int iterm);
291295
int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg);
292296
int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm);
297+
int (*bq256xx_set_charge_type)(struct bq256xx_device *bq, int type);
293298

294299
int bq256xx_def_ichg;
295300
int bq256xx_def_iindpm;
@@ -449,6 +454,27 @@ static int bq256xx_get_state(struct bq256xx_device *bq,
449454
return 0;
450455
}
451456

457+
static int bq256xx_set_charge_type(struct bq256xx_device *bq, int type)
458+
{
459+
int chg_config = 0;
460+
461+
switch (type) {
462+
case POWER_SUPPLY_CHARGE_TYPE_NONE:
463+
chg_config = 0x0;
464+
break;
465+
case POWER_SUPPLY_CHARGE_TYPE_TRICKLE:
466+
case POWER_SUPPLY_CHARGE_TYPE_FAST:
467+
chg_config = 0x1;
468+
break;
469+
default:
470+
return -EINVAL;
471+
}
472+
473+
return regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_0,
474+
BQ256XX_CHG_CONFIG_MASK,
475+
(chg_config ? 1 : 0) << BQ256XX_CHG_CONFIG_BIT_SHIFT);
476+
}
477+
452478
static int bq256xx_get_ichg_curr(struct bq256xx_device *bq)
453479
{
454480
unsigned int charge_current_limit;
@@ -915,6 +941,12 @@ static int bq256xx_set_charger_property(struct power_supply *psy,
915941
return ret;
916942
break;
917943

944+
case POWER_SUPPLY_PROP_CHARGE_TYPE:
945+
ret = bq->chip_info->bq256xx_set_charge_type(bq, val->intval);
946+
if (ret)
947+
return ret;
948+
break;
949+
918950
default:
919951
break;
920952
}
@@ -1197,6 +1229,7 @@ static int bq256xx_property_is_writeable(struct power_supply *psy,
11971229
case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
11981230
case POWER_SUPPLY_PROP_STATUS:
11991231
case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT:
1232+
case POWER_SUPPLY_PROP_CHARGE_TYPE:
12001233
return true;
12011234
default:
12021235
return false;
@@ -1286,6 +1319,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
12861319
.bq256xx_set_iterm = bq256xx_set_term_curr,
12871320
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
12881321
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
1322+
.bq256xx_set_charge_type = bq256xx_set_charge_type,
12891323

12901324
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
12911325
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1316,6 +1350,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
13161350
.bq256xx_set_iterm = bq256xx_set_term_curr,
13171351
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
13181352
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
1353+
.bq256xx_set_charge_type = bq256xx_set_charge_type,
13191354

13201355
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
13211356
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1346,6 +1381,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
13461381
.bq256xx_set_iterm = bq256xx_set_term_curr,
13471382
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
13481383
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
1384+
.bq256xx_set_charge_type = bq256xx_set_charge_type,
13491385

13501386
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
13511387
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1376,6 +1412,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
13761412
.bq256xx_set_iterm = bq256xx_set_term_curr,
13771413
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
13781414
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
1415+
.bq256xx_set_charge_type = bq256xx_set_charge_type,
13791416

13801417
.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
13811418
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1406,6 +1443,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
14061443
.bq256xx_set_iterm = bq256xx_set_term_curr,
14071444
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
14081445
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
1446+
.bq256xx_set_charge_type = bq256xx_set_charge_type,
14091447

14101448
.bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA,
14111449
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1436,6 +1474,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
14361474
.bq256xx_set_iterm = bq25618_619_set_term_curr,
14371475
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
14381476
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
1477+
.bq256xx_set_charge_type = bq256xx_set_charge_type,
14391478

14401479
.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
14411480
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
@@ -1466,6 +1505,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
14661505
.bq256xx_set_iterm = bq25618_619_set_term_curr,
14671506
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
14681507
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
1508+
.bq256xx_set_charge_type = bq256xx_set_charge_type,
14691509

14701510
.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
14711511
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,

drivers/power/supply/bq25890_charger.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1622,7 +1622,7 @@ static const struct i2c_device_id bq25890_i2c_ids[] = {
16221622
};
16231623
MODULE_DEVICE_TABLE(i2c, bq25890_i2c_ids);
16241624

1625-
static const struct of_device_id bq25890_of_match[] = {
1625+
static const struct of_device_id bq25890_of_match[] __maybe_unused = {
16261626
{ .compatible = "ti,bq25890", },
16271627
{ .compatible = "ti,bq25892", },
16281628
{ .compatible = "ti,bq25895", },

drivers/power/supply/charger-manager.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1331,7 +1331,7 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
13311331
of_property_read_string(np, "cm-thermal-zone", &desc->thermal_zone);
13321332

13331333
of_property_read_u32(np, "cm-battery-cold", &desc->temp_min);
1334-
if (of_get_property(np, "cm-battery-cold-in-minus", NULL))
1334+
if (of_property_read_bool(np, "cm-battery-cold-in-minus"))
13351335
desc->temp_min *= -1;
13361336
of_property_read_u32(np, "cm-battery-hot", &desc->temp_max);
13371337
of_property_read_u32(np, "cm-battery-temp-diff", &desc->temp_diff);

0 commit comments

Comments
 (0)