1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (C) 2017 Free Electrons
4 * Copyright (C) 2017 NextThing Co
6 * Author: Boris Brezillon <boris.brezillon@free-electrons.com>
11 static void amd_nand_decode_id(struct nand_chip
*chip
)
13 struct mtd_info
*mtd
= nand_to_mtd(chip
);
14 struct nand_memory_organization
*memorg
;
16 memorg
= nanddev_get_memorg(&chip
->base
);
18 nand_decode_ext_id(chip
);
21 * Check for Spansion/AMD ID + repeating 5th, 6th byte since
22 * some Spansion chips have erasesize that conflicts with size
23 * listed in nand_ids table.
24 * Data sheet (5 byte ID): Spansion S30ML-P ORNAND (p.39)
26 if (chip
->id
.data
[4] != 0x00 && chip
->id
.data
[5] == 0x00 &&
27 chip
->id
.data
[6] == 0x00 && chip
->id
.data
[7] == 0x00 &&
28 memorg
->pagesize
== 512) {
29 memorg
->pages_per_eraseblock
= 256;
30 memorg
->pages_per_eraseblock
<<= ((chip
->id
.data
[3] & 0x03) << 1);
31 mtd
->erasesize
= memorg
->pages_per_eraseblock
*
36 static int amd_nand_init(struct nand_chip
*chip
)
38 if (nand_is_slc(chip
))
40 * According to the datasheet of some Cypress SLC NANDs,
41 * the bad block markers can be in the first, second or last
42 * page of a block. So let's check all three locations.
44 chip
->options
|= NAND_BBM_FIRSTPAGE
| NAND_BBM_SECONDPAGE
|
50 const struct nand_manufacturer_ops amd_nand_manuf_ops
= {
51 .detect
= amd_nand_decode_id
,
52 .init
= amd_nand_init
,