summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNishant Kamat <nskamat@ti.com>2009-12-01 20:55:18 +0530
committerSantosh Shilimkar <santosh.shilimkar@ti.com>2009-12-01 21:05:46 +0530
commitee7fd78d38b9e6084748e43825daecc6f0da8838 (patch)
tree38bcb4c20a8c52e816e411d2efad54b70e022312
parent0d12da937bcb5ad6fdda07dae90f586b234a1780 (diff)
RTC: TWL6030: Don't use i2c burst writes for OMAP4ti-2.6.31-omap4-L24.1
This is a temporary hack to workaround the OMAP4 I2C issue with burst read/writes. The real fix should be added to the i2c-omap.c file. Signed-off-by: Nishant Kamat <nskamat@ti.com>
-rw-r--r--drivers/rtc/rtc-twl.c44
1 files changed, 42 insertions, 2 deletions
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c
index ff3842d9eec0..389d3dbc8d50 100644
--- a/drivers/rtc/rtc-twl.c
+++ b/drivers/rtc/rtc-twl.c
@@ -134,6 +134,29 @@ static int twl_rtc_write_u8(u8 data, u8 reg)
return ret;
}
+#ifdef CONFIG_ARCH_OMAP4
+static int twl_rtc_read(u8 *value, u8 reg, unsigned num_bytes)
+{
+ int ret = 0, i = 0;
+
+ for (i = 0; i < num_bytes; i++)
+ if (twl_rtc_read_u8(value + i, reg + i))
+ return ret;
+
+ return ret;
+}
+
+static int twl_rtc_write(u8 *value, u8 reg, unsigned num_bytes)
+{
+ int ret = 0, i = 0;
+
+ for (i = 0; i < num_bytes; i++)
+ if (twl_rtc_write_u8(*(value + i + 1), reg + i))
+ return ret;
+ return ret;
+}
+#endif
+
/*
* Cache the value for timer/alarm interrupts register; this is
* only changed by callers holding rtc ops lock (or resume).
@@ -222,9 +245,12 @@ static int twl_rtc_read_time(struct device *dev, struct rtc_time *tm)
if (ret < 0)
return ret;
+#ifndef CONFIG_ARCH_OMAP4
ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
REG_SECONDS_REG, ALL_TIME_REGS);
-
+#else
+ ret = twl_rtc_read(rtc_data, REG_SECONDS_REG, ALL_TIME_REGS);
+#endif
if (ret < 0) {
dev_err(dev, "rtc_read_time error %d\n", ret);
return ret;
@@ -264,8 +290,13 @@ static int twl_rtc_set_time(struct device *dev, struct rtc_time *tm)
goto out;
/* update all the time registers in one shot */
+#ifndef CONFIG_ARCH_OMAP4
ret = twl_i2c_write(TWL_MODULE_RTC, rtc_data,
REG_SECONDS_REG, ALL_TIME_REGS);
+#else
+ ret = twl_rtc_write(rtc_data,
+ REG_SECONDS_REG, ALL_TIME_REGS);
+#endif
if (ret < 0) {
dev_err(dev, "rtc_set_time error %d\n", ret);
goto out;
@@ -286,9 +317,13 @@ static int twl_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm)
{
unsigned char rtc_data[ALL_TIME_REGS + 1];
int ret;
-
+#ifndef CONFIG_ARCH_OMAP4
ret = twl_i2c_read(TWL_MODULE_RTC, rtc_data,
REG_ALARM_SECONDS_REG, ALL_TIME_REGS);
+#else
+ ret = twl_rtc_read(rtc_data,
+ REG_ALARM_SECONDS_REG, ALL_TIME_REGS);
+#endif
if (ret < 0) {
dev_err(dev, "rtc_read_alarm error %d\n", ret);
return ret;
@@ -326,8 +361,13 @@ static int twl_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm)
alarm_data[6] = bin2bcd(alm->time.tm_year - 100);
/* update all the alarm registers in one shot */
+#ifndef CONFIG_ARCH_OMAP4
ret = twl_i2c_write(TWL_MODULE_RTC, alarm_data,
REG_ALARM_SECONDS_REG, ALL_TIME_REGS);
+#else
+ ret = twl_rtc_write(alarm_data,
+ REG_ALARM_SECONDS_REG, ALL_TIME_REGS);
+#endif
if (ret) {
dev_err(dev, "rtc_set_alarm error %d\n", ret);
goto out;