2008-12-12 11:58:53 +00:00
|
|
|
From be0f111b3d1570dec174ff301d08bad995ccf1e6 Mon Sep 17 00:00:00 2001
|
2008-12-12 00:02:36 +00:00
|
|
|
From: Andy Green <andy@openmoko.com>
|
2008-12-12 11:58:53 +00:00
|
|
|
Date: Tue, 22 Jul 2008 22:17:15 +0100
|
2008-12-12 00:02:36 +00:00
|
|
|
Subject: [PATCH] fix-pcf50633-only-do-platform-callback-once-per-event.patch
|
|
|
|
Reported-by: Holger Freyther <zecke@openmoko.org>
|
|
|
|
|
|
|
|
We harmlessly repeated PMU platform callbacks about charging state twice.
|
|
|
|
Clean it up and leave it to pcf50633_charge_enable() to report once.
|
|
|
|
|
|
|
|
Also tidies the sequencing so we set current limit before we enable
|
|
|
|
charger now.
|
|
|
|
|
|
|
|
Signed-off-by: Andy Green <andy@openmoko.com>
|
|
|
|
---
|
2008-12-12 11:58:53 +00:00
|
|
|
drivers/i2c/chips/pcf50633.c | 35 ++++++++++++++++-------------------
|
|
|
|
1 files changed, 16 insertions(+), 19 deletions(-)
|
2008-12-12 00:02:36 +00:00
|
|
|
|
|
|
|
diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
|
2008-12-12 11:58:53 +00:00
|
|
|
index bd47ebc..98c254c 100644
|
2008-12-12 00:02:36 +00:00
|
|
|
--- a/drivers/i2c/chips/pcf50633.c
|
|
|
|
+++ b/drivers/i2c/chips/pcf50633.c
|
2008-12-12 11:58:53 +00:00
|
|
|
@@ -1392,6 +1392,7 @@ static DEVICE_ATTR(voltage_hcldo, S_IRUGO | S_IWUSR, show_vreg, set_vreg);
|
2008-12-12 00:02:36 +00:00
|
|
|
static void pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma)
|
|
|
|
{
|
|
|
|
u_int8_t bits;
|
|
|
|
+ int active = 0;
|
|
|
|
|
|
|
|
pcf->last_curlim_set = ma;
|
|
|
|
|
2008-12-12 11:58:53 +00:00
|
|
|
@@ -1407,30 +1408,26 @@ static void pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma)
|
2008-12-12 00:02:36 +00:00
|
|
|
else
|
|
|
|
bits = PCF50633_MBCC7_USB_SUSPEND;
|
|
|
|
|
|
|
|
- DEBUGPC("pcf50633_usb_curlim_set -> %dmA\n", ma);
|
|
|
|
-
|
|
|
|
- if (!pcf->pdata->cb)
|
|
|
|
- goto set_it;
|
|
|
|
+ /* set the nearest charging limit */
|
|
|
|
+ reg_set_bit_mask(pcf, PCF50633_REG_MBCC7, PCF56033_MBCC7_USB_MASK,
|
|
|
|
+ bits);
|
|
|
|
|
|
|
|
+ /* with this charging limit, is charging actually meaningful? */
|
|
|
|
switch (bits) {
|
|
|
|
- case PCF50633_MBCC7_USB_100mA:
|
|
|
|
- case PCF50633_MBCC7_USB_SUSPEND:
|
|
|
|
- /* no charging is gonna be happening */
|
|
|
|
- pcf->pdata->cb(&pcf->client.dev,
|
|
|
|
- PCF50633_FEAT_MBC, PMU_EVT_CHARGER_IDLE);
|
2008-12-12 11:58:53 +00:00
|
|
|
- pcf50633_charge_enable(pcf50633_global, 0);
|
2008-12-12 00:02:36 +00:00
|
|
|
+ case PCF50633_MBCC7_USB_500mA:
|
|
|
|
+ case PCF50633_MBCC7_USB_1000mA:
|
|
|
|
+ /* yes with this charging limit, we can do real charging */
|
|
|
|
+ active = 1;
|
|
|
|
break;
|
2008-12-12 11:58:53 +00:00
|
|
|
- default: /* right charging context that if there is power, we charge */
|
|
|
|
- if (pcf->flags & PCF50633_F_USB_PRESENT)
|
|
|
|
- pcf->pdata->cb(&pcf->client.dev,
|
|
|
|
- PCF50633_FEAT_MBC, PMU_EVT_CHARGER_ACTIVE);
|
|
|
|
- pcf50633_charge_enable(pcf50633_global, 1);
|
|
|
|
+ default:
|
|
|
|
+ /* no charging is gonna be happening */
|
2008-12-12 00:02:36 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
-
|
|
|
|
-set_it:
|
|
|
|
- reg_set_bit_mask(pcf, PCF50633_REG_MBCC7, PCF56033_MBCC7_USB_MASK,
|
|
|
|
- bits);
|
|
|
|
+ /*
|
|
|
|
+ * enable or disable charging according to current limit -- this will
|
|
|
|
+ * also throw a platform notification callback about it
|
|
|
|
+ */
|
|
|
|
+ pcf50633_charge_enable(pcf50633_global, active);
|
|
|
|
|
|
|
|
/* clear batfull */
|
|
|
|
reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,
|
|
|
|
--
|
2008-12-12 11:58:53 +00:00
|
|
|
1.5.6.5
|
2008-12-12 00:02:36 +00:00
|
|
|
|