Skip to content

Commit

Permalink
Merge tag 'for-v6.4' of git://git.kernel.org/pub/scm/linux/kernel/git…
Browse files Browse the repository at this point in the history
…/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
  ...
  • Loading branch information
Linus Torvalds committed Apr 30, 2023
2 parents e81507a + baba131 commit 17d4ded
Show file tree
Hide file tree
Showing 17 changed files with 412 additions and 253 deletions.
70 changes: 70 additions & 0 deletions Documentation/devicetree/bindings/power/supply/adc-battery.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/power/supply/adc-battery.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: ADC battery

maintainers:
- Sebastian Reichel <sre@kernel.org>

description:
Basic battery capacity meter, which only reports basic battery data
via ADC channels and optionally indicate that the battery is full by
polling a GPIO line.

The voltage is expected to be measured between the battery terminals
and mandatory. The optional current/power channel is expected to
monitor the current/power flowing out of the battery. Last but not
least the temperature channel is supposed to measure the battery
temperature.

allOf:
- $ref: power-supply.yaml#

properties:
compatible:
const: adc-battery

charged-gpios:
description:
GPIO which signals that the battery is fully charged. The GPIO is
often provided by charger ICs, that are not software controllable.
maxItems: 1

io-channels:
minItems: 1
maxItems: 4

io-channel-names:
minItems: 1
items:
- const: voltage
- enum: [ current, power, temperature ]
- enum: [ power, temperature ]
- const: temperature

monitored-battery: true

required:
- compatible
- io-channels
- io-channel-names
- monitored-battery

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/gpio/gpio.h>
fuel-gauge {
compatible = "adc-battery";
charged-gpios = <&gpio 42 GPIO_ACTIVE_HIGH>;
io-channels = <&adc 13>, <&adc 37>;
io-channel-names = "voltage", "current";
power-supplies = <&charger>;
monitored-battery = <&battery>;
};
2 changes: 1 addition & 1 deletion drivers/power/reset/qcom-pon.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static struct platform_driver pm8916_pon_driver = {
.probe = pm8916_pon_probe,
.driver = {
.name = "pm8916-pon",
.of_match_table = of_match_ptr(pm8916_pon_id_table),
.of_match_table = pm8916_pon_id_table,
},
};
module_platform_driver(pm8916_pon_driver);
Expand Down
15 changes: 13 additions & 2 deletions drivers/power/supply/axp288_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -836,6 +836,7 @@ static int axp288_charger_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev;
struct axp20x_dev *axp20x = dev_get_drvdata(pdev->dev.parent);
struct power_supply_config charger_cfg = {};
const char *extcon_name = NULL;
unsigned int val;

/*
Expand Down Expand Up @@ -872,8 +873,18 @@ static int axp288_charger_probe(struct platform_device *pdev)
return PTR_ERR(info->cable.edev);
}

if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1)) {
info->otg.cable = extcon_get_extcon_dev(USB_HOST_EXTCON_NAME);
/*
* On devices with broken ACPI GPIO event handlers there also is no ACPI
* "INT3496" (USB_HOST_EXTCON_HID) device. x86-android-tablets.ko
* instantiates an "intel-int3496" extcon on these devs as a workaround.
*/
if (acpi_quirk_skip_gpio_event_handlers())
extcon_name = "intel-int3496";
else if (acpi_dev_present(USB_HOST_EXTCON_HID, NULL, -1))
extcon_name = USB_HOST_EXTCON_NAME;

if (extcon_name) {
info->otg.cable = extcon_get_extcon_dev(extcon_name);
if (IS_ERR(info->otg.cable)) {
dev_err_probe(dev, PTR_ERR(info->otg.cable),
"extcon_get_extcon_dev(%s) failed\n",
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/bq24257_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1140,7 +1140,7 @@ static const struct i2c_device_id bq24257_i2c_ids[] = {
};
MODULE_DEVICE_TABLE(i2c, bq24257_i2c_ids);

static const struct of_device_id bq24257_of_match[] = {
static const struct of_device_id bq24257_of_match[] __maybe_unused = {
{ .compatible = "ti,bq24250", },
{ .compatible = "ti,bq24251", },
{ .compatible = "ti,bq24257", },
Expand Down
40 changes: 40 additions & 0 deletions drivers/power/supply/bq256xx_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@
#define BQ25611D_VBATREG_THRESH_uV 4290000
#define BQ25618_VBATREG_THRESH_uV 4300000

#define BQ256XX_CHG_CONFIG_MASK BIT(4)
#define BQ256XX_CHG_CONFIG_BIT_SHIFT 4

#define BQ256XX_ITERM_MASK GENMASK(3, 0)
#define BQ256XX_ITERM_STEP_uA 60000
#define BQ256XX_ITERM_OFFSET_uA 60000
Expand Down Expand Up @@ -259,6 +262,7 @@ struct bq256xx_device {
* @bq256xx_set_iterm: pointer to instance specific set_iterm function
* @bq256xx_set_iprechg: pointer to instance specific set_iprechg function
* @bq256xx_set_vindpm: pointer to instance specific set_vindpm function
* @bq256xx_set_charge_type: pointer to instance specific set_charge_type function
*
* @bq256xx_def_ichg: default ichg value in microamps
* @bq256xx_def_iindpm: default iindpm value in microamps
Expand Down Expand Up @@ -290,6 +294,7 @@ struct bq256xx_chip_info {
int (*bq256xx_set_iterm)(struct bq256xx_device *bq, int iterm);
int (*bq256xx_set_iprechg)(struct bq256xx_device *bq, int iprechg);
int (*bq256xx_set_vindpm)(struct bq256xx_device *bq, int vindpm);
int (*bq256xx_set_charge_type)(struct bq256xx_device *bq, int type);

int bq256xx_def_ichg;
int bq256xx_def_iindpm;
Expand Down Expand Up @@ -449,6 +454,27 @@ static int bq256xx_get_state(struct bq256xx_device *bq,
return 0;
}

static int bq256xx_set_charge_type(struct bq256xx_device *bq, int type)
{
int chg_config = 0;

switch (type) {
case POWER_SUPPLY_CHARGE_TYPE_NONE:
chg_config = 0x0;
break;
case POWER_SUPPLY_CHARGE_TYPE_TRICKLE:
case POWER_SUPPLY_CHARGE_TYPE_FAST:
chg_config = 0x1;
break;
default:
return -EINVAL;
}

return regmap_update_bits(bq->regmap, BQ256XX_CHARGER_CONTROL_0,
BQ256XX_CHG_CONFIG_MASK,
(chg_config ? 1 : 0) << BQ256XX_CHG_CONFIG_BIT_SHIFT);
}

static int bq256xx_get_ichg_curr(struct bq256xx_device *bq)
{
unsigned int charge_current_limit;
Expand Down Expand Up @@ -915,6 +941,12 @@ static int bq256xx_set_charger_property(struct power_supply *psy,
return ret;
break;

case POWER_SUPPLY_PROP_CHARGE_TYPE:
ret = bq->chip_info->bq256xx_set_charge_type(bq, val->intval);
if (ret)
return ret;
break;

default:
break;
}
Expand Down Expand Up @@ -1197,6 +1229,7 @@ static int bq256xx_property_is_writeable(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_TERM_CURRENT:
case POWER_SUPPLY_PROP_STATUS:
case POWER_SUPPLY_PROP_INPUT_VOLTAGE_LIMIT:
case POWER_SUPPLY_PROP_CHARGE_TYPE:
return true;
default:
return false;
Expand Down Expand Up @@ -1286,6 +1319,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iterm = bq256xx_set_term_curr,
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,

.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
Expand Down Expand Up @@ -1316,6 +1350,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iterm = bq256xx_set_term_curr,
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,

.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
Expand Down Expand Up @@ -1346,6 +1381,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iterm = bq256xx_set_term_curr,
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,

.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
Expand Down Expand Up @@ -1376,6 +1412,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iterm = bq256xx_set_term_curr,
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,

.bq256xx_def_ichg = BQ2560X_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
Expand Down Expand Up @@ -1406,6 +1443,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iterm = bq256xx_set_term_curr,
.bq256xx_set_iprechg = bq256xx_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,

.bq256xx_def_ichg = BQ25611D_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
Expand Down Expand Up @@ -1436,6 +1474,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iterm = bq25618_619_set_term_curr,
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,

.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
Expand Down Expand Up @@ -1466,6 +1505,7 @@ static const struct bq256xx_chip_info bq256xx_chip_info_tbl[] = {
.bq256xx_set_iterm = bq25618_619_set_term_curr,
.bq256xx_set_iprechg = bq25618_619_set_prechrg_curr,
.bq256xx_set_vindpm = bq256xx_set_input_volt_lim,
.bq256xx_set_charge_type = bq256xx_set_charge_type,

.bq256xx_def_ichg = BQ25618_ICHG_DEF_uA,
.bq256xx_def_iindpm = BQ256XX_IINDPM_DEF_uA,
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/bq25890_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -1622,7 +1622,7 @@ static const struct i2c_device_id bq25890_i2c_ids[] = {
};
MODULE_DEVICE_TABLE(i2c, bq25890_i2c_ids);

static const struct of_device_id bq25890_of_match[] = {
static const struct of_device_id bq25890_of_match[] __maybe_unused = {
{ .compatible = "ti,bq25890", },
{ .compatible = "ti,bq25892", },
{ .compatible = "ti,bq25895", },
Expand Down
2 changes: 1 addition & 1 deletion drivers/power/supply/charger-manager.c
Original file line number Diff line number Diff line change
Expand Up @@ -1331,7 +1331,7 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev)
of_property_read_string(np, "cm-thermal-zone", &desc->thermal_zone);

of_property_read_u32(np, "cm-battery-cold", &desc->temp_min);
if (of_get_property(np, "cm-battery-cold-in-minus", NULL))
if (of_property_read_bool(np, "cm-battery-cold-in-minus"))
desc->temp_min *= -1;
of_property_read_u32(np, "cm-battery-hot", &desc->temp_max);
of_property_read_u32(np, "cm-battery-temp-diff", &desc->temp_diff);
Expand Down
Loading

0 comments on commit 17d4ded

Please sign in to comment.