Skip to contentSkip to conversation

Flash CFI detection code.

U-Boot-Users Kári Davíðsson 1 participant 1 message May 13, 2008

lore
Share & tools
lore
#0 lore raw

Hi,

We have an flash (CFI) connected through an 8 bit bus.

What happens is that the call to cmdset_amd_init() is called with portwidth set to 2 resulting in flash_info_t::manufacturer_id equal to 0 and also flash_info_t::device_id is set to 0. This is because the commandpatterns are wrong for 8 bit devices.

Later on in the flash_get_size() function the portwidth is set to 1 as it should be (around line 1807).

After that the cmdset_amd_init() can be called and the manufacturer_id and device_id are set correctly....

Maybe this does not make sense but the patch below allows me to read the manufacturer_id and device_id correctly. If this is applicable in general for all boards I have no idea.

The patch is against u-boot-1.3.2.

rg
kd

mtd/cfi_flash.c (working copy) renamed from mtd/cfi_flash.c (revision 283) +1 -3
Index: drivers/mtd/cfi_flash.c
===================================================================
@@ -102,9 +102,9 @@
 #define AMD_STATUS_ERROR               0x20
 
 #define FLASH_OFFSET_MANUFACTURER_ID   0x00
-#define FLASH_OFFSET_DEVICE_ID         0x01
-#define FLASH_OFFSET_DEVICE_ID2                0x0E
-#define FLASH_OFFSET_DEVICE_ID3                0x0F
+#define FLASH_OFFSET_DEVICE_ID         ((info->portwidth ==

FLASH_CFI_8BIT) ? 0x02 : 0x01)
+#define FLASH_OFFSET_DEVICE_ID2 ((info->portwidth ==
FLASH_CFI_8BIT) ? 0x1C : 0x0E)
+#define FLASH_OFFSET_DEVICE_ID3 ((info->portwidth ==
FLASH_CFI_8BIT) ? 0x1E : 0x0F)

 #define FLASH_OFFSET_CFI               0x55
 #define FLASH_OFFSET_CFI_ALT           0x555
 #define FLASH_OFFSET_CFI_RESP          0x10
@@ -1695,11 +1695,8 @@
                switch (info->vendor) {
                case CFI_CMDSET_INTEL_STANDARD:
                case CFI_CMDSET_INTEL_EXTENDED:

- cmdset_intel_init(info, &qry);
- break;
case CFI_CMDSET_AMD_STANDARD:
case CFI_CMDSET_AMD_EXTENDED:

-                       cmdset_amd_init(info, &qry);
                        break;
                default:
                        printf("CFI: Unknown command set 0x%x\n",
@@ -1811,6 +1808,17 @@
                }
        }
+       switch (info->vendor) {
+       case CFI_CMDSET_INTEL_STANDARD:
+       case CFI_CMDSET_INTEL_EXTENDED:

+ cmdset_intel_init(info, &qry);
+ break;
+ case CFI_CMDSET_AMD_STANDARD:
+ case CFI_CMDSET_AMD_EXTENDED:
+ cmdset_amd_init(info, &qry);
+ break;
+ }
+

        flash_write_cmd (info, 0, 0, info->cmd_reset);
        return (info->size);

}