Skip to content

Commit 1595365

Browse files
committed
Merge git://git.infradead.org/battery-2.6
* git://git.infradead.org/battery-2.6: ds2760_battery: Document ABI change ds2760_battery: Make charge_now and charge_full writeable power_supply: Add support for writeable properties power_supply: Use attribute groups power_supply: Add test_power driver tosa_battery: Fix build error due to direct driver_data usage wm97xx_battery: Quieten sparse warning (bat_set_pdata not declared) ds2782_battery: Get rid of magic numbers in driver_data ds2782_battery: Add support for ds2786 battery gas gauge pda_power: Add function callbacks for suspend and resume wm831x_power: Use genirq Driver for Zipit Z2 battery chip ds2782_battery: Fix clientdata on removal
2 parents c3ed9ea + 24af320 commit 1595365

18 files changed

+901
-168
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
What: /sys/class/power/ds2760-battery.*/charge_now
2+
Date: May 2010
3+
KernelVersion: 2.6.35
4+
Contact: Daniel Mack <[email protected]>
5+
Description:
6+
This file is writeable and can be used to set the current
7+
coloumb counter value inside the battery monitor chip. This
8+
is needed for unavoidable corrections of aging batteries.
9+
A userspace daemon can monitor the battery charging logic
10+
and once the counter drops out of considerable bounds, take
11+
appropriate action.
12+
13+
What: /sys/class/power/ds2760-battery.*/charge_full
14+
Date: May 2010
15+
KernelVersion: 2.6.35
16+
Contact: Daniel Mack <[email protected]>
17+
Description:
18+
This file is writeable and can be used to set the assumed
19+
battery 'full level'. As batteries age, this value has to be
20+
amended over time.

drivers/power/Kconfig

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,11 @@ config WM8350_POWER
5757
Say Y here to enable support for the power management unit
5858
provided by the Wolfson Microelectronics WM8350 PMIC.
5959

60+
config TEST_POWER
61+
tristate "Test power driver"
62+
help
63+
This driver is used for testing. It's safe to say M here.
64+
6065
config BATTERY_DS2760
6166
tristate "DS2760 battery driver (HP iPAQ & others)"
6267
select W1
@@ -65,10 +70,10 @@ config BATTERY_DS2760
6570
Say Y here to enable support for batteries with ds2760 chip.
6671

6772
config BATTERY_DS2782
68-
tristate "DS2782 standalone gas-gauge"
73+
tristate "DS2782/DS2786 standalone gas-gauge"
6974
depends on I2C
7075
help
71-
Say Y here to enable support for the DS2782 standalone battery
76+
Say Y here to enable support for the DS2782/DS2786 standalone battery
7277
gas-gauge.
7378

7479
config BATTERY_PMU
@@ -125,6 +130,12 @@ config BATTERY_MAX17040
125130
in handheld and portable equipment. The MAX17040 is configured
126131
to operate with a single lithium cell
127132

133+
config BATTERY_Z2
134+
tristate "Z2 battery driver"
135+
depends on I2C && MACH_ZIPIT2
136+
help
137+
Say Y to include support for the battery on the Zipit Z2.
138+
128139
config CHARGER_PCF50633
129140
tristate "NXP PCF50633 MBC"
130141
depends on MFD_PCF50633

drivers/power/Makefile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ obj-$(CONFIG_MAX8925_POWER) += max8925_power.o
2020
obj-$(CONFIG_WM831X_BACKUP) += wm831x_backup.o
2121
obj-$(CONFIG_WM831X_POWER) += wm831x_power.o
2222
obj-$(CONFIG_WM8350_POWER) += wm8350_power.o
23+
obj-$(CONFIG_TEST_POWER) += test_power.o
2324

2425
obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
2526
obj-$(CONFIG_BATTERY_DS2782) += ds2782_battery.o
@@ -31,4 +32,5 @@ obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
3132
obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
3233
obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
3334
obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
35+
obj-$(CONFIG_BATTERY_Z2) += z2_battery.o
3436
obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o

drivers/power/ds2760_battery.c

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,28 @@ static void ds2760_battery_write_rated_capacity(struct ds2760_device_info *di,
304304
w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
305305
}
306306

307+
static void ds2760_battery_write_active_full(struct ds2760_device_info *di,
308+
int active_full)
309+
{
310+
unsigned char tmp[2] = {
311+
active_full >> 8,
312+
active_full & 0xff
313+
};
314+
315+
if (tmp[0] == di->raw[DS2760_ACTIVE_FULL] &&
316+
tmp[1] == di->raw[DS2760_ACTIVE_FULL + 1])
317+
return;
318+
319+
w1_ds2760_write(di->w1_dev, tmp, DS2760_ACTIVE_FULL, sizeof(tmp));
320+
w1_ds2760_store_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK0);
321+
w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK0);
322+
323+
/* Write to the di->raw[] buffer directly - the DS2760_ACTIVE_FULL
324+
* values won't be read back by ds2760_battery_read_status() */
325+
di->raw[DS2760_ACTIVE_FULL] = tmp[0];
326+
di->raw[DS2760_ACTIVE_FULL + 1] = tmp[1];
327+
}
328+
307329
static void ds2760_battery_work(struct work_struct *work)
308330
{
309331
struct ds2760_device_info *di = container_of(work,
@@ -426,6 +448,45 @@ static int ds2760_battery_get_property(struct power_supply *psy,
426448
return 0;
427449
}
428450

451+
static int ds2760_battery_set_property(struct power_supply *psy,
452+
enum power_supply_property psp,
453+
const union power_supply_propval *val)
454+
{
455+
struct ds2760_device_info *di = to_ds2760_device_info(psy);
456+
457+
switch (psp) {
458+
case POWER_SUPPLY_PROP_CHARGE_FULL:
459+
/* the interface counts in uAh, convert the value */
460+
ds2760_battery_write_active_full(di, val->intval / 1000L);
461+
break;
462+
463+
case POWER_SUPPLY_PROP_CHARGE_NOW:
464+
/* ds2760_battery_set_current_accum() does the conversion */
465+
ds2760_battery_set_current_accum(di, val->intval);
466+
break;
467+
468+
default:
469+
return -EPERM;
470+
}
471+
472+
return 0;
473+
}
474+
475+
static int ds2760_battery_property_is_writeable(struct power_supply *psy,
476+
enum power_supply_property psp)
477+
{
478+
switch (psp) {
479+
case POWER_SUPPLY_PROP_CHARGE_FULL:
480+
case POWER_SUPPLY_PROP_CHARGE_NOW:
481+
return 1;
482+
483+
default:
484+
break;
485+
}
486+
487+
return 0;
488+
}
489+
429490
static enum power_supply_property ds2760_battery_props[] = {
430491
POWER_SUPPLY_PROP_STATUS,
431492
POWER_SUPPLY_PROP_VOLTAGE_NOW,
@@ -460,6 +521,9 @@ static int ds2760_battery_probe(struct platform_device *pdev)
460521
di->bat.properties = ds2760_battery_props;
461522
di->bat.num_properties = ARRAY_SIZE(ds2760_battery_props);
462523
di->bat.get_property = ds2760_battery_get_property;
524+
di->bat.set_property = ds2760_battery_set_property;
525+
di->bat.property_is_writeable =
526+
ds2760_battery_property_is_writeable;
463527
di->bat.set_charged = ds2760_battery_set_charged;
464528
di->bat.external_power_changed =
465529
ds2760_battery_external_power_changed;

0 commit comments

Comments
 (0)