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:
  PXA: Use dev_pm_ops in z2_battery
  ds2760_battery: Fix rated capacity of the hx4700 1800mAh battery
  ds2760_battery: Fix indexing of the 4 active full EEPROM registers
  power: Make test_power driver more dynamic.
  bq27x00_battery: Name of cycle count property
  max8903_charger: Add GENERIC_HARDIRQS as a dependency (fixes S390 build)
  ARM: RX-51: Enable isp1704 power on/off
  isp1704_charger: Allow board specific powering routine
  gpio-charger: Add gpio_charger_resume
  power_supply: Add driver for MAX8903 charger
  • Loading branch information
Linus Torvalds committed May 27, 2011
2 parents 74e6392 + 906649d commit ea0ca3a
Show file tree
Hide file tree
Showing 12 changed files with 840 additions and 24 deletions.
27 changes: 25 additions & 2 deletions arch/arm/mach-omap2/board-rx51-peripherals.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
#include <linux/gpio.h>
#include <linux/gpio_keys.h>
#include <linux/mmc/host.h>
#include <linux/power/isp1704_charger.h>

#include <plat/mcspi.h>
#include <plat/board.h>
Expand Down Expand Up @@ -53,6 +54,8 @@
#define RX51_FMTX_RESET_GPIO 163
#define RX51_FMTX_IRQ 53

#define RX51_USB_TRANSCEIVER_RST_GPIO 67

/* list all spi devices here */
enum {
RX51_SPI_WL1251,
Expand Down Expand Up @@ -111,10 +114,30 @@ static struct spi_board_info rx51_peripherals_spi_board_info[] __initdata = {
},
};

static void rx51_charger_set_power(bool on)
{
gpio_set_value(RX51_USB_TRANSCEIVER_RST_GPIO, on);
}

static struct isp1704_charger_data rx51_charger_data = {
.set_power = rx51_charger_set_power,
};

static struct platform_device rx51_charger_device = {
.name = "isp1704_charger",
.name = "isp1704_charger",
.dev = {
.platform_data = &rx51_charger_data,
},
};

static void __init rx51_charger_init(void)
{
WARN_ON(gpio_request_one(RX51_USB_TRANSCEIVER_RST_GPIO,
GPIOF_OUT_INIT_LOW, "isp1704_reset"));

platform_device_register(&rx51_charger_device);
}

#if defined(CONFIG_KEYBOARD_GPIO) || defined(CONFIG_KEYBOARD_GPIO_MODULE)

#define RX51_GPIO_CAMERA_LENS_COVER 110
Expand Down Expand Up @@ -961,6 +984,6 @@ void __init rx51_peripherals_init(void)
if (partition)
omap2_hsmmc_init(mmc);

platform_device_register(&rx51_charger_device);
rx51_charger_init();
}

9 changes: 9 additions & 0 deletions drivers/power/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,15 @@ config CHARGER_ISP1704
Say Y to enable support for USB Charger Detection with
ISP1707/ISP1704 USB transceivers.

config CHARGER_MAX8903
tristate "MAX8903 Battery DC-DC Charger for USB and Adapter Power"
depends on GENERIC_HARDIRQS
help
Say Y to enable support for the MAX8903 DC-DC charger and sysfs.
The driver supports controlling charger-enable and current-limit
pins based on the status of charger connections with interrupt
handlers.

config CHARGER_TWL4030
tristate "OMAP TWL4030 BCI charger driver"
depends on TWL4030_CORE
Expand Down
1 change: 1 addition & 0 deletions drivers/power/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,6 @@ obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o
obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o
obj-$(CONFIG_CHARGER_ISP1704) += isp1704_charger.o
obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o
obj-$(CONFIG_CHARGER_TWL4030) += twl4030_charger.o
obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o
11 changes: 6 additions & 5 deletions drivers/power/bq27x00_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* Copyright (C) 2008 Rodolfo Giometti <giometti@linux.it>
* Copyright (C) 2008 Eurotech S.p.A. <info@eurotech.it>
* Copyright (C) 2010-2011 Lars-Peter Clausen <lars@metafoo.de>
* Copyright (C) 2011 Pali Rohár <pali.rohar@gmail.com>
*
* Based on a previous work by Copyright (C) 2008 Texas Instruments, Inc.
*
Expand Down Expand Up @@ -76,7 +77,7 @@ struct bq27x00_reg_cache {
int time_to_empty_avg;
int time_to_full;
int charge_full;
int charge_counter;
int cycle_count;
int capacity;
int flags;

Expand Down Expand Up @@ -115,7 +116,7 @@ static enum power_supply_property bq27x00_battery_props[] = {
POWER_SUPPLY_PROP_CHARGE_FULL,
POWER_SUPPLY_PROP_CHARGE_NOW,
POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN,
POWER_SUPPLY_PROP_CHARGE_COUNTER,
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_ENERGY_NOW,
};

Expand Down Expand Up @@ -267,7 +268,7 @@ static void bq27x00_update(struct bq27x00_device_info *di)
cache.time_to_empty_avg = bq27x00_battery_read_time(di, BQ27x00_REG_TTECP);
cache.time_to_full = bq27x00_battery_read_time(di, BQ27x00_REG_TTF);
cache.charge_full = bq27x00_battery_read_lmd(di);
cache.charge_counter = bq27x00_battery_read_cyct(di);
cache.cycle_count = bq27x00_battery_read_cyct(di);

if (!is_bq27500)
cache.current_now = bq27x00_read(di, BQ27x00_REG_AI, false);
Expand Down Expand Up @@ -496,8 +497,8 @@ static int bq27x00_battery_get_property(struct power_supply *psy,
case POWER_SUPPLY_PROP_CHARGE_FULL_DESIGN:
ret = bq27x00_simple_value(di->charge_design_full, val);
break;
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
ret = bq27x00_simple_value(di->cache.charge_counter, val);
case POWER_SUPPLY_PROP_CYCLE_COUNT:
ret = bq27x00_simple_value(di->cache.cycle_count, val);
break;
case POWER_SUPPLY_PROP_ENERGY_NOW:
ret = bq27x00_battery_energy(di, val);
Expand Down
6 changes: 5 additions & 1 deletion drivers/power/ds2760_battery.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,11 @@ static int rated_capacities[] = {
920, /* NEC */
1440, /* Samsung */
1440, /* BYD */
#ifdef CONFIG_MACH_H4700
1800, /* HP iPAQ hx4700 3.7V 1800mAh (359113-001) */
#else
1440, /* Lishen */
#endif
1440, /* NEC */
2880, /* Samsung */
2880, /* BYD */
Expand Down Expand Up @@ -186,7 +190,7 @@ static int ds2760_battery_read_status(struct ds2760_device_info *di)

scale[0] = di->full_active_uAh;
for (i = 1; i < 5; i++)
scale[i] = scale[i - 1] + di->raw[DS2760_ACTIVE_FULL + 2 + i];
scale[i] = scale[i - 1] + di->raw[DS2760_ACTIVE_FULL + 1 + i];

di->full_active_uAh = battery_interpolate(scale, di->temp_C / 10);
di->full_active_uAh *= 1000; /* convert to µAh */
Expand Down
15 changes: 15 additions & 0 deletions drivers/power/gpio-charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -161,12 +161,27 @@ static int __devexit gpio_charger_remove(struct platform_device *pdev)
return 0;
}

#ifdef CONFIG_PM_SLEEP
static int gpio_charger_resume(struct device *dev)
{
struct platform_device *pdev = to_platform_device(dev);
struct gpio_charger *gpio_charger = platform_get_drvdata(pdev);

power_supply_changed(&gpio_charger->charger);

return 0;
}
#endif

static SIMPLE_DEV_PM_OPS(gpio_charger_pm_ops, NULL, gpio_charger_resume);

static struct platform_driver gpio_charger_driver = {
.probe = gpio_charger_probe,
.remove = __devexit_p(gpio_charger_remove),
.driver = {
.name = "gpio-charger",
.owner = THIS_MODULE,
.pm = &gpio_charger_pm_ops,
},
};

Expand Down
22 changes: 22 additions & 0 deletions drivers/power/isp1704_charger.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include <linux/usb/ulpi.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
#include <linux/power/isp1704_charger.h>

/* Vendor specific Power Control register */
#define ISP1704_PWR_CTRL 0x3d
Expand Down Expand Up @@ -70,6 +71,18 @@ struct isp1704_charger {
unsigned max_power;
};

/*
* Disable/enable the power from the isp1704 if a function for it
* has been provided with platform data.
*/
static void isp1704_charger_set_power(struct isp1704_charger *isp, bool on)
{
struct isp1704_charger_data *board = isp->dev->platform_data;

if (board->set_power)
board->set_power(on);
}

/*
* Determine is the charging port DCP (dedicated charger) or CDP (Host/HUB
* chargers).
Expand Down Expand Up @@ -222,6 +235,9 @@ static void isp1704_charger_work(struct work_struct *data)

mutex_lock(&lock);

if (event != USB_EVENT_NONE)
isp1704_charger_set_power(isp, 1);

switch (event) {
case USB_EVENT_VBUS:
isp->online = true;
Expand Down Expand Up @@ -269,6 +285,8 @@ static void isp1704_charger_work(struct work_struct *data)
*/
if (isp->otg->gadget)
usb_gadget_disconnect(isp->otg->gadget);

isp1704_charger_set_power(isp, 0);
break;
case USB_EVENT_ENUMERATED:
if (isp->present)
Expand Down Expand Up @@ -394,6 +412,8 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)
isp->dev = &pdev->dev;
platform_set_drvdata(pdev, isp);

isp1704_charger_set_power(isp, 1);

ret = isp1704_test_ulpi(isp);
if (ret < 0)
goto fail1;
Expand Down Expand Up @@ -434,6 +454,7 @@ static int __devinit isp1704_charger_probe(struct platform_device *pdev)

/* Detect charger if VBUS is valid (the cable was already plugged). */
ret = otg_io_read(isp->otg, ULPI_USB_INT_STS);
isp1704_charger_set_power(isp, 0);
if ((ret & ULPI_INT_VBUS_VALID) && !isp->otg->default_a) {
isp->event = USB_EVENT_VBUS;
schedule_work(&isp->work);
Expand All @@ -459,6 +480,7 @@ static int __devexit isp1704_charger_remove(struct platform_device *pdev)
otg_unregister_notifier(isp->otg, &isp->nb);
power_supply_unregister(&isp->psy);
otg_put_transceiver(isp->otg);
isp1704_charger_set_power(isp, 0);
kfree(isp);

return 0;
Expand Down
Loading

0 comments on commit ea0ca3a

Please sign in to comment.