Hello, The RTC driver always reserves I/O port resources even if a system maps the chip in the memory space. Following is a fix allowing a system to select I/O memory resources. OK to apply? Maciej -- + Maciej W. Rozycki, Technical University of Gdansk, Poland + +--------------------------------------------------------------+ + e-mail: macro@ds2.pg.gda.pl, PGP key available + patch-mips-2.4.19-rc1-20020826-dec-rtc-5 diff -up --recursive --new-file linux-mips-2.4.19-rc1-20020826.macro/drivers/char/rtc.c linux-mips-2.4.19-rc1-20020826/drivers/char/rtc.c --- linux-mips-2.4.19-rc1-20020826.macro/drivers/char/rtc.c 2002-06-27 02:58:17.000000000 +0000 +++ linux-mips-2.4.19-rc1-20020826/drivers/char/rtc.c 2002-08-26 10:09:22.000000000 +0000 @@ -41,11 +41,10 @@ * 1.10c Cesar Barros: SMP locking fixes and cleanup * 1.10d Paul Gortmaker: delete paranoia check in rtc_exit * 1.10e Maciej W. Rozycki: Handle DECstation's year weirdness. + * 1.10f Maciej W. Rozycki: Handle memory-mapped chips properly. */ -#define RTC_VERSION "1.10e" - -#define RTC_IO_EXTENT 0x10 /* Only really two ports, but... */ +#define RTC_VERSION "1.10f" /* * Note that *all* calls to CMOS_READ and CMOS_WRITE are done with @@ -83,7 +82,9 @@ static unsigned long rtc_port; static int rtc_irq = PCI_IRQ_NONE; #endif +#if RTC_IRQ static int rtc_has_irq = 1; +#endif /* * We sponge a minor off of the misc major. No need slurping @@ -96,7 +97,9 @@ static struct fasync_struct *rtc_async_q static DECLARE_WAIT_QUEUE_HEAD(rtc_wait); +#if RTC_IRQ static struct timer_list rtc_irq_timer; +#endif static ssize_t rtc_read(struct file *file, char *buf, size_t count, loff_t *ppos); @@ -720,6 +723,9 @@ static int __init rtc_init(void) struct isa_device *isa_dev; #endif #endif +#ifndef __sparc__ + int r; +#endif #ifdef __sparc__ for_each_ebus(ebus) { @@ -766,9 +772,13 @@ found: } no_irq: #else - if (!request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc")) + if (RTC_IOMAPPED) + r = request_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); + else + r = request_mem_region(RTC_PORT(0), RTC_IO_EXTENT, "rtc"); + if (!r) { - printk(KERN_ERR "rtc: I/O port %d is not free.\n", RTC_PORT (0)); + printk(KERN_ERR "rtc: I/O resource %d is not free.\n", RTC_PORT (0)); return -EIO; } @@ -777,7 +787,10 @@ no_irq: { /* Yeah right, seeing as irq 8 doesn't even hit the bus. */ printk(KERN_ERR "rtc: IRQ %d is not free.\n", RTC_IRQ); - release_region(RTC_PORT(0), RTC_IO_EXTENT); + if (RTC_IOMAPPED) + release_region(RTC_PORT(0), RTC_IO_EXTENT); + else + release_mem_region(RTC_PORT(0), RTC_IO_EXTENT); return -EIO; } #endif @@ -861,7 +874,10 @@ static void __exit rtc_exit (void) if (rtc_has_irq) free_irq (rtc_irq, &rtc_port); #else - release_region (RTC_PORT (0), RTC_IO_EXTENT); + if (RTC_IOMAPPED) + release_region(RTC_PORT(0), RTC_IO_EXTENT); + else + release_mem_region(RTC_PORT(0), RTC_IO_EXTENT); #if RTC_IRQ if (rtc_has_irq) free_irq (RTC_IRQ, NULL); diff -up --recursive --new-file linux-mips-2.4.19-rc1-20020826.macro/include/asm-mips/mc146818rtc.h linux-mips-2.4.19-rc1-20020826/include/asm-mips/mc146818rtc.h --- linux-mips-2.4.19-rc1-20020826.macro/include/asm-mips/mc146818rtc.h 2002-07-15 02:58:45.000000000 +0000 +++ linux-mips-2.4.19-rc1-20020826/include/asm-mips/mc146818rtc.h 2002-08-26 13:01:51.000000000 +0000 @@ -6,26 +6,37 @@ * Machine dependent access functions for RTC registers. * * Copyright (C) 1996, 1997, 1998, 2000 Ralf Baechle + * Copyright (C) 2002 Maciej W. Rozycki */ #ifndef _ASM_MC146818RTC_H #define _ASM_MC146818RTC_H #include <linux/config.h> + +#include <asm/addrspace.h> #include <asm/io.h> -#ifndef RTC_PORT -#if defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) +#ifdef CONFIG_DECSTATION +extern char *dec_rtc_base; +#define RTC_PORT(x) CPHYSADDR(dec_rtc_base) +#define RTC_IO_EXTENT 0x100 +#define RTC_IOMAPPED 0 +#elif defined(CONFIG_MIPS_ITE8172) || defined(CONFIG_MIPS_IVR) #define RTC_PORT(x) (0x14014800 + (x)) +#define RTC_IOMAPPED 0 #elif defined(CONFIG_MIPS_PB1500) || defined(CONFIG_MIPS_PB1100) -#define RTC_PORT(x) (0xAC000000 + (x)) +#define RTC_PORT(x) (0x0c000000 + (x)) +#define RTC_IOMAPPED 0 #else #define RTC_PORT(x) (0x70 + (x)) #endif -#endif /* - * The yet supported machines all access the RTC index register via - * an ISA port access but the way to access the date register differs ... + * Most supported machines access the RTC index register via an ISA + * port access but the way to access the date register differs ... + * The DECstation directly maps the RTC memory in the CPU's address + * space with the chipset generating necessary index write/data access + * cycles automagically. */ #define CMOS_READ(addr) ({ \ rtc_ops->rtc_read_data(addr); \ diff -up --recursive --new-file linux-mips-2.4.19-rc1-20020826.macro/include/linux/mc146818rtc.h linux-mips-2.4.19-rc1-20020826/include/linux/mc146818rtc.h --- linux-mips-2.4.19-rc1-20020826.macro/include/linux/mc146818rtc.h 2001-08-27 04:27:42.000000000 +0000 +++ linux-mips-2.4.19-rc1-20020826/include/linux/mc146818rtc.h 2002-08-26 10:06:46.000000000 +0000 @@ -98,4 +98,12 @@ extern spinlock_t rtc_lock; /* serializ #define BIN_TO_BCD(val) ((val)=(((val)/10)<<4) + (val)%10) #endif +#ifndef RTC_IO_EXTENT +#define RTC_IO_EXTENT 0x10 /* Only really two ports, but... */ +#endif + +#ifndef RTC_IOMAPPED +#define RTC_IOMAPPED 1 /* Default to I/O mapping. */ +#endif + #endif /* _MC146818RTC_H */