mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/2] regulator: fp9931: fix voltage mapping and runtime PM issues
@ 2026-07-21  9:59 robby.cai
  2026-07-21  9:59 ` [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table robby.cai
  2026-07-21  9:59 ` [PATCH 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops robby.cai
  0 siblings, 2 replies; 5+ messages in thread
From: robby.cai @ 2026-07-21  9:59 UTC (permalink / raw)
  To: lgirdwood, broonie, andreas; +Cc: linux-kernel, imx

From: Robby Cai <robby.cai@nxp.com>

Hi,

This series fixes two issues in the FP9931/JD9930 regulator driver.

Patch 1 fixes an off-by-one error in the VPOS/VNEG voltage selector
table and aligns it with the datasheet-defined voltage mapping [1].

Patch 2 fixes a Runtime PM reference counting bug in the V3P3 regulator
callbacks that can lead to "Runtime PM usage count underflow!" warnings.

Thanks,
Robby

[1] https://www.fitipower.com/dl/file/flXa6hIchVeu0W3K (Datasheet, p.13)


Robby Cai (2):
  regulator: fp9931: Fix VPOS/VNEG voltage selector table
  regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops

 drivers/regulator/fp9931.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table
  2026-07-21  9:59 [PATCH 0/2] regulator: fp9931: fix voltage mapping and runtime PM issues robby.cai
@ 2026-07-21  9:59 ` robby.cai
  2026-07-27 20:04   ` Andreas Kemnade
  2026-07-21  9:59 ` [PATCH 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops robby.cai
  1 sibling, 1 reply; 5+ messages in thread
From: robby.cai @ 2026-07-21  9:59 UTC (permalink / raw)
  To: lgirdwood, broonie, andreas; +Cc: linux-kernel, imx

From: Robby Cai <robby.cai@nxp.com>

The VPOSNEG_table[] mapping does not match the FP9931/JD9930 datasheet.

The datasheet defines the VPOS/VNEG voltage mapping as:

  00h-04h ->  7.04V (-7.04V)
  05h     ->  7.26V (-7.26V)
  06h     ->  7.49V (-7.49V)
  ...
  28h-3Fh -> 15.06V (-15.06V)

However, the current table maps selector 0x05 to 7.04V instead of
7.26V, causing all subsequent entries to be shifted by one position.

Update VPOSNEG_table[] to match the documented register encoding.

Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
Signed-off-by: Robby Cai <robby.cai@nxp.com>
---
 drivers/regulator/fp9931.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/regulator/fp9931.c b/drivers/regulator/fp9931.c
index 002b41f53eff..5eee21034f6b 100644
--- a/drivers/regulator/fp9931.c
+++ b/drivers/regulator/fp9931.c
@@ -42,7 +42,6 @@ static const unsigned int VPOSNEG_table[] = {
 	7040000,
 	7040000,
 	7040000,
-	7040000,
 	7260000,
 	7490000,
 	7710000,
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops
  2026-07-21  9:59 [PATCH 0/2] regulator: fp9931: fix voltage mapping and runtime PM issues robby.cai
  2026-07-21  9:59 ` [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table robby.cai
@ 2026-07-21  9:59 ` robby.cai
  1 sibling, 0 replies; 5+ messages in thread
From: robby.cai @ 2026-07-21  9:59 UTC (permalink / raw)
  To: lgirdwood, broonie, andreas; +Cc: linux-kernel, imx

From: Robby Cai <robby.cai@nxp.com>

The fp9931_v3p3_enable() and fp9931_v3p3_disable() callbacks currently
acquire a Runtime PM reference when V3P3 is enabled and release it when
V3P3 is disabled.

This assumes that Runtime PM references remain associated with the V3P3
regulator state. However, FP9931 regulators share common device-level
Runtime PM state and references may be released through other regulator
paths, such as the VCOM control path. In addition, the regulator
framework may invoke disable callbacks during cleanup even when no
corresponding enable callback was executed.

As a result, fp9931_v3p3_disable() may call pm_runtime_put_autosuspend()
when the device runtime PM usage count has already reached 0, triggering:

  fp9931 1-0018: Runtime PM usage count underflow!

Fix this by scoping the Runtime PM reference lifetime to the register
access itself, pairing pm_runtime_resume_and_get() and
pm_runtime_put_autosuspend() within each callback.

Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
Signed-off-by: Robby Cai <robby.cai@nxp.com>
---
 drivers/regulator/fp9931.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/regulator/fp9931.c b/drivers/regulator/fp9931.c
index 5eee21034f6b..3ffba6fb75ff 100644
--- a/drivers/regulator/fp9931.c
+++ b/drivers/regulator/fp9931.c
@@ -243,8 +243,7 @@ static int fp9931_v3p3_enable(struct regulator_dev *rdev)
 		return ret;
 
 	ret = regulator_enable_regmap(rdev);
-	if (ret < 0)
-		pm_runtime_put_autosuspend(data->dev);
+	pm_runtime_put_autosuspend(data->dev);
 
 	return ret;
 }
@@ -254,6 +253,10 @@ static int fp9931_v3p3_disable(struct regulator_dev *rdev)
 	struct fp9931_data *data = rdev_get_drvdata(rdev);
 	int ret;
 
+	ret = pm_runtime_resume_and_get(data->dev);
+	if (ret < 0)
+		return ret;
+
 	ret = regulator_disable_regmap(rdev);
 	pm_runtime_put_autosuspend(data->dev);
 
-- 
2.50.1


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table
  2026-07-21  9:59 ` [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table robby.cai
@ 2026-07-27 20:04   ` Andreas Kemnade
  2026-07-31  8:42     ` Robby Cai (OSS)
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Kemnade @ 2026-07-27 20:04 UTC (permalink / raw)
  To: robby.cai; +Cc: lgirdwood, broonie, linux-kernel, imx

On Tue, 21 Jul 2026 17:59:58 +0800
robby.cai@oss.nxp.com wrote:

> From: Robby Cai <robby.cai@nxp.com>
> 
> The VPOSNEG_table[] mapping does not match the FP9931/JD9930
> datasheet.
> 
> The datasheet defines the VPOS/VNEG voltage mapping as:
> 
>   00h-04h ->  7.04V (-7.04V)
>   05h     ->  7.26V (-7.26V)
>   06h     ->  7.49V (-7.49V)
>   ...
>   28h-3Fh -> 15.06V (-15.06V)
> 
> However, the current table maps selector 0x05 to 7.04V instead of
> 7.26V, causing all subsequent entries to be shifted by one position.
> 
> Update VPOSNEG_table[] to match the documented register encoding.
> 
> Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
> Signed-off-by: Robby Cai <robby.cai@nxp.com>

Reviewed-by: Andreas Kemnade <andreas@kemnade.info>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table
  2026-07-27 20:04   ` Andreas Kemnade
@ 2026-07-31  8:42     ` Robby Cai (OSS)
  0 siblings, 0 replies; 5+ messages in thread
From: Robby Cai (OSS) @ 2026-07-31  8:42 UTC (permalink / raw)
  To: Andreas Kemnade; +Cc: lgirdwood, broonie, linux-kernel, imx



>-----Original Message-----
>From: Andreas Kemnade <andreas@kemnade.info>
>Sent: Tuesday, July 28, 2026 4:05 AM
>To: Robby Cai (OSS) <robby.cai@oss.nxp.com>
>Cc: lgirdwood@gmail.com; broonie@kernel.org; linux-kernel@vger.kernel.org;
>imx@lists.linux.dev
>Subject: Re: [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector
>table
>
>On Tue, 21 Jul 2026 17:59:58 +0800
>robby.cai@oss.nxp.com wrote:
>
>> From: Robby Cai <robby.cai@nxp.com>
>>
>> The VPOSNEG_table[] mapping does not match the FP9931/JD9930
>> datasheet.
>>
>> The datasheet defines the VPOS/VNEG voltage mapping as:
>>
>>   00h-04h ->  7.04V (-7.04V)
>>   05h     ->  7.26V (-7.26V)
>>   06h     ->  7.49V (-7.49V)
>>   ...
>>   28h-3Fh -> 15.06V (-15.06V)
>>
>> However, the current table maps selector 0x05 to 7.04V instead of
>> 7.26V, causing all subsequent entries to be shifted by one position.
>>
>> Update VPOSNEG_table[] to match the documented register encoding.
>>
>> Fixes: 12d821bd13d4 ("regulator: Add FP9931/JD9930 driver")
>> Signed-off-by: Robby Cai <robby.cai@nxp.com>
>
>Reviewed-by: Andreas Kemnade <andreas@kemnade.info>

Thanks for the review.

Just a note that there is a v2 available: 
https://lore.kernel.org/imx/20260724103441.800522-2-robby.cai@oss.nxp.com/

Compared to v1, the table has been updated to cover the full selector range defined by the datasheet. In particular, selectors 0x29-0x3f are now clamped to 15.06V, matching the hardware definition.
The main issue fixed by v1 remains the same, but v2 also ensures the voltage table correctly represents all valid selector values.

Regards,
Robby

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-31  8:42 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-21  9:59 [PATCH 0/2] regulator: fp9931: fix voltage mapping and runtime PM issues robby.cai
2026-07-21  9:59 ` [PATCH 1/2] regulator: fp9931: Fix VPOS/VNEG voltage selector table robby.cai
2026-07-27 20:04   ` Andreas Kemnade
2026-07-31  8:42     ` Robby Cai (OSS)
2026-07-21  9:59 ` [PATCH 2/2] regulator: fp9931: Fix Runtime PM usage count underflow in v3p3 ops robby.cai

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®