Skip to content

Commit 03d11a0

Browse files
committed
Merge tag 'for-v3.14' of git://git.infradead.org/battery-2.6
Pull battery updates from Dmitry Eremin-Solenikov: "I'm picking up power supply maintainership from Anton Vorontov. Could you please pull battery-2.6 git tree changes prepared for the v3.14 release. Highlights: - Power supply notifier - Several drivers gained DT support - Added Maxim 14577 driver - Change of maintainer" * tag 'for-v3.14' of git://git.infradead.org/battery-2.6: MAINTAINERS: Pick up power supply maintainership max17042_battery: Add IRQF_ONESHOT flag to use default irq handler gpio-charger: Support wakeup events power_supply: Add charger support for Maxim 14577 dt: Binding documentation for isp1704 charger isp1704_charger: Add DT support charger-manager: of_cm_parse_desc() should be static bq2415x_charger: Add DT support power_supply: Add power_supply_get_by_phandle bq2415x_charger: Use power_supply notifier for automode power: reset: Add as3722 power-off driver mfd: AS3722: Add dt node properties for system power controller charger-manager: Support deivce tree in charger manager driver charger-manager: Modify the way of checking battery's temperature power_supply: Add power_supply notifier
2 parents ac26663 + 5731893 commit 03d11a0

File tree

20 files changed

+1043
-132
lines changed

20 files changed

+1043
-132
lines changed

Documentation/devicetree/bindings/mfd/as3722.txt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ Following are properties of regulator subnode.
112112
ams,enable-tracking: Enable tracking with SD1, only supported
113113
by LDO3.
114114

115+
Power-off:
116+
=========
117+
AS3722 supports the system power off by turning off all its rail. This
118+
is provided through pm_power_off.
119+
The device node should have the following properties to enable this
120+
functionality
121+
ams,system-power-controller: Boolean, to enable the power off functionality
122+
through this device.
123+
115124
Example:
116125
--------
117126
#include <dt-bindings/mfd/as3722.h>
@@ -120,6 +129,8 @@ ams3722 {
120129
compatible = "ams,as3722";
121130
reg = <0x48>;
122131

132+
ams,system-power-controller;
133+
123134
interrupt-parent = <&intc>;
124135
interrupt-controller;
125136
#interrupt-cells = <2>;
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
Binding for NXP ISP1704 USB Charger Detection
2+
3+
Required properties:
4+
- compatible: Should contain one of the following:
5+
* "nxp,isp1704"
6+
- nxp,enable-gpio: Should contain a phandle + gpio-specifier
7+
to the GPIO pin connected to the chip's enable pin.
8+
- usb-phy: Should contain a phandle to the USB PHY
9+
the ISP1704 is connected to.
10+
11+
Example:
12+
13+
isp1704 {
14+
compatible = "nxp,isp1704";
15+
nxp,enable-gpio = <&gpio3 3 GPIO_ACTIVE_LOW>;
16+
usb-phy = <&usb2_phy>;
17+
};
Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
charger-manager bindings
2+
~~~~~~~~~~~~~~~~~~~~~~~~
3+
4+
Required properties :
5+
- compatible : "charger-manager"
6+
- <>-supply : for regulator consumer
7+
- cm-num-chargers : number of chargers
8+
- cm-chargers : name of chargers
9+
- cm-fuel-gauge : name of battery fuel gauge
10+
- subnode <regulator> :
11+
- cm-regulator-name : name of charger regulator
12+
- subnode <cable> :
13+
- cm-cable-name : name of charger cable
14+
- cm-cable-extcon : name of extcon dev
15+
(optional) - cm-cable-min : minimum current of cable
16+
(optional) - cm-cable-max : maximum current of cable
17+
18+
Optional properties :
19+
- cm-name : charger manager's name (default : "battery")
20+
- cm-poll-mode : polling mode (enum polling_modes)
21+
- cm-poll-interval : polling interval
22+
- cm-battery-stat : battery status (enum data_source)
23+
- cm-fullbatt-* : data for full battery checking
24+
- cm-thermal-zone : name of external thermometer's thermal zone
25+
- cm-battery-* : threshold battery temperature for charging
26+
-cold : critical cold temperature of battery for charging
27+
-cold-in-minus : flag that cold temerature is in minus degree
28+
-hot : critical hot temperature of battery for charging
29+
-temp-diff : temperature difference to allow recharging
30+
- cm-dis/charging-max = limits of charging duration
31+
32+
Example :
33+
charger-manager@0 {
34+
compatible = "charger-manager";
35+
chg-reg-supply = <&charger_regulator>;
36+
37+
cm-name = "battery";
38+
/* Always polling ON : 30s */
39+
cm-poll-mode = <1>;
40+
cm-poll-interval = <30000>;
41+
42+
cm-fullbatt-vchkdrop-ms = <30000>;
43+
cm-fullbatt-vchkdrop-volt = <150000>;
44+
cm-fullbatt-soc = <100>;
45+
46+
cm-battery-stat = <3>;
47+
48+
cm-num-chargers = <3>;
49+
cm-chargers = "charger0", "charger1", "charger2";
50+
51+
cm-fuel-gauge = "fuelgauge0";
52+
53+
cm-thermal-zone = "thermal_zone.1"
54+
/* in deci centigrade */
55+
cm-battery-cold = <50>;
56+
cm-battery-cold-in-minus;
57+
cm-battery-hot = <800>;
58+
cm-battery-temp-diff = <100>;
59+
60+
/* Allow charging for 5hr */
61+
cm-charging-max = <18000000>;
62+
/* Allow discharging for 2hr */
63+
cm-discharging-max = <7200000>;
64+
65+
regulator@0 {
66+
cm-regulator-name = "chg-reg";
67+
cable@0 {
68+
cm-cable-name = "USB";
69+
cm-cable-extcon = "extcon-dev.0";
70+
cm-cable-min = <475000>;
71+
cm-cable-max = <500000>;
72+
};
73+
cable@1 {
74+
cm-cable-name = "TA";
75+
cm-cable-extcon = "extcon-dev.0";
76+
cm-cable-min = <650000>;
77+
cm-cable-max = <675000>;
78+
};
79+
};
80+
81+
};

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6712,7 +6712,7 @@ F: include/linux/timer*
67126712
F: kernel/*timer*
67136713

67146714
POWER SUPPLY CLASS/SUBSYSTEM and DRIVERS
6715-
M: Anton Vorontsov <[email protected]>
6715+
M: Dmitry Eremin-Solenikov <[email protected]>
67166716
M: David Woodhouse <[email protected]>
67176717
T: git git://git.infradead.org/battery-2.6.git
67186718
S: Maintained

drivers/power/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,6 +317,13 @@ config CHARGER_MANAGER
317317
runtime and in suspend-to-RAM by waking up the system periodically
318318
with help of suspend_again support.
319319

320+
config CHARGER_MAX14577
321+
tristate "Maxim MAX14577 MUIC battery charger driver"
322+
depends on MFD_MAX14577
323+
help
324+
Say Y to enable support for the battery charger control sysfs and
325+
platform data of MAX14577 MUICs.
326+
320327
config CHARGER_MAX8997
321328
tristate "Maxim MAX8997/MAX8966 PMIC battery charger driver"
322329
depends on MFD_MAX8997 && REGULATOR_MAX8997

drivers/power/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ obj-$(CONFIG_CHARGER_LP8727) += lp8727_charger.o
4848
obj-$(CONFIG_CHARGER_LP8788) += lp8788-charger.o
4949
obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o
5050
obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o
51+
obj-$(CONFIG_CHARGER_MAX14577) += max14577_charger.o
5152
obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
5253
obj-$(CONFIG_CHARGER_MAX8998) += max8998_charger.o
5354
obj-$(CONFIG_CHARGER_BQ2415X) += bq2415x_charger.o

drivers/power/bq2415x_charger.c

Lines changed: 98 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* bq2415x charger driver
33
*
4-
* Copyright (C) 2011-2012 Pali Rohár <[email protected]>
4+
* Copyright (C) 2011-2013 Pali Rohár <[email protected]>
55
*
66
* This program is free software; you can redistribute it and/or modify
77
* it under the terms of the GNU General Public License as published by
@@ -170,6 +170,8 @@ struct bq2415x_device {
170170
struct bq2415x_platform_data init_data;
171171
struct power_supply charger;
172172
struct delayed_work work;
173+
struct power_supply *notify_psy;
174+
struct notifier_block nb;
173175
enum bq2415x_mode reported_mode;/* mode reported by hook function */
174176
enum bq2415x_mode mode; /* current configured mode */
175177
enum bq2415x_chip chip;
@@ -795,24 +797,53 @@ static int bq2415x_set_mode(struct bq2415x_device *bq, enum bq2415x_mode mode)
795797

796798
}
797799

798-
/* hook function called by other driver which set reported mode */
799-
static void bq2415x_hook_function(enum bq2415x_mode mode, void *data)
800+
static int bq2415x_notifier_call(struct notifier_block *nb,
801+
unsigned long val, void *v)
800802
{
801-
struct bq2415x_device *bq = data;
803+
struct bq2415x_device *bq =
804+
container_of(nb, struct bq2415x_device, nb);
805+
struct power_supply *psy = v;
806+
enum bq2415x_mode mode;
807+
union power_supply_propval prop;
808+
int ret;
809+
int mA;
802810

803-
if (!bq)
804-
return;
811+
if (val != PSY_EVENT_PROP_CHANGED)
812+
return NOTIFY_OK;
813+
814+
if (psy != bq->notify_psy)
815+
return NOTIFY_OK;
816+
817+
dev_dbg(bq->dev, "notifier call was called\n");
818+
819+
ret = psy->get_property(psy, POWER_SUPPLY_PROP_CURRENT_MAX, &prop);
820+
if (ret != 0)
821+
return NOTIFY_OK;
822+
823+
mA = prop.intval;
824+
825+
if (mA == 0)
826+
mode = BQ2415X_MODE_OFF;
827+
else if (mA < 500)
828+
mode = BQ2415X_MODE_NONE;
829+
else if (mA < 1800)
830+
mode = BQ2415X_MODE_HOST_CHARGER;
831+
else
832+
mode = BQ2415X_MODE_DEDICATED_CHARGER;
833+
834+
if (bq->reported_mode == mode)
835+
return NOTIFY_OK;
805836

806-
dev_dbg(bq->dev, "hook function was called\n");
807837
bq->reported_mode = mode;
808838

809839
/* if automode is not enabled do not tell about reported_mode */
810840
if (bq->automode < 1)
811-
return;
841+
return NOTIFY_OK;
812842

813843
sysfs_notify(&bq->charger.dev->kobj, NULL, "reported_mode");
814844
bq2415x_set_mode(bq, bq->reported_mode);
815845

846+
return NOTIFY_OK;
816847
}
817848

818849
/**** timer functions ****/
@@ -1512,9 +1543,11 @@ static int bq2415x_probe(struct i2c_client *client,
15121543
int num;
15131544
char *name;
15141545
struct bq2415x_device *bq;
1546+
struct device_node *np = client->dev.of_node;
1547+
struct bq2415x_platform_data *pdata = client->dev.platform_data;
15151548

1516-
if (!client->dev.platform_data) {
1517-
dev_err(&client->dev, "platform data not set\n");
1549+
if (!np && !pdata) {
1550+
dev_err(&client->dev, "platform data missing\n");
15181551
return -ENODEV;
15191552
}
15201553

@@ -1539,6 +1572,17 @@ static int bq2415x_probe(struct i2c_client *client,
15391572
goto error_2;
15401573
}
15411574

1575+
if (np) {
1576+
bq->notify_psy = power_supply_get_by_phandle(np, "ti,usb-charger-detection");
1577+
1578+
if (!bq->notify_psy)
1579+
return -EPROBE_DEFER;
1580+
}
1581+
else if (pdata->notify_device)
1582+
bq->notify_psy = power_supply_get_by_name(pdata->notify_device);
1583+
else
1584+
bq->notify_psy = NULL;
1585+
15421586
i2c_set_clientdata(client, bq);
15431587

15441588
bq->id = num;
@@ -1550,8 +1594,34 @@ static int bq2415x_probe(struct i2c_client *client,
15501594
bq->autotimer = 0;
15511595
bq->automode = 0;
15521596

1553-
memcpy(&bq->init_data, client->dev.platform_data,
1554-
sizeof(bq->init_data));
1597+
if (np) {
1598+
ret = of_property_read_u32(np, "ti,current-limit",
1599+
&bq->init_data.current_limit);
1600+
if (ret)
1601+
return ret;
1602+
ret = of_property_read_u32(np, "ti,weak-battery-voltage",
1603+
&bq->init_data.weak_battery_voltage);
1604+
if (ret)
1605+
return ret;
1606+
ret = of_property_read_u32(np, "ti,battery-regulation-voltage",
1607+
&bq->init_data.battery_regulation_voltage);
1608+
if (ret)
1609+
return ret;
1610+
ret = of_property_read_u32(np, "ti,charge-current",
1611+
&bq->init_data.charge_current);
1612+
if (ret)
1613+
return ret;
1614+
ret = of_property_read_u32(np, "ti,termination-current",
1615+
&bq->init_data.termination_current);
1616+
if (ret)
1617+
return ret;
1618+
ret = of_property_read_u32(np, "ti,resistor-sense",
1619+
&bq->init_data.resistor_sense);
1620+
if (ret)
1621+
return ret;
1622+
} else {
1623+
memcpy(&bq->init_data, pdata, sizeof(bq->init_data));
1624+
}
15551625

15561626
bq2415x_reset_chip(bq);
15571627

@@ -1573,16 +1643,20 @@ static int bq2415x_probe(struct i2c_client *client,
15731643
goto error_4;
15741644
}
15751645

1576-
if (bq->init_data.set_mode_hook) {
1577-
if (bq->init_data.set_mode_hook(
1578-
bq2415x_hook_function, bq)) {
1579-
bq->automode = 1;
1580-
bq2415x_set_mode(bq, bq->reported_mode);
1581-
dev_info(bq->dev, "automode enabled\n");
1582-
} else {
1583-
bq->automode = -1;
1584-
dev_info(bq->dev, "automode failed\n");
1646+
if (bq->notify_psy) {
1647+
bq->nb.notifier_call = bq2415x_notifier_call;
1648+
ret = power_supply_reg_notifier(&bq->nb);
1649+
if (ret) {
1650+
dev_err(bq->dev, "failed to reg notifier: %d\n", ret);
1651+
goto error_5;
15851652
}
1653+
1654+
/* Query for initial reported_mode and set it */
1655+
bq2415x_notifier_call(&bq->nb, PSY_EVENT_PROP_CHANGED, bq->notify_psy);
1656+
bq2415x_set_mode(bq, bq->reported_mode);
1657+
1658+
bq->automode = 1;
1659+
dev_info(bq->dev, "automode enabled\n");
15861660
} else {
15871661
bq->automode = -1;
15881662
dev_info(bq->dev, "automode not supported\n");
@@ -1594,6 +1668,7 @@ static int bq2415x_probe(struct i2c_client *client,
15941668
dev_info(bq->dev, "driver registered\n");
15951669
return 0;
15961670

1671+
error_5:
15971672
error_4:
15981673
bq2415x_sysfs_exit(bq);
15991674
error_3:
@@ -1614,8 +1689,8 @@ static int bq2415x_remove(struct i2c_client *client)
16141689
{
16151690
struct bq2415x_device *bq = i2c_get_clientdata(client);
16161691

1617-
if (bq->init_data.set_mode_hook)
1618-
bq->init_data.set_mode_hook(NULL, NULL);
1692+
if (bq->notify_psy)
1693+
power_supply_unreg_notifier(&bq->nb);
16191694

16201695
bq2415x_sysfs_exit(bq);
16211696
bq2415x_power_supply_exit(bq);

0 commit comments

Comments
 (0)