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.
Fabrice Gasnier (3):
dt-bindings: mfd: syscon: Add optional clock support
mfd: syscon: Add optional clock support
ARM: dts: stm32: Add clock on stm32mp157c syscfg
Documentation/devicetree/bindings/mfd/syscon.txt | 1 +
arch/arm/boot/dts/stm32mp157c.dtsi | 1 +
drivers/mfd/syscon.c | 19 +++++++++++++++++++
3 files changed, 21 insertions(+)
--
1.9.1
Some system control registers need to be clocked, so the registers can
be accessed. Add an optional clock.
Signed-off-by: Fabrice Gasnier <[email protected]>
---
Documentation/devicetree/bindings/mfd/syscon.txt | 1 +
1 file changed, 1 insertion(+)
diff --git a/Documentation/devicetree/bindings/mfd/syscon.txt b/Documentation/devicetree/bindings/mfd/syscon.txt
index 25d9e9c..a9aaa51 100644
--- a/Documentation/devicetree/bindings/mfd/syscon.txt
+++ b/Documentation/devicetree/bindings/mfd/syscon.txt
@@ -17,6 +17,7 @@ Optional property:
- reg-io-width: the size (in bytes) of the IO accesses that should be
performed on the device.
- hwlocks: reference to a phandle of a hardware spinlock provider node.
+- clocks: phandle to the syscon clock
Examples:
gpr: iomuxc-gpr@20e0000 {
--
1.9.1
STM32 syscfg needs a clock to access registers.
Signed-off-by: Fabrice Gasnier <[email protected]>
---
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
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 <[email protected]>
---
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
On Tue, Nov 27, 2018 at 05:48:15PM +0100, Fabrice Gasnier wrote:
> Some system control registers need to be clocked, so the registers can
> be accessed. Add an optional clock.
>
> Signed-off-by: Fabrice Gasnier <[email protected]>
> ---
> Documentation/devicetree/bindings/mfd/syscon.txt | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/Documentation/devicetree/bindings/mfd/syscon.txt b/Documentation/devicetree/bindings/mfd/syscon.txt
> index 25d9e9c..a9aaa51 100644
> --- a/Documentation/devicetree/bindings/mfd/syscon.txt
> +++ b/Documentation/devicetree/bindings/mfd/syscon.txt
> @@ -17,6 +17,7 @@ Optional property:
> - reg-io-width: the size (in bytes) of the IO accesses that should be
> performed on the device.
> - hwlocks: reference to a phandle of a hardware spinlock provider node.
> +- clocks: phandle to the syscon clock
No. Add clocks to specific bindings using syscon. If you have a node
with only 'syscon', then that should be fixed.
Rob
On 12/11/18 11:16 PM, Rob Herring wrote:
> On Tue, Nov 27, 2018 at 05:48:15PM +0100, Fabrice Gasnier wrote:
>> Some system control registers need to be clocked, so the registers can
>> be accessed. Add an optional clock.
>>
>> Signed-off-by: Fabrice Gasnier <[email protected]>
>> ---
>> Documentation/devicetree/bindings/mfd/syscon.txt | 1 +
>> 1 file changed, 1 insertion(+)
>>
>> diff --git a/Documentation/devicetree/bindings/mfd/syscon.txt b/Documentation/devicetree/bindings/mfd/syscon.txt
>> index 25d9e9c..a9aaa51 100644
>> --- a/Documentation/devicetree/bindings/mfd/syscon.txt
>> +++ b/Documentation/devicetree/bindings/mfd/syscon.txt
>> @@ -17,6 +17,7 @@ Optional property:
>> - reg-io-width: the size (in bytes) of the IO accesses that should be
>> performed on the device.
>> - hwlocks: reference to a phandle of a hardware spinlock provider node.
>> +- clocks: phandle to the syscon clock
>
> No. Add clocks to specific bindings using syscon. If you have a node
> with only 'syscon', then that should be fixed.
Hi Rob,
Thanks for reviewing, so I'll
- add it to Documentation/devicetree/bindings/arm/stm32/stm32-syscon.txt
- send a v2 with this change.
Best regards,
Fabrice
>
> Rob
>