power: supply: rt9471: Fix WDT bitfield and charger status
cover power: supply: rt9471: Fix WDT bitfield and charger status
From: ChiYuan Huang <[email protected]>
This patch series add the following fixes that reported from the end market included WDT bitfield and the real charger status.
ChiYuan Huang (2):
power: supply: rt9471: Fix wrong WDT function regfield declaration
power: supply: rt9471: Use IC status regfield to report real charger
status
drivers/power/supply/rt9471.c | 52 ++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 19 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/2 power: supply: rt9471: Fix wrong WDT function regfield declaration
From: ChiYuan Huang <[email protected]>
Fix F_WDT and F_WDT_RST wrong regfield declaration.
--- drivers/power/supply/rt9471.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/power/supply/rt9471.c +2 -2
@@ -153,8 +153,8 @@ struct rt9471_chip { };static const struct reg_field rt9471_reg_fields[F_MAX_FIELDS ] = { - [F_WDT ] =REG_FIELD (RT9471_REG_TOP ,0 ,0 ), - [F_WDT_RST ] =REG_FIELD (RT9471_REG_TOP ,1 ,1 ), + [F_WDT ] =REG_FIELD (RT9471_REG_TOP ,0 ,1 ), + [F_WDT_RST ] =REG_FIELD (RT9471_REG_TOP ,2 ,2 ), [F_CHG_EN ] =REG_FIELD (RT9471_REG_FUNC ,0 ,0 ), [F_HZ ] =REG_FIELD (RT9471_REG_FUNC ,5 ,5 ), [F_BATFET_DIS ] =REG_FIELD (RT9471_REG_FUNC ,7 ,7 ),
Signature · 1 line
2.34.1
PATCH 2/2 power: supply: rt9471: Use IC status regfield to report real charger status
In reply to [email protected]From: ChiYuan Huang <[email protected]>
Use IC status regfield to rewrite the 'get_staus' function. The original one cannot cover some special scenario like as charger OTP or JEITA case.
--- drivers/power/supply/rt9471.c | 48 ++++++++++++++++++++++------------- 1 file changed, 31 insertions(+), 17 deletions(-)
drivers/power/supply/rt9471.c +31 -17
@@ -139,6 +139,19 @@ enum { RT9471_PORTSTAT_DCP, }; +enum { +RT9471_ICSTAT_SLEEP =0 , +RT9471_ICSTAT_VBUSRDY , +RT9471_ICSTAT_TRICKLECHG , +RT9471_ICSTAT_PRECHG , +RT9471_ICSTAT_FASTCHG , +RT9471_ICSTAT_IEOC , +RT9471_ICSTAT_BGCHG , +RT9471_ICSTAT_CHGDONE , +RT9471_ICSTAT_CHGFAULT , +RT9471_ICSTAT_OTG =15 , +}; +struct rt9471_chip {struct device *dev;struct regmap *regmap;
@@ -255,31 +268,32 @@ static int rt9471_get_ieoc(struct rt9471_chip *chip, int *microamp)static int rt9471_get_status (struct rt9471_chip *chip,int *status) { -unsigned int chg_ready, chg_done, fault_stat; +unsigned int ic_stat;int ret; - ret =regmap_field_read (chip->rm_fields[F_ST_CHG_RDY ], &chg_ready); -if (ret) -return ret; - - ret =regmap_field_read (chip->rm_fields[F_ST_CHG_DONE ], &chg_done); + ret =regmap_field_read (chip->rm_fields[F_IC_STAT ], &ic_stat);if (ret)return ret; - ret =regmap_read (chip->regmap,RT9471_REG_STAT1 , &fault_stat); -if (ret) -return ret; - - fault_stat &=RT9471_CHGFAULT_MASK ; - -if (chg_ready && chg_done) - *status =POWER_SUPPLY_STATUS_FULL ; -else if (chg_ready && fault_stat) +switch (ic_stat) { +case RT9471_ICSTAT_VBUSRDY : +case RT9471_ICSTAT_CHGFAULT : *status =POWER_SUPPLY_STATUS_NOT_CHARGING ; -else if (chg_ready && !fault_stat) +break ; + case RT9471_ICSTAT_TRICKLECHG ... RT9471_ICSTAT_BGCHG: *status =POWER_SUPPLY_STATUS_CHARGING ; -else +break ; +case RT9471_ICSTAT_CHGDONE : + *status =POWER_SUPPLY_STATUS_FULL ; +break ; +case RT9471_ICSTAT_SLEEP : +case RT9471_ICSTAT_OTG : *status =POWER_SUPPLY_STATUS_DISCHARGING ; +break ; +default : + *status =POWER_SUPPLY_STATUS_UNKNOWN ; +break ; + }return 0 ; }
Signature · 1 line
2.34.1
Quoted 4 lines · On Wed, Sep 25, 2024 at 04:32:57PM +0800, [email protected] wrote:
From: ChiYuan Huang <[email protected]>
This patch series add the following fixes that reported from the end market included WDT bitfield and the real charger status.
Any reply for this patch series?
Quoted 12 lines
ChiYuan Huang (2):
power: supply: rt9471: Fix wrong WDT function regfield declaration
power: supply: rt9471: Use IC status regfield to report real charger
statusdrivers/power/supply/rt9471.c | 52 ++++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 19 deletions(-)Signature · 1 line
2.34.1
Sebastian Reichel
AppliedQuoted 11 lines · On Wed, 25 Sep 2024 16:32:57 +0800, [email protected] wrote:
From: ChiYuan Huang <[email protected]>
This patch series add the following fixes that reported from the end market included WDT bitfield and the real charger status.
ChiYuan Huang (2):
power: supply: rt9471: Fix wrong WDT function regfield declaration
power: supply: rt9471: Use IC status regfield to report real charger
status[...]
Applied, thanks!
[1/2] power: supply: rt9471: Fix wrong WDT function regfield declaration
commit: d10ff07dd2b933e3864c592ca932996b07bbf22a
[2/2] power: supply: rt9471: Use IC status regfield to report real charger status
commit: c46a9ee5c6210682611d3d4276436c23a95e1996Best regards,
Signature · 1 line
Sebastian Reichel <[email protected]>