1 From 91536c74c12a312e9d2e045daf4f7345ba6f2362 Mon Sep 17 00:00:00 2001
2 From: Andy Green <andy@openmoko.com>
3 Date: Fri, 25 Jul 2008 23:06:21 +0100
4 Subject: [PATCH] fix-pcf50633-only-do-platform-callback-once-per-event.patch
5 Reported-by: Holger Freyther <zecke@openmoko.org>
7 We harmlessly repeated PMU platform callbacks about charging state twice.
8 Clean it up and leave it to pcf50633_charge_enable() to report once.
10 Also tidies the sequencing so we set current limit before we enable
13 Signed-off-by: Andy Green <andy@openmoko.com>
15 drivers/i2c/chips/pcf50633.c | 27 ++++++++++++++-------------
16 1 files changed, 14 insertions(+), 13 deletions(-)
18 diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
19 index a5efb4e..01ffa1d 100644
20 --- a/drivers/i2c/chips/pcf50633.c
21 +++ b/drivers/i2c/chips/pcf50633.c
22 @@ -1391,6 +1391,7 @@ static DEVICE_ATTR(voltage_hcldo, S_IRUGO | S_IWUSR, show_vreg, set_vreg);
23 static void pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma)
28 pcf->last_curlim_set = ma;
30 @@ -1406,17 +1407,16 @@ static void pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma)
32 bits = PCF50633_MBCC7_USB_SUSPEND;
34 - DEBUGPC("pcf50633_usb_curlim_set -> %dmA\n", ma);
36 - if (!pcf->pdata->cb)
38 + /* set the nearest charging limit */
39 + reg_set_bit_mask(pcf, PCF50633_REG_MBCC7, PCF56033_MBCC7_USB_MASK,
42 + /* with this charging limit, is charging actually meaningful? */
44 - case PCF50633_MBCC7_USB_100mA:
45 - case PCF50633_MBCC7_USB_SUSPEND:
46 - /* no charging is gonna be happening */
47 - pcf->pdata->cb(&pcf->client.dev,
48 - PCF50633_FEAT_MBC, PMU_EVT_CHARGER_IDLE);
49 + case PCF50633_MBCC7_USB_500mA:
50 + case PCF50633_MBCC7_USB_1000mA:
51 + /* yes with this charging limit, we can do real charging */
54 default: /* right charging context that if there is power, we charge */
55 if (pcf->flags & PCF50633_F_USB_PRESENT)
56 @@ -1424,10 +1424,11 @@ static void pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma)
57 PCF50633_FEAT_MBC, PMU_EVT_CHARGER_ACTIVE);
62 - reg_set_bit_mask(pcf, PCF50633_REG_MBCC7, PCF56033_MBCC7_USB_MASK,
65 + * enable or disable charging according to current limit -- this will
66 + * also throw a platform notification callback about it
68 + pcf50633_charge_enable(pcf50633_global, active);
71 reg_set_bit_mask(pcf, PCF50633_REG_MBCC1,