From: NIIBE Y. <gn...@m1...> - 2001-12-12 00:41:52
|
I'll send following patch to Marcelo for inclusion of 2.4 mainline. Note that I've added two changes over yesterday's patch. One is SUGIOKA-san's patch for RTC fix, and another is commenting out maple/Config.in in config.in (it results error as we don't have it in mainline yet). -------------------------- * Documentation for adding new machine (Stuart Menefy) Documentation/sh/new-machine.txt * Follows PCI interface update (Jeremy Siegel) include/asm-sh/pci.h * Configuration fix (Jeremy Siegel, NIIBE Yutaka) arch/sh/config.in * Solution Engine 7751 update (Jeremy Siegel) arch/sh/kernel/io_7751se.c arch/sh/kernel/pci-7751se.c * Big endian support fixes (Jeremy Siegel, Tomoyoshi ASANO) include/asm-sh/stat.h include/asm-sh/uaccess.h * SuperH watch dog timer fix (Paul Mundt) drivers/char/shwdt.c * Follow new interface of sched.c (will implement later) arch/sh/kernel/traps.c * RTC fix (SUGIOKA Toshinobu) arch/sh/kernel/rtc.c diff -ruN3p v2.4.17-pre8/Documentation/sh/new-machine.txt linux/Documentation/sh/new-machine.txt --- v2.4.17-pre8/Documentation/sh/new-machine.txt Thu Jan 1 09:00:00 1970 +++ linux/Documentation/sh/new-machine.txt Tue Dec 11 15:52:33 2001 @@ -0,0 +1,77 @@ +The multiple machine support relies on redirecting all functions which will +need to be machine specific through a table of function pointers, the +machvec. These functions fall into a number of categories: + + - I/O functions to IO memory (inb etc) and PCI/main memory (readb etc). + - I/O remapping functions (ioremap etc) + - some initialisation functions + - a 'heartbeat' function + - some miscellaneous flags + +The tree can be built in two ways: + - as a fully generic build. All drivers are linked in, and all functions + go through the machvec + - as a machine specific build. In this case only the required drivers + will be linked in, and some macros may be redefined to not go through + the machvec where performance is important (in particular IO functions). + +There are three ways in which IO can be performed: + - none at all. This is really only useful for the 'unknown' machine type, + which us designed to run on a machine about which we know nothing, and + so all all IO instructions do nothing. + - fully custom. In this case all IO functions go to a machine specific + set of functions which can do what they like + - a generic set of functions. These will cope with most situations, + and rely on a single function, mv_port2addr, which is called through the + machine vector, and converts an IO address into a memory address, which + can be read from/written to directly. + +Thus adding a new machine involves the following steps (I will assume I am +adding a machine called fred): + + - add a new file include/asm-sh/io_fred.h which contains prototypes for + any machine specific IO functions prefixed with the machine name, for + example fred_inb. These will be needed when filling out the machine + vector. In addition, a section is required which defines what to do when + building a machine specific version. For example: + + #ifdef __WANT_IO_DEF + #define inb fred_inb + ... + #endif + + This is the minimum that is required, however there are ample + opportunities to optimise this. In particular, by making the prototypes + inline function definitions, it is possible to inline the function when + building machine specific versions. Note that the machine vector + functions will still be needed, so that a module built for a generic + setup can be loaded. + + - add a new file arch/sh/kernel/mach_fred.c. This contains the definition + of the machine vector. When building the machine specific version, this + will be the real machine vector (via an alias), while in the generic + version is used to initialise the machine vector, and then freed, by + making it initdata. This should be defined as: + + struct sh_machine_vector mv_fred __initmv = { + mv_name: "Fred" + } + ALIAS_MV(se) + + - finally add a file arch/sh/kernel/io_fred.c, which contains + definitions of the machine specific io functions. + +A note about initialisation functions. Three initialisation functions are +provided in the machine vector: + - mv_arch_init - called very early on from setup_arch + - mv_init_irq - called from init_IRQ, after the generic SH interrupt + initialisation + - mv_init_pci - currently not used + +Any other remaining functions which need to be called at start up can be +added to the list using the __initcalls macro (or module_init if the code +can be built as a module). Many generic drivers probe to see if the device +they are targeting is present, however this may not always be appropriate, +so a flag can be added to the machine vector which will be set on those +machines which have the hardware in question, reducing the probe to a +single conditional. diff -ruN3p v2.4.17-pre8/arch/sh/config.in linux/arch/sh/config.in --- v2.4.17-pre8/arch/sh/config.in Tue Oct 16 05:36:48 2001 +++ linux/arch/sh/config.in Wed Dec 12 09:22:08 2001 @@ -189,7 +189,7 @@ if [ "$CONFIG_PCI" = "y" ]; then if [ "$CONFIG_PCI_GODIRECT" = "y" -o "$CONFIG_PCI_GOANY" = "y" ]; then define_bool CONFIG_PCI_DIRECT y fi - define_bool CONFIG_SH_PCIDMA_NONCOHERENT n + bool 'Cache and PCI noncoherent' CONFIG_SH_PCIDMA_NONCOHERENT n fi source drivers/pci/Config.in @@ -280,9 +280,9 @@ endmenu # source drivers/input/Config.in -if [ "$CONFIG_SH_DREAMCAST" = "y" ]; then - source drivers/maple/Config.in -fi +# if [ "$CONFIG_SH_DREAMCAST" = "y" ]; then +# source drivers/maple/Config.in +# fi mainmenu_option next_comment comment 'Character devices' diff -ruN3p v2.4.17-pre8/arch/sh/kernel/io_7751se.c linux/arch/sh/kernel/io_7751se.c --- v2.4.17-pre8/arch/sh/kernel/io_7751se.c Sun Sep 9 04:29:09 2001 +++ linux/arch/sh/kernel/io_7751se.c Tue Dec 11 15:52:33 2001 @@ -17,7 +17,7 @@ #include <asm/hitachi_7751se.h> #include <asm/addrspace.h> -#include <asm/pci.h> +#include <linux/pci.h> #include <asm/pci-sh7751.h> #if 0 @@ -70,7 +70,7 @@ port2adr(unsigned int port) else return (volatile __u16 *) (PA_SUPERIO + (port << 1)); #endif - maybebadio(name,port); + maybebadio(name,(unsigned long)port); return (volatile __u16*)port; } @@ -276,6 +276,7 @@ void sh7751se_writel(unsigned int b, uns /* ISA page descriptor. */ static __u32 sh_isa_memmap[256]; +#if 0 static int sh_isa_mmap(__u32 start, __u32 length, __u32 offset) { @@ -286,12 +287,11 @@ sh_isa_mmap(__u32 start, __u32 length, _ idx = start >> 12; sh_isa_memmap[idx] = 0xb8000000 + (offset &~ 0xfff); -#if 0 printk("sh_isa_mmap: start %x len %x offset %x (idx %x paddr %x)\n", start, length, offset, idx, sh_isa_memmap[idx]); -#endif return 0; } +#endif unsigned long sh7751se_isa_port2addr(unsigned long offset) diff -ruN3p v2.4.17-pre8/arch/sh/kernel/pci-7751se.c linux/arch/sh/kernel/pci-7751se.c --- v2.4.17-pre8/arch/sh/kernel/pci-7751se.c Sun Sep 9 04:29:09 2001 +++ linux/arch/sh/kernel/pci-7751se.c Tue Dec 11 15:52:33 2001 @@ -37,7 +37,6 @@ */ int __init pcibios_init_platform(void) { - unsigned long data; unsigned long bcr1, wcr1, wcr2, wcr3, mcr; unsigned short bcr2; diff -ruN3p v2.4.17-pre8/arch/sh/kernel/rtc.c linux/arch/sh/kernel/rtc.c --- v2.4.17-pre8/arch/sh/kernel/rtc.c Thu Jun 28 05:55:29 2001 +++ linux/arch/sh/kernel/rtc.c Wed Dec 12 09:17:30 2001 @@ -46,7 +46,7 @@ void sh_rtc_gettimeofday(struct timeval } while ((ctrl_inb(RCR1) & RCR1_CF) != 0); #if RTC_BIT_INVERTED != 0 - /* Work around to avoid reading correct value. */ + /* Work around to avoid reading incorrect value. */ if (sec128 == RTC_BIT_INVERTED) { schedule_timeout(1); goto again; @@ -61,6 +61,11 @@ void sh_rtc_gettimeofday(struct timeval BCD_TO_BIN(min); BCD_TO_BIN(sec); +#if RTC_BIT_INVERTED != 0 + if ((sec128 & RTC_BIT_INVERTED)) + sec--; +#endif + if (yr > 99 || mon < 1 || mon > 12 || day > 31 || day < 1 || hr > 23 || min > 59 || sec > 59) { printk(KERN_ERR @@ -82,11 +87,12 @@ void sh_rtc_gettimeofday(struct timeval } tv->tv_sec = mktime(yr100 * 100 + yr, mon, day, hr, min, sec); - tv->tv_usec = ((sec128 ^ RTC_BIT_INVERTED) * 1000000) / 128; + tv->tv_usec = (sec128 * 1000000) / 128; } -static int set_rtc_time(unsigned long nowtime) +int sh_rtc_settimeofday(const struct timeval *tv) { + unsigned long nowtime = tv->tv_sec; int retval = 0; int real_seconds, real_minutes, cmos_minutes; @@ -122,13 +128,4 @@ static int set_rtc_time(unsigned long no ctrl_outb(RCR2_RTCEN|RCR2_START, RCR2); /* Start RTC */ return retval; -} - -int sh_rtc_settimeofday(const struct timeval *tv) -{ -#if RTC_BIT_INVERTED != 0 - /* This is not accurate, but better than nothing. */ - schedule_timeout(HZ/2); -#endif - return set_rtc_time(tv->tv_sec); } diff -ruN3p v2.4.17-pre8/drivers/char/shwdt.c linux/drivers/char/shwdt.c --- v2.4.17-pre8/drivers/char/shwdt.c Tue Oct 16 05:36:48 2001 +++ linux/drivers/char/shwdt.c Tue Dec 11 15:52:33 2001 @@ -10,7 +10,6 @@ * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ - #include <linux/config.h> #include <linux/module.h> #include <linux/init.h> @@ -177,7 +176,7 @@ static int sh_wdt_close(struct inode *in * sh_wdt_read - Read from Device * * @file: file handle of device - * @char: buffer to write to + * @buf: buffer to write to * @count: length of buffer * @ppos: offset * @@ -193,7 +192,7 @@ static ssize_t sh_wdt_read(struct file * * sh_wdt_write - Write to Device * * @file: file handle of device - * @char: buffer to write + * @buf: buffer to write * @count: length of buffer * @ppos: offset * @@ -269,7 +268,7 @@ static int sh_wdt_ioctl(struct inode *in static int sh_wdt_notify_sys(struct notifier_block *this, unsigned long code, void *unused) { - if (code == SYS_DOWN || SYS_HALT) { + if (code == SYS_DOWN || code == SYS_HALT) { sh_wdt_stop(); } diff -ruN3p v2.4.17-pre8/include/asm-sh/pci.h linux/include/asm-sh/pci.h --- v2.4.17-pre8/include/asm-sh/pci.h Sat Oct 13 07:35:54 2001 +++ linux/include/asm-sh/pci.h Tue Dec 11 15:52:33 2001 @@ -196,6 +196,11 @@ static inline int pci_dma_supported(stru return 1; } +/* Not supporting more than 32-bit PCI bus addresses now, but + * must satisfy references to this function. Change if needed. + */ +#define pci_dac_dma_supported(pci_dev, mask) (0) + /* Return the index of the PCI controller for device PDEV. */ #define pci_controller_num(PDEV) (0) diff -ruN3p v2.4.17-pre8/include/asm-sh/stat.h linux/include/asm-sh/stat.h --- v2.4.17-pre8/include/asm-sh/stat.h Tue Aug 1 09:38:07 2000 +++ linux/include/asm-sh/stat.h Tue Dec 11 15:52:33 2001 @@ -42,8 +42,16 @@ struct stat { * insane amounts of padding around dev_t's. */ struct stat64 { +#if defined(__BIG_ENDIAN__) + unsigned char __pad0b[6]; unsigned short st_dev; - unsigned char __pad0[10]; +#elif defined(__LITTLE_ENDIAN__) + unsigned short st_dev; + unsigned char __pad0b[6]; +#else +#error Must know endian to build stat64 structure! +#endif + unsigned char __pad0[4]; unsigned long st_ino; unsigned int st_mode; @@ -52,14 +60,25 @@ struct stat64 { unsigned long st_uid; unsigned long st_gid; +#if defined(__BIG_ENDIAN__) + unsigned char __pad3b[6]; + unsigned short st_rdev; +#else /* Must be little */ unsigned short st_rdev; - unsigned char __pad3[10]; + unsigned char __pad3b[6]; +#endif + unsigned char __pad3[4]; long long st_size; unsigned long st_blksize; +#if defined(__BIG_ENDIAN__) + unsigned long __pad4; /* Future possible st_blocks hi bits */ + unsigned long st_blocks; /* Number 512-byte blocks allocated. */ +#else /* Must be little */ unsigned long st_blocks; /* Number 512-byte blocks allocated. */ - unsigned long __pad4; /* future possible st_blocks high bits */ + unsigned long __pad4; /* Future possible st_blocks hi bits */ +#endif unsigned long st_atime; unsigned long __pad5; diff -ruN3p v2.4.17-pre8/include/asm-sh/uaccess.h linux/include/asm-sh/uaccess.h --- v2.4.17-pre8/include/asm-sh/uaccess.h Tue Oct 16 05:36:48 2001 +++ linux/include/asm-sh/uaccess.h Tue Dec 11 15:52:33 2001 @@ -216,6 +216,7 @@ __asm__ __volatile__( \ : "r" (val), "m" (__m(addr)), "i" (-EFAULT) \ : "memory"); }) #else +#define __put_user_u64(val,addr,retval) \ ({ \ __asm__ __volatile__( \ "1:\n\t" \ -- |