Skip to content

Commit

Permalink
Merge tag 'for-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/gi…
Browse files Browse the repository at this point in the history
…t/sre/linux-power-supply

Pull power supply and reset updates from Sebastian Reichel:

 - Add Spreadtrum SC2731 charger driver

 - bq25890-charger: Add BQ25896 support

 - bq27xxx-battery: Add support for BQ27411

 - qcom-pon: Add pms405 pon support

 - cros-charger: add support for dedicated port

 - misc fixes

* tag 'for-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/sre/linux-power-supply: (28 commits)
  power: max8925: mark expected switch fall-through
  power: supply: fix spelling mistake "Gauage" -> "Gauge"
  power: reset: qcom-pon: Add pms405 pon support
  power: supply: bq27xxx: Add support for BQ27411
  power: supply: Add Spreadtrum SC2731 charger support
  dt-bindings: power: Add Spreadtrum SC2731 charger documentation
  power: supply: twl4030_charger: disable eoc interrupt on linear charge
  power: supply: twl4030_charger: fix charging current out-of-bounds
  power: supply: bq25890_charger: fix semicolon.cocci warnings
  power: supply: max8998-charger: Fix platform data retrieval
  power: supply: cros: add support for dedicated port
  mfd: cros: add charger port count command definition
  power: reset: at91-poweroff: do not procede if at91_shdwc is allocated
  power: reset: at91-poweroff: rename at91_shdwc_base member of struct shdwc
  power: reset: at91-poweroff: make sclk part of struct shdwc
  power: reset: at91-poweroff: make mpddrc_base part of struct shdwc
  power: reset: at91-poweroff: use only one poweroff function
  power: reset: at91-poweroff: switch to slow clock before shutdown
  power: reset: convert to SPDX identifiers
  power: supply: ab8500_fg: silence uninitialized variable warnings
  ...
  • Loading branch information
Linus Torvalds committed Oct 25, 2018
2 parents 96f2f66 + cfb3479 commit df132e4
Show file tree
Hide file tree
Showing 30 changed files with 922 additions and 213 deletions.
5 changes: 4 additions & 1 deletion Documentation/devicetree/bindings/power/reset/qcom,pon.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,10 @@ and resin along with the Android reboot-mode.
This DT node has pwrkey and resin as sub nodes.

Required Properties:
-compatible: "qcom,pm8916-pon"
-compatible: Must be one of:
"qcom,pm8916-pon"
"qcom,pms405-pon"

-reg: Specifies the physical address of the pon register

Optional subnode:
Expand Down
3 changes: 3 additions & 0 deletions Documentation/devicetree/bindings/power/supply/bq25890.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
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.

Required properties:
- compatible: Should contain one of the following:
* "ti,bq25890"
Expand Down
1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/power/supply/bq27xxx.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ Required properties:
* "ti,bq27546" - BQ27546
* "ti,bq27742" - BQ27742
* "ti,bq27545" - BQ27545
* "ti,bq27411" - BQ27411
* "ti,bq27421" - BQ27421
* "ti,bq27425" - BQ27425
* "ti,bq27426" - BQ27426
Expand Down
40 changes: 40 additions & 0 deletions Documentation/devicetree/bindings/power/supply/sc2731_charger.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
Spreadtrum SC2731 PMIC battery charger binding

Required properties:
- compatible: Should be "sprd,sc2731-charger".
- reg: Address offset of charger register.
- phys: Contains a phandle to the USB phy.

Optional Properties:
- monitored-battery: phandle of battery characteristics devicetree node.
The charger uses the following battery properties:
- charge-term-current-microamp: current for charge termination phase.
- constant-charge-voltage-max-microvolt: maximum constant input voltage.
See Documentation/devicetree/bindings/power/supply/battery.txt

Example:

bat: battery {
compatible = "simple-battery";
charge-term-current-microamp = <120000>;
constant-charge-voltage-max-microvolt = <4350000>;
......
};

sc2731_pmic: pmic@0 {
compatible = "sprd,sc2731";
reg = <0>;
spi-max-frequency = <26000000>;
interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
interrupt-controller;
#interrupt-cells = <2>;
#address-cells = <1>;
#size-cells = <0>;

charger@0 {
compatible = "sprd,sc2731-charger";
reg = <0x0>;
phys = <&ssphy>;
monitored-battery = <&bat>;
};
};
8 changes: 8 additions & 0 deletions arch/arm/mach-at91/pm_suspend.S
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,14 @@ exit_suspend:
ENDPROC(at91_pm_suspend_in_sram)

ENTRY(at91_backup_mode)
/* Switch the master clock source to slow clock. */
ldr pmc, .pmc_base
ldr tmp1, [pmc, #AT91_PMC_MCKR]
bic tmp1, tmp1, #AT91_PMC_CSS
str tmp1, [pmc, #AT91_PMC_MCKR]

wait_mckrdy

/*BUMEN*/
ldr r0, .sfr
mov tmp1, #0x1
Expand Down
119 changes: 80 additions & 39 deletions drivers/power/reset/at91-sama5d2_shdwc.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
*/

#include <linux/clk.h>
#include <linux/clk/at91_pmc.h>
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
Expand Down Expand Up @@ -69,16 +70,17 @@ struct shdwc_config {

struct shdwc {
const struct shdwc_config *cfg;
void __iomem *at91_shdwc_base;
struct clk *sclk;
void __iomem *shdwc_base;
void __iomem *mpddrc_base;
void __iomem *pmc_base;
};

/*
* Hold configuration here, cannot be more than one instance of the driver
* since pm_power_off itself is global.
*/
static struct shdwc *at91_shdwc;
static struct clk *sclk;
static void __iomem *mpddrc_base;

static const unsigned long long sdwc_dbc_period[] = {
0, 3, 32, 512, 4096, 32768,
Expand All @@ -90,7 +92,7 @@ static void __init at91_wakeup_status(struct platform_device *pdev)
u32 reg;
char *reason = "unknown";

reg = readl(shdw->at91_shdwc_base + AT91_SHDW_SR);
reg = readl(shdw->shdwc_base + AT91_SHDW_SR);

dev_dbg(&pdev->dev, "%s: status = %#x\n", __func__, reg);

Expand All @@ -107,12 +109,6 @@ static void __init at91_wakeup_status(struct platform_device *pdev)
}

static void at91_poweroff(void)
{
writel(AT91_SHDW_KEY | AT91_SHDW_SHDW,
at91_shdwc->at91_shdwc_base + AT91_SHDW_CR);
}

static void at91_lpddr_poweroff(void)
{
asm volatile(
/* Align to cache lines */
Expand All @@ -122,16 +118,29 @@ static void at91_lpddr_poweroff(void)
" ldr r6, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t"

/* Power down SDRAM0 */
" tst %0, #0\n\t"
" beq 1f\n\t"
" 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"
" bic r6, r6, #" __stringify(AT91_PMC_CSS) "\n\t"
" str r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
/* Wait for clock switch. */
"2: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t"
" tst r6, #" __stringify(AT91_PMC_MCKRDY) "\n\t"
" beq 2b\n\t"

/* Shutdown CPU */
" str %3, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t"

" b .\n\t"
:
: "r" (mpddrc_base),
: "r" (at91_shdwc->mpddrc_base),
"r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF),
"r" (at91_shdwc->at91_shdwc_base),
"r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW)
"r" (at91_shdwc->shdwc_base),
"r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW),
"r" (at91_shdwc->pmc_base)
: "r6");
}

Expand Down Expand Up @@ -213,10 +222,10 @@ static void at91_shdwc_dt_configure(struct platform_device *pdev)
mode |= SHDW_RTCWKEN(shdw->cfg);

dev_dbg(&pdev->dev, "%s: mode = %#x\n", __func__, mode);
writel(mode, shdw->at91_shdwc_base + AT91_SHDW_MR);
writel(mode, shdw->shdwc_base + AT91_SHDW_MR);

input = at91_shdwc_get_wakeup_input(pdev, np);
writel(input, shdw->at91_shdwc_base + AT91_SHDW_WUIR);
writel(input, shdw->shdwc_base + AT91_SHDW_WUIR);
}

static const struct shdwc_config sama5d2_shdwc_config = {
Expand Down Expand Up @@ -246,27 +255,30 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)
if (!pdev->dev.of_node)
return -ENODEV;

if (at91_shdwc)
return -EBUSY;

at91_shdwc = devm_kzalloc(&pdev->dev, sizeof(*at91_shdwc), GFP_KERNEL);
if (!at91_shdwc)
return -ENOMEM;

platform_set_drvdata(pdev, at91_shdwc);

res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
at91_shdwc->at91_shdwc_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(at91_shdwc->at91_shdwc_base)) {
at91_shdwc->shdwc_base = devm_ioremap_resource(&pdev->dev, res);
if (IS_ERR(at91_shdwc->shdwc_base)) {
dev_err(&pdev->dev, "Could not map reset controller address\n");
return PTR_ERR(at91_shdwc->at91_shdwc_base);
return PTR_ERR(at91_shdwc->shdwc_base);
}

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

sclk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(sclk))
return PTR_ERR(sclk);
at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
if (IS_ERR(at91_shdwc->sclk))
return PTR_ERR(at91_shdwc->sclk);

ret = clk_prepare_enable(sclk);
ret = clk_prepare_enable(at91_shdwc->sclk);
if (ret) {
dev_err(&pdev->dev, "Could not enable slow clock\n");
return ret;
Expand All @@ -276,41 +288,70 @@ static int __init at91_shdwc_probe(struct platform_device *pdev)

at91_shdwc_dt_configure(pdev);

pm_power_off = at91_poweroff;
np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-pmc");
if (!np) {
ret = -ENODEV;
goto clk_disable;
}

at91_shdwc->pmc_base = of_iomap(np, 0);
of_node_put(np);

if (!at91_shdwc->pmc_base) {
ret = -ENOMEM;
goto clk_disable;
}

np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc");
if (!np)
return 0;
if (!np) {
ret = -ENODEV;
goto unmap;
}

mpddrc_base = of_iomap(np, 0);
at91_shdwc->mpddrc_base = of_iomap(np, 0);
of_node_put(np);

if (!mpddrc_base)
return 0;
if (!at91_shdwc->mpddrc_base) {
ret = -ENOMEM;
goto unmap;
}

ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & AT91_DDRSDRC_MD;
if ((ddr_type == AT91_DDRSDRC_MD_LPDDR2) ||
(ddr_type == AT91_DDRSDRC_MD_LPDDR3))
pm_power_off = at91_lpddr_poweroff;
else
iounmap(mpddrc_base);
pm_power_off = at91_poweroff;

ddr_type = readl(at91_shdwc->mpddrc_base + AT91_DDRSDRC_MDR) &
AT91_DDRSDRC_MD;
if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
iounmap(at91_shdwc->mpddrc_base);
at91_shdwc->mpddrc_base = NULL;
}

return 0;

unmap:
iounmap(at91_shdwc->pmc_base);
clk_disable:
clk_disable_unprepare(at91_shdwc->sclk);

return ret;
}

static int __exit at91_shdwc_remove(struct platform_device *pdev)
{
struct shdwc *shdw = platform_get_drvdata(pdev);

if (pm_power_off == at91_poweroff ||
pm_power_off == at91_lpddr_poweroff)
if (pm_power_off == at91_poweroff)
pm_power_off = NULL;

/* Reset values to disable wake-up features */
writel(0, shdw->at91_shdwc_base + AT91_SHDW_MR);
writel(0, shdw->at91_shdwc_base + AT91_SHDW_WUIR);
writel(0, shdw->shdwc_base + AT91_SHDW_MR);
writel(0, shdw->shdwc_base + AT91_SHDW_WUIR);

if (shdw->mpddrc_base)
iounmap(shdw->mpddrc_base);
iounmap(shdw->pmc_base);

clk_disable_unprepare(sclk);
clk_disable_unprepare(shdw->sclk);

return 0;
}
Expand Down
1 change: 1 addition & 0 deletions drivers/power/reset/qcom-pon.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ static int pm8916_pon_probe(struct platform_device *pdev)

static const struct of_device_id pm8916_pon_id_table[] = {
{ .compatible = "qcom,pm8916-pon" },
{ .compatible = "qcom,pms405-pon" },
{ }
};
MODULE_DEVICE_TABLE(of, pm8916_pon_id_table);
Expand Down
5 changes: 1 addition & 4 deletions drivers/power/reset/rmobile-reset.c
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Renesas R-Mobile Reset Driver
*
* Copyright (C) 2014 Glider bvba
*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*/

#include <linux/io.h>
Expand Down
7 changes: 7 additions & 0 deletions drivers/power/supply/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -645,4 +645,11 @@ config CHARGER_CROS_USBPD
what is connected to USB PD ports from the EC and converts
that into power_supply properties.

config CHARGER_SC2731
tristate "Spreadtrum SC2731 charger driver"
depends on MFD_SC27XX_PMIC || COMPILE_TEST
help
Say Y here to enable support for battery charging with SC2731
PMIC chips.

endif # POWER_SUPPLY
1 change: 1 addition & 0 deletions drivers/power/supply/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -85,3 +85,4 @@ obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o
obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o
obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o
obj-$(CONFIG_CHARGER_CROS_USBPD) += cros_usbpd-charger.o
obj-$(CONFIG_CHARGER_SC2731) += sc2731_charger.o
Loading

0 comments on commit df132e4

Please sign in to comment.