diff options
author | Sean McNeil <sean@mcneil.com> | 2008-12-02 11:35:42 +0000 |
---|---|---|
committer | Andy Green <agreen@pads.home.warmcat.com> | 2008-12-02 11:35:42 +0000 |
commit | 9205fa7206e2fcd5d6e23670f5d8c215fc999874 (patch) | |
tree | a2dc8158637f42354f620f39ca1e8cce7b937be0 /drivers | |
parent | 3e41e162f47f688c24e3402b961cf5c32f990dd9 (diff) |
PATCH-add-ac-charger-power_supply.eml
This adds an appropriate ac power_supply class and shows usb only when
at the appropriate current limit.
Signed-off-by: Sean McNeil <sean@mcneil.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/power/pcf50633-charger.c | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/drivers/power/pcf50633-charger.c b/drivers/power/pcf50633-charger.c index 03d64111501..9bbfaac48a1 100644 --- a/drivers/power/pcf50633-charger.c +++ b/drivers/power/pcf50633-charger.c @@ -154,6 +154,7 @@ static void pcf50633_mbc_irq_handler(struct pcf50633 *pcf, int irq, void *data) mbc->adapter_active = 0; } + power_supply_changed(&mbc->ac); power_supply_changed(&mbc->usb); power_supply_changed(&mbc->adapter); @@ -185,10 +186,36 @@ static int usb_get_property(struct power_supply *psy, { int ret = 0; struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, usb); + struct pcf50633 *pcf = container_of(mbc, struct pcf50633, mbc); + + u8 usblim = pcf50633_reg_read(pcf, PCF50633_REG_MBCC7) & + PCF50633_MBCC7_USB_MASK; + + switch (psp) { + case POWER_SUPPLY_PROP_ONLINE: + val->intval = mbc->usb_online && (usblim == PCF50633_MBCC7_USB_500mA); + break; + default: + ret = -EINVAL; + break; + } + return ret; +} + +static int ac_get_property(struct power_supply *psy, + enum power_supply_property psp, + union power_supply_propval *val) +{ + int ret = 0; + struct pcf50633_mbc *mbc = container_of(psy, struct pcf50633_mbc, ac); + struct pcf50633 *pcf = container_of(mbc, struct pcf50633, mbc); + + u8 usblim = pcf50633_reg_read(pcf, PCF50633_REG_MBCC7) & + PCF50633_MBCC7_USB_MASK; switch (psp) { case POWER_SUPPLY_PROP_ONLINE: - val->intval = mbc->usb_online; + val->intval = mbc->usb_online && (usblim == PCF50633_MBCC7_USB_1000mA); break; default: ret = -EINVAL; @@ -254,6 +281,14 @@ int __init pcf50633_mbc_probe(struct platform_device *pdev) mbc->usb.supplied_to = pcf->pdata->batteries; mbc->usb.num_supplicants = pcf->pdata->num_batteries; + mbc->ac.name = "ac"; + mbc->ac.type = POWER_SUPPLY_TYPE_MAINS; + mbc->ac.properties = power_props; + mbc->ac.num_properties = ARRAY_SIZE(power_props); + mbc->ac.get_property = ac_get_property; + mbc->ac.supplied_to = pcf->pdata->batteries; + mbc->ac.num_supplicants = pcf->pdata->num_batteries; + ret = power_supply_register(&pdev->dev, &mbc->adapter); if (ret) dev_err(pcf->dev, "failed to register adapter\n"); @@ -262,6 +297,10 @@ int __init pcf50633_mbc_probe(struct platform_device *pdev) if (ret) dev_err(pcf->dev, "failed to register usb\n"); + ret = power_supply_register(&pdev->dev, &mbc->ac); + if (ret) + dev_err(pcf->dev, "failed to register ac\n"); + return sysfs_create_group(&pdev->dev.kobj, &mbc_attr_group); } |