From: Sanchayan Maity <maitysanchayan@gmail.com>
To: rtc-linux@googlegroups.com
Cc: shawn.guo@linaro.org, linux@arm.linux.org.uk,
kernel@pengutronix.de, stefan@agner.ch, b35083@freescale.com,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Sanchayan Maity <maitysanchayan@gmail.com>
Subject: [[PATCHv2] 3/3] drivers/rtc/rtc-snvs: Add clock support
Date: Fri, 7 Nov 2014 18:34:28 +0530 [thread overview]
Message-ID: <30e496ce2d6521e608df3b68b73b3e05caa1daef.1415364391.git.maitysanchayan@gmail.com> (raw)
In-Reply-To: <cover.1415364391.git.maitysanchayan@gmail.com>
In-Reply-To: <cover.1415364391.git.maitysanchayan@gmail.com>
This patch adds clock enable and disable support for
the SNVS peripheral, which is required for using the
RTC within the SNVS block.
Signed-off-by: Sanchayan Maity <maitysanchayan@gmail.com>
---
drivers/rtc/rtc-snvs.c | 34 ++++++++++++++++++++++++++++++++--
1 file changed, 32 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c
index fa384fe..d4a6512 100644
--- a/drivers/rtc/rtc-snvs.c
+++ b/drivers/rtc/rtc-snvs.c
@@ -17,6 +17,7 @@
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
+#include <linux/clk.h>
/* These register offsets are relative to LP (Low Power) range */
#define SNVS_LPCR 0x04
@@ -39,6 +40,7 @@ struct snvs_rtc_data {
void __iomem *ioaddr;
int irq;
spinlock_t lock;
+ struct clk *clk;
};
static u32 rtc_read_lp_counter(void __iomem *ioaddr)
@@ -260,6 +262,18 @@ static int snvs_rtc_probe(struct platform_device *pdev)
if (data->irq < 0)
return data->irq;
+ data->clk = devm_clk_get(&pdev->dev, "snvs-rtc");
+ if (IS_ERR(data->clk)) {
+ data->clk = NULL;
+ } else {
+ ret = clk_prepare_enable(data->clk);
+ if (ret) {
+ dev_err(&pdev->dev,
+ "Could not prepare or enable the snvs clock\n");
+ return ret;
+ }
+ }
+
platform_set_drvdata(pdev, data);
spin_lock_init(&data->lock);
@@ -280,7 +294,7 @@ static int snvs_rtc_probe(struct platform_device *pdev)
if (ret) {
dev_err(&pdev->dev, "failed to request irq %d: %d\n",
data->irq, ret);
- return ret;
+ goto error_rtc_device_register;
}
data->rtc = devm_rtc_device_register(&pdev->dev, pdev->name,
@@ -288,10 +302,16 @@ static int snvs_rtc_probe(struct platform_device *pdev)
if (IS_ERR(data->rtc)) {
ret = PTR_ERR(data->rtc);
dev_err(&pdev->dev, "failed to register rtc: %d\n", ret);
- return ret;
+ goto error_rtc_device_register;
}
return 0;
+
+error_rtc_device_register:
+ if (data->clk)
+ clk_disable_unprepare(data->clk);
+
+ return ret;
}
#ifdef CONFIG_PM_SLEEP
@@ -302,16 +322,26 @@ static int snvs_rtc_suspend(struct device *dev)
if (device_may_wakeup(dev))
enable_irq_wake(data->irq);
+ if (data->clk)
+ clk_disable_unprepare(data->clk);
+
return 0;
}
static int snvs_rtc_resume(struct device *dev)
{
struct snvs_rtc_data *data = dev_get_drvdata(dev);
+ int ret;
if (device_may_wakeup(dev))
disable_irq_wake(data->irq);
+ if (data->clk) {
+ ret = clk_prepare_enable(data->clk);
+ if (ret)
+ return ret;
+ }
+
return 0;
}
#endif
--
1.7.9.5
next prev parent reply other threads:[~2014-11-07 13:05 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-11-07 13:04 [[PATCHv2] 0/3] Add SNVS clock gating and clock support to rtc-snvs driver Sanchayan Maity
2014-11-07 13:04 ` [[PATCHv2] 1/3] ARM: imx: clk-vf610: Add clock for SNVS Sanchayan Maity
2014-11-11 14:49 ` Shawn Guo
2014-11-11 20:58 ` Stefan Agner
2014-11-11 21:13 ` Stefan Agner
2014-11-07 13:04 ` [[PATCHv2] 2/3] ARM: dts: vfxxx: Add SNVS node Sanchayan Maity
2014-11-11 21:20 ` Stefan Agner
2014-11-12 8:46 ` Sanchayan Maity
2014-11-07 13:04 ` Sanchayan Maity [this message]
2014-11-11 21:27 ` [[PATCHv2] 3/3] drivers/rtc/rtc-snvs: Add clock support Stefan Agner
2014-11-12 8:56 ` Sanchayan Maity
2014-11-12 10:47 ` Shawn Guo
2014-11-13 5:33 ` Sanchayan Maity
2014-11-19 1:17 ` Shawn Guo
2014-11-19 4:49 ` Sanchayan Maity
2014-11-28 4:27 ` Sanchayan Maity
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=30e496ce2d6521e608df3b68b73b3e05caa1daef.1415364391.git.maitysanchayan@gmail.com \
--to=maitysanchayan@gmail.com \
--cc=b35083@freescale.com \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@arm.linux.org.uk \
--cc=rtc-linux@googlegroups.com \
--cc=shawn.guo@linaro.org \
--cc=stefan@agner.ch \
/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
all inboxes | Powered by JetHome®