Loading arch/sh/Kconfig +0 −13 Original line number Diff line number Diff line Loading @@ -296,19 +296,6 @@ config CPU_LITTLE_ENDIAN endian byte order. These modes require different kernels. Say Y if your machine is little endian, N if it's a big endian machine. # The SH7750 RTC module is disabled in the Dreamcast config SH_RTC bool depends on !SH_DREAMCAST && !SH_SATURN && !SH_7300_SOLUTION_ENGINE && \ !SH_73180_SOLUTION_ENGINE && !SH_LANDISK && \ !SH_R7780RP && !SH_SHMIN default y help Selecting this option will allow the Linux kernel to emulate PC's RTC. If unsure, say N. config SH_FPU bool "FPU support" depends on !CPU_SH3 Loading arch/sh/boards/snapgear/rtc.c +3 −24 Original line number Diff line number Diff line Loading @@ -19,9 +19,7 @@ #include <linux/mc146818rtc.h> #include <asm/io.h> /****************************************************************************/ static int use_ds1302 = 0; static int use_ds1302; /****************************************************************************/ /* Loading Loading @@ -79,10 +77,6 @@ static unsigned int ds1302_readbyte(unsigned int addr) unsigned int val; unsigned long flags; #if 0 printk("SnapGear RTC: ds1302_readbyte(addr=%x)\n", addr); #endif local_irq_save(flags); set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK); set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); Loading @@ -101,10 +95,6 @@ static void ds1302_writebyte(unsigned int addr, unsigned int val) { unsigned long flags; #if 0 printk("SnapGear RTC: ds1302_writebyte(addr=%x)\n", addr); #endif local_irq_save(flags); set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK); set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); Loading Loading @@ -167,9 +157,6 @@ void __init secureedge5410_rtc_init(void) if (use_ds1302) { rtc_sh_get_time = snapgear_rtc_gettimeofday; rtc_sh_set_time = snapgear_rtc_settimeofday; } else { rtc_sh_get_time = sh_rtc_gettimeofday; rtc_sh_set_time = sh_rtc_settimeofday; } printk("SnapGear RTC: using %s rtc.\n", use_ds1302 ? "ds1302" : "internal"); Loading @@ -184,10 +171,8 @@ void snapgear_rtc_gettimeofday(struct timespec *ts) { unsigned int sec, min, hr, day, mon, yr; if (!use_ds1302) { sh_rtc_gettimeofday(ts); if (!use_ds1302) return; } sec = bcd2int(ds1302_readbyte(RTC_ADDR_SEC)); min = bcd2int(ds1302_readbyte(RTC_ADDR_MIN)); Loading Loading @@ -228,7 +213,7 @@ int snapgear_rtc_settimeofday(const time_t secs) unsigned long nowtime; if (!use_ds1302) return sh_rtc_settimeofday(secs); return 0; /* * This is called direct from the kernel timer handling code. Loading @@ -237,10 +222,6 @@ int snapgear_rtc_settimeofday(const time_t secs) nowtime = secs; #if 1 printk("SnapGear RTC: snapgear_rtc_settimeofday(nowtime=%ld)\n", nowtime); #endif /* STOP RTC */ ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); Loading Loading @@ -326,5 +307,3 @@ void secureedge5410_cmos_write(unsigned char val, int addr) default: break; } } /****************************************************************************/ arch/sh/kernel/cpu/Makefile +0 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,5 @@ obj-$(CONFIG_CPU_SH2) += sh2/ obj-$(CONFIG_CPU_SH3) += sh3/ obj-$(CONFIG_CPU_SH4) += sh4/ obj-$(CONFIG_SH_RTC) += rtc.o obj-$(CONFIG_UBC_WAKEUP) += ubc.o obj-$(CONFIG_SH_ADC) += adc.o arch/sh/kernel/cpu/irq/ipr.c +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ void __init init_IRQ(void) #ifndef CONFIG_CPU_SUBTYPE_SH7780 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY); make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY); #if defined(CONFIG_SH_RTC) #ifdef RTC_IRQ make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY); #endif Loading arch/sh/kernel/cpu/rtc.cdeleted 100644 → 0 +0 −128 Original line number Diff line number Diff line /* * linux/arch/sh/kernel/rtc.c -- SH3 / SH4 on-chip RTC support * * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka */ #include <linux/init.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/time.h> #include <linux/bcd.h> #include <asm/io.h> #include <asm/rtc.h> void sh_rtc_gettimeofday(struct timespec *ts) { unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; unsigned long flags; again: do { local_irq_save(flags); ctrl_outb(0, RCR1); /* Clear CF-bit */ sec128 = ctrl_inb(R64CNT); sec = ctrl_inb(RSECCNT); min = ctrl_inb(RMINCNT); hr = ctrl_inb(RHRCNT); wk = ctrl_inb(RWKCNT); day = ctrl_inb(RDAYCNT); mon = ctrl_inb(RMONCNT); #if defined(CONFIG_CPU_SH4) yr = ctrl_inw(RYRCNT); yr100 = (yr >> 8); yr &= 0xff; #else yr = ctrl_inb(RYRCNT); yr100 = (yr == 0x99) ? 0x19 : 0x20; #endif sec2 = ctrl_inb(R64CNT); cf_bit = ctrl_inb(RCR1) & RCR1_CF; local_irq_restore(flags); } while (cf_bit != 0 || ((sec128 ^ sec2) & RTC_BIT_INVERTED) != 0); BCD_TO_BIN(yr100); BCD_TO_BIN(yr); BCD_TO_BIN(mon); BCD_TO_BIN(day); BCD_TO_BIN(hr); BCD_TO_BIN(min); BCD_TO_BIN(sec); if (yr > 99 || mon < 1 || mon > 12 || day > 31 || day < 1 || hr > 23 || min > 59 || sec > 59) { printk(KERN_ERR "SH RTC: invalid value, resetting to 1 Jan 2000\n"); local_irq_save(flags); ctrl_outb(RCR2_RESET, RCR2); /* Reset & Stop */ ctrl_outb(0, RSECCNT); ctrl_outb(0, RMINCNT); ctrl_outb(0, RHRCNT); ctrl_outb(6, RWKCNT); ctrl_outb(1, RDAYCNT); ctrl_outb(1, RMONCNT); #if defined(CONFIG_CPU_SH4) ctrl_outw(0x2000, RYRCNT); #else ctrl_outb(0, RYRCNT); #endif ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start */ goto again; } #if RTC_BIT_INVERTED != 0 if ((sec128 & RTC_BIT_INVERTED)) sec--; #endif ts->tv_sec = mktime(yr100 * 100 + yr, mon, day, hr, min, sec); ts->tv_nsec = ((sec128 * 1000000) / 128) * 1000; } /* * Changed to only care about tv_sec, and not the full timespec struct * (i.e. tv_nsec). It can easily be switched to timespec for future cpus * that support setting usec or nsec RTC values. */ int sh_rtc_settimeofday(const time_t secs) { int retval = 0; int real_seconds, real_minutes, cmos_minutes; unsigned long flags; local_irq_save(flags); ctrl_outb(RCR2_RESET, RCR2); /* Reset pre-scaler & stop RTC */ cmos_minutes = ctrl_inb(RMINCNT); BCD_TO_BIN(cmos_minutes); /* * since we're only adjusting minutes and seconds, * don't interfere with hour overflow. This avoids * messing with unknown time zones but requires your * RTC not to be off by more than 15 minutes */ real_seconds = secs % 60; real_minutes = secs / 60; if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1) real_minutes += 30; /* correct for half hour time zone */ real_minutes %= 60; if (abs(real_minutes - cmos_minutes) < 30) { BIN_TO_BCD(real_seconds); BIN_TO_BCD(real_minutes); ctrl_outb(real_seconds, RSECCNT); ctrl_outb(real_minutes, RMINCNT); } else { printk(KERN_WARNING "set_rtc_time: can't update from %d to %d\n", cmos_minutes, real_minutes); retval = -1; } ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start RTC */ local_irq_restore(flags); return retval; } Loading
arch/sh/Kconfig +0 −13 Original line number Diff line number Diff line Loading @@ -296,19 +296,6 @@ config CPU_LITTLE_ENDIAN endian byte order. These modes require different kernels. Say Y if your machine is little endian, N if it's a big endian machine. # The SH7750 RTC module is disabled in the Dreamcast config SH_RTC bool depends on !SH_DREAMCAST && !SH_SATURN && !SH_7300_SOLUTION_ENGINE && \ !SH_73180_SOLUTION_ENGINE && !SH_LANDISK && \ !SH_R7780RP && !SH_SHMIN default y help Selecting this option will allow the Linux kernel to emulate PC's RTC. If unsure, say N. config SH_FPU bool "FPU support" depends on !CPU_SH3 Loading
arch/sh/boards/snapgear/rtc.c +3 −24 Original line number Diff line number Diff line Loading @@ -19,9 +19,7 @@ #include <linux/mc146818rtc.h> #include <asm/io.h> /****************************************************************************/ static int use_ds1302 = 0; static int use_ds1302; /****************************************************************************/ /* Loading Loading @@ -79,10 +77,6 @@ static unsigned int ds1302_readbyte(unsigned int addr) unsigned int val; unsigned long flags; #if 0 printk("SnapGear RTC: ds1302_readbyte(addr=%x)\n", addr); #endif local_irq_save(flags); set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK); set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); Loading @@ -101,10 +95,6 @@ static void ds1302_writebyte(unsigned int addr, unsigned int val) { unsigned long flags; #if 0 printk("SnapGear RTC: ds1302_writebyte(addr=%x)\n", addr); #endif local_irq_save(flags); set_dirp(get_dirp() | RTC_RESET | RTC_IODATA | RTC_SCLK); set_dp(get_dp() & ~(RTC_RESET | RTC_IODATA | RTC_SCLK)); Loading Loading @@ -167,9 +157,6 @@ void __init secureedge5410_rtc_init(void) if (use_ds1302) { rtc_sh_get_time = snapgear_rtc_gettimeofday; rtc_sh_set_time = snapgear_rtc_settimeofday; } else { rtc_sh_get_time = sh_rtc_gettimeofday; rtc_sh_set_time = sh_rtc_settimeofday; } printk("SnapGear RTC: using %s rtc.\n", use_ds1302 ? "ds1302" : "internal"); Loading @@ -184,10 +171,8 @@ void snapgear_rtc_gettimeofday(struct timespec *ts) { unsigned int sec, min, hr, day, mon, yr; if (!use_ds1302) { sh_rtc_gettimeofday(ts); if (!use_ds1302) return; } sec = bcd2int(ds1302_readbyte(RTC_ADDR_SEC)); min = bcd2int(ds1302_readbyte(RTC_ADDR_MIN)); Loading Loading @@ -228,7 +213,7 @@ int snapgear_rtc_settimeofday(const time_t secs) unsigned long nowtime; if (!use_ds1302) return sh_rtc_settimeofday(secs); return 0; /* * This is called direct from the kernel timer handling code. Loading @@ -237,10 +222,6 @@ int snapgear_rtc_settimeofday(const time_t secs) nowtime = secs; #if 1 printk("SnapGear RTC: snapgear_rtc_settimeofday(nowtime=%ld)\n", nowtime); #endif /* STOP RTC */ ds1302_writebyte(RTC_ADDR_SEC, ds1302_readbyte(RTC_ADDR_SEC) | 0x80); Loading Loading @@ -326,5 +307,3 @@ void secureedge5410_cmos_write(unsigned char val, int addr) default: break; } } /****************************************************************************/
arch/sh/kernel/cpu/Makefile +0 −1 Original line number Diff line number Diff line Loading @@ -8,6 +8,5 @@ obj-$(CONFIG_CPU_SH2) += sh2/ obj-$(CONFIG_CPU_SH3) += sh3/ obj-$(CONFIG_CPU_SH4) += sh4/ obj-$(CONFIG_SH_RTC) += rtc.o obj-$(CONFIG_UBC_WAKEUP) += ubc.o obj-$(CONFIG_SH_ADC) += adc.o
arch/sh/kernel/cpu/irq/ipr.c +1 −1 Original line number Diff line number Diff line Loading @@ -124,7 +124,7 @@ void __init init_IRQ(void) #ifndef CONFIG_CPU_SUBTYPE_SH7780 make_ipr_irq(TIMER_IRQ, TIMER_IPR_ADDR, TIMER_IPR_POS, TIMER_PRIORITY); make_ipr_irq(TIMER1_IRQ, TIMER1_IPR_ADDR, TIMER1_IPR_POS, TIMER1_PRIORITY); #if defined(CONFIG_SH_RTC) #ifdef RTC_IRQ make_ipr_irq(RTC_IRQ, RTC_IPR_ADDR, RTC_IPR_POS, RTC_PRIORITY); #endif Loading
arch/sh/kernel/cpu/rtc.cdeleted 100644 → 0 +0 −128 Original line number Diff line number Diff line /* * linux/arch/sh/kernel/rtc.c -- SH3 / SH4 on-chip RTC support * * Copyright (C) 2000 Philipp Rumpf <prumpf@tux.org> * Copyright (C) 1999 Tetsuya Okada & Niibe Yutaka */ #include <linux/init.h> #include <linux/kernel.h> #include <linux/sched.h> #include <linux/time.h> #include <linux/bcd.h> #include <asm/io.h> #include <asm/rtc.h> void sh_rtc_gettimeofday(struct timespec *ts) { unsigned int sec128, sec, sec2, min, hr, wk, day, mon, yr, yr100, cf_bit; unsigned long flags; again: do { local_irq_save(flags); ctrl_outb(0, RCR1); /* Clear CF-bit */ sec128 = ctrl_inb(R64CNT); sec = ctrl_inb(RSECCNT); min = ctrl_inb(RMINCNT); hr = ctrl_inb(RHRCNT); wk = ctrl_inb(RWKCNT); day = ctrl_inb(RDAYCNT); mon = ctrl_inb(RMONCNT); #if defined(CONFIG_CPU_SH4) yr = ctrl_inw(RYRCNT); yr100 = (yr >> 8); yr &= 0xff; #else yr = ctrl_inb(RYRCNT); yr100 = (yr == 0x99) ? 0x19 : 0x20; #endif sec2 = ctrl_inb(R64CNT); cf_bit = ctrl_inb(RCR1) & RCR1_CF; local_irq_restore(flags); } while (cf_bit != 0 || ((sec128 ^ sec2) & RTC_BIT_INVERTED) != 0); BCD_TO_BIN(yr100); BCD_TO_BIN(yr); BCD_TO_BIN(mon); BCD_TO_BIN(day); BCD_TO_BIN(hr); BCD_TO_BIN(min); BCD_TO_BIN(sec); if (yr > 99 || mon < 1 || mon > 12 || day > 31 || day < 1 || hr > 23 || min > 59 || sec > 59) { printk(KERN_ERR "SH RTC: invalid value, resetting to 1 Jan 2000\n"); local_irq_save(flags); ctrl_outb(RCR2_RESET, RCR2); /* Reset & Stop */ ctrl_outb(0, RSECCNT); ctrl_outb(0, RMINCNT); ctrl_outb(0, RHRCNT); ctrl_outb(6, RWKCNT); ctrl_outb(1, RDAYCNT); ctrl_outb(1, RMONCNT); #if defined(CONFIG_CPU_SH4) ctrl_outw(0x2000, RYRCNT); #else ctrl_outb(0, RYRCNT); #endif ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start */ goto again; } #if RTC_BIT_INVERTED != 0 if ((sec128 & RTC_BIT_INVERTED)) sec--; #endif ts->tv_sec = mktime(yr100 * 100 + yr, mon, day, hr, min, sec); ts->tv_nsec = ((sec128 * 1000000) / 128) * 1000; } /* * Changed to only care about tv_sec, and not the full timespec struct * (i.e. tv_nsec). It can easily be switched to timespec for future cpus * that support setting usec or nsec RTC values. */ int sh_rtc_settimeofday(const time_t secs) { int retval = 0; int real_seconds, real_minutes, cmos_minutes; unsigned long flags; local_irq_save(flags); ctrl_outb(RCR2_RESET, RCR2); /* Reset pre-scaler & stop RTC */ cmos_minutes = ctrl_inb(RMINCNT); BCD_TO_BIN(cmos_minutes); /* * since we're only adjusting minutes and seconds, * don't interfere with hour overflow. This avoids * messing with unknown time zones but requires your * RTC not to be off by more than 15 minutes */ real_seconds = secs % 60; real_minutes = secs / 60; if (((abs(real_minutes - cmos_minutes) + 15)/30) & 1) real_minutes += 30; /* correct for half hour time zone */ real_minutes %= 60; if (abs(real_minutes - cmos_minutes) < 30) { BIN_TO_BCD(real_seconds); BIN_TO_BCD(real_minutes); ctrl_outb(real_seconds, RSECCNT); ctrl_outb(real_minutes, RMINCNT); } else { printk(KERN_WARNING "set_rtc_time: can't update from %d to %d\n", cmos_minutes, real_minutes); retval = -1; } ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start RTC */ local_irq_restore(flags); return retval; }