Skip to content

Commit

Permalink
Merge git://git.infradead.org/battery-2.6
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
torvalds committed May 24, 2010
2 parents c3ed9ea + 24af320 commit 1595365
Show file tree
Hide file tree
Showing 18 changed files with 901 additions and 168 deletions.
20 changes: 20 additions & 0 deletions Documentation/ABI/testing/sysfs-class-power
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
What: /sys/class/power/ds2760-battery.*/charge_now
Date: May 2010
KernelVersion: 2.6.35
Contact: Daniel Mack <[email protected]>
Description:
This file is writeable and can be used to set the current
coloumb counter value inside the battery monitor chip. This
is needed for unavoidable corrections of aging batteries.
A userspace daemon can monitor the battery charging logic
and once the counter drops out of considerable bounds, take
appropriate action.

What: /sys/class/power/ds2760-battery.*/charge_full
Date: May 2010
KernelVersion: 2.6.35
Contact: Daniel Mack <[email protected]>
Description:
This file is writeable and can be used to set the assumed
battery 'full level'. As batteries age, this value has to be
amended over time.
15 changes: 13 additions & 2 deletions drivers/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,11 @@ config WM8350_POWER
Say Y here to enable support for the power management unit
provided by the Wolfson Microelectronics WM8350 PMIC.

config TEST_POWER
tristate "Test power driver"
help
This driver is used for testing. It's safe to say M here.

config BATTERY_DS2760
tristate "DS2760 battery driver (HP iPAQ & others)"
select W1
Expand All @@ -65,10 +70,10 @@ config BATTERY_DS2760
Say Y here to enable support for batteries with ds2760 chip.

config BATTERY_DS2782
tristate "DS2782 standalone gas-gauge"
tristate "DS2782/DS2786 standalone gas-gauge"
depends on I2C
help
Say Y here to enable support for the DS2782 standalone battery
Say Y here to enable support for the DS2782/DS2786 standalone battery
gas-gauge.

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

config BATTERY_Z2
tristate "Z2 battery driver"
depends on I2C && MACH_ZIPIT2
help
Say Y to include support for the battery on the Zipit Z2.

config CHARGER_PCF50633
tristate "NXP PCF50633 MBC"
depends on MFD_PCF50633
Expand Down
2 changes: 2 additions & 0 deletions drivers/power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ obj-$(CONFIG_MAX8925_POWER) += max8925_power.o
obj-$(CONFIG_WM831X_BACKUP) += wm831x_backup.o
obj-$(CONFIG_WM831X_POWER) += wm831x_power.o
obj-$(CONFIG_WM8350_POWER) += wm8350_power.o
obj-$(CONFIG_TEST_POWER) += test_power.o

obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
obj-$(CONFIG_BATTERY_DS2782) += ds2782_battery.o
Expand All @@ -31,4 +32,5 @@ obj-$(CONFIG_BATTERY_WM97XX) += wm97xx_battery.o
obj-$(CONFIG_BATTERY_BQ27x00) += bq27x00_battery.o
obj-$(CONFIG_BATTERY_DA9030) += da9030_battery.o
obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
obj-$(CONFIG_BATTERY_Z2) += z2_battery.o
obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
64 changes: 64 additions & 0 deletions drivers/power/ds2760_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,28 @@ static void ds2760_battery_write_rated_capacity(struct ds2760_device_info *di,
w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK1);
}

static void ds2760_battery_write_active_full(struct ds2760_device_info *di,
int active_full)
{
unsigned char tmp[2] = {
active_full >> 8,
active_full & 0xff
};

if (tmp[0] == di->raw[DS2760_ACTIVE_FULL] &&
tmp[1] == di->raw[DS2760_ACTIVE_FULL + 1])
return;

w1_ds2760_write(di->w1_dev, tmp, DS2760_ACTIVE_FULL, sizeof(tmp));
w1_ds2760_store_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK0);
w1_ds2760_recall_eeprom(di->w1_dev, DS2760_EEPROM_BLOCK0);

/* Write to the di->raw[] buffer directly - the DS2760_ACTIVE_FULL
* values won't be read back by ds2760_battery_read_status() */
di->raw[DS2760_ACTIVE_FULL] = tmp[0];
di->raw[DS2760_ACTIVE_FULL + 1] = tmp[1];
}

static void ds2760_battery_work(struct work_struct *work)
{
struct ds2760_device_info *di = container_of(work,
Expand Down Expand Up @@ -426,6 +448,45 @@ static int ds2760_battery_get_property(struct power_supply *psy,
return 0;
}

static int ds2760_battery_set_property(struct power_supply *psy,
enum power_supply_property psp,
const union power_supply_propval *val)
{
struct ds2760_device_info *di = to_ds2760_device_info(psy);

switch (psp) {
case POWER_SUPPLY_PROP_CHARGE_FULL:
/* the interface counts in uAh, convert the value */
ds2760_battery_write_active_full(di, val->intval / 1000L);
break;

case POWER_SUPPLY_PROP_CHARGE_NOW:
/* ds2760_battery_set_current_accum() does the conversion */
ds2760_battery_set_current_accum(di, val->intval);
break;

default:
return -EPERM;
}

return 0;
}

static int ds2760_battery_property_is_writeable(struct power_supply *psy,
enum power_supply_property psp)
{
switch (psp) {
case POWER_SUPPLY_PROP_CHARGE_FULL:
case POWER_SUPPLY_PROP_CHARGE_NOW:
return 1;

default:
break;
}

return 0;
}

static enum power_supply_property ds2760_battery_props[] = {
POWER_SUPPLY_PROP_STATUS,
POWER_SUPPLY_PROP_VOLTAGE_NOW,
Expand Down Expand Up @@ -460,6 +521,9 @@ static int ds2760_battery_probe(struct platform_device *pdev)
di->bat.properties = ds2760_battery_props;
di->bat.num_properties = ARRAY_SIZE(ds2760_battery_props);
di->bat.get_property = ds2760_battery_get_property;
di->bat.set_property = ds2760_battery_set_property;
di->bat.property_is_writeable =
ds2760_battery_property_is_writeable;
di->bat.set_charged = ds2760_battery_set_charged;
di->bat.external_power_changed =
ds2760_battery_external_power_changed;
Expand Down
Loading

0 comments on commit 1595365

Please sign in to comment.