diff options
| author | Paul Mackerras <paulus@samba.org> | 2006-03-28 21:24:50 -0500 |
|---|---|---|
| committer | Paul Mackerras <paulus@samba.org> | 2006-03-28 21:24:50 -0500 |
| commit | bac30d1a78d0f11c613968fc8b351a91ed465386 (patch) | |
| tree | e52f3c876522a2f6047a6ec1c27df2e8a79486b8 /arch/sh | |
| parent | e8222502ee6157e2713da9e0792c21f4ad458d50 (diff) | |
| parent | ca9ba4471c1203bb6e759b76e83167fec54fe590 (diff) | |
Merge ../linux-2.6
Diffstat (limited to 'arch/sh')
| -rw-r--r-- | arch/sh/boards/mpc1211/rtc.c | 50 | ||||
| -rw-r--r-- | arch/sh/boards/sh03/rtc.c | 13 | ||||
| -rw-r--r-- | arch/sh/kernel/cpu/rtc.c | 10 | ||||
| -rw-r--r-- | arch/sh/kernel/setup.c | 5 |
4 files changed, 20 insertions, 58 deletions
diff --git a/arch/sh/boards/mpc1211/rtc.c b/arch/sh/boards/mpc1211/rtc.c index 4d100f048072..a76c655dceee 100644 --- a/arch/sh/boards/mpc1211/rtc.c +++ b/arch/sh/boards/mpc1211/rtc.c | |||
| @@ -9,36 +9,16 @@ | |||
| 9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
| 10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
| 11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
| 12 | #include <linux/bcd.h> | ||
| 12 | #include <linux/mc146818rtc.h> | 13 | #include <linux/mc146818rtc.h> |
| 13 | 14 | ||
| 14 | #ifndef BCD_TO_BIN | ||
| 15 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
| 16 | #endif | ||
| 17 | |||
| 18 | #ifndef BIN_TO_BCD | ||
| 19 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
| 20 | #endif | ||
| 21 | |||
| 22 | /* arc/i386/kernel/time.c */ | ||
| 23 | unsigned long get_cmos_time(void) | 15 | unsigned long get_cmos_time(void) |
| 24 | { | 16 | { |
| 25 | unsigned int year, mon, day, hour, min, sec; | 17 | unsigned int year, mon, day, hour, min, sec; |
| 26 | int i; | ||
| 27 | 18 | ||
| 28 | spin_lock(&rtc_lock); | 19 | spin_lock(&rtc_lock); |
| 29 | /* The Linux interpretation of the CMOS clock register contents: | 20 | |
| 30 | * When the Update-In-Progress (UIP) flag goes from 1 to 0, the | 21 | do { |
| 31 | * RTC registers show the second which has precisely just started. | ||
| 32 | * Let's hope other operating systems interpret the RTC the same way. | ||
| 33 | */ | ||
| 34 | /* read RTC exactly on falling edge of update flag */ | ||
| 35 | for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */ | ||
| 36 | if (CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP) | ||
| 37 | break; | ||
| 38 | for (i = 0 ; i < 1000000 ; i++) /* must try at least 2.228 ms */ | ||
| 39 | if (!(CMOS_READ(RTC_FREQ_SELECT) & RTC_UIP)) | ||
| 40 | break; | ||
| 41 | do { /* Isn't this overkill ? UIP above should guarantee consistency */ | ||
| 42 | sec = CMOS_READ(RTC_SECONDS); | 22 | sec = CMOS_READ(RTC_SECONDS); |
| 43 | min = CMOS_READ(RTC_MINUTES); | 23 | min = CMOS_READ(RTC_MINUTES); |
| 44 | hour = CMOS_READ(RTC_HOURS); | 24 | hour = CMOS_READ(RTC_HOURS); |
| @@ -46,18 +26,22 @@ unsigned long get_cmos_time(void) | |||
| 46 | mon = CMOS_READ(RTC_MONTH); | 26 | mon = CMOS_READ(RTC_MONTH); |
| 47 | year = CMOS_READ(RTC_YEAR); | 27 | year = CMOS_READ(RTC_YEAR); |
| 48 | } while (sec != CMOS_READ(RTC_SECONDS)); | 28 | } while (sec != CMOS_READ(RTC_SECONDS)); |
| 49 | if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) | 29 | |
| 50 | { | 30 | if (!(CMOS_READ(RTC_CONTROL) & RTC_DM_BINARY) || RTC_ALWAYS_BCD) { |
| 51 | BCD_TO_BIN(sec); | 31 | BCD_TO_BIN(sec); |
| 52 | BCD_TO_BIN(min); | 32 | BCD_TO_BIN(min); |
| 53 | BCD_TO_BIN(hour); | 33 | BCD_TO_BIN(hour); |
| 54 | BCD_TO_BIN(day); | 34 | BCD_TO_BIN(day); |
| 55 | BCD_TO_BIN(mon); | 35 | BCD_TO_BIN(mon); |
| 56 | BCD_TO_BIN(year); | 36 | BCD_TO_BIN(year); |
| 57 | } | 37 | } |
| 38 | |||
| 58 | spin_unlock(&rtc_lock); | 39 | spin_unlock(&rtc_lock); |
| 59 | if ((year += 1900) < 1970) | 40 | |
| 41 | year += 1900; | ||
| 42 | if (year < 1970) | ||
| 60 | year += 100; | 43 | year += 100; |
| 44 | |||
| 61 | return mktime(year, mon, day, hour, min, sec); | 45 | return mktime(year, mon, day, hour, min, sec); |
| 62 | } | 46 | } |
| 63 | 47 | ||
diff --git a/arch/sh/boards/sh03/rtc.c b/arch/sh/boards/sh03/rtc.c index cbeca7037ba5..d609863cfe53 100644 --- a/arch/sh/boards/sh03/rtc.c +++ b/arch/sh/boards/sh03/rtc.c | |||
| @@ -9,6 +9,7 @@ | |||
| 9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
| 10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
| 11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
| 12 | #include <linux/bcd.h> | ||
| 12 | #include <asm/io.h> | 13 | #include <asm/io.h> |
| 13 | #include <linux/rtc.h> | 14 | #include <linux/rtc.h> |
| 14 | #include <linux/spinlock.h> | 15 | #include <linux/spinlock.h> |
| @@ -33,14 +34,6 @@ | |||
| 33 | #define RTC_BUSY 1 | 34 | #define RTC_BUSY 1 |
| 34 | #define RTC_STOP 2 | 35 | #define RTC_STOP 2 |
| 35 | 36 | ||
| 36 | #ifndef BCD_TO_BIN | ||
| 37 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
| 38 | #endif | ||
| 39 | |||
| 40 | #ifndef BIN_TO_BCD | ||
| 41 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
| 42 | #endif | ||
| 43 | |||
| 44 | extern void (*rtc_get_time)(struct timespec *); | 37 | extern void (*rtc_get_time)(struct timespec *); |
| 45 | extern int (*rtc_set_time)(const time_t); | 38 | extern int (*rtc_set_time)(const time_t); |
| 46 | extern spinlock_t rtc_lock; | 39 | extern spinlock_t rtc_lock; |
| @@ -48,13 +41,9 @@ extern spinlock_t rtc_lock; | |||
| 48 | unsigned long get_cmos_time(void) | 41 | unsigned long get_cmos_time(void) |
| 49 | { | 42 | { |
| 50 | unsigned int year, mon, day, hour, min, sec; | 43 | unsigned int year, mon, day, hour, min, sec; |
| 51 | int i; | ||
| 52 | 44 | ||
| 53 | spin_lock(&rtc_lock); | 45 | spin_lock(&rtc_lock); |
| 54 | again: | 46 | again: |
| 55 | for (i = 0 ; i < 1000000 ; i++) /* may take up to 1 second... */ | ||
| 56 | if (!(ctrl_inb(RTC_CTL) & RTC_BUSY)) | ||
| 57 | break; | ||
| 58 | do { | 47 | do { |
| 59 | sec = (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10; | 48 | sec = (ctrl_inb(RTC_SEC1) & 0xf) + (ctrl_inb(RTC_SEC10) & 0x7) * 10; |
| 60 | min = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10; | 49 | min = (ctrl_inb(RTC_MIN1) & 0xf) + (ctrl_inb(RTC_MIN10) & 0xf) * 10; |
diff --git a/arch/sh/kernel/cpu/rtc.c b/arch/sh/kernel/cpu/rtc.c index f8361f5e788b..4304cf75cfa2 100644 --- a/arch/sh/kernel/cpu/rtc.c +++ b/arch/sh/kernel/cpu/rtc.c | |||
| @@ -9,18 +9,10 @@ | |||
| 9 | #include <linux/kernel.h> | 9 | #include <linux/kernel.h> |
| 10 | #include <linux/sched.h> | 10 | #include <linux/sched.h> |
| 11 | #include <linux/time.h> | 11 | #include <linux/time.h> |
| 12 | 12 | #include <linux/bcd.h> | |
| 13 | #include <asm/io.h> | 13 | #include <asm/io.h> |
| 14 | #include <asm/rtc.h> | 14 | #include <asm/rtc.h> |
| 15 | 15 | ||
| 16 | #ifndef BCD_TO_BIN | ||
| 17 | #define BCD_TO_BIN(val) ((val)=((val)&15) + ((val)>>4)*10) | ||
| 18 | #endif | ||
| 19 | |||
| 20 | #ifndef BIN_TO_BCD | ||
| 21 | #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) | ||
| 22 | #endif | ||
| 23 | |||
| 24 | void sh_rtc_gettimeofday(struct timespec *ts) | 16 | void sh_rtc_gettimeofday(struct timespec *ts) |
| 25 | { | 17 | { |
| 26 | unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; | 18 | unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; |
diff --git a/arch/sh/kernel/setup.c b/arch/sh/kernel/setup.c index c0e79843f580..7ee4ca203616 100644 --- a/arch/sh/kernel/setup.c +++ b/arch/sh/kernel/setup.c | |||
| @@ -20,6 +20,7 @@ | |||
| 20 | #include <linux/root_dev.h> | 20 | #include <linux/root_dev.h> |
| 21 | #include <linux/utsname.h> | 21 | #include <linux/utsname.h> |
| 22 | #include <linux/cpu.h> | 22 | #include <linux/cpu.h> |
| 23 | #include <linux/pfn.h> | ||
| 23 | #include <asm/uaccess.h> | 24 | #include <asm/uaccess.h> |
| 24 | #include <asm/io.h> | 25 | #include <asm/io.h> |
| 25 | #include <asm/sections.h> | 26 | #include <asm/sections.h> |
| @@ -275,10 +276,6 @@ void __init setup_arch(char **cmdline_p) | |||
| 275 | 276 | ||
| 276 | sh_mv_setup(cmdline_p); | 277 | sh_mv_setup(cmdline_p); |
| 277 | 278 | ||
| 278 | #define PFN_UP(x) (((x) + PAGE_SIZE-1) >> PAGE_SHIFT) | ||
| 279 | #define PFN_DOWN(x) ((x) >> PAGE_SHIFT) | ||
| 280 | #define PFN_PHYS(x) ((x) << PAGE_SHIFT) | ||
| 281 | |||
| 282 | /* | 279 | /* |
| 283 | * Find the highest page frame number we have available | 280 | * Find the highest page frame number we have available |
| 284 | */ | 281 | */ |
