Skip to content

Commit 76f901e

Browse files
committed
Merge tag 'for-v3.5' of git://git.infradead.org/battery-2.6
Pull battery updates from Anton Vorontsov: "A bunch of fixes for v3.5, nothing extraordinary." * tag 'for-v3.5' of git://git.infradead.org/battery-2.6: (27 commits) smb347-charger: Include missing <linux/err.h> smb347-charger: Clean up battery attributes max17042_battery: Add support for max17047/50 chip sbs-battery.c: Capacity attr = remaining relative capacity isp1704_charger: Use after free on probe error ds2781_battery: Use DS2781_PARAM_EEPROM_SIZE and DS2781_USER_EEPROM_SIZE power_supply: Fix a typo in BATTERY_DS2781 Kconfig entry charger-manager: Provide cm_notify_event function for in-kernel use charger-manager: Poll battery health in normal state smb347-charger: Convert to regmap API smb347-charger: Move IRQ enabling to the end of probe smb347-charger: Rename few functions to match better what they are doing smb347-charger: Convert to use module_i2c_driver() smb347_charger: Cleanup power supply registration code in probe ab8500: Clean up probe routines ab8500_fg: Harden platform data check ab8500_btemp: Harden platform data check ab8500_charger: Harden platform data check MAINTAINERS: Fix 'F' entry for the power supply class max17042_battery: Handle irq request failure case ...
2 parents bd0e162 + 96facd2 commit 76f901e

17 files changed

+943
-497
lines changed

Documentation/power/charger-manager.txt

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,16 @@ Charger Manager supports the following:
4444
Normally, the platform will need to resume and suspend some devices
4545
that are used by Charger Manager.
4646

47+
* Support for premature full-battery event handling
48+
If the battery voltage drops by "fullbatt_vchkdrop_uV" after
49+
"fullbatt_vchkdrop_ms" from the full-battery event, the framework
50+
restarts charging. This check is also performed while suspended by
51+
setting wakeup time accordingly and using suspend_again.
52+
53+
* Support for uevent-notify
54+
With the charger-related events, the device sends
55+
notification to users with UEVENT.
56+
4757
2. Global Charger-Manager Data related with suspend_again
4858
========================================================
4959
In order to setup Charger Manager with suspend-again feature
@@ -55,7 +65,7 @@ if there are multiple batteries. If there are multiple batteries, the
5565
multiple instances of Charger Manager share the same charger_global_desc
5666
and it will manage in-suspend monitoring for all instances of Charger Manager.
5767

58-
The user needs to provide all the two entries properly in order to activate
68+
The user needs to provide all the three entries properly in order to activate
5969
in-suspend monitoring:
6070

6171
struct charger_global_desc {
@@ -74,6 +84,11 @@ bool (*rtc_only_wakeup)(void);
7484
same struct. If there is any other wakeup source triggered the
7585
wakeup, it should return false. If the "rtc" is the only wakeup
7686
reason, it should return true.
87+
88+
bool assume_timer_stops_in_suspend;
89+
: if true, Charger Manager assumes that
90+
the timer (CM uses jiffies as timer) stops during suspend. Then, CM
91+
assumes that the suspend-duration is same as the alarm length.
7792
};
7893

7994
3. How to setup suspend_again
@@ -111,6 +126,16 @@ enum polling_modes polling_mode;
111126
CM_POLL_CHARGING_ONLY: poll this battery if and only if the
112127
battery is being charged.
113128

129+
unsigned int fullbatt_vchkdrop_ms;
130+
unsigned int fullbatt_vchkdrop_uV;
131+
: If both have non-zero values, Charger Manager will check the
132+
battery voltage drop fullbatt_vchkdrop_ms after the battery is fully
133+
charged. If the voltage drop is over fullbatt_vchkdrop_uV, Charger
134+
Manager will try to recharge the battery by disabling and enabling
135+
chargers. Recharge with voltage drop condition only (without delay
136+
condition) is needed to be implemented with hardware interrupts from
137+
fuel gauges or charger devices/chips.
138+
114139
unsigned int fullbatt_uV;
115140
: If specified with a non-zero value, Charger Manager assumes
116141
that the battery is full (capacity = 100) if the battery is not being
@@ -122,6 +147,8 @@ unsigned int polling_interval_ms;
122147
this battery every polling_interval_ms or more frequently.
123148

124149
enum data_source battery_present;
150+
: CM_BATTERY_PRESENT: assume that the battery exists.
151+
CM_NO_BATTERY: assume that the battery does not exists.
125152
CM_FUEL_GAUGE: get battery presence information from fuel gauge.
126153
CM_CHARGER_STAT: get battery presence from chargers.
127154

@@ -151,7 +178,17 @@ bool measure_battery_temp;
151178
the value of measure_battery_temp.
152179
};
153180

154-
5. Other Considerations
181+
5. Notify Charger-Manager of charger events: cm_notify_event()
182+
=========================================================
183+
If there is an charger event is required to notify
184+
Charger Manager, a charger device driver that triggers the event can call
185+
cm_notify_event(psy, type, msg) to notify the corresponding Charger Manager.
186+
In the function, psy is the charger driver's power_supply pointer, which is
187+
associated with Charger-Manager. The parameter "type"
188+
is the same as irq's type (enum cm_event_types). The event message "msg" is
189+
optional and is effective only if the event type is "UNDESCRIBED" or "OTHERS".
190+
191+
6. Other Considerations
155192
=======================
156193

157194
At the charger/battery-related events such as battery-pulled-out,

Documentation/power/power_supply_class.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ are already charged or discharging, 'n/a' can be displayed (or
8484
HEALTH - represents health of the battery, values corresponds to
8585
POWER_SUPPLY_HEALTH_*, defined in battery.h.
8686

87+
VOLTAGE_OCV - open circuit voltage of the battery.
88+
8789
VOLTAGE_MAX_DESIGN, VOLTAGE_MIN_DESIGN - design values for maximal and
8890
minimal power supply voltages. Maximal/minimal means values of voltages
8991
when battery considered "full"/"empty" at normal conditions. Yes, there is

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5337,7 +5337,7 @@ M: David Woodhouse <dwmw2@infradead.org>
53375337
T: git git://git.infradead.org/battery-2.6.git
53385338
S: Maintained
53395339
F: include/linux/power_supply.h
5340-
F: drivers/power/power_supply*
5340+
F: drivers/power/
53415341

53425342
PNP SUPPORT
53435343
M: Adam Belay <abelay@mit.edu>

drivers/power/Kconfig

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
menuconfig POWER_SUPPLY
2-
tristate "Power supply class support"
2+
bool "Power supply class support"
33
help
44
Say Y here to enable power supply class support. This allows
55
power supply (batteries, AC, USB) monitoring by userspace
@@ -77,7 +77,7 @@ config BATTERY_DS2780
7777
Say Y here to enable support for batteries with ds2780 chip.
7878

7979
config BATTERY_DS2781
80-
tristate "2781 battery driver"
80+
tristate "DS2781 battery driver"
8181
depends on HAS_IOMEM
8282
select W1
8383
select W1_SLAVE_DS2781
@@ -181,14 +181,15 @@ config BATTERY_MAX17040
181181
to operate with a single lithium cell
182182

183183
config BATTERY_MAX17042
184-
tristate "Maxim MAX17042/8997/8966 Fuel Gauge"
184+
tristate "Maxim MAX17042/17047/17050/8997/8966 Fuel Gauge"
185185
depends on I2C
186186
help
187187
MAX17042 is fuel-gauge systems for lithium-ion (Li+) batteries
188188
in handheld and portable equipment. The MAX17042 is configured
189189
to operate with a single lithium cell. MAX8997 and MAX8966 are
190190
multi-function devices that include fuel gauages that are compatible
191-
with MAX17042.
191+
with MAX17042. This driver also supports max17047/50 chips which are
192+
improved version of max17042.
192193

193194
config BATTERY_Z2
194195
tristate "Z2 battery driver"
@@ -291,6 +292,7 @@ config CHARGER_MAX8998
291292
config CHARGER_SMB347
292293
tristate "Summit Microelectronics SMB347 Battery Charger"
293294
depends on I2C
295+
select REGMAP_I2C
294296
help
295297
Say Y to include support for Summit Microelectronics SMB347
296298
Battery Charger.

drivers/power/ab8500_btemp.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -964,10 +964,15 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
964964
{
965965
int irq, i, ret = 0;
966966
u8 val;
967-
struct abx500_bm_plat_data *plat_data;
967+
struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data;
968+
struct ab8500_btemp *di;
969+
970+
if (!plat_data) {
971+
dev_err(&pdev->dev, "No platform data\n");
972+
return -EINVAL;
973+
}
968974

969-
struct ab8500_btemp *di =
970-
kzalloc(sizeof(struct ab8500_btemp), GFP_KERNEL);
975+
di = kzalloc(sizeof(*di), GFP_KERNEL);
971976
if (!di)
972977
return -ENOMEM;
973978

@@ -977,7 +982,6 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
977982
di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
978983

979984
/* get btemp specific platform data */
980-
plat_data = pdev->dev.platform_data;
981985
di->pdata = plat_data->btemp;
982986
if (!di->pdata) {
983987
dev_err(di->dev, "no btemp platform data supplied\n");

drivers/power/ab8500_charger.c

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2534,10 +2534,15 @@ static int __devexit ab8500_charger_remove(struct platform_device *pdev)
25342534
static int __devinit ab8500_charger_probe(struct platform_device *pdev)
25352535
{
25362536
int irq, i, charger_status, ret = 0;
2537-
struct abx500_bm_plat_data *plat_data;
2537+
struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data;
2538+
struct ab8500_charger *di;
25382539

2539-
struct ab8500_charger *di =
2540-
kzalloc(sizeof(struct ab8500_charger), GFP_KERNEL);
2540+
if (!plat_data) {
2541+
dev_err(&pdev->dev, "No platform data\n");
2542+
return -EINVAL;
2543+
}
2544+
2545+
di = kzalloc(sizeof(*di), GFP_KERNEL);
25412546
if (!di)
25422547
return -ENOMEM;
25432548

@@ -2550,9 +2555,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
25502555
spin_lock_init(&di->usb_state.usb_lock);
25512556

25522557
/* get charger specific platform data */
2553-
plat_data = pdev->dev.platform_data;
25542558
di->pdata = plat_data->charger;
2555-
25562559
if (!di->pdata) {
25572560
dev_err(di->dev, "no charger platform data supplied\n");
25582561
ret = -EINVAL;

drivers/power/ab8500_fg.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2446,10 +2446,15 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev)
24462446
{
24472447
int i, irq;
24482448
int ret = 0;
2449-
struct abx500_bm_plat_data *plat_data;
2449+
struct abx500_bm_plat_data *plat_data = pdev->dev.platform_data;
2450+
struct ab8500_fg *di;
2451+
2452+
if (!plat_data) {
2453+
dev_err(&pdev->dev, "No platform data\n");
2454+
return -EINVAL;
2455+
}
24502456

2451-
struct ab8500_fg *di =
2452-
kzalloc(sizeof(struct ab8500_fg), GFP_KERNEL);
2457+
di = kzalloc(sizeof(*di), GFP_KERNEL);
24532458
if (!di)
24542459
return -ENOMEM;
24552460

@@ -2461,7 +2466,6 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev)
24612466
di->gpadc = ab8500_gpadc_get("ab8500-gpadc.0");
24622467

24632468
/* get fg specific platform data */
2464-
plat_data = pdev->dev.platform_data;
24652469
di->pdata = plat_data->fg;
24662470
if (!di->pdata) {
24672471
dev_err(di->dev, "no fg platform data supplied\n");

0 commit comments

Comments
 (0)