diff mbox

RTC: add support for DS1388

Message ID 1237987182.2194.5.camel@gentoo-jocke.transmode.se
State Accepted, archived
Headers show

Commit Message

Joakim Tjernlund March 25, 2009, 1:19 p.m. UTC
>From 03d257c844062f3a21a0dbe1fa8f58f65ce8c30d Mon Sep 17 00:00:00 2001
From: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
Date: Wed, 11 Feb 2009 18:21:37 +0100
Subject: [PATCH] RTC: add support for DS1388

Extend the ds1307 driver to support ds1388 too.

Signed-off-by: Joakim Tjernlund <Joakim.Tjernlund@transmode.se>
---
 drivers/rtc/rtc-ds1307.c |   14 +++++++++++---
 1 files changed, 11 insertions(+), 3 deletions(-)
diff mbox

Patch

diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index 7e5155e..8cda7dc 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			reg_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->reg_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->reg_addr, 7, buf);
 	if (result < 0) {
 		dev_err(dev, "%s error %d\n", "write", result);
 		return result;
@@ -589,6 +593,9 @@  static int __devinit ds1307_probe(struct i2c_client *client,
 			dev_warn(&client->dev, "SET TIME!\n");
 		}
 		break;
+	case ds_1388:
+		ds1307->reg_addr = 1; /* Seconds starts at 1 */
+		break;
 	default:
 		break;
 	}
@@ -651,6 +658,7 @@  read_rtc:
 		break;
 	case ds_1337:
 	case ds_1339:
+	case ds_1388:
 		break;
 	}