rename CFG_ENV macros to CONFIG_ENV
[platform/kernel/u-boot.git] / board / omap1610inn / flash.c
index ae7fb3b..d88a981 100644 (file)
@@ -2,7 +2,7 @@
  * (C) Copyright 2001
  * Kyle Harris, Nexus Technologies, Inc. kharris@nexus-tech.net
  *
- * (C) Copyright 2001
+ * (C) Copyright 2001-2004
  * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  *
  * (C) Copyright 2003
@@ -19,7 +19,7 @@
  *
  * 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
+ * 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
@@ -32,7 +32,7 @@
 #include <linux/byteorder/swab.h>
 
 #define PHYS_FLASH_SECT_SIZE   0x00020000      /* 256 KB sectors (x2) */
-flash_info_t flash_info[CFG_MAX_FLASH_BANKS];  /* info for FLASH chips    */
+flash_info_t flash_info[CFG_MAX_FLASH_BANKS];  /* info for FLASH chips    */
 
 /* Board support for 1 or 2 flash devices */
 #undef FLASH_PORT_WIDTH32
@@ -80,6 +80,7 @@ void flash_print_info (flash_info_t * info);
 void flash_unprotect_sectors (FPWV * addr);
 int flash_erase (flash_info_t * info, int s_first, int s_last);
 int write_buff (flash_info_t * info, uchar * src, ulong addr, ulong cnt);
+void flash_unlock(flash_info_t * info);
 
 /*-----------------------------------------------------------------------
  */
@@ -88,11 +89,12 @@ unsigned long flash_init (void)
 {
        int i;
        ulong size = 0;
+
        for (i = 0; i < CFG_MAX_FLASH_BANKS; i++) {
                switch (i) {
                case 0:
-                       flash_get_size ((FPW *) PHYS_FLASH_1, &flash_info[i]);
-                       flash_get_offsets (PHYS_FLASH_1, &flash_info[i]);
+                       flash_get_size ((FPW *) CFG_FLASH_BASE, &flash_info[i]);
+                       flash_get_offsets (CFG_FLASH_BASE, &flash_info[i]);
                        /* to reset the lock bit */
                        flash_unlock(&flash_info[i]);
                        break;
@@ -110,23 +112,23 @@ unsigned long flash_init (void)
                        CFG_FLASH_BASE + monitor_flash_len - 1, &flash_info[0]);
 
        flash_protect (FLAG_PROTECT_SET,
-                       CFG_ENV_ADDR,
-                       CFG_ENV_ADDR + CFG_ENV_SIZE - 1, &flash_info[0]);
+                       CONFIG_ENV_ADDR,
+                       CONFIG_ENV_ADDR + CONFIG_ENV_SIZE - 1, &flash_info[0]);
 
        return size;
 }
 
 /*-----------------------------------------------------------------------
  */
-flash_unlock(flash_info_t * info)
+void flash_unlock(flash_info_t * info)
 {
-        int j;
-        for (j=2;j<CFG_MAX_FLASH_SECT;j++){
-        FPWV *addr = (FPWV *) (info->start[j]);
-        flash_unprotect_sectors (addr);
-        *addr = (FPW) 0x00500050;/* clear status register */
-        *addr = (FPW) 0x00FF00FF;/* resest to read mode */
-        }
+       int j;
+       for (j=2;j<CFG_MAX_FLASH_SECT;j++){
+       FPWV *addr = (FPWV *) (info->start[j]);
+       flash_unprotect_sectors (addr);
+       *addr = (FPW) 0x00500050;/* clear status register */
+       *addr = (FPW) 0x00FF00FF;/* resest to read mode */
+       }
 }
 
 /*-----------------------------------------------------------------------
@@ -192,7 +194,7 @@ void flash_print_info (flash_info_t * info)
                if ((i % 5) == 0)
                        printf ("\n   ");
                printf (" %08lX%s",
-                       info->start[i], info->protect[i] ? " (RO)" : "     ");
+                       info->start[i], info->protect[i] ? " (RO)" : "     ");
        }
        printf ("\n");
        return;
@@ -224,18 +226,18 @@ static ulong flash_get_size (FPW * addr, flash_info_t * info)
                info->sector_count = 0;
                info->size = 0;
                addr[0] = (FPW) 0x00FF00FF;     /* restore read mode */
-               return (0);             /* no or unknown flash  */
+               return (0);             /* no or unknown flash  */
        }
 
        mb ();
-       value = addr[1];        /* device ID        */
+       value = addr[1];        /* device ID        */
        switch (value) {
 
        case (FPW) (INTEL_ID_28F256L18T):
                info->flash_id += FLASH_28F256L18T;
                info->sector_count = 259;
                info->size = 0x02000000;
-               break;                  /* => 32 MB     */
+               break;                  /* => 32 MB     */
 
        default:
                info->flash_id = FLASH_UNKNOWN;
@@ -318,7 +320,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
 
        /* Start erase on unprotected sectors */
        for (sect = s_first; sect <= s_last; sect++) {
-               if (info->protect[sect] == 0) { /* not protected */
+               if (info->protect[sect] == 0) { /* not protected */
                        FPWV *addr = (FPWV *) (info->start[sect]);
                        FPW status;
 
@@ -348,7 +350,7 @@ int flash_erase (flash_info_t * info, int s_first, int s_last)
                                }
                        }
 
-                       /* clear status register cmd.   */
+                       /* clear status register cmd.   */
                        *addr = (FPW) 0x00500050;
                        *addr = (FPW) 0x00FF00FF;/* resest to read mode */
                        printf (" done\n");