summaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorHaojian Zhuang <haojian.zhuang@marvell.com>2012-02-23 16:36:37 +0100
committerHaojian Zhuang <haojian.zhuang@marvell.com>2012-02-28 03:13:52 +0100
commit8e8bbcb3685ab809348d300b8e2c1f1ea0294e81 (patch)
tree743c67a19a57f7e83b36469ccf3712ae640dfda8 /drivers/rtc
parentARM: pxa: add rtc dummy clock (diff)
downloadlinux-8e8bbcb3685ab809348d300b8e2c1f1ea0294e81.tar.xz
linux-8e8bbcb3685ab809348d300b8e2c1f1ea0294e81.zip
rtc: sa1100: enable clk support
Enable clock support on rtc-sa1100. Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-sa1100.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c
index 0a36c7ee3b40..962510cf726f 100644
--- a/drivers/rtc/rtc-sa1100.c
+++ b/drivers/rtc/rtc-sa1100.c
@@ -23,6 +23,7 @@
#include <linux/platform_device.h>
#include <linux/module.h>
+#include <linux/clk.h>
#include <linux/rtc.h>
#include <linux/init.h>
#include <linux/fs.h>
@@ -48,6 +49,7 @@ struct sa1100_rtc {
int irq_1hz;
int irq_alarm;
struct rtc_device *rtc;
+ struct clk *clk;
};
static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id)
@@ -104,6 +106,9 @@ static int sa1100_rtc_open(struct device *dev)
struct rtc_device *rtc = info->rtc;
int ret;
+ ret = clk_prepare_enable(info->clk);
+ if (ret)
+ goto fail_clk;
ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, IRQF_DISABLED,
"rtc 1Hz", dev);
if (ret) {
@@ -124,6 +129,8 @@ static int sa1100_rtc_open(struct device *dev)
fail_ai:
free_irq(info->irq_1hz, dev);
fail_ui:
+ clk_disable_unprepare(info->clk);
+ fail_clk:
return ret;
}
@@ -137,6 +144,7 @@ static void sa1100_rtc_release(struct device *dev)
free_irq(info->irq_alarm, dev);
free_irq(info->irq_1hz, dev);
+ clk_disable_unprepare(info->clk);
}
static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
@@ -234,6 +242,12 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL);
if (!info)
return -ENOMEM;
+ info->clk = clk_get(&pdev->dev, NULL);
+ if (IS_ERR(info->clk)) {
+ dev_err(&pdev->dev, "failed to find rtc clock source\n");
+ ret = PTR_ERR(info->clk);
+ goto err_clk;
+ }
info->irq_1hz = irq_1hz;
info->irq_alarm = irq_alarm;
spin_lock_init(&info->lock);
@@ -292,6 +306,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev)
return 0;
err_dev:
platform_set_drvdata(pdev, NULL);
+ clk_put(info->clk);
+err_clk:
kfree(info);
return ret;
}
@@ -302,6 +318,7 @@ static int sa1100_rtc_remove(struct platform_device *pdev)
if (info) {
rtc_device_unregister(info->rtc);
+ clk_put(info->clk);
platform_set_drvdata(pdev, NULL);
kfree(info);
}