17 #include <linux/device.h>
18 #include <linux/errno.h>
20 #include <linux/kernel.h>
21 #include <linux/string.h>
22 #include <linux/slab.h>
23 #include <linux/rtc.h>
26 #include <linux/module.h>
28 #define DRV_VERSION "0.2"
30 #define RS5C348_REG_SECS 0
31 #define RS5C348_REG_MINS 1
32 #define RS5C348_REG_HOURS 2
33 #define RS5C348_REG_WDAY 3
34 #define RS5C348_REG_DAY 4
35 #define RS5C348_REG_MONTH 5
36 #define RS5C348_REG_YEAR 6
37 #define RS5C348_REG_CTL1 14
38 #define RS5C348_REG_CTL2 15
40 #define RS5C348_SECS_MASK 0x7f
41 #define RS5C348_MINS_MASK 0x7f
42 #define RS5C348_HOURS_MASK 0x3f
43 #define RS5C348_WDAY_MASK 0x03
44 #define RS5C348_DAY_MASK 0x3f
45 #define RS5C348_MONTH_MASK 0x1f
47 #define RS5C348_BIT_PM 0x20
48 #define RS5C348_BIT_Y2K 0x80
49 #define RS5C348_BIT_24H 0x20
50 #define RS5C348_BIT_XSTP 0x10
51 #define RS5C348_BIT_VDET 0x40
53 #define RS5C348_CMD_W(addr) (((addr) << 4) | 0x08)
54 #define RS5C348_CMD_R(addr) (((addr) << 4) | 0x0c)
55 #define RS5C348_CMD_MW(addr) (((addr) << 4) | 0x00)
56 #define RS5C348_CMD_MR(addr) (((addr) << 4) | 0x04)
104 u8 txbuf[5], rxbuf[7];
116 rxbuf,
sizeof(rxbuf));
141 dev_err(&spi->
dev,
"retrieved date/time is not valid.\n");
149 .read_time = rs5c348_rtc_read_time,
150 .set_time = rs5c348_rtc_set_time,
168 if (ret < 0 || (ret & 0x80)) {
187 dev_warn(&spi->
dev,
"oscillator-stop detected.\n");
189 ret = rs5c348_rtc_set_time(&spi->
dev, &tm);
234 .name =
"rtc-rs5c348",
237 .probe = rs5c348_probe,