aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/mtd/chips/cfi_cmdset_0002.c21
-rw-r--r--include/linux/mtd/cfi.h13
2 files changed, 34 insertions, 0 deletions
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c
index 9885726a16e4..8901c4412daf 100644
--- a/drivers/mtd/chips/cfi_cmdset_0002.c
+++ b/drivers/mtd/chips/cfi_cmdset_0002.c
@@ -161,6 +161,26 @@ static void fixup_use_write_buffers(struct mtd_info *mtd, void *param)
161 } 161 }
162} 162}
163 163
164/* Atmel chips don't use the same PRI format as AMD chips */
165static void fixup_convert_atmel_pri(struct mtd_info *mtd, void *param)
166{
167 struct map_info *map = mtd->priv;
168 struct cfi_private *cfi = map->fldrv_priv;
169 struct cfi_pri_amdstd *extp = cfi->cmdset_priv;
170 struct cfi_pri_atmel atmel_pri;
171
172 memcpy(&atmel_pri, extp, sizeof(atmel_pri));
173 memset(extp + 5, 0, sizeof(*extp) - 5);
174
175 if (atmel_pri.Features & 0x02)
176 extp->EraseSuspend = 2;
177
178 if (atmel_pri.BottomBoot)
179 extp->TopBottom = 2;
180 else
181 extp->TopBottom = 3;
182}
183
164static void fixup_use_secsi(struct mtd_info *mtd, void *param) 184static void fixup_use_secsi(struct mtd_info *mtd, void *param)
165{ 185{
166 /* Setup for chips with a secsi area */ 186 /* Setup for chips with a secsi area */
@@ -192,6 +212,7 @@ static struct cfi_fixup cfi_fixup_table[] = {
192#if !FORCE_WORD_WRITE 212#if !FORCE_WORD_WRITE
193 { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, }, 213 { CFI_MFR_ANY, CFI_ID_ANY, fixup_use_write_buffers, NULL, },
194#endif 214#endif
215 { CFI_MFR_ATMEL, CFI_ID_ANY, fixup_convert_atmel_pri, NULL },
195 { 0, 0, NULL, NULL } 216 { 0, 0, NULL, NULL }
196}; 217};
197static struct cfi_fixup jedec_fixup_table[] = { 218static struct cfi_fixup jedec_fixup_table[] = {
diff --git a/include/linux/mtd/cfi.h b/include/linux/mtd/cfi.h
index 09bfae6938b3..123948b14547 100644
--- a/include/linux/mtd/cfi.h
+++ b/include/linux/mtd/cfi.h
@@ -199,6 +199,18 @@ struct cfi_pri_amdstd {
199 uint8_t TopBottom; 199 uint8_t TopBottom;
200} __attribute__((packed)); 200} __attribute__((packed));
201 201
202/* Vendor-Specific PRI for Atmel chips (command set 0x0002) */
203
204struct cfi_pri_atmel {
205 uint8_t pri[3];
206 uint8_t MajorVersion;
207 uint8_t MinorVersion;
208 uint8_t Features;
209 uint8_t BottomBoot;
210 uint8_t BurstMode;
211 uint8_t PageMode;
212} __attribute__((packed));
213
202struct cfi_pri_query { 214struct cfi_pri_query {
203 uint8_t NumFields; 215 uint8_t NumFields;
204 uint32_t ProtField[1]; /* Not host ordered */ 216 uint32_t ProtField[1]; /* Not host ordered */
@@ -464,6 +476,7 @@ struct cfi_fixup {
464#define CFI_ID_ANY 0xffff 476#define CFI_ID_ANY 0xffff
465 477
466#define CFI_MFR_AMD 0x0001 478#define CFI_MFR_AMD 0x0001
479#define CFI_MFR_ATMEL 0x001F
467#define CFI_MFR_ST 0x0020 /* STMicroelectronics */ 480#define CFI_MFR_ST 0x0020 /* STMicroelectronics */
468 481
469void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups); 482void cfi_fixup(struct mtd_info *mtd, struct cfi_fixup* fixups);