Few cpcap charger fixes for v4.12-rc cycle
cover Few cpcap charger fixes for v4.12-rc cycle
Hi,
While wondering how come the ADC values don't match the charger values and Android kernel values, I noticed few issues that would be good to fix for v4.12-rc cycle.
Especially we should stick with the Android kernel name "usb" for the charger as there's no need to break the compability there.
The other issues are fixes for misconfigured charger hardware.
Regards,
Tony
Tony Lindgren (4):
power: supply: cpcap-charger: Fix charger name
power: supply: cpcap-charger: Fix charge voltage configuration
power: supply: cpcap-charger: Fix enable for 3.8V charge setting
power: supply: cpcap-charger: Keep trickle charger bits disabled
drivers/power/supply/cpcap-charger.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
Signature · 1 line
2.12.2
PATCH 1/4 power: supply: cpcap-charger: Fix charger name
I noticed we have a different name from what Android is using. Let's not break the /sys/class/power user space interface here and use the same naming as Android has.
On Android we have the following for droid 4:
$ ls /sys/class/power_supply/ ac battery usb
So let's use the usb naming here for charger too.
CPCAP PMIC battery charger")
--- drivers/power/supply/cpcap-charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/cpcap-charger.c +1 -1
@@ -602,7 +602,7 @@ static int cpcap_charger_init_iio(struct cpcap_charger_ddata *ddata) }static const struct power_supply_desc cpcap_charger_usb_desc = { - .name ="cpcap_usb" , + .name ="usb" , .type =POWER_SUPPLY_TYPE_USB , .properties = cpcap_charger_props, .num_properties =ARRAY_SIZE (cpcap_charger_props),
Signature · 1 line
2.12.2
PATCH 2/4 power: supply: cpcap-charger: Fix charge voltage configuration
In reply to Tony LindgrenWe have the charge voltage wrong, it should be 4.35V instead of 4.2V. This will cause the battery to never get fully charged.
I noticed this when looking at the Andoid kernel battery and charger status for a fully charged battery:
# grep VOLTAGE_NOW /sys/class/power_supply/battery/uevent POWER_SUPPLY_VOLTAGE_NOW=4351000
Also the battery on droid 4 says "4.35, 1735/1785mAh (min/typ), 6.6/6.8 Wh (min/typ)". Presumably the 4.35 on the battery is the charge voltage.
And finally, on Android the CPCAP CRM register is set to 0x03b5 where the b is the charge voltage.
Let's fix the charge voltage define and update the charge configuration to use the 4.35V setting.
CPCAP PMIC battery charger")
--- drivers/power/supply/cpcap-charger.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/cpcap-charger.c +2 -2
@@ -76,7 +76,7 @@#define CPCAP_REG_CRM_VCHRG_4V30 CPCAP_REG_CRM_VCHRG(0x8)#define CPCAP_REG_CRM_VCHRG_4V32 CPCAP_REG_CRM_VCHRG(0x9)#define CPCAP_REG_CRM_VCHRG_4V34 CPCAP_REG_CRM_VCHRG(0xa) -#define CPCAP_REG_CRM_VCHRG_4V36 CPCAP_REG_CRM_VCHRG(0xb) +#define CPCAP_REG_CRM_VCHRG_4V35 CPCAP_REG_CRM_VCHRG(0xb)#define CPCAP_REG_CRM_VCHRG_4V38 CPCAP_REG_CRM_VCHRG(0xc)#define CPCAP_REG_CRM_VCHRG_4V40 CPCAP_REG_CRM_VCHRG(0xd)#define CPCAP_REG_CRM_VCHRG_4V42 CPCAP_REG_CRM_VCHRG(0xe)
@@ -469,7 +469,7 @@ static void cpcap_usb_detect(struct work_struct *work) max_current =CPCAP_REG_CRM_ICHRG_0A528 ; error =cpcap_charger_set_state (ddata, -CPCAP_REG_CRM_VCHRG_4V20 , +CPCAP_REG_CRM_VCHRG_4V35 , max_current,CPCAP_REG_CRM_TR_0A72 );if (error)
Signature · 1 line
2.12.2
PATCH 3/4 power: supply: cpcap-charger: Fix enable for 3.8V charge setting
In reply to Tony LindgrenZero is a valid register value for for 3.8V charging.
CPCAP PMIC battery charger")
--- drivers/power/supply/cpcap-charger.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/power/supply/cpcap-charger.c +1 -1
@@ -262,7 +262,7 @@ static int cpcap_charger_set_state(struct cpcap_charger_ddata *ddata,bool enable;int error; - enable = max_voltage && (charge_current || trickle_current); + enable = (charge_current || trickle_current);dev_dbg (ddata->dev,"%s enable: %i\n" , __func__, enable);if (!enable) {
Signature · 1 line
2.12.2
PATCH 4/4 power: supply: cpcap-charger: Keep trickle charger bits disabled
In reply to Tony LindgrenAndroid does not seem to set the trickle charger bits, and these seem to be only used by the bootloader when bringing up a completely discharged battery. So let's keep the trickle charging bits disabled and avoid misconfiguring the hardware.
CPCAP PMIC battery charger")
--- drivers/power/supply/cpcap-charger.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/power/supply/cpcap-charger.c +1 -2
@@ -470,8 +470,7 @@ static void cpcap_usb_detect(struct work_struct *work) error =cpcap_charger_set_state (ddata,CPCAP_REG_CRM_VCHRG_4V35 , - max_current, -CPCAP_REG_CRM_TR_0A72 ); + max_current,0 );if (error) goto out_err; }else {
Signature · 1 line
2.12.2
Hi,
Quoted 15 lines · Tony Lindgren
While wondering how come the ADC values don't match the charger values and Android kernel values, I noticed few issues that would be good to fix for v4.12-rc cycle.
Especially we should stick with the Android kernel name "usb" for the charger as there's no need to break the compability there.
The other issues are fixes for misconfigured charger hardware.
Regards,
Tony
Quoted 8 lines
Tony Lindgren (4):
power: supply: cpcap-charger: Fix charger name
power: supply: cpcap-charger: Fix charge voltage configuration
power: supply: cpcap-charger: Fix enable for 3.8V charge setting
power: supply: cpcap-charger: Keep trickle charger bits disableddrivers/power/supply/cpcap-charger.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-)
Thanks, queued.
-- Sebastian