]> www.infradead.org Git - users/rw/ppcboot.git/commitdiff
Switch LWMON config to environment in flash
authorwdenk <wdenk>
Fri, 11 Oct 2002 12:26:26 +0000 (12:26 +0000)
committerwdenk <wdenk>
Fri, 11 Oct 2002 12:26:26 +0000 (12:26 +0000)
board/lwmon/flash.c
common/env_flash.c
include/configs/lwmon.h

index fc91b8ff9d84c445bc66f7223b4cb00d0a84a13b..3d2a00fd3e070aeb9f6dfe40a7ec31f30f3cb023 100644 (file)
@@ -21,6 +21,8 @@
  * MA 02111-1307 USA
  */
 
+/* #define DEBUG */
+
 #include <common.h>
 #include <mpc8xx.h>
 
 # endif
 #endif
 
-/*---------------------------------------------------------------------*/
-#undef DEBUG_FLASH
-
-#ifdef DEBUG_FLASH
-#define DEBUGF(fmt,args...) printf(fmt ,##args)
-#else
-#define DEBUGF(fmt,args...)
-#endif
 /*---------------------------------------------------------------------*/
 
 flash_info_t   flash_info[CFG_MAX_FLASH_BANKS]; /* info for FLASH chips        */
@@ -72,7 +66,7 @@ unsigned long flash_init (void)
 
        /* Static FLASH Bank configuration here - FIXME XXX */
 
-       DEBUGF("\n## Get flash bank 1 size @ 0x%08x\n",FLASH_BASE0_PRELIM);
+       debug ("\n## Get flash bank 1 size @ 0x%08x\n",FLASH_BASE0_PRELIM);
 
        size_b0 = flash_get_size((vu_long *)FLASH_BASE0_PRELIM, &flash_info[0]);
 
@@ -83,11 +77,11 @@ unsigned long flash_init (void)
                        size_b0, size_b0<<20);
        }
 
-       DEBUGF("## Get flash bank 2 size @ 0x%08x\n",FLASH_BASE1_PRELIM);
+       debug ("## Get flash bank 2 size @ 0x%08x\n",FLASH_BASE1_PRELIM);
 
        size_b1 = flash_get_size((vu_long *)FLASH_BASE1_PRELIM, &flash_info[1]);
 
-       DEBUGF("## Prelim. Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
+       debug ("## Prelim. Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
 
        if (size_b1 > size_b0) {
                printf ("## ERROR: "
@@ -104,7 +98,7 @@ unsigned long flash_init (void)
                return (0);
        }
 
-       DEBUGF ("## Before remap: "
+       debug  ("## Before remap: "
                "BR0: 0x%08x    OR0: 0x%08x    "
                "BR1: 0x%08x    OR1: 0x%08x\n",
                memctl->memc_br0, memctl->memc_or0,
@@ -115,7 +109,7 @@ unsigned long flash_init (void)
                                OR_CSNT_SAM | OR_ACS_DIV1;
        memctl->memc_br0 = (CFG_FLASH_BASE & BR_BA_MSK) | BR_PS_32 | BR_V;
 
-       DEBUGF("## BR0: 0x%08x    OR0: 0x%08x\n",
+       debug ("## BR0: 0x%08x    OR0: 0x%08x\n",
                memctl->memc_br0, memctl->memc_or0);
 
        /* Re-do sizing to get full correct info */
@@ -147,7 +141,7 @@ unsigned long flash_init (void)
                memctl->memc_br1 = ((CFG_FLASH_BASE + size_b0) & BR_BA_MSK) |
                                        BR_PS_32 | BR_V;
 
-               DEBUGF("## BR1: 0x%08x    OR1: 0x%08x\n",
+               debug ("## BR1: 0x%08x    OR1: 0x%08x\n",
                        memctl->memc_br1, memctl->memc_or1);
 
                /* Re-do sizing to get full correct info */
@@ -177,7 +171,7 @@ unsigned long flash_init (void)
                memctl->memc_br1 = 0;           /* invalidate bank */
                memctl->memc_or1 = 0;           /* invalidate bank */
 
-               DEBUGF("## DISABLE BR1: 0x%08x    OR1: 0x%08x\n",
+               debug ("## DISABLE BR1: 0x%08x    OR1: 0x%08x\n",
                        memctl->memc_br1, memctl->memc_or1);
 
                flash_info[1].flash_id = FLASH_UNKNOWN;
@@ -185,7 +179,7 @@ unsigned long flash_init (void)
                flash_info[1].size = 0;
        }
 
-       DEBUGF("## Final Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
+       debug ("## Final Flash bank sizes: %08lx + 0x%08lx\n",size_b0,size_b1);
 
        return (size_b0 + size_b1);
 }
@@ -289,7 +283,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
        addr[0] = 0x00900090;
        value = addr[0];
 
-       DEBUGF("Manuf. ID @ 0x%08lx: 0x%08lx\n", (ulong)addr, value);
+       debug ("Manuf. ID @ 0x%08lx: 0x%08lx\n", (ulong)addr, value);
 
        switch (value) {
        case AMD_MANUFACT:
@@ -317,7 +311,7 @@ static ulong flash_get_size (vu_long *addr, flash_info_t *info)
 
        value = addr[1];                        /* device ID            */
 
-       DEBUGF("Device ID @ 0x%08lx: 0x%08lx\n", (ulong)(&addr[1]), value);
+       debug ("Device ID @ 0x%08lx: 0x%08lx\n", (ulong)(&addr[1]), value);
 
        switch (value) {
        case INTEL_ID_28F320J3A:
@@ -365,6 +359,8 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
        int flag, prot, sect;
        ulong start, now, last;
 
+       debug ("flash_erase: first: %d last: %d\n", s_first, s_last);
+
        if ((s_first < 0) || (s_first > s_last)) {
                if (info->flash_id == FLASH_UNKNOWN) {
                        printf ("- missing\n");
index 4f1081ade3b6222a9330dfe5806526f799162e65..b76ed14bcb3c8e4c7fcbbbbb9d551f587439b0f4 100644 (file)
@@ -271,6 +271,10 @@ int saveenv(void)
        flash_offset    = ((ulong)flash_addr) & (CFG_ENV_SECT_SIZE-1);
        flash_sect_addr = ((ulong)flash_addr) & ~(CFG_ENV_SECT_SIZE-1);
 
+       debug ( "copy old content: "
+               "sect_addr: %08lX  env_addr: %08lX  offset: %08lX\n",
+               flash_sect_addr, (ulong)flash_addr, flash_offset);
+
        /* copy old contents to temporary buffer */
        memcpy (env_buffer, (void *)flash_sect_addr, CFG_ENV_SECT_SIZE);
 
@@ -293,6 +297,9 @@ int saveenv(void)
        end_addr = flash_sect_addr + 0x20000 - 1;
 #endif
 
+       debug ("Protect off %08lX ... %08lX\n",
+               (ulong)flash_sect_addr, end_addr);
+
        if (flash_sect_protect (0, flash_sect_addr, end_addr))
                return 1;
 
index e34c1139962699a4f610bd7dad14adf10c1581ee..1fa63721b6a495fad9d9a36ba6188f425f271aa7 100644 (file)
 #if 1
 /* Put environment in flash which is much faster to boot */
 #define CFG_ENV_IS_IN_FLASH    1
-#define CFG_ENV_ADDR       0x407E0000  /* Address    of Environment Sector     */
+#define CFG_ENV_ADDR       0x40040000  /* Address    of Environment Sector     */
 #define CFG_ENV_SIZE           0x2000  /* Total Size of Environment            */
-#define CFG_ENV_SECT_SIZE      0x20000 /* we have BIG sectors only :-(         */
+#define CFG_ENV_SECT_SIZE      0x40000 /* we have BIG sectors only :-(         */
 #else
 /* Environment in EEPROM */
 #define CFG_ENV_IS_IN_EEPROM   1