* [PATCH] RTC v3020 fixes
@ 2007-08-15 5:45 Mike Rapoport
2007-08-15 12:59 ` Raphaël Assénat
0 siblings, 1 reply; 6+ messages in thread
From: Mike Rapoport @ 2007-08-15 5:45 UTC (permalink / raw)
To: Raphael Assenat, LKML
Fix off-by-one in month calculations
Add delay for bus accesses to satisfy Tw > 500ns
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
drivers/rtc/rtc-v3020.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index 3b58d3d..21b0be5 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -26,6 +26,7 @@
#include <linux/types.h>
#include <linux/bcd.h>
#include <linux/rtc-v3020.h>
+#include <linux/delay.h>
#include <asm/io.h>
@@ -47,6 +48,7 @@ static void v3020_set_reg(struct v3020 *chip, unsigned char
address,
for (i = 0; i < 4; i++) {
writel((tmp & 1) << chip->leftshift, chip->ioaddress);
tmp >>= 1;
+ udelay(1);
}
/* Commands dont have data */
@@ -54,6 +56,7 @@ static void v3020_set_reg(struct v3020 *chip, unsigned char
address,
for (i = 0; i < 8; i++) {
writel((data & 1) << chip->leftshift, chip->ioaddress);
data >>= 1;
+ udelay(1);
}
}
}
@@ -66,12 +69,14 @@ static unsigned char v3020_get_reg(struct v3020 *chip,
unsigned char address)
for (i = 0; i < 4; i++) {
writel((address & 1) << chip->leftshift, chip->ioaddress);
address >>= 1;
+ udelay(1);
}
for (i = 0; i < 8; i++) {
data >>= 1;
if (readl(chip->ioaddress) & (1 << chip->leftshift))
data |= 0x80;
+ udelay(1);
}
return data;
@@ -95,7 +100,7 @@ static int v3020_read_time(struct device *dev, struct
rtc_time *dt)
tmp = v3020_get_reg(chip, V3020_MONTH_DAY);
dt->tm_mday = BCD2BIN(tmp);
tmp = v3020_get_reg(chip, V3020_MONTH);
- dt->tm_mon = BCD2BIN(tmp);
+ dt->tm_mon = BCD2BIN(tmp) - 1;
tmp = v3020_get_reg(chip, V3020_WEEK_DAY);
dt->tm_wday = BCD2BIN(tmp);
tmp = v3020_get_reg(chip, V3020_YEAR);
@@ -135,7 +140,7 @@ static int v3020_set_time(struct device *dev, struct
rtc_time *dt)
v3020_set_reg(chip, V3020_MINUTES, BIN2BCD(dt->tm_min));
v3020_set_reg(chip, V3020_HOURS, BIN2BCD(dt->tm_hour));
v3020_set_reg(chip, V3020_MONTH_DAY, BIN2BCD(dt->tm_mday));
- v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon));
+ v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon) + 1);
v3020_set_reg(chip, V3020_WEEK_DAY, BIN2BCD(dt->tm_wday));
v3020_set_reg(chip, V3020_YEAR, BIN2BCD(dt->tm_year % 100));
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] RTC v3020 fixes
2007-08-15 5:45 [PATCH] RTC v3020 fixes Mike Rapoport
@ 2007-08-15 12:59 ` Raphaël Assénat
2007-08-15 14:02 ` Mike Rapoport
0 siblings, 1 reply; 6+ messages in thread
From: Raphaël Assénat @ 2007-08-15 12:59 UTC (permalink / raw)
To: Mike Rapoport; +Cc: LKML
Mike Rapoport wrote:
> Fix off-by-one in month calculations
> Add delay for bus accesses to satisfy Tw > 500ns
>
*snip*
> @@ -135,7 +140,7 @@ static int v3020_set_time(struct device *dev, struct
> rtc_time *dt)
> v3020_set_reg(chip, V3020_MINUTES, BIN2BCD(dt->tm_min));
> v3020_set_reg(chip, V3020_HOURS, BIN2BCD(dt->tm_hour));
> v3020_set_reg(chip, V3020_MONTH_DAY, BIN2BCD(dt->tm_mday));
> - v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon));
> + v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon) + 1);
This should be BIN2BCD(dt->tm_mon + 1)) instead. Otherwise, in october (month
9), the final value will be 0xa instead of 0x10.
Other than that, the patch looks fine to me. You can add
Acked-by: Raphael Assenat <raph@8d.com> to the updated patch.
Please add Alessandro Zummo <a.zummo@towertech.it> in the CC list to make sure
he sees it.
Best regards,
Raphaël Assénat
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RTC v3020 fixes
2007-08-15 12:59 ` Raphaël Assénat
@ 2007-08-15 14:02 ` Mike Rapoport
0 siblings, 0 replies; 6+ messages in thread
From: Mike Rapoport @ 2007-08-15 14:02 UTC (permalink / raw)
To: Raphaël Assénat; +Cc: LKML, Alessandro Zummo
Raphaël Assénat wrote:
> Mike Rapoport wrote:
>> Fix off-by-one in month calculations
>> Add delay for bus accesses to satisfy Tw > 500ns
>>
> *snip*
>> @@ -135,7 +140,7 @@ static int v3020_set_time(struct device *dev,
>> struct rtc_time *dt)
>> v3020_set_reg(chip, V3020_MINUTES, BIN2BCD(dt->tm_min));
>> v3020_set_reg(chip, V3020_HOURS, BIN2BCD(dt->tm_hour));
>> v3020_set_reg(chip, V3020_MONTH_DAY, BIN2BCD(dt->tm_mday));
>> - v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon));
>> + v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon) + 1);
>
> This should be BIN2BCD(dt->tm_mon + 1)) instead. Otherwise, in october
> (month 9), the final value will be 0xa instead of 0x10.
Fixed.
> Other than that, the patch looks fine to me. You can add
> Acked-by: Raphael Assenat <raph@8d.com> to the updated patch.
>
> Please add Alessandro Zummo <a.zummo@towertech.it> in the CC list to
> make sure he sees it.
>
> Best regards,
> Raphaël Assénat
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Acked-by: Raphael Assenat <raph@8d.com>
drivers/rtc/rtc-v3020.c | 9 +++++++--
1 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/drivers/rtc/rtc-v3020.c b/drivers/rtc/rtc-v3020.c
index 3b58d3d..e96d667 100644
--- a/drivers/rtc/rtc-v3020.c
+++ b/drivers/rtc/rtc-v3020.c
@@ -26,6 +26,7 @@
#include <linux/types.h>
#include <linux/bcd.h>
#include <linux/rtc-v3020.h>
+#include <linux/delay.h>
#include <asm/io.h>
@@ -47,6 +48,7 @@ static void v3020_set_reg(struct v3020 *chip, unsigned char
address,
for (i = 0; i < 4; i++) {
writel((tmp & 1) << chip->leftshift, chip->ioaddress);
tmp >>= 1;
+ udelay(1);
}
/* Commands dont have data */
@@ -54,6 +56,7 @@ static void v3020_set_reg(struct v3020 *chip, unsigned char
address,
for (i = 0; i < 8; i++) {
writel((data & 1) << chip->leftshift, chip->ioaddress);
data >>= 1;
+ udelay(1);
}
}
}
@@ -66,12 +69,14 @@ static unsigned char v3020_get_reg(struct v3020 *chip,
unsigned char address)
for (i = 0; i < 4; i++) {
writel((address & 1) << chip->leftshift, chip->ioaddress);
address >>= 1;
+ udelay(1);
}
for (i = 0; i < 8; i++) {
data >>= 1;
if (readl(chip->ioaddress) & (1 << chip->leftshift))
data |= 0x80;
+ udelay(1);
}
return data;
@@ -95,7 +100,7 @@ static int v3020_read_time(struct device *dev, struct
rtc_time *dt)
tmp = v3020_get_reg(chip, V3020_MONTH_DAY);
dt->tm_mday = BCD2BIN(tmp);
tmp = v3020_get_reg(chip, V3020_MONTH);
- dt->tm_mon = BCD2BIN(tmp);
+ dt->tm_mon = BCD2BIN(tmp) - 1;
tmp = v3020_get_reg(chip, V3020_WEEK_DAY);
dt->tm_wday = BCD2BIN(tmp);
tmp = v3020_get_reg(chip, V3020_YEAR);
@@ -135,7 +140,7 @@ static int v3020_set_time(struct device *dev, struct
rtc_time *dt)
v3020_set_reg(chip, V3020_MINUTES, BIN2BCD(dt->tm_min));
v3020_set_reg(chip, V3020_HOURS, BIN2BCD(dt->tm_hour));
v3020_set_reg(chip, V3020_MONTH_DAY, BIN2BCD(dt->tm_mday));
- v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon));
+ v3020_set_reg(chip, V3020_MONTH, BIN2BCD(dt->tm_mon + 1));
v3020_set_reg(chip, V3020_WEEK_DAY, BIN2BCD(dt->tm_wday));
v3020_set_reg(chip, V3020_YEAR, BIN2BCD(dt->tm_year % 100));
--
Sincerely yours,
Mike.
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH] RTC v3020 fixes
2007-08-23 6:56 ` Satyam Sharma
@ 2007-08-23 7:34 ` Mike
0 siblings, 0 replies; 6+ messages in thread
From: Mike @ 2007-08-23 7:34 UTC (permalink / raw)
To: Satyam Sharma; +Cc: LKML, Raphael Assenat, Alessandro Zummo
Satyam Sharma wrote:
> Hi,
>
>
> On Thu, 23 Aug 2007, Mike Rapoport wrote:
>
> No changelog for patch ?!
>
Ooops. The wrong file from the wrong place. Sorry for the noise.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] RTC v3020 fixes
2007-08-23 6:28 Mike Rapoport
@ 2007-08-23 6:56 ` Satyam Sharma
2007-08-23 7:34 ` Mike
0 siblings, 1 reply; 6+ messages in thread
From: Satyam Sharma @ 2007-08-23 6:56 UTC (permalink / raw)
To: Mike Rapoport; +Cc: LKML, Raphael Assenat, Alessandro Zummo
Hi,
On Thu, 23 Aug 2007, Mike Rapoport wrote:
No changelog for patch ?!
> - for ( i = 0; i < 4; i++ )
> + for ( i = 0; i < 4; i++ ) {
> writel((address << (16-i)), EMV3020_VA_RTC);
> + udelay(1);
> + }
> +
>
^ Spurious extra newline here.
> - BCD_TO_BIN(dt->tm_mon);
> + BCD_TO_BIN(dt->tm_mon - 1);
> - emv3020_set_reg(0x06, dt->tm_mon);
> + emv3020_set_reg(0x06, dt->tm_mon + 1);
Why? (looks unrelated to the udelay() fixes as well)
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH] RTC v3020 fixes
@ 2007-08-23 6:28 Mike Rapoport
2007-08-23 6:56 ` Satyam Sharma
0 siblings, 1 reply; 6+ messages in thread
From: Mike Rapoport @ 2007-08-23 6:28 UTC (permalink / raw)
To: LKML; +Cc: Raphael Assenat, Alessandro Zummo
Signed-off-by: Mike Rapoport <mike@compulab.co.il>
Acked-by: Raphael Assenat <raph@8d.com>
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);
^ permalink raw reply related [flat|nested] 6+ messages in thread
end of thread, other threads:[~2007-08-23 7:40 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-08-15 5:45 [PATCH] RTC v3020 fixes Mike Rapoport
2007-08-15 12:59 ` Raphaël Assénat
2007-08-15 14:02 ` Mike Rapoport
2007-08-23 6:28 Mike Rapoport
2007-08-23 6:56 ` Satyam Sharma
2007-08-23 7:34 ` Mike
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).