* [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
@ 2025-01-24 19:16 Rob Herring (Arm)
2025-01-24 22:08 ` Nishanth Menon
` (7 more replies)
0 siblings, 8 replies; 10+ messages in thread
From: Rob Herring (Arm) @ 2025-01-24 19:16 UTC (permalink / raw)
To: Lee Jones, Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey
Cc: Will McVicker, John Madieu, Nishanth Menon, Vaishnav Achath,
linux-kernel
Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
"syscon" compatible") broke drivers which call device_node_to_regmap()
on nodes without a "syscon" compatible. Restore the prior behavior for
device_node_to_regmap().
This also makes using device_node_to_regmap() incompatible with
of_syscon_register_regmap() again, so add kerneldoc for
device_node_to_regmap() and syscon_node_to_regmap() to make it clear
how and when each one should be used.
Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
Cc: Will McVicker <willmcvicker@google.com>
Cc: John Madieu <john.madieu.xa@bp.renesas.com>
Cc: Nishanth Menon <nm@ti.com>
Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
---
drivers/mfd/syscon.c | 29 ++++++++++++++++++++++++++---
1 file changed, 26 insertions(+), 3 deletions(-)
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 226915ca3c93..aa4a9940b569 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -159,6 +159,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
}
static struct regmap *device_node_get_regmap(struct device_node *np,
+ bool create_regmap,
bool check_res)
{
struct syscon *entry, *syscon = NULL;
@@ -172,7 +173,7 @@ static struct regmap *device_node_get_regmap(struct device_node *np,
}
if (!syscon) {
- if (of_device_is_compatible(np, "syscon"))
+ if (create_regmap)
syscon = of_syscon_register(np, check_res);
else
syscon = ERR_PTR(-EINVAL);
@@ -233,15 +234,37 @@ int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap)
}
EXPORT_SYMBOL_GPL(of_syscon_register_regmap);
+/**
+ * device_node_to_regmap() - Get or create a regmap for specified device node
+ * @np: Device tree node
+ *
+ * Get a regmap for the specified device node. If there's not an existing
+ * regmap, then one is instantiated. This function should not be used if the
+ * device node has a custom regmap driver or has resources (clocks, resets) to
+ * be managed. Use syscon_node_to_regmap() instead for those cases.
+ *
+ * Return: regmap ptr on success, negative error code on failure.
+ */
struct regmap *device_node_to_regmap(struct device_node *np)
{
- return device_node_get_regmap(np, false);
+ return device_node_get_regmap(np, true, false);
}
EXPORT_SYMBOL_GPL(device_node_to_regmap);
+/**
+ * syscon_node_to_regmap() - Get or create a regmap for specified syscon device node
+ * @np: Device tree node
+ *
+ * Get a regmap for the specified device node. If there's not an existing
+ * regmap, then one is instantiated if the node is a generic "syscon". This
+ * function is safe to use for a syscon registered with
+ * of_syscon_register_regmap().
+ *
+ * Return: regmap ptr on success, negative error code on failure.
+ */
struct regmap *syscon_node_to_regmap(struct device_node *np)
{
- return device_node_get_regmap(np, true);
+ return device_node_get_regmap(np, of_device_is_compatible(np, "syscon"), true);
}
EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
--
2.45.2
^ permalink raw reply related [flat|nested] 10+ messages in thread
* Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
@ 2025-01-24 22:08 ` Nishanth Menon
2025-01-28 22:53 ` Nícolas F. R. A. Prado
` (6 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Nishanth Menon @ 2025-01-24 22:08 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Lee Jones, Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey,
Will McVicker, John Madieu, Vaishnav Achath, linux-kernel
On 13:16-20250124, Rob Herring wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Thanks Rob.
Tested with next-20250124 on TI K3 platforms
Tested-by: Nishanth Menon <nm@ti.com>
--
Regards,
Nishanth Menon
Key (0xDDB5849D1736249D) / Fingerprint: F8A2 8693 54EB 8232 17A3 1A34 DDB5 849D 1736 249D
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
2025-01-24 22:08 ` Nishanth Menon
@ 2025-01-28 22:53 ` Nícolas F. R. A. Prado
2025-02-02 22:57 ` Daniel Golle
` (5 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Nícolas F. R. A. Prado @ 2025-01-28 22:53 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Lee Jones, Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey,
Will McVicker, John Madieu, Nishanth Menon, Vaishnav Achath,
linux-kernel
On Fri, Jan 24, 2025 at 01:16:44PM -0600, Rob Herring (Arm) wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Still hitting this as of next-20250128. This patch fixed the issue which
otherwise prevents boot on the Genio 700 EVK and Genio 1200 EVK boards.
Tested-by: Nícolas F. R. A. Prado <nfraprado@collabora.com>
Thanks,
Nícolas
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
2025-01-24 22:08 ` Nishanth Menon
2025-01-28 22:53 ` Nícolas F. R. A. Prado
@ 2025-02-02 22:57 ` Daniel Golle
2025-02-03 13:16 ` Aw: " Frank Wunderlich
2025-02-04 9:21 ` Dhruva Gole
` (4 subsequent siblings)
7 siblings, 1 reply; 10+ messages in thread
From: Daniel Golle @ 2025-02-02 22:57 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Lee Jones, Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey,
Will McVicker, John Madieu, Nishanth Menon, Vaishnav Achath,
Frank Wunderlich, Rafał Miłecki, John Crispin,
linux-kernel
On Fri, Jan 24, 2025 at 01:16:44PM -0600, Rob Herring (Arm) wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
Reviewed-by: Daniel Golle <daniel@makrotopia.org>
Texted-by: Daniel Golle <daniel@makrotopia.org>
This fix is required to un-break various Mediatek clock drivers as
device_node_to_regmap() is used all over the place there (in
reset.c, clk-gate.c, clk-cpumux.c, clk-mux.c) and commit
3ba5a6159434 ("arm64: dts: mediatek: mt7622: fix clock controllers")
has droped all those unneeded "syscon"s.
> drivers/mfd/syscon.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 226915ca3c93..aa4a9940b569 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -159,6 +159,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
> }
>
> static struct regmap *device_node_get_regmap(struct device_node *np,
> + bool create_regmap,
> bool check_res)
> {
> struct syscon *entry, *syscon = NULL;
> @@ -172,7 +173,7 @@ static struct regmap *device_node_get_regmap(struct device_node *np,
> }
>
> if (!syscon) {
> - if (of_device_is_compatible(np, "syscon"))
> + if (create_regmap)
> syscon = of_syscon_register(np, check_res);
> else
> syscon = ERR_PTR(-EINVAL);
> @@ -233,15 +234,37 @@ int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap)
> }
> EXPORT_SYMBOL_GPL(of_syscon_register_regmap);
>
> +/**
> + * device_node_to_regmap() - Get or create a regmap for specified device node
> + * @np: Device tree node
> + *
> + * Get a regmap for the specified device node. If there's not an existing
> + * regmap, then one is instantiated. This function should not be used if the
> + * device node has a custom regmap driver or has resources (clocks, resets) to
> + * be managed. Use syscon_node_to_regmap() instead for those cases.
> + *
> + * Return: regmap ptr on success, negative error code on failure.
> + */
> struct regmap *device_node_to_regmap(struct device_node *np)
> {
> - return device_node_get_regmap(np, false);
> + return device_node_get_regmap(np, true, false);
> }
> EXPORT_SYMBOL_GPL(device_node_to_regmap);
>
> +/**
> + * syscon_node_to_regmap() - Get or create a regmap for specified syscon device node
> + * @np: Device tree node
> + *
> + * Get a regmap for the specified device node. If there's not an existing
> + * regmap, then one is instantiated if the node is a generic "syscon". This
> + * function is safe to use for a syscon registered with
> + * of_syscon_register_regmap().
> + *
> + * Return: regmap ptr on success, negative error code on failure.
> + */
> struct regmap *syscon_node_to_regmap(struct device_node *np)
> {
> - return device_node_get_regmap(np, true);
> + return device_node_get_regmap(np, of_device_is_compatible(np, "syscon"), true);
> }
> EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
>
> --
> 2.45.2
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Aw: Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-02-02 22:57 ` Daniel Golle
@ 2025-02-03 13:16 ` Frank Wunderlich
0 siblings, 0 replies; 10+ messages in thread
From: Frank Wunderlich @ 2025-02-03 13:16 UTC (permalink / raw)
To: daniel, robh
Cc: lee, arnd, krzysztof.kozlowski, pankaj.dubey, willmcvicker,
john.madieu.xa, nm, vaishnav.a, rafal, john, linux-kernel
regards Frank
> Gesendet: Sonntag, 2. Februar 2025 um 23:57
> Von: "Daniel Golle" <daniel@makrotopia.org>
> Betreff: Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
>
> On Fri, Jan 24, 2025 at 01:16:44PM -0600, Rob Herring (Arm) wrote:
> > Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> > "syscon" compatible") broke drivers which call device_node_to_regmap()
> > on nodes without a "syscon" compatible. Restore the prior behavior for
> > device_node_to_regmap().
> >
> > This also makes using device_node_to_regmap() incompatible with
> > of_syscon_register_regmap() again, so add kerneldoc for
> > device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> > how and when each one should be used.
> >
> > Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> > Cc: Will McVicker <willmcvicker@google.com>
> > Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> > Cc: Nishanth Menon <nm@ti.com>
> > Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> > Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> > ---
>
> Reviewed-by: Daniel Golle <daniel@makrotopia.org>
> Texted-by: Daniel Golle <daniel@makrotopia.org>
fixing Daniels Tested-by-tag :)
Tested-by: Daniel Golle <daniel@makrotopia.org>
and confirming the patch fixes the clock-syscon-issue (on mt7988)
Tested-by: Frank Wunderlich <frank-w@public-files.de>
> This fix is required to un-break various Mediatek clock drivers as
> device_node_to_regmap() is used all over the place there (in
> reset.c, clk-gate.c, clk-cpumux.c, clk-mux.c) and commit
> 3ba5a6159434 ("arm64: dts: mediatek: mt7622: fix clock controllers")
> has droped all those unneeded "syscon"s.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
` (2 preceding siblings ...)
2025-02-02 22:57 ` Daniel Golle
@ 2025-02-04 9:21 ` Dhruva Gole
2025-02-07 9:00 ` Lee Jones
` (3 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Dhruva Gole @ 2025-02-04 9:21 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Lee Jones, Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey,
Will McVicker, John Madieu, Nishanth Menon, Vaishnav Achath,
linux-kernel
On Jan 24, 2025 at 13:16:44 -0600, Rob Herring (Arm) wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> drivers/mfd/syscon.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
Tested this for basic boot on TI K3 AM625-SK with next-20250204.
Tested-by: Dhruva Gole <d-gole@ti.com>
--
Best regards,
Dhruva Gole
Texas Instruments Incorporated
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
` (3 preceding siblings ...)
2025-02-04 9:21 ` Dhruva Gole
@ 2025-02-07 9:00 ` Lee Jones
2025-02-10 6:17 ` Chen-Yu Tsai
` (2 subsequent siblings)
7 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2025-02-07 9:00 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey, Will McVicker,
John Madieu, Nishanth Menon, Vaishnav Achath, linux-kernel
On Fri, 24 Jan 2025, Rob Herring (Arm) wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> drivers/mfd/syscon.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
NOTE TO SELF: -rcs
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
` (4 preceding siblings ...)
2025-02-07 9:00 ` Lee Jones
@ 2025-02-10 6:17 ` Chen-Yu Tsai
2025-02-11 14:50 ` AngeloGioacchino Del Regno
2025-02-11 14:54 ` (subset) " Lee Jones
7 siblings, 0 replies; 10+ messages in thread
From: Chen-Yu Tsai @ 2025-02-10 6:17 UTC (permalink / raw)
To: Rob Herring (Arm)
Cc: Lee Jones, Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey,
Will McVicker, John Madieu, Nishanth Menon, Vaishnav Achath,
linux-kernel
On Fri, Jan 24, 2025 at 01:16:44PM -0600, Rob Herring (Arm) wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Tested-by: Chen-Yu Tsai <wenst@chromium.org>
This restored the power controller and everything depending on it on the
MT8183 Chromebooks.
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
` (5 preceding siblings ...)
2025-02-10 6:17 ` Chen-Yu Tsai
@ 2025-02-11 14:50 ` AngeloGioacchino Del Regno
2025-02-11 14:54 ` (subset) " Lee Jones
7 siblings, 0 replies; 10+ messages in thread
From: AngeloGioacchino Del Regno @ 2025-02-11 14:50 UTC (permalink / raw)
To: Rob Herring (Arm), Lee Jones, Arnd Bergmann, Krzysztof Kozlowski,
Pankaj Dubey
Cc: Will McVicker, John Madieu, Nishanth Menon, Vaishnav Achath,
linux-kernel
Il 24/01/25 20:16, Rob Herring (Arm) ha scritto:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> Fixes: ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a "syscon" compatible")
> Cc: Will McVicker <willmcvicker@google.com>
> Cc: John Madieu <john.madieu.xa@bp.renesas.com>
> Cc: Nishanth Menon <nm@ti.com>
> Reported-by: Vaishnav Achath <vaishnav.a@ti.com>
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
...and tested on
Radxa NIO 12L (MT8395/8195), MediaTek Genio 700 EVK (MT8390/MT8188), and on
MT8195 Tomato Chromebook
Tested-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@collabora.com>
> ---
> drivers/mfd/syscon.c | 29 ++++++++++++++++++++++++++---
> 1 file changed, 26 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
> index 226915ca3c93..aa4a9940b569 100644
> --- a/drivers/mfd/syscon.c
> +++ b/drivers/mfd/syscon.c
> @@ -159,6 +159,7 @@ static struct syscon *of_syscon_register(struct device_node *np, bool check_res)
> }
>
> static struct regmap *device_node_get_regmap(struct device_node *np,
> + bool create_regmap,
> bool check_res)
> {
> struct syscon *entry, *syscon = NULL;
> @@ -172,7 +173,7 @@ static struct regmap *device_node_get_regmap(struct device_node *np,
> }
>
> if (!syscon) {
> - if (of_device_is_compatible(np, "syscon"))
> + if (create_regmap)
> syscon = of_syscon_register(np, check_res);
> else
> syscon = ERR_PTR(-EINVAL);
> @@ -233,15 +234,37 @@ int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap)
> }
> EXPORT_SYMBOL_GPL(of_syscon_register_regmap);
>
> +/**
> + * device_node_to_regmap() - Get or create a regmap for specified device node
> + * @np: Device tree node
> + *
> + * Get a regmap for the specified device node. If there's not an existing
> + * regmap, then one is instantiated. This function should not be used if the
> + * device node has a custom regmap driver or has resources (clocks, resets) to
> + * be managed. Use syscon_node_to_regmap() instead for those cases.
> + *
> + * Return: regmap ptr on success, negative error code on failure.
> + */
> struct regmap *device_node_to_regmap(struct device_node *np)
> {
> - return device_node_get_regmap(np, false);
> + return device_node_get_regmap(np, true, false);
> }
> EXPORT_SYMBOL_GPL(device_node_to_regmap);
>
> +/**
> + * syscon_node_to_regmap() - Get or create a regmap for specified syscon device node
> + * @np: Device tree node
> + *
> + * Get a regmap for the specified device node. If there's not an existing
> + * regmap, then one is instantiated if the node is a generic "syscon". This
> + * function is safe to use for a syscon registered with
> + * of_syscon_register_regmap().
> + *
> + * Return: regmap ptr on success, negative error code on failure.
> + */
> struct regmap *syscon_node_to_regmap(struct device_node *np)
> {
> - return device_node_get_regmap(np, true);
> + return device_node_get_regmap(np, of_device_is_compatible(np, "syscon"), true);
> }
> EXPORT_SYMBOL_GPL(syscon_node_to_regmap);
>
^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: (subset) [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
` (6 preceding siblings ...)
2025-02-11 14:50 ` AngeloGioacchino Del Regno
@ 2025-02-11 14:54 ` Lee Jones
7 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2025-02-11 14:54 UTC (permalink / raw)
To: Lee Jones, Arnd Bergmann, Krzysztof Kozlowski, Pankaj Dubey,
Rob Herring (Arm)
Cc: Will McVicker, John Madieu, Nishanth Menon, Vaishnav Achath,
linux-kernel
On Fri, 24 Jan 2025 13:16:44 -0600, Rob Herring (Arm) wrote:
> Commit ba5095ebbc7a ("mfd: syscon: Allow syscon nodes without a
> "syscon" compatible") broke drivers which call device_node_to_regmap()
> on nodes without a "syscon" compatible. Restore the prior behavior for
> device_node_to_regmap().
>
> This also makes using device_node_to_regmap() incompatible with
> of_syscon_register_regmap() again, so add kerneldoc for
> device_node_to_regmap() and syscon_node_to_regmap() to make it clear
> how and when each one should be used.
>
> [...]
Applied, thanks!
[1/1] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes
commit: 5728c92ae112301936006c5e305677beb1a7f578
--
Lee Jones [李琼斯]
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2025-02-11 14:54 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-24 19:16 [PATCH] mfd: syscon: Restore device_node_to_regmap() for non-syscon nodes Rob Herring (Arm)
2025-01-24 22:08 ` Nishanth Menon
2025-01-28 22:53 ` Nícolas F. R. A. Prado
2025-02-02 22:57 ` Daniel Golle
2025-02-03 13:16 ` Aw: " Frank Wunderlich
2025-02-04 9:21 ` Dhruva Gole
2025-02-07 9:00 ` Lee Jones
2025-02-10 6:17 ` Chen-Yu Tsai
2025-02-11 14:50 ` AngeloGioacchino Del Regno
2025-02-11 14:54 ` (subset) " Lee Jones
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox