]> git.kernelconcepts.de Git - karo-tx-uboot.git/blobdiff - board/cmi/flash.c
imported Freescale specific U-Boot additions for i.MX28,... release L2.6.31_10.08.01
[karo-tx-uboot.git] / board / cmi / flash.c
index f7c25f4284334f9d51e6f82a754e7b34f15d42a0..630c3305e16b8bd2286694233e8396689193a33d 100755 (executable)
@@ -25,7 +25,7 @@
  * File:               flash.c
  *
  * Discription:                This Driver is for 28F320J3A, 28F640J3A and
- *                     28F128J3A Intel flashs working in 16 Bit mode.
+ *                     28F128J3A Intel flashs working in 16 Bit mode.
  *                     They are single bank flashs.
  *
  *                     Most of this code is taken from existing u-boot
 #include <common.h>
 #include <mpc5xx.h>
 
-#if defined(CFG_ENV_IS_IN_FLASH)
-# ifndef  CFG_ENV_ADDR
-#  define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_ENV_OFFSET)
+#if defined(CONFIG_ENV_IS_IN_FLASH)
+# ifndef  CONFIG_ENV_ADDR
+#  define CONFIG_ENV_ADDR      (CONFIG_SYS_FLASH_BASE + CONFIG_ENV_OFFSET)
 # endif
-# ifndef  CFG_ENV_SIZE
-#  define CFG_ENV_SIZE CFG_ENV_SECT_SIZE
+# ifndef  CONFIG_ENV_SIZE
+#  define CONFIG_ENV_SIZE      CONFIG_ENV_SECT_SIZE
 # endif
-# ifndef  CFG_ENV_SECT_SIZE
-#  define CFG_ENV_SECT_SIZE  CFG_ENV_SIZE
+# ifndef  CONFIG_ENV_SECT_SIZE
+#  define CONFIG_ENV_SECT_SIZE  CONFIG_ENV_SIZE
 # endif
 #endif
 
 #define FLASH_CMD_PROTECT_CLEAR                0x00D0
 #define FLASH_STATUS_DONE              0x0080
 
-flash_info_t   flash_info[CFG_MAX_FLASH_BANKS];
+flash_info_t   flash_info[CONFIG_SYS_MAX_FLASH_BANKS];
 
 /*
  * Local function prototypes
  */
-static ulong   flash_get_size          (vu_short *addr, flash_info_t *info);
-static int     write_short             (flash_info_t *info, ulong dest, ushort data);
-static void    flash_get_offsets       (ulong base, flash_info_t *info);
+static ulong   flash_get_size          (vu_short *addr, flash_info_t *info);
+static int     write_short             (flash_info_t *info, ulong dest, ushort data);
+static void    flash_get_offsets       (ulong base, flash_info_t *info);
 
 /*
  * Initialize flash
@@ -81,7 +81,7 @@ unsigned long flash_init (void)
        int i;
 
        /* Init: no FLASHes known */
-       for (i=0; i<CFG_MAX_FLASH_BANKS; ++i) {
+       for (i=0; i<CONFIG_SYS_MAX_FLASH_BANKS; ++i) {
                flash_info[i].flash_id = FLASH_UNKNOWN;
        }
 
@@ -102,19 +102,19 @@ unsigned long flash_init (void)
 
        flash_info[0].size = size_b0;
 
-#if CFG_MONITOR_BASE >= CFG_FLASH_BASE
+#if CONFIG_SYS_MONITOR_BASE >= CONFIG_SYS_FLASH_BASE
        /* monitor protection ON by default */
        flash_protect(FLAG_PROTECT_SET,
-                     CFG_MONITOR_BASE,
-                     CFG_MONITOR_BASE+monitor_flash_len-1,
+                     CONFIG_SYS_MONITOR_BASE,
+                     CONFIG_SYS_MONITOR_BASE+monitor_flash_len-1,
                      &flash_info[0]);
 #endif
 
-#ifdef CFG_ENV_IS_IN_FLASH
+#ifdef CONFIG_ENV_IS_IN_FLASH
        /* ENV protection ON by default */
        flash_protect(FLAG_PROTECT_SET,
-                     CFG_ENV_ADDR,
-                     CFG_ENV_ADDR+CFG_ENV_SECT_SIZE-1,
+                     CONFIG_ENV_ADDR,
+                     CONFIG_ENV_ADDR+CONFIG_ENV_SECT_SIZE-1,
                      &flash_info[0]);
 #endif
 
@@ -268,10 +268,10 @@ static ulong flash_get_size (vu_short *addr, flash_info_t *info)
 
        }
 
-       if (info->sector_count > CFG_MAX_FLASH_SECT) {
+       if (info->sector_count > CONFIG_SYS_MAX_FLASH_SECT) {
                printf ("** ERROR: sector count %d > max (%d) **\n",
-                       info->sector_count, CFG_MAX_FLASH_SECT);
-               info->sector_count = CFG_MAX_FLASH_SECT;
+                       info->sector_count, CONFIG_SYS_MAX_FLASH_SECT);
+               info->sector_count = CONFIG_SYS_MAX_FLASH_SECT;
        }
 
        addr[0] = FLASH_CMD_RESET;              /* restore read mode */
@@ -345,7 +345,7 @@ int flash_erase (flash_info_t *info, int s_first, int s_last)
                        udelay (1000);
 
                        while (((status = *addr) & FLASH_STATUS_DONE) != FLASH_STATUS_DONE) {
-                               if ((now=get_timer(start)) > CFG_FLASH_ERASE_TOUT) {
+                               if ((now=get_timer(start)) > CONFIG_SYS_FLASH_ERASE_TOUT) {
                                        printf("Flash erase timeout at address %lx\n", info->start[sect]);
                                        *addr = FLASH_CMD_SUSPEND_ERASE;
                                        *addr = FLASH_CMD_RESET;
@@ -473,7 +473,7 @@ static int write_short (flash_info_t *info, ulong dest, ushort data)
 
        /* wait for error or finish */
        while(!(addr[0] & FLASH_STATUS_DONE)){
-               if (get_timer(start) > CFG_FLASH_WRITE_TOUT) {
+               if (get_timer(start) > CONFIG_SYS_FLASH_WRITE_TOUT) {
                        addr[0] = FLASH_CMD_RESET;
                        return (1);
                }
@@ -504,7 +504,7 @@ int flash_real_protect(flash_info_t *info, long sector, int prot)
        /* wait for error or finish */
        start = get_timer (0);
        while(!(addr[0] & FLASH_STATUS_DONE)){
-               if (get_timer(start) > CFG_FLASH_ERASE_TOUT) {
+               if (get_timer(start) > CONFIG_SYS_FLASH_ERASE_TOUT) {
                        printf("Flash protect timeout at address %lx\n",  info->start[sector]);
                        addr[0] = FLASH_CMD_RESET;
                        return (1);