Skip to content

Commit 0c5ecf7

Browse files
committed
power: supply: ln8411: Clears CP_EN when protection fault is hit
Clears CP_EN through power_supply when any of the COMP_FLAG protections mentioned in 'Protections' in the d/s are tripped. This is necessary as CP_EN does not autoclear after a protection fault. Change-Id: Id649eda39ff630eb2a77ac7ce683e61848d9f9ad Signed-off-by: Ricardo Rivera-Matos <[email protected]>
1 parent e3f9a7e commit 0c5ecf7

File tree

2 files changed

+27
-10
lines changed

2 files changed

+27
-10
lines changed

drivers/power/supply/ln8411_charger.c

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -874,32 +874,39 @@ static int ln8411_post_irq_handler(void *irq_drv_data)
874874
{
875875
struct ln8411_device *ln8411 = irq_drv_data;
876876
union power_supply_propval val = {0};
877+
bool protect_flt_set = false;
877878
unsigned int reg;
878879
int ret;
879880

880881
ret = regmap_read(ln8411->regmap, LN8411_COMP_FLAG0, &reg);
881882
if (ret)
882883
return ret;
883884

884-
/* CP_EN bit does not auto clear during unplug, must be manually cleared*/
885-
if (reg & LN8411_IBUS_UCP_FALL_FLAG) {
886-
val.intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
887-
888-
ret = power_supply_set_property(ln8411->charger, POWER_SUPPLY_PROP_STATUS, &val);
889-
if (ret)
890-
return ret;
891-
892-
dev_dbg(ln8411->dev, "Unplug detected, disabling converter\n");
893-
}
885+
if (reg & LN8411_PROTECT_FLTS_COMP_FLAG0)
886+
protect_flt_set = true;
894887

895888
dev_dbg(ln8411->dev, "COMP_FLAG0: 0x%x\n", reg);
896889

897890
ret = regmap_read(ln8411->regmap, LN8411_COMP_FLAG1, &reg);
898891
if (ret)
899892
return ret;
900893

894+
if (reg & LN8411_PROTECT_FLTS_COMP_FLAG1)
895+
protect_flt_set = true;
896+
901897
dev_dbg(ln8411->dev, "COMP_FLAG1: 0x%x\n", reg);
902898

899+
/* CP_EN bit does not auto clear during protection fault, must be manually cleared */
900+
if (protect_flt_set) {
901+
val.intval = POWER_SUPPLY_STATUS_NOT_CHARGING;
902+
903+
ret = power_supply_set_property(ln8411->charger, POWER_SUPPLY_PROP_STATUS, &val);
904+
if (ret)
905+
return ret;
906+
907+
dev_dbg(ln8411->dev, "Fault detected, disabling converter\n");
908+
}
909+
903910
ret = regmap_set_bits(ln8411->regmap, LN8411_LION_INT_MASK_2, LN8411_CLEAR_INT);
904911
if (ret)
905912
return ret;

drivers/power/supply/ln8411_charger.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,16 @@
392392
#define LN8411_OTG_MIN_1TO2_MIN_UV (LN8411_OTG_MIN_UV * 2)
393393
#define LN8411_OTG_MIN_1TO4_MIN_UV (LN8411_OTG_MIN_UV * 4)
394394

395+
#define LN8411_PROTECT_FLTS_COMP_FLAG0 (LN8411_VUSB_OVP_FLAG | \
396+
LN8411_VWPC_OVP_FLAG | \
397+
LN8411_IBUS_OCP_FLAG | \
398+
LN8411_IBUS_UCP_FALL_FLAG | \
399+
LN8411_VBAT_OVP_FLAG | \
400+
LN8411_IBAT_OCP_FLAG)
401+
402+
#define LN8411_PROTECT_FLTS_COMP_FLAG1 (LN8411_PMID2OUT_UVP_FLAG | \
403+
LN8411_PMID2OUT_OVP_FLAG)
404+
395405
enum ln8411_roles {
396406
LN8411_USB = 0,
397407
LN8411_DUAL,

0 commit comments

Comments
 (0)