]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
* Patch by Denis Peter, 18 Jan 2002:
authorwdenk <wdenk>
Fri, 18 Jan 2002 11:04:56 +0000 (11:04 +0000)
committerwdenk <wdenk>
Fri, 18 Jan 2002 11:04:56 +0000 (11:04 +0000)
  - Support for QNX images
  - Cleanup of MPL files

* Unified speed.c for all 824x boards
  Patch by Greg Allen, 17 Jan 2002

41 files changed:
CHANGELOG
board/cu824/Makefile
board/cu824/speed.c [deleted file]
board/mousse/Makefile
board/mousse/speed.c [deleted file]
board/mpl/common/common_util.c [new file with mode: 0644]
board/mpl/common/common_util.h [new file with mode: 0644]
board/mpl/common/flash.c
board/mpl/common/memtst.c
board/mpl/common/pci_parts.h
board/mpl/mip405/Makefile
board/mpl/mip405/cmd_mip405.c
board/mpl/mip405/mip405.c
board/mpl/mip405/mip405.h
board/mpl/pip405/Makefile
board/mpl/pip405/cmd_pip405.c
board/mpl/pip405/pip405.c
board/mpl/pip405/pip405.h
board/mpl/pip405/ppcboot.lds
board/mpl/pip405/ppcboot.lds.debug
board/musenki/Makefile
board/musenki/serial.c
board/musenki/speed.c [deleted file]
board/sandpoint/Makefile
board/sandpoint/sandpoint.c
board/sandpoint/speed.c [deleted file]
common/cmd_bootm.c
common/cmd_scsi.c
common/usb_storage.c
cpu/mpc824x/Makefile
cpu/mpc824x/cpu_init.c
cpu/mpc824x/speed.c [new file with mode: 0644]
disk/part.c
disk/part_dos.c
include/cmd_usb.h
include/config_MIP405.h
include/config_MOUSSE.h
include/config_MUSENKI.h
include/config_PIP405.h
include/config_Sandpoint8240.h
include/part.h

index 12d4d81866510ae8069f500df2dab290b9b6fd4b..ddbb2c012eefe3bd5b884d6d27050a20599814c9 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -6,6 +6,15 @@ Modifications for 1.1.4:
 
 * Support for GESPAC PCIPPC2 board
 
+* Patch by Denis Peter, 18 Jan 2002:
+  - Support for QNX images
+  - Cleanup of MPL files
+
+* Fix Sandpoint8240 port: working now from flash, without need for DINK
+
+* Unified speed.c for all 824x boards
+  Patch by Greg Allen, 17 Jan 2002
+
 * added command to switch LSB on LWMON boards
 
 * increased IDE_TIME_OUT as needed on some boards
@@ -33,8 +42,6 @@ Modifications for 1.1.4:
 * Fix bug in interrupt handling in Walnut flash driver
   Patch by Andrew May, 10 Jan 2002
 
-* Fix Sandpoint8240 port: boots now from flash, without need for DINK
-
 * "Final" fix for HUSH shell
 
 * Fix IDE on BAB750 board
index c5a98bf0d82f6db6877f977a13e167c4e5003124..e515e6e68824744fed77088b851b0aeac077499b 100644 (file)
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    = lib$(BOARD).a
 
-OBJS   = $(BOARD).o flash.o ns16550.o serial.o speed.o dc2114x.o
+OBJS   = $(BOARD).o flash.o ns16550.o serial.o dc2114x.o
 
 $(LIB):        .depend $(OBJS)
        $(AR) crv $@ $^
diff --git a/board/cu824/speed.c b/board/cu824/speed.c
deleted file mode 100644 (file)
index 313462f..0000000
+++ /dev/null
@@ -1,88 +0,0 @@
-/*
- * (C) Copyright 2001
- * 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
- */
-
-#include <ppcboot.h>
-#include <mpc824x.h>
-#include <asm/processor.h>
-
-static char pll_to_bus_factor[] =
-{
-       3, 0, 0, 0, 0,
-       0, 0, 0, 1, 0,
-       0, 0, 2, 0, 2,
-       0, 3, 0, 0, 0,
-       2, 0, 0, 0
-};
-
-#define PLL_STATE_REG 0xFE80002F
-
-ulong get_bus_freq(ulong ignore)
-{
-       unsigned char pll = *(volatile char *) (PLL_STATE_REG);
-
-       if (pll == 24)
-       {
-               return CONFIG_SYS_CLK_FREQ * 5 / 2;
-       }
-       else
-       {
-               return CONFIG_SYS_CLK_FREQ * pll_to_bus_factor[pll];
-       }
-}
-
-/* ------------------------------------------------------------------------- */
-
-/*
- * Measure CPU clock speed
- */
-
-/* Table to convert pllratio to actual processor clock scaling factor (*10)
- */
-#ifdef CONFIG_MPC824X
-short pllratio_to_factor[] = {
-    00, 00, 00, 10, 20, 20, 25, 00, 00, 00, 00, 00, 00, 00, 00, 00,
-    00, 00, 00, 10, 00, 00, 00, 45, 30, 00, 40, 00, 00, 00, 35, 00,
-};
-#endif
-
-ulong get_gclk_freq(void)
-{
-       uint hid1 = mfspr(HID1);
-
-#ifdef CONFIG_MPC824X
-
-               /* 5 bits for PLL ration on 824X
-                */
-       hid1 = (hid1 >> (32-5)) & 0x1f;
-#else
-
-               /* 4 bits on everythings else
-                */
-       hid1 = (hid1 >> (32-4)) & 0xf;
-#endif
-
-       return (pllratio_to_factor[hid1] * get_bus_freq(0)) / 10;
-}
-
-/* ------------------------------------------------------------------------- */
-
index f24ec6c6bdb81bd1c3884abe2e7eef59a04e76a6..3a3f2f384d3da0057a6b2fa5f99c446c48ad46ea 100644 (file)
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    = lib$(BOARD).a
 
-OBJS   = $(BOARD).o ns16550.o serial.o speed.o dc2114x.o\
+OBJS   = $(BOARD).o ns16550.o serial.o dc2114x.o\
          m48t59y.o pci.o flash.o
 #pci.o
 
diff --git a/board/mousse/speed.c b/board/mousse/speed.c
deleted file mode 100644 (file)
index 7cbd660..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-/*
- * (C) Copyright 2001
- * 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
- */
-
-#include <ppcboot.h>
-#include <mpc824x.h>
-#include <asm/processor.h>
-
-
-ulong get_bus_freq(ulong ignore)
-{
-  return 33000000; /* On Mousse, PCI is at least 33Mhz */
-}
-
-/* ------------------------------------------------------------------------- */
-
-/*
- * Measure CPU clock speed
- */
-
-/* Table to convert pllratio to actual processor clock scaling factor (*10)
- */
-#ifdef CONFIG_MPC824X
-short pllratio_to_factor[] = {
-    00, 00, 00, 10, 20, 20, 25, 00, 00, 00, 00, 00, 00, 00, 00, 00,
-    00, 00, 00, 10, 00, 00, 00, 45, 60, 00, 40, 00, 00, 00, 35, 00,
-};
-#endif
-
-ulong get_gclk_freq(void)
-{
-       uint hid1 = mfspr(HID1);
-
-#ifdef CONFIG_MPC824X
-
-               /* 5 bits for PLL ration on 824x
-                */
-       hid1 = (hid1 >> (32-5)) & 0x1f;
-#else
-
-               /* 4 bits on everythings else
-                */
-       hid1 = (hid1 >> (32-4)) & 0xf;
-#endif
-       return (pllratio_to_factor[hid1] * get_bus_freq(0)) / 10;
-}
-
-/* ------------------------------------------------------------------------- */
-
diff --git a/board/mpl/common/common_util.c b/board/mpl/common/common_util.c
new file mode 100644 (file)
index 0000000..39c6f70
--- /dev/null
@@ -0,0 +1,384 @@
+/*
+ * (C) Copyright 2001
+ * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
+ *
+ * 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 <ppcboot.h>
+#include <command.h> 
+#include "common_util.h"
+#include <asm/processor.h>
+extern int  gunzip (void *, int, unsigned char *, int *);
+extern int mem_test(unsigned long start, unsigned long ramsize, int quiet);
+#define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */
+#define IMAGE_SIZE 0x80000 
+
+extern flash_info_t flash_info[];      /* info for FLASH chips */
+
+image_header_t header;
+
+
+int mpl_prg(unsigned long src,unsigned long size)
+{
+       unsigned long start;
+       flash_info_t *info;
+       int i,rc;
+       unsigned long *magic = (unsigned long *)src;
+       
+       info = &flash_info[0];
+       start = 0 - size;
+       for(i=info->sector_count-1;i>0;i--)
+       {
+               info->protect[i] = 0; /* unprotect this sector */
+               if(start>=info->start[i])
+               break;
+       }
+       /* set-up flash location */
+       /* now erase flash */
+       if(magic[0]!=IH_MAGIC) {
+               printf("Bad Magic number\n");
+               return -1;
+       }
+       printf("Erasing at %lx (sector %d) (start %lx)\n",
+                               start,i,info->start[i]);
+       flash_erase (info, i, info->sector_count-1);
+       printf("flash erased, programming from 0x%lx 0x%lx Bytes\n",src,size);
+       switch (rc = flash_write ((uchar *)src, start, size)) 
+       {
+               case 0: printf ("OK programming done\n"); return 0;
+               case 1: printf ("ERROR Timeout writing to Flash\n"); return 1;
+               case 2: printf ("ERROR Flash not Erased\n"); return 1;
+               case 4: printf ("ERROR Can't write to protected Flash sectors\n"); return 1;
+               case 8: printf ("ERROR Outside available Flash\n"); return 1;
+               default:        printf ("ERROR %s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc); return 1;
+       }
+  return 1;
+}
+
+
+int mpl_prg_image(unsigned long load_addr)
+{
+       unsigned long data,len,checksum;
+       image_header_t *hdr=&header;  
+       /* Copy header so we can blank CRC field for re-calculation */
+       memcpy (&header, (char *)load_addr, sizeof(image_header_t));
+       if (hdr->ih_magic  != IH_MAGIC) {
+               printf ("Bad Magic Number\n");
+               return 1;
+       }
+       print_image_hdr(hdr);
+       if (hdr->ih_os  != IH_OS_PPCBOOT) {
+               printf ("No PPCBOOT Image\n");
+               return 1;
+       }
+       if (hdr->ih_type  != IH_TYPE_FIRMWARE) {
+               printf ("No Firmware Image\n");
+               return 1;
+       }
+       data = (ulong)&header;
+       len  = sizeof(image_header_t);
+       checksum = hdr->ih_hcrc;
+       hdr->ih_hcrc = 0;
+       if (crc32 (0, (char *)data, len) != checksum) {
+               printf ("Bad Header Checksum\n");
+               return 1;
+       }
+       data = load_addr + sizeof(image_header_t);
+       len  = hdr->ih_size;
+       printf ("Verifying Checksum ... ");
+       if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) {
+               printf ("Bad Data CRC\n");
+               return 1;
+       }
+       switch (hdr->ih_comp) {
+       case IH_COMP_NONE:
+               break;
+       case IH_COMP_GZIP:
+               printf ("  Uncompressing  ... ");
+               if (gunzip ((void *)(data+0x100000), 0x400000,
+                           (uchar *)data, (int *)&len) != 0) {
+                       printf ("GUNZIP ERROR\n");
+                       return 1;
+               }
+               data+=0x100000;
+               break;
+       default:
+               printf ("   Unimplemented compression type %d\n", hdr->ih_comp);
+               return 1;
+       }
+
+       printf ("  OK\n");
+       return(mpl_prg(data,len));
+} 
+
+
+void get_backup_values(backup_t *buf)
+{
+       eeprom_read(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,(void *)buf,sizeof(backup_t));
+}
+
+void set_backup_values(int overwrite)
+{
+       backup_t back;
+       int i;
+
+       get_backup_values(&back);
+       if(!overwrite) {
+               if(strncmp(back.signature,"MPL\0",4)==0) {
+                       printf("Not possible to write Backup\n");
+                       return;
+               }
+       }
+       memcpy(back.signature,"MPL\0",4);
+       i=getenv_r("serial#",back.serial_name,16);
+       if(i==0) {
+               printf("Not possible to write Backup\n");
+               return;
+       }
+       back.serial_name[16]=0;
+       i=getenv_r("ethaddr",back.eth_addr,20);
+       if(i==0) {
+               printf("Not possible to write Backup\n");
+               return;
+       }
+       back.eth_addr[20]=0;
+       eeprom_write(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,(void *)&back,sizeof(backup_t));
+}
+
+void clear_env_values(void)
+{
+       backup_t back;
+       unsigned char env_crc[4];
+       
+       memset(&back,0xff,sizeof(backup_t));
+       memset(env_crc,0x00,4);
+       eeprom_write(CFG_DEF_EEPROM_ADDR,I2C_BACKUP_ADDR,(void *)&back,sizeof(backup_t));
+       eeprom_write(CFG_DEF_EEPROM_ADDR,CFG_ENV_OFFSET,(void *)env_crc,4);
+}
+       
+/* ------------------------------------------------------------------------- */
+
+       /* switches the cs0 and the cs1 to the locations. 
+          When boot is TRUE, the the mapping is switched 
+          to the boot configuration, If it is FALSE, the
+          flash will be switched in the boot area */
+
+#undef SW_CS_DBG
+#ifdef SW_CS_DBG
+#define        SW_CS_PRINTF(fmt,args...)       printf (fmt ,##args)
+#else
+#define SW_CS_PRINTF(fmt,args...)
+#endif
+
+
+int switch_cs(unsigned char boot)
+{
+       unsigned long pbcr;
+       mtdcr(ebccfga, pb0cr); /* get cs0 config reg */
+       pbcr = mfdcr(ebccfgd);
+       if((pbcr&0x00002000)==0) {  
+               /* we need only to switch if boot from MPS */
+               /*printf(" MPS boot mode detected. ");*/ 
+               /* printf("cs0 cfg: %lx\n",pbcr); */
+               if(boot) { 
+                       /* switch to boot configuration */
+                       /* this is a 8bit boot, switch cs0 to flash location */
+                       SW_CS_PRINTF("switch to boot mode (MPS on High address\n");  
+                       pbcr&=0x000FFFFF; /*mask base address of the cs0 */
+                       pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
+                       mtdcr(ebccfga, pb0cr);
+                       mtdcr(ebccfgd, pbcr);
+                       SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr); 
+                       mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
+                       pbcr = mfdcr(ebccfgd);
+                       SW_CS_PRINTF(" old cs1 cfg: %lx\n",pbcr); 
+                       pbcr&=0x000FFFFF; /*mask base address of the cs1 */
+                       pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
+                       mtdcr(ebccfga, pb1cr);
+                       mtdcr(ebccfgd, pbcr);
+                       SW_CS_PRINTF("  new cs1 cfg: %lx, MPS is on High Address\n",pbcr); 
+               }
+               else 
+               { 
+                       /* map flash to boot area, */
+                       SW_CS_PRINTF("map Flash to boot area\n"); 
+                       pbcr&=0x000FFFFF; /*mask base address of the cs0 */
+                       pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
+                       mtdcr(ebccfga, pb0cr);
+                       mtdcr(ebccfgd, pbcr);
+                       SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr); 
+                       mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
+                       pbcr = mfdcr(ebccfgd);
+                       SW_CS_PRINTF("  cs1 cfg: %lx\n",pbcr); 
+                       pbcr&=0x000FFFFF; /*mask base address of the cs1 */
+                       pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
+                       mtdcr(ebccfga, pb1cr);
+                       mtdcr(ebccfgd, pbcr);
+                       SW_CS_PRINTF("  new cs1 cfg: %lx Flash is on High Address\n",pbcr); 
+               }
+               return 1;
+       }
+       else {
+               SW_CS_PRINTF("Normal boot, no switching necessary\n"); 
+               return 0;
+       }
+}
+
+
+int do_mplcommon(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
+{
+       ulong size,src,load_addr;
+       int result;     
+       backup_t back;
+       src = MULTI_PURPOSE_SOCKET_ADDR;
+       size = IMAGE_SIZE;
+
+       if (strcmp(argv[1], "flash") == 0) 
+       {
+#if (CONFIG_COMMANDS & CFG_CMD_FDC)
+               if (strcmp(argv[2], "floppy") == 0) {
+                       char *local_args[3];
+                       extern int do_fdcboot (cmd_tbl_t *, bd_t *, int, int, char *[]);
+                       printf ("\nupdating bootloader image from floppy\n");
+                       local_args[0] = argv[0];
+                       if(argc==4) {
+                               local_args[1] = argv[3];
+                               local_args[2] = NULL;
+                               load_addr=simple_strtoul(argv[3], NULL, 16);
+                               result=do_fdcboot(cmdtp, bd, 0, 2, local_args);
+                       }
+                       else {
+                               local_args[1] = NULL;
+                               load_addr=CFG_LOAD_ADDR;
+                               result=do_fdcboot(cmdtp, bd, 0, 1, local_args);
+                       }
+                       result=mpl_prg_image(load_addr); 
+                       return result;
+               }
+#endif /* (CONFIG_COMMANDS & CFG_CMD_FDC) */
+               if (strcmp(argv[2], "mem") == 0) {
+                       if(argc==4) {
+                               load_addr=simple_strtoul(argv[3], NULL, 16);
+                       }
+                       else {
+                               load_addr=CFG_LOAD_ADDR;
+                       }
+                       printf ("\nupdating bootloader image from memory at %lX\n",load_addr);
+                       result=mpl_prg_image(load_addr); 
+                       return result;
+               }
+               if (strcmp(argv[2], "mps") == 0) {
+                       printf ("\nupdating bootloader image from MSP\n");
+                       result=mpl_prg(src,size);
+                       return result;
+               }
+               
+       }
+       if (strcmp(argv[1], "mem") == 0) 
+       {
+               result=0;
+               if(argc==3)
+               {
+                       result = (int)simple_strtol(argv[2], NULL, 16);
+           }
+           src=(unsigned long)&result;
+           src-=CFG_MEMTEST_START;
+           src-=(100*1024); /* - 100k */
+           src&=0xfff00000;
+           size=0;
+           do {
+               size++;
+                       printf("\n\nPass %ld\n",size);
+                       mem_test(CFG_MEMTEST_START,src,1);
+                       if(ctrlc())
+                               break;
+                       if(result>0)
+                               result--;
+                       
+               }while(result);
+               return 0;
+       }
+       if (strcmp(argv[1], "clearenvvalues") == 0) 
+       {
+               if (strcmp(argv[2], "yes") == 0)
+               {
+                       clear_env_values();
+                       return 0;
+               }
+       }
+       if (strcmp(argv[1], "getback") == 0) {
+               get_backup_values(&back);
+               back.signature[3]=0;
+               back.serial_name[16]=0;
+               back.eth_addr[20]=0;
+               printf("GetBackUp: signature: %s\n",back.signature);
+               printf("           serial#:   %s\n",back.serial_name);
+               printf("           ethaddr:   %s\n",back.eth_addr);
+               return 0;
+       } 
+       if (strcmp(argv[1], "setback") == 0) {
+               set_backup_values(1);
+               return 0;
+       }
+#if 0
+       if (strcmp(argv[1], "test") == 0) {
+               char *local_args[6];
+               int i;
+               extern int do_doc(cmd_tbl_t *, bd_t *, int, int, char *[]);
+               local_args[0] = argv[0];
+           for(i=1;i<5;i++) {
+               if(i+1<argc) {
+                               local_args[i]=argv[i+1];
+                       }
+                       else {
+                               local_args[i]=NULL;
+                       }
+               }
+               local_args[5]=NULL;
+               result=do_doc(cmdtp, bd, 0, argc-1, local_args);
+               return 0;
+       }
+       if (strcmp(argv[1], "test1") == 0) {
+               char *local_args[6];
+               int i;
+               extern int do_docboot(cmd_tbl_t *, bd_t *, int, int, char *[]);
+               local_args[0] = argv[0];
+           for(i=1;i<5;i++) {
+               if(i+1<argc) {
+                               local_args[i]=argv[i+1];
+                       }
+                       else {
+                               local_args[i]=NULL;
+                       }
+               }
+               local_args[5]=NULL;
+               result=do_docboot(cmdtp, bd, 0, argc-1, local_args);
+               return 0;
+       }
+#endif
+       printf("Usage:\n%s\n", cmdtp->usage);
+       return 1;
+}
+
+
diff --git a/board/mpl/common/common_util.h b/board/mpl/common/common_util.h
new file mode 100644 (file)
index 0000000..7f8ddef
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * (C) Copyright 2001
+ * Denis Peter, MPL AG Switzerland, d.peter@mpl.ch
+ *
+ * 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
+ *
+ */
+#ifndef _COMMON_UTIL_H_
+#define _COMMON_UTIL_H_
+
+typedef struct {
+       char signature[4];
+       char serial_name[17];   /* "MIP405_1000xxxxx" */
+       char eth_addr[21];                      /* "00:60:C2:0a:00:00" */
+} backup_t;
+
+int mpl_prg(unsigned long src,unsigned long size);
+int mpl_prg_image(unsigned long load_addr);
+void get_backup_values(backup_t *buf);
+void set_backup_values(int overwrite);
+void clear_env_values(void);
+int switch_cs(unsigned char boot);
+
+
+#endif /* _COMMON_UTIL_H_ */
+
index 6f2eef60c549aee76cfb5a0ea5707cc845341df7..95c9929dc11b0227f07b0b707947d5700fac6108 100644 (file)
@@ -44,6 +44,7 @@
 #ifdef CONFIG_MIP405
 #include "../mip405/mip405.h"
 #endif
+#include "common_util.h"
 
 flash_info_t   flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips        */
 /*-----------------------------------------------------------------------
index e573c949c333a5e47e9f60bf1c3b4d2fa03ea148..5be183fb650c7b0fef783d0aefd4b79c17820cdf 100644 (file)
@@ -450,7 +450,7 @@ int mem_test(unsigned long start, unsigned long ramsize, int quiet)
        prog++;
        printf(".");
        }
-       sprintf(dispbuf,"\n\nMemory Test: addr = 0x%lx size = 0x%lx\n",startaddr,size);
+       sprintf(dispbuf,"\nMemory Test: addr = 0x%lx size = 0x%lx\n",startaddr,size);
   testm_puts(quiet,dispbuf);
        for(stage=0;stage<TEST_STAGES;stage++){
                sprintf(dispbuf,test_stage[stage].test_write_desc); 
index 2be414186fa4dcae13d0de485ff423610fc7c1c6..5fb884ebca9920e4cae60aac1ddcdbd94a2403e5 100644 (file)
@@ -83,7 +83,7 @@ static PCI_DEV_CFG_TABLE pcidevtbl[]={
 {0x8086,0x7110,        0xff,0, {
        {PCI_CFG_PIIX4_SERIRQ,  0xD0,           1},/* enable Continous SERIRQ Pin */
        {PCI_CFG_PIIX4_GENCFG,  0x00010000,     4},/* enable SERIRQs     */
-       {PCI_CFG_PIIX4_XBCS,    0x0080,         2}, /* disable all peri CS  */
+       {PCI_CFG_PIIX4_XBCS,    0x02C4,         2}, /* disable all peri CS  */
        {PCI_CFG_PIIX4_RTCCFG,  0x21,           1}, /* enable RTC          */
        {0xFFFF, 0,0}}                          /* end of device table */
 },
index bcb1da58cd2cd466e5f4a9021ae98ded89b1223d..686ae06f3817eb80680a16d57cd51da624f5c5a1 100644 (file)
@@ -25,7 +25,9 @@ include $(TOPDIR)/config.mk
 
 LIB    = lib$(BOARD).a
 
-OBJS   = $(BOARD).o ../common/flash.o cmd_mip405.o ../common/pci.o ../common/usb_uhci.o ../common/memtst.o
+OBJS   = $(BOARD).o ../common/flash.o cmd_mip405.o ../common/pci.o \
+                       ../common/usb_uhci.o ../common/memtst.o ../common/common_util.o 
+                 
 SOBJS  = init.o
 
 $(LIB):        $(OBJS) $(SOBJS)
index 3829a24a53dba262f25ddec9fa209aa1a0dd50d0..9449f535a0580423ffd8d6d743b6fdd1b18d4cb0 100644 (file)
  * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  * MA 02111-1307 USA
  *
- * hacked for PIP405
+ * hacked for MIP405
  */
 
 #include <ppcboot.h>
 #include <command.h> 
 #include "mip405.h"
-#include <rtc.h>
-#include "../common/isa.h"
-#include "../common/video.h"
-#include <i2c.h>
-extern flash_info_t flash_info[];      /* info for FLASH chips */
+#include "../common/common_util.h"
 
-int PCI_Write_CFG_Reg(int BusDevFunc, int Reg, unsigned int Value, int Width);
-unsigned int PCI_Read_CFG_Reg(int BusDevFunc, int Reg, int Width);
-extern void print_mip405_info(void);
-
-
-
-
-
-#define TRUE 1
-#define FALSE 0
-
-#define IMAGE_SIZE 0x80000 
-
-image_header_t header;
-
-
-
-int mip405_prg(unsigned long src,unsigned long size)
-{
-       unsigned long start;
-       flash_info_t *info;
-       int i,rc;
-       unsigned long *magic = (unsigned long *)src;
-       
-       info = &flash_info[0];
-       start = 0 - size;
-       for(i=info->sector_count-1;i>0;i--)
-       {
-               info->protect[i] = 0; /* unprotect this sector */
-               if(start>=info->start[i])
-               break;
-       }
-       /* set-up flash location */
-       /* now erase flash */
-       if(magic[0]!=IH_MAGIC) {
-               printf("Bad Magic number\n");
-               return -1;
-       }
-       printf("Start erasing at %lx (sector %d) (start %lx)\n",
-                               start,i,info->start[i]);
-       flash_erase (info, i, info->sector_count-1);
-       printf("flash erased, programming from 0x%lx 0x%lx Bytes\n",src,size);
-       switch (rc = flash_write ((uchar *)src, start, size)) 
-       {
-               case 0: printf ("programming done\n"); return 0;
-               case 1: printf ("Timeout writing to Flash\n"); return 1;
-               case 2: printf ("Flash not Erased\n"); return 1;
-               case 4: printf ("Can't write to protected Flash sectors\n"); return 1;
-               case 8: printf ("Outside available Flash\n"); return 1;
-               default:        printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc); return 1;
-       }
-  return 1;
-}
-
-
-int mip405_prg_image(unsigned long load_addr)
-{
-       unsigned long data,len,checksum;
-       image_header_t *hdr=&header;  
-       /* Copy header so we can blank CRC field for re-calculation */
-       memcpy (&header, (char *)load_addr, sizeof(image_header_t));
 
-       if (hdr->ih_magic  != IH_MAGIC) {
-               printf ("Bad Magic Number\n");
-               return 1;
-       }
-       if (hdr->ih_os  != IH_OS_PPCBOOT) {
-               printf ("No PPCBOOT Image\n");
-               return 1;
-       }
-       if (hdr->ih_type  != IH_TYPE_FIRMWARE) {
-               printf ("No Firmware Image\n");
-               return 1;
-       }
-       data = (ulong)&header;
-       len  = sizeof(image_header_t);
-       checksum = hdr->ih_hcrc;
-       hdr->ih_hcrc = 0;
-       if (crc32 (0, (char *)data, len) != checksum) {
-               printf ("Bad Header Checksum\n");
-               return 1;
-       }
-       data = load_addr + sizeof(image_header_t);
-       len  = hdr->ih_size;
-       printf ("   Verifying Checksum ... ");
-       if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) {
-               printf ("Bad Data CRC\n");
-               return 1;
-       }
-       printf ("OK\n");
-       return(mip405_prg(data,len));
-} 
+extern void print_mip405_info(void);
+extern int do_mplcommon(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
 
 
 /* ------------------------------------------------------------------------- */
@@ -132,83 +38,20 @@ int mip405_prg_image(unsigned long load_addr)
 int do_mip405(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 {
 
-       ulong size,src,device,load_addr;
-       int result;     
-       backup_t back;
-       src = MULTI_PURPOSE_SOCKET_ADDR;
-       size = IMAGE_SIZE;
+       ulong led_on;
 
-       if (strcmp(argv[1], "flash") == 0) 
-       {
-               if (strcmp(argv[2], "mem") == 0) {
-                       if(argc==4) {
-                               load_addr=simple_strtoul(argv[3], NULL, 16);
-                       }
-                       else {
-                               load_addr=CFG_LOAD_ADDR;
-                       }
-                       printf ("\nupdating bootloader image from memory at %lX\n",load_addr);
-                       result=mip405_prg_image(load_addr); 
-                       return result;
-               }
-               if (strcmp(argv[2], "mps") == 0) {
-                       printf ("\nupdating bootloader image from MSP\n");
-                       result=mip405_prg(src,size);
-                       return result;
-               }
-               
-       }
-       if (strcmp(argv[1], "mem") == 0) 
-       {
-               result=0;
-               if(argc==3)
-               {
-                       result = (int)simple_strtol(argv[2], NULL, 16);
-           }
-           src=(unsigned long)&result;
-           src-=CFG_MEMTEST_START;
-           src-=(100*1024); /* - 100k */
-           src&=0xfff00000;
-           size=0;
-           do {
-               size++;
-                       printf("Pass %ld\n",size);
-                       mem_test(CFG_MEMTEST_START,src,1);
-                       if(ctrlc())
-                               break;
-                       if(result>0)
-                               result--;
-                       
-               }while(result);
-               return 0;
-       }
-       if (strcmp(argv[1], "info") == 0) 
+       if (strcmp(argv[1], "info") == 0) 
        {
                print_mip405_info();
                return 0;
        }
        if (strcmp(argv[1], "led") == 0) 
        {
-               device = (ulong)simple_strtoul(argv[2], NULL, 10);
-               user_led0((device==1));
+               led_on = (ulong)simple_strtoul(argv[2], NULL, 10);
+               user_led0(led_on);
                return 0;
        }
-       if (strcmp(argv[1], "getback") == 0) {
-               get_backup_values(&back);
-               back.signature[3]=0;
-               back.serial_name[16]=0;
-               back.eth_addr[20]=0;
-               printf("GetBackUp: signature: %s\n",back.signature);
-               printf("           serial#:   %s\n",back.serial_name);
-               printf("           ethaddr:   %s\n",back.eth_addr);
-               return 0;
-       } 
-       if (strcmp(argv[1], "setback") == 0) {
-               set_backup_values(1);
-               return 0;
-       } 
-       printf("Usage:\n%s\n", cmdtp->usage);
-    return 1;
+       return (do_mplcommon(cmdtp, bd, flag, argc, argv));
 }
 
 /* ------------------------------------------------------------------------- */
index 0e4dcb2e14a44bf7f0aabc5226f61a2620807852..e151809d3869245d0520576e234bccc2bda9dab2 100644 (file)
@@ -68,6 +68,7 @@
 #include <405gp_i2c.h>
 #include <miiphy.h>
 #include <devices.h>
+#include "../common/common_util.h"
 
 extern block_dev_desc_t * scsi_get_dev(int dev);
 extern block_dev_desc_t * ide_get_dev(int dev);
@@ -466,49 +467,6 @@ void ide_set_reset(int idereset)
                out8(PLD_COM_MODE_REG,(in8(PLD_COM_MODE_REG)&0xfe));
 }
 
-#define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */
-
-void get_backup_values(backup_t *buf)
-{
-       eeprom_read (CFG_DEF_EEPROM_ADDR,
-                    I2C_BACKUP_ADDR,
-                    (void *)buf,
-                    sizeof(backup_t));
-}
-
-void set_backup_values(int overwrite)
-{
-       backup_t back;
-       int i;
-
-       get_backup_values(&back);
-       if(!overwrite) {
-               if(strncmp(back.signature,"MPL\0",4)==0) {
-                       printf("Not possible to write Backup\n");
-                       return;
-               }
-       }
-       memcpy(back.signature,"MPL\0",4);
-       i=getenv_r("serial#",back.serial_name,16);
-       if(i==0) {
-               printf("Not possible to write Backup\n");
-               return;
-       }
-       back.serial_name[16]=0;
-       i=getenv_r("ethaddr",back.eth_addr,20);
-       if(i==0) {
-               printf("Not possible to write Backup\n");
-               return;
-       }
-       back.eth_addr[20]=0;
-       eeprom_write (CFG_DEF_EEPROM_ADDR,
-                     CFG_ENV_OFFSET+I2C_BACKUP_ADDR,
-                     (void *)&back,
-                     sizeof(backup_t));
-}
-
-
-
 
 /* ------------------------------------------------------------------------- */
 
@@ -618,74 +576,6 @@ int testdram (unsigned long ramsize)
                return(1);
 }
 
-/* ------------------------------------------------------------------------- */
-
-       /* switches the cs0 and the cs1 to the locations.
-          When boot is TRUE, the the mapping is switched
-          to the boot configuration, If it is FALSE, the
-          flash will be switched in the boot area */
-
-#undef SW_CS_DBG
-#ifdef SW_CS_DBG
-#define        SW_CS_PRINTF(fmt,args...)       printf (fmt ,##args)
-#else
-#define SW_CS_PRINTF(fmt,args...)
-#endif
-
-
-int switch_cs(unsigned char boot)
-{
-       unsigned long pbcr;
-       mtdcr(ebccfga, pb0cr); /* get cs0 config reg */
-       pbcr = mfdcr(ebccfgd);
-       if((pbcr&0x00002000)==0) {
-               /* we need only to switch if boot from MPS */
-               /*printf(" MPS boot mode detected. ");*/
-               /* printf("cs0 cfg: %lx\n",pbcr); */
-               if(boot==TRUE) {
-                       /* switch to boot configuration */
-                       /* this is a 8bit boot, switch cs0 to flash location */
-                       SW_CS_PRINTF("switch to boot mode (MPS on High address\n");
-                       pbcr&=0x000FFFFF; /*mask base address of the cs0 */
-                       pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
-                       mtdcr(ebccfga, pb0cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr);
-                       mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
-                       pbcr = mfdcr(ebccfgd);
-                       SW_CS_PRINTF(" old cs1 cfg: %lx\n",pbcr);
-                       pbcr&=0x000FFFFF; /*mask base address of the cs1 */
-                       pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
-                       mtdcr(ebccfga, pb1cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs1 cfg: %lx, MPS is on High Address\n",pbcr);
-               }
-               else
-               {
-                       /* map flash to boot area, */
-                       SW_CS_PRINTF("map Flash to boot area\n");
-                       pbcr&=0x000FFFFF; /*mask base address of the cs0 */
-                       pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
-                       mtdcr(ebccfga, pb0cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr);
-                       mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
-                       pbcr = mfdcr(ebccfgd);
-                       SW_CS_PRINTF("  cs1 cfg: %lx\n",pbcr);
-                       pbcr&=0x000FFFFF; /*mask base address of the cs1 */
-                       pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
-                       mtdcr(ebccfga, pb1cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs1 cfg: %lx Flash is on High Address\n",pbcr);
-               }
-               return TRUE;
-       }
-       else {
-               SW_CS_PRINTF("Normal boot, no switching necessary\n");
-               return FALSE;
-       }
-}
-
 void misc_init_r(bd_t *bd)
 {
 #if 0
@@ -809,6 +699,7 @@ void print_mip405_info(void)
        printf("Population Options %d %d %d %d\n",(cfg)&0x1,(cfg>>1)&0x1,(cfg>>2)&0x1,(cfg>>3)&0x1);
        printf("User LED %s\n",(com_mode & 0x4) ? "on" : "off");
        printf("UART Clocks %d\n",(com_mode>>4)&0x3);
+       printf("Test ist %x\n",com_mode);
        printf("User Config Switch %d %d %d %d %d %d %d %d\n",
                (ext)&0x1,(ext>>1)&0x1,(ext>>2)&0x1,(ext>>3)&0x1,(ext>>4)&0x1,(ext>>5)&0x1,(ext>>6)&0x1,(ext>>7)&0x1);
        printf("SER1 uses handshakes %s\n",(ext & 0x80) ? "DTR/DSR" : "RTS/CTS");
index a4ce24391d9055ba5e1e4e07be9756ae63809f1d..c284f371ac5739d86d80dc7fd1fc8112b0034c59 100644 (file)
  * Global routines used for MIP405
  *****************************************************************************/
 #ifndef __ASSEMBLY__ 
-int switch_cs(unsigned char boot);
+/*int switch_cs(unsigned char boot);*/
 
 extern int  mem_test(unsigned long start, unsigned long ramsize,int mode); 
 
 void user_led0(unsigned char on);
 
-typedef struct {
-       char signature[4];
-       char serial_name[17];   /* "MIP405_1000xxxxx" */
-       char eth_addr[21];                      /* "00:60:C2:0a:00:00" */
-} backup_t;
-void get_backup_values(backup_t *buf);
-void set_backup_values(int overwrite);
 
 
 #endif
index 802ab607820d8aa433c908ab77299c7804d8b891..1e6d57ab24315b65656f6379d30bc3e2b0e7bb4c 100644 (file)
@@ -25,7 +25,12 @@ include $(TOPDIR)/config.mk
 
 LIB    = lib$(BOARD).a
 
-OBJS   = $(BOARD).o ../common/flash.o cmd_pip405.o ../common/pci.o ../common/isa.o ../common/kbd.o ../common/video.o ../common/sym53c8xx.o ../common/usb_uhci.o ../common/memtst.o
+OBJS   = $(BOARD).o \
+         ../common/flash.o cmd_pip405.o ../common/pci.o \
+         ../common/isa.o ../common/kbd.o ../common/video.o \
+         ../common/sym53c8xx.o ../common/usb_uhci.o \
+         ../common/memtst.o ../common/common_util.o
+
 SOBJS  = init.o
 
 $(LIB):        $(OBJS) $(SOBJS)
index e4f5e0be89c71a45b72d35a53f55cda1496f7fbe..c3efd98a17e38b0b36d0144c62eded9434ef2286 100644 (file)
 #include <ppcboot.h>
 #include <command.h>
 #include "pip405.h"
-#include <rtc.h>
-#include "../common/isa.h"
-#include "../common/video.h"
-#include <i2c.h>
+#include "../common/common_util.h"
  
-extern flash_info_t flash_info[];      /* info for FLASH chips */
 
-int PCI_Write_CFG_Reg(int BusDevFunc, int Reg, unsigned int Value, int Width);
-unsigned int PCI_Read_CFG_Reg(int BusDevFunc, int Reg, int Width);
+extern void print_pip405_info(void);
+extern int do_mplcommon(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
 
 
 
-
-
-#define TRUE 1
-#define FALSE 0
-
-#define IMAGE_SIZE 0x80000 
-
-image_header_t header;
-
-
-
-int pip405_prg(unsigned long src,unsigned long size)
-{
-       unsigned long start;
-       flash_info_t *info;
-       int i,rc;
-       unsigned long *magic = (unsigned long *)src;
-       
-       info = &flash_info[0];
-       start = 0 - size;
-       for(i=info->sector_count-1;i>0;i--)
-       {
-               info->protect[i] = 0; /* unprotect this sector */
-               if(start>=info->start[i])
-               break;
-       }
-       /* set-up flash location */
-       rc=switch_cs(FALSE);
-       /* now erase flash */
-       if(magic[0]!=IH_MAGIC) {
-               printf("Bad Magic number\n");
-               switch_cs(rc);
-               return -1;
-       }
-       printf("Start erasing at %lx (sector %d) (start %lx)\n",
-                               start,i,info->start[i]);
-       flash_erase (info, i, info->sector_count-1);
-       printf("flash erased, programming 0x%lx Bytes\n",size);
-       switch (rc = flash_write ((uchar *)src, start, size)) 
-       {
-               case 0: printf ("programming done\n"); return 0;
-               case 1: printf ("Timeout writing to Flash\n"); return 1;
-               case 2: printf ("Flash not Erased\n"); return 1;
-               case 4: printf ("Can't write to protected Flash sectors\n"); return 1;
-               case 8: printf ("Outside available Flash\n"); return 1;
-               default:        printf ("%s[%d] FIXME: rc=%d\n",__FILE__,__LINE__,rc); return 1;
-       }
-  return 1;
-}
-
-int pip405_prg_image(unsigned long load_addr)
-{
-       unsigned long data,len,checksum;
-       image_header_t *hdr=&header;  
-       /* Copy header so we can blank CRC field for re-calculation */
-       memcpy (&header, (char *)load_addr, sizeof(image_header_t));
-
-       if (hdr->ih_magic  != IH_MAGIC) {
-               printf ("Bad Magic Number\n");
-               return 1;
-       }
-       if (hdr->ih_os  != IH_OS_PPCBOOT) {
-               printf ("No PPCBOOT Image\n");
-               return 1;
-       }
-       if (hdr->ih_type  != IH_TYPE_FIRMWARE) {
-               printf ("No Firmware Image\n");
-               return 1;
-       }
-       data = (ulong)&header;
-       len  = sizeof(image_header_t);
-       checksum = hdr->ih_hcrc;
-       hdr->ih_hcrc = 0;
-       if (crc32 (0, (char *)data, len) != checksum) {
-               printf ("Bad Header Checksum\n");
-               return 1;
-       }
-       data = load_addr + sizeof(image_header_t);
-       len  = hdr->ih_size;
-       printf ("   Verifying Checksum ... ");
-       if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) {
-               printf ("Bad Data CRC\n");
-               return 1;
-       }
-       printf ("OK\n");
-       return(pip405_prg(data,len));
-} 
-
-
 /* ------------------------------------------------------------------------- */
 
 int do_pip405(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 {
 
-       ulong size,src,device,function,load_addr;
-       unsigned char i2c[3];
-       int result;     
-       backup_t back;  
-       src = MULTI_PURPOSE_SOCKET_ADDR;
-       size = IMAGE_SIZE;
+       ulong led_on,led_nr;
+
+       if (strcmp(argv[1], "info") == 0) 
+       {
+               print_pip405_info();
+               return 0;
+       }
+       if (strcmp(argv[1], "led") == 0) 
+       {
+               led_nr = (ulong)simple_strtoul(argv[2], NULL, 10);
+               led_on = (ulong)simple_strtoul(argv[3], NULL, 10);
+               if(!led_nr)
+                       user_led0(led_on);
+               else
+                       user_led1(led_on);
+               return 0;
+       }
 
+#if 0
        if (strcmp(argv[1], "flash") == 0) 
        {
                if (strcmp(argv[2], "floppy") == 0) {
@@ -157,7 +76,7 @@ int do_pip405(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
                                load_addr=CFG_LOAD_ADDR;
                                result=do_fdcboot(cmdtp, bd, 0, 1, local_args);
                        }
-                       result=pip405_prg_image(load_addr); 
+                       result=mpl_prg_image(load_addr); 
                        return result;
                }
                if (strcmp(argv[2], "mem") == 0) {
@@ -168,12 +87,12 @@ int do_pip405(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
                                load_addr=CFG_LOAD_ADDR;
                        }
                        printf ("\nupdating bootloader image from memory at %lX\n",load_addr);
-                       result=pip405_prg_image(load_addr); 
+                       result=mpl_prg_image(load_addr); 
                        return result;
                }
                if (strcmp(argv[2], "mps") == 0) {
                        printf ("\nupdating bootloader image from MSP\n");
-                       result=pip405_prg(src,size);
+                       result=mpl_prg(src,size);
                        return result;
                }
        }
@@ -191,6 +110,14 @@ int do_pip405(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
                set_backup_values(1);
                return 0;
        } 
+       if (strcmp(argv[1], "clearenvvalues") == 0) 
+       {
+               if (strcmp(argv[2], "yes") == 0)
+               {
+                       clear_env_values();
+                       return 0;
+               }
+       }
        if (strcmp(argv[1], "mem") == 0) 
        {
                result=0;
@@ -215,31 +142,8 @@ int do_pip405(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
                }while(result);
                return 0;
        }
-       if (strcmp(argv[1], "info") == 0) 
-       {
-               print_pip405_info();
-               return 0;
-       }
-       if (strcmp(argv[1], "i2c") == 0) 
-       {
-               i2c[0]=CFG_I2C_EEPROM_ADDR;
-               i2c[1]=0;
-               i2c[2]=0;
-               i2c_read(&i2c[0],3,(unsigned char *)CFG_LOAD_ADDR,512);
-               return 0;
-       }
-       if (strcmp(argv[1], "led") == 0) 
-       {
-               device = (ulong)simple_strtoul(argv[2], NULL, 10);
-               function = (ulong)simple_strtoul(argv[3], NULL, 10);
-               if(device==0)
-                       user_led0((function==1));
-               else
-                       user_led1((function==1));
-               return 0;
-       }
-    printf("Usage:\n%s\n", cmdtp->usage);
-    return 1;
+ #endif        
+       return (do_mplcommon(cmdtp, bd, flag, argc, argv));
 }
 
 /* ------------------------------------------------------------------------- */
index f961eb4c2f962753432630e1773c51db2af41b46..6df8eb207ddc5b9cadd26a6b1861261efe37b40b 100644 (file)
@@ -31,6 +31,7 @@
 #include <devices.h>
 #include "../common/isa.h"
 #include "../common/video.h"
+#include "../common/common_util.h"
 
 
 extern block_dev_desc_t * scsi_get_dev(int dev);
@@ -543,47 +544,6 @@ int board_pre_init (void)
 
 
 /* ------------------------------------------------------------------------- */
-#define I2C_BACKUP_ADDR 0x7C00 /* 0x200 bytes for backup */
-
-void get_backup_values(backup_t *buf)
-{
-       eeprom_read (CFG_DEF_EEPROM_ADDR,
-                    I2C_BACKUP_ADDR,
-                    (void *)buf,
-                    sizeof(backup_t));
-}
-
-void set_backup_values(int overwrite)
-{
-       backup_t back;
-       int i;
-
-       get_backup_values(&back);
-       if(!overwrite) {
-               if(strncmp(back.signature,"MPL\0",4)==0) {
-                       printf("Not possible to write Backup\n");
-                       return;
-               }
-       }
-       memcpy(back.signature,"MPL\0",4);
-       i=getenv_r("serial#",back.serial_name,16);
-       if(i==0) {
-               printf("Not possible to write Backup\n");
-               return;
-       }
-       back.serial_name[16]=0;
-       i=getenv_r("ethaddr",back.eth_addr,20);
-       if(i==0) {
-               printf("Not possible to write Backup\n");
-               return;
-       }
-       back.eth_addr[20]=0;
-       eeprom_write (CFG_DEF_EEPROM_ADDR,
-                     CFG_ENV_OFFSET+I2C_BACKUP_ADDR,
-                     (void *)&back,
-                     sizeof(backup_t));
-}
-
 
 /*
  * Check Board Identity:
@@ -677,74 +637,6 @@ int testdram (unsigned long ramsize)
                return(1);
 }
 
-/* ------------------------------------------------------------------------- */
-
-       /* switches the cs0 and the cs1 to the locations. 
-          When boot is TRUE, the the mapping is switched 
-          to the boot configuration, If it is FALSE, the
-          flash will be switched in the boot area */
-
-
-#undef SW_CS_DBG
-#ifdef SW_CS_DBG
-#define        SW_CS_PRINTF(fmt,args...)       printf (fmt ,##args)
-#else
-#define SW_CS_PRINTF(fmt,args...)
-#endif
-
-
-int switch_cs(unsigned char boot)
-{
-       unsigned long pbcr;
-       mtdcr(ebccfga, pb0cr); /* get cs0 config reg */
-       pbcr = mfdcr(ebccfgd);
-       if((pbcr&0x00002000)==0) {  
-               /* we need only to switch if boot from MPS */
-               SW_CS_PRINTF(" MPS boot mode detected. "); 
-               /* printf("cs0 cfg: %lx\n",pbcr); */
-               if(boot==TRUE) { 
-                       /* switch to boot configuration */
-                       /* this is a 8bit boot, switch cs0 to flash location */
-                       SW_CS_PRINTF("switch to boot mode (MPS on High address\n");  
-                       pbcr&=0x000FFFFF; /*mask base address of the cs0 */
-                       pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
-                       mtdcr(ebccfga, pb0cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr); 
-                       mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
-                       pbcr = mfdcr(ebccfgd);
-                       SW_CS_PRINTF(" old cs1 cfg: %lx\n",pbcr); 
-                       pbcr&=0x000FFFFF; /*mask base address of the cs1 */
-                       pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
-                       mtdcr(ebccfga, pb1cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs1 cfg: %lx, MPS is on High Address\n",pbcr); 
-               }
-               else 
-               { 
-                       /* map flash to boot area, */
-                       SW_CS_PRINTF("map Flash to boot area\n"); 
-                       pbcr&=0x000FFFFF; /*mask base address of the cs0 */
-                       pbcr|=(MULTI_PURPOSE_SOCKET_ADDR & 0xFFF00000);
-                       mtdcr(ebccfga, pb0cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs0 cfg: %lx\n",pbcr); 
-                       mtdcr(ebccfga, pb1cr); /* get cs1 config reg (flash) */
-                       pbcr = mfdcr(ebccfgd);
-                       SW_CS_PRINTF("  cs1 cfg: %lx\n",pbcr); 
-                       pbcr&=0x000FFFFF; /*mask base address of the cs1 */
-                       pbcr|=(FLASH_BASE0_PRELIM & 0xFFF00000);
-                       mtdcr(ebccfga, pb1cr);
-                       mtdcr(ebccfgd, pbcr);
-                       SW_CS_PRINTF("  new cs1 cfg: %lx Flash is on High Address\n",pbcr); 
-               }
-               return TRUE;
-       }
-       else {
-               SW_CS_PRINTF("Normal boot, no switching necessary\n"); 
-               return FALSE;
-       }
-}
 
 void misc_init_r(bd_t *bd)
 {
index 7adfcef827a548e7c6aa56f1e85878eb9bd3d2fc..ee08035e2f0e6ee5cbebf0dc4f225056ff737ae4 100644 (file)
@@ -25,7 +25,6 @@
  * Global routines used for PIP405
  *****************************************************************************/
  
-int switch_cs(unsigned char boot);
 
 extern int  mem_test(unsigned long start, unsigned long ramsize,int mode); 
 
@@ -34,14 +33,6 @@ void print_pip405_info(void);
 void user_led0(unsigned char on);
 void user_led1(unsigned char on);
 
-typedef struct {
-       char signature[4];
-       char serial_name[17];   /* "PIP405_1000xxxxx" */
-       char eth_addr[21];                      /* "00:60:C2:08:00:00" */
-} backup_t;
-
-void get_backup_values(backup_t *buf);
-void set_backup_values(int overwrite);
 
 #define PLD_BASE_ADDRESS               CFG_ISA_IO_BASE_ADDRESS + 0x800
 #define PLD_PART_REG                           PLD_BASE_ADDRESS + 0
index c260b1843a9a2846ffc7df6fb0ed6465a03f3200..06f55ddf49eb0d394ccd35af50a23f8c9c4a6f29 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000, 2001
+ * (C) Copyright 2000
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
index b8ec990c4d072e552160ab57202e6fe137c6843c..83c7f19d627a57ea2ceb6ad917dc5044b3c828f5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000, 2001
+ * (C) Copyright 2000
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * See file CREDITS for list of people who contributed to this
index b87f5394737ce04ad633a91f8bc0631bc639035e..444bc767ba485fcbf610847b79d6d99ade27cd8c 100644 (file)
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    = lib$(BOARD).a
 
-OBJS   = $(BOARD).o flash.o ns16550.o serial.o speed.o dc2114x.o
+OBJS   = $(BOARD).o flash.o ns16550.o serial.o dc2114x.o
 SOBJS  = early_init.o
 
 $(LIB):        .depend $(OBJS) $(SOBJS)
index 256146e213bdb223a966256a30c10887e7697e4c..acc500f436cb5ad189fe136725956686ab0283f6 100644 (file)
@@ -32,10 +32,12 @@ static struct NS16550 *console = (struct NS16550 *) (CFG_EUMB_ADDR + 0x4500);
 #error no valid console defined
 #endif
 
+extern ulong get_bus_freq(ulong);
+
 void
 serial_init (unsigned long dummy, int baudrate)
 {
-    int clock_divisor = CFG_SERIAL_CLOCK / 16 / baudrate;
+    int clock_divisor = get_bus_freq(0) / 16 / baudrate;
 
     NS16550_init(CONFIG_CONS_INDEX - 1, clock_divisor);
 }
@@ -74,7 +76,7 @@ serial_tstc(void)
 void
 serial_setbrg (unsigned long dummy, int baudrate)
 {
-   int clock_divisor = CFG_SERIAL_CLOCK / 16 / baudrate;
+    int clock_divisor = get_bus_freq(0) / 16 / baudrate;
 
    NS16550_reinit(console, clock_divisor);
 }
diff --git a/board/musenki/speed.c b/board/musenki/speed.c
deleted file mode 100644 (file)
index 048fca1..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * (C) Copyright 2001
- * 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
- */
-
-#include <ppcboot.h>
-#include <mpc824x.h>
-#include <asm/processor.h>
-
-
-ulong get_bus_freq(ulong ignore)
-{
-       return 100000000;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/*
- * Measure CPU clock speed
- */
-
-/* Table to convert pllratio to actual processor clock scaling factor (*10)
- */
-#ifdef CONFIG_MPC8245          /* FIXME */
-short pllratio_to_factor[] = {
-    00, 00, 00, 10, 20, 20, 25, 00, 00, 00, 00, 00, 00, 00, 00, 00,
-    00, 00, 00, 10, 00, 00, 00, 45, 30, 00, 40, 00, 00, 00, 35, 00,
-};
-#endif
-
-ulong get_gclk_freq(void)
-{
-       uint hid1 = mfspr(HID1);
-
-       /* 5 bits for PLL ration on 8240/8245 */
-       hid1 = (hid1 >> (32-5)) & 0x1f;
-
-       return (pllratio_to_factor[hid1] * get_bus_freq(0)) / 10;
-}
-
-/* ------------------------------------------------------------------------- */
-
index 76c8a33e3ddf36349c565c84d954b7e1834d14ff..82856162f604735a32ec3e78addcefb330951cc0 100644 (file)
@@ -25,7 +25,7 @@ include $(TOPDIR)/config.mk
 
 LIB    = lib$(BOARD).a
 
-OBJS   = $(BOARD).o flash.o ns16550.o ns87308.o serial.o speed.o \
+OBJS   = $(BOARD).o flash.o ns16550.o ns87308.o serial.o \
          pci.o eepro100.o
 
 $(LIB):        .depend $(OBJS)
index ae69f75c4617a7b89889a0e7ca0e6b0d29810e46..e365d13d64b6b4f3580c723a9d2c4567213fa40f 100644 (file)
@@ -40,51 +40,52 @@ int checkflash (void)
        return (0);
 }
 
-static long dram_size (void)
+long int initdram (int board_type)
 {
-       static const unsigned long
-                       addressmask = 0x4ff00000, addressinc = 0x00100000;
-       long result = 0;
+       int              i, cnt;
+       volatile uchar * base= CFG_SDRAM_BASE;
+       volatile ulong * addr;
+       ulong            save[32];
+       ulong            val, ret  = 0;
 
-#if (CFG_BANK_ENABLE & 0x80)
-       result += (CFG_BANK7_END & addressmask) + addressinc -
-                 (CFG_BANK7_START & addressmask);
-#endif
-#if (CFG_BANK_ENABLE & 0x40)
-       result += (CFG_BANK6_END & addressmask) + addressinc -
-                 (CFG_BANK6_START & addressmask);
-#endif
-#if (CFG_BANK_ENABLE & 0x20)
-       result += (CFG_BANK5_END & addressmask) + addressinc -
-                 (CFG_BANK5_START & addressmask);
-#endif
-#if (CFG_BANK_ENABLE & 0x10)
-       result += (CFG_BANK4_END & addressmask) + addressinc -
-                 (CFG_BANK4_START & addressmask);
-#endif
-#if (CFG_BANK_ENABLE & 0x08)
-       result += (CFG_BANK3_END & addressmask) + addressinc -
-                 (CFG_BANK3_START & addressmask);
-#endif
-#if (CFG_BANK_ENABLE & 0x04)
-       result += (CFG_BANK2_END & addressmask) + addressinc -
-                 (CFG_BANK2_START & addressmask);
-#endif
-#if (CFG_BANK_ENABLE & 0x02)
-       result += (CFG_BANK1_END & addressmask) + addressinc -
-                 (CFG_BANK1_START & addressmask);
-#endif
-#if (CFG_BANK_ENABLE & 0x01)
-       result += (CFG_BANK0_END & addressmask) + addressinc -
-                 (CFG_BANK0_START & addressmask);
-#endif
+       for (i=0, cnt=(CFG_MAX_RAM_SIZE / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
+               addr = (volatile ulong *)base + cnt;
+               save[i++] = *addr;
+               *addr = ~cnt;
+       }
 
-       return result;
-}
+       addr = (volatile ulong *)base;
+       save[i] = *addr;
+       *addr = 0;
 
-long int initdram (int board_type)
-{
-       return dram_size ();
+       if (*addr != 0) {
+               *addr = save[i];
+               goto Done;
+       }
+
+       for (cnt = 1; cnt <= CFG_MAX_RAM_SIZE / sizeof(long); cnt <<= 1) {
+               addr = (volatile ulong *)base + cnt;
+               val = *addr;
+               *addr = save[--i];
+               if (val != ~cnt) {
+                       ulong new_bank0_end = cnt * sizeof(long) - 1;
+                       ulong mear1  = mpc824x_mpc107_getreg(MEAR1);
+                       ulong emear1 = mpc824x_mpc107_getreg(EMEAR1);
+                       mear1 =  (mear1  & 0xFFFFFF00) |
+                       ((new_bank0_end & MICR_ADDR_MASK) >> MICR_ADDR_SHIFT);
+                       emear1 = (emear1 & 0xFFFFFF00) |
+                       ((new_bank0_end & MICR_ADDR_MASK) >> MICR_EADDR_SHIFT);
+                       mpc824x_mpc107_setreg(MEAR1,  mear1);
+                       mpc824x_mpc107_setreg(EMEAR1, emear1);
+
+                       ret = cnt * sizeof(long);
+                       goto Done;
+               }
+       }
+
+       ret = CFG_MAX_RAM_SIZE;
+Done:
+       return ret;
 }
 
 /*
diff --git a/board/sandpoint/speed.c b/board/sandpoint/speed.c
deleted file mode 100644 (file)
index 3a8aa8f..0000000
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * (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
- */
-
-#include <ppcboot.h>
-#include <mpc824x.h>
-#include <asm/processor.h>
-#include "speed.h"
-
-/*use UART2 to measure bus speed*/
-#include "ns16550.h"
-
-
-/* Access functions for the Machine State Register */
-static __inline__ unsigned long get_msr(void)
-{
-    unsigned long msr;
-
-    __asm__ ("mfmsr %0" : "=r" (msr) :);
-    return msr;
-}
-
-static __inline__ void set_msr(unsigned long msr)
-{
-    __asm__ __volatile__("mtmsr %0" : : "r" (msr));
-}
-
-/* ------------------------------------------------------------------------- */
-
-ulong get_bus_freq (ulong ignore)
-{
-    return 66666666;
-}
-
-/* ------------------------------------------------------------------------- */
-
-/*
- * Measure CPU clock speed
- */
-
-/*
- * table to convert pllratio to actual processor clock scaling factor (*2)
- * if you are using a a different processor with your sandpoint,
- * have a look at pmc.c in the dink source for values, or
- * figure it out from the hardware book
- */
-
-#ifdef CONFIG_MPC824X
-const unsigned char pllratio_to_factor[32] = {
-    0, 0, 0, 2, 4, 4, 6, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-    0, 0, 0, 2, 0, 0, 0, 9, 6, 0, 8, 0, 0, 0, 7, 0
-};
-#else
-  #error Enter clock divider array here!
-#endif
-
-ulong get_gclk_freq (void)
-{
-   uint hid1;
-   hid1 = mfspr(HID1);
-   #ifdef CONFIG_MPC824X
-   hid1 = (hid1 >> (32-5)) & 0x1f; /* 5 bits for PLL ration on 824x */
-   #else
-   hid1 = (hid1 >> (32-4)) & 0xf; /* 4 bits on everythings else*/
-   #endif
-
-   return pllratio_to_factor[hid1] * get_bus_freq(0)/2;
-}
-
-/* ------------------------------------------------------------------------- */
-
index 067b74679996dde4c21023f66d57a74621c2de79..39bbf1a8292a65e497af6123cae323a330ad67e0 100644 (file)
@@ -74,7 +74,9 @@ static boot_os_Fcn do_bootm_linux;
 static boot_os_Fcn do_bootm_netbsd;
 #if (CONFIG_COMMANDS & CFG_CMD_ELF)
 static boot_os_Fcn do_bootm_vxworks;
+static boot_os_Fcn do_bootm_qnxelf;
 int do_bootvx( cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[] );
+int do_bootelf( cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[] );
 #endif /* CFG_CMD_ELF */
 
 image_header_t header;
@@ -238,6 +240,10 @@ int do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
            do_bootm_vxworks (cmdtp, bd, flag, argc, argv,
                              addr, len_ptr, verify);
            break;
+       case IH_OS_QNX:
+           do_bootm_qnxelf (cmdtp, bd, flag, argc, argv,
+                             addr, len_ptr, verify);
+           break;
 #endif /* CFG_CMD_ELF */
        }
 
@@ -707,6 +713,7 @@ print_type (image_header_t *hdr)
        case IH_OS_NETBSD:      os = "NetBSD";                  break;
        case IH_OS_LINUX:       os = "Linux";                   break;
        case IH_OS_VXWORKS:     os = "VxWorks";                 break;
+       case IH_OS_QNX:         os = "QNX";                     break;
        case IH_OS_PPCBOOT:     os = "PPCBoot";                 break;
        default:                os = "Unknown OS";              break;
        }
@@ -841,4 +848,18 @@ do_bootm_vxworks (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[],
        setenv("loadaddr", str);
        do_bootvx(cmdtp, bd, 0, 0, NULL);
 }
+
+static void
+do_bootm_qnxelf (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[],
+                 ulong addr, ulong *len_ptr, int verify)
+{
+       image_header_t *hdr = &header;
+       char *local_args[2];
+       char str[16];
+       
+       sprintf(str, "%x", hdr->ih_ep); /* write entry-point into string */
+       local_args[0] = argv[0];
+       local_args[1] = str;    /* and provide it via the arguments */
+       do_bootelf(cmdtp, bd, 0, 2, local_args);
+}
 #endif /* CFG_CMD_ELF */
index 267c6d82a2cb2370065e6d909a6b805c778e71a6..1235de940c80ff807252be2d8f3207afe8c144b3 100644 (file)
@@ -297,7 +297,8 @@ int do_scsiboot (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
                cnt /= info.blksz;
                cnt -= 1;
        } else {
-               cnt = info.size - 1;
+               printf("\n** Bad Magic Number **\n");
+               return 1;
        }
 
        if (scsi_read (dev, info.start+1, cnt,
index 9b840387ef8a2d00800ffe726282709cd96d09e1..fb0f7db820839c566e68b0210a22f061bc53d975 100644 (file)
@@ -152,7 +152,7 @@ int usb_stor_scan(int mode)
        for(i=0;i<USB_MAX_STOR_DEV;i++) {
                memset(&usb_dev_desc[i],0,sizeof(block_dev_desc_t));
                usb_dev_desc[i].target=0xff;
-               usb_dev_desc[i].if_type=IF_TYPE_SCSI;
+               usb_dev_desc[i].if_type=IF_TYPE_USB;
                usb_dev_desc[i].dev=i;
                usb_dev_desc[i].part_type=PART_TYPE_UNKNOWN;
                usb_dev_desc[i].block_read=usb_stor_read;
index 84464e3cc311823f62788f162070fcc6f406e13d..f08a084aca10cb72be831b0cf5f2c9decb9fcb3f 100644 (file)
@@ -26,7 +26,7 @@ include $(TOPDIR)/config.mk
 LIB    = lib$(CPU).a
 
 START  = start.S
-OBJS   = traps.o cpu.o cpu_init.o interrupts.o \
+OBJS   = traps.o cpu.o cpu_init.o interrupts.o speed.o \
           drivers/epic/epic1.o
 
 all:   .depend $(START) $(LIB)
index 28a678b9ceb0431943064cf13d9726576c7d4265..ccf5b34cd2f6f47d7c05e39dc2b3d5c84e2e4d83 100644 (file)
@@ -41,14 +41,18 @@ cpu_init_f (void)
     CONFIG_WRITE_HALFWORD(PCICR, 0x06); /* Bus Master, respond to PCI memory space acesses*/
 /*    CONFIG_WRITE_HALFWORD(PCISR, 0xffff); */ /*reset PCISR*/
 
-#if defined(CONFIG_MPC8245)
-    CONFIG_WRITE_BYTE(PCLSR, 0x8);     /* set cache line size */
-    /* clear then set then clear the memory DLL */
+    CONFIG_WRITE_BYTE(PCLSR, 0x8);     /* set PCI cache line size */
+
+    /*
+     * Note that although this bit is cleared after a hard reset, it
+     * must be explicitly set and then cleared by software during
+     * initialization in order to guarantee correct operation of the
+     * DLL and the SDRAM_CLK[0:3] signals (if they are used).
+     */
     CONFIG_READ_BYTE (AMBOR, val);
     CONFIG_WRITE_BYTE(AMBOR, val & 0xDF);
     CONFIG_WRITE_BYTE(AMBOR, val | 0x20);
     CONFIG_WRITE_BYTE(AMBOR, val & 0xDF);
-#endif
 
     CONFIG_READ_WORD(PICR1, val);
 #if defined(CONFIG_MPC8240)
diff --git a/cpu/mpc824x/speed.c b/cpu/mpc824x/speed.c
new file mode 100644 (file)
index 0000000..df2b08f
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * (C) Copyright 2001
+ * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
+ *
+ * (C) Copyright 2002
+ * Gregory E. Allen, gallen@arlut.utexas.edu
+ * Applied Research Laboratories, The University of Texas at Austin
+ *
+ * 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 <ppcboot.h>
+#include <mpc824x.h>
+#include <asm/processor.h>
+
+/* ------------------------------------------------------------------------- */
+/* NOTE: This describes the proper use of this file. */
+/* CONFIG_SYS_CLK_FREQ should be defined as the input frequency on PCI_SYNC_IN */
+/* CONFIG_PLL_PCI_TO_MEM_MULTIPLIER is only required on MPC8240 boards */
+/*   it should be defined as the PCI to Memory Multiplier as documented */
+/*   in the MPC8240 Hardware Specs */
+/* Other mpc824x boards don't need CONFIG_PLL_PCI_TO_MEM_MULTIPLIER because */
+/*   they can determine it from the PCR */
+
+/* If the PCR is an undocumented feature on the mpc8240 then we can do away */
+/*   with CONFIG_PLL_PCI_TO_MEM_MULTIPLIER altogether */
+
+/* ------------------------------------------------------------------------- */
+
+/* This gives the PCI to Memory multiplier times 10 */
+/* The index is the value of PLL_CFG[0:4] */
+/* This is documented in the MPC8240/5 Hardware Specs */
+
+short pll_pci_to_mem_multiplier[] = {
+#if defined(CONFIG_MPC8240)
+       30, 30, 10, 10, 20, 10, 00, 10,
+       10, 00, 20, 00, 20, 00, 20, 00,
+       30, 00, 15, 00, 20, 00, 20, 00,
+       25, 00, 10, 00, 15, 15, 00, 00
+#elif defined(CONFIG_MPC8245)
+       30, 30, 10, 10, 20, 10, 10, 10,
+       10, 20, 20, 15, 20, 15, 20, 00,
+       30, 00, 15, 00, 20, 25, 20, 40,
+       25, 20, 10, 20, 15, 15, 15, 00
+#else
+#error Specific type of MPC824x must be defined (i.e. CONFIG_MPC8240)
+#endif
+};
+
+#define CU824_PLL_STATE_REG  0xFE80002F
+#define PCR                             0x800000E2
+
+/* ------------------------------------------------------------------------- */
+
+/* compute the memory bus clock frequency */
+ulong get_bus_freq(ulong ignore)
+{
+       unsigned char pll_cfg;
+#if defined(CONFIG_MPC8240) && !defined(CONFIG_CU824)
+       return (CONFIG_SYS_CLK_FREQ) * (CONFIG_PLL_PCI_TO_MEM_MULTIPLIER);
+#elif defined(CONFIG_CU824)
+       pll_cfg = *(volatile unsigned char *) (CU824_PLL_STATE_REG);
+       pll_cfg &= 0x1f;
+#else
+       CONFIG_READ_BYTE(PCR, pll_cfg);
+       pll_cfg = (pll_cfg >> 3) & 0x1f;
+#endif
+       return ((CONFIG_SYS_CLK_FREQ) * pll_pci_to_mem_multiplier[pll_cfg] + 5) / 10;
+}
+
+
+/* ------------------------------------------------------------------------- */
+
+/* This gives the Memory to CPU Core multiplier times 10 */
+/* The index is the value of PLLRATIO in HID1 */
+/* This is documented in the MPC8240 Hardware Specs */
+/* This is not documented for MPC8245 ? FIXME */
+short pllratio_to_factor[] = {
+    00, 00, 00, 10, 20, 20, 25, 45,
+    00, 00, 00, 00, 00, 00, 00, 00,
+    00, 00, 00, 10, 00, 00, 00, 45,
+    30, 00, 40, 00, 00, 00, 35, 00,
+};
+
+/* compute the memory bus clock frequency */
+ulong get_gclk_freq(void)
+{
+       uint hid1 = mfspr(HID1);
+       hid1 = (hid1 >> (32-5)) & 0x1f;
+       return (pllratio_to_factor[hid1] * get_bus_freq(0) + 5) / 10;
+}
index 59ca1f4043337dc1a3dddb8ba8a377ca425d452b..3e6e05f7cff5da51bf98374295fbef053e0d7992 100644 (file)
@@ -178,6 +178,10 @@ static void print_part_header (const char *type, block_dev_desc_t * dev_desc)
                                        break;
                case IF_TYPE_ATAPI:     puts ("ATAPI");
                                        break;
+               case IF_TYPE_USB:       puts ("USB");
+                                       break;
+               case IF_TYPE_DOC:       puts ("DOC");
+                                       break;
                default:                puts ("UNKNOWN");
                                        break;
        }
index ff62614ddcddf6d625ea11d559f6bc3d5cd6f757..20218e96fb8dab2238c3ff751d615bc5f461035e 100644 (file)
@@ -175,11 +175,18 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
                        info->size  = le32_to_int (pt->size4);
                        switch(dev_desc->if_type) {
                                case IF_TYPE_IDE:
+                               case IF_TYPE_ATAPI:
                                        sprintf (info->name, "hd%c%d\n", 'a' + dev_desc->dev, part_num);
                                        break;
                                case IF_TYPE_SCSI:
                                        sprintf (info->name, "sd%c%d\n", 'a' + dev_desc->dev, part_num);
                                        break;
+                               case IF_TYPE_USB:
+                                       sprintf (info->name, "usbd%c%d\n", 'a' + dev_desc->dev, part_num);
+                                       break;
+                               case IF_TYPE_DOC:
+                                       sprintf (info->name, "docd%c%d\n", 'a' + dev_desc->dev, part_num);
+                                       break;
                                default:
                                        sprintf (info->name, "xx%c%d\n", 'a' + dev_desc->dev, part_num);
                                        break;
index f1917d7920d814c1e2e7135a052202b683389a59..20b830d57dd2f3ef773116899abe3394ac62d2fe 100644 (file)
@@ -39,7 +39,7 @@
        "usb  tree  - show USB device tree\n"                           \
        "usb  info [dev] - show available USB devices\n"                                \
        "usb  scan  - (re-)scan USB bus for storage devices\n"                                  \
-       "usb  device [dev] - show or set current USB staorage device\n"                 \
+       "usb  device [dev] - show or set current USB storage device\n"                  \
        "usb  part [dev] - print partition table of one or all USB storage devices\n"   \
        "usb  read addr blk# cnt - read `cnt' blocks starting at block `blk#'\n"\
        "     to memory address `addr'\n"                                       \
@@ -73,5 +73,5 @@ int do_usbboot (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[]);
 #define CMD_TBL_USBBOOT
 #endif
 
-#endif /* _CMD_SCSI_H */
+#endif /* _CMD_USB_H */
 
index 3e155ded86f4e267fdf00f15aef975da5787c824..771893f5fd72241eeddd3a9ae2d6dcfdc859e158 100644 (file)
@@ -92,7 +92,8 @@
  * Environment definitions
  **************************************************************/
 #define CONFIG_BAUDRATE                9600    /* STD Baudrate */
-#define CONFIG_BOOTDELAY       -1                      /* no autoboot */
+#define CONFIG_BOOTDELAY       5       
+/* autoboot (do NOT change this set environment variable "bootdelay" to -1 instead) */
 
 #define CONFIG_BOOTCOMMAND     "diskboot 200000 0:1; bootm" /* autoboot command                */
 #define CONFIG_BOOTARGS                "console=ttyS0,9600 root=/dev/hda5" /* boot arguments */
 #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_MEMTEST_START      0x0100000       /* memtest works on     */
+#define CFG_MEMTEST_END                0x0C00000       /* 1 ... 12 MB in DRAM  */
 
 #undef  CFG_EXT_SERIAL_CLOCK           /* no external serial clock used */
+#define CFG_IGNORE_405_UART_ERRATA_59
 
 /* The following table includes the supported baudrates */
 #define CFG_BAUDRATE_TABLE      \
 /************************************************************
  * Ident
  ************************************************************/
-#define VERSION_TAG "REL_1_1_1"
+#define VERSION_TAG "REL_1_1_3"
 #define CONFIG_IDENT_STRING "\n(c) 2001 by MPL AG Switzerland, MEV-10072-001 " VERSION_TAG
 
 
index 8ffccd89917f05ee50b7f747cbc56702de4e89da..400e7b4556bd21237ca84e5a1b551203be464686 100644 (file)
  * For the detail description refer to the MPC8240 user's manual.
  */
 
-#define CONFIG_SYS_CLK_FREQ  200000000
+#define CONFIG_SYS_CLK_FREQ  33000000  /* external frequency to pll */
+#define CONFIG_PLL_PCI_TO_MEM_MULTIPLIER  2
 #define CFG_HZ               1000
 
 #define CFG_ETH_DEV_FN       0x00
index 981be3c72476738ba9cefcbf8fac07734423a6e4..e52dba61f72b8ad8bbff92c72af7df5aeee6ab0c 100644 (file)
  * For the detail description refer to the MPC8240 user's manual.
  */
 
-#define CONFIG_SYS_CLK_FREQ  100000000
-#define CFG_SERIAL_CLOCK     CONFIG_SYS_CLK_FREQ
+#define CONFIG_SYS_CLK_FREQ  33000000  /* external frequency to pll */
 #define CFG_HZ              1000
 
 #define CFG_ETH_DEV_FN      0x7800
index e6a1a9b6a95e28161117f45825f8d39c5becfb29..270b1838af8358e7de983a3553b5603a32e5224b 100644 (file)
  * Environment definitions
  **************************************************************/
 #define CONFIG_BAUDRATE                9600    /* STD Baudrate */
-#define CONFIG_BOOTDELAY       -1                      /* no autoboot */
+
+
+#define CONFIG_BOOTDELAY       5       
+/* autoboot (do NOT change this set environment variable "bootdelay" to -1 instead) */
 
 #define CONFIG_BOOTCOMMAND     "diskboot 200000 0:1; bootm" /* autoboot command                */
 #define CONFIG_BOOTARGS                "console=ttyS0,9600 root=/dev/hda5" /* boot arguments */
 #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_MEMTEST_START      0x0100000       /* memtest works on     */
+#define CFG_MEMTEST_END                0x0C00000       /* 1 ... 12 MB in DRAM  */
 
 #undef  CFG_EXT_SERIAL_CLOCK           /* no external serial clock used */
+#define CFG_IGNORE_405_UART_ERRATA_59
 
 /* The following table includes the supported baudrates */
 #define CFG_BAUDRATE_TABLE      \
 /************************************************************
  * Ident
  ************************************************************/
-#define VERSION_TAG "REL_1_1_1"
+#define VERSION_TAG "REL_1_1_3"
 #define CONFIG_IDENT_STRING "\n(c) 2001 by MPL AG Switzerland, MEV-10066-001 " VERSION_TAG
 
 
index 45d6dda5ada73a599f4385b88fe1d4a0e06b1a08..9a6fdadd0814b2ee99d8aec46ff91b0ccbca91c2 100644 (file)
@@ -82,6 +82,7 @@
  * Please note that CFG_SDRAM_BASE _must_ start at 0
  */
 #define CFG_SDRAM_BASE         0x00000000
+#define CFG_MAX_RAM_SIZE       0x10000000
 
 #if defined (USE_DINK32)
 #define CFG_MONITOR_LEN                0x00030000
  * You should know what you are doing if you make changes here.
  */
 
+#define CONFIG_SYS_CLK_FREQ  33000000  /* external frequency to pll */
+#define CONFIG_PLL_PCI_TO_MEM_MULTIPLIER  2
 
 #define CFG_ROMNAL             7       /*rom/flash next access time            */
 #define CFG_ROMFAL             11      /*rom/flash access time                 */
 #define CFG_REGISTERD_TYPE_BUFFER   1
 
 /* memory bank settings*/
-/* only bits 20-29 are actually used from these vales to set the start/end address
-   the upper two bits will be 0, and the lower 20 bits will be set to
-   0x00000 for a start address, or 0xfffff for an end address*/
-
+/*
+ * only bits 20-29 are actually used from these vales to set the
+ * start/end address the upper two bits will be 0, and the lower 20
+ * bits will be set to 0x00000 for a start address, or 0xfffff for an
+ * end address
+ */
 #define CFG_BANK0_START                0x00000000
-#define CFG_BANK0_END          0x01ffffff
+#define CFG_BANK0_END          (CFG_MAX_RAM_SIZE - 1)
 #define CFG_BANK0_ENABLE       1
-#define CFG_BANK1_START                0x04000000
-#define CFG_BANK1_END          0x07ffffff
+#define CFG_BANK1_START                0x3ff00000
+#define CFG_BANK1_END          0x3fffffff
 #define CFG_BANK1_ENABLE       0
-#define CFG_BANK2_START                0x08000000
-#define CFG_BANK2_END          0x0bffffff
+#define CFG_BANK2_START                0x3ff00000
+#define CFG_BANK2_END          0x3fffffff
 #define CFG_BANK2_ENABLE       0
-#define CFG_BANK3_START                0x0c000000
-#define CFG_BANK3_END          0x0fffffff
+#define CFG_BANK3_START                0x3ff00000
+#define CFG_BANK3_END          0x3fffffff
 #define CFG_BANK3_ENABLE       0
 #define CFG_BANK4_START                0x00000000
 #define CFG_BANK4_END          0x00000000
index 02fefff55fbb02af1dd3edaf759b295fa1024f83..10324fe398c0a507716e3c2fc089cf0927d8f2e5 100644 (file)
@@ -44,6 +44,8 @@ typedef struct block_dev_desc {
 #define IF_TYPE_IDE                    1
 #define IF_TYPE_SCSI           2
 #define IF_TYPE_ATAPI          3
+#define IF_TYPE_USB                    4
+#define IF_TYPE_DOC                    5
 /* Part types */
 #define        PART_TYPE_UNKNOWN       0x00
 #define PART_TYPE_MAC          0x01