]> git.sur5r.net Git - u-boot/commitdiff
CFI: synchronize command offsets with Linux CFI driver
authorBartlomiej Sieka <tur@semihalf.com>
Tue, 11 Dec 2007 12:59:57 +0000 (13:59 +0100)
committerStefan Roese <sr@denx.de>
Thu, 13 Dec 2007 11:00:37 +0000 (12:00 +0100)
Fixes non-working CFI Flash on the Inka4x0 board.

Signed-off-by: Bartlomiej Sieka <tur@semihalf.com>
drivers/mtd/cfi_flash.c
include/flash.h

index 66754cd58c463ac592f69eba430dff21ccd759eb..c3293d0efacb4723969cb08ce257dd87edc77d41 100644 (file)
@@ -1231,9 +1231,26 @@ static int flash_detect_cfi (flash_info_t * info)
                                        debug ("port %d bits chip %d bits\n",
                                                info->portwidth << CFI_FLASH_SHIFT_WIDTH,
                                                info->chipwidth << CFI_FLASH_SHIFT_WIDTH);
-                                       /* this probably only works if info->interface == FLASH_CFI_X8X16 */
-                                       info->addr_unlock1 = (info->portwidth == FLASH_CFI_8BIT) ? 0xAAA : 0x555;
-                                       info->addr_unlock2 = (info->portwidth == FLASH_CFI_8BIT) ? 0x555 : 0x2AA;
+
+                                       /* calculate command offsets as in the Linux driver */
+                                       info->addr_unlock1 = 0x555;
+                                       info->addr_unlock2 = 0x2aa;
+
+                                       /*
+                                        * modify the unlock address if we are
+                                        * in compatibility mode
+                                        */
+                                       if (    /* x8/x16 in x8 mode */
+                                               ((info->chipwidth == FLASH_CFI_BY8) &&
+                                                       (info->interface == FLASH_CFI_X8X16)) ||
+                                               /* x16/x32 in x16 mode */
+                                               ((info->chipwidth == FLASH_CFI_BY16) &&
+                                                       (info->interface == FLASH_CFI_X16X32)))
+                                       {
+                                               info->addr_unlock1 = 0xaaa;
+                                               info->addr_unlock2 = 0x555;
+                                       }
+
                                        info->name = "CFI conformant";
                                        return 1;
                                }
index 6e252ccad8bd24f327db46bcb1c0175104675638..2ed1e20fd22be96a45932eb3d34cb2eba6d26a0c 100644 (file)
@@ -80,6 +80,7 @@ typedef struct {
 #define FLASH_CFI_X8           0x00
 #define FLASH_CFI_X16          0x01
 #define FLASH_CFI_X8X16                0x02
+#define FLASH_CFI_X16X32       0x05
 
 /* convert between bit value and numeric value */
 #define CFI_FLASH_SHIFT_WIDTH  3