[MTD] Unlocking all Intel flash that is locked on power up.
[deliverable/linux.git] / drivers / mtd / chips / cfi_cmdset_0002.c
index 702ae4cd8691c510e33ecc3892bccd0c16653f61..d072e87ce4e20cec96af6220d8bd903864b8de29 100644 (file)
@@ -48,6 +48,7 @@
 #define MANUFACTURER_ATMEL     0x001F
 #define MANUFACTURER_SST       0x00BF
 #define SST49LF004B            0x0060
+#define SST49LF040B            0x0050
 #define SST49LF008A            0x005a
 #define AT49BV6416             0x00d6
 
@@ -184,6 +185,10 @@ static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param)
                extp->TopBottom = 2;
        else
                extp->TopBottom = 3;
+
+       /* burst write mode not supported */
+       cfi->cfiq->BufWriteTimeoutTyp = 0;
+       cfi->cfiq->BufWriteTimeoutMax = 0;
 }
 
 static void fixup_use_secsi(struct mtd_info *mtd, void *param)
@@ -212,10 +217,11 @@ static void fixup_use_atmel_lock(struct mtd_info *mtd, void *param)
 {
        mtd->lock = cfi_atmel_lock;
        mtd->unlock = cfi_atmel_unlock;
-       mtd->flags |= MTD_STUPID_LOCK;
+       mtd->flags |= MTD_POWERUP_LOCK;
 }
 
 static struct cfi_fixup cfi_fixup_table[] = {
+       { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
 #ifdef AMD_BOOTLOC_BUG
        { CFI_MFR_AMD, CFI_ID_ANY, fixup_amd_bootblock, NULL },
 #endif
@@ -228,11 +234,11 @@ static struct cfi_fixup cfi_fixup_table[] = {
 #if !FORCE_WORD_WRITE
        { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
 #endif
-       { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
        { 0, 0, NULL, NULL }
 };
 static struct cfi_fixup jedec_fixup_table[] = {
        { MANUFACTURER_SST, SST49LF004B, fixup_use_fwh_lock, NULL, },
+       { MANUFACTURER_SST, SST49LF040B, fixup_use_fwh_lock, NULL, },
        { MANUFACTURER_SST, SST49LF008A, fixup_use_fwh_lock, NULL, },
        { 0, 0, NULL, NULL }
 };
@@ -255,12 +261,11 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
        struct mtd_info *mtd;
        int i;
 
-       mtd = kmalloc(sizeof(*mtd), GFP_KERNEL);
+       mtd = kzalloc(sizeof(*mtd), GFP_KERNEL);
        if (!mtd) {
                printk(KERN_WARNING "Failed to allocate memory for MTD device\n");
                return NULL;
        }
-       memset(mtd, 0, sizeof(*mtd));
        mtd->priv = map;
        mtd->type = MTD_NORFLASH;
 
@@ -337,10 +342,12 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
                /* Modify the unlock address if we are in compatibility mode */
                if (    /* x16 in x8 mode */
                        ((cfi->device_type == CFI_DEVICETYPE_X8) &&
-                               (cfi->cfiq->InterfaceDesc == 2)) ||
+                               (cfi->cfiq->InterfaceDesc ==
+                                       CFI_INTERFACE_X8_BY_X16_ASYNC)) ||
                        /* x32 in x16 mode */
                        ((cfi->device_type == CFI_DEVICETYPE_X16) &&
-                               (cfi->cfiq->InterfaceDesc == 4)))
+                               (cfi->cfiq->InterfaceDesc ==
+                                       CFI_INTERFACE_X16_BY_X32_ASYNC)))
                {
                        cfi->addr_unlock1 = 0xaaa;
                        cfi->addr_unlock2 = 0x555;
@@ -358,6 +365,8 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
                cfi->chips[i].word_write_time = 1<<cfi->cfiq->WordWriteTimeoutTyp;
                cfi->chips[i].buffer_write_time = 1<<cfi->cfiq->BufWriteTimeoutTyp;
                cfi->chips[i].erase_time = 1<<cfi->cfiq->BlockEraseTimeoutTyp;
+               cfi->chips[i].ref_point_counter = 0;
+               init_waitqueue_head(&(cfi->chips[i].wq));
        }
 
        map->fldrv = &cfi_amdstd_chipdrv;
@@ -519,10 +528,12 @@ static int get_chip(struct map_info *map, struct flchip *chip, unsigned long adr
                if (mode == FL_WRITING) /* FIXME: Erase-suspend-program appears broken. */
                        goto sleep;
 
-               if (!(mode == FL_READY || mode == FL_POINT
+               if (!(   mode == FL_READY
+                     || mode == FL_POINT
                      || !cfip
                      || (mode == FL_WRITING && (cfip->EraseSuspend & 0x2))
-                     || (mode == FL_WRITING && (cfip->EraseSuspend & 0x1))))
+                     || (mode == FL_WRITING && (cfip->EraseSuspend & 0x1)
+                   )))
                        goto sleep;
 
                /* We could check to see if we're trying to access the sector
@@ -1604,7 +1615,7 @@ static int __xipram do_erase_oneblock(struct map_info *map, struct flchip *chip,
 }
 
 
-int cfi_amdstd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
+static int cfi_amdstd_erase_varsize(struct mtd_info *mtd, struct erase_info *instr)
 {
        unsigned long ofs, len;
        int ret;
This page took 0.028937 seconds and 5 git commands to generate.