Commit e665faa4 authored by Linus Torvalds's avatar Linus Torvalds

Merge tag 'for-v3.7' of git://git.infradead.org/battery-2.6

Pull battery updates from Anton Vorontsov:
 "1. New drivers:
     - Marvell 88pm860x charger and battery drivers;
     - Texas Instruments LP8788 charger driver;
  2. Two new power supply properties: whether a battery is authentic,
     and chargers' maximal currents and voltages;
  3. A lot of TI LP8727 Charger cleanups;
  4. New features for Charger Manager, mainly now we can disable
     specific regulators;
  5. Random fixes and cleanups for other drivers."

Fix up trivial conflicts in <linux/mfd/88pm860x.h>

* tag 'for-v3.7' of git://git.infradead.org/battery-2.6: (52 commits)
  pda_power: Remove ac_draw_failed goto and label
  charger-manager: Add support sysfs entry for charger
  charger-manager: Support limit of maximum possible
  charger-manager: Check fully charged state of battery periodically
  lp8727_charger: More pure cosmetic improvements
  lp8727_charger: Fix checkpatch warning
  lp8727_charger: Add description in the private data
  lp8727_charger: Fix a typo - chg_parm to chg_param
  lp8727_charger: Make some cosmetic changes in lp8727_delayed_func()
  lp8727_charger: Clean up lp8727_charger_changed()
  lp8727_charger: Return if the battery is discharging
  lp8727_charger: Make lp8727_charger_get_propery() simpler
  lp8727_charger: Make lp8727_ctrl_switch() inline
  lp8727_charger: Make lp8727_init_device() shorter
  lp8727_charger: Clean up lp8727_is_charger_attached()
  lp8727_charger: Use specific definition
  lp8727_charger: Clean up lp8727 definitions
  lp8727_charger: Use the definition rather than enum
  lp8727_charger: Fix code for getting battery temp
  lp8727_charger: Clear interrrupts at inital time
  ...
parents ca4da694 18766f09
......@@ -81,6 +81,9 @@ This defines trickle and fast charges. For batteries that
are already charged or discharging, 'n/a' can be displayed (or
'unknown', if the status is not known).
AUTHENTIC - indicates the power supply (battery or charger) connected
to the platform is authentic(1) or non authentic(0).
HEALTH - represents health of the battery, values corresponds to
POWER_SUPPLY_HEALTH_*, defined in battery.h.
......@@ -113,8 +116,12 @@ be negative; there is no empty or full value. It is only useful for
relative, time-based measurements.
CONSTANT_CHARGE_CURRENT - constant charge current programmed by charger.
CONSTANT_CHARGE_CURRENT_MAX - maximum charge current supported by the
power supply object.
CONSTANT_CHARGE_VOLTAGE - constant charge voltage programmed by charger.
CONSTANT_CHARGE_VOLTAGE_MAX - maximum charge voltage supported by the
power supply object.
ENERGY_FULL, ENERGY_EMPTY - same as above but for energy.
......
......@@ -24,6 +24,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
......@@ -150,7 +151,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,},
......@@ -318,10 +320,15 @@ static struct regulator_init_data preg_init_data = {
.consumer_supplies = &preg_supply[0],
};
static struct charger_regulator chg_desc_regulator_data[] = {
{ .regulator_name = "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[] = {
......@@ -929,6 +936,19 @@ static void __devinit device_power_init(struct pm860x_chip *chip,
NULL, chip->irq_base, NULL);
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, NULL);
if (ret < 0)
dev_err(chip->dev, "Failed to add chg-manager subdev\n");
}
}
static void __devinit device_onkey_init(struct pm860x_chip *chip,
......
This diff is collapsed.
This diff is collapsed.
......@@ -69,6 +69,12 @@ config TEST_POWER
help
This driver is used for testing. It's safe to say M here.
config BATTERY_88PM860X
tristate "Marvell 88PM860x battery driver"
depends on MFD_88PM860X
help
Say Y here to enable battery monitor for Marvell 88PM860x chip.
config BATTERY_DS2760
tristate "DS2760 battery driver (HP iPAQ & others)"
depends on W1 && W1_SLAVE_DS2760
......@@ -174,7 +180,6 @@ config BATTERY_DA9030
config BATTERY_DA9052
tristate "Dialog DA9052 Battery"
depends on PMIC_DA9052
depends on BROKEN
help
Say Y here to enable support for batteries charger integrated into
DA9052 PMIC.
......@@ -210,6 +215,12 @@ config BATTERY_S3C_ADC
help
Say Y here to enable support for iPAQ h1930/h1940/rx1950 battery
config CHARGER_88PM860X
tristate "Marvell 88PM860x Charger driver"
depends on MFD_88PM860X && BATTERY_88PM860X
help
Say Y here to enable charger for Marvell 88PM860x chip.
config CHARGER_PCF50633
tristate "NXP PCF50633 MBC"
depends on MFD_PCF50633
......@@ -262,6 +273,13 @@ config CHARGER_LP8727
help
Say Y here to enable support for LP8727 Charger Driver.
config CHARGER_LP8788
tristate "TI LP8788 charger driver"
depends on MFD_LP8788
depends on LP8788_ADC
help
Say Y to enable support for the LP8788 linear charger.
config CHARGER_GPIO
tristate "GPIO charger"
depends on GPIOLIB
......
......@@ -15,6 +15,7 @@ obj-$(CONFIG_WM831X_POWER) += wm831x_power.o
obj-$(CONFIG_WM8350_POWER) += wm8350_power.o
obj-$(CONFIG_TEST_POWER) += test_power.o
obj-$(CONFIG_BATTERY_88PM860X) += 88pm860x_battery.o
obj-$(CONFIG_BATTERY_DS2760) += ds2760_battery.o
obj-$(CONFIG_BATTERY_DS2780) += ds2780_battery.o
obj-$(CONFIG_BATTERY_DS2781) += ds2781_battery.o
......@@ -32,6 +33,7 @@ obj-$(CONFIG_BATTERY_MAX17040) += max17040_battery.o
obj-$(CONFIG_BATTERY_MAX17042) += max17042_battery.o
obj-$(CONFIG_BATTERY_Z2) += z2_battery.o
obj-$(CONFIG_BATTERY_S3C_ADC) += s3c_adc_battery.o
obj-$(CONFIG_CHARGER_88PM860X) += 88pm860x_charger.o
obj-$(CONFIG_CHARGER_PCF50633) += pcf50633-charger.o
obj-$(CONFIG_BATTERY_JZ4740) += jz4740-battery.o
obj-$(CONFIG_BATTERY_INTEL_MID) += intel_mid_battery.o
......@@ -40,6 +42,7 @@ obj-$(CONFIG_CHARGER_ISP1704) += isp1704_charger.o
obj-$(CONFIG_CHARGER_MAX8903) += max8903_charger.o
obj-$(CONFIG_CHARGER_TWL4030) += twl4030_charger.o
obj-$(CONFIG_CHARGER_LP8727) += lp8727_charger.o
obj-$(CONFIG_CHARGER_LP8788) += lp8788-charger.o
obj-$(CONFIG_CHARGER_GPIO) += gpio-charger.o
obj-$(CONFIG_CHARGER_MANAGER) += charger-manager.o
obj-$(CONFIG_CHARGER_MAX8997) += max8997_charger.o
......
......@@ -1014,6 +1014,7 @@ static int __devinit ab8500_btemp_probe(struct platform_device *pdev)
create_singlethread_workqueue("ab8500_btemp_wq");
if (di->btemp_wq == NULL) {
dev_err(di->dev, "failed to create work queue\n");
ret = -ENOMEM;
goto free_device_info;
}
......
......@@ -2614,6 +2614,7 @@ static int __devinit ab8500_charger_probe(struct platform_device *pdev)
create_singlethread_workqueue("ab8500_charger_wq");
if (di->charger_wq == NULL) {
dev_err(di->dev, "failed to create work queue\n");
ret = -ENOMEM;
goto free_device_info;
}
......
......@@ -2506,6 +2506,7 @@ static int __devinit ab8500_fg_probe(struct platform_device *pdev)
di->fg_wq = create_singlethread_workqueue("ab8500_fg_wq");
if (di->fg_wq == NULL) {
dev_err(di->dev, "failed to create work queue\n");
ret = -ENOMEM;
goto free_device_info;
}
......
......@@ -814,7 +814,8 @@ static int bq27x00_battery_probe(struct i2c_client *client,
di->bat.name = name;
di->bus.read = &bq27x00_read_i2c;
if (bq27x00_powersupply_init(di))
retval = bq27x00_powersupply_init(di);
if (retval)
goto batt_failed_3;
i2c_set_clientdata(client, di);
......
This diff is collapsed.
......@@ -187,8 +187,8 @@ static const struct file_operations bat_debug_fops = {
static struct dentry *da9030_bat_create_debugfs(struct da9030_charger *charger)
{
charger->debug_file = debugfs_create_file("charger", 0666, 0, charger,
&bat_debug_fops);
charger->debug_file = debugfs_create_file("charger", 0666, NULL,
charger, &bat_debug_fops);
return charger->debug_file;
}
......
......@@ -327,7 +327,7 @@ static int da9052_bat_interpolate(int vbat_lower, int vbat_upper,
return tmp;
}
unsigned char da9052_determine_vc_tbl_index(unsigned char adc_temp)
static unsigned char da9052_determine_vc_tbl_index(unsigned char adc_temp)
{
int i;
......@@ -345,6 +345,13 @@ unsigned char da9052_determine_vc_tbl_index(unsigned char adc_temp)
&& (adc_temp <= vc_tbl_ref[i]))
return i + 1;
}
/*
* For some reason authors of the driver didn't presume that we can
* end up here. It might be OK, but might be not, no one knows for
* sure. Go check your battery, is it on fire?
*/
WARN_ON(1);
return 0;
}
static int da9052_bat_read_capacity(struct da9052_battery *bat, int *capacity)
......@@ -616,7 +623,7 @@ static s32 __devinit da9052_bat_probe(struct platform_device *pdev)
return 0;
err:
for (; i >= 0; i--) {
while (--i >= 0) {
irq = platform_get_irq_byname(pdev, da9052_bat_irqs[i]);
free_irq(bat->da9052->irq_base + irq, bat);
}
......
......@@ -755,11 +755,9 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
int ret = 0;
struct ds2781_device_info *dev_info;
dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
if (!dev_info) {
ret = -ENOMEM;
goto fail;
}
dev_info = devm_kzalloc(&pdev->dev, sizeof(*dev_info), GFP_KERNEL);
if (!dev_info)
return -ENOMEM;
platform_set_drvdata(pdev, dev_info);
......@@ -774,7 +772,7 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
ret = power_supply_register(&pdev->dev, &dev_info->bat);
if (ret) {
dev_err(dev_info->dev, "failed to register battery\n");
goto fail_free_info;
goto fail;
}
ret = sysfs_create_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
......@@ -808,8 +806,6 @@ static int __devinit ds2781_battery_probe(struct platform_device *pdev)
sysfs_remove_group(&dev_info->bat.dev->kobj, &ds2781_attr_group);
fail_unregister:
power_supply_unregister(&dev_info->bat);
fail_free_info:
kfree(dev_info);
fail:
return ret;
}
......@@ -823,7 +819,6 @@ static int __devexit ds2781_battery_remove(struct platform_device *pdev)
power_supply_unregister(&dev_info->bat);
kfree(dev_info);
return 0;
}
......@@ -834,20 +829,7 @@ static struct platform_driver ds2781_battery_driver = {
.probe = ds2781_battery_probe,
.remove = __devexit_p(ds2781_battery_remove),
};
static int __init ds2781_battery_init(void)
{
return platform_driver_register(&ds2781_battery_driver);
}
static void __exit ds2781_battery_exit(void)
{
platform_driver_unregister(&ds2781_battery_driver);
}
module_init(ds2781_battery_init);
module_exit(ds2781_battery_exit);
module_platform_driver(ds2781_battery_driver);
MODULE_LICENSE("GPL");
MODULE_AUTHOR("Renata Sayakhova <renata@oktetlabs.ru>");
......
This diff is collapsed.
This diff is collapsed.
......@@ -281,6 +281,12 @@ static int pda_power_probe(struct platform_device *pdev)
goto init_failed;
}
ac_draw = regulator_get(dev, "ac_draw");
if (IS_ERR(ac_draw)) {
dev_dbg(dev, "couldn't get ac_draw regulator\n");
ac_draw = NULL;
}
update_status();
update_charger();
......@@ -309,13 +315,6 @@ static int pda_power_probe(struct platform_device *pdev)
pda_psy_usb.num_supplicants = pdata->num_supplicants;
}
ac_draw = regulator_get(dev, "ac_draw");
if (IS_ERR(ac_draw)) {
dev_dbg(dev, "couldn't get ac_draw regulator\n");
ac_draw = NULL;
ret = PTR_ERR(ac_draw);
}
#ifdef CONFIG_USB_OTG_UTILS
transceiver = usb_get_phy(USB_PHY_TYPE_USB2);
if (!IS_ERR_OR_NULL(transceiver)) {
......
......@@ -138,6 +138,7 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(health),
POWER_SUPPLY_ATTR(present),
POWER_SUPPLY_ATTR(online),
POWER_SUPPLY_ATTR(authentic),
POWER_SUPPLY_ATTR(technology),
POWER_SUPPLY_ATTR(cycle_count),
POWER_SUPPLY_ATTR(voltage_max),
......@@ -160,7 +161,9 @@ static struct device_attribute power_supply_attrs[] = {
POWER_SUPPLY_ATTR(charge_avg),
POWER_SUPPLY_ATTR(charge_counter),
POWER_SUPPLY_ATTR(constant_charge_current),
POWER_SUPPLY_ATTR(constant_charge_current_max),
POWER_SUPPLY_ATTR(constant_charge_voltage),
POWER_SUPPLY_ATTR(constant_charge_voltage_max),
POWER_SUPPLY_ATTR(energy_full_design),
POWER_SUPPLY_ATTR(energy_empty_design),
POWER_SUPPLY_ATTR(energy_full),
......
......@@ -759,6 +759,16 @@ static int __devinit sbs_probe(struct i2c_client *client,
chip->irq = irq;
skip_gpio:
/*
* Before we register, we need to make sure we can actually talk
* to the battery.
*/
rc = sbs_read_word_data(client, sbs_data[REG_STATUS].addr);
if (rc < 0) {
dev_err(&client->dev, "%s: Failed to get device status\n",
__func__);
goto exit_psupply;
}
rc = power_supply_register(&client->dev, &chip->power_supply);
if (rc) {
......
......@@ -80,6 +80,7 @@
#define CFG_FAULT_IRQ_DCIN_UV BIT(2)
#define CFG_STATUS_IRQ 0x0d
#define CFG_STATUS_IRQ_TERMINATION_OR_TAPER BIT(4)
#define CFG_STATUS_IRQ_CHARGE_TIMEOUT BIT(7)
#define CFG_ADDRESS 0x0e
/* Command registers */
......@@ -96,6 +97,9 @@
#define IRQSTAT_C_TERMINATION_STAT BIT(0)
#define IRQSTAT_C_TERMINATION_IRQ BIT(1)
#define IRQSTAT_C_TAPER_IRQ BIT(3)
#define IRQSTAT_D 0x38
#define IRQSTAT_D_CHARGE_TIMEOUT_STAT BIT(2)
#define IRQSTAT_D_CHARGE_TIMEOUT_IRQ BIT(3)
#define IRQSTAT_E 0x39
#define IRQSTAT_E_USBIN_UV_STAT BIT(0)
#define IRQSTAT_E_USBIN_UV_IRQ BIT(1)
......@@ -109,8 +113,10 @@
#define STAT_B 0x3c
#define STAT_C 0x3d
#define STAT_C_CHG_ENABLED BIT(0)
#define STAT_C_HOLDOFF_STAT BIT(3)
#define STAT_C_CHG_MASK 0x06
#define STAT_C_CHG_SHIFT 1
#define STAT_C_CHG_TERM BIT(5)
#define STAT_C_CHARGER_ERROR BIT(6)
#define STAT_E 0x3f
......@@ -701,7 +707,7 @@ static int smb347_hw_init(struct smb347_charger *smb)
static irqreturn_t smb347_interrupt(int irq, void *data)
{
struct smb347_charger *smb = data;
unsigned int stat_c, irqstat_e, irqstat_c;
unsigned int stat_c, irqstat_c, irqstat_d, irqstat_e;
bool handled = false;
int ret;
......@@ -717,6 +723,12 @@ static irqreturn_t smb347_interrupt(int irq, void *data)
return IRQ_NONE;
}
ret = regmap_read(smb->regmap, IRQSTAT_D, &irqstat_d);
if (ret < 0) {
dev_warn(smb->dev, "reading IRQSTAT_D failed\n");
return IRQ_NONE;
}
ret = regmap_read(smb->regmap, IRQSTAT_E, &irqstat_e);
if (ret < 0) {
dev_warn(smb->dev, "reading IRQSTAT_E failed\n");
......@@ -724,13 +736,11 @@ static irqreturn_t smb347_interrupt(int irq, void *data)
}
/*
* If we get charger error we report the error back to user and
* disable charging.
* If we get charger error we report the error back to user.
* If the error is recovered charging will resume again.
*/
if (stat_c & STAT_C_CHARGER_ERROR) {
dev_err(smb->dev, "error in charger, disabling charging\n");
smb347_charging_disable(smb);
dev_err(smb->dev, "charging stopped due to charger error\n");
power_supply_changed(&smb->battery);
handled = true;
}
......@@ -743,6 +753,20 @@ static irqreturn_t smb347_interrupt(int irq, void *data)
if (irqstat_c & (IRQSTAT_C_TERMINATION_IRQ | IRQSTAT_C_TAPER_IRQ)) {
if (irqstat_c & IRQSTAT_C_TERMINATION_STAT)
power_supply_changed(&smb->battery);
dev_dbg(smb->dev, "going to HW maintenance mode\n");
handled = true;
}
/*
* If we got a charger timeout INT that means the charge
* full is not detected with in charge timeout value.
*/
if (irqstat_d & IRQSTAT_D_CHARGE_TIMEOUT_IRQ) {
dev_dbg(smb->dev, "total Charge Timeout INT received\n");
if (irqstat_d & IRQSTAT_D_CHARGE_TIMEOUT_STAT)
dev_warn(smb->dev, "charging stopped due to timeout\n");
power_supply_changed(&smb->battery);
handled = true;
}
......@@ -776,6 +800,7 @@ static int smb347_irq_set(struct smb347_charger *smb, bool enable)
* Enable/disable interrupts for:
* - under voltage
* - termination current reached
* - charger timeout
* - charger error
*/
ret = regmap_update_bits(smb->regmap, CFG_FAULT_IRQ, 0xff,
......@@ -784,7 +809,8 @@ static int smb347_irq_set(struct smb347_charger *smb, bool enable)
goto fail;
ret = regmap_update_bits(smb->regmap, CFG_STATUS_IRQ, 0xff,
enable ? CFG_STATUS_IRQ_TERMINATION_OR_TAPER : 0);
enable ? (CFG_STATUS_IRQ_TERMINATION_OR_TAPER |
CFG_STATUS_IRQ_CHARGE_TIMEOUT) : 0);
if (ret < 0)
goto fail;
......@@ -988,6 +1014,51 @@ static enum power_supply_property smb347_usb_properties[] = {
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
};
static int smb347_get_charging_status(struct smb347_charger *smb)
{
int ret, status;
unsigned int val;
if (!smb347_is_ps_online(smb))
return POWER_SUPPLY_STATUS_DISCHARGING;
ret = regmap_read(smb->regmap, STAT_C, &val);
if (ret < 0)
return ret;
if ((val & STAT_C_CHARGER_ERROR) ||
(val & STAT_C_HOLDOFF_STAT)) {
/*
* set to NOT CHARGING upon charger error
* or charging has stopped.
*/
status = POWER_SUPPLY_STATUS_NOT_CHARGING;
} else {
if ((val & STAT_C_CHG_MASK) >> STAT_C_CHG_SHIFT) {
/*
* set to charging if battery is in pre-charge,
* fast charge or taper charging mode.
*/
status = POWER_SUPPLY_STATUS_CHARGING;
} else if (val & STAT_C_CHG_TERM) {
/*
* set the status to FULL if battery is not in pre
* charge, fast charge or taper charging mode AND
* charging is terminated at least once.
*/
status = POWER_SUPPLY_STATUS_FULL;
} else {
/*
* in this case no charger error or termination
* occured but charging is not in progress!!!
*/
status = POWER_SUPPLY_STATUS_NOT_CHARGING;
}
}
return status;
}
static int smb347_battery_get_property(struct power_supply *psy,
enum power_supply_property prop,
union power_supply_propval *val)
......@@ -1003,14 +1074,10 @@ static int smb347_battery_get_property(struct power_supply *psy,
switch (prop) {
case POWER_SUPPLY_PROP_STATUS:
if (!smb347_is_ps_online(smb)) {
val->intval = POWER_SUPPLY_STATUS_DISCHARGING;
break;
}
if (smb347_charging_status(smb))
val->intval = POWER_SUPPLY_STATUS_CHARGING;
else
val->intval = POWER_SUPPLY_STATUS_FULL;
ret = smb347_get_charging_status(smb);
if (ret < 0)
return ret;
val->intval = ret;
break;
case POWER_SUPPLY_PROP_CHARGE_TYPE:
......
......@@ -41,16 +41,16 @@
#define TWL4030_STS_VBUS BIT(7)
#define TWL4030_STS_USB_ID BIT(2)
#define TWL4030_BBCHEN BIT(4)
#define TWL4030_BBSEL_MASK 0b1100
#define TWL4030_BBSEL_2V5 0b0000
#define TWL4030_BBSEL_3V0 0b0100
#define TWL4030_BBSEL_3V1 0b1000
#define TWL4030_BBSEL_3V2 0b1100
#define TWL4030_BBISEL_MASK 0b11
#define TWL4030_BBISEL_25uA 0b00
#define TWL4030_BBISEL_150uA 0b01
#define TWL4030_BBISEL_500uA 0b10
#define TWL4030_BBISEL_1000uA 0b11
#define TWL4030_BBSEL_MASK 0x0c
#define TWL4030_BBSEL_2V5 0x00
#define TWL4030_BBSEL_3V0 0x04
#define TWL4030_BBSEL_3V1 0x08
#define TWL4030_BBSEL_3V2 0x0c
#define TWL4030_BBISEL_MASK 0x03
#define TWL4030_BBISEL_25uA 0x00
#define TWL4030_BBISEL_150uA 0x01
#define TWL4030_BBISEL_500uA 0x02
#define TWL4030_BBISEL_1000uA 0x03
/* BCI interrupts */
#define TWL4030_WOVF BIT(0) /* Watchdog overflow */
......@@ -534,7 +534,8 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
}
ret = request_threaded_irq(bci->irq_chg, NULL,
twl4030_charger_interrupt, 0, pdev->name, bci);
twl4030_charger_interrupt, IRQF_ONESHOT, pdev->name,
bci);
if (ret < 0) {
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
bci->irq_chg, ret);
......@@ -542,7 +543,7 @@ static int __init twl4030_bci_probe(struct platform_device *pdev)
}
ret = request_threaded_irq(bci->irq_bci, NULL,
twl4030_bci_interrupt, 0, pdev->name, bci);
twl4030_bci_interrupt, IRQF_ONESHOT, pdev->name, bci);
if (ret < 0) {
dev_err(&pdev->dev, "could not request irq %d, status %d\n",
bci->irq_bci, ret);
......
......@@ -212,8 +212,10 @@ static int __devinit wm97xx_bat_probe(struct platform_device *dev)
props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */
prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
if (!prop)
if (!prop) {
ret = -ENOMEM;
goto err3;
}
prop[i++] = POWER_SUPPLY_PROP_PRESENT;
if (pdata->charge_gpio >= 0)
......
......@@ -39,6 +39,21 @@ enum {
#define PM8606_DCM_BOOST (0x00)
#define PM8606_PWM (0x01)
#define PM8607_MISC2 (0x42)
/* Power Up Log Register */
#define PM8607_POWER_UP_LOG (0x3F)
/* Charger Control Registers */
#define PM8607_CCNT (0x47)
#define PM8607_CHG_CTRL1 (0x48)
#define PM8607_CHG_CTRL2 (0x49)
#define PM8607_CHG_CTRL3 (0x4A)
#define PM8607_CHG_CTRL4 (0x4B)
#define PM8607_CHG_CTRL5 (0x4C)
#define PM8607_CHG_CTRL6 (0x4D)
#define PM8607_CHG_CTRL7 (0x4E)
/* Backlight Registers */
#define PM8606_WLED1A (0x02)
#define PM8606_WLED1B (0x03)
......@@ -189,6 +204,71 @@ enum {
#define PM8607_PD_PREBIAS (0x56) /* prebias time */
#define PM8607_GPADC_MISC1 (0x57)
/* bit definitions of MEAS_EN1*/
#define PM8607_MEAS_EN1_VBAT (1 << 0)
#define PM8607_MEAS_EN1_VCHG (1 << 1)
#define PM8607_MEAS_EN1_VSYS (1 << 2)
#define PM8607_MEAS_EN1_TINT (1 << 3)
#define PM8607_MEAS_EN1_RFTMP (1 << 4)
#define PM8607_MEAS_EN1_TBAT (1 << 5)
#define PM8607_MEAS_EN1_GPADC2 (1 << 6)
#define PM8607_MEAS_EN1_GPADC3 (1 << 7)
/* Battery Monitor Registers */
#define PM8607_GP_BIAS2 (0x5A)
#define PM8607_VBAT_LOWTH (0x5B)
#define PM8607_VCHG_LOWTH (0x5C)
#define PM8607_VSYS_LOWTH (0x5D)
#define PM8607_TINT_LOWTH (0x5E)
#define PM8607_GPADC0_LOWTH (0x5F)
#define PM8607_GPADC1_LOWTH (0x60)
#define PM8607_GPADC2_LOWTH (0x61)
#define PM8607_GPADC3_LOWTH (0x62)
#define PM8607_VBAT_HIGHTH (0x63)
#define PM8607_VCHG_HIGHTH (0x64)
#define PM8607_VSYS_HIGHTH (0x65)
#define PM8607_TINT_HIGHTH (0x66)
#define PM8607_GPADC0_HIGHTH (0x67)
#define PM8607_GPADC1_HIGHTH (0x68)
#define PM8607_GPADC2_HIGHTH (0x69)
#define PM8607_GPADC3_HIGHTH (0x6A)
#define PM8607_IBAT_MEAS1 (0x6B)
#define PM8607_IBAT_MEAS2 (0x6C)
#define PM8607_VBAT_MEAS1 (0x6D)
#define PM8607_VBAT_MEAS2 (0x6E)
#define PM8607_VCHG_MEAS1 (0x6F)
#define PM8607_VCHG_MEAS2 (0x70)
#define PM8607_VSYS_MEAS1 (0x71)
#define PM8607_VSYS_MEAS2 (0x72)
#define PM8607_TINT_MEAS1 (0x73)
#define PM8607_TINT_MEAS2 (0x74)
#define PM8607_GPADC0_MEAS1 (0x75)
#define PM8607_GPADC0_MEAS2 (0x76)
#define PM8607_GPADC1_MEAS1 (0x77)
#define PM8607_GPADC1_MEAS2 (0x78)
#define PM8607_GPADC2_MEAS1 (0x79)
#define PM8607_GPADC2_MEAS2 (0x7A)
#define PM8607_GPADC3_MEAS1 (0x7B)
#define PM8607_GPADC3_MEAS2 (0x7C)
#define PM8607_CCNT_MEAS1 (0x95)
#define PM8607_CCNT_MEAS2 (0x96)
#define PM8607_VBAT_AVG (0x97)
#define PM8607_VCHG_AVG (0x98)
#define PM8607_VSYS_AVG (0x99)
#define PM8607_VBAT_MIN (0x9A)
#define PM8607_VCHG_MIN (0x9B)
#define PM8607_VSYS_MIN (0x9C)
#define PM8607_VBAT_MAX (0x9D)
#define PM8607_VCHG_MAX (0x9E)
#define PM8607_VSYS_MAX (0x9F)
#define PM8607_GPADC_MISC2 (0x59)
#define PM8607_GPADC0_GP_BIAS_A0 (1 << 0)
#define PM8607_GPADC1_GP_BIAS_A1 (1 << 1)
#define PM8607_GPADC2_GP_BIAS_A2 (1 << 2)
#define PM8607_GPADC3_GP_BIAS_A3 (1 << 3)
#define PM8607_GPADC2_GP_BIAS_OUT2 (1 << 6)
/* RTC Control Registers */
#define PM8607_RTC1 (0xA0)
#define PM8607_RTC_COUNTER1 (0xA1)
......@@ -350,7 +430,8 @@ struct pm860x_touch_pdata {
};
struct pm860x_power_pdata {
unsigned fast_charge; /* charge current */
int max_capacity;
int resistor;
};
struct pm860x_platform_data {
......@@ -375,6 +456,7 @@ struct pm860x_platform_data {
struct regulator_init_data *ldo12;
struct regulator_init_data *ldo_vibrator;
struct regulator_init_data *ldo14;
struct charger_desc *chg_desc;
int companion_addr; /* I2C address of companion chip */
int i2c_port; /* Controlled by GI2C or PI2C */
......
......@@ -13,32 +13,32 @@
#define _LP8727_H
enum lp8727_eoc_level {
EOC_5P,
EOC_10P,
EOC_16P,
EOC_20P,
EOC_25P,
EOC_33P,
EOC_50P,
LP8727_EOC_5P,
LP8727_EOC_10P,
LP8727_EOC_16P,
LP8727_EOC_20P,
LP8727_EOC_25P,
LP8727_EOC_33P,
LP8727_EOC_50P,
};
enum lp8727_ichg {
ICHG_90mA,
ICHG_100mA,
ICHG_400mA,
ICHG_450mA,
ICHG_500mA,
ICHG_600mA,
ICHG_700mA,
ICHG_800mA,
ICHG_900mA,
ICHG_1000mA,
LP8727_ICHG_90mA,
LP8727_ICHG_100mA,
LP8727_ICHG_400mA,
LP8727_ICHG_450mA,
LP8727_ICHG_500mA,
LP8727_ICHG_600mA,
LP8727_ICHG_700mA,
LP8727_ICHG_800mA,
LP8727_ICHG_900mA,
LP8727_ICHG_1000mA,
};
/**
* struct lp8727_chg_param
* @eoc_level : end of charge level setting
* @ichg : charging current
* @ichg : charging current
*/
struct lp8727_chg_param {
enum lp8727_eoc_level eoc_level;
......@@ -47,19 +47,22 @@ struct lp8727_chg_param {
/**
* struct lp8727_platform_data
* @get_batt_present : check battery status - exists or not
* @get_batt_level : get battery voltage (mV)
* @get_batt_present : check battery status - exists or not
* @get_batt_level : get battery voltage (mV)
* @get_batt_capacity : get battery capacity (%)
* @get_batt_temp : get battery temperature
* @ac, @usb : charging parameters each charger type
* @get_batt_temp : get battery temperature
* @ac : charging parameters for AC type charger
* @usb : charging parameters for USB type charger
* @debounce_msec : interrupt debounce time
*/
struct lp8727_platform_data {
u8 (*get_batt_present)(void);
u16 (*get_batt_level)(void);
u8 (*get_batt_capacity)(void);
u8 (*get_batt_temp)(void);
struct lp8727_chg_param ac;
struct lp8727_chg_param usb;
struct lp8727_chg_param *ac;
struct lp8727_chg_param *usb;
unsigned int debounce_msec;
};
#endif
......@@ -109,24 +109,43 @@ struct charger_cable {
* struct charger_regulator
* @regulator_name: the name of regulator for using charger.
* @consumer: the regulator consumer for the charger.
* @externally_control:
* Set if the charger-manager cannot control charger,
* the charger will be maintained with disabled state.
* @cables:
* the array of charger cables to enable/disable charger
* and set current limit according to constratint data of
* struct charger_cable if only charger cable included
* in the array of charger cables is attached/detached.
* @num_cables: the number of charger cables.
* @attr_g: Attribute group for the charger(regulator)
* @attr_name: "name" sysfs entry
* @attr_state: "state" sysfs entry
* @attr_externally_control: "externally_control" sysfs entry
* @attrs: Arrays pointing to attr_name/state/externally_control for attr_g
*/
struct charger_regulator {
/* The name of regulator for charging */
const char *regulator_name;
struct regulator *consumer;
/* charger never on when system is on */
int externally_control;
/*
* Store constraint information related to current limit,
* each cable have different condition for charging.
*/
struct charger_cable *cables;
int num_cables;
struct attribute_group attr_g;
struct device_attribute attr_name;
struct device_attribute attr_state;
struct device_attribute attr_externally_control;
struct attribute *attrs[4];
struct charger_manager *cm;
};
/**
......@@ -140,7 +159,11 @@ struct charger_regulator {
* If it has dropped more than fullbatt_vchkdrop_uV after
* fullbatt_vchkdrop_ms, CM will restart charging.
* @fullbatt_uV: voltage in microvolt
* If it is not being charged and VBATT >= fullbatt_uV,
* If VBATT >= fullbatt_uV, it is assumed to be full.
* @fullbatt_soc: state of Charge in %
* If state of Charge >= fullbatt_soc, it is assumed to be full.
* @fullbatt_full_capacity: full capacity measure
* If full capacity of battery >= fullbatt_full_capacity,
* it is assumed to be full.
* @polling_interval_ms: interval in millisecond at which
* charger manager will monitor battery health
......@@ -148,7 +171,7 @@ struct charger_regulator {
* Specify where information for existance of battery can be obtained
* @psy_charger_stat: the names of power-supply for chargers
* @num_charger_regulator: the number of entries in charger_regulators
* @charger_regulators: array of regulator_bulk_data for chargers
* @charger_regulators: array of charger regulators
* @psy_fuel_gauge: the name of power-supply for fuel gauge
* @temperature_out_of_range:
* Determine whether the status is overheat or cold or normal.
......@@ -158,6 +181,13 @@ struct charger_regulator {
* @measure_battery_temp:
* true: measure battery temperature
* false: measure ambient temperature
* @charging_max_duration_ms: Maximum possible duration for charging
* If whole charging duration exceed 'charging_max_duration_ms',
* cm stop charging.
* @discharging_max_duration_ms:
* Maximum possible duration for discharging with charger cable
* after full-batt. If discharging duration exceed 'discharging
* max_duration_ms', cm start charging.
*/
struct charger_desc {
char *psy_name;
......@@ -168,6 +198,8 @@ struct charger_desc {
unsigned int fullbatt_vchkdrop_ms;
unsigned int fullbatt_vchkdrop_uV;
unsigned int fullbatt_uV;
unsigned int fullbatt_soc;
unsigned int fullbatt_full_capacity;
enum data_source battery_present;
......@@ -180,6 +212,9 @@ struct charger_desc {
int (*temperature_out_of_range)(int *mC);
bool measure_battery_temp;
u64 charging_max_duration_ms;
u64 discharging_max_duration_ms;
};
#define PSY_NAME_MAX 30
......@@ -194,8 +229,6 @@ struct charger_desc {
* @charger_enabled: the state of charger
* @fullbatt_vchk_jiffies_at:
* jiffies at the time full battery check will occur.
* @fullbatt_vchk_uV: voltage in microvolt
* criteria for full battery
* @fullbatt_vchk_work: work queue for full battery check
* @emergency_stop:
* When setting true, stop charging
......@@ -206,6 +239,8 @@ struct charger_desc {
* saved status of external power before entering suspend-to-RAM
* @status_save_batt:
* saved status of battery before entering suspend-to-RAM
* @charging_start_time: saved start time of enabling charging
* @charging_end_time: saved end time of disabling charging
*/
struct charger_manager {
struct list_head entry;
......@@ -218,7 +253,6 @@ struct charger_manager {
bool charger_enabled;
unsigned long fullbatt_vchk_jiffies_at;
unsigned int fullbatt_vchk_uV;
struct delayed_work fullbatt_vchk_work;
int emergency_stop;
......@@ -229,6 +263,9 @@ struct charger_manager {
bool status_save_ext_pwr_inserted;
bool status_save_batt;
u64 charging_start_time;
u64 charging_end_time;
};
#ifdef CONFIG_CHARGER_MANAGER
......
......@@ -88,6 +88,7 @@ enum power_supply_property {
POWER_SUPPLY_PROP_HEALTH,
POWER_SUPPLY_PROP_PRESENT,
POWER_SUPPLY_PROP_ONLINE,
POWER_SUPPLY_PROP_AUTHENTIC,
POWER_SUPPLY_PROP_TECHNOLOGY,
POWER_SUPPLY_PROP_CYCLE_COUNT,
POWER_SUPPLY_PROP_VOLTAGE_MAX,
......@@ -110,7 +111,9 @@ enum power_supply_property {
POWER_SUPPLY_PROP_CHARGE_AVG,
POWER_SUPPLY_PROP_CHARGE_COUNTER,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE,
POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX,
POWER_SUPPLY_PROP_ENERGY_FULL_DESIGN,
POWER_SUPPLY_PROP_ENERGY_EMPTY_DESIGN,
POWER_SUPPLY_PROP_ENERGY_FULL,
......@@ -248,6 +251,7 @@ static inline bool power_supply_is_amp_property(enum power_supply_property psp)
case POWER_SUPPLY_PROP_CHARGE_AVG:
case POWER_SUPPLY_PROP_CHARGE_COUNTER:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_CURRENT_MAX:
case POWER_SUPPLY_PROP_CURRENT_MAX:
case POWER_SUPPLY_PROP_CURRENT_NOW:
case POWER_SUPPLY_PROP_CURRENT_AVG:
......@@ -276,6 +280,7 @@ static inline bool power_supply_is_watt_property(enum power_supply_property psp)
case POWER_SUPPLY_PROP_VOLTAGE_AVG:
case POWER_SUPPLY_PROP_VOLTAGE_OCV:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE:
case POWER_SUPPLY_PROP_CONSTANT_CHARGE_VOLTAGE_MAX:
case POWER_SUPPLY_PROP_POWER_NOW:
return 1;
default:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment