linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND PATCH v2 0/3] mfd: syscon: Add optional clock support needed on stm32
@ 2019-01-07 10:07 Fabrice Gasnier
  2019-01-07 10:07 ` [RESEND PATCH v2 1/3] dt-bindings: stm32: syscon: add clock support Fabrice Gasnier
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Fabrice Gasnier @ 2019-01-07 10:07 UTC (permalink / raw)
  To: lee.jones, alexandre.torgue
  Cc: robh+dt, mcoquelin.stm32, arnd, mark.rutland, gabriel.fernandez,
	fabrice.gasnier, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

STM32 syscfg registers are accessed using syscon. It needs syscfg clock
to be enabled while accessing registers.
This adds support for optional clock on syscon, and the relevant clock
in stm32mp157 device tree.

Changes in v2:
- move clocks to specific bindings using syscon as per Rob's comment

Fabrice Gasnier (3):
  dt-bindings: stm32: syscon: add clock support
  mfd: syscon: Add optional clock support
  ARM: dts: stm32: Add clock on stm32mp157c syscfg

 .../devicetree/bindings/arm/stm32/stm32-syscon.txt    |  2 ++
 arch/arm/boot/dts/stm32mp157c.dtsi                    |  1 +
 drivers/mfd/syscon.c                                  | 19 +++++++++++++++++++
 3 files changed, 22 insertions(+)

-- 
1.9.1


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

* [RESEND PATCH v2 1/3] dt-bindings: stm32: syscon: add clock support
  2019-01-07 10:07 [RESEND PATCH v2 0/3] mfd: syscon: Add optional clock support needed on stm32 Fabrice Gasnier
@ 2019-01-07 10:07 ` Fabrice Gasnier
  2019-01-07 10:07 ` [RESEND PATCH v2 2/3] mfd: syscon: Add optional " Fabrice Gasnier
  2019-01-07 10:07 ` [RESEND PATCH v2 3/3] ARM: dts: stm32: Add clock on stm32mp157c syscfg Fabrice Gasnier
  2 siblings, 0 replies; 4+ messages in thread
From: Fabrice Gasnier @ 2019-01-07 10:07 UTC (permalink / raw)
  To: lee.jones, alexandre.torgue
  Cc: robh+dt, mcoquelin.stm32, arnd, mark.rutland, gabriel.fernandez,
	fabrice.gasnier, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

STM32 system configuration controller registers needs to be clocked.
Document clock support on stm32-syscon.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
Reviewed-by: Rob Herring <robh@kernel.org>
---
Changes in v2:
- move clocks to specific bindings using syscon as per Rob's comment
---
 Documentation/devicetree/bindings/arm/stm32/stm32-syscon.txt | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/arm/stm32/stm32-syscon.txt b/Documentation/devicetree/bindings/arm/stm32/stm32-syscon.txt
index 99980ae..c92d411 100644
--- a/Documentation/devicetree/bindings/arm/stm32/stm32-syscon.txt
+++ b/Documentation/devicetree/bindings/arm/stm32/stm32-syscon.txt
@@ -5,10 +5,12 @@ Properties:
                  - " st,stm32mp157-syscfg " - for stm32mp157 based SoCs,
                  second value must be always "syscon".
    - reg : offset and length of the register set.
+   - clocks: phandle to the syscfg clock
 
  Example:
          syscfg: syscon@50020000 {
                  compatible = "st,stm32mp157-syscfg", "syscon";
                  reg = <0x50020000 0x400>;
+                 clocks = <&rcc SYSCFG>;
          };
 
-- 
1.9.1


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

* [RESEND PATCH v2 2/3] mfd: syscon: Add optional clock support
  2019-01-07 10:07 [RESEND PATCH v2 0/3] mfd: syscon: Add optional clock support needed on stm32 Fabrice Gasnier
  2019-01-07 10:07 ` [RESEND PATCH v2 1/3] dt-bindings: stm32: syscon: add clock support Fabrice Gasnier
@ 2019-01-07 10:07 ` Fabrice Gasnier
  2019-01-07 10:07 ` [RESEND PATCH v2 3/3] ARM: dts: stm32: Add clock on stm32mp157c syscfg Fabrice Gasnier
  2 siblings, 0 replies; 4+ messages in thread
From: Fabrice Gasnier @ 2019-01-07 10:07 UTC (permalink / raw)
  To: lee.jones, alexandre.torgue
  Cc: robh+dt, mcoquelin.stm32, arnd, mark.rutland, gabriel.fernandez,
	fabrice.gasnier, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

Some system control registers need to be clocked, so the registers can
be accessed. Add an optional clock and attach it to regmap.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
 drivers/mfd/syscon.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index b6d05cd..a0ba4ff 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -12,6 +12,7 @@
  * (at your option) any later version.
  */
 
+#include <linux/clk.h>
 #include <linux/err.h>
 #include <linux/hwspinlock.h>
 #include <linux/io.h>
@@ -45,6 +46,7 @@ struct syscon {
 
 static struct syscon *of_syscon_register(struct device_node *np)
 {
+	struct clk *clk;
 	struct syscon *syscon;
 	struct regmap *regmap;
 	void __iomem *base;
@@ -119,6 +121,18 @@ static struct syscon *of_syscon_register(struct device_node *np)
 		goto err_regmap;
 	}
 
+	clk = of_clk_get(np, 0);
+	if (IS_ERR(clk)) {
+		ret = PTR_ERR(clk);
+		/* clock is optional */
+		if (ret != -ENOENT)
+			goto err_clk;
+	} else {
+		ret = regmap_mmio_attach_clk(regmap, clk);
+		if (ret)
+			goto err_attach;
+	}
+
 	syscon->regmap = regmap;
 	syscon->np = np;
 
@@ -128,6 +142,11 @@ static struct syscon *of_syscon_register(struct device_node *np)
 
 	return syscon;
 
+err_attach:
+	if (!IS_ERR(clk))
+		clk_put(clk);
+err_clk:
+	regmap_exit(regmap);
 err_regmap:
 	iounmap(base);
 err_map:
-- 
1.9.1


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

* [RESEND PATCH v2 3/3] ARM: dts: stm32: Add clock on stm32mp157c syscfg
  2019-01-07 10:07 [RESEND PATCH v2 0/3] mfd: syscon: Add optional clock support needed on stm32 Fabrice Gasnier
  2019-01-07 10:07 ` [RESEND PATCH v2 1/3] dt-bindings: stm32: syscon: add clock support Fabrice Gasnier
  2019-01-07 10:07 ` [RESEND PATCH v2 2/3] mfd: syscon: Add optional " Fabrice Gasnier
@ 2019-01-07 10:07 ` Fabrice Gasnier
  2 siblings, 0 replies; 4+ messages in thread
From: Fabrice Gasnier @ 2019-01-07 10:07 UTC (permalink / raw)
  To: lee.jones, alexandre.torgue
  Cc: robh+dt, mcoquelin.stm32, arnd, mark.rutland, gabriel.fernandez,
	fabrice.gasnier, devicetree, linux-kernel, linux-stm32,
	linux-arm-kernel

STM32 syscfg needs a clock to access registers.

Signed-off-by: Fabrice Gasnier <fabrice.gasnier@st.com>
---
 arch/arm/boot/dts/stm32mp157c.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm/boot/dts/stm32mp157c.dtsi b/arch/arm/boot/dts/stm32mp157c.dtsi
index 8bf1c17..61b2a70 100644
--- a/arch/arm/boot/dts/stm32mp157c.dtsi
+++ b/arch/arm/boot/dts/stm32mp157c.dtsi
@@ -820,6 +820,7 @@
 		syscfg: syscon@50020000 {
 			compatible = "st,stm32mp157-syscfg", "syscon";
 			reg = <0x50020000 0x400>;
+			clocks = <&rcc SYSCFG>;
 		};
 
 		lptimer2: timer@50021000 {
-- 
1.9.1


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

end of thread, other threads:[~2019-01-07 10:08 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-07 10:07 [RESEND PATCH v2 0/3] mfd: syscon: Add optional clock support needed on stm32 Fabrice Gasnier
2019-01-07 10:07 ` [RESEND PATCH v2 1/3] dt-bindings: stm32: syscon: add clock support Fabrice Gasnier
2019-01-07 10:07 ` [RESEND PATCH v2 2/3] mfd: syscon: Add optional " Fabrice Gasnier
2019-01-07 10:07 ` [RESEND PATCH v2 3/3] ARM: dts: stm32: Add clock on stm32mp157c syscfg Fabrice Gasnier

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