X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=arch%2Fsh%2Fboards%2Fsh03%2Frtc.c;h=cbeca7037ba562321c3607e3b83d493d71ea2356;hb=987b0145d94eecf292d8b301228356f44611ab7c;hp=d609863cfe53fba5ba3068da2d1d78a95d2bade5;hpb=f7ed79d23a47594e7834d66a8f14449796d4f3e6;p=linux-2.6.git diff --git a/arch/sh/boards/sh03/rtc.c b/arch/sh/boards/sh03/rtc.c index d609863cf..cbeca7037 100644 --- a/arch/sh/boards/sh03/rtc.c +++ b/arch/sh/boards/sh03/rtc.c @@ -9,7 +9,6 @@ #include #include #include -#include #include #include #include @@ -34,6 +33,14 @@ #define RTC_BUSY 1 #define RTC_STOP 2 +#ifndef BCD_TO_BIN +#define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) +#endif + +#ifndef BIN_TO_BCD +#define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) +#endif + extern void (*rtc_get_time)(struct timespec *); extern int (*rtc_set_time)(const time_t); extern spinlock_t rtc_lock; @@ -41,9 +48,13 @@ extern spinlock_t rtc_lock; unsigned long get_cmos_time(void) { unsigned int year, mon, day, hour, min, sec; + int i; spin_lock(&rtc_lock); again: + for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */ + if (!(ctrl_inb(RTC_CTL) & RTC_BUSY)) + break; do { sec = (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10; min = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10;