11 #include <linux/kernel.h>
12 #include <linux/module.h>
14 #include <linux/rtc.h>
15 #include <linux/slab.h>
41 #define RP5C01_12_24_SELECT_12 (0 << 0)
42 #define RP5C01_12_24_SELECT_24 (1 << 0)
44 #define RP5C01_10_HOUR_AM (0 << 1)
45 #define RP5C01_10_HOUR_PM (1 << 1)
47 #define RP5C01_MODE_TIMER_EN (1 << 3)
48 #define RP5C01_MODE_ALARM_EN (1 << 2)
50 #define RP5C01_MODE_MODE_MASK (3 << 0)
51 #define RP5C01_MODE_MODE00 (0 << 0)
52 #define RP5C01_MODE_MODE01 (1 << 0)
53 #define RP5C01_MODE_RAM_BLOCK10 (2 << 0)
54 #define RP5C01_MODE_RAM_BLOCK11 (3 << 0)
56 #define RP5C01_RESET_1HZ_PULSE (1 << 3)
57 #define RP5C01_RESET_16HZ_PULSE (1 << 2)
58 #define RP5C01_RESET_SECOND (1 << 1)
60 #define RP5C01_RESET_ALARM (1 << 0)
97 spin_lock_irq(&priv->
lock);
117 spin_unlock_irq(&priv->
lock);
122 static int rp5c01_set_time(
struct device *dev,
struct rtc_time *tm)
126 spin_lock_irq(&priv->
lock);
147 spin_unlock_irq(&priv->
lock);
152 .read_time = rp5c01_read_time,
153 .set_time = rp5c01_set_time,
171 spin_lock_irq(&priv->
lock);
173 for (count = 0; size > 0 && pos <
RP5C01_MODE; count++, size--) {
179 data = rp5c01_read(priv, pos) << 4;
183 data |= rp5c01_read(priv, pos++);
189 spin_unlock_irq(&priv->
lock);
195 char *buf, loff_t pos,
size_t size)
201 spin_lock_irq(&priv->
lock);
203 for (count = 0; size > 0 && pos <
RP5C01_MODE; count++, size--) {
209 rp5c01_write(priv, data >> 4, pos);
213 rp5c01_write(priv, data & 0xf, pos++);
218 spin_unlock_irq(&priv->
lock);
252 platform_set_drvdata(dev, priv);
257 error = PTR_ERR(rtc);
271 platform_set_drvdata(dev,
NULL);
280 struct rp5c01_priv *priv = platform_get_drvdata(dev);
291 .name =
"rtc-rp5c01",
294 .remove =
__exit_p(rp5c01_rtc_remove),
297 static int __init rp5c01_rtc_init(
void)
302 static void __exit rp5c01_rtc_fini(
void)