12 #include <linux/kernel.h>
13 #include <linux/module.h>
15 #include <linux/rtc.h>
16 #include <linux/slab.h>
38 #define MSM6242_HOUR10_AM (0 << 2)
39 #define MSM6242_HOUR10_PM (1 << 2)
40 #define MSM6242_HOUR10_HR_MASK (3 << 0)
42 #define MSM6242_WEEK_SUNDAY 0
43 #define MSM6242_WEEK_MONDAY 1
44 #define MSM6242_WEEK_TUESDAY 2
45 #define MSM6242_WEEK_WEDNESDAY 3
46 #define MSM6242_WEEK_THURSDAY 4
47 #define MSM6242_WEEK_FRIDAY 5
48 #define MSM6242_WEEK_SATURDAY 6
50 #define MSM6242_CD_30_S_ADJ (1 << 3)
51 #define MSM6242_CD_IRQ_FLAG (1 << 2)
52 #define MSM6242_CD_BUSY (1 << 1)
53 #define MSM6242_CD_HOLD (1 << 0)
55 #define MSM6242_CE_T_MASK (3 << 2)
56 #define MSM6242_CE_T_64HZ (0 << 2)
57 #define MSM6242_CE_T_1HZ (1 << 2)
58 #define MSM6242_CE_T_1MINUTE (2 << 2)
59 #define MSM6242_CE_T_1HOUR (3 << 2)
61 #define MSM6242_CE_ITRPT_STND (1 << 1)
62 #define MSM6242_CE_MASK (1 << 0)
64 #define MSM6242_CF_TEST (1 << 3)
65 #define MSM6242_CF_12H (0 << 2)
66 #define MSM6242_CF_24H (1 << 2)
67 #define MSM6242_CF_STOP (1 << 1)
68 #define MSM6242_CF_REST (1 << 0)
91 msm6242_write(priv, msm6242_read(priv, reg) | val, reg);
94 static inline void msm6242_clear(
struct msm6242_priv *priv,
unsigned int val,
97 msm6242_write(priv, msm6242_read(priv, reg) & ~val, reg);
114 pr_warning(
"msm6242: timed out waiting for RTC (0x%x)\n",
150 else if (pm && tm->
tm_hour != 12)
154 msm6242_unlock(priv);
159 static int msm6242_set_time(
struct device *dev,
struct rtc_time *tm)
169 if (msm6242_read(priv,
MSM6242_CF) & MSM6242_CF_24H)
188 msm6242_unlock(priv);
193 .read_time = msm6242_read_time,
194 .set_time = msm6242_set_time,
217 platform_set_drvdata(dev, priv);
222 error = PTR_ERR(rtc);
230 platform_set_drvdata(dev,
NULL);
249 .name =
"rtc-msm6242",
252 .remove =
__exit_p(msm6242_rtc_remove),
255 static int __init msm6242_rtc_init(
void)
260 static void __exit msm6242_rtc_fini(
void)