diff mbox

RTC: add support for DS1388

Message ID 1238432178-22471-1-git-send-email-Joakim.Tjernlund@transmode.se
State Accepted, archived
Headers show

Commit Message

Joakim Tjernlund March 30, 2009, 4:56 p.m. UTC
Extend the ds1307 driver to support ds1388 too.
---
 drivers/rtc/rtc-ds1307.c |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

Comments

Joakim Tjernlund March 30, 2009, 4:59 p.m. UTC | #1
Joakim Tjernlund <Joakim.Tjernlund@transmode.se> wrote on 30/03/2009 
18:56:18:

> 
> Extend the ds1307 driver to support ds1388 too.
> ---

 Forgot:
Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
-~----------~----~----~----~------~----~------~--~---
diff mbox

Patch

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 7e5155e..1ef25f6 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -30,6 +30,7 @@  enum ds_type {
 	ds_1338,
 	ds_1339,
 	ds_1340,
+	ds_1388,
 	m41t00,
 	// rs5c372 too?  different address...
 };
@@ -86,6 +87,7 @@  enum ds_type {
 
 
 struct ds1307 {
+	u8			secs_addr;
 	u8			regs[11];
 	enum ds_type		type;
 	unsigned long		flags;
@@ -124,6 +126,7 @@  static const struct i2c_device_id ds1307_id[] = {
 	{ "ds1337", ds_1337 },
 	{ "ds1338", ds_1338 },
 	{ "ds1339", ds_1339 },
+	{ "ds1388", ds_1388 },
 	{ "ds1340", ds_1340 },
 	{ "m41t00", m41t00 },
 	{ }
@@ -202,8 +205,8 @@  static int ds1307_get_time(struct device *dev, struct rtc_time *t)
 	int		tmp;
 
 	/* read the RTC date and time registers all at once */
-	tmp = i2c_smbus_read_i2c_block_data(ds1307->client,
-		DS1307_REG_SECS, 7, ds1307->regs);
+	tmp = i2c_smbus_read_i2c_block_data(ds1307->client, ds1307->secs_addr,
+					    7, ds1307->regs);
 	if (tmp != 7) {
 		dev_err(dev, "%s error %d\n", "read", tmp);
 		return -EIO;
@@ -279,7 +282,8 @@  static int ds1307_set_time(struct device *dev, struct rtc_time *t)
 		"write", buf[0], buf[1], buf[2], buf[3],
 		buf[4], buf[5], buf[6]);
 
-	result = i2c_smbus_write_i2c_block_data(ds1307->client, 0, 7, buf);
+	result = i2c_smbus_write_i2c_block_data(ds1307->client,
+						ds1307->secs_addr, 7, buf);
 	if (result < 0) {
 		dev_err(dev, "%s error %d\n", "write", result);
 		return result;
@@ -547,6 +551,7 @@  static int __devinit ds1307_probe(struct i2c_client *client,
 	i2c_set_clientdata(client, ds1307);
 	ds1307->type = id->driver_data;
 	buf = ds1307->regs;
+	ds1307->secs_addr = 0;
 
 	switch (ds1307->type) {
 	case ds_1337:
@@ -589,6 +594,9 @@  static int __devinit ds1307_probe(struct i2c_client *client,
 			dev_warn(&client->dev, "SET TIME!\n");
 		}
 		break;
+	case ds_1388:
+		ds1307->secs_addr = 1; /* Seconds starts at 1 */
+		break;
 	default:
 		break;
 	}
@@ -651,6 +659,7 @@  read_rtc:
 		break;
 	case ds_1337:
 	case ds_1339:
+	case ds_1388:
 		break;
 	}