summaryrefslogtreecommitdiff
path: root/drivers/rtc
diff options
context:
space:
mode:
authorDaehyoung Ko <dko@nvidia.com>2011-04-11 13:04:54 -0700
committerDan Willemsen <dwillemsen@nvidia.com>2011-11-30 21:43:14 -0800
commitd9d5c223aa2b71f3c855270be8e3074422b9ed4f (patch)
tree183d7173d578b3e64c13f06b12a66486e12b6614 /drivers/rtc
parenta0a5a5fd043324387f5f6c031e0dd708750d1a1f (diff)
rtc : tps6586x: avoid RTC time is getting slower
To ensure an accurate read of the RTC registers during the required multi-byte read operation, the PMU RTC is designed with the following protection scheme - A circuit detects a write/read and locks the RTC_COUNT4 value by keeping the RTC in a suspended mode - During the suspended mode, a secondary counter is used to keep track of all counts that would have normally incremented the RTC - After the read is complete, the value of the secondary counter is added back to the RTC registers and thereby keeping the RTC accurate - The backup counter allows for a 1ms RTC suspend mode duration when the RTC prescaler is enabled. i2c needs to generate a 2 msgs when reading. - the address setup(write RTC_COUNT4 operation), hence start locking the RTC_COUNT4 - the data transfer (read RTC_COUNT4 operation),release locking it. this may allow the CPU to execute other portions of code in between the two operation. The fix is to start a PMU RTC access by reading the register prior to the RTC_COUNT4 so that access of the RTC PMU registers will be guaranteed to always occur within the 1ms time period. - the address setup(write RTC_COUNT4-1 operation), so there is no locking the RTC_COUNT4 - the data transfer (read RTC_COUNT4 operation), starting locking the RTC_COUNT4 and release locking the RTC_COUNT4 in one operation, so it will be guaranteed within 1ms Bug 811075 Original-Change-Id: Ie07472a329f6a0eed11e6a039cd93307bb5276a0 Reviewed-on: http://git-master/r/27537 Reviewed-by: Varun Colbert <vcolbert@nvidia.com> Tested-by: Varun Colbert <vcolbert@nvidia.com> Rebase-Id: R0279c3dac03756636596c504e623b7159ee474f7
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-tps6586x.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/drivers/rtc/rtc-tps6586x.c b/drivers/rtc/rtc-tps6586x.c
index 20bd0d06ce1c..265c57d55ed1 100644
--- a/drivers/rtc/rtc-tps6586x.c
+++ b/drivers/rtc/rtc-tps6586x.c
@@ -39,6 +39,7 @@
#define CL_SEL_POS 1
#define RTC_ALARM1_HI 0xc1
#define RTC_COUNT4 0xc6
+#define RTC_COUNT4_DUMMYREAD 0xc5 /* start a PMU RTC access by reading the register prior to the RTC_COUNT4 */
struct tps6586x_rtc {
unsigned long epoch_start;
@@ -58,17 +59,17 @@ static int tps6586x_rtc_read_time(struct device *dev, struct rtc_time *tm)
struct device *tps_dev = to_tps6586x_dev(dev);
unsigned long long ticks = 0;
unsigned long seconds;
- u8 buff[5];
+ u8 buff[6];
int err;
int i;
- err = tps6586x_reads(tps_dev, RTC_COUNT4, sizeof(buff), buff);
+ err = tps6586x_reads(tps_dev, RTC_COUNT4_DUMMYREAD, sizeof(buff), buff);
if (err < 0) {
dev_err(dev, "failed to read counter\n");
return err;
}
- for (i = 0; i < sizeof(buff); i++) {
+ for (i = 1; i < sizeof(buff); i++) {
ticks <<= 8;
ticks |= buff[i];
}