Hi,
These two patches simply enable the charge function and could
distinguish the charge source is USB wall charger or USB host.
Then battery could be charged by the charge source accordingly.
Cheers,
Matt
Index: u-boot/board/neo1973/gta02/pcf50633.c
===================================================================
--- u-boot.orig/board/neo1973/gta02/pcf50633.c 2008-01-22 15:00:13.000000000 +0800
+++ u-boot/board/neo1973/gta02/pcf50633.c 2008-01-22 20:51:20.000000000 +0800
@@ -107,7 +107,7 @@
[PCF50633_REG_MBCC2] = 0x28, /* Vbatconid=2.7V, Vmax=4.20V */
[PCF50633_REG_MBCC3] = 0x19, /* 25/255 == 98mA pre-charge */
[PCF50633_REG_MBCC4] = 0xff, /* 255/255 == 1A adapter fast */
- [PCF50633_REG_MBCC5] = 0x7f, /* 127/255 == 500mA usb fast */
+ [PCF50633_REG_MBCC5] = 0xff, /* 255/255 == 1A usb fast */
[PCF50633_REG_MBCC6] = 0x00, /* cutoff current 1/32 * Ichg */
[PCF50633_REG_MBCC7] = 0x00, /* 1.6A max bat curr, USB 100mA */
[PCF50633_REG_MBCC8] = 0x00,
Index: linux-2.6.22.5/drivers/i2c/chips/pcf50633.c
===================================================================
--- linux-2.6.22.5.orig/drivers/i2c/chips/pcf50633.c 2008-01-22 20:16:28.000000000 +0800
+++ linux-2.6.22.5/drivers/i2c/chips/pcf50633.c 2008-01-22 20:43:32.000000000 +0800
@@ -224,6 +224,17 @@
channel &= PCF50633_ADCC1_ADCMUX_MASK;
+ /* necessary setting for specific channel */
+ if (channel & PCF50633_ADCC1_MUX_ADCIN1){
+ reg_set_bit_mask(pcf, PCF50633_REG_ADCC2,
+ 0x7 ,PCF50633_ADCC2_RATIO_ADCIN1);
+ reg_set_bit_mask(pcf, PCF50633_REG_ADCC3,
+ 0x1f ,PCF50633_ADCC3_ACCSW_EN);
+ }
+ else if (channel & PCF50633_ADCC1_MUX_BATTEMP){
+ /* FIXME: Not implemented */
+ }
+
mutex_lock(&pcf->lock);
/* start ADC conversion of selected channel */
@@ -864,6 +875,15 @@
}
static DEVICE_ATTR(usb_curlim, S_IRUGO | S_IWUSR, show_usblim, NULL);
+static uint16_t pcf50633_usbid_volt(struct pcf50633_data *pcf)
+{
+ uint16_t adc;
+
+ adc = adc_read(pcf, PCF50633_ADCC1_MUX_ADCIN1, 0, NULL);
+
+ return adc;
+}
+
/* Enable/disable charging */
void pcf50633_charge_enable(struct pcf50633_data *pcf, int on)
{
@@ -875,9 +895,20 @@
if (on) {
pcf->flags |= PCF50633_F_CHG_ENABLED;
bits = PCF50633_MBCC1_CHGENA;
+ reg_set_bit_mask(pcf, PCF50633_REG_MBCC1, 0xff, bits);
+
+ if(pcf50633_usbid_volt(pcf) < 600){
+ DEBUGP("USB Wall CHG \n");
+ pcf50633_usb_curlim_set(pcf, 1000);
+ }
+ else{
+ DEBUGP("USB Host \n");
+ pcf50633_usb_curlim_set(pcf, 500);
+ }
} else {
pcf->flags &= ~PCF50633_F_CHG_ENABLED;
bits = 0;
+ reg_set_bit_mask(pcf, PCF50633_REG_MBCC1, 0xff, bits);
}
}
EXPORT_SYMBOL_GPL(pcf50633_charge_enable);