[PATCH] mtd: spinand: heyangtek: add support for HYF4GQ4UAACBE
Lin Quanji
linquanji at heyangtek.com
Wed Nov 18 01:23:48 PST 2026
Add the 4 Gbit member of the HeYangTek SPI-NAND family. The die has
4096-byte pages and a 256-byte spare area, and uses eight 512-byte ECC
steps with 14-bit correction, i.e. 24 bytes of on-die parity per step
and 192 bytes in total.
The spare area is therefore laid out in eight 32-byte groups, one per
ECC step: bytes 0..7 are exposed as free and bytes 8..31 hold the
parity. This is not the "first half free, second half parity" layout
used by the GigaDevice 256-byte-OOB parts, which carry 8-bit ECC and
consequently only need 128 bytes of parity.
The ECC status register uses the same 2-bit encoding as HYF1GQ4UDACAE,
so the existing hyf1gq4_ecc_get_status() is reused unchanged.
Datasheet: https://www.heyangtek.cn/h-pd-31.html
Signed-off-by: Lin Quanji <linquanji at heyangtek.com>
---
drivers/mtd/nand/spi/heyangtek.c | 52 ++++++++++++++++++++++++++++++++
1 file changed, 52 insertions(+)
diff --git a/drivers/mtd/nand/spi/heyangtek.c b/drivers/mtd/nand/spi/heyangtek.c
index 76d97ae..fa69ea8 100644
--- a/drivers/mtd/nand/spi/heyangtek.c
+++ b/drivers/mtd/nand/spi/heyangtek.c
@@ -73,6 +73,48 @@ static const struct mtd_ooblayout_ops hyf1gq4_ooblayout = {
.free = hyf1gq4_ooblayout_free,
};
+/*
+ * HYF4GQ4UAACBE: 4 KB page, 256-byte spare area. The die uses eight
+ * 512-byte ECC steps, each owning one 32-byte group of the spare area:
+ * bytes 0..7 are exposed as free and bytes 8..31 hold the on-die parity
+ * (24 bytes, i.e. 14 bit / 512 B). 8 x 32 = 256 bytes, of which 192 are
+ * parity.
+ */
+static int hyf4gq4_ooblayout_ecc(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *region)
+{
+ if (section > 7)
+ return -ERANGE;
+
+ region->offset = (32 * section) + 8;
+ region->length = 24;
+
+ return 0;
+}
+
+static int hyf4gq4_ooblayout_free(struct mtd_info *mtd, int section,
+ struct mtd_oob_region *region)
+{
+ if (section > 7)
+ return -ERANGE;
+
+ if (section) {
+ region->offset = 32 * section;
+ region->length = 8;
+ } else {
+ /* section 0 has two bytes reserved for the bad block marker */
+ region->offset = 2;
+ region->length = 6;
+ }
+
+ return 0;
+}
+
+static const struct mtd_ooblayout_ops hyf4gq4_ooblayout = {
+ .ecc = hyf4gq4_ooblayout_ecc,
+ .free = hyf4gq4_ooblayout_free,
+};
+
static int hyf1gq4_ecc_get_status(struct spinand_device *spinand, u8 status)
{
struct nand_device *nand = spinand_to_nand(spinand);
@@ -118,6 +160,16 @@ static const struct spinand_info heyangtek_spinand_table[] = {
SPINAND_HAS_QE_BIT,
SPINAND_ECCINFO(&hyf1gq4_ooblayout,
hyf1gq4_ecc_get_status)),
+ SPINAND_INFO("HYF4GQ4UAACBE",
+ SPINAND_ID(SPINAND_READID_METHOD_OPCODE_ADDR, 0xd4),
+ NAND_MEMORG(1, 4096, 256, 64, 2048, 40, 1, 1, 1),
+ NAND_ECCREQ(14, 512),
+ SPINAND_INFO_OP_VARIANTS(&read_cache_variants,
+ &write_cache_variants,
+ &update_cache_variants),
+ SPINAND_HAS_QE_BIT,
+ SPINAND_ECCINFO(&hyf4gq4_ooblayout,
+ hyf1gq4_ecc_get_status)),
};
static const struct spinand_manufacturer_ops heyangtek_spinand_manuf_ops = {
--
2.55.0.windows.3
More information about the linux-mtd
mailing list