MTD: Convert Atmel PRI information to AMD format
[deliverable/linux.git] / drivers / mtd / chips / cfi_cmdset_0002.c
index 3aeb0c79e714fe454ae6006a13b9625c67b24c19..8901c4412daf173c21406e076ed2713d1e433e89 100644 (file)
@@ -21,7 +21,6 @@
  *
  */
 
-#include <linux/config.h>
 #include <linux/module.h>
 #include <linux/types.h>
 #include <linux/kernel.h>
@@ -162,6 +161,26 @@ static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
        }
 }
 
+/* Atmel chips don't use the same PRI format as AMD chips */
+static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param)
+{
+       struct map_info *map = mtd->priv;
+       struct cfi_private *cfi = map->fldrv_priv;
+       struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
+       struct cfi_pri_atmel atmel_pri;
+
+       memcpy(&atmel_pri, extp, sizeof(atmel_pri));
+       memset(extp + 5, 0, sizeof(*extp) - 5);
+
+       if (atmel_pri.Features & 0x02)
+               extp->EraseSuspend = 2;
+
+       if (atmel_pri.BottomBoot)
+               extp->TopBottom = 2;
+       else
+               extp->TopBottom = 3;
+}
+
 static void fixup_use_secsi(struct mtd_info *mtd, void *param)
 {
        /* Setup for chips with a secsi area */
@@ -193,6 +212,7 @@ 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[] = {
@@ -236,6 +256,7 @@ struct mtd_info *cfi_cmdset_0002(struct map_info *map, int primary)
        mtd->resume  = cfi_amdstd_resume;
        mtd->flags   = MTD_CAP_NORFLASH;
        mtd->name    = map->name;
+       mtd->writesize = 1;
 
        if (cfi->cfi_mode==CFI_MODE_CFI){
                unsigned char bootloc;
This page took 0.096951 seconds and 5 git commands to generate.