Skip to content

Commit

Permalink
power_supply: Enable battery-charger for 88pm860x
Browse files Browse the repository at this point in the history
There are charger and battery measurement feature for 88pm860x PMIC.

For charger, it can support pre-charge with small current when battery is
nearly exausted and then changed into fast-charge with CC&CV mode.

For battery monitor, it can support battery measurement such as
vbat,vsys,vchg and ibat etc,it can aslo accumulating the Coulomb value
charged or discharged from battery based on Conlomb Counter, we use it
to estimate battery capacity.

Signed-off-by: Jett.Zhou <jtzhou@marvell.com>
Signed-off-by: Anton Vorontsov <anton.vorontsov@linaro.org>
  • Loading branch information
Jett.Zhou authored and Anton Vorontsov committed Sep 20, 2012
1 parent 98a2766 commit a830d28
Show file tree
Hide file tree
Showing 6 changed files with 1,905 additions and 2 deletions.
22 changes: 21 additions & 1 deletion drivers/mfd/88pm860x-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <linux/mfd/core.h>
#include <linux/mfd/88pm860x.h>
#include <linux/regulator/machine.h>
#include <linux/power/charger-manager.h>

#define INT_STATUS_NUM 3

Expand Down Expand Up @@ -84,7 +85,8 @@ static struct resource battery_resources[] __devinitdata = {
static struct resource charger_resources[] __devinitdata = {
{PM8607_IRQ_CHG, PM8607_IRQ_CHG, "charger detect", IORESOURCE_IRQ,},
{PM8607_IRQ_CHG_DONE, PM8607_IRQ_CHG_DONE, "charging done", IORESOURCE_IRQ,},
{PM8607_IRQ_CHG_FAULT, PM8607_IRQ_CHG_FAULT, "charging timeout", IORESOURCE_IRQ,},
{PM8607_IRQ_CHG_FAIL, PM8607_IRQ_CHG_FAIL, "charging timeout", IORESOURCE_IRQ,},
{PM8607_IRQ_CHG_FAULT, PM8607_IRQ_CHG_FAULT, "charging fault", IORESOURCE_IRQ,},
{PM8607_IRQ_GPADC1, PM8607_IRQ_GPADC1, "battery temperature", IORESOURCE_IRQ,},
{PM8607_IRQ_VBAT, PM8607_IRQ_VBAT, "battery voltage", IORESOURCE_IRQ,},
{PM8607_IRQ_VCHG, PM8607_IRQ_VCHG, "vchg voltage", IORESOURCE_IRQ,},
Expand Down Expand Up @@ -155,10 +157,15 @@ static struct regulator_init_data preg_init_data = {
.consumer_supplies = &preg_supply[0],
};

static struct regulator_bulk_data chg_desc_regulator_data[] = {
{ .supply = "preg", },
};

static struct mfd_cell power_devs[] = {
{"88pm860x-battery", -1,},
{"88pm860x-charger", -1,},
{"88pm860x-preg", -1,},
{"charger-manager", -1,},
};

static struct mfd_cell rtc_devs[] = {
Expand Down Expand Up @@ -791,6 +798,19 @@ static void __devinit device_power_init(struct pm860x_chip *chip,
&preg_resources[0], chip->irq_base);
if (ret < 0)
dev_err(chip->dev, "Failed to add preg subdev\n");

if (pdata->chg_desc) {
pdata->chg_desc->charger_regulators =
&chg_desc_regulator_data[0];
pdata->chg_desc->num_charger_regulators =
ARRAY_SIZE(chg_desc_regulator_data),
power_devs[3].platform_data = pdata->chg_desc;
power_devs[3].pdata_size = sizeof(*pdata->chg_desc);
ret = mfd_add_devices(chip->dev, 0, &power_devs[3], 1,
NULL, chip->irq_base);
if (ret < 0)
dev_err(chip->dev, "Failed to add chg-manager subdev\n");
}
}

static void __devinit device_onkey_init(struct pm860x_chip *chip,
Expand Down
Loading

0 comments on commit a830d28

Please sign in to comment.