14 #include <linux/module.h>
15 #include <linux/i2c.h>
17 #include <linux/rtc.h>
20 #define DRV_VERSION "0.2"
25 #define MAX6900_REG_SC 0
26 #define MAX6900_REG_MN 1
27 #define MAX6900_REG_HR 2
28 #define MAX6900_REG_DT 3
29 #define MAX6900_REG_MO 4
30 #define MAX6900_REG_DW 5
31 #define MAX6900_REG_YR 6
32 #define MAX6900_REG_CT 7
34 #define MAX6900_REG_CENTURY 9
35 #define MAX6900_REG_LEN 10
37 #define MAX6900_BURST_LEN 8
39 #define MAX6900_REG_CT_WP (1 << 7)
44 #define MAX6900_REG_CONTROL_WRITE 0x8e
45 #define MAX6900_REG_CENTURY_WRITE 0x92
46 #define MAX6900_REG_CENTURY_READ 0x93
47 #define MAX6900_REG_RESERVED_READ 0x96
48 #define MAX6900_REG_BURST_WRITE 0xbe
49 #define MAX6900_REG_BURST_READ 0xbf
51 #define MAX6900_IDLE_TIME_AFTER_WRITE 3
63 .len =
sizeof(reg_burst_read),
64 .buf = reg_burst_read}
75 .len =
sizeof(reg_century_read),
76 .buf = reg_century_read}
89 dev_err(&client->
dev,
"%s: register read failed\n", __func__);
95 static int max6900_i2c_write_regs(
struct i2c_client *client,
u8 const *buf)
98 struct i2c_msg century_msgs[1] = {
102 .len =
sizeof(i2c_century_buf),
103 .buf = i2c_century_buf}
106 struct i2c_msg burst_msgs[1] = {
110 .len =
sizeof(i2c_burst_buf),
111 .buf = i2c_burst_buf}
140 dev_err(&client->
dev,
"%s: register write failed\n", __func__);
149 rc = max6900_i2c_read_regs(client, regs);
165 static int max6900_i2c_clear_write_protect(
struct i2c_client *client)
170 dev_err(&client->
dev,
"%s: control register write failed\n",
183 rc = max6900_i2c_clear_write_protect(client);
198 rc = max6900_i2c_write_regs(client, regs);
210 static int max6900_rtc_set_time(
struct device *dev,
struct rtc_time *tm)
215 static int max6900_remove(
struct i2c_client *client)
226 .read_time = max6900_rtc_read_time,
227 .set_time = max6900_rtc_set_time,
245 i2c_set_clientdata(client, rtc);
257 .name =
"rtc-max6900",
259 .probe = max6900_probe,
260 .remove = max6900_remove,
261 .id_table = max6900_id,