From a830d28b48bf92944e57058e87d17cee5a7cd2a1 Mon Sep 17 00:00:00 2001 From: "Jett.Zhou" Date: Fri, 27 Jul 2012 16:27:16 +0800 Subject: power_supply: Enable battery-charger for 88pm860x 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 Signed-off-by: Anton Vorontsov --- drivers/mfd/88pm860x-core.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'drivers/mfd') diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index d09918cf1b1..229cb292008 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c @@ -18,6 +18,7 @@ #include #include #include +#include #define INT_STATUS_NUM 3 @@ -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,}, @@ -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[] = { @@ -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, -- cgit v1.2.3-70-g09d2 From f1ade35253f5026170a5fe17f87d0249f03629dd Mon Sep 17 00:00:00 2001 From: Anton Vorontsov Date: Wed, 22 Aug 2012 20:31:33 -0700 Subject: 88pm860x_battery and charger: Fix a few post-merge issues Sparse complains: CHECK drivers/power/88pm860x_battery.c drivers/power/88pm860x_battery.c:128:5: warning: symbol 'array_soc' was not declared. Should it be static? CHECK drivers/power/88pm860x_charger.c drivers/power/88pm860x_charger.c:640:3: warning: symbol 'pm860x_irq_descs' was not declared. Should it be static? CHECK drivers/mfd/88pm860x-core.c drivers/mfd/88pm860x-core.c:803:53: warning: incorrect type in assignment (different base types) drivers/mfd/88pm860x-core.c:803:53: expected struct charger_regulator *charger_regulators drivers/mfd/88pm860x-core.c:803:53: got struct regulator_bulk_data static [toplevel] * The issues are minor, except for the last one. We seemed to use 'regulator_bulk_data' struct (just as charger manager documentation wrongly tells us), but in real it should have been 'struct charger_regulator'. The only reason that it worked is because both 'supply' and 'regulator_name' struct members are the first in these structs. :-) Signed-off-by: Anton Vorontsov --- drivers/mfd/88pm860x-core.c | 4 ++-- drivers/power/88pm860x_battery.c | 2 +- drivers/power/88pm860x_charger.c | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'drivers/mfd') diff --git a/drivers/mfd/88pm860x-core.c b/drivers/mfd/88pm860x-core.c index 229cb292008..76b5b7daf65 100644 --- a/drivers/mfd/88pm860x-core.c +++ b/drivers/mfd/88pm860x-core.c @@ -157,8 +157,8 @@ 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 charger_regulator chg_desc_regulator_data[] = { + { .regulator_name = "preg", }, }; static struct mfd_cell power_devs[] = { diff --git a/drivers/power/88pm860x_battery.c b/drivers/power/88pm860x_battery.c index 5e905f3db4b..beed5ecf75e 100644 --- a/drivers/power/88pm860x_battery.c +++ b/drivers/power/88pm860x_battery.c @@ -125,7 +125,7 @@ struct ccnt { * State of Charge. * The first number is mAh(=3.6C), and the second number is percent point. */ -int array_soc[][2] = { +static int array_soc[][2] = { {4170, 100}, {4154, 99}, {4136, 98}, {4122, 97}, {4107, 96}, {4102, 95}, {4088, 94}, {4081, 93}, {4070, 92}, {4060, 91}, {4053, 90}, {4044, 89}, {4035, 88}, {4028, 87}, {4019, 86}, diff --git a/drivers/power/88pm860x_charger.c b/drivers/power/88pm860x_charger.c index 4fd7614ee83..2dbeb146090 100644 --- a/drivers/power/88pm860x_charger.c +++ b/drivers/power/88pm860x_charger.c @@ -632,7 +632,7 @@ static int pm860x_init_charger(struct pm860x_charger_info *info) return 0; } -struct pm860x_irq_desc { +static struct pm860x_irq_desc { const char *name; irqreturn_t (*handler)(int irq, void *data); } pm860x_irq_descs[] = { -- cgit v1.2.3-70-g09d2