[PATCH] power: pcf50633 wall charger current limit fix
Rask Ingemann Lambertsen
rask at sygehus.dk
Sun Feb 8 14:58:47 CET 2009
Hi.
The recent patch to fix a USB current limit violation when turning the
device off triggered a bug in setting the battery charge current limit. We
now get a charge current limit of 0 mA on the GTA02 when plugging in the
wall charger (just as when setting 1000 mA in /sys/class/[...]/chg_curlim).
This patch fixes it (and a comment typo). Tested on a GTA02 with a wall
charger.
Signed-off-by: Rask Ingemann Lambertsen <rask at sygehus.dk>
---
drivers/power/pcf50633-charger.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
--- a/drivers/power/pcf50633-charger.c 2009-02-05 18:01:56.000000000 +0100
+++ b/drivers/power/pcf50633-charger.c 2009-02-08 13:49:58.000000000 +0100
@@ -48,7 +48,7 @@ int pcf50633_mbc_usb_curlim_set(struct p
u8 bits;
int charging_start = 1;
u8 mbcs2, chgmod;
- u8 mbcc5;
+ unsigned int mbcc5;
if (ma >= 1000) {
bits = PCF50633_MBCC7_USB_1000mA;
@@ -76,7 +76,7 @@ int pcf50633_mbc_usb_curlim_set(struct p
* We limit the charging current to be the USB current limit.
* The reason is that on pcf50633, when it enters PMU Standby mode,
* which it does when the device goes "off", the USB current limit
- * reverts to the variant default. It at least one common case, that
+ * reverts to the variant default. In at least one common case, that
* default is 500mA. By setting the charging current to be the same
* as the USB limit we set here before PMU standby, we enforce it only
* using the correct amount of current even when the USB current limit
@@ -84,6 +84,8 @@ int pcf50633_mbc_usb_curlim_set(struct p
*/
mbcc5 = (ma << 8) / mbc->pcf->pdata->chg_ref_current_ma;
+ if (mbcc5 > 255)
+ mbcc5 = 255;
pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
mbcs2 = pcf50633_reg_read(pcf, PCF50633_REG_MBCS2);
@@ -192,7 +194,7 @@ static ssize_t set_chglim(struct device
{
struct pcf50633_mbc *mbc = dev_get_drvdata(dev);
unsigned long ma;
- u8 mbcc5;
+ unsigned int mbcc5;
int ret;
ret = strict_strtoul(buf, 10, &ma);
@@ -200,6 +202,8 @@ static ssize_t set_chglim(struct device
return -EINVAL;
mbcc5 = (ma << 8) / mbc->pcf->pdata->chg_ref_current_ma;
+ if (mbcc5 > 255)
+ mbcc5 = 255;
pcf50633_reg_write(mbc->pcf, PCF50633_REG_MBCC5, mbcc5);
return count;
--
Rask Ingemann Lambertsen
Danish law requires addresses in e-mail to be logged and stored for a year
More information about the openmoko-kernel
mailing list