diff options
author | Haojian Zhuang <haojian.zhuang@marvell.com> | 2012-02-23 10:36:37 -0500 |
---|---|---|
committer | Haojian Zhuang <haojian.zhuang@marvell.com> | 2012-02-27 21:13:52 -0500 |
commit | 8e8bbcb3685ab809348d300b8e2c1f1ea0294e81 (patch) | |
tree | 743c67a19a57f7e83b36469ccf3712ae640dfda8 /drivers/rtc/rtc-sa1100.c | |
parent | 3e12ec7714e77010539749bfed5ea11c166095d3 (diff) |
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/rtc-sa1100.c')
-rw-r--r-- | drivers/rtc/rtc-sa1100.c | 17 |
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 @@ | |||
23 | 23 | ||
24 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
25 | #include <linux/module.h> | 25 | #include <linux/module.h> |
26 | #include <linux/clk.h> | ||
26 | #include <linux/rtc.h> | 27 | #include <linux/rtc.h> |
27 | #include <linux/init.h> | 28 | #include <linux/init.h> |
28 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
@@ -48,6 +49,7 @@ struct sa1100_rtc { | |||
48 | int irq_1hz; | 49 | int irq_1hz; |
49 | int irq_alarm; | 50 | int irq_alarm; |
50 | struct rtc_device *rtc; | 51 | struct rtc_device *rtc; |
52 | struct clk *clk; | ||
51 | }; | 53 | }; |
52 | 54 | ||
53 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | 55 | static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) |
@@ -104,6 +106,9 @@ static int sa1100_rtc_open(struct device *dev) | |||
104 | struct rtc_device *rtc = info->rtc; | 106 | struct rtc_device *rtc = info->rtc; |
105 | int ret; | 107 | int ret; |
106 | 108 | ||
109 | ret = clk_prepare_enable(info->clk); | ||
110 | if (ret) | ||
111 | goto fail_clk; | ||
107 | ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, IRQF_DISABLED, | 112 | ret = request_irq(info->irq_1hz, sa1100_rtc_interrupt, IRQF_DISABLED, |
108 | "rtc 1Hz", dev); | 113 | "rtc 1Hz", dev); |
109 | if (ret) { | 114 | if (ret) { |
@@ -124,6 +129,8 @@ static int sa1100_rtc_open(struct device *dev) | |||
124 | fail_ai: | 129 | fail_ai: |
125 | free_irq(info->irq_1hz, dev); | 130 | free_irq(info->irq_1hz, dev); |
126 | fail_ui: | 131 | fail_ui: |
132 | clk_disable_unprepare(info->clk); | ||
133 | fail_clk: | ||
127 | return ret; | 134 | return ret; |
128 | } | 135 | } |
129 | 136 | ||
@@ -137,6 +144,7 @@ static void sa1100_rtc_release(struct device *dev) | |||
137 | 144 | ||
138 | free_irq(info->irq_alarm, dev); | 145 | free_irq(info->irq_alarm, dev); |
139 | free_irq(info->irq_1hz, dev); | 146 | free_irq(info->irq_1hz, dev); |
147 | clk_disable_unprepare(info->clk); | ||
140 | } | 148 | } |
141 | 149 | ||
142 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 150 | 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) | |||
234 | info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL); | 242 | info = kzalloc(sizeof(struct sa1100_rtc), GFP_KERNEL); |
235 | if (!info) | 243 | if (!info) |
236 | return -ENOMEM; | 244 | return -ENOMEM; |
245 | info->clk = clk_get(&pdev->dev, NULL); | ||
246 | if (IS_ERR(info->clk)) { | ||
247 | dev_err(&pdev->dev, "failed to find rtc clock source\n"); | ||
248 | ret = PTR_ERR(info->clk); | ||
249 | goto err_clk; | ||
250 | } | ||
237 | info->irq_1hz = irq_1hz; | 251 | info->irq_1hz = irq_1hz; |
238 | info->irq_alarm = irq_alarm; | 252 | info->irq_alarm = irq_alarm; |
239 | spin_lock_init(&info->lock); | 253 | spin_lock_init(&info->lock); |
@@ -292,6 +306,8 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
292 | return 0; | 306 | return 0; |
293 | err_dev: | 307 | err_dev: |
294 | platform_set_drvdata(pdev, NULL); | 308 | platform_set_drvdata(pdev, NULL); |
309 | clk_put(info->clk); | ||
310 | err_clk: | ||
295 | kfree(info); | 311 | kfree(info); |
296 | return ret; | 312 | return ret; |
297 | } | 313 | } |
@@ -302,6 +318,7 @@ static int sa1100_rtc_remove(struct platform_device *pdev) | |||
302 | 318 | ||
303 | if (info) { | 319 | if (info) { |
304 | rtc_device_unregister(info->rtc); | 320 | rtc_device_unregister(info->rtc); |
321 | clk_put(info->clk); | ||
305 | platform_set_drvdata(pdev, NULL); | 322 | platform_set_drvdata(pdev, NULL); |
306 | kfree(info); | 323 | kfree(info); |
307 | } | 324 | } |