From nobody Sat Feb 7 09:25:13 2026 Received: from mail-pl1-f180.google.com (mail-pl1-f180.google.com [209.85.214.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 68CDEDF76 for ; Tue, 9 Dec 2025 07:16:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.180 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765264594; cv=none; b=VyJ/b0tjX2Arc8bSwMIJmXODJQicwOhHN7ofOe5VUfJL1kDGfpX+wMf1jsQXbmVOO0Bobkqb3BhHnOjbx9QkeL2pNexrEul73tAns5Hr5ildFFg/a/Y6CGNjG1NHVmU5XW2psV5Z7qIrbKsjbYgyS5E+2opPgWd1BATCy6ivlr4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1765264594; c=relaxed/simple; bh=zHLh/hIokllVOV6IpIphtx7EBxyeERxYvG+VcPdsc7U=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=piULNUhH2qkuiHog1wknRQhlu9VkdzqVdwR75yLAnIf59d/B7PCWyvcaAs0svSYgeMyG93Nf0pn9HByrknesVC5VQZqTezzrMmYpgl633iG5EFUOgDi5b9aC77VHDsVIMcgmY3fdRpE8NgpFfLe6YOgYSY5Wmg+f4ypv6/rIww0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=i5WkcMt7; arc=none smtp.client-ip=209.85.214.180 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="i5WkcMt7" Received: by mail-pl1-f180.google.com with SMTP id d9443c01a7336-29812589890so73668285ad.3 for ; Mon, 08 Dec 2025 23:16:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1765264592; x=1765869392; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=5RED2CAsyuQW239qmVORCgxiFQVUz8czLslu+op8xjU=; b=i5WkcMt70QCiUWUL5IqMou/qaJvPGhvU8bqawn+Ja6tHuinHhFBZYGpaD1crVnITjX Z5cAqPtfqh3Kg9n45gZALYg5ih95z9HS4Ojh76Wj1ra2o2aZTV6TKZ7Rj+4J2L87QeMg DvKwcA/9sOjExWgHlK+dDwG7b3ph7w5z0+XcjbjpstOj4jikx7ZKpaAvUEt8Lw5TP2fr oCwZQwE9yBJXvXm0QI60ix1gtpRn+8KpRmQrfpQWeUUAHGWSnr0uoe/bticNkUxOoaqD QHAwWBZ8K+etXLB8XkzybKsGoPms4KhelLo10/HCZvJsxymgqTEuWLLPqD2mas/V5/aT dkcA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1765264592; x=1765869392; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=5RED2CAsyuQW239qmVORCgxiFQVUz8czLslu+op8xjU=; b=Xl8FDoPFJqdn8D9wi+2Glllf97tim+w2ddAvly3I7UyW/OpINqZlxRzjNz+PdfoJaY X9tgN7I/y7jD1TR1QPvxBKdudgrulnhrbNYFRud1+vReFyL3+FlzX9V29wM21O88zSIN gMU++PGnvg9C2qVu+qBRcluX766cLzrjNWvDnbJAjiWjbCKCJJeYGAP7aKqz9YJ3etRk L0COkSsfO1ppJTwMX808Q0JZ1wqZj/MmRVYkkCdW5yjxaJu7+DZfX1VwEXFdper/igkW bqwhfRabqp8wn/uF+gFcHvGMxvo7e28ezKQzATsS7s2RNqDjiYtHa1xQwKQ+98frlV4X 0VFg== X-Forwarded-Encrypted: i=1; AJvYcCW2NFJn7G0Axrffn67psSrwcpQ+PPuHJvb+HFo6A3WIjTHa7xou9xEqiBG+31eZKC8aix4rt025zC76KYE=@vger.kernel.org X-Gm-Message-State: AOJu0YzNNIyWiilihrCDELjAJxtbuRyIsYgrix3ccfwpDjpIyEJnnmXh CeloB3yLBBynLwf2iaT5NX/8Dj4RWmGNop9r1L6JvfNJhsD3O3ljbM3n X-Gm-Gg: AY/fxX5XHXsm7X172xn5C2RWEM7HLGxmo4VrTvsDGsvTLvx6J6mtsKUWkTlWX9xj/r9 znwpyUxLyNyRmWYUMy7ZuXfTByRaVydxxHVnaxMR7zGqSLj+cwAlcFt4swOg8+xWBDDGDdbe+XT NXapH82kYihCBMxbAGfUk8oXwb+5iu4XfuOCkN1ptMdIDoNVh93vEtj8fbQZ+kOwos1hYTQ7hKR ujhcCWduBJhvRkDS7DitjoMnyrYvTYRCBv5E3tyS+REXGwHfjFIO68OIC/fEKT2VjBJUL0fEcmq FkIxwXVXgwtpLKb9ygM8CSsmVMYoPAbiudoPuedQOCqelk04NmQk+9kSFj5Cgx5/MmaBEnZyq+w xrMt4vF9THcrpTWiWOmTeCApnr0ts0wRiewijebsafpXRS1O3YobvGzzBZQFoX0Ho/YlOpHZchr 23SDJWhAh6FLW9nouSthcS X-Google-Smtp-Source: AGHT+IFWaD3cFLUC/FQPUtDsgSigxggTA554xMHc8MDDs9pgERSGGEmc2ncHBgtV9o4wNM4ILv9zmw== X-Received: by 2002:a17:902:da2d:b0:297:cf96:45bd with SMTP id d9443c01a7336-29df547485fmr85256685ad.19.1765264591632; Mon, 08 Dec 2025 23:16:31 -0800 (PST) Received: from DESKTOP-TIT0J8O.dm.ae ([49.47.198.227]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-29dae99f01csm142776245ad.48.2025.12.08.23.16.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Dec 2025 23:16:31 -0800 (PST) From: Ahmed Naseef To: Cc: Ahmed Naseef , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , linux-kernel@vger.kernel.org, linux-mtd@lists.infradead.org Subject: [PATCH v2] mtd: spinand: add support for Dosilicon DS35Q1GA/DS35M1GA Date: Tue, 9 Dec 2025 11:16:02 +0400 Message-Id: <20251209071604.36482-1-naseefkm@gmail.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Add support for Dosilicon DS35Q1GA (3.3V) and DS35M1GA (1.8V) SPI NAND. These are 1Gbit (128MB) devices with: - 2048 byte pages + 64 byte OOB - 64 pages per block, 1024 blocks - On-die 4-bit ECC per 512 byte sector The 64-byte OOB area is divided into 4 segments of 16 bytes, with each segment containing 8 bytes of user data (M2+M1) and 8 bytes of ECC parity (R1). This provides 30 bytes of usable OOB space after reserving 2 bytes for the bad block marker. Tested on Genexis Platinum 4410 (EcoNet EN751221) by writing known patterns to OOB and verifying ECC parity placement in R1 regions. Datasheet: https://www.dosilicon.com/resources/SPI%20NAND/DS35X1GAXXX_rev08.pdf Signed-off-by: Ahmed Naseef --- Changes in v2: - Rebased on rc1 (updated SPINAND_OP_VARIANTS macros) - Fixed OOB layout based on hardware testing: - ECC regions: bytes 8-15, 24-31, 40-47, 56-63 (32 bytes total) - Free regions: bytes 2-7, 16-23, 32-39, 48-55 (30 bytes total) - Updated commit message --- drivers/mtd/nand/spi/Makefile | 4 +- drivers/mtd/nand/spi/core.c | 1 + drivers/mtd/nand/spi/dosilicon.c | 91 ++++++++++++++++++++++++++++++++ include/linux/mtd/spinand.h | 1 + 4 files changed, 95 insertions(+), 2 deletions(-) create mode 100644 drivers/mtd/nand/spi/dosilicon.c diff --git a/drivers/mtd/nand/spi/Makefile b/drivers/mtd/nand/spi/Makefile index 6d3d203df..a47bd22cd 100644 --- a/drivers/mtd/nand/spi/Makefile +++ b/drivers/mtd/nand/spi/Makefile @@ -1,5 +1,5 @@ # SPDX-License-Identifier: GPL-2.0 spinand-objs :=3D core.o otp.o -spinand-objs +=3D alliancememory.o ato.o esmt.o fmsh.o foresee.o gigadevic= e.o macronix.o -spinand-objs +=3D micron.o paragon.o skyhigh.o toshiba.o winbond.o xtx.o +spinand-objs +=3D alliancememory.o ato.o dosilicon.o esmt.o fmsh.o foresee= .o gigadevice.o +spinand-objs +=3D macronix.o micron.o paragon.o skyhigh.o toshiba.o winbon= d.o xtx.o obj-$(CONFIG_MTD_SPI_NAND) +=3D spinand.o diff --git a/drivers/mtd/nand/spi/core.c b/drivers/mtd/nand/spi/core.c index d20728657..0346916b0 100644 --- a/drivers/mtd/nand/spi/core.c +++ b/drivers/mtd/nand/spi/core.c @@ -1227,6 +1227,7 @@ static const struct nand_ops spinand_ops =3D { static const struct spinand_manufacturer *spinand_manufacturers[] =3D { &alliancememory_spinand_manufacturer, &ato_spinand_manufacturer, + &dosilicon_spinand_manufacturer, &esmt_8c_spinand_manufacturer, &esmt_c8_spinand_manufacturer, &fmsh_spinand_manufacturer, diff --git a/drivers/mtd/nand/spi/dosilicon.c b/drivers/mtd/nand/spi/dosili= con.c new file mode 100644 index 000000000..f99899866 --- /dev/null +++ b/drivers/mtd/nand/spi/dosilicon.c @@ -0,0 +1,91 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Author: Ahmed Naseef + */ + +#include +#include +#include + +#define SPINAND_MFR_DOSILICON 0xE5 + +static SPINAND_OP_VARIANTS(read_cache_variants, + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_4S_OP(0, 1, NULL, 0, 0), + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_2S_OP(0, 1, NULL, 0, 0), + SPINAND_PAGE_READ_FROM_CACHE_FAST_1S_1S_1S_OP(0, 1, NULL, 0, 0), + SPINAND_PAGE_READ_FROM_CACHE_1S_1S_1S_OP(0, 1, NULL, 0, 0)); + +static SPINAND_OP_VARIANTS(write_cache_variants, + SPINAND_PROG_LOAD_1S_1S_4S_OP(true, 0, NULL, 0), + SPINAND_PROG_LOAD_1S_1S_1S_OP(true, 0, NULL, 0)); + +static SPINAND_OP_VARIANTS(update_cache_variants, + SPINAND_PROG_LOAD_1S_1S_4S_OP(false, 0, NULL, 0), + SPINAND_PROG_LOAD_1S_1S_1S_OP(false, 0, NULL, 0)); + +static int ds35xx_ooblayout_ecc(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) +{ + if (section > 3) + return -ERANGE; + + region->offset =3D 8 + (section * 16); + region->length =3D 8; + + return 0; +} + +static int ds35xx_ooblayout_free(struct mtd_info *mtd, int section, + struct mtd_oob_region *region) +{ + if (section > 3) + return -ERANGE; + + if (section =3D=3D 0) { + /* reserve 2 bytes for the BBM */ + region->offset =3D 2; + region->length =3D 6; + } else { + region->offset =3D section * 16; + region->length =3D 8; + } + + return 0; +} + +static const struct mtd_ooblayout_ops ds35xx_ooblayout =3D { + .ecc =3D ds35xx_ooblayout_ecc, + .free =3D ds35xx_ooblayout_free, +}; + +static const struct spinand_info dosilicon_spinand_table[] =3D { + SPINAND_INFO("DS35Q1GA", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x71), + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), + SPINAND_HAS_QE_BIT, + SPINAND_ECCINFO(&ds35xx_ooblayout, NULL)), + SPINAND_INFO("DS35M1GA", + SPINAND_ID(SPINAND_READID_METHOD_OPCODE_DUMMY, 0x21), + NAND_MEMORG(1, 2048, 64, 64, 1024, 20, 1, 1, 1), + NAND_ECCREQ(4, 512), + SPINAND_INFO_OP_VARIANTS(&read_cache_variants, + &write_cache_variants, + &update_cache_variants), + SPINAND_HAS_QE_BIT, + SPINAND_ECCINFO(&ds35xx_ooblayout, NULL)), +}; + +static const struct spinand_manufacturer_ops dosilicon_spinand_manuf_ops = =3D { +}; + +const struct spinand_manufacturer dosilicon_spinand_manufacturer =3D { + .id =3D SPINAND_MFR_DOSILICON, + .name =3D "Dosilicon", + .chips =3D dosilicon_spinand_table, + .nchips =3D ARRAY_SIZE(dosilicon_spinand_table), + .ops =3D &dosilicon_spinand_manuf_ops, +}; diff --git a/include/linux/mtd/spinand.h b/include/linux/mtd/spinand.h index ce76f5c63..c50a43b44 100644 --- a/include/linux/mtd/spinand.h +++ b/include/linux/mtd/spinand.h @@ -354,6 +354,7 @@ struct spinand_manufacturer { /* SPI NAND manufacturers */ extern const struct spinand_manufacturer alliancememory_spinand_manufactur= er; extern const struct spinand_manufacturer ato_spinand_manufacturer; +extern const struct spinand_manufacturer dosilicon_spinand_manufacturer; extern const struct spinand_manufacturer esmt_8c_spinand_manufacturer; extern const struct spinand_manufacturer esmt_c8_spinand_manufacturer; extern const struct spinand_manufacturer fmsh_spinand_manufacturer; --=20 2.34.1