[PATCH] RTC v3020 fixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Mike Rapoport <[email protected]>
Acked-by: Raphael Assenat <[email protected]>

diff --git a/drivers/char/emv3020.c b/drivers/char/emv3020.c
index df7f1a4..1d93269 100644
--- a/drivers/char/emv3020.c
+++ b/drivers/char/emv3020.c
@@ -48,12 +48,16 @@ static void emv3020_set_reg(unsigned char address, unsigned char data)
 {
 	int i;

-	for ( i = 0; i < 4; i++ )
+	for ( i = 0; i < 4; i++ ) {
 		writel((address << (16-i)), EMV3020_VA_RTC);
+		udelay(1);
+	}

 	if ( address < 0xe)
-		for ( i = 0; i < 8; i++)
+		for ( i = 0; i < 8; i++) {
 			writel((data << (16-i)), EMV3020_VA_RTC);
+			udelay(1);
+		}
 }

 static unsigned char emv3020_get_reg(unsigned char address)
@@ -61,12 +65,16 @@ static unsigned char emv3020_get_reg(unsigned char address)
 	unsigned int data=0;
 	int i, tmp;

-	for ( i = 0; i < 4; i++ )
+	for ( i = 0; i < 4; i++ ) {
 		writel((address << (16-i)), EMV3020_VA_RTC);
+		udelay(1);
+	}
+

 	for ( i = 0; i < 8; i++ ) {
 		tmp = readl(EMV3020_VA_RTC);
 		data |= ((tmp & 0x10000) >> (16 - i));
+		udelay(1);
 	}

 	return data;
@@ -108,7 +116,7 @@ static int emv3020_rtc_gettime(struct rtc_time *dt)
 	BCD_TO_BIN(dt->tm_min);
 	BCD_TO_BIN(dt->tm_hour);
 	BCD_TO_BIN(dt->tm_mday);
-	BCD_TO_BIN(dt->tm_mon);
+	BCD_TO_BIN(dt->tm_mon - 1);
 	BCD_TO_BIN(dt->tm_wday);
 	BCD_TO_BIN(dt->tm_year);
 	dt->tm_year += 100;
@@ -148,7 +156,7 @@ static int emv3020_rtc_settime(struct rtc_time *dt)
 	emv3020_set_reg(0x03, dt->tm_min);
 	emv3020_set_reg(0x04, dt->tm_hour);
 	emv3020_set_reg(0x05, dt->tm_mday);
-	emv3020_set_reg(0x06, dt->tm_mon);
+	emv3020_set_reg(0x06, dt->tm_mon + 1);
 	emv3020_set_reg(0x08, dt->tm_wday);
 	emv3020_set_reg(0x07, dt->tm_year);


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux