]> git.sur5r.net Git - openocd/blobdiff - src/flash/nor/non_cfi.c
add support for spansion flash on mindspeed c300 eval board
[openocd] / src / flash / nor / non_cfi.c
index b49e4415062ba9e2476d313f401bf3c0ded19486..9c516c257bfacbe90d4d1b4bb00be7d864de2a25 100644 (file)
@@ -90,6 +90,20 @@ static struct non_cfi non_cfi_flashes[] = {
                        ERASE_REGION(128, 4*KB)
                }
        },
+       {
+               .mfr = CFI_MFR_AMD,             /* Spansion AM29LV040B */
+               .id = 0x4f,
+               .pri_id = 0x02,
+               .dev_size = 512*KB,
+               .interface_desc = 0x0,          /* x8 only device */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
+               .num_erase_regions = 1,
+               .erase_region_info =
+               {
+                       ERASE_REGION(8, 64*KB)
+               }
+       },
        {
                .mfr = CFI_MFR_SST,
                .id = 0x2780,
@@ -230,6 +244,20 @@ static struct non_cfi non_cfi_flashes[] = {
                }
        },
        {
+       .mfr = CFI_MFR_SST,
+           .id = 0x236d,               /* SST39VF6401B */
+           .pri_id = 0x02,
+           .dev_size = 8*MB,
+           .interface_desc = 0x2,      /* x8 or x16 device with nBYTE */
+           .max_buf_write_size = 0x0,
+           .status_poll_mask = CFI_STATUS_POLL_MASK_DQ6_DQ7,
+           .num_erase_regions = 1,
+           .erase_region_info =
+           {
+               ERASE_REGION(2048, 4*KB)
+           }
+       },
+       {
                .mfr = CFI_MFR_AMD,
                .id = 0x22ab,                           /* AM29F400BB */
                .pri_id = 0x02,
@@ -280,6 +308,23 @@ static struct non_cfi non_cfi_flashes[] = {
                        ERASE_REGION(15, 64*KB)
                }
        },
+   {
+               .mfr = CFI_MFR_FUJITSU,
+               .id = 0x22ea,                           /* MBM29SL800TE */
+               .pri_id = 0x02,
+               .dev_size = 1*MB,
+               .interface_desc = 0x2,          /* x8 or x16 device with nBYTE */
+               .max_buf_write_size = 0x0,
+               .status_poll_mask = CFI_STATUS_POLL_MASK_DQ5_DQ6_DQ7,
+               .num_erase_regions = 4,
+               .erase_region_info =
+               {
+                       ERASE_REGION(15, 64*KB),
+                       ERASE_REGION(1,  32*KB),
+                       ERASE_REGION(2,  8*KB),
+                       ERASE_REGION(1,  16*KB)
+               }
+       },
        {
                .mfr = CFI_MFR_FUJITSU,
                .id = 0xba,                             /* 29LV400BC */
@@ -423,13 +468,19 @@ static struct non_cfi non_cfi_flashes[] = {
 
 void cfi_fixup_non_cfi(struct flash_bank *bank)
 {
+       unsigned int mask;
        struct cfi_flash_bank *cfi_info = bank->driver_priv;
        struct non_cfi *non_cfi = non_cfi_flashes;
 
+       if(cfi_info->x16_as_x8)
+               mask = 0xFF;
+       else
+               mask = 0xFFFF;
+
        for (non_cfi = non_cfi_flashes; non_cfi->mfr; non_cfi++)
        {
                if ((cfi_info->manufacturer == non_cfi->mfr)
-                       && (cfi_info->device_id == non_cfi->id))
+                       && (cfi_info->device_id == (non_cfi->id & mask)))
                {
                        break;
                }
@@ -446,10 +497,12 @@ void cfi_fixup_non_cfi(struct flash_bank *bank)
        cfi_info->vcc_max = 0x0;
        cfi_info->vpp_min = 0x0;
        cfi_info->vpp_max = 0x0;
-       cfi_info->word_write_timeout_typ = 0x0;
-       cfi_info->buf_write_timeout_typ = 0x0;
-       cfi_info->block_erase_timeout_typ = 0x0;
-       cfi_info->chip_erase_timeout_typ = 0x0;
+       /* these are used for timeouts - use vales that should be long enough
+          for normal operation. */
+       cfi_info->word_write_timeout_typ = 0x0a;
+       cfi_info->buf_write_timeout_typ = 0x0d;
+       cfi_info->block_erase_timeout_typ = 0x0d;
+       cfi_info->chip_erase_timeout_typ = 0x10;
        cfi_info->word_write_timeout_max = 0x0;
        cfi_info->buf_write_timeout_max = 0x0;
        cfi_info->block_erase_timeout_max = 0x0;
@@ -469,7 +522,11 @@ void cfi_fixup_non_cfi(struct flash_bank *bank)
        cfi_info->max_buf_write_size = non_cfi->max_buf_write_size;
        cfi_info->status_poll_mask = non_cfi->status_poll_mask;
        cfi_info->num_erase_regions = non_cfi->num_erase_regions;
-       cfi_info->erase_region_info = non_cfi->erase_region_info;
+       size_t erase_region_info_size = sizeof(*cfi_info->erase_region_info) *
+                       cfi_info->num_erase_regions;
+       cfi_info->erase_region_info = malloc(erase_region_info_size);
+       memcpy(cfi_info->erase_region_info,
+                       non_cfi->erase_region_info, erase_region_info_size);
        cfi_info->dev_size = non_cfi->dev_size;
 
        if (cfi_info->pri_id == 0x2)