Skip to content

Commit

Permalink
rtc: sa1100: enable clk support
Browse files Browse the repository at this point in the history
Enable clock support on rtc-sa1100.

Signed-off-by: Haojian Zhuang <haojian.zhuang@marvell.com>
  • Loading branch information
Haojian Zhuang committed Feb 28, 2012
1 parent 3e12ec7 commit 8e8bbcb
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions drivers/rtc/rtc-sa1100.c
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand All @@ -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)
Expand Down Expand Up @@ -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) {
Expand All @@ -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;
}

Expand All @@ -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)
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down

0 comments on commit 8e8bbcb

Please sign in to comment.