12 #include <linux/i2c.h>
13 #include <linux/rtc.h>
14 #include <linux/module.h>
16 #define DRV_VERSION "0.4"
20 #define DS1672_REG_CNT_BASE 0
21 #define DS1672_REG_CONTROL 4
22 #define DS1672_REG_TRICKLE 5
24 #define DS1672_REG_CONTROL_EOSC 0x80
55 dev_err(&client->
dev,
"%s: read error\n", __func__);
60 "%s: raw read data - counters=%02x,%02x,%02x,%02x\n",
61 __func__, buf[0], buf[1], buf[2], buf[3]);
63 time = (buf[3] << 24) | (buf[2] << 16) | (buf[1] << 8) | buf[0];
67 dev_dbg(&client->
dev,
"%s: tm is secs=%d, mins=%d, hours=%d, "
68 "mday=%d, mon=%d, year=%d, wday=%d\n",
75 static int ds1672_set_mmss(
struct i2c_client *client,
unsigned long secs)
81 buf[1] = secs & 0x000000FF;
82 buf[2] = (secs & 0x0000FF00) >> 8;
83 buf[3] = (secs & 0x00FF0000) >> 16;
84 buf[4] = (secs & 0xFF000000) >> 24;
89 dev_err(&client->
dev,
"%s: send: %d\n", __func__, xfer);
101 static int ds1672_rtc_set_mmss(
struct device *dev,
unsigned long secs)
117 .addr = client->
addr,
126 dev_err(&client->
dev,
"%s: read error\n", __func__);
141 err = ds1672_get_control(client, &control);
146 ?
"disabled" :
"enabled");
152 .read_time = ds1672_rtc_read_time,
153 .set_mmss = ds1672_rtc_set_mmss,
156 static int ds1672_remove(
struct i2c_client *client)
166 static int ds1672_probe(
struct i2c_client *client,
186 i2c_set_clientdata(client, rtc);
189 err = ds1672_get_control(client, &control);
195 "Set time to enable.\n");
216 .name =
"rtc-ds1672",
218 .probe = &ds1672_probe,
219 .remove = &ds1672_remove,
220 .id_table = ds1672_id,