From: Fabrice Gasnier <fabrice.gasnier@st.com>
To: <lee.jones@linaro.org>, <robh+dt@kernel.org>, <alexandre.torgue@st.com>
Cc: <mcoquelin.stm32@gmail.com>, <arnd@arndb.de>,
<mark.rutland@arm.com>, <gabriel.fernandez@st.com>,
<fabrice.gasnier@st.com>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>,
<linux-stm32@st-md-mailman.stormreply.com>,
<linux-arm-kernel@lists.infradead.org>
Subject: [PATCH v2 2/3] mfd: syscon: Add optional clock support
Date: Wed, 12 Dec 2018 09:48:14 +0100 [thread overview]
Message-ID: <1544604495-4082-3-git-send-email-fabrice.gasnier@st.com> (raw)
In-Reply-To: <1544604495-4082-1-git-send-email-fabrice.gasnier@st.com>
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
next prev parent reply other threads:[~2018-12-12 8:48 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-12-12 8:48 [PATCH v2 0/3] mfd: syscon: Add optional clock support needed on stm32 Fabrice Gasnier
2018-12-12 8:48 ` [PATCH v2 1/3] dt-bindings: stm32: syscon: add clock support Fabrice Gasnier
2018-12-18 17:12 ` Rob Herring
2019-03-20 13:05 ` Lee Jones
2018-12-12 8:48 ` Fabrice Gasnier [this message]
2019-01-16 12:14 ` [PATCH v2 2/3] mfd: syscon: Add optional " Arnd Bergmann
2019-01-16 14:10 ` Fabrice Gasnier
2019-01-16 15:11 ` Arnd Bergmann
2019-01-28 13:20 ` Fabrice Gasnier
2019-02-11 16:32 ` Fabrice Gasnier
2019-02-18 12:54 ` Arnd Bergmann
2019-03-20 13:05 ` Lee Jones
2018-12-12 8:48 ` [PATCH v2 3/3] ARM: dts: stm32: Add clock on stm32mp157c syscfg Fabrice Gasnier
2019-03-26 11:24 ` Alexandre Torgue
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1544604495-4082-3-git-send-email-fabrice.gasnier@st.com \
--to=fabrice.gasnier@st.com \
--cc=alexandre.torgue@st.com \
--cc=arnd@arndb.de \
--cc=devicetree@vger.kernel.org \
--cc=gabriel.fernandez@st.com \
--cc=lee.jones@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=mark.rutland@arm.com \
--cc=mcoquelin.stm32@gmail.com \
--cc=robh+dt@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).