]> git.sur5r.net Git - u-boot/blobdiff - drivers/mtd/cfi_flash.c
Fix compile error related to r8a66597-hcd & usb
[u-boot] / drivers / mtd / cfi_flash.c
index c0ea97be70ec2316530d665bb9b76625e9c1cce8..479075ccb19942d406ffa9bea3100c2bf55a711b 100644 (file)
@@ -158,13 +158,13 @@ static uint flash_offset_cfi[2] = { FLASH_OFFSET_CFI, FLASH_OFFSET_CFI_ALT };
 
 /* use CFG_MAX_FLASH_BANKS_DETECT if defined */
 #ifdef CFG_MAX_FLASH_BANKS_DETECT
-static ulong bank_base[CFG_MAX_FLASH_BANKS_DETECT] = CFG_FLASH_BANKS_LIST;
-flash_info_t flash_info[CFG_MAX_FLASH_BANKS_DETECT];   /* FLASH chips info */
+# define CFI_MAX_FLASH_BANKS   CFG_MAX_FLASH_BANKS_DETECT
 #else
-static ulong bank_base[CFG_MAX_FLASH_BANKS] = CFG_FLASH_BANKS_LIST;
-flash_info_t flash_info[CFG_MAX_FLASH_BANKS];          /* FLASH chips info */
+# define CFI_MAX_FLASH_BANKS   CFG_MAX_FLASH_BANKS
 #endif
 
+flash_info_t flash_info[CFI_MAX_FLASH_BANKS];  /* FLASH chips info */
+
 /*
  * Check if chip width is defined. If not, start detecting with 8bit.
  */
@@ -301,11 +301,14 @@ static inline void flash_unmap(flash_info_t *info, flash_sect_t sect,
 /*-----------------------------------------------------------------------
  * make a proper sized command based on the port and chip widths
  */
-static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
+static void flash_make_cmd(flash_info_t *info, u32 cmd, void *cmdbuf)
 {
        int i;
        int cword_offset;
        int cp_offset;
+#if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA)
+       u32 cmd_le = cpu_to_le32(cmd);
+#endif
        uchar val;
        uchar *cp = (uchar *) cmdbuf;
 
@@ -313,12 +316,12 @@ static void flash_make_cmd (flash_info_t * info, ulong cmd, void *cmdbuf)
                cword_offset = (info->portwidth-i)%info->chipwidth;
 #if defined(__LITTLE_ENDIAN) || defined(CFG_WRITE_SWAPPED_DATA)
                cp_offset = info->portwidth - i;
-               val = *((uchar*)&cmd + cword_offset);
+               val = *((uchar*)&cmd_le + cword_offset);
 #else
                cp_offset = i - 1;
-               val = *((uchar*)&cmd + sizeof(ulong) - cword_offset - 1);
+               val = *((uchar*)&cmd + sizeof(u32) - cword_offset - 1);
 #endif
-               cp[cp_offset] = (cword_offset >= sizeof(ulong)) ? 0x00 : val;
+               cp[cp_offset] = (cword_offset >= sizeof(u32)) ? 0x00 : val;
        }
 }
 
@@ -433,7 +436,7 @@ static ulong flash_read_long (flash_info_t * info, flash_sect_t sect,
  * Write a proper sized command to the correct address
  */
 static void flash_write_cmd (flash_info_t * info, flash_sect_t sect,
-                            uint offset, ulong cmd)
+                            uint offset, u32 cmd)
 {
 
        void *addr;
@@ -1909,12 +1912,14 @@ unsigned long flash_init (void)
        char *s = getenv("unlock");
 #endif
 
+#define BANK_BASE(i)   (((unsigned long [CFI_MAX_FLASH_BANKS])CFG_FLASH_BANKS_LIST)[i])
+
        /* Init: no FLASHes known */
        for (i = 0; i < CFG_MAX_FLASH_BANKS; ++i) {
                flash_info[i].flash_id = FLASH_UNKNOWN;
 
-               if (!flash_detect_legacy (bank_base[i], i))
-                       flash_get_size (bank_base[i], i);
+               if (!flash_detect_legacy (BANK_BASE(i), i))
+                       flash_get_size (BANK_BASE(i), i);
                size += flash_info[i].size;
                if (flash_info[i].flash_id == FLASH_UNKNOWN) {
 #ifndef CFG_FLASH_QUIET_TEST