* [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status
@ 2024-09-25 8:32 cy_huang
2024-09-25 8:32 ` [PATCH 1/2] power: supply: rt9471: Fix wrong WDT function regfield declaration cy_huang
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: cy_huang @ 2024-09-25 8:32 UTC (permalink / raw)
To: 'Lucas Tsai ', Sebastian Reichel
Cc: ChiYuan Huang, linux-pm, linux-kernel
From: ChiYuan Huang <cy_huang@richtek.com>
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(-)
--
2.34.1
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] power: supply: rt9471: Fix wrong WDT function regfield declaration
2024-09-25 8:32 [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status cy_huang
@ 2024-09-25 8:32 ` cy_huang
2024-09-25 8:32 ` [PATCH 2/2] power: supply: rt9471: Use IC status regfield to report real charger status cy_huang
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: cy_huang @ 2024-09-25 8:32 UTC (permalink / raw)
To: 'Lucas Tsai ', Sebastian Reichel
Cc: ChiYuan Huang, linux-pm, linux-kernel
From: ChiYuan Huang <cy_huang@richtek.com>
Fix F_WDT and F_WDT_RST wrong regfield declaration.
Fixes: 4a1a5f6781d8 ("power: supply: rt9471: Add Richtek RT9471 charger driver")
Reported-by: Lucas Tsai <lucas_tsai@richtek.com>
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
drivers/power/supply/rt9471.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/power/supply/rt9471.c b/drivers/power/supply/rt9471.c
index c04af1ee89c6..730b252b4900 100644
--- a/drivers/power/supply/rt9471.c
+++ b/drivers/power/supply/rt9471.c
@@ -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),
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] power: supply: rt9471: Use IC status regfield to report real charger status
2024-09-25 8:32 [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status cy_huang
2024-09-25 8:32 ` [PATCH 1/2] power: supply: rt9471: Fix wrong WDT function regfield declaration cy_huang
@ 2024-09-25 8:32 ` cy_huang
2024-10-16 6:13 ` [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and " ChiYuan Huang
2024-10-16 21:41 ` Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: cy_huang @ 2024-09-25 8:32 UTC (permalink / raw)
To: 'Lucas Tsai ', Sebastian Reichel
Cc: ChiYuan Huang, linux-pm, linux-kernel
From: ChiYuan Huang <cy_huang@richtek.com>
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.
Fixes: 4a1a5f6781d8 ("power: supply: rt9471: Add Richtek RT9471 charger driver")
Reported-by: Lucas Tsai <lucas_tsai@richtek.com>
Signed-off-by: ChiYuan Huang <cy_huang@richtek.com>
---
drivers/power/supply/rt9471.c | 48 ++++++++++++++++++++++-------------
1 file changed, 31 insertions(+), 17 deletions(-)
diff --git a/drivers/power/supply/rt9471.c b/drivers/power/supply/rt9471.c
index 730b252b4900..67b86ac91a21 100644
--- a/drivers/power/supply/rt9471.c
+++ b/drivers/power/supply/rt9471.c
@@ -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;
}
--
2.34.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status
2024-09-25 8:32 [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status cy_huang
2024-09-25 8:32 ` [PATCH 1/2] power: supply: rt9471: Fix wrong WDT function regfield declaration cy_huang
2024-09-25 8:32 ` [PATCH 2/2] power: supply: rt9471: Use IC status regfield to report real charger status cy_huang
@ 2024-10-16 6:13 ` ChiYuan Huang
2024-10-16 21:41 ` Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: ChiYuan Huang @ 2024-10-16 6:13 UTC (permalink / raw)
To: Sebastian Reichel; +Cc: lucas_tsai, linux-pm, linux-kernel
On Wed, Sep 25, 2024 at 04:32:57PM +0800, cy_huang@richtek.com wrote:
> From: ChiYuan Huang <cy_huang@richtek.com>
>
> 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?
>
> 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(-)
>
> --
> 2.34.1
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status
2024-09-25 8:32 [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status cy_huang
` (2 preceding siblings ...)
2024-10-16 6:13 ` [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and " ChiYuan Huang
@ 2024-10-16 21:41 ` Sebastian Reichel
3 siblings, 0 replies; 5+ messages in thread
From: Sebastian Reichel @ 2024-10-16 21:41 UTC (permalink / raw)
To: 'Lucas Tsai ', Sebastian Reichel, cy_huang; +Cc: linux-pm, linux-kernel
On Wed, 25 Sep 2024 16:32:57 +0800, cy_huang@richtek.com wrote:
> From: ChiYuan Huang <cy_huang@richtek.com>
>
> 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: c46a9ee5c6210682611d3d4276436c23a95e1996
Best regards,
--
Sebastian Reichel <sebastian.reichel@collabora.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-10-16 21:42 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-25 8:32 [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and charger status cy_huang
2024-09-25 8:32 ` [PATCH 1/2] power: supply: rt9471: Fix wrong WDT function regfield declaration cy_huang
2024-09-25 8:32 ` [PATCH 2/2] power: supply: rt9471: Use IC status regfield to report real charger status cy_huang
2024-10-16 6:13 ` [PATCH 0/2] power: supply: rt9471: Fix WDT bitfield and " ChiYuan Huang
2024-10-16 21:41 ` Sebastian Reichel
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).