25 #include <linux/module.h>
27 #include <linux/rtc.h>
31 #include <linux/slab.h>
32 #include <linux/string.h>
35 #include <linux/bitops.h>
38 #include <mach/hardware.h>
39 #include <mach/irqs.h>
41 #if defined(CONFIG_ARCH_PXA) || defined(CONFIG_ARCH_MMP)
42 #include <mach/regs-rtc.h>
45 #define RTC_DEF_DIVIDER (32768 - 1)
46 #define RTC_DEF_TRIM 0
64 spin_lock(&info->
lock);
100 spin_unlock(&info->
lock);
105 static int sa1100_rtc_open(
struct device *
dev)
111 ret = clk_prepare_enable(info->
clk);
132 clk_disable_unprepare(info->
clk);
137 static void sa1100_rtc_release(
struct device *dev)
141 spin_lock_irq(&info->
lock);
143 spin_unlock_irq(&info->
lock);
147 clk_disable_unprepare(info->
clk);
150 static int sa1100_rtc_alarm_irq_enable(
struct device *dev,
unsigned int enabled)
154 spin_lock_irq(&info->
lock);
159 spin_unlock_irq(&info->
lock);
180 static int sa1100_rtc_read_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
190 static int sa1100_rtc_set_alarm(
struct device *dev,
struct rtc_wkalrm *alrm)
196 spin_lock_irq(&info->
lock);
207 spin_unlock_irq(&info->
lock);
212 static int sa1100_rtc_proc(
struct device *dev,
struct seq_file *seq)
221 .open = sa1100_rtc_open,
222 .release = sa1100_rtc_release,
223 .read_time = sa1100_rtc_read_time,
224 .set_time = sa1100_rtc_set_time,
225 .read_alarm = sa1100_rtc_read_alarm,
226 .set_alarm = sa1100_rtc_set_alarm,
227 .proc = sa1100_rtc_proc,
228 .alarm_irq_enable = sa1100_rtc_alarm_irq_enable,
239 if (irq_1hz < 0 || irq_alarm < 0)
246 if (IS_ERR(info->
clk)) {
247 dev_err(&pdev->
dev,
"failed to find rtc clock source\n");
248 ret = PTR_ERR(info->
clk);
254 platform_set_drvdata(pdev, info);
266 "initializing default clock divider/trim value\n");
308 platform_set_drvdata(pdev,
NULL);
317 struct sa1100_rtc *info = platform_get_drvdata(pdev);
322 platform_set_drvdata(pdev,
NULL);
330 static int sa1100_rtc_suspend(
struct device *dev)
333 if (device_may_wakeup(dev))
338 static int sa1100_rtc_resume(
struct device *dev)
341 if (device_may_wakeup(dev))
346 static const struct dev_pm_ops sa1100_rtc_pm_ops = {
348 .resume = sa1100_rtc_resume,
353 { .compatible =
"mrvl,sa1100-rtc", },
354 { .compatible =
"mrvl,mmp-rtc", },
360 .probe = sa1100_rtc_probe,
361 .remove = sa1100_rtc_remove,
363 .name =
"sa1100-rtc",
365 .pm = &sa1100_rtc_pm_ops,
367 .of_match_table = sa1100_rtc_dt_ids,