Skip to content

Commit b6603fe

Browse files
committed
Merge tag 'for-linus-20140716' of git://git.infradead.org/linux-mtd
Pull MTD fixes from Brian Norris: - Fix ELM suspend/resume - Reduce warnings if NAND ECC is too weak - Add CFI support for Sharp LH28F640BF NOR The last fix is coming in because other commits in the 3.16 cycle depended on this support. * tag 'for-linus-20140716' of git://git.infradead.org/linux-mtd: mtd: cfi_cmdset_0001.c: add support for Sharp LH28F640BF NOR mtd: nand: reduce the warning noise when the ECC is too weak mtd: devices: elm: fix elm_context_save() and elm_context_restore() functions
2 parents bcf44bf + 812c5fa commit b6603fe

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

drivers/mtd/chips/cfi_cmdset_0001.c

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,11 @@
5252
/* Atmel chips */
5353
#define AT49BV640D 0x02de
5454
#define AT49BV640DT 0x02db
55+
/* Sharp chips */
56+
#define LH28F640BFHE_PTTL90 0x00b0
57+
#define LH28F640BFHE_PBTL90 0x00b1
58+
#define LH28F640BFHE_PTTL70A 0x00b2
59+
#define LH28F640BFHE_PBTL70A 0x00b3
5560

5661
static int cfi_intelext_read (struct mtd_info *, loff_t, size_t, size_t *, u_char *);
5762
static int cfi_intelext_write_words(struct mtd_info *, loff_t, size_t, size_t *, const u_char *);
@@ -258,6 +263,36 @@ static void fixup_st_m28w320cb(struct mtd_info *mtd)
258263
(cfi->cfiq->EraseRegionInfo[1] & 0xffff0000) | 0x3e;
259264
};
260265

266+
static int is_LH28F640BF(struct cfi_private *cfi)
267+
{
268+
/* Sharp LH28F640BF Family */
269+
if (cfi->mfr == CFI_MFR_SHARP && (
270+
cfi->id == LH28F640BFHE_PTTL90 || cfi->id == LH28F640BFHE_PBTL90 ||
271+
cfi->id == LH28F640BFHE_PTTL70A || cfi->id == LH28F640BFHE_PBTL70A))
272+
return 1;
273+
return 0;
274+
}
275+
276+
static void fixup_LH28F640BF(struct mtd_info *mtd)
277+
{
278+
struct map_info *map = mtd->priv;
279+
struct cfi_private *cfi = map->fldrv_priv;
280+
struct cfi_pri_intelext *extp = cfi->cmdset_priv;
281+
282+
/* Reset the Partition Configuration Register on LH28F640BF
283+
* to a single partition (PCR = 0x000): PCR is embedded into A0-A15. */
284+
if (is_LH28F640BF(cfi)) {
285+
printk(KERN_INFO "Reset Partition Config. Register: 1 Partition of 4 planes\n");
286+
map_write(map, CMD(0x60), 0);
287+
map_write(map, CMD(0x04), 0);
288+
289+
/* We have set one single partition thus
290+
* Simultaneous Operations are not allowed */
291+
printk(KERN_INFO "cfi_cmdset_0001: Simultaneous Operations disabled\n");
292+
extp->FeatureSupport &= ~512;
293+
}
294+
}
295+
261296
static void fixup_use_point(struct mtd_info *mtd)
262297
{
263298
struct map_info *map = mtd->priv;
@@ -309,6 +344,8 @@ static struct cfi_fixup cfi_fixup_table[] = {
309344
{ CFI_MFR_ST, 0x00ba, /* M28W320CT */ fixup_st_m28w320ct },
310345
{ CFI_MFR_ST, 0x00bb, /* M28W320CB */ fixup_st_m28w320cb },
311346
{ CFI_MFR_INTEL, CFI_ID_ANY, fixup_unlock_powerup_lock },
347+
{ CFI_MFR_SHARP, CFI_ID_ANY, fixup_unlock_powerup_lock },
348+
{ CFI_MFR_SHARP, CFI_ID_ANY, fixup_LH28F640BF },
312349
{ 0, 0, NULL }
313350
};
314351

@@ -1649,6 +1686,12 @@ static int __xipram do_write_buffer(struct map_info *map, struct flchip *chip,
16491686
initial_adr = adr;
16501687
cmd_adr = adr & ~(wbufsize-1);
16511688

1689+
/* Sharp LH28F640BF chips need the first address for the
1690+
* Page Buffer Program command. See Table 5 of
1691+
* LH28F320BF, LH28F640BF, LH28F128BF Series (Appendix FUM00701) */
1692+
if (is_LH28F640BF(cfi))
1693+
cmd_adr = adr;
1694+
16521695
/* Let's determine this according to the interleave only once */
16531696
write_cmd = (cfi->cfiq->P_ID != P_ID_INTEL_PERFORMANCE) ? CMD(0xe8) : CMD(0xe9);
16541697

drivers/mtd/devices/elm.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -475,6 +475,7 @@ static int elm_context_save(struct elm_info *info)
475475
ELM_SYNDROME_FRAGMENT_1 + offset);
476476
regs->elm_syndrome_fragment_0[i] = elm_read_reg(info,
477477
ELM_SYNDROME_FRAGMENT_0 + offset);
478+
break;
478479
default:
479480
return -EINVAL;
480481
}
@@ -520,6 +521,7 @@ static int elm_context_restore(struct elm_info *info)
520521
regs->elm_syndrome_fragment_1[i]);
521522
elm_write_reg(info, ELM_SYNDROME_FRAGMENT_0 + offset,
522523
regs->elm_syndrome_fragment_0[i]);
524+
break;
523525
default:
524526
return -EINVAL;
525527
}

drivers/mtd/nand/nand_base.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4047,8 +4047,10 @@ int nand_scan_tail(struct mtd_info *mtd)
40474047
ecc->layout->oobavail += ecc->layout->oobfree[i].length;
40484048
mtd->oobavail = ecc->layout->oobavail;
40494049

4050-
/* ECC sanity check: warn noisily if it's too weak */
4051-
WARN_ON(!nand_ecc_strength_good(mtd));
4050+
/* ECC sanity check: warn if it's too weak */
4051+
if (!nand_ecc_strength_good(mtd))
4052+
pr_warn("WARNING: %s: the ECC used on your system is too weak compared to the one required by the NAND chip\n",
4053+
mtd->name);
40524054

40534055
/*
40544056
* Set the number of read / write steps for one page depending on ECC

0 commit comments

Comments
 (0)