summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFabrice Gasnier <fabrice.gasnier@st.com>2018-12-12 03:48:14 -0500
committerLee Jones <lee.jones@linaro.org>2019-05-14 03:13:25 -0400
commita00406b71c5f08f2bd8171bc43331f0726f9bdae (patch)
treed629d2417a3c575f363afa06dfbeb71b1e3e7e9d
parentc6ba08819b6a8a94dfb4b0fec7d7b501a6f24aee (diff)
mfd: syscon: Add optional clock support
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> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Lee Jones <lee.jones@linaro.org>
-rw-r--r--drivers/mfd/syscon.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/drivers/mfd/syscon.c b/drivers/mfd/syscon.c
index 0ecdffb3d967..f6922a0f8058 100644
--- a/drivers/mfd/syscon.c
+++ b/drivers/mfd/syscon.c
@@ -12,6 +12,7 @@
12 * (at your option) any later version. 12 * (at your option) any later version.
13 */ 13 */
14 14
15#include <linux/clk.h>
15#include <linux/err.h> 16#include <linux/err.h>
16#include <linux/hwspinlock.h> 17#include <linux/hwspinlock.h>
17#include <linux/io.h> 18#include <linux/io.h>
@@ -45,6 +46,7 @@ static const struct regmap_config syscon_regmap_config = {
45 46
46static struct syscon *of_syscon_register(struct device_node *np) 47static struct syscon *of_syscon_register(struct device_node *np)
47{ 48{
49 struct clk *clk;
48 struct syscon *syscon; 50 struct syscon *syscon;
49 struct regmap *regmap; 51 struct regmap *regmap;
50 void __iomem *base; 52 void __iomem *base;
@@ -119,6 +121,18 @@ static struct syscon *of_syscon_register(struct device_node *np)
119 goto err_regmap; 121 goto err_regmap;
120 } 122 }
121 123
124 clk = of_clk_get(np, 0);
125 if (IS_ERR(clk)) {
126 ret = PTR_ERR(clk);
127 /* clock is optional */
128 if (ret != -ENOENT)
129 goto err_clk;
130 } else {
131 ret = regmap_mmio_attach_clk(regmap, clk);
132 if (ret)
133 goto err_attach;
134 }
135
122 syscon->regmap = regmap; 136 syscon->regmap = regmap;
123 syscon->np = np; 137 syscon->np = np;
124 138
@@ -128,6 +142,11 @@ static struct syscon *of_syscon_register(struct device_node *np)
128 142
129 return syscon; 143 return syscon;
130 144
145err_attach:
146 if (!IS_ERR(clk))
147 clk_put(clk);
148err_clk:
149 regmap_exit(regmap);
131err_regmap: 150err_regmap:
132 iounmap(base); 151 iounmap(base);
133err_map: 152err_map: