14 #include <linux/i2c.h>
16 #include <linux/rtc.h>
17 #include <linux/slab.h>
18 #include <linux/module.h>
20 #define DRV_VERSION "0.1"
23 #define ISL12022_REG_SC 0x00
24 #define ISL12022_REG_MN 0x01
25 #define ISL12022_REG_HR 0x02
26 #define ISL12022_REG_DT 0x03
27 #define ISL12022_REG_MO 0x04
28 #define ISL12022_REG_YR 0x05
29 #define ISL12022_REG_DW 0x06
31 #define ISL12022_REG_SR 0x07
32 #define ISL12022_REG_INT 0x08
35 #define ISL12022_HR_MIL (1 << 7)
37 #define ISL12022_SR_LBAT85 (1 << 2)
38 #define ISL12022_SR_LBAT75 (1 << 1)
40 #define ISL12022_INT_WRTC (1 << 6)
75 dev_err(&client->
dev,
"%s: read error, ret=%d\n",
84 static int isl12022_write_reg(
struct i2c_client *client,
91 if (err !=
sizeof(data)) {
93 "%s: err=%d addr=%02x, data=%02x\n",
94 __func__, err, data[0], data[1]);
117 "voltage dropped below %u%%, "
118 "date and time is not reliable.\n",
123 "%s: raw data is sec=%02x, min=%02x, hr=%02x, "
124 "mday=%02x, mon=%02x, year=%02x, wday=%02x, "
145 dev_dbg(&client->
dev,
"%s: secs=%d, mins=%d, hours=%d, "
146 "mday=%d, mon=%d, year=%d, wday=%d\n",
154 dev_err(&client->
dev,
"retrieved date and time is invalid.\n");
166 dev_dbg(&client->
dev,
"%s: secs=%d, mins=%d, hours=%d, "
167 "mday=%d, mon=%d, year=%d, wday=%d\n",
182 "init write enable and 24 hour format\n");
185 ret = isl12022_write_reg(client,
187 buf[0] | ISL12022_INT_WRTC);
199 ret = isl12022_write_reg(client,
240 static int isl12022_rtc_set_time(
struct device *dev,
struct rtc_time *tm)
246 .read_time = isl12022_rtc_read_time,
247 .set_time = isl12022_rtc_set_time,
250 static int isl12022_probe(
struct i2c_client *client,
253 struct isl12022 *isl12022;
260 isl12022 = kzalloc(
sizeof(
struct isl12022),
GFP_KERNEL);
266 i2c_set_clientdata(client, isl12022);
273 if (IS_ERR(isl12022->
rtc)) {
274 ret = PTR_ERR(isl12022->
rtc);
286 static int isl12022_remove(
struct i2c_client *client)
288 struct isl12022 *isl12022 = i2c_get_clientdata(client);
305 .name =
"rtc-isl12022",
307 .probe = isl12022_probe,
308 .remove = isl12022_remove,
309 .id_table = isl12022_id,