1 --- a/drivers/mtd/nand/spi/Makefile
2 +++ b/drivers/mtd/nand/spi/Makefile
4 # SPDX-License-Identifier: GPL-2.0
5 -spinand-objs := core.o esmt.o gigadevice.o macronix.o micron.o paragon.o toshiba.o winbond.o xtx.o
6 +spinand-objs := core.o esmt.o etron.o gigadevice.o macronix.o micron.o paragon.o toshiba.o winbond.o xtx.o
7 obj-$(CONFIG_MTD_SPI_NAND) += spinand.o
8 --- a/drivers/mtd/nand/spi/core.c
9 +++ b/drivers/mtd/nand/spi/core.c
10 @@ -898,6 +898,7 @@ static const struct nand_ops spinand_ops
11 static const struct spinand_manufacturer *spinand_manufacturers[] = {
12 &esmt_c8_spinand_manufacturer,
13 &gigadevice_spinand_manufacturer,
14 + &etron_spinand_manufacturer,
15 ¯onix_spinand_manufacturer,
16 µn_spinand_manufacturer,
17 ¶gon_spinand_manufacturer,
19 +++ b/drivers/mtd/nand/spi/etron.c
21 +// SPDX-License-Identifier: GPL-2.0
23 +#include <linux/device.h>
24 +#include <linux/kernel.h>
25 +#include <linux/mtd/spinand.h>
27 +#define SPINAND_MFR_ETRON 0xd5
30 +static SPINAND_OP_VARIANTS(read_cache_variants,
31 + SPINAND_PAGE_READ_FROM_CACHE_QUADIO_OP(0, 1, NULL, 0),
32 + SPINAND_PAGE_READ_FROM_CACHE_X4_OP(0, 1, NULL, 0),
33 + SPINAND_PAGE_READ_FROM_CACHE_DUALIO_OP(0, 1, NULL, 0),
34 + SPINAND_PAGE_READ_FROM_CACHE_X2_OP(0, 1, NULL, 0),
35 + SPINAND_PAGE_READ_FROM_CACHE_OP(true, 0, 1, NULL, 0),
36 + SPINAND_PAGE_READ_FROM_CACHE_OP(false, 0, 1, NULL, 0));
38 +static SPINAND_OP_VARIANTS(write_cache_variants,
39 + SPINAND_PROG_LOAD_X4(true, 0, NULL, 0),
40 + SPINAND_PROG_LOAD(true, 0, NULL, 0));
42 +static SPINAND_OP_VARIANTS(update_cache_variants,
43 + SPINAND_PROG_LOAD_X4(false, 0, NULL, 0),
44 + SPINAND_PROG_LOAD(false, 0, NULL, 0));
46 +static int etron_ooblayout_ecc(struct mtd_info *mtd, int section,
47 + struct mtd_oob_region *oobregion)
52 + oobregion->offset = 72;
53 + oobregion->length = 56;
58 +static int etron_ooblayout_free(struct mtd_info *mtd, int section,
59 + struct mtd_oob_region *oobregion)
64 + oobregion->offset = 1;
65 + oobregion->length = 71;
70 +static int etron_ecc_get_status(struct spinand_device *spinand, u8 status)
72 + switch (status & STATUS_ECC_MASK) {
73 + case STATUS_ECC_NO_BITFLIPS:
76 + case STATUS_ECC_HAS_BITFLIPS:
77 + /* Between 1-7 bitflips were corrected */
80 + case STATUS_ECC_MASK:
81 + /* Maximum bitflips were corrected */
84 + case STATUS_ECC_UNCOR_ERROR:
91 +static const struct mtd_ooblayout_ops etron_ooblayout = {
92 + .ecc = etron_ooblayout_ecc,
93 + .free = etron_ooblayout_free,
96 +static const struct spinand_info etron_spinand_table[] = {
97 + SPINAND_INFO("EM73D044VCx",
98 + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0x1f),
99 + // bpc, pagesize, oobsize, pagesperblock, bperlun, maxbadplun, ppl, lpt, #t
100 + NAND_MEMORG(1, 2048, 128, 64, 2048, 40, 1, 1, 1),
101 + NAND_ECCREQ(8, 512),
102 + SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
103 + &write_cache_variants,
104 + &update_cache_variants),
105 + SPINAND_HAS_QE_BIT,
106 + SPINAND_ECCINFO(&etron_ooblayout, etron_ecc_get_status)),
109 +static const struct spinand_manufacturer_ops etron_spinand_manuf_ops = {
112 +const struct spinand_manufacturer etron_spinand_manufacturer = {
113 + .id = SPINAND_MFR_ETRON,
115 + .chips = etron_spinand_table,
116 + .nchips = ARRAY_SIZE(etron_spinand_table),
117 + .ops = &etron_spinand_manuf_ops,
119 --- a/include/linux/mtd/spinand.h
120 +++ b/include/linux/mtd/spinand.h
121 @@ -261,6 +261,7 @@ struct spinand_manufacturer {
123 /* SPI NAND manufacturers */
124 extern const struct spinand_manufacturer esmt_c8_spinand_manufacturer;
125 +extern const struct spinand_manufacturer etron_spinand_manufacturer;
126 extern const struct spinand_manufacturer gigadevice_spinand_manufacturer;
127 extern const struct spinand_manufacturer macronix_spinand_manufacturer;
128 extern const struct spinand_manufacturer micron_spinand_manufacturer;