Merge remote branch 'u-boot-nand-flash/master'
authorWolfgang Denk <wd@denx.de>
Mon, 2 Jun 2008 22:16:48 +0000 (00:16 +0200)
committerWolfgang Denk <wd@denx.de>
Mon, 2 Jun 2008 22:16:48 +0000 (00:16 +0200)
17 files changed:
MAINTAINERS
MAKEALL
Makefile
board/dbau1x00/dbau1x00.c
board/gth2/gth2.c
board/pb1x00/pb1x00.c
board/qemu-mips/qemu-mips.c
board/quad100hd/Makefile [new file with mode: 0644]
board/quad100hd/config.mk [new file with mode: 0644]
board/quad100hd/nand.c [new file with mode: 0644]
board/quad100hd/quad100hd.c [new file with mode: 0644]
board/quad100hd/u-boot.lds [new file with mode: 0644]
cpu/mips/cpu.c
include/asm-mips/errno.h [new file with mode: 0644]
include/asm-mips/mipsregs.h
include/configs/quad100hd.h [new file with mode: 0644]
lib_mips/board.c

index ac7572c..cc88762 100644 (file)
@@ -204,6 +204,10 @@ Klaus Heydeck <heydeck@kieback-peter.de>
        KUP4K                   MPC855
        KUP4X                   MPC859
 
+Gary Jennejohn <garyj@denx.de>
+
+       quad100hd               PPC405EP
+
 Murray Jensen <Murray.Jensen@csiro.au>
 
        cogent_mpc8xx           MPC8xx
diff --git a/MAKEALL b/MAKEALL
index 0674069..4bf6d4d 100755 (executable)
--- a/MAKEALL
+++ b/MAKEALL
@@ -219,6 +219,7 @@ LIST_4xx="          \
        PMC405          \
        PMC440          \
        PPChameleonEVB  \
+       quad100hd       \
        rainier         \
        sbc405          \
        sc3             \
index 3401203..04cebac 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1391,6 +1391,9 @@ PPChameleonEVB_HI_33_config:      unconfig
                }
        @$(MKCONFIG) -a $(call xtract_4xx,$@) ppc ppc4xx PPChameleonEVB dave
 
+quad100hd_config:      unconfig
+       @$(MKCONFIG) $(@:_config=) ppc ppc4xx quad100hd
+
 sbc405_config: unconfig
        @$(MKCONFIG) $(@:_config=) ppc ppc4xx sbc405
 
index a13eeeb..1be72a2 100644 (file)
@@ -52,7 +52,7 @@ int checkboard (void)
 
        *sys_counter = 0x100; /* Enable 32 kHz oscillator for RTC/TOY */
 
-       proc_id = read_32bit_cp0_register(CP0_PRID);
+       proc_id = read_c0_prid();
 
        switch (proc_id >> 24) {
        case 0:
index 6da80dc..9bc4d3f 100644 (file)
@@ -135,7 +135,7 @@ int checkboard (void)
 
        *sys_counter = 0x100; /* Enable 32 kHz oscillator for RTC/TOY */
 
-       proc_id = read_32bit_cp0_register(CP0_PRID);
+       proc_id = read_c0_prid();
 
        switch (proc_id >> 24) {
        case 0:
index 536c954..82b7235 100644 (file)
@@ -51,7 +51,7 @@ int checkboard (void)
 
        *sys_counter = 0x100; /* Enable 32 kHz oscillator for RTC/TOY */
 
-       proc_id = read_32bit_cp0_register(CP0_PRID);
+       proc_id = read_c0_prid();
 
        switch (proc_id >> 24) {
        case 0:
index 6869074..6e6eab2 100644 (file)
@@ -38,7 +38,7 @@ int checkboard(void)
        u32 proc_id;
        u32 config1;
 
-       proc_id = read_32bit_cp0_register(CP0_PRID);
+       proc_id = read_c0_prid();
        printf("Board: Qemu -M mips CPU: ");
        switch (proc_id) {
        case 0x00018000:
@@ -51,7 +51,7 @@ int checkboard(void)
                printf("4KEc");
                break;
        case 0x00019300:
-               config1 = read_mips32_cp0_config1();
+               config1 = read_c0_config1();
                if (config1 & 1)
                        printf("24Kf");
                else
@@ -64,7 +64,7 @@ int checkboard(void)
                printf("R4000");
                break;
        case 0x00018100:
-               config1 = read_mips32_cp0_config1();
+               config1 = read_c0_config1();
                if (config1 & 1)
                        printf("5Kf");
                else
diff --git a/board/quad100hd/Makefile b/board/quad100hd/Makefile
new file mode 100644 (file)
index 0000000..252ad5a
--- /dev/null
@@ -0,0 +1,51 @@
+#
+# (C) Copyright 2007
+# Stefan Roese, DENX Software Engineering, sr@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB    = $(obj)lib$(BOARD).a
+
+COBJS  = $(BOARD).o nand.o
+SOBJS   =
+
+SRCS   := $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS   := $(addprefix $(obj),$(COBJS))
+SOBJS  := $(addprefix $(obj),$(SOBJS))
+
+$(LIB):        $(OBJS) $(SOBJS)
+       $(AR) $(ARFLAGS) $@ $(OBJS) $(SOBJS)
+
+clean:
+       rm -f $(SOBJS) $(OBJS)
+
+distclean:     clean
+       rm -f $(LIB) core *.bak .depend
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
diff --git a/board/quad100hd/config.mk b/board/quad100hd/config.mk
new file mode 100644 (file)
index 0000000..1bdf5e4
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# (C) Copyright 2000
+# Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+TEXT_BASE = 0xFFFC0000
diff --git a/board/quad100hd/nand.c b/board/quad100hd/nand.c
new file mode 100644 (file)
index 0000000..a36b89d
--- /dev/null
@@ -0,0 +1,79 @@
+/*
+ * (C) Copyright 2008
+ * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <config.h>
+#if defined(CONFIG_CMD_NAND)
+#include <asm/gpio.h>
+#include <nand.h>
+
+/*
+ *     hardware specific access to control-lines
+ */
+static void quad100hd_hwcontrol(struct mtd_info *mtd, int cmd)
+{
+       switch(cmd) {
+       case NAND_CTL_SETCLE:
+               gpio_write_bit(CFG_NAND_CLE, 1);
+               break;
+       case NAND_CTL_CLRCLE:
+               gpio_write_bit(CFG_NAND_CLE, 0);
+               break;
+
+       case NAND_CTL_SETALE:
+               gpio_write_bit(CFG_NAND_ALE, 1);
+               break;
+       case NAND_CTL_CLRALE:
+               gpio_write_bit(CFG_NAND_ALE, 0);
+               break;
+
+       case NAND_CTL_SETNCE:
+               gpio_write_bit(CFG_NAND_CE, 0);
+               break;
+       case NAND_CTL_CLRNCE:
+               gpio_write_bit(CFG_NAND_CE, 1);
+               break;
+       }
+}
+
+static int quad100hd_nand_ready(struct mtd_info *mtd)
+{
+       return gpio_read_in_bit(CFG_NAND_RDY);
+}
+
+/*
+ * Main initialization routine
+ */
+int board_nand_init(struct nand_chip *nand)
+{
+       /* Set address of hardware control function */
+       nand->hwcontrol = quad100hd_hwcontrol;
+       nand->dev_ready = quad100hd_nand_ready;
+       nand->eccmode = NAND_ECC_SOFT;
+       /* 15 us command delay time */
+       nand->chip_delay =  20;
+
+       /* Return happy */
+       return 0;
+}
+#endif /* CONFIG_CMD_NAND */
diff --git a/board/quad100hd/quad100hd.c b/board/quad100hd/quad100hd.c
new file mode 100644 (file)
index 0000000..638bd6c
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * (C) Copyright 2008
+ * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de.
+ *
+ * Based in part on board/icecube/icecube.c from PPCBoot
+ * (C) Copyright 2003 Intrinsyc Software
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#include <common.h>
+#include <command.h>
+#include <malloc.h>
+#include <environment.h>
+#include <logbuff.h>
+#include <post.h>
+
+#include <asm/processor.h>
+#include <asm/io.h>
+#include <asm/gpio.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+int board_early_init_f(void)
+{
+       /* taken from PPCBoot */
+       mtdcr(uicsr, 0xFFFFFFFF);       /* clear all ints */
+       mtdcr(uicer, 0x00000000);       /* disable all ints */
+       mtdcr(uiccr, 0x00000000);
+       mtdcr(uicpr, 0xFFFF7FFE);       /* set int polarities */
+       mtdcr(uictr, 0x00000000);       /* set int trigger levels */
+       mtdcr(uicsr, 0xFFFFFFFF);       /* clear all ints */
+       mtdcr(uicvcr, 0x00000001);      /* set vect base=0,INT0 highest priority */
+
+       mtdcr(CPC0_SRR, 0x00040000);   /* Hold PCI bridge in reset */
+
+       return 0;
+}
+
+/*
+ * Check Board Identity:
+ */
+int checkboard(void)
+{
+       char *s = getenv("serial#");
+#ifdef DISPLAY_BOARD_INFO
+       sys_info_t sysinfo;
+#endif
+
+       puts("Board: Quad100hd");
+
+       if (s != NULL) {
+               puts(", serial# ");
+               puts(s);
+       }
+       putc('\n');
+
+#ifdef DISPLAY_BOARD_INFO
+       /* taken from ppcboot */
+       get_sys_info(&sysinfo);
+
+       printf("\tVCO: %lu MHz\n", sysinfo.freqVCOMhz);
+       printf("\tCPU: %lu MHz\n", sysinfo.freqProcessor / 1000000);
+       printf("\tPLB: %lu MHz\n", sysinfo.freqPLB / 1000000);
+       printf("\tOPB: %lu MHz\n", sysinfo.freqOPB / 1000000);
+       printf("\tEPB: %lu MHz\n", sysinfo.freqPLB / (sysinfo.pllExtBusDiv *
+               1000000));
+       printf("\tPCI: %lu MHz\n", sysinfo.freqPCI / 1000000);
+#endif
+
+       return 0;
+}
+
+long int initdram(int board_type)
+{
+       return CFG_SDRAM_SIZE;
+}
diff --git a/board/quad100hd/u-boot.lds b/board/quad100hd/u-boot.lds
new file mode 100644 (file)
index 0000000..195d91b
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * (C) Copyright 2000
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+OUTPUT_ARCH(powerpc)
+SEARCH_DIR(/lib); SEARCH_DIR(/usr/lib); SEARCH_DIR(/usr/local/lib); SEARCH_DIR(/usr/local/powerpc-any-elf/lib);
+/* Do we need any of these for elf?
+   __DYNAMIC = 0;    */
+SECTIONS
+{
+  .resetvec 0xFFFFFFFC :
+  {
+    *(.resetvec)
+  } = 0xffff
+
+  /* Read-only sections, merged into text segment: */
+  . = + SIZEOF_HEADERS;
+  .interp : { *(.interp) }
+  .hash          : { *(.hash)          }
+  .dynsym        : { *(.dynsym)                }
+  .dynstr        : { *(.dynstr)                }
+  .rel.text      : { *(.rel.text)              }
+  .rela.text     : { *(.rela.text)     }
+  .rel.data      : { *(.rel.data)              }
+  .rela.data     : { *(.rela.data)     }
+  .rel.rodata    : { *(.rel.rodata)    }
+  .rela.rodata   : { *(.rela.rodata)   }
+  .rel.got       : { *(.rel.got)               }
+  .rela.got      : { *(.rela.got)              }
+  .rel.ctors     : { *(.rel.ctors)     }
+  .rela.ctors    : { *(.rela.ctors)    }
+  .rel.dtors     : { *(.rel.dtors)     }
+  .rela.dtors    : { *(.rela.dtors)    }
+  .rel.bss       : { *(.rel.bss)               }
+  .rela.bss      : { *(.rela.bss)              }
+  .rel.plt       : { *(.rel.plt)               }
+  .rela.plt      : { *(.rela.plt)              }
+  .init          : { *(.init)  }
+  .plt : { *(.plt) }
+  .text      :
+  {
+    cpu/ppc4xx/start.o (.text)
+
+    *(.text)
+    *(.fixup)
+    *(.got1)
+  }
+  _etext = .;
+  PROVIDE (etext = .);
+  .rodata    :
+  {
+    *(.rodata)
+    *(.rodata1)
+    *(.rodata.str1.4)
+  }
+  .fini      : { *(.fini)    } =0
+  .ctors     : { *(.ctors)   }
+  .dtors     : { *(.dtors)   }
+
+  /* Read-write section, merged into data segment: */
+  . = (. + 0x00FF) & 0xFFFFFF00;
+  _erotext = .;
+  PROVIDE (erotext = .);
+  .reloc   :
+  {
+    *(.got)
+    _GOT2_TABLE_ = .;
+    *(.got2)
+    _FIXUP_TABLE_ = .;
+    *(.fixup)
+  }
+  __got2_entries = (_FIXUP_TABLE_ - _GOT2_TABLE_) >>2;
+  __fixup_entries = (. - _FIXUP_TABLE_)>>2;
+
+  .data    :
+  {
+    *(.data)
+    *(.data1)
+    *(.sdata)
+    *(.sdata2)
+    *(.dynamic)
+    CONSTRUCTORS
+  }
+  _edata  =  .;
+  PROVIDE (edata = .);
+
+  . = .;
+  __u_boot_cmd_start = .;
+  .u_boot_cmd : { *(.u_boot_cmd) }
+  __u_boot_cmd_end = .;
+
+  . = .;
+  __start___ex_table = .;
+  __ex_table : { *(__ex_table) }
+  __stop___ex_table = .;
+
+  . = ALIGN(256);
+  __init_begin = .;
+  .text.init : { *(.text.init) }
+  .data.init : { *(.data.init) }
+  . = ALIGN(256);
+  __init_end = .;
+
+  __bss_start = .;
+  .bss (NOLOAD)       :
+  {
+   *(.sbss) *(.scommon)
+   *(.dynbss)
+   *(.bss)
+   *(COMMON)
+  }
+  _end = . ;
+  PROVIDE (end = .);
+}
index e267bba..0f58d25 100644 (file)
@@ -66,10 +66,10 @@ void flush_cache(ulong start_addr, ulong size)
 
 void write_one_tlb(int index, u32 pagemask, u32 hi, u32 low0, u32 low1)
 {
-       write_32bit_cp0_register(CP0_ENTRYLO0, low0);
-       write_32bit_cp0_register(CP0_PAGEMASK, pagemask);
-       write_32bit_cp0_register(CP0_ENTRYLO1, low1);
-       write_32bit_cp0_register(CP0_ENTRYHI, hi);
-       write_32bit_cp0_register(CP0_INDEX, index);
+       write_c0_entrylo0(low0);
+       write_c0_pagemask(pagemask);
+       write_c0_entrylo1(low1);
+       write_c0_entryhi(hi);
+       write_c0_index(index);
        tlb_write_indexed();
 }
diff --git a/include/asm-mips/errno.h b/include/asm-mips/errno.h
new file mode 100644 (file)
index 0000000..1665a63
--- /dev/null
@@ -0,0 +1,143 @@
+/*
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License.  See the file "COPYING" in the main directory of this archive
+ * for more details.
+ *
+ * Copyright (C) 1995, 1999, 2001, 2002 by Ralf Baechle
+ */
+#ifndef _ASM_MIPS_ERRNO_H
+#define _ASM_MIPS_ERRNO_H
+
+/*
+ * These first 34 error codes are from Linux 2.6, <asm-generic/errno-base.h>
+ */
+#define        EPERM            1      /* Operation not permitted */
+#define        ENOENT           2      /* No such file or directory */
+#define        ESRCH            3      /* No such process */
+#define        EINTR            4      /* Interrupted system call */
+#define        EIO              5      /* I/O error */
+#define        ENXIO            6      /* No such device or address */
+#define        E2BIG            7      /* Argument list too long */
+#define        ENOEXEC          8      /* Exec format error */
+#define        EBADF            9      /* Bad file number */
+#define        ECHILD          10      /* No child processes */
+#define        EAGAIN          11      /* Try again */
+#define        ENOMEM          12      /* Out of memory */
+#define        EACCES          13      /* Permission denied */
+#define        EFAULT          14      /* Bad address */
+#define        ENOTBLK         15      /* Block device required */
+#define        EBUSY           16      /* Device or resource busy */
+#define        EEXIST          17      /* File exists */
+#define        EXDEV           18      /* Cross-device link */
+#define        ENODEV          19      /* No such device */
+#define        ENOTDIR         20      /* Not a directory */
+#define        EISDIR          21      /* Is a directory */
+#define        EINVAL          22      /* Invalid argument */
+#define        ENFILE          23      /* File table overflow */
+#define        EMFILE          24      /* Too many open files */
+#define        ENOTTY          25      /* Not a typewriter */
+#define        ETXTBSY         26      /* Text file busy */
+#define        EFBIG           27      /* File too large */
+#define        ENOSPC          28      /* No space left on device */
+#define        ESPIPE          29      /* Illegal seek */
+#define        EROFS           30      /* Read-only file system */
+#define        EMLINK          31      /* Too many links */
+#define        EPIPE           32      /* Broken pipe */
+#define        EDOM            33      /* Math argument out of domain of func */
+#define        ERANGE          34      /* Math result not representable */
+
+/*
+ * These error numbers are intended to be MIPS ABI compatible
+ */
+#define        ENOMSG          35      /* No message of desired type */
+#define        EIDRM           36      /* Identifier removed */
+#define        ECHRNG          37      /* Channel number out of range */
+#define        EL2NSYNC        38      /* Level 2 not synchronized */
+#define        EL3HLT          39      /* Level 3 halted */
+#define        EL3RST          40      /* Level 3 reset */
+#define        ELNRNG          41      /* Link number out of range */
+#define        EUNATCH         42      /* Protocol driver not attached */
+#define        ENOCSI          43      /* No CSI structure available */
+#define        EL2HLT          44      /* Level 2 halted */
+#define        EDEADLK         45      /* Resource deadlock would occur */
+#define        ENOLCK          46      /* No record locks available */
+#define        EBADE           50      /* Invalid exchange */
+#define        EBADR           51      /* Invalid request descriptor */
+#define        EXFULL          52      /* Exchange full */
+#define        ENOANO          53      /* No anode */
+#define        EBADRQC         54      /* Invalid request code */
+#define        EBADSLT         55      /* Invalid slot */
+#define        EDEADLOCK       56      /* File locking deadlock error */
+#define        EBFONT          59      /* Bad font file format */
+#define        ENOSTR          60      /* Device not a stream */
+#define        ENODATA         61      /* No data available */
+#define        ETIME           62      /* Timer expired */
+#define        ENOSR           63      /* Out of streams resources */
+#define        ENONET          64      /* Machine is not on the network */
+#define        ENOPKG          65      /* Package not installed */
+#define        EREMOTE         66      /* Object is remote */
+#define        ENOLINK         67      /* Link has been severed */
+#define        EADV            68      /* Advertise error */
+#define        ESRMNT          69      /* Srmount error */
+#define        ECOMM           70      /* Communication error on send */
+#define        EPROTO          71      /* Protocol error */
+#define        EDOTDOT         73      /* RFS specific error */
+#define        EMULTIHOP       74      /* Multihop attempted */
+#define        EBADMSG         77      /* Not a data message */
+#define        ENAMETOOLONG    78      /* File name too long */
+#define        EOVERFLOW       79      /* Value too large for defined data type */
+#define        ENOTUNIQ        80      /* Name not unique on network */
+#define        EBADFD          81      /* File descriptor in bad state */
+#define        EREMCHG         82      /* Remote address changed */
+#define        ELIBACC         83      /* Can not access a needed shared library */
+#define        ELIBBAD         84      /* Accessing a corrupted shared library */
+#define        ELIBSCN         85      /* .lib section in a.out corrupted */
+#define        ELIBMAX         86      /* Attempting to link in too many shared libraries */
+#define        ELIBEXEC        87      /* Cannot exec a shared library directly */
+#define        EILSEQ          88      /* Illegal byte sequence */
+#define        ENOSYS          89      /* Function not implemented */
+#define        ELOOP           90      /* Too many symbolic links encountered */
+#define        ERESTART        91      /* Interrupted system call should be restarted */
+#define        ESTRPIPE        92      /* Streams pipe error */
+#define        ENOTEMPTY       93      /* Directory not empty */
+#define        EUSERS          94      /* Too many users */
+#define        ENOTSOCK        95      /* Socket operation on non-socket */
+#define        EDESTADDRREQ    96      /* Destination address required */
+#define        EMSGSIZE        97      /* Message too long */
+#define        EPROTOTYPE      98      /* Protocol wrong type for socket */
+#define        ENOPROTOOPT     99      /* Protocol not available */
+#define        EPROTONOSUPPORT 120     /* Protocol not supported */
+#define        ESOCKTNOSUPPORT 121     /* Socket type not supported */
+#define        EOPNOTSUPP      122     /* Operation not supported on transport endpoint */
+#define        EPFNOSUPPORT    123     /* Protocol family not supported */
+#define        EAFNOSUPPORT    124     /* Address family not supported by protocol */
+#define        EADDRINUSE      125     /* Address already in use */
+#define        EADDRNOTAVAIL   126     /* Cannot assign requested address */
+#define        ENETDOWN        127     /* Network is down */
+#define        ENETUNREACH     128     /* Network is unreachable */
+#define        ENETRESET       129     /* Network dropped connection because of reset */
+#define        ECONNABORTED    130     /* Software caused connection abort */
+#define        ECONNRESET      131     /* Connection reset by peer */
+#define        ENOBUFS         132     /* No buffer space available */
+#define        EISCONN         133     /* Transport endpoint is already connected */
+#define        ENOTCONN        134     /* Transport endpoint is not connected */
+#define        EUCLEAN         135     /* Structure needs cleaning */
+#define        ENOTNAM         137     /* Not a XENIX named type file */
+#define        ENAVAIL         138     /* No XENIX semaphores available */
+#define        EISNAM          139     /* Is a named type file */
+#define        EREMOTEIO       140     /* Remote I/O error */
+#define EINIT          141     /* Reserved */
+#define EREMDEV                142     /* Error 142 */
+#define        ESHUTDOWN       143     /* Cannot send after transport endpoint shutdown */
+#define        ETOOMANYREFS    144     /* Too many references: cannot splice */
+#define        ETIMEDOUT       145     /* Connection timed out */
+#define        ECONNREFUSED    146     /* Connection refused */
+#define        EHOSTDOWN       147     /* Host is down */
+#define        EHOSTUNREACH    148     /* No route to host */
+#define        EWOULDBLOCK     EAGAIN  /* Operation would block */
+#define        EALREADY        149     /* Operation already in progress */
+#define        EINPROGRESS     150     /* Operation now in progress */
+#define        ESTALE          151     /* Stale NFS file handle */
+#define ECANCELED      158     /* AIO operation canceled */
+
+#endif /* _ASM_MIPS_ERRNO_H */
index 61a0dac..be7e5c6 100644 (file)
@@ -7,8 +7,8 @@
  * Copyright (C) 2000 Silicon Graphics, Inc.
  * Modified for further R[236]000 support by Paul M. Antoine, 1996.
  * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
- * Copyright (C) 2000 MIPS Technologies, Inc.  All rights reserved.
- * Copyright (C) 2003  Maciej W. Rozycki
+ * Copyright (C) 2000, 07 MIPS Technologies, Inc.
+ * Copyright (C) 2003, 2004  Maciej W. Rozycki
  */
 #ifndef _ASM_MIPSREGS_H
 #define _ASM_MIPSREGS_H
 #endif
 
 /*
+ *  Configure language
+ */
+#ifdef __ASSEMBLY__
+#define _ULCAST_
+#else
+#define _ULCAST_ (unsigned long)
+#endif
+
+/*
  * Coprocessor 0 register names
  */
 #define CP0_INDEX $0
 #define CP0_XCONTEXT $20
 #define CP0_FRAMEMASK $21
 #define CP0_DIAGNOSTIC $22
+#define CP0_DEBUG $23
+#define CP0_DEPC $24
 #define CP0_PERFORMANCE $25
 #define CP0_ECC $26
 #define CP0_CACHEERR $27
 #define CP0_TAGLO $28
 #define CP0_TAGHI $29
 #define CP0_ERROREPC $30
+#define CP0_DESAVE $31
 
 /*
  * R4640/R4650 cp0 register names.  These registers are listed
 #define CP0_S1_DERRADDR0  $26
 #define CP0_S1_DERRADDR1  $27
 #define CP0_S1_INTCONTROL $20
+
+/*
+ * Coprocessor 0 Set 2 register names
+ */
+#define CP0_S2_SRSCTL  $12     /* MIPSR2 */
+
+/*
+ * Coprocessor 0 Set 3 register names
+ */
+#define CP0_S3_SRSMAP  $12     /* MIPSR2 */
+
+/*
+ *  TX39 Series
+ */
+#define CP0_TX39_CACHE $7
+
 /*
  * Coprocessor 1 (FPU) register names
  */
-#define CP1_REVISION   $0
-#define CP1_STATUS     $31
+#define CP1_REVISION   $0
+#define CP1_STATUS     $31
 
 /*
  * FPU Status Register Values
  * Status Register Values
  */
 
-#define FPU_CSR_FLUSH   0x01000000      /* flush denormalised results to 0 */
-#define FPU_CSR_COND    0x00800000      /* $fcc0 */
-#define FPU_CSR_COND0   0x00800000      /* $fcc0 */
-#define FPU_CSR_COND1   0x02000000      /* $fcc1 */
-#define FPU_CSR_COND2   0x04000000      /* $fcc2 */
-#define FPU_CSR_COND3   0x08000000      /* $fcc3 */
-#define FPU_CSR_COND4   0x10000000      /* $fcc4 */
-#define FPU_CSR_COND5   0x20000000      /* $fcc5 */
-#define FPU_CSR_COND6   0x40000000      /* $fcc6 */
-#define FPU_CSR_COND7   0x80000000      /* $fcc7 */
+#define FPU_CSR_FLUSH  0x01000000      /* flush denormalised results to 0 */
+#define FPU_CSR_COND   0x00800000      /* $fcc0 */
+#define FPU_CSR_COND0  0x00800000      /* $fcc0 */
+#define FPU_CSR_COND1  0x02000000      /* $fcc1 */
+#define FPU_CSR_COND2  0x04000000      /* $fcc2 */
+#define FPU_CSR_COND3  0x08000000      /* $fcc3 */
+#define FPU_CSR_COND4  0x10000000      /* $fcc4 */
+#define FPU_CSR_COND5  0x20000000      /* $fcc5 */
+#define FPU_CSR_COND6  0x40000000      /* $fcc6 */
+#define FPU_CSR_COND7  0x80000000      /* $fcc7 */
 
 /*
  * X the exception cause indicator
  * E the exception enable
  * S the sticky/flag bit
-*/
-#define FPU_CSR_ALL_X 0x0003f000
-#define FPU_CSR_UNI_X   0x00020000
-#define FPU_CSR_INV_X   0x00010000
-#define FPU_CSR_DIV_X   0x00008000
-#define FPU_CSR_OVF_X   0x00004000
-#define FPU_CSR_UDF_X   0x00002000
-#define FPU_CSR_INE_X   0x00001000
-
-#define FPU_CSR_ALL_E   0x00000f80
-#define FPU_CSR_INV_E   0x00000800
-#define FPU_CSR_DIV_E   0x00000400
-#define FPU_CSR_OVF_E   0x00000200
-#define FPU_CSR_UDF_E   0x00000100
-#define FPU_CSR_INE_E   0x00000080
-
-#define FPU_CSR_ALL_S   0x0000007c
-#define FPU_CSR_INV_S   0x00000040
-#define FPU_CSR_DIV_S   0x00000020
-#define FPU_CSR_OVF_S   0x00000010
-#define FPU_CSR_UDF_S   0x00000008
-#define FPU_CSR_INE_S   0x00000004
+ */
+#define FPU_CSR_ALL_X  0x0003f000
+#define FPU_CSR_UNI_X  0x00020000
+#define FPU_CSR_INV_X  0x00010000
+#define FPU_CSR_DIV_X  0x00008000
+#define FPU_CSR_OVF_X  0x00004000
+#define FPU_CSR_UDF_X  0x00002000
+#define FPU_CSR_INE_X  0x00001000
 
-/* rounding mode */
-#define FPU_CSR_RN      0x0     /* nearest */
-#define FPU_CSR_RZ      0x1     /* towards zero */
-#define FPU_CSR_RU      0x2     /* towards +Infinity */
-#define FPU_CSR_RD      0x3     /* towards -Infinity */
+#define FPU_CSR_ALL_E  0x00000f80
+#define FPU_CSR_INV_E  0x00000800
+#define FPU_CSR_DIV_E  0x00000400
+#define FPU_CSR_OVF_E  0x00000200
+#define FPU_CSR_UDF_E  0x00000100
+#define FPU_CSR_INE_E  0x00000080
 
+#define FPU_CSR_ALL_S  0x0000007c
+#define FPU_CSR_INV_S  0x00000040
+#define FPU_CSR_DIV_S  0x00000020
+#define FPU_CSR_OVF_S  0x00000010
+#define FPU_CSR_UDF_S  0x00000008
+#define FPU_CSR_INE_S  0x00000004
+
+/* rounding mode */
+#define FPU_CSR_RN     0x0     /* nearest */
+#define FPU_CSR_RZ     0x1     /* towards zero */
+#define FPU_CSR_RU     0x2     /* towards +Infinity */
+#define FPU_CSR_RD     0x3     /* towards -Infinity */
 
 /*
  * Values for PageMask register
  */
-#include <linux/config.h>
 #ifdef CONFIG_CPU_VR41XX
-#define PM_1K   0x00000000
-#define PM_4K   0x00001800
-#define PM_16K  0x00007800
-#define PM_64K  0x0001f800
-#define PM_256K 0x0007f800
-#else
-#define PM_4K   0x00000000
-#define PM_16K  0x00006000
-#define PM_64K  0x0001e000
-#define PM_256K 0x0007e000
-#define PM_1M   0x001fe000
-#define PM_4M   0x007fe000
-#define PM_16M  0x01ffe000
-#endif
 
-/*
- * Values used for computation of new tlb entries
- */
-#define PL_4K   12
-#define PL_16K  14
-#define PL_64K  16
-#define PL_256K 18
-#define PL_1M   20
-#define PL_4M   22
-#define PL_16M  24
+/* Why doesn't stupidity hurt ... */
 
-/*
- * Macros to access the system control coprocessor
- */
-#define read_32bit_cp0_register(source)                         \
-({ int __res;                                                   \
-       __asm__ __volatile__(                                   \
-       ".set\tpush\n\t"                                        \
-       ".set\treorder\n\t"                                     \
-       "mfc0\t%0,"STR(source)"\n\t"                            \
-       ".set\tpop"                                             \
-       : "=r" (__res));                                        \
-       __res;})
+#define PM_1K          0x00000000
+#define PM_4K          0x00001800
+#define PM_16K         0x00007800
+#define PM_64K         0x0001f800
+#define PM_256K                0x0007f800
 
-#define read_32bit_cp0_set1_register(source)                    \
-({ int __res;                                                   \
-       __asm__ __volatile__(                                   \
-       ".set\tpush\n\t"                                        \
-       ".set\treorder\n\t"                                     \
-       "cfc0\t%0,"STR(source)"\n\t"                            \
-       ".set\tpop"                                             \
-       : "=r" (__res));                                        \
-       __res;})
+#else
 
-/*
- * For now use this only with interrupts disabled!
- */
-#define read_64bit_cp0_register(source)                         \
-({ int __res;                                                   \
-       __asm__ __volatile__(                                   \
-       ".set\tmips3\n\t"                                       \
-       "dmfc0\t%0,"STR(source)"\n\t"                           \
-       ".set\tmips0"                                           \
-       : "=r" (__res));                                        \
-       __res;})
+#define PM_4K          0x00000000
+#define PM_16K         0x00006000
+#define PM_64K         0x0001e000
+#define PM_256K                0x0007e000
+#define PM_1M          0x001fe000
+#define PM_4M          0x007fe000
+#define PM_16M         0x01ffe000
+#define PM_64M         0x07ffe000
+#define PM_256M                0x1fffe000
 
-#define write_32bit_cp0_register(register,value)                \
-       __asm__ __volatile__(                                   \
-       "mtc0\t%0,"STR(register)"\n\t"                          \
-       "nop"                                                   \
-       : : "r" (value));
-
-#define write_32bit_cp0_set1_register(register,value)           \
-       __asm__ __volatile__(                                   \
-       "ctc0\t%0,"STR(register)"\n\t"                          \
-       "nop"                                                   \
-       : : "r" (value));
-
-#define write_64bit_cp0_register(register,value)                \
-       __asm__ __volatile__(                                   \
-       ".set\tmips3\n\t"                                       \
-       "dmtc0\t%0,"STR(register)"\n\t"                         \
-       ".set\tmips0"                                           \
-       : : "r" (value))
-
-/*
- * This should be changed when we get a compiler that support the MIPS32 ISA.
- */
-#define read_mips32_cp0_config1()                               \
-({ int __res;                                                   \
-       __asm__ __volatile__(                                   \
-       ".set\tnoreorder\n\t"                                   \
-       ".set\tnoat\n\t"                                        \
-       ".word\t0x40018001\n\t"                                 \
-       "move\t%0,$1\n\t"                                       \
-       ".set\tat\n\t"                                          \
-       ".set\treorder"                                         \
-       :"=r" (__res));                                         \
-       __res;})
+#endif
 
-#define tlb_write_indexed()                                     \
-       __asm__ __volatile__(                                   \
-               ".set noreorder\n\t"                            \
-               "tlbwi\n\t"                                     \
-".set reorder")
+/*
+ * Values used for computation of new tlb entries
+ */
+#define PL_4K          12
+#define PL_16K         14
+#define PL_64K         16
+#define PL_256K                18
+#define PL_1M          20
+#define PL_4M          22
+#define PL_16M         24
+#define PL_64M         26
+#define PL_256M                28
 
 /*
  * R4x00 interrupt enable / cause bits
  */
-#define IE_SW0          (1<< 8)
-#define IE_SW1          (1<< 9)
-#define IE_IRQ0         (1<<10)
-#define IE_IRQ1         (1<<11)
-#define IE_IRQ2         (1<<12)
-#define IE_IRQ3         (1<<13)
-#define IE_IRQ4         (1<<14)
-#define IE_IRQ5         (1<<15)
+#define IE_SW0         (_ULCAST_(1) <<  8)
+#define IE_SW1         (_ULCAST_(1) <<  9)
+#define IE_IRQ0                (_ULCAST_(1) << 10)
+#define IE_IRQ1                (_ULCAST_(1) << 11)
+#define IE_IRQ2                (_ULCAST_(1) << 12)
+#define IE_IRQ3                (_ULCAST_(1) << 13)
+#define IE_IRQ4                (_ULCAST_(1) << 14)
+#define IE_IRQ5                (_ULCAST_(1) << 15)
 
 /*
  * R4x00 interrupt cause bits
  */
-#define C_SW0           (1<< 8)
-#define C_SW1           (1<< 9)
-#define C_IRQ0          (1<<10)
-#define C_IRQ1          (1<<11)
-#define C_IRQ2          (1<<12)
-#define C_IRQ3          (1<<13)
-#define C_IRQ4          (1<<14)
-#define C_IRQ5          (1<<15)
-
-#ifndef _LANGUAGE_ASSEMBLY
-/*
- * Manipulate the status register.
- * Mostly used to access the interrupt bits.
- */
-#define __BUILD_SET_CP0(name,register)                          \
-extern __inline__ unsigned int                                  \
-set_cp0_##name(unsigned int set)                               \
-{                                                               \
-       unsigned int res;                                       \
-                                                               \
-       res = read_32bit_cp0_register(register);                \
-       res |= set;                                             \
-       write_32bit_cp0_register(register, res);                \
-                                                               \
-       return res;                                             \
-}                                                              \
-                                                               \
-extern __inline__ unsigned int                                  \
-clear_cp0_##name(unsigned int clear)                           \
-{                                                               \
-       unsigned int res;                                       \
-                                                               \
-       res = read_32bit_cp0_register(register);                \
-       res &= ~clear;                                          \
-       write_32bit_cp0_register(register, res);                \
-                                                               \
-       return res;                                             \
-}                                                              \
-                                                               \
-extern __inline__ unsigned int                                  \
-change_cp0_##name(unsigned int change, unsigned int new)       \
-{                                                               \
-       unsigned int res;                                       \
-                                                               \
-       res = read_32bit_cp0_register(register);                \
-       res &= ~change;                                         \
-       res |= (new & change);                                  \
-       if(change)                                              \
-               write_32bit_cp0_register(register, res);        \
-                                                               \
-       return res;                                             \
-}
-
-__BUILD_SET_CP0(status,CP0_STATUS)
-__BUILD_SET_CP0(cause,CP0_CAUSE)
-__BUILD_SET_CP0(config,CP0_CONFIG)
-
-#endif /* defined (_LANGUAGE_ASSEMBLY) */
+#define C_SW0          (_ULCAST_(1) <<  8)
+#define C_SW1          (_ULCAST_(1) <<  9)
+#define C_IRQ0         (_ULCAST_(1) << 10)
+#define C_IRQ1         (_ULCAST_(1) << 11)
+#define C_IRQ2         (_ULCAST_(1) << 12)
+#define C_IRQ3         (_ULCAST_(1) << 13)
+#define C_IRQ4         (_ULCAST_(1) << 14)
+#define C_IRQ5         (_ULCAST_(1) << 15)
 
 /*
  * Bitfields in the R4xx0 cp0 status register
@@ -337,9 +248,16 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
 #define ST0_CE                 0x00020000
 
 /*
+ * Setting c0_status.co enables Hit_Writeback and Hit_Writeback_Invalidate
+ * cacheops in userspace.  This bit exists only on RM7000 and RM9000
+ * processors.
+ */
+#define ST0_CO                 0x08000000
+
+/*
  * Bitfields in the R[23]000 cp0 status register.
  */
-#define ST0_IEC                 0x00000001
+#define ST0_IEC                        0x00000001
 #define ST0_KUC                        0x00000002
 #define ST0_IEP                        0x00000004
 #define ST0_KUP                        0x00000008
@@ -353,9 +271,14 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
 /*
  * Bits specific to the R4640/R4650
  */
-#define ST0_UM                 (1   <<  4)
-#define ST0_IL                 (1   << 23)
-#define ST0_DL                 (1   << 24)
+#define ST0_UM                 (_ULCAST_(1) <<  4)
+#define ST0_IL                 (_ULCAST_(1) << 23)
+#define ST0_DL                 (_ULCAST_(1) << 24)
+
+/*
+ * Enable the MIPS MDMX and DSP ASEs
+ */
+#define ST0_MX                 0x01000000
 
 /*
  * Bitfields in the TX39 family CP0 Configuration Register 3
@@ -395,39 +318,40 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
  */
 #define ST0_IM                 0x0000ff00
 #define  STATUSB_IP0           8
-#define  STATUSF_IP0           (1   <<  8)
+#define  STATUSF_IP0           (_ULCAST_(1) <<  8)
 #define  STATUSB_IP1           9
-#define  STATUSF_IP1           (1   <<  9)
+#define  STATUSF_IP1           (_ULCAST_(1) <<  9)
 #define  STATUSB_IP2           10
-#define  STATUSF_IP2           (1   << 10)
+#define  STATUSF_IP2           (_ULCAST_(1) << 10)
 #define  STATUSB_IP3           11
-#define  STATUSF_IP3           (1   << 11)
+#define  STATUSF_IP3           (_ULCAST_(1) << 11)
 #define  STATUSB_IP4           12
-#define  STATUSF_IP4           (1   << 12)
+#define  STATUSF_IP4           (_ULCAST_(1) << 12)
 #define  STATUSB_IP5           13
-#define  STATUSF_IP5           (1   << 13)
+#define  STATUSF_IP5           (_ULCAST_(1) << 13)
 #define  STATUSB_IP6           14
-#define  STATUSF_IP6           (1   << 14)
+#define  STATUSF_IP6           (_ULCAST_(1) << 14)
 #define  STATUSB_IP7           15
-#define  STATUSF_IP7           (1   << 15)
+#define  STATUSF_IP7           (_ULCAST_(1) << 15)
 #define  STATUSB_IP8           0
-#define  STATUSF_IP8           (1   << 0)
+#define  STATUSF_IP8           (_ULCAST_(1) <<  0)
 #define  STATUSB_IP9           1
-#define  STATUSF_IP9           (1   << 1)
+#define  STATUSF_IP9           (_ULCAST_(1) <<  1)
 #define  STATUSB_IP10          2
-#define  STATUSF_IP10          (1   << 2)
+#define  STATUSF_IP10          (_ULCAST_(1) <<  2)
 #define  STATUSB_IP11          3
-#define  STATUSF_IP11          (1   << 3)
+#define  STATUSF_IP11          (_ULCAST_(1) <<  3)
 #define  STATUSB_IP12          4
-#define  STATUSF_IP12          (1   << 4)
+#define  STATUSF_IP12          (_ULCAST_(1) <<  4)
 #define  STATUSB_IP13          5
-#define  STATUSF_IP13          (1   << 5)
+#define  STATUSF_IP13          (_ULCAST_(1) <<  5)
 #define  STATUSB_IP14          6
-#define  STATUSF_IP14          (1   << 6)
+#define  STATUSF_IP14          (_ULCAST_(1) <<  6)
 #define  STATUSB_IP15          7
-#define  STATUSF_IP15          (1   << 7)
+#define  STATUSF_IP15          (_ULCAST_(1) <<  7)
 #define ST0_CH                 0x00040000
 #define ST0_SR                 0x00100000
+#define ST0_TS                 0x00200000
 #define ST0_BEV                        0x00400000
 #define ST0_RE                 0x02000000
 #define ST0_FR                 0x04000000
@@ -444,35 +368,36 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
  * Refer to your MIPS R4xx0 manual, chapter 5 for explanation.
  */
 #define  CAUSEB_EXCCODE                2
-#define  CAUSEF_EXCCODE                (31  <<  2)
+#define  CAUSEF_EXCCODE                (_ULCAST_(31)  <<  2)
 #define  CAUSEB_IP             8
-#define  CAUSEF_IP             (255 <<  8)
+#define  CAUSEF_IP             (_ULCAST_(255) <<  8)
 #define  CAUSEB_IP0            8
-#define  CAUSEF_IP0            (1   <<  8)
+#define  CAUSEF_IP0            (_ULCAST_(1)   <<  8)
 #define  CAUSEB_IP1            9
-#define  CAUSEF_IP1            (1   <<  9)
+#define  CAUSEF_IP1            (_ULCAST_(1)   <<  9)
 #define  CAUSEB_IP2            10
-#define  CAUSEF_IP2            (1   << 10)
+#define  CAUSEF_IP2            (_ULCAST_(1)   << 10)
 #define  CAUSEB_IP3            11
-#define  CAUSEF_IP3            (1   << 11)
+#define  CAUSEF_IP3            (_ULCAST_(1)   << 11)
 #define  CAUSEB_IP4            12
-#define  CAUSEF_IP4            (1   << 12)
+#define  CAUSEF_IP4            (_ULCAST_(1)   << 12)
 #define  CAUSEB_IP5            13
-#define  CAUSEF_IP5            (1   << 13)
+#define  CAUSEF_IP5            (_ULCAST_(1)   << 13)
 #define  CAUSEB_IP6            14
-#define  CAUSEF_IP6            (1   << 14)
+#define  CAUSEF_IP6            (_ULCAST_(1)   << 14)
 #define  CAUSEB_IP7            15
-#define  CAUSEF_IP7            (1   << 15)
+#define  CAUSEF_IP7            (_ULCAST_(1)   << 15)
 #define  CAUSEB_IV             23
-#define  CAUSEF_IV             (1   << 23)
+#define  CAUSEF_IV             (_ULCAST_(1)   << 23)
 #define  CAUSEB_CE             28
-#define  CAUSEF_CE             (3   << 28)
+#define  CAUSEF_CE             (_ULCAST_(3)   << 28)
 #define  CAUSEB_BD             31
-#define  CAUSEF_BD             (1   << 31)
+#define  CAUSEF_BD             (_ULCAST_(1)   << 31)
 
 /*
- * Bits in the coprozessor 0 config register.
+ * Bits in the coprocessor 0 config register.
  */
+/* Generic bits.  */
 #define CONF_CM_CACHABLE_NO_WA         0
 #define CONF_CM_CACHABLE_WA            1
 #define CONF_CM_UNCACHED               2
@@ -482,66 +407,958 @@ __BUILD_SET_CP0(config,CP0_CONFIG)
 #define CONF_CM_CACHABLE_CUW           6
 #define CONF_CM_CACHABLE_ACCELERATED   7
 #define CONF_CM_CMASK                  7
-#define CONF_DB                                (1 <<  4)
-#define CONF_IB                                (1 <<  5)
-#define CONF_SC                                (1 << 17)
-#define CONF_AC                         (1 << 23)
-#define CONF_HALT                       (1 << 25)
+#define CONF_BE                        (_ULCAST_(1) << 15)
+
+/* Bits common to various processors.  */
+#define CONF_CU                        (_ULCAST_(1) <<  3)
+#define CONF_DB                        (_ULCAST_(1) <<  4)
+#define CONF_IB                        (_ULCAST_(1) <<  5)
+#define CONF_DC                        (_ULCAST_(7) <<  6)
+#define CONF_IC                        (_ULCAST_(7) <<  9)
+#define CONF_EB                        (_ULCAST_(1) << 13)
+#define CONF_EM                        (_ULCAST_(1) << 14)
+#define CONF_SM                        (_ULCAST_(1) << 16)
+#define CONF_SC                        (_ULCAST_(1) << 17)
+#define CONF_EW                        (_ULCAST_(3) << 18)
+#define CONF_EP                        (_ULCAST_(15)<< 24)
+#define CONF_EC                        (_ULCAST_(7) << 28)
+#define CONF_CM                        (_ULCAST_(1) << 31)
+
+/* Bits specific to the R4xx0.  */
+#define R4K_CONF_SW            (_ULCAST_(1) << 20)
+#define R4K_CONF_SS            (_ULCAST_(1) << 21)
+#define R4K_CONF_SB            (_ULCAST_(3) << 22)
+
+/* Bits specific to the R5000.  */
+#define R5K_CONF_SE            (_ULCAST_(1) << 12)
+#define R5K_CONF_SS            (_ULCAST_(3) << 20)
+
+/* Bits specific to the RM7000.  */
+#define RM7K_CONF_SE           (_ULCAST_(1) <<  3)
+#define RM7K_CONF_TE           (_ULCAST_(1) << 12)
+#define RM7K_CONF_CLK          (_ULCAST_(1) << 16)
+#define RM7K_CONF_TC           (_ULCAST_(1) << 17)
+#define RM7K_CONF_SI           (_ULCAST_(3) << 20)
+#define RM7K_CONF_SC           (_ULCAST_(1) << 31)
+
+/* Bits specific to the R10000.  */
+#define R10K_CONF_DN           (_ULCAST_(3) <<  3)
+#define R10K_CONF_CT           (_ULCAST_(1) <<  5)
+#define R10K_CONF_PE           (_ULCAST_(1) <<  6)
+#define R10K_CONF_PM           (_ULCAST_(3) <<  7)
+#define R10K_CONF_EC           (_ULCAST_(15)<<  9)
+#define R10K_CONF_SB           (_ULCAST_(1) << 13)
+#define R10K_CONF_SK           (_ULCAST_(1) << 14)
+#define R10K_CONF_SS           (_ULCAST_(7) << 16)
+#define R10K_CONF_SC           (_ULCAST_(7) << 19)
+#define R10K_CONF_DC           (_ULCAST_(7) << 26)
+#define R10K_CONF_IC           (_ULCAST_(7) << 29)
+
+/* Bits specific to the VR41xx.  */
+#define VR41_CONF_CS           (_ULCAST_(1) << 12)
+#define VR41_CONF_P4K          (_ULCAST_(1) << 13)
+#define VR41_CONF_BP           (_ULCAST_(1) << 16)
+#define VR41_CONF_M16          (_ULCAST_(1) << 20)
+#define VR41_CONF_AD           (_ULCAST_(1) << 23)
+
+/* Bits specific to the R30xx.  */
+#define R30XX_CONF_FDM         (_ULCAST_(1) << 19)
+#define R30XX_CONF_REV         (_ULCAST_(1) << 22)
+#define R30XX_CONF_AC          (_ULCAST_(1) << 23)
+#define R30XX_CONF_RF          (_ULCAST_(1) << 24)
+#define R30XX_CONF_HALT                (_ULCAST_(1) << 25)
+#define R30XX_CONF_FPINT       (_ULCAST_(7) << 26)
+#define R30XX_CONF_DBR         (_ULCAST_(1) << 29)
+#define R30XX_CONF_SB          (_ULCAST_(1) << 30)
+#define R30XX_CONF_LOCK                (_ULCAST_(1) << 31)
+
+/* Bits specific to the TX49.  */
+#define TX49_CONF_DC           (_ULCAST_(1) << 16)
+#define TX49_CONF_IC           (_ULCAST_(1) << 17)  /* conflict with CONF_SC */
+#define TX49_CONF_HALT         (_ULCAST_(1) << 18)
+#define TX49_CONF_CWFON                (_ULCAST_(1) << 27)
+
+/* Bits specific to the MIPS32/64 PRA.  */
+#define MIPS_CONF_MT           (_ULCAST_(7) <<  7)
+#define MIPS_CONF_AR           (_ULCAST_(7) << 10)
+#define MIPS_CONF_AT           (_ULCAST_(3) << 13)
+#define MIPS_CONF_M            (_ULCAST_(1) << 31)
+
+/*
+ * Bits in the MIPS32/64 PRA coprocessor 0 config registers 1 and above.
+ */
+#define MIPS_CONF1_FP          (_ULCAST_(1) <<  0)
+#define MIPS_CONF1_EP          (_ULCAST_(1) <<  1)
+#define MIPS_CONF1_CA          (_ULCAST_(1) <<  2)
+#define MIPS_CONF1_WR          (_ULCAST_(1) <<  3)
+#define MIPS_CONF1_PC          (_ULCAST_(1) <<  4)
+#define MIPS_CONF1_MD          (_ULCAST_(1) <<  5)
+#define MIPS_CONF1_C2          (_ULCAST_(1) <<  6)
+#define MIPS_CONF1_DA          (_ULCAST_(7) <<  7)
+#define MIPS_CONF1_DL          (_ULCAST_(7) << 10)
+#define MIPS_CONF1_DS          (_ULCAST_(7) << 13)
+#define MIPS_CONF1_IA          (_ULCAST_(7) << 16)
+#define MIPS_CONF1_IL          (_ULCAST_(7) << 19)
+#define MIPS_CONF1_IS          (_ULCAST_(7) << 22)
+#define MIPS_CONF1_TLBS                (_ULCAST_(63)<< 25)
+
+#define MIPS_CONF2_SA          (_ULCAST_(15)<<  0)
+#define MIPS_CONF2_SL          (_ULCAST_(15)<<  4)
+#define MIPS_CONF2_SS          (_ULCAST_(15)<<  8)
+#define MIPS_CONF2_SU          (_ULCAST_(15)<< 12)
+#define MIPS_CONF2_TA          (_ULCAST_(15)<< 16)
+#define MIPS_CONF2_TL          (_ULCAST_(15)<< 20)
+#define MIPS_CONF2_TS          (_ULCAST_(15)<< 24)
+#define MIPS_CONF2_TU          (_ULCAST_(7) << 28)
+
+#define MIPS_CONF3_TL          (_ULCAST_(1) <<  0)
+#define MIPS_CONF3_SM          (_ULCAST_(1) <<  1)
+#define MIPS_CONF3_MT          (_ULCAST_(1) <<  2)
+#define MIPS_CONF3_SP          (_ULCAST_(1) <<  4)
+#define MIPS_CONF3_VINT                (_ULCAST_(1) <<  5)
+#define MIPS_CONF3_VEIC                (_ULCAST_(1) <<  6)
+#define MIPS_CONF3_LPA         (_ULCAST_(1) <<  7)
+#define MIPS_CONF3_DSP         (_ULCAST_(1) << 10)
+#define MIPS_CONF3_ULRI                (_ULCAST_(1) << 13)
+
+#define MIPS_CONF7_WII         (_ULCAST_(1) << 31)
+
+#define MIPS_CONF7_RPS         (_ULCAST_(1) << 2)
+
+/*
+ * Bits in the MIPS32/64 coprocessor 1 (FPU) revision register.
+ */
+#define MIPS_FPIR_S            (_ULCAST_(1) << 16)
+#define MIPS_FPIR_D            (_ULCAST_(1) << 17)
+#define MIPS_FPIR_PS           (_ULCAST_(1) << 18)
+#define MIPS_FPIR_3D           (_ULCAST_(1) << 19)
+#define MIPS_FPIR_W            (_ULCAST_(1) << 20)
+#define MIPS_FPIR_L            (_ULCAST_(1) << 21)
+#define MIPS_FPIR_F64          (_ULCAST_(1) << 22)
+
+#ifndef __ASSEMBLY__
+
+/*
+ * Functions to access the R10000 performance counters.  These are basically
+ * mfc0 and mtc0 instructions from and to coprocessor register with a 5-bit
+ * performance counter number encoded into bits 1 ... 5 of the instruction.
+ * Only performance counters 0 to 1 actually exist, so for a non-R10000 aware
+ * disassembler these will look like an access to sel 0 or 1.
+ */
+#define read_r10k_perf_cntr(counter)                           \
+({                                                             \
+       unsigned int __res;                                     \
+       __asm__ __volatile__(                                   \
+       "mfpc\t%0, %1"                                          \
+       : "=r" (__res)                                          \
+       : "i" (counter));                                       \
+                                                               \
+       __res;                                                  \
+})
+
+#define write_r10k_perf_cntr(counter,val)                      \
+do {                                                           \
+       __asm__ __volatile__(                                   \
+       "mtpc\t%0, %1"                                          \
+       :                                                       \
+       : "r" (val), "i" (counter));                            \
+} while (0)
+
+#define read_r10k_perf_event(counter)                          \
+({                                                             \
+       unsigned int __res;                                     \
+       __asm__ __volatile__(                                   \
+       "mfps\t%0, %1"                                          \
+       : "=r" (__res)                                          \
+       : "i" (counter));                                       \
+                                                               \
+       __res;                                                  \
+})
+
+#define write_r10k_perf_cntl(counter,val)                      \
+do {                                                           \
+       __asm__ __volatile__(                                   \
+       "mtps\t%0, %1"                                          \
+       :                                                       \
+       : "r" (val), "i" (counter));                            \
+} while (0)
+
+/*
+ * Macros to access the system control coprocessor
+ */
+
+#define __read_32bit_c0_register(source, sel)                          \
+({ int __res;                                                          \
+       if (sel == 0)                                                   \
+               __asm__ __volatile__(                                   \
+                       "mfc0\t%0, " #source "\n\t"                     \
+                       : "=r" (__res));                                \
+       else                                                            \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips32\n\t"                              \
+                       "mfc0\t%0, " #source ", " #sel "\n\t"           \
+                       ".set\tmips0\n\t"                               \
+                       : "=r" (__res));                                \
+       __res;                                                          \
+})
+
+#define __read_64bit_c0_register(source, sel)                          \
+({ unsigned long long __res;                                           \
+       if (sizeof(unsigned long) == 4)                                 \
+               __res = __read_64bit_c0_split(source, sel);             \
+       else if (sel == 0)                                              \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips3\n\t"                               \
+                       "dmfc0\t%0, " #source "\n\t"                    \
+                       ".set\tmips0"                                   \
+                       : "=r" (__res));                                \
+       else                                                            \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips64\n\t"                              \
+                       "dmfc0\t%0, " #source ", " #sel "\n\t"          \
+                       ".set\tmips0"                                   \
+                       : "=r" (__res));                                \
+       __res;                                                          \
+})
+
+#define __write_32bit_c0_register(register, sel, value)                        \
+do {                                                                   \
+       if (sel == 0)                                                   \
+               __asm__ __volatile__(                                   \
+                       "mtc0\t%z0, " #register "\n\t"                  \
+                       : : "Jr" ((unsigned int)(value)));              \
+       else                                                            \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips32\n\t"                              \
+                       "mtc0\t%z0, " #register ", " #sel "\n\t"        \
+                       ".set\tmips0"                                   \
+                       : : "Jr" ((unsigned int)(value)));              \
+} while (0)
+
+#define __write_64bit_c0_register(register, sel, value)                        \
+do {                                                                   \
+       if (sizeof(unsigned long) == 4)                                 \
+               __write_64bit_c0_split(register, sel, value);           \
+       else if (sel == 0)                                              \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips3\n\t"                               \
+                       "dmtc0\t%z0, " #register "\n\t"                 \
+                       ".set\tmips0"                                   \
+                       : : "Jr" (value));                              \
+       else                                                            \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips64\n\t"                              \
+                       "dmtc0\t%z0, " #register ", " #sel "\n\t"       \
+                       ".set\tmips0"                                   \
+                       : : "Jr" (value));                              \
+} while (0)
+
+#define __read_ulong_c0_register(reg, sel)                             \
+       ((sizeof(unsigned long) == 4) ?                                 \
+       (unsigned long) __read_32bit_c0_register(reg, sel) :            \
+       (unsigned long) __read_64bit_c0_register(reg, sel))
+
+#define __write_ulong_c0_register(reg, sel, val)                       \
+do {                                                                   \
+       if (sizeof(unsigned long) == 4)                                 \
+               __write_32bit_c0_register(reg, sel, val);               \
+       else                                                            \
+               __write_64bit_c0_register(reg, sel, val);               \
+} while (0)
+
+/*
+ * On RM7000/RM9000 these are uses to access cop0 set 1 registers
+ */
+#define __read_32bit_c0_ctrl_register(source)                          \
+({ int __res;                                                          \
+       __asm__ __volatile__(                                           \
+               "cfc0\t%0, " #source "\n\t"                             \
+               : "=r" (__res));                                        \
+       __res;                                                          \
+})
+
+#define __write_32bit_c0_ctrl_register(register, value)                        \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+               "ctc0\t%z0, " #register "\n\t"                          \
+               : : "Jr" ((unsigned int)(value)));                      \
+} while (0)
+
+/*
+ * These versions are only needed for systems with more than 38 bits of
+ * physical address space running the 32-bit kernel.  That's none atm :-)
+ */
+#define __read_64bit_c0_split(source, sel)                             \
+({                                                                     \
+       unsigned long long __val;                                       \
+       unsigned long __flags;                                          \
+                                                                       \
+       local_irq_save(__flags);                                        \
+       if (sel == 0)                                                   \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips64\n\t"                              \
+                       "dmfc0\t%M0, " #source "\n\t"                   \
+                       "dsll\t%L0, %M0, 32\n\t"                        \
+                       "dsrl\t%M0, %M0, 32\n\t"                        \
+                       "dsrl\t%L0, %L0, 32\n\t"                        \
+                       ".set\tmips0"                                   \
+                       : "=r" (__val));                                \
+       else                                                            \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips64\n\t"                              \
+                       "dmfc0\t%M0, " #source ", " #sel "\n\t"         \
+                       "dsll\t%L0, %M0, 32\n\t"                        \
+                       "dsrl\t%M0, %M0, 32\n\t"                        \
+                       "dsrl\t%L0, %L0, 32\n\t"                        \
+                       ".set\tmips0"                                   \
+                       : "=r" (__val));                                \
+       local_irq_restore(__flags);                                     \
+                                                                       \
+       __val;                                                          \
+})
+
+#define __write_64bit_c0_split(source, sel, val)                       \
+do {                                                                   \
+       unsigned long __flags;                                          \
+                                                                       \
+       local_irq_save(__flags);                                        \
+       if (sel == 0)                                                   \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips64\n\t"                              \
+                       "dsll\t%L0, %L0, 32\n\t"                        \
+                       "dsrl\t%L0, %L0, 32\n\t"                        \
+                       "dsll\t%M0, %M0, 32\n\t"                        \
+                       "or\t%L0, %L0, %M0\n\t"                         \
+                       "dmtc0\t%L0, " #source "\n\t"                   \
+                       ".set\tmips0"                                   \
+                       : : "r" (val));                                 \
+       else                                                            \
+               __asm__ __volatile__(                                   \
+                       ".set\tmips64\n\t"                              \
+                       "dsll\t%L0, %L0, 32\n\t"                        \
+                       "dsrl\t%L0, %L0, 32\n\t"                        \
+                       "dsll\t%M0, %M0, 32\n\t"                        \
+                       "or\t%L0, %L0, %M0\n\t"                         \
+                       "dmtc0\t%L0, " #source ", " #sel "\n\t"         \
+                       ".set\tmips0"                                   \
+                       : : "r" (val));                                 \
+       local_irq_restore(__flags);                                     \
+} while (0)
+
+#define read_c0_index()                __read_32bit_c0_register($0, 0)
+#define write_c0_index(val)    __write_32bit_c0_register($0, 0, val)
+
+#define read_c0_entrylo0()     __read_ulong_c0_register($2, 0)
+#define write_c0_entrylo0(val) __write_ulong_c0_register($2, 0, val)
+
+#define read_c0_entrylo1()     __read_ulong_c0_register($3, 0)
+#define write_c0_entrylo1(val) __write_ulong_c0_register($3, 0, val)
+
+#define read_c0_conf()         __read_32bit_c0_register($3, 0)
+#define write_c0_conf(val)     __write_32bit_c0_register($3, 0, val)
+
+#define read_c0_context()      __read_ulong_c0_register($4, 0)
+#define write_c0_context(val)  __write_ulong_c0_register($4, 0, val)
+
+#define read_c0_userlocal()    __read_ulong_c0_register($4, 2)
+#define write_c0_userlocal(val)        __write_ulong_c0_register($4, 2, val)
+
+#define read_c0_pagemask()     __read_32bit_c0_register($5, 0)
+#define write_c0_pagemask(val) __write_32bit_c0_register($5, 0, val)
+
+#define read_c0_wired()                __read_32bit_c0_register($6, 0)
+#define write_c0_wired(val)    __write_32bit_c0_register($6, 0, val)
+
+#define read_c0_info()         __read_32bit_c0_register($7, 0)
+
+#define read_c0_cache()                __read_32bit_c0_register($7, 0) /* TX39xx */
+#define write_c0_cache(val)    __write_32bit_c0_register($7, 0, val)
+
+#define read_c0_badvaddr()     __read_ulong_c0_register($8, 0)
+#define write_c0_badvaddr(val) __write_ulong_c0_register($8, 0, val)
+
+#define read_c0_count()                __read_32bit_c0_register($9, 0)
+#define write_c0_count(val)    __write_32bit_c0_register($9, 0, val)
+
+#define read_c0_count2()       __read_32bit_c0_register($9, 6) /* pnx8550 */
+#define write_c0_count2(val)   __write_32bit_c0_register($9, 6, val)
+
+#define read_c0_count3()       __read_32bit_c0_register($9, 7) /* pnx8550 */
+#define write_c0_count3(val)   __write_32bit_c0_register($9, 7, val)
+
+#define read_c0_entryhi()      __read_ulong_c0_register($10, 0)
+#define write_c0_entryhi(val)  __write_ulong_c0_register($10, 0, val)
+
+#define read_c0_compare()      __read_32bit_c0_register($11, 0)
+#define write_c0_compare(val)  __write_32bit_c0_register($11, 0, val)
+
+#define read_c0_compare2()     __read_32bit_c0_register($11, 6) /* pnx8550 */
+#define write_c0_compare2(val) __write_32bit_c0_register($11, 6, val)
+
+#define read_c0_compare3()     __read_32bit_c0_register($11, 7) /* pnx8550 */
+#define write_c0_compare3(val) __write_32bit_c0_register($11, 7, val)
+
+#define read_c0_status()       __read_32bit_c0_register($12, 0)
+#ifdef CONFIG_MIPS_MT_SMTC
+#define write_c0_status(val)                                           \
+do {                                                                   \
+       __write_32bit_c0_register($12, 0, val);                         \
+       __ehb();                                                        \
+} while (0)
+#else
+/*
+ * Legacy non-SMTC code, which may be hazardous
+ * but which might not support EHB
+ */
+#define write_c0_status(val)   __write_32bit_c0_register($12, 0, val)
+#endif /* CONFIG_MIPS_MT_SMTC */
+
+#define read_c0_cause()                __read_32bit_c0_register($13, 0)
+#define write_c0_cause(val)    __write_32bit_c0_register($13, 0, val)
+
+#define read_c0_epc()          __read_ulong_c0_register($14, 0)
+#define write_c0_epc(val)      __write_ulong_c0_register($14, 0, val)
+
+#define read_c0_prid()         __read_32bit_c0_register($15, 0)
+
+#define read_c0_config()       __read_32bit_c0_register($16, 0)
+#define read_c0_config1()      __read_32bit_c0_register($16, 1)
+#define read_c0_config2()      __read_32bit_c0_register($16, 2)
+#define read_c0_config3()      __read_32bit_c0_register($16, 3)
+#define read_c0_config4()      __read_32bit_c0_register($16, 4)
+#define read_c0_config5()      __read_32bit_c0_register($16, 5)
+#define read_c0_config6()      __read_32bit_c0_register($16, 6)
+#define read_c0_config7()      __read_32bit_c0_register($16, 7)
+#define write_c0_config(val)   __write_32bit_c0_register($16, 0, val)
+#define write_c0_config1(val)  __write_32bit_c0_register($16, 1, val)
+#define write_c0_config2(val)  __write_32bit_c0_register($16, 2, val)
+#define write_c0_config3(val)  __write_32bit_c0_register($16, 3, val)
+#define write_c0_config4(val)  __write_32bit_c0_register($16, 4, val)
+#define write_c0_config5(val)  __write_32bit_c0_register($16, 5, val)
+#define write_c0_config6(val)  __write_32bit_c0_register($16, 6, val)
+#define write_c0_config7(val)  __write_32bit_c0_register($16, 7, val)
+
+/*
+ * The WatchLo register.  There may be upto 8 of them.
+ */
+#define read_c0_watchlo0()     __read_ulong_c0_register($18, 0)
+#define read_c0_watchlo1()     __read_ulong_c0_register($18, 1)
+#define read_c0_watchlo2()     __read_ulong_c0_register($18, 2)
+#define read_c0_watchlo3()     __read_ulong_c0_register($18, 3)
+#define read_c0_watchlo4()     __read_ulong_c0_register($18, 4)
+#define read_c0_watchlo5()     __read_ulong_c0_register($18, 5)
+#define read_c0_watchlo6()     __read_ulong_c0_register($18, 6)
+#define read_c0_watchlo7()     __read_ulong_c0_register($18, 7)
+#define write_c0_watchlo0(val) __write_ulong_c0_register($18, 0, val)
+#define write_c0_watchlo1(val) __write_ulong_c0_register($18, 1, val)
+#define write_c0_watchlo2(val) __write_ulong_c0_register($18, 2, val)
+#define write_c0_watchlo3(val) __write_ulong_c0_register($18, 3, val)
+#define write_c0_watchlo4(val) __write_ulong_c0_register($18, 4, val)
+#define write_c0_watchlo5(val) __write_ulong_c0_register($18, 5, val)
+#define write_c0_watchlo6(val) __write_ulong_c0_register($18, 6, val)
+#define write_c0_watchlo7(val) __write_ulong_c0_register($18, 7, val)
+
+/*
+ * The WatchHi register.  There may be upto 8 of them.
+ */
+#define read_c0_watchhi0()     __read_32bit_c0_register($19, 0)
+#define read_c0_watchhi1()     __read_32bit_c0_register($19, 1)
+#define read_c0_watchhi2()     __read_32bit_c0_register($19, 2)
+#define read_c0_watchhi3()     __read_32bit_c0_register($19, 3)
+#define read_c0_watchhi4()     __read_32bit_c0_register($19, 4)
+#define read_c0_watchhi5()     __read_32bit_c0_register($19, 5)
+#define read_c0_watchhi6()     __read_32bit_c0_register($19, 6)
+#define read_c0_watchhi7()     __read_32bit_c0_register($19, 7)
+
+#define write_c0_watchhi0(val) __write_32bit_c0_register($19, 0, val)
+#define write_c0_watchhi1(val) __write_32bit_c0_register($19, 1, val)
+#define write_c0_watchhi2(val) __write_32bit_c0_register($19, 2, val)
+#define write_c0_watchhi3(val) __write_32bit_c0_register($19, 3, val)
+#define write_c0_watchhi4(val) __write_32bit_c0_register($19, 4, val)
+#define write_c0_watchhi5(val) __write_32bit_c0_register($19, 5, val)
+#define write_c0_watchhi6(val) __write_32bit_c0_register($19, 6, val)
+#define write_c0_watchhi7(val) __write_32bit_c0_register($19, 7, val)
+
+#define read_c0_xcontext()     __read_ulong_c0_register($20, 0)
+#define write_c0_xcontext(val) __write_ulong_c0_register($20, 0, val)
+
+#define read_c0_intcontrol()   __read_32bit_c0_ctrl_register($20)
+#define write_c0_intcontrol(val) __write_32bit_c0_ctrl_register($20, val)
+
+#define read_c0_framemask()    __read_32bit_c0_register($21, 0)
+#define write_c0_framemask(val)        __write_32bit_c0_register($21, 0, val)
+
+/* RM9000 PerfControl performance counter control register */
+#define read_c0_perfcontrol()  __read_32bit_c0_register($22, 0)
+#define write_c0_perfcontrol(val) __write_32bit_c0_register($22, 0, val)
+
+#define read_c0_diag()         __read_32bit_c0_register($22, 0)
+#define write_c0_diag(val)     __write_32bit_c0_register($22, 0, val)
+
+#define read_c0_diag1()                __read_32bit_c0_register($22, 1)
+#define write_c0_diag1(val)    __write_32bit_c0_register($22, 1, val)
+
+#define read_c0_diag2()                __read_32bit_c0_register($22, 2)
+#define write_c0_diag2(val)    __write_32bit_c0_register($22, 2, val)
+
+#define read_c0_diag3()                __read_32bit_c0_register($22, 3)
+#define write_c0_diag3(val)    __write_32bit_c0_register($22, 3, val)
+
+#define read_c0_diag4()                __read_32bit_c0_register($22, 4)
+#define write_c0_diag4(val)    __write_32bit_c0_register($22, 4, val)
+
+#define read_c0_diag5()                __read_32bit_c0_register($22, 5)
+#define write_c0_diag5(val)    __write_32bit_c0_register($22, 5, val)
+
+#define read_c0_debug()                __read_32bit_c0_register($23, 0)
+#define write_c0_debug(val)    __write_32bit_c0_register($23, 0, val)
+
+#define read_c0_depc()         __read_ulong_c0_register($24, 0)
+#define write_c0_depc(val)     __write_ulong_c0_register($24, 0, val)
+
+/*
+ * MIPS32 / MIPS64 performance counters
+ */
+#define read_c0_perfctrl0()    __read_32bit_c0_register($25, 0)
+#define write_c0_perfctrl0(val)        __write_32bit_c0_register($25, 0, val)
+#define read_c0_perfcntr0()    __read_32bit_c0_register($25, 1)
+#define write_c0_perfcntr0(val)        __write_32bit_c0_register($25, 1, val)
+#define read_c0_perfctrl1()    __read_32bit_c0_register($25, 2)
+#define write_c0_perfctrl1(val)        __write_32bit_c0_register($25, 2, val)
+#define read_c0_perfcntr1()    __read_32bit_c0_register($25, 3)
+#define write_c0_perfcntr1(val)        __write_32bit_c0_register($25, 3, val)
+#define read_c0_perfctrl2()    __read_32bit_c0_register($25, 4)
+#define write_c0_perfctrl2(val)        __write_32bit_c0_register($25, 4, val)
+#define read_c0_perfcntr2()    __read_32bit_c0_register($25, 5)
+#define write_c0_perfcntr2(val)        __write_32bit_c0_register($25, 5, val)
+#define read_c0_perfctrl3()    __read_32bit_c0_register($25, 6)
+#define write_c0_perfctrl3(val)        __write_32bit_c0_register($25, 6, val)
+#define read_c0_perfcntr3()    __read_32bit_c0_register($25, 7)
+#define write_c0_perfcntr3(val)        __write_32bit_c0_register($25, 7, val)
+
+/* RM9000 PerfCount performance counter register */
+#define read_c0_perfcount()    __read_64bit_c0_register($25, 0)
+#define write_c0_perfcount(val)        __write_64bit_c0_register($25, 0, val)
+
+#define read_c0_ecc()          __read_32bit_c0_register($26, 0)
+#define write_c0_ecc(val)      __write_32bit_c0_register($26, 0, val)
+
+#define read_c0_derraddr0()    __read_ulong_c0_register($26, 1)
+#define write_c0_derraddr0(val)        __write_ulong_c0_register($26, 1, val)
+
+#define read_c0_cacheerr()     __read_32bit_c0_register($27, 0)
+
+#define read_c0_derraddr1()    __read_ulong_c0_register($27, 1)
+#define write_c0_derraddr1(val)        __write_ulong_c0_register($27, 1, val)
+
+#define read_c0_taglo()                __read_32bit_c0_register($28, 0)
+#define write_c0_taglo(val)    __write_32bit_c0_register($28, 0, val)
+
+#define read_c0_dtaglo()       __read_32bit_c0_register($28, 2)
+#define write_c0_dtaglo(val)   __write_32bit_c0_register($28, 2, val)
+
+#define read_c0_taghi()                __read_32bit_c0_register($29, 0)
+#define write_c0_taghi(val)    __write_32bit_c0_register($29, 0, val)
+
+#define read_c0_errorepc()     __read_ulong_c0_register($30, 0)
+#define write_c0_errorepc(val) __write_ulong_c0_register($30, 0, val)
+
+/* MIPSR2 */
+#define read_c0_hwrena()       __read_32bit_c0_register($7, 0)
+#define write_c0_hwrena(val)   __write_32bit_c0_register($7, 0, val)
+
+#define read_c0_intctl()       __read_32bit_c0_register($12, 1)
+#define write_c0_intctl(val)   __write_32bit_c0_register($12, 1, val)
+
+#define read_c0_srsctl()       __read_32bit_c0_register($12, 2)
+#define write_c0_srsctl(val)   __write_32bit_c0_register($12, 2, val)
+
+#define read_c0_srsmap()       __read_32bit_c0_register($12, 3)
+#define write_c0_srsmap(val)   __write_32bit_c0_register($12, 3, val)
+
+#define read_c0_ebase()                __read_32bit_c0_register($15, 1)
+#define write_c0_ebase(val)    __write_32bit_c0_register($15, 1, val)
 
 /*
- * R10000 performance counter definitions.
+ * Macros to access the floating point coprocessor control registers
+ */
+#define read_32bit_cp1_register(source)                                \
+({ int __res;                                                  \
+       __asm__ __volatile__(                                   \
+       ".set\tpush\n\t"                                        \
+       ".set\treorder\n\t"                                     \
+       "cfc1\t%0,"STR(source)"\n\t"                            \
+       ".set\tpop"                                             \
+       : "=r" (__res));                                        \
+       __res;})
+
+#define rddsp(mask)                                                    \
+({                                                                     \
+       unsigned int __res;                                             \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                            \n"             \
+       "       .set    noat                            \n"             \
+       "       # rddsp $1, %x1                         \n"             \
+       "       .word   0x7c000cb8 | (%x1 << 16)        \n"             \
+       "       move    %0, $1                          \n"             \
+       "       .set    pop                             \n"             \
+       : "=r" (__res)                                                  \
+       : "i" (mask));                                                  \
+       __res;                                                          \
+})
+
+#define wrdsp(val, mask)                                               \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # wrdsp $1, %x1                                 \n"     \
+       "       .word   0x7c2004f8 | (%x1 << 11)                \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (val), "i" (mask));                                       \
+} while (0)
+
+#define mfhi0()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mfhi  %0, $ac0                \n"                     \
+       "       .word   0x00000810              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mfhi1()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mfhi  %0, $ac1                \n"                     \
+       "       .word   0x00200810              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mfhi2()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mfhi  %0, $ac2                \n"                     \
+       "       .word   0x00400810              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mfhi3()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mfhi  %0, $ac3                \n"                     \
+       "       .word   0x00600810              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mflo0()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mflo  %0, $ac0                \n"                     \
+       "       .word   0x00000812              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mflo1()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mflo  %0, $ac1                \n"                     \
+       "       .word   0x00200812              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mflo2()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mflo  %0, $ac2                \n"                     \
+       "       .word   0x00400812              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mflo3()                                                                \
+({                                                                     \
+       unsigned long __treg;                                           \
+                                                                       \
+       __asm__ __volatile__(                                           \
+       "       .set    push                    \n"                     \
+       "       .set    noat                    \n"                     \
+       "       # mflo  %0, $ac3                \n"                     \
+       "       .word   0x00600812              \n"                     \
+       "       move    %0, $1                  \n"                     \
+       "       .set    pop                     \n"                     \
+       : "=r" (__treg));                                               \
+       __treg;                                                         \
+})
+
+#define mthi0(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mthi  $1, $ac0                                \n"     \
+       "       .word   0x00200011                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+#define mthi1(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mthi  $1, $ac1                                \n"     \
+       "       .word   0x00200811                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+#define mthi2(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mthi  $1, $ac2                                \n"     \
+       "       .word   0x00201011                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+#define mthi3(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mthi  $1, $ac3                                \n"     \
+       "       .word   0x00201811                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+#define mtlo0(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mtlo  $1, $ac0                                \n"     \
+       "       .word   0x00200013                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+#define mtlo1(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mtlo  $1, $ac1                                \n"     \
+       "       .word   0x00200813                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+#define mtlo2(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mtlo  $1, $ac2                                \n"     \
+       "       .word   0x00201013                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+#define mtlo3(x)                                                       \
+do {                                                                   \
+       __asm__ __volatile__(                                           \
+       "       .set    push                                    \n"     \
+       "       .set    noat                                    \n"     \
+       "       move    $1, %0                                  \n"     \
+       "       # mtlo  $1, $ac3                                \n"     \
+       "       .word   0x00201813                              \n"     \
+       "       .set    pop                                     \n"     \
+       :                                                               \
+       : "r" (x));                                                     \
+} while (0)
+
+/*
+ * TLB operations.
  *
- * FIXME: The R10000 performance counter opens a nice way to implement CPU
- *        time accounting with a precission of one cycle.  I don't have
- *        R10000 silicon but just a manual, so ...
- */
-
-/*
- * Events counted by counter #0
- */
-#define CE0_CYCLES                     0
-#define CE0_INSN_ISSUED                        1
-#define CE0_LPSC_ISSUED                        2
-#define CE0_S_ISSUED                   3
-#define CE0_SC_ISSUED                  4
-#define CE0_SC_FAILED                  5
-#define CE0_BRANCH_DECODED             6
-#define CE0_QW_WB_SECONDARY            7
-#define CE0_CORRECTED_ECC_ERRORS       8
-#define CE0_ICACHE_MISSES              9
-#define CE0_SCACHE_I_MISSES            10
-#define CE0_SCACHE_I_WAY_MISSPREDICTED 11
-#define CE0_EXT_INTERVENTIONS_REQ      12
-#define CE0_EXT_INVALIDATE_REQ         13
-#define CE0_VIRTUAL_COHERENCY_COND     14
-#define CE0_INSN_GRADUATED             15
-
-/*
- * Events counted by counter #1
- */
-#define CE1_CYCLES                     0
-#define CE1_INSN_GRADUATED             1
-#define CE1_LPSC_GRADUATED             2
-#define CE1_S_GRADUATED                        3
-#define CE1_SC_GRADUATED               4
-#define CE1_FP_INSN_GRADUATED          5
-#define CE1_QW_WB_PRIMARY              6
-#define CE1_TLB_REFILL                 7
-#define CE1_BRANCH_MISSPREDICTED       8
-#define CE1_DCACHE_MISS                        9
-#define CE1_SCACHE_D_MISSES            10
-#define CE1_SCACHE_D_WAY_MISSPREDICTED 11
-#define CE1_EXT_INTERVENTION_HITS      12
-#define CE1_EXT_INVALIDATE_REQ         13
-#define CE1_SP_HINT_TO_CEXCL_SC_BLOCKS 14
-#define CE1_SP_HINT_TO_SHARED_SC_BLOCKS        15
-
-/*
- * These flags define in which priviledge mode the counters count events
- */
-#define CEB_USER       8       /* Count events in user mode, EXL = ERL = 0 */
-#define CEB_SUPERVISOR 4       /* Count events in supvervisor mode EXL = ERL = 0 */
-#define CEB_KERNEL     2       /* Count events in kernel mode EXL = ERL = 0 */
-#define CEB_EXL                1       /* Count events with EXL = 1, ERL = 0 */
+ * It is responsibility of the caller to take care of any TLB hazards.
+ */
+static inline void tlb_probe(void)
+{
+       __asm__ __volatile__(
+               ".set noreorder\n\t"
+               "tlbp\n\t"
+               ".set reorder");
+}
+
+static inline void tlb_read(void)
+{
+#if MIPS34K_MISSED_ITLB_WAR
+       int res = 0;
+
+       __asm__ __volatile__(
+       "       .set    push                                    \n"
+       "       .set    noreorder                               \n"
+       "       .set    noat                                    \n"
+       "       .set    mips32r2                                \n"
+       "       .word   0x41610001              # dvpe $1       \n"
+       "       move    %0, $1                                  \n"
+       "       ehb                                             \n"
+       "       .set    pop                                     \n"
+       : "=r" (res));
+
+       instruction_hazard();
+#endif
+
+       __asm__ __volatile__(
+               ".set noreorder\n\t"
+               "tlbr\n\t"
+               ".set reorder");
+
+#if MIPS34K_MISSED_ITLB_WAR
+       if ((res & _ULCAST_(1)))
+               __asm__ __volatile__(
+               "       .set    push                            \n"
+               "       .set    noreorder                       \n"
+               "       .set    noat                            \n"
+               "       .set    mips32r2                        \n"
+               "       .word   0x41600021      # evpe          \n"
+               "       ehb                                     \n"
+               "       .set    pop                             \n");
+#endif
+}
+
+static inline void tlb_write_indexed(void)
+{
+       __asm__ __volatile__(
+               ".set noreorder\n\t"
+               "tlbwi\n\t"
+               ".set reorder");
+}
+
+static inline void tlb_write_random(void)
+{
+       __asm__ __volatile__(
+               ".set noreorder\n\t"
+               "tlbwr\n\t"
+               ".set reorder");
+}
+
+/*
+ * Manipulate bits in a c0 register.
+ */
+#define __BUILD_SET_C0(name)                                   \
+static inline unsigned int                                     \
+set_c0_##name(unsigned int set)                                        \
+{                                                              \
+       unsigned int res;                                       \
+                                                               \
+       res = read_c0_##name();                                 \
+       res |= set;                                             \
+       write_c0_##name(res);                                   \
+                                                               \
+       return res;                                             \
+}                                                              \
+                                                               \
+static inline unsigned int                                     \
+clear_c0_##name(unsigned int clear)                            \
+{                                                              \
+       unsigned int res;                                       \
+                                                               \
+       res = read_c0_##name();                                 \
+       res &= ~clear;                                          \
+       write_c0_##name(res);                                   \
+                                                               \
+       return res;                                             \
+}                                                              \
+                                                               \
+static inline unsigned int                                     \
+change_c0_##name(unsigned int change, unsigned int new)                \
+{                                                              \
+       unsigned int res;                                       \
+                                                               \
+       res = read_c0_##name();                                 \
+       res &= ~change;                                         \
+       res |= (new & change);                                  \
+       write_c0_##name(res);                                   \
+                                                               \
+       return res;                                             \
+}
+
+__BUILD_SET_C0(status)
+__BUILD_SET_C0(cause)
+__BUILD_SET_C0(config)
+__BUILD_SET_C0(intcontrol)
+__BUILD_SET_C0(intctl)
+__BUILD_SET_C0(srsmap)
+
+#endif /* !__ASSEMBLY__ */
 
 #endif /* _ASM_MIPSREGS_H */
diff --git a/include/configs/quad100hd.h b/include/configs/quad100hd.h
new file mode 100644 (file)
index 0000000..622a5d4
--- /dev/null
@@ -0,0 +1,298 @@
+/*
+ * (C) Copyright 2008
+ * Gary Jennejohn, DENX Software Engineering GmbH, garyj@denx.de.
+ *
+ * See file CREDITS for list of people who contributed to this
+ * project.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.         See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+/************************************************************************
+ * quad100hd.h - configuration for Quad100hd board
+ ***********************************************************************/
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*-----------------------------------------------------------------------
+ * High Level Configuration Options
+ *----------------------------------------------------------------------*/
+#define CONFIG_QUAD100HD       1               /* Board is Quad100hd   */
+#define CONFIG_4xx             1               /* ... PPC4xx family    */
+#define CONFIG_405EP           1               /* Specifc 405EP support*/
+
+#define CONFIG_SYS_CLK_FREQ     33333333 /* external frequency to pll   */
+
+#define CONFIG_BOARD_EARLY_INIT_F 1            /* Call board_early_init_f */
+
+#define PLLMR0_DEFAULT         PLLMR0_266_133_66 /* no PCI */
+#define PLLMR1_DEFAULT         PLLMR1_266_133_66 /* no PCI */
+
+/* the environment is in the EEPROM by default */
+#define CFG_ENV_IS_IN_EEPROM
+#undef CFG_ENV_IS_IN_FLASH
+
+#define CONFIG_NET_MULTI       1
+#define CONFIG_HAS_ETH1                1
+#define CONFIG_MII             1       /* MII PHY management           */
+#define CONFIG_PHY_ADDR                0x01    /* PHY address                  */
+#define CFG_RX_ETH_BUFFER      16      /* Number of ethernet rx buffers & descriptors */
+#define CONFIG_PHY_RESET       1
+#define CONFIG_PHY_RESET_DELAY 300     /* PHY RESET recovery delay     */
+
+/*
+ * Command line configuration.
+ */
+#include <config_cmd_default.h>
+
+#undef CONFIG_CMD_ASKENV
+#undef CONFIG_CMD_CACHE
+#define CONFIG_CMD_DHCP
+#undef CONFIG_CMD_DIAG
+#define CONFIG_CMD_EEPROM
+#undef CONFIG_CMD_ELF
+#define CONFIG_CMD_I2C
+#undef CONFIG_CMD_IRQ
+#define CONFIG_CMD_JFFS2
+#undef CONFIG_CMD_LOG
+#undef CONFIG_CMD_MII
+#define CONFIG_CMD_NAND
+#undef CONFIG_CMD_PING
+#define CONFIG_CMD_REGINFO
+
+#undef CONFIG_WATCHDOG                 /* watchdog disabled            */
+
+/*-----------------------------------------------------------------------
+ * SDRAM
+ *----------------------------------------------------------------------*/
+/*
+ * SDRAM configuration (please see cpu/ppc/sdram.[ch])
+ */
+#define CONFIG_SDRAM_BANK0  1
+#define CFG_SDRAM_SIZE      0x02000000      /* 32 MB */
+
+/* FIX! SDRAM timings used in datasheet */
+#define CFG_SDRAM_CL            3       /* CAS latency */
+#define CFG_SDRAM_tRP           20      /* PRECHARGE command period */
+#define CFG_SDRAM_tRC           66      /* ACTIVE-to-ACTIVE command period */
+#define CFG_SDRAM_tRCD          20      /* ACTIVE-to-READ delay */
+#define CFG_SDRAM_tRFC          66      /* Auto refresh period */
+
+/*
+ * JFFS2
+ */
+#define CFG_JFFS2_FIRST_BANK    0
+#ifdef  CFG_KERNEL_IN_JFFS2
+#define CFG_JFFS2_FIRST_SECTOR  0   /* JFFS starts at block 0 */
+#else /* kernel not in JFFS */
+#define CFG_JFFS2_FIRST_SECTOR  8   /* block 0-7 is kernel (1MB = 8 sectors) */
+#endif
+#define CFG_JFFS2_NUM_BANKS     1
+
+/*-----------------------------------------------------------------------
+ * Serial Port
+ *----------------------------------------------------------------------*/
+#undef CFG_EXT_SERIAL_CLOCK                    /* external serial clock */
+#define CFG_BASE_BAUD          691200
+#define CONFIG_BAUDRATE                115200
+#define CONFIG_SERIAL_MULTI
+
+/* The following table includes the supported baudrates */
+#define CFG_BAUDRATE_TABLE     \
+       {300, 600, 1200, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 230400}
+
+/*-----------------------------------------------------------------------
+ * Miscellaneous configurable options
+ *----------------------------------------------------------------------*/
+#define CFG_LONGHELP                   /* undef to save memory         */
+#define CFG_PROMPT             "=> "   /* Monitor Command Prompt       */
+#if defined(CONFIG_CMD_KGDB)
+#define CFG_CBSIZE             1024    /* Console I/O Buffer Size      */
+#else
+#define CFG_CBSIZE             256     /* Console I/O Buffer Size      */
+#endif
+#define CFG_PBSIZE              (CFG_CBSIZE+sizeof(CFG_PROMPT)+16) /* Print Buffer Size */
+#define CFG_MAXARGS            16      /* max number of command args   */
+#define CFG_BARGSIZE           CFG_CBSIZE /* Boot Argument Buffer Size */
+
+#define CFG_MEMTEST_START      0x0400000 /* memtest works on           */
+#define CFG_MEMTEST_END                0x0C00000 /* 4 ... 12 MB in DRAM        */
+
+#define CFG_LOAD_ADDR          0x100000  /* default load address       */
+#define CFG_EXTBDINFO          1       /* To use extended board_info (bd_t) */
+
+#define CFG_HZ                 1000    /* decrementer freq: 1 ms ticks */
+
+#define CONFIG_LOADS_ECHO      1       /* echo on for serial download  */
+#define CFG_LOADS_BAUD_CHANGE  1       /* allow baudrate change        */
+
+#define CONFIG_CMDLINE_EDITING 1       /* add command line history     */
+#define CONFIG_LOOPW            1       /* enable loopw command         */
+#define CONFIG_MX_CYCLIC        1       /* enable mdc/mwc commands      */
+#define CONFIG_ZERO_BOOTDELAY_CHECK    /* check for keypress on bootdelay==0 */
+#define CONFIG_VERSION_VARIABLE 1      /* include version env variable */
+
+/*-----------------------------------------------------------------------
+ * I2C
+ *----------------------------------------------------------------------*/
+#define CONFIG_HARD_I2C                1               /* I2C with hardware support    */
+#undef CONFIG_SOFT_I2C                         /* I2C bit-banged               */
+#define CFG_I2C_SPEED          400000          /* I2C speed and slave address  */
+#define CFG_I2C_SLAVE          0x7F
+
+#define CFG_I2C_EEPROM_ADDR    0x50            /* base address */
+#define CFG_I2C_EEPROM_ADDR_LEN        2               /* bytes of address */
+
+#define CFG_EEPROM_PAGE_WRITE_BITS     5       /* 8 byte write page size */
+#define CFG_EEPROM_PAGE_WRITE_DELAY_MS 10      /* and takes up to 10 msec */
+#define CFG_EEPROM_SIZE                        0x2000
+
+/*-----------------------------------------------------------------------
+ * Start addresses for the final memory configuration
+ * (Set up by the startup code)
+ * Please note that CFG_SDRAM_BASE _must_ start at 0
+ */
+#define CFG_SDRAM_BASE         0x00000000
+#define CFG_FLASH_BASE         0xFFC00000
+#define CFG_MONITOR_LEN                (256 * 1024)    /* Reserve 256 kB for Monitor   */
+#define CFG_MALLOC_LEN         (128 * 1024)    /* Reserve 128 kB for malloc()  */
+#define CFG_MONITOR_BASE       (TEXT_BASE)
+
+/*
+ * For booting Linux, the board info and command line data
+ * have to be in the first 8 MB of memory, since this is
+ * the maximum mapped by the Linux kernel during initialization.
+ */
+#define CFG_BOOTMAPSZ          (8 << 20)       /* Initial Memory map for Linux */
+
+/*-----------------------------------------------------------------------
+ * FLASH organization
+ */
+#define CFG_FLASH_CFI                  /* The flash is CFI compatible  */
+#define        CFG_FLASH_CFI_DRIVER
+
+#define CFG_FLASH_BANKS_LIST   { CFG_FLASH_BASE }
+
+#define CFG_MAX_FLASH_BANKS    1       /* max number of memory banks   */
+#define CFG_MAX_FLASH_SECT     128     /* max number of sectors on one chip */
+
+#define CFG_FLASH_ERASE_TOUT   120000  /* Timeout for Flash Erase (in ms) */
+#define CFG_FLASH_WRITE_TOUT   500     /* Timeout for Flash Write (in ms) */
+
+#define CFG_FLASH_USE_BUFFER_WRITE 1   /* use buffered writes (20x faster) */
+#define CFG_FLASH_INCREMENT      0       /* there is only one bank         */
+
+#define CFG_FLASH_EMPTY_INFO           /* print 'E' for empty sector on flinfo */
+#define CFG_FLASH_QUIET_TEST   1       /* don't warn upon unknown flash */
+
+#ifdef CFG_ENV_IS_IN_FLASH
+#define CFG_ENV_SECT_SIZE      0x10000 /* size of one complete sector  */
+/* the environment is located before u-boot */
+#define CFG_ENV_ADDR           (TEXT_BASE - CFG_ENV_SECT_SIZE)
+
+/* Address and size of Redundant Environment Sector    */
+#define CFG_ENV_ADDR_REDUND    (CFG_ENV_ADDR - CFG_ENV_SECT_SIZE)
+#define CFG_ENV_SIZE_REDUND    (CFG_ENV_SECT_SIZE)
+#endif
+
+#ifdef CFG_ENV_IS_IN_EEPROM
+#define CFG_ENV_SIZE           0x400           /* Size of Environment vars */
+#define CFG_ENV_OFFSET         0x00000000
+#define CFG_ENABLE_CRC_16      1       /* Intrinsyc formatting used crc16 */
+#endif
+
+/* partly from PPCBoot */
+/* NAND */
+#define CONFIG_NAND
+#ifdef CONFIG_NAND
+#define CFG_NAND_BASE   0x60000000
+#define CFG_NAND_CS    10   /* our CS is GPIO10 */
+#define CFG_NAND_RDY   23   /* our RDY is GPIO23 */
+#define CFG_NAND_CE    24   /* our CE is GPIO24  */
+#define CFG_NAND_CLE   31   /* our CLE is GPIO31 */
+#define CFG_NAND_ALE   30   /* our ALE is GPIO30 */
+#define NAND_MAX_CHIPS 1
+#define CFG_MAX_NAND_DEVICE    1
+#endif
+
+/*-----------------------------------------------------------------------
+ * Definitions for initial stack pointer and data area (in data cache)
+ */
+/* use on chip memory (OCM) for temperary stack until sdram is tested */
+/* see ./cpu/ppc4xx/start.S */
+#define CFG_TEMP_STACK_OCM     1
+
+/* On Chip Memory location */
+#define CFG_OCM_DATA_ADDR      0xF8000000
+#define CFG_OCM_DATA_SIZE      0x1000
+#define CFG_INIT_RAM_ADDR      CFG_OCM_DATA_ADDR /* inside of OCM              */
+#define CFG_INIT_RAM_END       CFG_OCM_DATA_SIZE /* End of used area in RAM    */
+
+#define CFG_GBL_DATA_SIZE      128  /* size in bytes reserved for initial data */
+#define CFG_GBL_DATA_OFFSET    (CFG_INIT_RAM_END - CFG_GBL_DATA_SIZE)
+#define CFG_INIT_SP_OFFSET      CFG_GBL_DATA_OFFSET
+
+/*-----------------------------------------------------------------------
+ * External Bus Controller (EBC) Setup
+ * Taken from PPCBoot board/icecube/icecube.h
+ */
+
+/* see ./cpu/ppc4xx/cpu_init.c ./cpu/ppc4xx/ndfc.c */
+#define CFG_EBC_PB0AP          0x04002480
+/* AMD NOR flash - this corresponds to FLASH_BASE so may be correct */
+#define CFG_EBC_PB0CR          0xFFC5A000
+#define CFG_EBC_PB1AP           0x04005480
+#define CFG_EBC_PB1CR           0x60018000
+#define CFG_EBC_PB2AP           0x00000000
+#define CFG_EBC_PB2CR           0x00000000
+#define CFG_EBC_PB3AP           0x00000000
+#define CFG_EBC_PB3CR           0x00000000
+#define CFG_EBC_PB4AP           0x00000000
+#define CFG_EBC_PB4CR           0x00000000
+
+/*-----------------------------------------------------------------------
+ * Definitions for GPIO setup (PPC405EP specific)
+ *
+ * Taken in part from PPCBoot board/icecube/icecube.h
+ */
+/* see ./cpu/ppc4xx/cpu_init.c ./cpu/ppc4xx/start.S */
+#define CFG_GPIO0_OSRH         0x55555550
+#define CFG_GPIO0_OSRL         0x00000110
+#define CFG_GPIO0_ISR1H                0x00000000
+#define CFG_GPIO0_ISR1L                0x15555445
+#define CFG_GPIO0_TSRH         0x00000000
+#define CFG_GPIO0_TSRL         0x00000000
+#define CFG_GPIO0_TCR          0xFFFF8097
+#define CFG_GPIO0_ODR          0x00000000
+
+#if defined(CONFIG_CMD_KGDB)
+#define CONFIG_KGDB_BAUDRATE   230400          /* speed to run kgdb serial port */
+#define CONFIG_KGDB_SER_INDEX  2               /* which serial port to use */
+#endif
+
+/* ENVIRONMENT VARS */
+
+#define CONFIG_IPADDR          192.168.1.67
+#define CONFIG_SERVERIP                192.168.1.50
+#define CONFIG_GATEWAYIP       192.168.1.1
+#define CONFIG_NETMASK         255.255.255.0
+#define CONFIG_LOADADDR                300000
+#define CONFIG_BOOTDELAY       5       /* autoboot after 5 seconds */
+
+/* pass open firmware flat tree */
+#define CONFIG_OF_LIBFDT       1
+
+#endif /* __CONFIG_H */
index 1645f2c..532550b 100644 (file)
@@ -28,6 +28,8 @@
 #include <version.h>
 #include <net.h>
 #include <environment.h>
+#include <nand.h>
+#include <spi.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -416,6 +418,17 @@ void board_init_r (gd_t *id, ulong dest_addr)
        }
 #endif
 
+#ifdef CONFIG_CMD_NAND
+       puts ("NAND:  ");
+       nand_init ();           /* go init the NAND */
+#endif
+
+#ifdef CONFIG_CMD_SPI
+       puts ("SPI:   ");
+       spi_init ();            /* go init the SPI */
+       puts ("ready\n");
+#endif
+
 #if defined(CONFIG_MISC_INIT_R)
        /* miscellaneous platform dependent initialisations */
        misc_init_r ();