Skip to content

Commit df132e4

Browse files
committed
Merge tag 'for-v4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/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 ...
2 parents 96f2f66 + cfb3479 commit df132e4

30 files changed

+922
-213
lines changed

Documentation/devicetree/bindings/power/reset/qcom,pon.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ and resin along with the Android reboot-mode.
66
This DT node has pwrkey and resin as sub nodes.
77

88
Required Properties:
9-
-compatible: "qcom,pm8916-pon"
9+
-compatible: Must be one of:
10+
"qcom,pm8916-pon"
11+
"qcom,pms405-pon"
12+
1013
-reg: Specifies the physical address of the pon register
1114

1215
Optional subnode:

Documentation/devicetree/bindings/power/supply/bq25890.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Binding for TI bq25890 Li-Ion Charger
22

3+
This driver will support the bq25896 and the bq25890. There are other ICs
4+
in the same family but those have not been tested.
5+
36
Required properties:
47
- compatible: Should contain one of the following:
58
* "ti,bq25890"

Documentation/devicetree/bindings/power/supply/bq27xxx.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ Required properties:
2323
* "ti,bq27546" - BQ27546
2424
* "ti,bq27742" - BQ27742
2525
* "ti,bq27545" - BQ27545
26+
* "ti,bq27411" - BQ27411
2627
* "ti,bq27421" - BQ27421
2728
* "ti,bq27425" - BQ27425
2829
* "ti,bq27426" - BQ27426
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
Spreadtrum SC2731 PMIC battery charger binding
2+
3+
Required properties:
4+
- compatible: Should be "sprd,sc2731-charger".
5+
- reg: Address offset of charger register.
6+
- phys: Contains a phandle to the USB phy.
7+
8+
Optional Properties:
9+
- monitored-battery: phandle of battery characteristics devicetree node.
10+
The charger uses the following battery properties:
11+
- charge-term-current-microamp: current for charge termination phase.
12+
- constant-charge-voltage-max-microvolt: maximum constant input voltage.
13+
See Documentation/devicetree/bindings/power/supply/battery.txt
14+
15+
Example:
16+
17+
bat: battery {
18+
compatible = "simple-battery";
19+
charge-term-current-microamp = <120000>;
20+
constant-charge-voltage-max-microvolt = <4350000>;
21+
......
22+
};
23+
24+
sc2731_pmic: pmic@0 {
25+
compatible = "sprd,sc2731";
26+
reg = <0>;
27+
spi-max-frequency = <26000000>;
28+
interrupts = <GIC_SPI 31 IRQ_TYPE_LEVEL_HIGH>;
29+
interrupt-controller;
30+
#interrupt-cells = <2>;
31+
#address-cells = <1>;
32+
#size-cells = <0>;
33+
34+
charger@0 {
35+
compatible = "sprd,sc2731-charger";
36+
reg = <0x0>;
37+
phys = <&ssphy>;
38+
monitored-battery = <&bat>;
39+
};
40+
};

arch/arm/mach-at91/pm_suspend.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,14 @@ exit_suspend:
149149
ENDPROC(at91_pm_suspend_in_sram)
150150

151151
ENTRY(at91_backup_mode)
152+
/* Switch the master clock source to slow clock. */
153+
ldr pmc, .pmc_base
154+
ldr tmp1, [pmc, #AT91_PMC_MCKR]
155+
bic tmp1, tmp1, #AT91_PMC_CSS
156+
str tmp1, [pmc, #AT91_PMC_MCKR]
157+
158+
wait_mckrdy
159+
152160
/*BUMEN*/
153161
ldr r0, .sfr
154162
mov tmp1, #0x1

drivers/power/reset/at91-sama5d2_shdwc.c

Lines changed: 80 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
*/
2020

2121
#include <linux/clk.h>
22+
#include <linux/clk/at91_pmc.h>
2223
#include <linux/io.h>
2324
#include <linux/module.h>
2425
#include <linux/of.h>
@@ -69,16 +70,17 @@ struct shdwc_config {
6970

7071
struct shdwc {
7172
const struct shdwc_config *cfg;
72-
void __iomem *at91_shdwc_base;
73+
struct clk *sclk;
74+
void __iomem *shdwc_base;
75+
void __iomem *mpddrc_base;
76+
void __iomem *pmc_base;
7377
};
7478

7579
/*
7680
* Hold configuration here, cannot be more than one instance of the driver
7781
* since pm_power_off itself is global.
7882
*/
7983
static struct shdwc *at91_shdwc;
80-
static struct clk *sclk;
81-
static void __iomem *mpddrc_base;
8284

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

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

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

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

109111
static void at91_poweroff(void)
110-
{
111-
writel(AT91_SHDW_KEY | AT91_SHDW_SHDW,
112-
at91_shdwc->at91_shdwc_base + AT91_SHDW_CR);
113-
}
114-
115-
static void at91_lpddr_poweroff(void)
116112
{
117113
asm volatile(
118114
/* Align to cache lines */
@@ -122,16 +118,29 @@ static void at91_lpddr_poweroff(void)
122118
" ldr r6, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t"
123119

124120
/* Power down SDRAM0 */
121+
" tst %0, #0\n\t"
122+
" beq 1f\n\t"
125123
" str %1, [%0, #" __stringify(AT91_DDRSDRC_LPR) "]\n\t"
124+
125+
/* Switch the master clock source to slow clock. */
126+
"1: ldr r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
127+
" bic r6, r6, #" __stringify(AT91_PMC_CSS) "\n\t"
128+
" str r6, [%4, #" __stringify(AT91_PMC_MCKR) "]\n\t"
129+
/* Wait for clock switch. */
130+
"2: ldr r6, [%4, #" __stringify(AT91_PMC_SR) "]\n\t"
131+
" tst r6, #" __stringify(AT91_PMC_MCKRDY) "\n\t"
132+
" beq 2b\n\t"
133+
126134
/* Shutdown CPU */
127135
" str %3, [%2, #" __stringify(AT91_SHDW_CR) "]\n\t"
128136

129137
" b .\n\t"
130138
:
131-
: "r" (mpddrc_base),
139+
: "r" (at91_shdwc->mpddrc_base),
132140
"r" cpu_to_le32(AT91_DDRSDRC_LPDDR2_PWOFF),
133-
"r" (at91_shdwc->at91_shdwc_base),
134-
"r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW)
141+
"r" (at91_shdwc->shdwc_base),
142+
"r" cpu_to_le32(AT91_SHDW_KEY | AT91_SHDW_SHDW),
143+
"r" (at91_shdwc->pmc_base)
135144
: "r6");
136145
}
137146

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

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

218227
input = at91_shdwc_get_wakeup_input(pdev, np);
219-
writel(input, shdw->at91_shdwc_base + AT91_SHDW_WUIR);
228+
writel(input, shdw->shdwc_base + AT91_SHDW_WUIR);
220229
}
221230

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

258+
if (at91_shdwc)
259+
return -EBUSY;
260+
249261
at91_shdwc = devm_kzalloc(&pdev->dev, sizeof(*at91_shdwc), GFP_KERNEL);
250262
if (!at91_shdwc)
251263
return -ENOMEM;
252264

253265
platform_set_drvdata(pdev, at91_shdwc);
254266

255267
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
256-
at91_shdwc->at91_shdwc_base = devm_ioremap_resource(&pdev->dev, res);
257-
if (IS_ERR(at91_shdwc->at91_shdwc_base)) {
268+
at91_shdwc->shdwc_base = devm_ioremap_resource(&pdev->dev, res);
269+
if (IS_ERR(at91_shdwc->shdwc_base)) {
258270
dev_err(&pdev->dev, "Could not map reset controller address\n");
259-
return PTR_ERR(at91_shdwc->at91_shdwc_base);
271+
return PTR_ERR(at91_shdwc->shdwc_base);
260272
}
261273

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

265-
sclk = devm_clk_get(&pdev->dev, NULL);
266-
if (IS_ERR(sclk))
267-
return PTR_ERR(sclk);
277+
at91_shdwc->sclk = devm_clk_get(&pdev->dev, NULL);
278+
if (IS_ERR(at91_shdwc->sclk))
279+
return PTR_ERR(at91_shdwc->sclk);
268280

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

277289
at91_shdwc_dt_configure(pdev);
278290

279-
pm_power_off = at91_poweroff;
291+
np = of_find_compatible_node(NULL, NULL, "atmel,sama5d2-pmc");
292+
if (!np) {
293+
ret = -ENODEV;
294+
goto clk_disable;
295+
}
296+
297+
at91_shdwc->pmc_base = of_iomap(np, 0);
298+
of_node_put(np);
299+
300+
if (!at91_shdwc->pmc_base) {
301+
ret = -ENOMEM;
302+
goto clk_disable;
303+
}
280304

281305
np = of_find_compatible_node(NULL, NULL, "atmel,sama5d3-ddramc");
282-
if (!np)
283-
return 0;
306+
if (!np) {
307+
ret = -ENODEV;
308+
goto unmap;
309+
}
284310

285-
mpddrc_base = of_iomap(np, 0);
311+
at91_shdwc->mpddrc_base = of_iomap(np, 0);
286312
of_node_put(np);
287313

288-
if (!mpddrc_base)
289-
return 0;
314+
if (!at91_shdwc->mpddrc_base) {
315+
ret = -ENOMEM;
316+
goto unmap;
317+
}
290318

291-
ddr_type = readl(mpddrc_base + AT91_DDRSDRC_MDR) & AT91_DDRSDRC_MD;
292-
if ((ddr_type == AT91_DDRSDRC_MD_LPDDR2) ||
293-
(ddr_type == AT91_DDRSDRC_MD_LPDDR3))
294-
pm_power_off = at91_lpddr_poweroff;
295-
else
296-
iounmap(mpddrc_base);
319+
pm_power_off = at91_poweroff;
320+
321+
ddr_type = readl(at91_shdwc->mpddrc_base + AT91_DDRSDRC_MDR) &
322+
AT91_DDRSDRC_MD;
323+
if (ddr_type != AT91_DDRSDRC_MD_LPDDR2 &&
324+
ddr_type != AT91_DDRSDRC_MD_LPDDR3) {
325+
iounmap(at91_shdwc->mpddrc_base);
326+
at91_shdwc->mpddrc_base = NULL;
327+
}
297328

298329
return 0;
330+
331+
unmap:
332+
iounmap(at91_shdwc->pmc_base);
333+
clk_disable:
334+
clk_disable_unprepare(at91_shdwc->sclk);
335+
336+
return ret;
299337
}
300338

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

305-
if (pm_power_off == at91_poweroff ||
306-
pm_power_off == at91_lpddr_poweroff)
343+
if (pm_power_off == at91_poweroff)
307344
pm_power_off = NULL;
308345

309346
/* Reset values to disable wake-up features */
310-
writel(0, shdw->at91_shdwc_base + AT91_SHDW_MR);
311-
writel(0, shdw->at91_shdwc_base + AT91_SHDW_WUIR);
347+
writel(0, shdw->shdwc_base + AT91_SHDW_MR);
348+
writel(0, shdw->shdwc_base + AT91_SHDW_WUIR);
349+
350+
if (shdw->mpddrc_base)
351+
iounmap(shdw->mpddrc_base);
352+
iounmap(shdw->pmc_base);
312353

313-
clk_disable_unprepare(sclk);
354+
clk_disable_unprepare(shdw->sclk);
314355

315356
return 0;
316357
}

drivers/power/reset/qcom-pon.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ static int pm8916_pon_probe(struct platform_device *pdev)
7474

7575
static const struct of_device_id pm8916_pon_id_table[] = {
7676
{ .compatible = "qcom,pm8916-pon" },
77+
{ .compatible = "qcom,pms405-pon" },
7778
{ }
7879
};
7980
MODULE_DEVICE_TABLE(of, pm8916_pon_id_table);

drivers/power/reset/rmobile-reset.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1+
// SPDX-License-Identifier: GPL-2.0
12
/*
23
* Renesas R-Mobile Reset Driver
34
*
45
* Copyright (C) 2014 Glider bvba
5-
*
6-
* This file is subject to the terms and conditions of the GNU General Public
7-
* License. See the file "COPYING" in the main directory of this archive
8-
* for more details.
96
*/
107

118
#include <linux/io.h>

drivers/power/supply/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -645,4 +645,11 @@ config CHARGER_CROS_USBPD
645645
what is connected to USB PD ports from the EC and converts
646646
that into power_supply properties.
647647

648+
config CHARGER_SC2731
649+
tristate "Spreadtrum SC2731 charger driver"
650+
depends on MFD_SC27XX_PMIC || COMPILE_TEST
651+
help
652+
Say Y here to enable support for battery charging with SC2731
653+
PMIC chips.
654+
648655
endif # POWER_SUPPLY

drivers/power/supply/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,3 +85,4 @@ obj-$(CONFIG_CHARGER_TPS65217) += tps65217_charger.o
8585
obj-$(CONFIG_AXP288_FUEL_GAUGE) += axp288_fuel_gauge.o
8686
obj-$(CONFIG_AXP288_CHARGER) += axp288_charger.o
8787
obj-$(CONFIG_CHARGER_CROS_USBPD) += cros_usbpd-charger.o
88+
obj-$(CONFIG_CHARGER_SC2731) += sc2731_charger.o

0 commit comments

Comments
 (0)