Skip to content

Commit

Permalink
Merge tag 'for-v5.6' 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:
 "Core:
   - Add battery internal resistance temperature table support

  Drivers:
   - sc27xx: Optimize the battery resistance with measuring temperature
   - max17042-battery: Add MAX17055 support
   - bq25890-charger: Add support of BQ25892 and BQ25896 chips
   - misc fixes"

* tag 'for-v5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (44 commits)
  power: supply: ipaq_micro_battery: remove unneeded semicolon
  power: supply: bq25890_charger: fix incorrect error return when bq25890_field_read fails
  power: supply: axp20x_usb_power: Only poll while offline
  power: supply: axp20x_usb_power: Add wakeup control
  power: supply: axp20x_usb_power: Allow offlining
  power: supply: axp20x_usb_power: Use a match structure
  power: suppy: ucs1002: Make the symbol 'ucs1002_regulator_enable' static
  power: reset: at91-poweroff: use proper master clock register offset
  power: reset: at91-poweroff: introduce struct shdwc_reg_config
  power: supply: bq25890_charger: Add DT and I2C ids for all supported chips
  dt-bindings: Add new chips to bq25890 binding documentation
  power: supply: bq25890_charger: Add support of BQ25892 and BQ25896 chips
  power: supply: core: Update sysfs-class-power ABI document
  power: supply: sbs-battery: Fix a signedness bug in sbs_get_battery_capacity()
  power: supply: ltc2941-battery-gauge: fix use-after-free
  power: supply: max17040: Correct IRQ wake handling
  power: supply: axp20x_usb_power: Remove unused device_node
  power: supply: axp20x_ac_power: Add wakeup control
  power: supply: axp20x_ac_power: Allow offlining
  power: supply: axp20x_ac_power: Fix reporting online status
  ...
  • Loading branch information
Linus Torvalds committed Jan 30, 2020
2 parents 893e591 + 3d32a84 commit 4cadc60
Show file tree
Hide file tree
Showing 30 changed files with 882 additions and 210 deletions.
3 changes: 2 additions & 1 deletion Documentation/ABI/testing/sysfs-class-power
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,8 @@ Description:
Access: Read
Valid values: "Unknown", "Good", "Overheat", "Dead",
"Over voltage", "Unspecified failure", "Cold",
"Watchdog timer expire", "Safety timer expire"
"Watchdog timer expire", "Safety timer expire",
"Over current"

What: /sys/class/power_supply/<supply_name>/precharge_current
Date: June 2017
Expand Down
5 changes: 5 additions & 0 deletions Documentation/devicetree/bindings/power/supply/battery.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,10 @@ Optional Properties:
for each of the battery capacity lookup table. The first temperature value
specifies the OCV table 0, and the second temperature value specifies the
OCV table 1, and so on.
- resistance-temp-table: An array providing the temperature in degree Celsius
and corresponding battery internal resistance percent, which is used to look
up the resistance percent according to current temperature to get a accurate
batterty internal resistance in different temperatures.

Battery properties are named, where possible, for the corresponding
elements in enum power_supply_property, defined in
Expand All @@ -61,6 +65,7 @@ Example:
ocv-capacity-table-0 = <4185000 100>, <4113000 95>, <4066000 90>, ...;
ocv-capacity-table-1 = <4200000 100>, <4185000 95>, <4113000 90>, ...;
ocv-capacity-table-2 = <4250000 100>, <4200000 95>, <4185000 90>, ...;
resistance-temp-table = <20 100>, <10 90>, <0 80>, <(-10) 60>;
};

charger: charger@11 {
Expand Down
7 changes: 5 additions & 2 deletions Documentation/devicetree/bindings/power/supply/bq25890.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
Binding for TI bq25890 Li-Ion Charger

This driver will support the bq25896 and the bq25890. There are other ICs
in the same family but those have not been tested.
This driver will support the bq25892, the bq25896 and the bq25890. There are
other ICs in the same family but those have not been tested.

Required properties:
- compatible: Should contain one of the following:
* "ti,bq25890"
* "ti,bq25892"
* "ti,bq25895"
* "ti,bq25896"
- reg: integer, i2c address of the device.
- ti,battery-regulation-voltage: integer, maximum charging voltage (in uV);
- ti,charge-current: integer, maximum charging current (in uA);
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
max17040_battery
~~~~~~~~~~~~~~~~

Required properties :
- compatible : "maxim,max17040" or "maxim,max77836-battery"
- reg: i2c slave address

Optional properties :
- maxim,alert-low-soc-level : The alert threshold that sets the state of
charge level (%) where an interrupt is
generated. Can be configured from 1 up to 32
(%). If skipped the power up default value of
4 (%) will be used.
- interrupts : Interrupt line see Documentation/devicetree/
bindings/interrupt-controller/interrupts.txt
- wakeup-source : This device has wakeup capabilities. Use this
property to use alert low SOC level interrupt
as wake up source.

Optional properties support interrupt functionality for alert low state of
charge level, present in some ICs in the same family, and should be used with
compatible "maxim,max77836-battery".

Example:

battery-fuel-gauge@36 {
compatible = "maxim,max77836-battery";
reg = <0x36>;
maxim,alert-low-soc-level = <10>;
interrupt-parent = <&gpio7>;
interrupts = <2 IRQ_TYPE_EDGE_FALLING>;
wakeup-source;
};
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ max17042_battery
~~~~~~~~~~~~~~~~

Required properties :
- compatible : "maxim,max17042"
- compatible : one of the following
* "maxim,max17042"
* "maxim,max17047"
* "maxim,max17050"
* "maxim,max17055"

Optional properties :
- maxim,rsns-microohm : Resistance of rsns resistor in micro Ohms
Expand Down
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/power/supply/sc27xx-fg.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ Required properties:
- io-channel-names: Should be "bat-temp" or "charge-vol".
- nvmem-cells: A phandle to the calibration cells provided by eFuse device.
- nvmem-cell-names: Should be "fgu_calib".
- sprd,calib-resistance-micro-ohms: Specify the real resistance of coulomb counter
chip in micro Ohms.
- monitored-battery: Phandle of battery characteristics devicetree node.
See Documentation/devicetree/bindings/power/supply/battery.txt

Expand Down Expand Up @@ -52,5 +54,6 @@ Example:
nvmem-cells = <&fgu_calib>;
nvmem-cell-names = "fgu_calib";
monitored-battery = <&bat>;
sprd,calib-resistance-micro-ohms = <21500>;
};
};
16 changes: 8 additions & 8 deletions drivers/power/reset/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -141,14 +141,14 @@ config POWER_RESET_LTC2952
down via the LTC2952. Bindings are made in the device tree.

config POWER_RESET_MT6323
bool "MediaTek MT6323 power-off driver"
depends on MFD_MT6397
help
The power-off driver is responsible for externally shutdown down
the power of a remote MediaTek SoC MT6323 is connected to through
controlling a tiny circuit BBPU inside MT6323 RTC.

Say Y if you have a board where MT6323 could be found.
bool "MediaTek MT6323 power-off driver"
depends on MFD_MT6397
help
The power-off driver is responsible for externally shutdown down
the power of a remote MediaTek SoC MT6323 is connected to through
controlling a tiny circuit BBPU inside MT6323 RTC.

Say Y if you have a board where MT6323 could be found.

config POWER_RESET_QNAP
bool "QNAP power-off driver"
Expand Down
72 changes: 47 additions & 25 deletions drivers/power/reset/at91-sama5d2_shdwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,25 @@

#define SHDW_CFG_NOT_USED (32)

struct shdwc_config {
struct shdwc_reg_config {
u8 wkup_pin_input;
u8 mr_rtcwk_shift;
u8 mr_rttwk_shift;
u8 sr_rtcwk_shift;
u8 sr_rttwk_shift;
};

struct pmc_reg_config {
u8 mckr;
};

struct reg_config {
struct shdwc_reg_config shdwc;
struct pmc_reg_config pmc;
};

struct shdwc {
const struct shdwc_config *cfg;
const struct reg_config *rcfg;
struct clk *sclk;
void __iomem *shdwc_base;
void __iomem *mpddrc_base;
Expand All @@ -95,6 +104,7 @@ static const unsigned long long sdwc_dbc_period[] = {
static void __init at91_wakeup_status(struct platform_device *pdev)
{
struct shdwc *shdw = platform_get_drvdata(pdev);
const struct reg_config *rcfg = shdw->rcfg;
u32 reg;
char *reason = "unknown";

Expand All @@ -106,11 +116,11 @@ static void __init at91_wakeup_status(struct platform_device *pdev)
if (!reg)
return;

if (SHDW_WK_PIN(reg, shdw->cfg))
if (SHDW_WK_PIN(reg, &rcfg->shdwc))
reason = "WKUP pin";
else if (SHDW_RTCWK(reg, shdw->cfg))
else if (SHDW_RTCWK(reg, &rcfg->shdwc))
reason = "RTC";
else if (SHDW_RTTWK(reg, shdw->cfg))
else if (SHDW_RTTWK(reg, &rcfg->shdwc))
reason = "RTT";

pr_info("AT91: Wake-Up source: %s\n", reason);
Expand All @@ -131,9 +141,9 @@ static void at91_poweroff(void)
" str %1, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t"

/* Switch the master clock source to slow clock. */
"1: ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
"1: ldr r6, [%4, %5]\n\t"
" bic r6, r6, #" __stringify(AT91_PMC_CSS) "\n\t"
" str r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
" str r6, [%4, %5]\n\t"
/* Wait for clock switch. */
"2: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t"
" tst r6, #" __stringify(AT91_PMC_MCKRDY) "\n\t"
Expand All @@ -148,7 +158,8 @@ static void at91_poweroff(void)
"r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF),
"r" (at91_shdwc->shdwc_base),
"r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW),
"r" (at91_shdwc->pmc_base)
"r" (at91_shdwc->pmc_base),
"r" (at91_shdwc->rcfg->pmc.mckr)
: "r6");
}

Expand Down Expand Up @@ -215,6 +226,7 @@ static u32 at91_shdwc_get_wakeup_input(struct platform_device *pdev,
static void at91_shdwc_dt_configure(struct platform_device *pdev)
{
struct shdwc *shdw = platform_get_drvdata(pdev);
const struct reg_config *rcfg = shdw->rcfg;
struct device_node *np = pdev->dev.of_node;
u32 mode = 0, tmp, input;

Expand All @@ -227,10 +239,10 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev)
mode |= AT91_SHDW_WKUPDBC(at91_shdwc_debouncer_value(pdev, tmp));

if (of_property_read_bool(np, "atmel,wakeup-rtc-timer"))
mode |= SHDW_RTCWKEN(shdw->cfg);
mode |= SHDW_RTCWKEN(&rcfg->shdwc);

if (of_property_read_bool(np, "atmel,wakeup-rtt-timer"))
mode |= SHDW_RTTWKEN(shdw->cfg);
mode |= SHDW_RTTWKEN(&rcfg->shdwc);

dev_dbg(&pdev->dev, "%s: mode = %#x\n", __func__, mode);
writel(mode, shdw->shdwc_base + AT91_SHDW_MR);
Expand All @@ -239,30 +251,40 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev)
writel(input, shdw->shdwc_base + AT91_SHDW_WUIR);
}

static const struct shdwc_config sama5d2_shdwc_config = {
.wkup_pin_input = 0,
.mr_rtcwk_shift = 17,
.mr_rttwk_shift = SHDW_CFG_NOT_USED,
.sr_rtcwk_shift = 5,
.sr_rttwk_shift = SHDW_CFG_NOT_USED,
static const struct reg_config sama5d2_reg_config = {
.shdwc = {
.wkup_pin_input = 0,
.mr_rtcwk_shift = 17,
.mr_rttwk_shift = SHDW_CFG_NOT_USED,
.sr_rtcwk_shift = 5,
.sr_rttwk_shift = SHDW_CFG_NOT_USED,
},
.pmc = {
.mckr = 0x30,
},
};

static const struct shdwc_config sam9x60_shdwc_config = {
.wkup_pin_input = 0,
.mr_rtcwk_shift = 17,
.mr_rttwk_shift = 16,
.sr_rtcwk_shift = 5,
.sr_rttwk_shift = 4,
static const struct reg_config sam9x60_reg_config = {
.shdwc = {
.wkup_pin_input = 0,
.mr_rtcwk_shift = 17,
.mr_rttwk_shift = 16,
.sr_rtcwk_shift = 5,
.sr_rttwk_shift = 4,
},
.pmc = {
.mckr = 0x28,
},
};

static const struct of_device_id at91_shdwc_of_match[] = {
{
.compatible = "atmel,sama5d2-shdwc",
.data = &sama5d2_shdwc_config,
.data = &sama5d2_reg_config,
},
{
.compatible = "microchip,sam9x60-shdwc",
.data = &sam9x60_shdwc_config,
.data = &sam9x60_reg_config,
}, {
/*sentinel*/
}
Expand Down Expand Up @@ -303,7 +325,7 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
}

match = of_match_node(at91_shdwc_of_match, pdev->dev.of_node);
at91_shdwc->cfg = match->data;
at91_shdwc->rcfg = match->data;

at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(at91_shdwc->sclk))
Expand Down
8 changes: 5 additions & 3 deletions drivers/power/reset/gpio-restart.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,11 @@ static int gpio_restart_probe(struct platform_device *pdev)

gpio_restart->reset_gpio = devm_gpiod_get(&pdev->dev, NULL,
open_source ? GPIOD_IN : GPIOD_OUT_LOW);
if (IS_ERR(gpio_restart->reset_gpio)) {
dev_err(&pdev->dev, "Could not get reset GPIO\n");
return PTR_ERR(gpio_restart->reset_gpio);
ret = PTR_ERR_OR_ZERO(gpio_restart->reset_gpio);
if (ret) {
if (ret != -EPROBE_DEFER)
dev_err(&pdev->dev, "Could not get reset GPIO\n");
return ret;
}

gpio_restart->restart_handler.notifier_call = gpio_restart_notify;
Expand Down
30 changes: 15 additions & 15 deletions drivers/power/supply/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,10 @@ config WM831X_POWER
provided by Wolfson Microelectronics WM831x PMICs.

config WM8350_POWER
tristate "WM8350 PMU support"
depends on MFD_WM8350
help
Say Y here to enable support for the power management unit
tristate "WM8350 PMU support"
depends on MFD_WM8350
help
Say Y here to enable support for the power management unit
provided by the Wolfson Microelectronics WM8350 PMIC.

config TEST_POWER
Expand Down Expand Up @@ -209,16 +209,16 @@ config BATTERY_WM97XX
Say Y to enable support for battery measured by WM97xx aux port.

config BATTERY_SBS
tristate "SBS Compliant gas gauge"
depends on I2C
help
tristate "SBS Compliant gas gauge"
depends on I2C
help
Say Y to include support for SBS battery driver for SBS-compliant
gas gauges.

config CHARGER_SBS
tristate "SBS Compliant charger"
depends on I2C
help
tristate "SBS Compliant charger"
depends on I2C
help
Say Y to include support for SBS compliant battery chargers.

config MANAGER_SBS
Expand Down Expand Up @@ -484,11 +484,11 @@ config CHARGER_MANAGER
depends on REGULATOR
select EXTCON
help
Say Y to enable charger-manager support, which allows multiple
chargers attached to a battery and multiple batteries attached to a
system. The charger-manager also can monitor charging status in
runtime and in suspend-to-RAM by waking up the system periodically
with help of suspend_again support.
Say Y to enable charger-manager support, which allows multiple
chargers attached to a battery and multiple batteries attached to a
system. The charger-manager also can monitor charging status in
runtime and in suspend-to-RAM by waking up the system periodically
with help of suspend_again support.

config CHARGER_LT3651
tristate "Analog Devices LT3651 charger"
Expand Down
6 changes: 3 additions & 3 deletions drivers/power/supply/ab8500_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -789,7 +789,7 @@ static int ab8500_charger_max_usb_curr(struct ab8500_charger *di,
di->max_usb_in_curr.usb_type_max = USB_CH_IP_CUR_LVL_0P05;
ret = -ENXIO;
break;
};
}

di->max_usb_in_curr.set_max = di->max_usb_in_curr.usb_type_max;
dev_dbg(di->dev, "USB Type - 0x%02x MaxCurr: %d",
Expand Down Expand Up @@ -1079,7 +1079,7 @@ static int ab8500_charger_get_usb_cur(struct ab8500_charger *di)
di->max_usb_in_curr.usb_type_max = USB_CH_IP_CUR_LVL_0P05;
ret = -EPERM;
break;
};
}
di->max_usb_in_curr.set_max = di->max_usb_in_curr.usb_type_max;
return ret;
}
Expand Down Expand Up @@ -2427,7 +2427,7 @@ static void ab8500_charger_usb_state_changed_work(struct work_struct *work)

default:
break;
};
}
}

/**
Expand Down
Loading

0 comments on commit 4cadc60

Please sign in to comment.