]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Add support for XIP images
authorwdenk <wdenk>
Fri, 26 Apr 2002 20:03:31 +0000 (20:03 +0000)
committerwdenk <wdenk>
Fri, 26 Apr 2002 20:03:31 +0000 (20:03 +0000)
Patch by Denis Peter, 25 Apr 2002:
- fix wrong initialization (ptmms) in 405gp_pci.c
- cleanup MPL boards (PIP405/MIP405) for the PID#73 patch
- added "non emulation" boot support for ISO fs

16 files changed:
CHANGELOG
MAINTAINERS
board/mpl/common/common_util.c
board/mpl/common/common_util.h
board/mpl/common/flash.c
board/mpl/common/pci.c
board/mpl/common/pci_parts.h
board/mpl/common/piix4_pci.h
board/mpl/mip405/mip405.c
board/mpl/pip405/pip405.c
common/cmd_bootm.c
cpu/ppc4xx/405gp_pci.c
disk/part_iso.c
include/config_MIP405.h
include/config_PIP405.h
tools/mkimage.c

index 9ee39b994a603f5b2a0b4680483e64b656ac7b6f..4e934912f2ed266a5b2e673307ae75aaa62cd402 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
 Modifications for 1.1.6:
 ======================================================================
 
+* Add support for XIP images
+
+* Patch by Denis Peter, 25 Apr 2002:
+  - fix wrong initialization (ptmms) in 405gp_pci.c
+  - cleanup MPL boards (PIP405/MIP405) for the PID#73 patch
+  - added "non emulation" boot support for ISO fs
+
 * Add support for "wd" command on PCIPPC2/6
   (Guillaume Alexandre, 19 Apr 2002)
 
index 633e304656098677528f5f0091e155d96be1b4a6..17a5de54514b76c85f524edea2c1f32f19bd96d6 100644 (file)
@@ -122,6 +122,11 @@ Dave Ellis <DGE@sixnetio.com>
 
        SXNI855T                MPC8xx
 
+Denis Peter <d.peter@mpl.ch>
+
+       MIP405                  PPC4xx
+       PIP405                  PPC4xx
+
 -------------------------------------------------------------------------
 
 Unknown / orphaned boards:
@@ -140,8 +145,6 @@ Unknown / orphaned boards:
 
        CRAYL1                  PPC4xx
        ERIC                    PPC4xx
-       MIP405                  PPC4xx
-       PIP405                  PPC4xx
        WALNUT405               PPC4xx
 
        MOUSSE                  MPC824x
index 32731787ef7f06572444dfcec117c7db75b4d54c..6ab0819b3f5863d6c62d676d830e4d1a4e73f2c7 100644 (file)
@@ -26,6 +26,8 @@
 #include <command.h>
 #include "common_util.h"
 #include <asm/processor.h>
+#include <i2c.h>
+#include <devices.h>
 
 extern int  gunzip (void *, int, unsigned char *, int *);
 extern int mem_test(unsigned long start, unsigned long ramsize, int quiet);
@@ -77,12 +79,12 @@ int mpl_prg(unsigned long src,unsigned long size)
 }
 
 
-int mpl_prg_image(unsigned long load_addr)
+int mpl_prg_image(unsigned long ld_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));
+       memcpy (&header, (char *)ld_addr, sizeof(image_header_t));
        if (hdr->ih_magic  != IH_MAGIC) {
                printf ("Bad Magic Number\n");
                return 1;
@@ -104,7 +106,7 @@ int mpl_prg_image(unsigned long load_addr)
                printf ("Bad Header Checksum\n");
                return 1;
        }
-       data = load_addr + sizeof(image_header_t);
+       data = ld_addr + sizeof(image_header_t);
        len  = hdr->ih_size;
        printf ("Verifying Checksum ... ");
        if (crc32 (0, (char *)data, len) != hdr->ih_dcrc) {
@@ -135,7 +137,7 @@ int mpl_prg_image(unsigned long load_addr)
 
 void get_backup_values(backup_t *buf)
 {
-       eeprom_read(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,(void *)buf,sizeof(backup_t));
+       i2c_read(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)buf,sizeof(backup_t));
 }
 
 void set_backup_values(int overwrite)
@@ -163,7 +165,7 @@ void set_backup_values(int overwrite)
                return;
        }
        back.eth_addr[20]=0;
-       eeprom_write(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,(void *)&back,sizeof(backup_t));
+       i2c_write(CFG_DEF_EEPROM_ADDR, I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t));
 }
 
 void clear_env_values(void)
@@ -173,8 +175,154 @@ void clear_env_values(void)
 
        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);
+       i2c_write(CFG_DEF_EEPROM_ADDR,I2C_BACKUP_ADDR,2,(void *)&back,sizeof(backup_t));
+       i2c_write(CFG_DEF_EEPROM_ADDR,CFG_ENV_OFFSET,2,(void *)env_crc,4);
+}
+
+/*
+ * check crc of "older" environment
+ */
+int check_env_old_size(ulong oldsize)
+{
+       ulong crc, len, new;
+       unsigned off;
+       uchar buf[64];
+
+       /* read old CRC */
+       eeprom_read (CFG_DEF_EEPROM_ADDR,
+                    CFG_ENV_OFFSET,
+                    (uchar *)&crc, sizeof(ulong));
+
+       new = 0;
+       len = oldsize;
+       off = sizeof(long);
+       len = oldsize-off;
+       while (len > 0) {
+               int n = (len > sizeof(buf)) ? sizeof(buf) : len;
+
+               eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, buf, n);
+               new = crc32 (new, buf, n);
+               len -= n;
+               off += n;
+       }
+
+       return (crc == new);
+}
+
+static ulong oldsizes[] = {
+       0x200,
+       0x800,
+       0
+};
+
+void copy_old_env(ulong size)
+{
+       uchar name_buf[64];
+       uchar value_buf[0x800];
+       uchar c;
+       ulong len;
+       unsigned off;
+       uchar *name, *value;
+       
+       name=&name_buf[0];
+       value=&value_buf[0];
+       len=size;
+       off = sizeof(long);
+       while (len > off) {
+               eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1);
+               if(c != '=') {
+                       *name++=c;
+                       off++;
+               }
+               else {
+                       *name++='\0';
+                       off++;
+                       do {
+                               eeprom_read (CFG_DEF_EEPROM_ADDR, CFG_ENV_OFFSET+off, &c, 1);
+                               *value++=c;
+                               off++;
+                               if(c == '\0')
+                                       break;
+                       } while(len > off);
+                       name=&name_buf[0];
+                       value=&value_buf[0];
+                       if(strncmp(name,"baudrate",8)!=0) {
+                               setenv(name,value);
+                       }
+                       
+               }
+       }
+}
+
+
+void check_env(void)
+{
+       unsigned char *s;
+       int i=0;
+       char buf[32];
+       backup_t back;
+
+       s=getenv("serial#");
+       if(!s) {
+               while(oldsizes[i]) {
+                       if(check_env_old_size(oldsizes[i])) 
+                               break;
+                       i++;
+               }
+               if(!oldsizes[i]) {
+                       /* no old environment has been found */
+                       get_backup_values (&back);
+                       if (strncmp (back.signature, "MPL\0", 4) == 0) {
+                               sprintf (buf, "%s", back.serial_name);
+                               setenv ("serial#", buf);
+                               sprintf (buf, "%s", back.eth_addr);
+                               setenv ("ethaddr", buf);
+                               printf ("INFO:  serial# and ethaddr recovered, use saveenv\n");
+                               return;
+                       }
+               }
+               else {
+                       copy_old_env(oldsizes[i]);
+                       printf ("INFO:  old environment ajusted, use saveenv\n");
+               }
+       }
+       else {
+               /* check if back up is set */
+               get_backup_values(&back);
+               if(strncmp(back.signature,"MPL\0",4)!=0) {
+                       set_backup_values(0);
+               }
+       }
+}
+
+
+
+extern device_t *stdio_devices[];
+extern char *stdio_names[];
+
+void show_stdio_dev(void)
+{
+       /* Print informations */
+       printf ("In:    ");
+       if (stdio_devices[stdin] == NULL) {
+               printf ("No input devices available!\n");
+       } else {
+               printf ("%s\n", stdio_devices[stdin]->name);
+       }
+
+       printf ("Out:   ");
+       if (stdio_devices[stdout] == NULL) {
+               printf ("No output devices available!\n");
+       } else {
+               printf ("%s\n", stdio_devices[stdout]->name);
+       }
+
+       printf ("Err:   ");
+       if (stdio_devices[stderr] == NULL) {
+               printf ("No error devices available!\n");
+       } else {
+               printf ("%s\n", stdio_devices[stderr]->name);
+       }
 }
 
 /* ------------------------------------------------------------------------- */
@@ -248,14 +396,16 @@ int switch_cs(unsigned char boot)
 
 int do_mplcommon(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 {
-       ulong size,src,load_addr;
+       ulong size,src,ld_addr;
        int result;
        backup_t back;
+       char sw;
        src = MULTI_PURPOSE_SOCKET_ADDR;
        size = IMAGE_SIZE;
 
        if (strcmp(argv[1], "flash") == 0)
        {
+               sw = switch_cs(0); /* Switch flash to normal location */
 #if (CONFIG_COMMANDS & CFG_CMD_FDC)
                if (strcmp(argv[2], "floppy") == 0) {
                        char *local_args[3];
@@ -265,34 +415,38 @@ int do_mplcommon(cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
                        if(argc==4) {
                                local_args[1] = argv[3];
                                local_args[2] = NULL;
-                               load_addr=simple_strtoul(argv[3], NULL, 16);
+                               ld_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;
+                               ld_addr=CFG_LOAD_ADDR;
                                result=do_fdcboot(cmdtp, bd, 0, 1, local_args);
                        }
-                       result=mpl_prg_image(load_addr);
+                       result=mpl_prg_image(ld_addr);
+                       switch_cs(sw); /* Switch flash back */
                        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);
+                               ld_addr=simple_strtoul(argv[3], NULL, 16);
                        }
                        else {
-                               load_addr=CFG_LOAD_ADDR;
+                               ld_addr=load_addr;
                        }
-                       printf ("\nupdating bootloader image from memory at %lX\n",load_addr);
-                       result=mpl_prg_image(load_addr);
+                       printf ("\nupdating bootloader image from memory at %lX\n",ld_addr);
+                       result=mpl_prg_image(ld_addr);
+                       switch_cs(sw); /* Switch flash back */
                        return result;
                }
                if (strcmp(argv[2], "mps") == 0) {
                        printf ("\nupdating bootloader image from MSP\n");
                        result=mpl_prg(src,size);
+                       switch_cs(sw); /* Switch flash back */
                        return result;
                }
+               switch_cs(sw); /* Switch flash back */
 
        }
        if (strcmp(argv[1], "mem") == 0)
index 154ecd52928857f94502c7c8d70d415f07525ef3..70cd46928adaf0289772f5f6b4537ac0467e2c03 100644 (file)
@@ -30,12 +30,10 @@ typedef struct {
        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);
+void show_stdio_dev(void);
+void check_env(void);
 #if (CONFIG_COMMANDS & CFG_CMD_DOC)
 void doc_init (void);
 #endif
index c174911ecc745cc815cf312a33ea5475311e5a1a..184d73796f936df2ca5385c06b2eda10cdf08b7b 100644 (file)
@@ -194,7 +194,7 @@ unsigned long flash_init (void)
            flash_info[0].size = size_b0;
            flash_info[1].size = size_b1;
          }/* else 2 banks */
-       /*      switch_cs(rc); */ /* switch mode back */
+       switch_cs(rc); /* switch mode back */
        return (size_b0 + size_b1);
 }
 
@@ -721,35 +721,12 @@ void unlock_intel_sectors(flash_info_t *info,ulong addr,ulong cnt)
 
 int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
 {
-       ulong wp, data;
-       int rc;
-       /*      int i, l, rc;  */
-       /* unsigned char sw; */
-       ulong *srcp;
-
-
+       ulong cp, wp, data;
+       int i, l, rc;
 
        if((info->flash_id & FLASH_VENDMASK) == FLASH_MAN_INTEL){
                unlock_intel_sectors(info,addr,cnt);
        }
-       wp=addr;
-       srcp=(ulong *)src;
-       while (cnt >= 4) {
-               data=*srcp++;
-               if ((rc = write_word(info, wp, data)) != 0) {
-                       return (rc);
-               }
-               wp  += 4;
-               if((wp % 0x10000)==0)
-                       printf("."); /* show Progress */
-               cnt -= 4;
-       }
-
-       if (cnt == 0) {
-               return (0);
-       }
-       return -1;
-#if 0
        wp = (addr & ~3);       /* get lower word aligned address */
        /*
         * handle unaligned start bytes
@@ -808,8 +785,6 @@ int write_buff (flash_info_t *info, uchar *src, ulong addr, ulong cnt)
        }
        rc=write_word(info, wp, data);
        return rc;
-
-#endif
 }
 
 /*-----------------------------------------------------------------------
@@ -831,7 +806,7 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
 
        /* Check if Flash is (sufficiently) erased */
        if ((*((volatile FLASH_WORD_SIZE *)dest) &
-               (FLASH_WORD_SIZE)data) != (FLASH_WORD_SIZE)data) {
+               (FLASH_WORD_SIZE)data) != (FLASH_WORD_SIZE)data) {
                return (2);
        }
        /* Disable interrupts which might cause a timeout here */
@@ -842,42 +817,40 @@ static int write_word (flash_info_t *info, ulong dest, ulong data)
                        /* intel style writting */
                        dest2[i] = (FLASH_WORD_SIZE)0x00500050;
                        dest2[i] = (FLASH_WORD_SIZE)0x00400040;
-               *read_val++ = data2[i];
+                       *read_val++ = data2[i];
                        dest2[i] = data2[i];
-               if (flag)
-                       enable_interrupts();
-               /* data polling for D7 */
-               start = get_timer (0);
+                       if (flag)
+                               enable_interrupts();
+                       /* data polling for D7 */
+                       start = get_timer (0);
                        udelay(10);
-               while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080)
-               {
-                       if (get_timer(start) > CFG_FLASH_WRITE_TOUT)
-                               return (1);
+                       while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) != (FLASH_WORD_SIZE)0x00800080)
+                       {
+                               if (get_timer(start) > CFG_FLASH_WRITE_TOUT)
+                                       return (1);
                        }
                        dest2[i] = (FLASH_WORD_SIZE)0x00FF00FF; /* return to read mode */
                        udelay(10);
                        dest2[i] = (FLASH_WORD_SIZE)0x00FF00FF; /* return to read mode */
                        if(dest2[i]!=data2[i])
                                printf("Error at %p 0x%04X != 0x%04X\n",&dest2[i],dest2[i],data2[i]);
-
                }
                else {
-                       addr2[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
-               addr2[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
-               addr2[ADDR0] = (FLASH_WORD_SIZE)0x00A000A0;
+                       addr2[ADDR0] = (FLASH_WORD_SIZE)0x00AA00AA;
+                       addr2[ADDR1] = (FLASH_WORD_SIZE)0x00550055;
+                       addr2[ADDR0] = (FLASH_WORD_SIZE)0x00A000A0;
                        dest2[i] = data2[i];
-            /* re-enable interrupts if necessary */
-               if (flag)
-                       enable_interrupts();
-
-                   /* data polling for D7 */
-               start = get_timer (0);
-               while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) !=
-                               (data2[i] & (FLASH_WORD_SIZE)0x00800080)) {
-                       if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
-                               return (1);
-                               }
-               }
+                       /* re-enable interrupts if necessary */
+                       if (flag)
+                               enable_interrupts();
+                       /* data polling for D7 */
+                       start = get_timer (0);
+                       while ((dest2[i] & (FLASH_WORD_SIZE)0x00800080) !=
+                               (data2[i] & (FLASH_WORD_SIZE)0x00800080)) {
+                               if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+                                       return (1);
+                               }
+                       }
                }
        }
        return (0);
index 4dd3d968f107cc5be544ab54cd19490892446556..ec96c3b97d23e52081f5377eacfd83606d8c7472 100644 (file)
@@ -37,7 +37,7 @@
 #include "piix4_pci.h"
 #include "pci_parts.h"
 
-void pci_pip405_write_regs(struct pci_controller *hose, pci_dev_t dev, 
+void pci_pip405_write_regs(struct pci_controller *hose, pci_dev_t dev,
                           struct pci_config_table *entry)
 {
        struct pci_pip405_config_entry *table;
@@ -54,24 +54,37 @@ void pci_pip405_write_regs(struct pci_controller *hose, pci_dev_t dev,
 
                switch(table[i].width)
                {
-               case 1: pci_write_config_byte(dev, table[i].index, table[i].val); break;
-               case 2: pci_write_config_word(dev, table[i].index, table[i].val); break;
-               case 4: pci_write_config_dword(dev, table[i].index, table[i].val); break;
+               case 1: pci_hose_write_config_byte(hose, dev, table[i].index, table[i].val); break;
+               case 2: pci_hose_write_config_word(hose, dev, table[i].index, table[i].val); break;
+               case 4: pci_hose_write_config_dword(hose, dev, table[i].index, table[i].val); break;
                }
        }
 }
 
-extern void pci_405gp_fixup_irq(struct pci_controller *hose, pci_dev_t dev);
+static void pci_pip405_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
+{
+       unsigned char int_line = 0xff;
+       /*
+        * Write pci interrupt line register
+        */
+       if(PCI_DEV_NUMBER(dev)>PCI_HIGHEST_ON_BOARD_ID) {
+               /* only external (PC104+) residing devices will be written */
+               int_line=PCI_IRQ_VECTOR(dev);
+               pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, int_line);
+       }
+}
+
 extern void pci_405gp_init(bd_t* bd, struct pci_controller *hose);
 
+
 static struct pci_controller hose = {
   config_table: pci_pip405_config_table,
-  fixup_irq: pci_405gp_fixup_irq,
+  fixup_irq: pci_pip405_fixup_irq,
 };
 
 void pci_init(bd_t *bd)
 {
-  pci_405gp_init(bd, &hose);
+       pci_405gp_init(bd, &hose);
 }
 
 #endif /* CONFIG_PCI */
index 6eb79b2269bb3eb796cb5acbcd6ac4b33996d385..0cea5281cae61d0ec4f6335aeca5d373ea3b9a50 100644 (file)
@@ -54,6 +54,7 @@
  * Vector = devicenumber % 4 + 28
  *
  */
+#define PCI_HIGHEST_ON_BOARD_ID        19
 #define PCI_DEV_NUMBER(x)      (((x>>11) & 0x1f) + 10)
 #define PCI_IRQ_VECTOR(x)      (PCI_DEV_NUMBER(x) % 4) + 28
 
@@ -86,14 +87,20 @@ struct pci_pip405_config_entry {
 
 extern void pci_pip405_write_regs(struct pci_controller *, 
                                  pci_dev_t, 
-                                 struct pci_config_table *);
+                                 struct pci_config_table *);       
 
 /* PIIX4 ISA Bridge Function 0 */
 static struct pci_pip405_config_entry piix4_isa_bridge_f0[] = {
        {PCI_CFG_PIIX4_SERIRQ,  0xD0,           1}, /* enable Continous SERIRQ Pin */
-       {PCI_CFG_PIIX4_GENCFG,  0x00010000,     4}, /* enable SERIRQs           */
+       {PCI_CFG_PIIX4_GENCFG,  0x00010041,     4}, /* enable SERIRQs, ISA, PNP */
+       {PCI_CFG_PIIX4_TOM,     0xFE,           1}, /* Top of Memory            */
        {PCI_CFG_PIIX4_XBCS,    0x02C4,         2}, /* disable all peri CS      */
        {PCI_CFG_PIIX4_RTCCFG,  0x21,           1}, /* enable RTC               */
+#if defined(CONFIG_PIP405)
+       {PCI_CFG_PIIX4_MBDMA,   0x82,           1}, /* set MBDMA0 to DMA 2      */
+       {PCI_CFG_PIIX4_MBDMA+1, 0x83,           1}, /* set MBDMA1 to DMA 3      */
+#endif
+       {PCI_CFG_PIIX4_DLC,     0x0,            1}, /* disable passive release feature */
        { }                                         /* end of device table      */
 };
 
@@ -114,6 +121,15 @@ static struct pci_pip405_config_entry piix4_usb_cntrl_f2[] = {
        { }                                         /* end of device table      */
 };
 
+/* PIIX4 Power Management Function 3 */
+static struct pci_pip405_config_entry piix4_pmm_cntrl_f3[] = {
+       {PCI_COMMAND,           0x0001,         2}, /* enable IO access         */
+       {PCI_CFG_PIIX4_PMAB,    0x00004000,     4}, /* set PMBA to "valid" value */
+       {PCI_CFG_PIIX4_PMMISC,  0x01,           1}, /* enable PMBA IO access    */
+       {PCI_CFG_PIIX4_SMBBA,   0x00005000,     4}, /* set SMBBA to "valid" value */
+       { }                                         /* end of device table      */
+};
+
 /* VGA Controller  ct69000 (logical device 0) */
 static struct pci_pip405_config_entry vga_ct69000[] = {
        {PCI_BASE_ADDRESS_0,    0x80000000,     4}, /* Frame buffer access      */
@@ -132,10 +148,21 @@ static struct pci_pip405_config_entry symbois_810_f0[] = {
        {0xFFFF, 0,0}                               /* end of device table      */
 };
 
+/* PPC405 Dummy only used to prevent autosetup on this host bridge */
+static struct pci_pip405_config_entry ibm405_dummy[] = {
+       { }                                         /* end of device table      */
+};
+
 void pci_405gp_setup_vga(struct pci_controller *hose, pci_dev_t dev, 
                         struct pci_config_table *entry);
 
 static struct pci_config_table pci_pip405_config_table[]={
+       {PCI_VENDOR_ID_IBM,                     /* 405 dummy */
+        PCI_DEVICE_ID_IBM_405GP,
+        PCI_ANY_ID,
+        PCI_ANY_ID, PCI_ANY_ID, 0,
+        pci_pip405_write_regs, {(unsigned long) ibm405_dummy}},
+
        {PCI_VENDOR_ID_INTEL,                   /* PIIX4 ISA Bridge Function 0 */
         PCI_DEVICE_ID_INTEL_82371AB_0, 
         PCI_ANY_ID, 
@@ -154,6 +181,12 @@ static struct pci_config_table pci_pip405_config_table[]={
         PCI_ANY_ID, PCI_ANY_ID, 2,
         pci_pip405_write_regs, {(unsigned long) piix4_usb_cntrl_f2}},
 
+       {PCI_VENDOR_ID_INTEL,                   /* PIIX4 USB Controller Function 3 */
+        PCI_DEVICE_ID_INTEL_82371AB_3,
+        PCI_ANY_ID,
+        PCI_ANY_ID, PCI_ANY_ID, 3,
+        pci_pip405_write_regs, {(unsigned long) piix4_pmm_cntrl_f3}},
+
        {PCI_VENDOR_ID_CT,                      /* VGA Controller  ct69000 (logical device 0) */
         PCI_DEVICE_ID_CT_69000,
         PCI_ANY_ID, 
index ce9f835ab7db36f7bad282ecfc0647e4430bc80a..5a0fd5ea2214ea365105cbb7e39b25220fb60082 100644 (file)
 #define        PCI_CFG_PIIX4_DEVRESG   0x70
 #define        PCI_CFG_PIIX4_DEVRESH   0x74
 #define        PCI_CFG_PIIX4_DEVRESI   0x78
+#define        PCI_CFG_PIIX4_PMMISC    0x80
+#define        PCI_CFG_PIIX4_SMBBA     0x90
+
 
 
 #endif
index e151809d3869245d0520576e234bccc2bda9dab2..3c670f85a066b8d7ebe70a124ec8d433df6484cf 100644 (file)
@@ -67,9 +67,8 @@
 #include <asm/processor.h>
 #include <405gp_i2c.h>
 #include <miiphy.h>
-#include <devices.h>
 #include "../common/common_util.h"
-
+#include <i2c.h>
 extern block_dev_desc_t * scsi_get_dev(int dev);
 extern block_dev_desc_t * ide_get_dev(int dev);
 
@@ -198,8 +197,8 @@ int init_sdram (void)
        unsigned long *p;
 
 
-
-       serial_init(get_gclk_freq(),9600);
+       i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
+       serial_init(get_gclk_freq(),9600);
        serial_puts("\nInitializing SDRAM, Please stand by");
        mtdcr(ebccfga, pb0cr); /* get cs0 config reg */
        pbcr = mfdcr(ebccfgd);
@@ -476,7 +475,7 @@ void ide_set_reset(int idereset)
 
 int checkboard (void)
 {
-    unsigned char s[50];
+       unsigned char s[50];
        unsigned char bc,var,rc;
        int i;
        backup_t *b=(backup_t *)s;
@@ -492,24 +491,24 @@ int checkboard (void)
        }
        rc++;
        i=getenv_r("serial#",s,32);
-    if ((i==0) || strncmp(s, "MIP405", 6)) {
-       get_backup_values(b);
+       if ((i==0) || strncmp(s, "MIP405", 6)) {
+               get_backup_values(b);
                if(strncmp(b->signature,"MPL\0",4)!=0) {
                        printf("### No HW ID - assuming MIP405");
                        printf("-%d Rev %c",rc, 'A'+((bc>>4)&0xf));
                }
                else {
                        b->serial_name[6]=0;
-               printf("%s-%d Rev %c SN: %s",b->serial_name,rc, 'A'+((bc>>4)&0xf),&b->serial_name[7]);
+                       printf("%s-%d Rev %c SN: %s",b->serial_name,rc, 'A'+((bc>>4)&0xf),&b->serial_name[7]);
                }
-    }
-    else {
-       s[6]=0;
-       printf("%s-%d Rev %c SN: %s",s,rc, 'A'+((bc>>4)&0xf),&s[7]);
+       }
+       else {
+               s[6]=0;
+               printf("%s-%d Rev %c SN: %s",s,rc, 'A'+((bc>>4)&0xf),&s[7]);
        }
        bc=in8(PLD_EXT_CONF_REG);
        printf(" Boot Config: 0x%x\n",bc);
-    return (0);
+       return (0);
 }
 
 
@@ -599,74 +598,36 @@ void misc_init_r(bd_t *bd)
        }
 #endif
        /* it is time to swap the flash permanently to the flash area */
-       switch_cs(FALSE);
-}
-
-
-
-void set_init_backup(void)
-{
-    unsigned char *s;
-       char buf[32];
-       backup_t back;
-
-       s=getenv("serial#");
-       if(!s) {
-               get_backup_values(&back);
-               if(strncmp(back.signature,"MPL\0",4)==0) {
-                       sprintf(buf,"%s",back.serial_name);
-                       setenv("serial#",buf);
-                       sprintf(buf,"%s",back.eth_addr);
-                       setenv("ethaddr",buf);
-                       printf("INFO:  serial# and ethaddr recovered, use saveenv\n");
-               }
-       }
-       else {
-               /* check if back up is set */
-               get_backup_values(&back);
-               if(strncmp(back.signature,"MPL\0",4)!=0) {
-                       set_backup_values(0);
-               }
-       }
+/*     switch_cs(FALSE); */
 }
 
-extern device_t *stdio_devices[];
-extern char *stdio_names[];
-
-void show_stdio_dev(void)
+void print_mip405_rev (void)
 {
-       /* Print informations */
-       printf ("In:    ");
-       if (stdio_devices[stdin] == NULL) {
-               printf ("No input devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stdin]->name);
-       }
-
-       printf ("Out:   ");
-       if (stdio_devices[stdout] == NULL) {
-               printf ("No output devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stdout]->name);
-       }
-
-       printf ("Err:   ");
-       if (stdio_devices[stderr] == NULL) {
-               printf ("No error devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stderr]->name);
-       }
+       unsigned char part, vers, cfg, rev;
+       
+       cfg=get_board_revcfg();
+       vers=cfg;
+       vers&=0xf;
+       rev=(   ((vers & 0x1) ? 0x8 : 0) |
+               ((vers & 0x2) ? 0x4 : 0) |
+               ((vers & 0x4) ? 0x2 : 0) |
+               ((vers & 0x8) ? 0x1 : 0));
+       
+       part=in8(PLD_PART_REG);
+       vers=in8(PLD_VERS_REG);
+       printf ("Rev:   MIP405-%d Rev %c PLD%d Vers %d\n",
+               (16-rev),((cfg>>4) & 0xf) + 'A', part,vers);
 }
 
 
-
 int last_stage_init(void)
 {
-       set_init_backup();
-    if(miiphy_write(0x1, 0x14, 0x2402) != 0) {
-      printf("Error writing to the PHY\n");
+       if(miiphy_write(0x1, 0x14, 0x2402) != 0) {
+               printf("Error writing to the PHY\n");
        }
+       print_mip405_rev();
        show_stdio_dev();
+       check_env();
        return 0;
 }
 
index e552c8fd7f593da6346cc3a60ce1b4e530458808..5559562180a89c18eab7f0938654530b0dabfa62 100644 (file)
@@ -28,7 +28,6 @@
 #include "pip405.h"
 #include <asm/processor.h>
 #include <i2c.h>
-#include <devices.h>
 #include "../common/isa.h"
 #include "../common/video.h"
 #include "../common/common_util.h"
@@ -203,6 +202,7 @@ int board_pre_init (void)
 #endif
 
        /* Read Serial Presence Detect Information */
+       i2c_init (CFG_I2C_SPEED, CFG_I2C_SLAVE);
        dataout[0] = 0;
        for (i = 0; i < 128; i++)
                datain[i] = 127;
@@ -683,30 +683,6 @@ int overwrite_console (void)
 }
 
 
-void set_init_backup (void)
-{
-       unsigned char *s;
-       char buf[32];
-       backup_t back;
-
-       s = getenv ("serial#");
-       if (!s) {
-               get_backup_values (&back);
-               if (strncmp (back.signature, "MPL\0", 4) == 0) {
-                       sprintf (buf, "%s", back.serial_name);
-                       setenv ("serial#", buf);
-                       sprintf (buf, "%s", back.eth_addr);
-                       setenv ("ethaddr", buf);
-                       printf ("INFO:  serial# and ethaddr recovered, use saveenv\n");
-               }
-       } else {
-               /* check if back up is set */
-               get_backup_values (&back);
-               if (strncmp (back.signature, "MPL\0", 4) != 0) {
-                       set_backup_values (0);
-               }
-       }
-}
 
 extern int isa_init (void);
 
@@ -723,42 +699,15 @@ void print_pip405_rev (void)
                        vers & 0xf, (part >> 4) & 0xf, (vers >> 4) & 0xf);
 }
 
-extern device_t *stdio_devices[];
-extern char *stdio_names[];
-
-void show_stdio_dev (void)
-{
-       /* Print informations */
-       printf ("In:    ");
-       if (stdio_devices[stdin] == NULL) {
-               printf ("No input devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stdin]->name);
-       }
-
-       printf ("Out:   ");
-       if (stdio_devices[stdout] == NULL) {
-               printf ("No output devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stdout]->name);
-       }
-
-       printf ("Err:   ");
-       if (stdio_devices[stderr] == NULL) {
-               printf ("No error devices available!\n");
-       } else {
-               printf ("%s\n", stdio_devices[stderr]->name);
-       }
-}
-
+extern void check_env(void);
 
 
 int last_stage_init (void)
 {
        print_pip405_rev ();
-       set_init_backup ();
        isa_init ();
        show_stdio_dev ();
+       check_env();
        return 0;
 }
 
@@ -1075,7 +1024,7 @@ void video_write_board_info (void)
        init_data_t *idata = (init_data_t *) (CFG_INIT_RAM_ADDR + CFG_INIT_DATA_OFFSET);
        unsigned char *s = getenv ("serial#");
        unsigned char *e;
-       unsigned char bc;
+       unsigned char bc,sw;
 
        /* first write PPCBOOT Info */
        video_puts ("\n");
@@ -1151,7 +1100,9 @@ void video_write_board_info (void)
        video_puts (buf);
        /* flash size: */
        video_puts ("FLASH: ");
-       if (switch_cs (0) == 0) {
+       sw = switch_cs (0);
+       switch_cs (sw);
+       if (sw == 0) {
                bc = video_set_attr (VGA_ATTR_CLR_GRN);
                video_puts ("(Flash boot)");
                video_set_attr (bc);
index 9ddde2d23fca74851a8ac265f7bd27cd6be9ba3e..295dee470a21ae9c680f412a43a7635ecbe37e04 100644 (file)
@@ -182,8 +182,12 @@ int do_bootm (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
 
        switch (hdr->ih_comp) {
        case IH_COMP_NONE:
-               printf ("   Loading %s ... ", name);
-               memcpy ((void *)hdr->ih_load, (uchar *)data, len);
+               if(hdr->ih_load == addr) {
+                       printf ("   XIP %s ... ", name);
+               } else {
+                       printf ("   Loading %s ... ", name);
+                       memcpy ((void *)hdr->ih_load, (uchar *)data, len);
+               }
                break;
        case IH_COMP_GZIP:
                printf ("   Uncompressing %s ... ", name);
index 714aa25a0b92e2b8929785fc7c245a81fa32ade3..5d3d2fe864ca586ceda8421eb8c5b7d96603a56a 100644 (file)
@@ -91,7 +91,7 @@ void pci_405gp_init(bd_t *bd, struct pci_controller *hose)
   unsigned long ptmms[2]    = {~(bd->bi_memsize - 1) | 1, ~(bd->bi_flashsize - 1) | 1};
 #else
   unsigned long ptmla[2]    = {CFG_PCI_PTM1LA, CFG_PCI_PTM2LA};
-  unsigned long ptmms[2]    = {CFG_PCI_PTM2MS, CFG_PCI_PTM2MS};
+  unsigned long ptmms[2]    = {CFG_PCI_PTM1MS, CFG_PCI_PTM2MS};
 #endif
 #if defined(CONFIG_PIP405) || defined (CONFIG_MIP405)
   unsigned long pmmla[3]    = {0x80000000, 0xA0000000, 0};
@@ -236,7 +236,7 @@ void pci_405gp_init(bd_t *bd, struct pci_controller *hose)
   }
 #endif
 
-#if (CONFIG_PCI_HOST != PCI_HOST_ADAPTOR)
+#if (CONFIG_PCI_HOST != PCI_HOST_ADAPTER)
 #if (CONFIG_PCI_HOSE == PCI_HOST_AUTO)
   if (mfdcr(strap) & PSR_PCI_ARBIT_EN)
 #endif
index cebc7026a40a08c6c8af3444aca812f314e60205..f8db4b6c7d2c73bef22dcf0e87cd371f0417174d 100644 (file)
@@ -36,6 +36,8 @@
 #define PRINTF(fmt,args...)
 #endif
 
+/* enable this if CDs are written with the PowerPC Platform ID */
+#undef CHECK_FOR_POWERPC_PLATTFORM
 #define CD_SECTSIZE 2048
 
 static unsigned char tmpbuf[CD_SECTSIZE];
@@ -50,6 +52,15 @@ static inline unsigned long le32_to_int(unsigned char *le32)
             le32[0]
           );
 }
+/* Convert char[2] in little endian format to the host format integer
+ */
+static inline unsigned short le16_to_int(unsigned char *le16)
+{
+    return ((le16[1] << 8) +
+          le16[0]
+          );
+}
+
 
 /* only boot records will be listed as valid partitions */
 int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_partition_t * info, int verb)
@@ -62,7 +73,6 @@ int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_
        iso_pri_rec_t *ppr = (iso_pri_rec_t     *)tmpbuf;       /* primary desc */
        iso_val_entry_t *pve = (iso_val_entry_t *)tmpbuf;
        iso_init_def_entry_t *pide;
-       iso_header_entry_t *phe;
 
        /* the first sector (sector 0x10) must be a primary volume desc */
        blkaddr=PVD_OFFSET;
@@ -78,10 +88,10 @@ int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_
                        printf("ISO Ident: %s wrong\n",ppr->stand_ident);
                return (-1);
        }
-       lastsect= ((ppr->firstsek_LEpathtab1_LE & 0xff)<<24) +
-                                               ((ppr->firstsek_LEpathtab1_LE & 0xff00)<<8) +
-                                               ((ppr->firstsek_LEpathtab1_LE & 0xff0000)>>8) +
-                                               ((ppr->firstsek_LEpathtab1_LE & 0xff000000)>>24);
+       lastsect= ((ppr->firstsek_LEpathtab1_LE & 0x000000ff)<<24) +
+                 ((ppr->firstsek_LEpathtab1_LE & 0x0000ff00)<< 8) +
+                 ((ppr->firstsek_LEpathtab1_LE & 0x00ff0000)>> 8) +
+                 ((ppr->firstsek_LEpathtab1_LE & 0xff000000)>>24) ;
        info->blksz=ppr->secsize_BE; /* assuming same block size for all entries */
        PRINTF(" Lastsect:%08lx\n",lastsect);
        for(i=blkaddr;i<lastsect;i++) {
@@ -119,72 +129,47 @@ int get_partition_info_iso_verb(block_dev_desc_t * dev_desc, int part_num, disk_
                        printf(" key 0x55 0xAA error\n");
                return(-1);
        }
+#ifdef CHECK_FOR_POWERPC_PLATTFORM
+       if(pve->platform!=0x01) {
+               if(verb)
+                       printf(" no PowerPC platform\n");
+               return(-1);
+       }
+#endif
        /* the validation entry seems to be ok, now search the "partition" */
        entry_num=0;
        offset=0x20;
-       if(part_num==0) { /* the default partition */
-               #if 0
-               if(pve->platform!=0x01) {
-                       if(verb)
-                               printf(" default entry is no PowerPC partition\n");
-                       return(-1);
-               }
-               #endif
-               sprintf(info->name,"%.32s",pve->manu_str);
-               sprintf (info->type, "PPCBoot");
+       sprintf(info->name,"%.32s",pve->manu_str);
+       sprintf (info->type, "PPCBoot");
+       /* the bootcatalog (including validation Entry) is limited to 2048Bytes
+        * (63 boot entries + validation entry) */
+        while(offset<2048) {
                pide=(iso_init_def_entry_t *)&tmpbuf[offset];
-               goto found;
-       }
-       /* partition is not the default partition */
-       offset+=0x20;
-       while(1) {
-               phe=(iso_header_entry_t *)&tmpbuf[offset];
-               if((phe->header_id & 0xfe)!=0x90) { /* no valid header ID */
+               if ((pide->boot_ind==0x88) ||
+                   (pide->boot_ind==0x00)) { /* Header Id for default Sections Entries */
+                       if(entry_num==part_num) { /* part found */
+                               goto found;
+                       }
+                       entry_num++; /* count partitions Entries (boot and non bootables */
+                       offset+=0x20;
+                       continue;
+               }
+               if ((pide->boot_ind==0x90) ||   /* Section Header Entry */
+                   (pide->boot_ind==0x91) ||   /* Section Header Entry (last) */
+                   (pide->boot_ind==0x44)) {   /* Extension Indicator */
+                       offset+=0x20; /* skip unused entries */
+               }
+               else {
                        if(verb)
                                printf(" part %d not found\n",part_num);
                        return(-1);
                }
-               if((entry_num+(phe->numentry[1]<<8)+phe->numentry[0])>=part_num) { /* partition lies in this header */
-                       #if 0
-                       if(phe->platform!=0x01) {
-                               if(verb)
-                                       printf(" part %d is no PowerPC partition\n",part_num);
-                               return(-1);
-                       }
-                       #endif
-                       sprintf(info->type,"%.32s",phe->id_str);
-                       entry_num++;
-                       offset+=0x20;
-                       while(entry_num!=part_num) {
-                               offset+=0x20;
-                               while(tmpbuf[offset]==0x44)
-                                       offset+=0x20; /* skip extension records */
-                               entry_num++;
-                       }
-                       /* part entry should be here */
-                       pide=(iso_init_def_entry_t *)&tmpbuf[offset];
-                       goto found;
-               }
-               else { /* search next header */
-                       if((phe->header_id)==0x91) { /* last header ID */
-                               if(verb)
-                                       printf(" part %d not found\n",part_num);
-                               return(-1);
-                       }
-                       entry_num+=((phe->numentry[1]<<8)+phe->numentry[0]); /* count partitions */
-                       offset+=0x20;
-                       while((tmpbuf[offset]=0x44) || /* skip extension records */
-                                               (tmpbuf[offset]=0x88) || /* skip boot entries */
-                                               (tmpbuf[offset]=0x00)) {         /* skip no boot entries */
-                               offset+=0x20;
-                               if(offset>=CD_SECTSIZE) { /* to prevent overflow */
-                                       if(verb)
-                                               printf(" part %d not found\n",part_num);
-                                       return(-1);
-                               }
-                       } /* while skipping all unused records */
-               } /* else */
-       } /* while(TRUE) */
+       }
+       /* if we reach this point entire sector has been
+        * searched w/o succsess */
+       if(verb)
+               printf(" part %d not found\n",part_num);
+       return(-1);
 found:
        if(pide->boot_ind!=0x88) {
                if(verb)
@@ -192,12 +177,14 @@ found:
                return (-1);
        }
        switch(pide->boot_media) {
-               case 0x00:      info->size=2880>>2; break; /* dummy (No Emulation) */
+               case 0x00: /* no emulation */
+                       info->size=le16_to_int(pide->sec_cnt)>>2;
+                       break;
                case 0x01:      info->size=2400>>2; break; /* 1.2MByte Floppy */
                case 0x02:      info->size=2880>>2; break; /* 1.44MByte Floppy */
                case 0x03:      info->size=5760>>2; break; /* 2.88MByte Floppy */
                case 0x04:      info->size=2880>>2; break; /* dummy (HD Emulation) */
-               default:                info->size=0; break;
+               default:        info->size=0; break;
        }
        newblkaddr=le32_to_int(pide->rel_block_addr);
        info->start=newblkaddr;
@@ -224,9 +211,10 @@ void print_part_iso(block_dev_desc_t * dev_desc)
        printf("Part   Start     Sect x Size Type\n");
        i=0;
        do {
-               printf(" %2d %8ld %8ld %6ld %.32s\n",i,info.start,info.size,info.blksz,info.type);
+               printf (" %2d %8ld %8ld %6ld %.32s\n",
+                       i, info.start, info.size, info.blksz, info.type);
                i++;
-       }while(get_partition_info_iso_verb(dev_desc,i,&info,0)!=-1);
+       } while (get_partition_info_iso_verb(dev_desc,i,&info,0)!=-1);
 }
 
 int test_part_iso (block_dev_desc_t *dev_desc)
@@ -237,5 +225,3 @@ int test_part_iso (block_dev_desc_t *dev_desc)
 }
 
 #endif /* ((CONFIG_COMMANDS & CFG_CMD_IDE) || (CONFIG_COMMANDS & CFG_CMD_SCSI)) && defined(CONFIG_ISO_PARTITION) */
-
-
index 971986323938efe22692cb6f2a9a366e8fdfc124..8b0d2303ed4fc3c3673dd72f78384bcdcbfc0b58 100644 (file)
  ***************************************************************/
 
 #define CONFIG_HARD_I2C                        /* I2c with hardware support */
-#define CFG_I2C_SPEED          400000  /* I2C speed and slave address */
+#define CFG_I2C_SPEED          50000   /* I2C speed and slave address */
 #define CFG_I2C_SLAVE          0x7F
 
 #define CFG_I2C_EEPROM_ADDR    0x53    /* EEPROM 24C128/256            */
 #define CFG_I2C_EEPROM_ADDR_LEN        2       /* Bytes of address             */
 /* mask of address bits that overflow into the "EEPROM chip address"    */
-#undef  CFG_I2C_EEPROM_ADDR_OVERFLOW
-#define CFG_EEPROM_PAGE_WRITE_BITS     6
+#undef CFG_I2C_EEPROM_ADDR_OVERFLOW
 #define CFG_EEPROM_PAGE_WRITE_BITS 6   /* The Atmel 24C128/256 has     */
                                        /* 64 byte page write mode using*/
                                        /* last 6 bits of the address   */
 #define CFG_EEPROM_PAGE_WRITE_ENABLE   /* enable Page write */
+#define CFG_EEPROM_PAGE_WRITE_DELAY_MS 10      /* and takes up to 10 msec */
 
 
 #define CFG_ENV_IS_IN_EEPROM   1       /* use EEPROM for environment vars */
 
 #undef CFG_EXT_SERIAL_CLOCK           /* no external serial clock used */
 #define CFG_IGNORE_405_UART_ERRATA_59
-#define CFG_BASE_BAUD       691200
+#define CFG_BASE_BAUD       916667
 
 /* The following table includes the supported baudrates */
 #define CFG_BAUDRATE_TABLE     \
 /************************************************************
  * Ident
  ************************************************************/
-#define VERSION_TAG "REL_1_1_3"
+#define VERSION_TAG "dp_00006"
 #define CONFIG_IDENT_STRING "\n(c) 2001 by MPL AG Switzerland, MEV-10072-001 " VERSION_TAG
 
 
index 2256f4ba123f85221b886ebbbc9e4c4cddafb5d2..19880d2114f9049545ba2821395990abf7edb664 100644 (file)
  * The Atmel EEPROM uses 16Bit addressing.
  ***************************************************************/ 
 #define CONFIG_HARD_I2C                        /* I2c with hardware support */
-#define CFG_I2C_SPEED          400000  /* I2C speed and slave address */
+#define CFG_I2C_SPEED          50000   /* I2C speed and slave address */
 #define CFG_I2C_SLAVE          0x7F
 
 #define CFG_I2C_EEPROM_ADDR    0x53
 #define CFG_I2C_EEPROM_ADDR_LEN        2
 #define CFG_ENV_IS_IN_EEPROM    1       /* use EEPROM for environment vars */
 #define CFG_ENV_OFFSET          0x000   /* environment starts at the beginning of the EEPROM */
-#define CFG_ENV_SIZE            0x200   /* 512 bytes may be used for env vars */
+#define CFG_ENV_SIZE            0x800   /* 2 kBytes may be used for env vars */
 
-/* The Atmel 24C128/256 has 64 byte page write mode using last 6 bits of the address   */
-#define CFG_EEPROM_PAGE_WRITE_BITS     6
+#undef CFG_I2C_EEPROM_ADDR_OVERFLOW
+#define CFG_EEPROM_PAGE_WRITE_BITS 6   /* The Atmel 24C128/256 has     */
+                                       /* 64 byte page write mode using*/
+                                       /* last 6 bits of the address   */
 #define CFG_EEPROM_PAGE_WRITE_ENABLE   /* enable Page write */
+#define CFG_EEPROM_PAGE_WRITE_DELAY_MS 10      /* and takes up to 10 msec */
+
 
 /***************************************************************
  * Definitions for Serial Presence Detect EEPROM address
 /************************************************************
  * Ident
  ************************************************************/
-#define VERSION_TAG "REL_1_1_3"
+#define VERSION_TAG "dp_00006"
 #define CONFIG_IDENT_STRING "\n(c) 2001 by MPL AG Switzerland, MEV-10066-001 " VERSION_TAG
 
 
index 19d3d024060dd0c6fdfe2215326ce32cf4feccf5..6bb7f4da4c1719b853443705108b60851042b58e 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * (C) Copyright 2000
+ * (C) Copyright 2000-2002
  * DENX Software Engineering
  * Wolfgang Denk, wd@denx.de
  * All rights reserved.
@@ -35,8 +35,8 @@ typedef               unsigned char   uint8_t;
 typedef                unsigned short  uint16_t;
 typedef                unsigned int    uint32_t;
 
-#define     ntohl(a)        SWAP_LONG(a)
-#define     htonl(a)        SWAP_LONG(a)
+#define     ntohl(a)   SWAP_LONG(a)
+#define     htonl(a)   SWAP_LONG(a)
 #endif /* __WIN32__ */
 
 #include <image.h>
@@ -138,6 +138,7 @@ int eflag    = 0;
 int lflag    = 0;
 int vflag    = 0;
 int sflag    = 0;
+int xflag    = 0;
 int opt_os   = IH_OS_LINUX;
 int opt_arch = IH_CPU_PPC;
 int opt_type = IH_TYPE_KERNEL;
@@ -231,6 +232,9 @@ main (int argc, char **argv)
                        case 'v':
                                vflag++;
                                break;
+                       case 'x':
+                               xflag++;
+                               break;
                        default:
                                usage ();
                        }
@@ -241,8 +245,24 @@ NXTARG:            ;
        if ((argc != 1) || ((lflag ^ dflag) == 0))
                usage();
 
-       if (!eflag)
+       if (!eflag) {
                ep = addr;
+               /* If XIP, entry point must be after the ppcboot header */
+               if (xflag)
+                       ep += sizeof(image_header_t);
+       }
+
+       /*
+        * If XIP, ensure the entry point is equal to the load address plus
+        * the size of the ppcboot header.
+        */
+       if (xflag) {
+               if (ep != addr + sizeof(image_header_t)) {
+                       fprintf (stderr, "%s: For XIP, the entry point must be the load addr + %d\n",
+                               cmdname, sizeof(image_header_t));
+                       exit (EXIT_FAILURE);
+               }
+       }
 
        imagefile = *argv;
 
@@ -289,10 +309,10 @@ NXTARG:           ;
                        exit (EXIT_FAILURE);
                }
 
-                /*
-                 * create copy of header so that we can blank out the
-                 * checksum field for checking - this can't be done
-                 * on the PROT_READ mapped data.
+               /*
+                * create copy of header so that we can blank out the
+                * checksum field for checking - this can't be done
+                * on the PROT_READ mapped data.
                 */
                memcpy (hdr, ptr, sizeof(image_header_t));
 
@@ -471,6 +491,8 @@ copy_file (int ifd, const char *datafile, int pad)
        unsigned char *ptr;
        int tail;
        int zero = 0;
+       int offset = 0;
+       int size;
 
        if (vflag) {
                fprintf (stderr, "Adding Image %s\n", datafile);
@@ -496,13 +518,41 @@ copy_file (int ifd, const char *datafile, int pad)
                exit (EXIT_FAILURE);
        }
 
-       if (write(ifd, ptr, sbuf.st_size) != sbuf.st_size) {
+       if (xflag) {
+               unsigned char *p = NULL;
+               /*
+                * XIP: do not append the image_header_t at the
+                * beginning of the file, but consume the space
+                * reserved for it.
+                */
+
+               if (sbuf.st_size < sizeof(image_header_t)) {
+                       fprintf (stderr,
+                               "%s: Bad size: \"%s\" is too small for XIP\n",
+                               cmdname, datafile);
+                       exit (EXIT_FAILURE);
+               }
+
+               for (p=ptr; p < ptr+sizeof(image_header_t); p++) {
+                       if ( *p != 0xff ) {
+                               fprintf (stderr,
+                                       "%s: Bad file: \"%s\" has invalid buffer for XIP\n",
+                                       cmdname, datafile);
+                               exit (EXIT_FAILURE);
+                       }
+               }
+
+               offset = sizeof(image_header_t);
+       }
+
+       size = sbuf.st_size - offset;
+       if (write(ifd, ptr + offset, size) != size) {
                fprintf (stderr, "%s: Write error on %s: %s\n",
                        cmdname, imagefile, strerror(errno));
                exit (EXIT_FAILURE);
        }
 
-       if (pad && ((tail = sbuf.st_size % 4) != 0)) {
+       if (pad && ((tail = size % 4) != 0)) {
 
                if (write(ifd, (char *)&zero, 4-tail) != 4-tail) {
                        fprintf (stderr, "%s: Write error on %s: %s\n",
@@ -531,6 +581,7 @@ usage ()
                         "          -e ==> set entry point to 'ep' (hex)\n"
                         "          -n ==> set image name to 'name'\n"
                         "          -d ==> use image data from 'datafile'\n"
+                        "          -x ==> set XIP (execute in place)\n"
                );
        exit (EXIT_FAILURE);
 }
@@ -573,9 +624,9 @@ print_header (image_header_t *hdr)
                                i, size, size>>10, size>>20);
                        if (hdr->ih_type == IH_TYPE_SCRIPT && i > 0) {
                                /*
-                                 * the user may need to know offsets
-                                 * if planning to do something with
-                                 * multiple files
+                                * the user may need to know offsets
+                                * if planning to do something with
+                                * multiple files
                                 */
                                printf ("    Offset = %08x\n", pos);
                        }