linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 0/2] Add syscon of_syscon_register_regmap api
@ 2024-06-21 11:55 Peter Griffin
  2024-06-21 11:55 ` [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API Peter Griffin
                   ` (4 more replies)
  0 siblings, 5 replies; 10+ messages in thread
From: Peter Griffin @ 2024-06-21 11:55 UTC (permalink / raw)
  To: lee, arnd, krzk, alim.akhtar
  Cc: linux-arm-kernel, linux-samsung-soc, linux-kernel, tudor.ambarus,
	andre.draszik, saravanak, willmcvicker, semen.protsenko,
	kernel-team, Peter Griffin

Hi Lee, Arnd, Krzysztof, all,

This series adds support to syscon driver for a new of_syscon_register_regmap()
api.

Platforms such as gs101 require a special regmap to access PMU registers, which
in the existing upstream client drivers are accessed via syscon regmap. This
issue was partly solved in [1] whereby a custom regmap is created in exynos-pmu
and a new API exynos_get_pmu_regmap_by_phandle() created.

One issue with the approach in [1] is that it required client drivers to be
updated from syscon_regmap_lookup_by_phandle() to
exynos_get_pmu_regmap_by_phandle() when obtaining the regmap.

Whilst updating to exynos_get_pmu_regmap_by_phandle() was OK for exynos
specific drivers, it meant other drivers like syscon-reboot and syscon-poweroff
which span multiple SoC architectures could not be easily re-used.

In previous review feedback for USB phy and gs101 poweroff driver Krzysztof
requested [2] that we take a more generic approach that other SoCs can also
leverage.

The new of_syscon_register_regmap() api overcomes this limitation by allowing
a SoC driver like exynos-pmu to register it's SoC specific regmap with the
syscon driver. This keeps the SoC complexity out of syscon driver, and allows
client drivers to continue using syscon_regmap_lookup_by_phandle() as before.
The solution allows more code re-use and can be used by other SoC archs.

Notes on probe ordering

exynos-pmu runs at postcore_initcall, so all but one of the client drivers
(ufs phy, usb phy, watchdog) run after the regmap is created and registered.

The one exception to this is pinctrl-samsung driver which is also
postcore_initcall level. The exynos_get_pmu_regmap() and
exynos_get_pmu_regmap_by_phandle() have been temporarily left to support
-EPROBE_DEFER for pinctrl-samsung driver.

The longer term plan to solve that probe ordering issue is to enable
fw_devlink for syscon dt properties so they are correctly listed as
suppliers in /sys/class/devlink. I tested a PoC patch (see below) for
fw_devlink and that seemed to work fine. Once fw_devlink supports syscon I
believe exynos_get_pmu_regmap_by_phandle() api could be removed. The main issue
currently with fw_devlink syscon support is the wide diversity of dt property
naming currently in use. That was discussed previously here [3]

1248a1256,1257
> DEFINE_SUFFIX_PROP(syscon_phandle, "syscon-phandle", NULL)
> DEFINE_SUFFIX_PROP(pmu_syscon, "pmu-syscon", NULL)
1358a1368,1369
>     { .parse_prop = parse_syscon_phandle, },
>     { .parse_prop = parse_pmu_syscon, },


Note one previous concern from Saravana about syscon potentially probing
before exynos-pmu driver and it relying on drivers/Makefile ordering. I tested
this and even if mfd is listed before soc in drivers/Makefile exynos-pmu
always probes first due to syscon driver not setting a .of_match_table entry.

Once the syscon and exynos-pmu patchs are queued I will send patches for
watchdog and ufs phy drivers to switch back to syscon_regmap_lookup_by_phandle()

Many thanks,

Peter.

[1] https://lore.kernel.org/linux-arm-kernel/20240219204238.356942-1-peter.griffin@linaro.org/T/
[2] https://lore.kernel.org/lkml/06383015-51b2-4f4c-9fd8-e4f7ce12f44e@kernel.org/
[3] https://lore.kernel.org/all/CAGETcx-CCpaV7R0O0HpDpoX6KxQBuJiMmKdWA8nDE-5Qj2Sa7g@mail.gmail.com/

Changes since v2:
 - Move allocation outside spinlock area (Arnd)
Link to v2:
 - https://lore.kernel.org/linux-arm-kernel/20240620112446.1286223-1-peter.griffin@linaro.org/

Changes since v1:
 - Collect by tags
 - Keep syscon lock held for check and adding entry (Krzysztof)
 - pass pmu_np not np to syscon_node_to_regmap() (William)

Link to v1:
 - https://lore.kernel.org/linux-arm-kernel/20240614140421.3172674-1-peter.griffin@linaro.org/

Peter Griffin (2):
  mfd: syscon: add of_syscon_register_regmap() API
  soc: samsung: exynos-pmu: update to use of_syscon_register_regmap()

 drivers/mfd/syscon.c             | 48 ++++++++++++++++++++++++++++++++
 drivers/soc/samsung/exynos-pmu.c | 38 ++++++++++---------------
 include/linux/mfd/syscon.h       |  8 ++++++
 3 files changed, 70 insertions(+), 24 deletions(-)

-- 
2.45.2.741.gdbec12cfda-goog



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

* [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API
  2024-06-21 11:55 [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Peter Griffin
@ 2024-06-21 11:55 ` Peter Griffin
  2024-06-21 23:56   ` William McVicker
  2024-06-24  5:57   ` Krzysztof Kozlowski
  2024-06-21 11:55 ` [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap() Peter Griffin
                   ` (3 subsequent siblings)
  4 siblings, 2 replies; 10+ messages in thread
From: Peter Griffin @ 2024-06-21 11:55 UTC (permalink / raw)
  To: lee, arnd, krzk, alim.akhtar
  Cc: linux-arm-kernel, linux-samsung-soc, linux-kernel, tudor.ambarus,
	andre.draszik, saravanak, willmcvicker, semen.protsenko,
	kernel-team, Peter Griffin

The of_syscon_register_regmap() API allows an externally created regmap
to be registered with syscon. This regmap can then be returned to client
drivers using the syscon_regmap_lookup_by_phandle() APIs.

The API is used by platforms where mmio access to the syscon registers is
not possible, and a underlying soc driver like exynos-pmu provides a SoC
specific regmap that can issue a SMC or hypervisor call to write the
register.

This approach keeps the SoC complexities out of syscon, but allows common
drivers such as  syscon-poweroff, syscon-reboot and friends that are used
by many SoCs already to be re-used.

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v3:
- Move kzalloc allocation outside of spin lock (Arnd)
- Link to v2 https://lore.kernel.org/linux-arm-kernel/20240620112446.1286223-2-peter.griffin@linaro.org/

Changes in v2:
- Keep syscon lock held between checking and adding entry (Krzysztof)
- Link to v1 https://lore.kernel.org/linux-arm-kernel/20240614140421.3172674-2-peter.griffin@linaro.org/
---
 drivers/mfd/syscon.c       | 48 ++++++++++++++++++++++++++++++++++++++
 include/linux/mfd/syscon.h |  8 +++++++
 2 files changed, 56 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 7d0e91164cba..33f1e07ab24d 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -192,6 +192,54 @@ static struct regmap *device_node_get_regmap(struct device_node *np,
 	return syscon->regmap;
 }
 
+/**
+ * of_syscon_register_regmap() - Register regmap for specified device node
+ * @np: Device tree node
+ * @regmap: Pointer to regmap object
+ *
+ * Register an externally created regmap object with syscon for the specified
+ * device tree node. This regmap will then be returned to client drivers using
+ * the syscon_regmap_lookup_by_phandle() API.
+ *
+ * Return: 0 on success, negative error code on failure.
+ */
+int of_syscon_register_regmap(struct device_node *np, struct regmap *regmap)
+{
+	struct syscon *entry, *syscon = NULL;
+	int ret;
+
+	if (!np || !regmap)
+		return -EINVAL;
+
+	syscon = kzalloc(sizeof(*syscon), GFP_KERNEL);
+	if (!syscon)
+		return -ENOMEM;
+
+	/* check if syscon entry already exists */
+	spin_lock(&syscon_list_slock);
+
+	list_for_each_entry(entry, &syscon_list, list)
+		if (entry->np == np) {
+			ret = -EEXIST;
+			goto err_unlock;
+		}
+
+	syscon->regmap = regmap;
+	syscon->np = np;
+
+	/* register the regmap in syscon list */
+	list_add_tail(&syscon->list, &syscon_list);
+	spin_unlock(&syscon_list_slock);
+
+	return 0;
+
+err_unlock:
+	spin_unlock(&syscon_list_slock);
+	kfree(syscon);
+	return ret;
+}
+EXPORT_SYMBOL_GPL(of_syscon_register_regmap);
+
 struct regmap *device_node_to_regmap(struct device_node *np)
 {
 	return device_node_get_regmap(np, false);
diff --git a/include/linux/mfd/syscon.h b/include/linux/mfd/syscon.h
index c315903f6dab..aad9c6b50463 100644
--- a/include/linux/mfd/syscon.h
+++ b/include/linux/mfd/syscon.h
@@ -28,6 +28,8 @@ struct regmap *syscon_regmap_lookup_by_phandle_args(struct device_node *np,
 						    unsigned int *out_args);
 struct regmap *syscon_regmap_lookup_by_phandle_optional(struct device_node *np,
 							const char *property);
+int of_syscon_register_regmap(struct device_node *np,
+			      struct regmap *regmap);
 #else
 static inline struct regmap *device_node_to_regmap(struct device_node *np)
 {
@@ -67,6 +69,12 @@ static inline struct regmap *syscon_regmap_lookup_by_phandle_optional(
 	return NULL;
 }
 
+static inline int of_syscon_register_regmap(struct device_node *np,
+					struct regmap *regmap)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif
 
 #endif /* __LINUX_MFD_SYSCON_H__ */
-- 
2.45.2.741.gdbec12cfda-goog



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

* [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap()
  2024-06-21 11:55 [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Peter Griffin
  2024-06-21 11:55 ` [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API Peter Griffin
@ 2024-06-21 11:55 ` Peter Griffin
  2024-06-21 23:57   ` William McVicker
  2024-06-24  5:58   ` Krzysztof Kozlowski
  2024-06-21 14:54 ` [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Arnd Bergmann
                   ` (2 subsequent siblings)
  4 siblings, 2 replies; 10+ messages in thread
From: Peter Griffin @ 2024-06-21 11:55 UTC (permalink / raw)
  To: lee, arnd, krzk, alim.akhtar
  Cc: linux-arm-kernel, linux-samsung-soc, linux-kernel, tudor.ambarus,
	andre.draszik, saravanak, willmcvicker, semen.protsenko,
	kernel-team, Peter Griffin

For SoCs like gs101 that need a special regmap, register this with
of_syscon_register_regmap api, so it can be returned by
syscon_regmap_lookup_by_phandle() and friends.

For SoCs that don't require a custom regmap, revert back to syscon
creating the mmio regmap rather than duplicating the logic here.

exynos_get_pmu_regmap_by_phandle() api is also updated to retrieve
the regmap via syscon. The exynos_get_pmu_regmap_by_phandle() api
is kept around until fw_devlink support for syscon property is added
for the pinctrl-samsung driver that also runs at postcore_initcall
level.

All other exynos client drivers can revert back to
syscon_regmap_lookup_by_phandle().

Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
Reviewed-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
---
Changes in v2:
 - None
 - Link to v2: https://lore.kernel.org/linux-arm-kernel/20240620112446.1286223-3-peter.griffin@linaro.org/

Changes since v1:
 - pass pmu_np (not np) to syscon_node_to_regmap() (reported by William)
 - Link to v1: https://lore.kernel.org/linux-arm-kernel/20240614140421.3172674-3-peter.griffin@linaro.org/
---
 drivers/soc/samsung/exynos-pmu.c | 38 ++++++++++++--------------------
 1 file changed, 14 insertions(+), 24 deletions(-)

diff --git a/drivers/soc/samsung/exynos-pmu.c b/drivers/soc/samsung/exynos-pmu.c
index fd8b6ac06656..624324f4001c 100644
--- a/drivers/soc/samsung/exynos-pmu.c
+++ b/drivers/soc/samsung/exynos-pmu.c
@@ -204,16 +204,6 @@ static const struct regmap_config regmap_smccfg = {
 	.reg_update_bits = tensor_sec_update_bits,
 };
 
-static const struct regmap_config regmap_mmiocfg = {
-	.name = "pmu_regs",
-	.reg_bits = 32,
-	.reg_stride = 4,
-	.val_bits = 32,
-	.fast_io = true,
-	.use_single_read = true,
-	.use_single_write = true,
-};
-
 static const struct exynos_pmu_data gs101_pmu_data = {
 	.pmu_secure = true
 };
@@ -290,7 +280,6 @@ EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap);
 struct regmap *exynos_get_pmu_regmap_by_phandle(struct device_node *np,
 						const char *propname)
 {
-	struct exynos_pmu_context *ctx;
 	struct device_node *pmu_np;
 	struct device *dev;
 
@@ -316,9 +305,7 @@ struct regmap *exynos_get_pmu_regmap_by_phandle(struct device_node *np,
 	if (!dev)
 		return ERR_PTR(-EPROBE_DEFER);
 
-	ctx = dev_get_drvdata(dev);
-
-	return ctx->pmureg;
+	return syscon_node_to_regmap(pmu_np);
 }
 EXPORT_SYMBOL_GPL(exynos_get_pmu_regmap_by_phandle);
 
@@ -355,19 +342,22 @@ static int exynos_pmu_probe(struct platform_device *pdev)
 		regmap = devm_regmap_init(dev, NULL,
 					  (void *)(uintptr_t)res->start,
 					  &pmu_regmcfg);
+
+		if (IS_ERR(regmap))
+			return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
+					     "regmap init failed\n");
+
+		ret = of_syscon_register_regmap(dev->of_node, regmap);
+		if (ret)
+			return ret;
 	} else {
-		/* All other SoCs use a MMIO regmap */
-		pmu_regmcfg = regmap_mmiocfg;
-		pmu_regmcfg.max_register = resource_size(res) -
-					   pmu_regmcfg.reg_stride;
-		regmap = devm_regmap_init_mmio(dev, pmu_base_addr,
-					       &pmu_regmcfg);
+		/* let syscon create mmio regmap */
+		regmap = syscon_node_to_regmap(dev->of_node);
+		if (IS_ERR(regmap))
+			return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
+					     "syscon_node_to_regmap failed\n");
 	}
 
-	if (IS_ERR(regmap))
-		return dev_err_probe(&pdev->dev, PTR_ERR(regmap),
-				     "regmap init failed\n");
-
 	pmu_context->pmureg = regmap;
 	pmu_context->dev = dev;
 
-- 
2.45.2.741.gdbec12cfda-goog



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

* Re: [PATCH v3 0/2] Add syscon of_syscon_register_regmap api
  2024-06-21 11:55 [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Peter Griffin
  2024-06-21 11:55 ` [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API Peter Griffin
  2024-06-21 11:55 ` [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap() Peter Griffin
@ 2024-06-21 14:54 ` Arnd Bergmann
  2024-06-26 15:48 ` Lee Jones
  2024-06-28 14:26 ` [GIT PULL] Immutable branch between MFD and SoC Samsung due for the v6.11 merge window Lee Jones
  4 siblings, 0 replies; 10+ messages in thread
From: Arnd Bergmann @ 2024-06-21 14:54 UTC (permalink / raw)
  To: Peter Griffin, Lee Jones, Krzysztof Kozlowski, Alim Akhtar
  Cc: linux-arm-kernel, linux-samsung-soc, linux-kernel, Tudor Ambarus,
	André Draszik, Saravana Kannan, William McVicker,
	Sam Protsenko, kernel-team

On Fri, Jun 21, 2024, at 11:55, Peter Griffin wrote:

> Changes since v2:
>  - Move allocation outside spinlock area (Arnd)
> Link to v2:

Looks good to me now.

      Arnd


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

* Re: [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API
  2024-06-21 11:55 ` [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API Peter Griffin
@ 2024-06-21 23:56   ` William McVicker
  2024-06-24  5:57   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 10+ messages in thread
From: William McVicker @ 2024-06-21 23:56 UTC (permalink / raw)
  To: Peter Griffin
  Cc: lee, arnd, krzk, alim.akhtar, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, tudor.ambarus, andre.draszik, saravanak,
	semen.protsenko, kernel-team

On 06/21/2024, Peter Griffin wrote:
> The of_syscon_register_regmap() API allows an externally created regmap
> to be registered with syscon. This regmap can then be returned to client
> drivers using the syscon_regmap_lookup_by_phandle() APIs.
> 
> The API is used by platforms where mmio access to the syscon registers is
> not possible, and a underlying soc driver like exynos-pmu provides a SoC
> specific regmap that can issue a SMC or hypervisor call to write the
> register.
> 
> This approach keeps the SoC complexities out of syscon, but allows common
> drivers such as  syscon-poweroff, syscon-reboot and friends that are used
> by many SoCs already to be re-used.
> 
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

Tested-by: Will McVicker <willmcvicker@google.com>

[...]

Thanks Peter! I've tested the patch series on my Pixel 6 Pro and all is working
well. I verified all the modularized drivers load and probe successfully:

root@google-gs:~# lsmod
Module                  Size  Used by
at24                   24576  0
dwc3_exynos            12288  0
i2c_exynos5            28672  0
phy_exynos_ufs         20480  1
ufs_exynos             32768  0
phy_exynos5_usbdrd     36864  2
s3c2410_wdt            24576  0
arm_dsu_pmu            24576  0

Thanks,
Will


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

* Re: [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap()
  2024-06-21 11:55 ` [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap() Peter Griffin
@ 2024-06-21 23:57   ` William McVicker
  2024-06-24  5:58   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 10+ messages in thread
From: William McVicker @ 2024-06-21 23:57 UTC (permalink / raw)
  To: Peter Griffin
  Cc: lee, arnd, krzk, alim.akhtar, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, tudor.ambarus, andre.draszik, saravanak,
	semen.protsenko, kernel-team

On 06/21/2024, Peter Griffin wrote:
> For SoCs like gs101 that need a special regmap, register this with
> of_syscon_register_regmap api, so it can be returned by
> syscon_regmap_lookup_by_phandle() and friends.
> 
> For SoCs that don't require a custom regmap, revert back to syscon
> creating the mmio regmap rather than duplicating the logic here.
> 
> exynos_get_pmu_regmap_by_phandle() api is also updated to retrieve
> the regmap via syscon. The exynos_get_pmu_regmap_by_phandle() api
> is kept around until fw_devlink support for syscon property is added
> for the pinctrl-samsung driver that also runs at postcore_initcall
> level.
> 
> All other exynos client drivers can revert back to
> syscon_regmap_lookup_by_phandle().
> 
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

Tested-by: Will McVicker <willmcvicker@google.com>

[...]

(Testing details in patch 1)

Thanks,
Will


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

* Re: [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API
  2024-06-21 11:55 ` [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API Peter Griffin
  2024-06-21 23:56   ` William McVicker
@ 2024-06-24  5:57   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-24  5:57 UTC (permalink / raw)
  To: Peter Griffin, lee, arnd, alim.akhtar
  Cc: linux-arm-kernel, linux-samsung-soc, linux-kernel, tudor.ambarus,
	andre.draszik, saravanak, willmcvicker, semen.protsenko,
	kernel-team

On 21/06/2024 13:55, Peter Griffin wrote:
> The of_syscon_register_regmap() API allows an externally created regmap
> to be registered with syscon. This regmap can then be returned to client
> drivers using the syscon_regmap_lookup_by_phandle() APIs.
> 
> The API is used by platforms where mmio access to the syscon registers is
> not possible, and a underlying soc driver like exynos-pmu provides a SoC
> specific regmap that can issue a SMC or hypervisor call to write the
> register.
> 
> This approach keeps the SoC complexities out of syscon, but allows common
> drivers such as  syscon-poweroff, syscon-reboot and friends that are used
> by many SoCs already to be re-used.
> 
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>


Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Lee,

The second patch is for Samsung SoC but it depends on this one. I do not
see any conflicting work, so you could take both via MFD tree, but just
in case, could you keep both on a separate patchset? That way I could
still pull it if there are more patches coming.

Best regards,
Krzysztof



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

* Re: [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap()
  2024-06-21 11:55 ` [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap() Peter Griffin
  2024-06-21 23:57   ` William McVicker
@ 2024-06-24  5:58   ` Krzysztof Kozlowski
  1 sibling, 0 replies; 10+ messages in thread
From: Krzysztof Kozlowski @ 2024-06-24  5:58 UTC (permalink / raw)
  To: Peter Griffin, lee, arnd, alim.akhtar
  Cc: linux-arm-kernel, linux-samsung-soc, linux-kernel, tudor.ambarus,
	andre.draszik, saravanak, willmcvicker, semen.protsenko,
	kernel-team

On 21/06/2024 13:55, Peter Griffin wrote:
> For SoCs like gs101 that need a special regmap, register this with
> of_syscon_register_regmap api, so it can be returned by
> syscon_regmap_lookup_by_phandle() and friends.
> 
> For SoCs that don't require a custom regmap, revert back to syscon
> creating the mmio regmap rather than duplicating the logic here.
> 
> exynos_get_pmu_regmap_by_phandle() api is also updated to retrieve
> the regmap via syscon. The exynos_get_pmu_regmap_by_phandle() api
> is kept around until fw_devlink support for syscon property is added
> for the pinctrl-samsung driver that also runs at postcore_initcall
> level.
> 
> All other exynos client drivers can revert back to
> syscon_regmap_lookup_by_phandle().
> 
> Signed-off-by: Peter Griffin <peter.griffin@linaro.org>
> Reviewed-by: Arnd Bergmann <arnd@arndb.de>
> Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>

For Lee/MFD:

Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>

Best regards,
Krzysztof



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

* Re: [PATCH v3 0/2] Add syscon of_syscon_register_regmap api
  2024-06-21 11:55 [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Peter Griffin
                   ` (2 preceding siblings ...)
  2024-06-21 14:54 ` [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Arnd Bergmann
@ 2024-06-26 15:48 ` Lee Jones
  2024-06-28 14:26 ` [GIT PULL] Immutable branch between MFD and SoC Samsung due for the v6.11 merge window Lee Jones
  4 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2024-06-26 15:48 UTC (permalink / raw)
  To: Peter Griffin
  Cc: arnd, krzk, alim.akhtar, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, tudor.ambarus, andre.draszik, saravanak,
	willmcvicker, semen.protsenko, kernel-team

On Fri, 21 Jun 2024, Peter Griffin wrote:

> Hi Lee, Arnd, Krzysztof, all,
> 
> This series adds support to syscon driver for a new of_syscon_register_regmap()
> api.
> 
> Platforms such as gs101 require a special regmap to access PMU registers, which
> in the existing upstream client drivers are accessed via syscon regmap. This
> issue was partly solved in [1] whereby a custom regmap is created in exynos-pmu
> and a new API exynos_get_pmu_regmap_by_phandle() created.
> 
> One issue with the approach in [1] is that it required client drivers to be
> updated from syscon_regmap_lookup_by_phandle() to
> exynos_get_pmu_regmap_by_phandle() when obtaining the regmap.
> 
> Whilst updating to exynos_get_pmu_regmap_by_phandle() was OK for exynos
> specific drivers, it meant other drivers like syscon-reboot and syscon-poweroff
> which span multiple SoC architectures could not be easily re-used.
> 
> In previous review feedback for USB phy and gs101 poweroff driver Krzysztof
> requested [2] that we take a more generic approach that other SoCs can also
> leverage.
> 
> The new of_syscon_register_regmap() api overcomes this limitation by allowing
> a SoC driver like exynos-pmu to register it's SoC specific regmap with the
> syscon driver. This keeps the SoC complexity out of syscon driver, and allows
> client drivers to continue using syscon_regmap_lookup_by_phandle() as before.
> The solution allows more code re-use and can be used by other SoC archs.
> 
> Notes on probe ordering
> 
> exynos-pmu runs at postcore_initcall, so all but one of the client drivers
> (ufs phy, usb phy, watchdog) run after the regmap is created and registered.
> 
> The one exception to this is pinctrl-samsung driver which is also
> postcore_initcall level. The exynos_get_pmu_regmap() and
> exynos_get_pmu_regmap_by_phandle() have been temporarily left to support
> -EPROBE_DEFER for pinctrl-samsung driver.
> 
> The longer term plan to solve that probe ordering issue is to enable
> fw_devlink for syscon dt properties so they are correctly listed as
> suppliers in /sys/class/devlink. I tested a PoC patch (see below) for
> fw_devlink and that seemed to work fine. Once fw_devlink supports syscon I
> believe exynos_get_pmu_regmap_by_phandle() api could be removed. The main issue
> currently with fw_devlink syscon support is the wide diversity of dt property
> naming currently in use. That was discussed previously here [3]
> 
> 1248a1256,1257
> > DEFINE_SUFFIX_PROP(syscon_phandle, "syscon-phandle", NULL)
> > DEFINE_SUFFIX_PROP(pmu_syscon, "pmu-syscon", NULL)
> 1358a1368,1369
> >     { .parse_prop = parse_syscon_phandle, },
> >     { .parse_prop = parse_pmu_syscon, },
> 
> 
> Note one previous concern from Saravana about syscon potentially probing
> before exynos-pmu driver and it relying on drivers/Makefile ordering. I tested
> this and even if mfd is listed before soc in drivers/Makefile exynos-pmu
> always probes first due to syscon driver not setting a .of_match_table entry.
> 
> Once the syscon and exynos-pmu patchs are queued I will send patches for
> watchdog and ufs phy drivers to switch back to syscon_regmap_lookup_by_phandle()
> 
> Many thanks,
> 
> Peter.
> 
> [1] https://lore.kernel.org/linux-arm-kernel/20240219204238.356942-1-peter.griffin@linaro.org/T/
> [2] https://lore.kernel.org/lkml/06383015-51b2-4f4c-9fd8-e4f7ce12f44e@kernel.org/
> [3] https://lore.kernel.org/all/CAGETcx-CCpaV7R0O0HpDpoX6KxQBuJiMmKdWA8nDE-5Qj2Sa7g@mail.gmail.com/
> 
> Changes since v2:
>  - Move allocation outside spinlock area (Arnd)
> Link to v2:
>  - https://lore.kernel.org/linux-arm-kernel/20240620112446.1286223-1-peter.griffin@linaro.org/
> 
> Changes since v1:
>  - Collect by tags
>  - Keep syscon lock held for check and adding entry (Krzysztof)
>  - pass pmu_np not np to syscon_node_to_regmap() (William)
> 
> Link to v1:
>  - https://lore.kernel.org/linux-arm-kernel/20240614140421.3172674-1-peter.griffin@linaro.org/
> 
> Peter Griffin (2):
>   mfd: syscon: add of_syscon_register_regmap() API
>   soc: samsung: exynos-pmu: update to use of_syscon_register_regmap()
> 
>  drivers/mfd/syscon.c             | 48 ++++++++++++++++++++++++++++++++
>  drivers/soc/samsung/exynos-pmu.c | 38 ++++++++++---------------
>  include/linux/mfd/syscon.h       |  8 ++++++
>  3 files changed, 70 insertions(+), 24 deletions(-)

Applied and submitted for build testing.

If all is good, I'll send out a PR for the other maintainer(s).

Note to self: ib-mfd-soc-samsung-6.11

-- 
Lee Jones [李琼斯]


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

* [GIT PULL] Immutable branch between MFD and SoC Samsung due for the v6.11 merge window
  2024-06-21 11:55 [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Peter Griffin
                   ` (3 preceding siblings ...)
  2024-06-26 15:48 ` Lee Jones
@ 2024-06-28 14:26 ` Lee Jones
  4 siblings, 0 replies; 10+ messages in thread
From: Lee Jones @ 2024-06-28 14:26 UTC (permalink / raw)
  To: Peter Griffin
  Cc: arnd, krzk, alim.akhtar, linux-arm-kernel, linux-samsung-soc,
	linux-kernel, tudor.ambarus, andre.draszik, saravanak,
	willmcvicker, semen.protsenko, kernel-team

Enjoy!

The following changes since commit 1613e604df0cd359cf2a7fbd9be7a0bcfacfabd0:

  Linux 6.10-rc1 (2024-05-26 15:20:12 -0700)

are available in the Git repository at:

  ssh://git@gitolite.kernel.org/pub/scm/linux/kernel/git/lee/mfd.git tags/ib-mfd-soc-samsung-v6.11

for you to fetch changes up to 35d6b98c625867209bc47df99cf03edf4280799f:

  soc: samsung: exynos-pmu: update to use of_syscon_register_regmap() (2024-06-26 16:47:05 +0100)

----------------------------------------------------------------
Immutable branch between MFD and SoC Samsung due for the v6.11 merge window

----------------------------------------------------------------
Peter Griffin (2):
      mfd: syscon: Add of_syscon_register_regmap() API
      soc: samsung: exynos-pmu: update to use of_syscon_register_regmap()

 drivers/mfd/syscon.c             | 48 ++++++++++++++++++++++++++++++++++++++++
 drivers/soc/samsung/exynos-pmu.c | 38 ++++++++++++-------------------
 include/linux/mfd/syscon.h       |  8 +++++++
 3 files changed, 70 insertions(+), 24 deletions(-)

-- 
Lee Jones [李琼斯]


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

end of thread, other threads:[~2024-06-28 14:26 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-21 11:55 [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Peter Griffin
2024-06-21 11:55 ` [PATCH v3 1/2] mfd: syscon: add of_syscon_register_regmap() API Peter Griffin
2024-06-21 23:56   ` William McVicker
2024-06-24  5:57   ` Krzysztof Kozlowski
2024-06-21 11:55 ` [PATCH v3 2/2] soc: samsung: exynos-pmu: update to use of_syscon_register_regmap() Peter Griffin
2024-06-21 23:57   ` William McVicker
2024-06-24  5:58   ` Krzysztof Kozlowski
2024-06-21 14:54 ` [PATCH v3 0/2] Add syscon of_syscon_register_regmap api Arnd Bergmann
2024-06-26 15:48 ` Lee Jones
2024-06-28 14:26 ` [GIT PULL] Immutable branch between MFD and SoC Samsung due for the v6.11 merge window Lee Jones

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).