Subject: pcf50633_introduce_charging_restart_interval.patch
authorBalaji Rao <balajirrao@openmoko.org>
Wed, 28 Jan 2009 19:31:11 +0000 (19:31 +0000)
committerAndy Green <agreen@octopus.localdomain>
Wed, 28 Jan 2009 19:31:11 +0000 (19:31 +0000)
X-Git-Url: http://git.openmoko.org/?p=kernel.git;a=commitdiff_plain;h=1bb6adaa6a59f52d616b5260cb776eafd40ef05e

pcf50633_introduce_charging_restart_interval.patch

Signed-off-by: Balaji Rao <balajirrao@openmoko.org>

arch/arm/mach-s3c2440/mach-gta02.c
drivers/power/pcf50633-charger.c
include/linux/mfd/pcf50633/core.h

index 29d35f2..31759d8 100644 (file)
@@ -639,6 +639,7 @@ struct pcf50633_platform_data gta02_pcf_pdata = {
 
        .batteries = gta02_batteries,
        .num_batteries = ARRAY_SIZE(gta02_batteries),
+       .charging_restart_interval = (900 * HZ),
 
        .reg_init_data = {
                [PCF50633_REGULATOR_AUTO] = {
index 98fb645..1efd798 100644 (file)
@@ -172,12 +172,10 @@ static struct attribute_group mbc_attr_group = {
  * batteries is marginal(1~2 %) till about 80% of its capacity - which means,
  * after a BATFULL, charging won't be restarted until 80%.
  *
- * This work_struct function restarts charging every
- * CHARGING_RESTART_TIMEOUT seconds and makes sure we don't discharge too much
+ * This work_struct function restarts charging every few seconds and makes
+ * sure we don't discharge too much
  */
 
-#define CHARGING_RESTART_TIMEOUT       (900 * HZ)  /* 15 minutes */
-
 static void pcf50633_mbc_charging_restart(struct work_struct *work)
 {
        struct pcf50633_mbc *mbc;
@@ -205,6 +203,8 @@ static void
 pcf50633_mbc_irq_handler(int irq, void *data)
 {
        struct pcf50633_mbc *mbc = data;
+       int chg_restart_interval = 
+                       mbc->pcf->pdata->charging_restart_interval;
 
        /* USB */
        if (irq == PCF50633_IRQ_USBINS) {
@@ -212,7 +212,7 @@ pcf50633_mbc_irq_handler(int irq, void *data)
        } else if (irq == PCF50633_IRQ_USBREM) {
                mbc->usb_online = 0;
                mbc->usb_active = 0;
-               pcf50633_mbc_usb_curlim_set(mbc->pcf, 0);
+               pcf50633_mbc_usb_curlim_set(mbc->pcf, 0);               
                cancel_delayed_work_sync(&mbc->charging_restart_work);
        }
 
@@ -228,8 +228,10 @@ pcf50633_mbc_irq_handler(int irq, void *data)
        if (irq == PCF50633_IRQ_BATFULL) {
                mbc->usb_active = 0;
                mbc->adapter_active = 0;
-               schedule_delayed_work(&mbc->charging_restart_work,
-                                               CHARGING_RESTART_TIMEOUT);
+
+               if (chg_restart_interval > 0)
+                       schedule_delayed_work(&mbc->charging_restart_work,
+                                                       chg_restart_interval);
        } else if (irq == PCF50633_IRQ_USBLIMON)
                mbc->usb_active = 0;
        else if (irq == PCF50633_IRQ_USBLIMOFF)
@@ -419,6 +421,8 @@ static int __devexit pcf50633_mbc_remove(struct platform_device *pdev)
        power_supply_unregister(&mbc->usb);
        power_supply_unregister(&mbc->adapter);
 
+       cancel_delayed_work_sync(&mbc->charging_restart_work);
+
        kfree(mbc);
 
        return 0;
index 2269f3b..b7a891b 100644 (file)
@@ -29,6 +29,8 @@ struct pcf50633_platform_data {
        char **batteries;
        int num_batteries;
 
+       int charging_restart_interval;
+
        /* Callbacks */
        void (*probe_done)(struct pcf50633 *);
        void (*mbc_event_callback)(struct pcf50633 *, int);