[PATCH 1/2] fix-pcf50633-move-charger-enable-decision-to-pcf50633_usb_curlim_set.patch

Andy Green andy at openmoko.com
Tue Jul 22 13:15:13 CEST 2008


At the moment we ended up enabling and disabling the charger
at the time we service USBINS and USBREM events in the ISR.

We did that in machine specific code, but really it is PMU
specific decision, so this patch moves it into PMU code.

We enabled and disabled the charge immediately we saw the
interrupt event from PMU, yet we deferred setting charging
state based on ID and USB enumeration until at least after a
PMU ADC read that was handled in a second interrupt later.

Now the timing is unified to after we determined the charger
type and we enable and disable right there.

Signed-off-by: Andy Green <andy at openmoko.com>
---

 arch/arm/mach-s3c2440/mach-gta02.c |    8 ++------
 drivers/i2c/chips/pcf50633.c       |    2 ++
 2 files changed, 4 insertions(+), 6 deletions(-)

diff --git a/arch/arm/mach-s3c2440/mach-gta02.c b/arch/arm/mach-s3c2440/mach-gta02.c
index 25764f3..d287877 100644
--- a/arch/arm/mach-s3c2440/mach-gta02.c
+++ b/arch/arm/mach-s3c2440/mach-gta02.c
@@ -484,16 +484,12 @@ static int pmu_callback(struct device *dev, unsigned int feature,
 	switch (feature) {
 	case PCF50633_FEAT_MBC:
 		switch (event) {
-		case PMU_EVT_INSERT:
 		case PMU_EVT_USB_INSERT:
-			pcf50633_charge_enable(pcf50633_global, 1);
-			break;
-		case PMU_EVT_REMOVE:
 		case PMU_EVT_USB_REMOVE:
-			pcf50633_charge_enable(pcf50633_global, 0);
-			break;
 		case PMU_EVT_CHARGER_IDLE:
 		case PMU_EVT_CHARGER_ACTIVE:
+		case PMU_EVT_INSERT: /* adapter */
+		case PMU_EVT_REMOVE: /* adapter */
 			break;
 		default:
 			break;
diff --git a/drivers/i2c/chips/pcf50633.c b/drivers/i2c/chips/pcf50633.c
index af36e33..d9b78d8 100644
--- a/drivers/i2c/chips/pcf50633.c
+++ b/drivers/i2c/chips/pcf50633.c
@@ -1414,11 +1414,13 @@ void pcf50633_usb_curlim_set(struct pcf50633_data *pcf, int ma)
 		 /* no charging is gonna be happening */
 		pcf->pdata->cb(&pcf->client.dev,
 			       PCF50633_FEAT_MBC, PMU_EVT_CHARGER_IDLE);
+		pcf50633_charge_enable(pcf50633_global, 0);
 		break;
 	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);
 		break;
 	}
 





More information about the openmoko-kernel mailing list