From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C6A2C2F6577; Mon, 20 Oct 2025 10:13:50 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955232; cv=none; b=MFQbNR4zODo1bV7llvq/TZ7BVvxaovoNrmpFN4cxUXLNEcXDxgeGsWylE/trU8nC9W2Xhm/vbpeaILVRf2pfexzhV6LJco6MeLj6Cv+sW0P/WuJjVWFUaAYnXLeJKIIhBj694KpDxTazRnrSslFeemPlQfMxwu5CPyFtguYK+c8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955232; c=relaxed/simple; bh=uV3J+ukDhk15H89nr/D2cVuC6yRnOiEZ9jjzajCXzKA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JVLPoY1bpL/dVw04vvD0nKQVGCtKlqVdKccDhJqzr2mSlYjSXpyoBwpxh8FzVgJyVox8PII9/BvGuNvtoXNmeYM2GSDCafahuuIpjNjrr5B3MJGC6M55/wC9OKxx5Dauuf42bHMWBd/xw8ZKwyYx+DF1IDZK515pyb3bxNhWCrM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=ZKstGuMo; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="ZKstGuMo" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 2869C4E411F3; Mon, 20 Oct 2025 10:13:49 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id EF86A606D5; Mon, 20 Oct 2025 10:13:48 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BED94102F23A7; Mon, 20 Oct 2025 12:13:45 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955227; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=j9UGTJcWYSBAqp5JJLufyhsbLELsj0ohBAucYdJtZ1o=; b=ZKstGuMoiIN/ifTdPeQY8PmAMotlWmbporhLhj7pGHzBM32L0Oimhlj9F8vLLXbnXug4uQ qERwvE68jOeOd4Q+imJIbtPiuOM2dHBoPpiUpyTbmQlzf/koGuwGowDJWgH1xxgkN+AkTz YAbTdrNS3yw5I+0goOMHNDmsieefCMP75oNwWSnkZQx9oThOlNMQogdgBRZjR/1HUJ3GGB MXUvYhtA8I3ivHfz9GGHYWyTZ+0tAi4bySm6smXAI0gNeN9rC222/WJO5BZ7MTEbGRlfze C4gT/le7b8+5cabWB3hpxiSp+z1kyE3ur+IbICHqPAyhFMJHlTx9rS8SJxSaVQ== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 01/15] mtd: rawnand: sunxi: Remove superfluous register readings Date: Mon, 20 Oct 2025 12:12:57 +0200 Message-ID: <20251020101311.256819-2-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The register NFC_REG_ECC_CTL was read twice and the result was not used, then a third time with a mask applied. Removing those calls didn't change the behavior. Tested on H616 SoC, scrambling enabled. Reviewed-by: Jernej Skrabec Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index f6a8e8ae819d..cb12179b63a5 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -623,13 +623,12 @@ static void sunxi_nfc_randomizer_config(struct nand_c= hip *nand, int page, bool ecc) { struct sunxi_nfc *nfc =3D to_sunxi_nfc(nand->controller); - u32 ecc_ctl =3D readl(nfc->regs + NFC_REG_ECC_CTL); + u32 ecc_ctl; u16 state; =20 if (!(nand->options & NAND_NEED_SCRAMBLING)) return; =20 - ecc_ctl =3D readl(nfc->regs + NFC_REG_ECC_CTL); state =3D sunxi_nfc_randomizer_state(nand, page, ecc); ecc_ctl =3D readl(nfc->regs + NFC_REG_ECC_CTL) & ~NFC_RANDOM_SEED_MSK; writel(ecc_ctl | NFC_RANDOM_SEED(state), nfc->regs + NFC_REG_ECC_CTL); From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B5B702F6183 for ; Mon, 20 Oct 2025 10:13:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955234; cv=none; b=YGgoEzdye0fUrfKHt0QzDQJ5aFE05a4hSFqMcm5ZAqA6Vgv0SvGYgAoR6JmSQ/vC3kE7yXLS7Gd+SeXqL9QNadxl3I9AKOOE4rL+BFm4UlmnXIdYuYgA8XVEbtCKo0lWBPYedLQ7UCgEkdPPhVh8skbP5FLPdUggq3A0Jx6Oxss= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955234; c=relaxed/simple; bh=SFORQBRRqv9pOnneUDLkM8a+CKz0DTFZisD9lU5eojM=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=D+e9ccIormDA18I3mwQ3/saMXroOF8ygBvz0qiOE0zfTz3L/vlex4g2fbUMrT0+UbUBDX4PEaRyLxDYdhzMeopiepce1UU+hgZBPP0Kr4ytJXo+kfUkMfuvURA8/Pnp7NxR4irENp/AeTDCxKGmA49nZLiiUryCPQfNEWcWU0U8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=vf+gL8i4; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="vf+gL8i4" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id EAC624E411F4; Mon, 20 Oct 2025 10:13:50 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id C05DA606D5; Mon, 20 Oct 2025 10:13:50 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id E9AEE102F23AF; Mon, 20 Oct 2025 12:13:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955229; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=qvlyha3XerTbsFS6cH72yftIqITSDRC+fAzq8n2ZdDU=; b=vf+gL8i4KPMd1K+yWFT9H4XWYyCTPI6GWG1hiK1pS+AK56pcVcgqyScsnTThkcT0tjWb47 vkfaAV0w3JxH5jniB5CFhMezVyJMhoZT3J6ydoPkF9OmLNFcSiP/kiCiz28ST1z8D4rnXi YmTvqUailKFcQiLfYyK0412CmPsk9caFfZbdWbOYKTk31ImoE8w//nrOjKCvTHc+vSfEbj hRbvAFDwo1tT1Wah3n9CsoqNP/40zx8lfcqwqBRyoBOnjxfHZzFu5NWRCApXXyF3aooIcx kZpZ+aUGf444jF915sR25Jtce9YQetNF9+07b0gAOkHwvBwjGapRZTjpVlcPUg== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 02/15] mtd: rawnand: sunxi: move ECC strenghts in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:12:58 +0200 Message-ID: <20251020101311.256819-3-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" H6/H616 has more ECC strenghts than A10/A23. Move the ECC strenghts array to sunxi_nfc_caps to make it ready for H6/H616 support. No functional change. Reviewed-by: Chen-Yu Tsai Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index cb12179b63a5..d3b17d54f04c 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -213,11 +213,15 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(s= truct nand_chip *nand) * through MBUS on A23/A33 needs extra configuration. * @reg_io_data: I/O data register * @dma_maxburst: DMA maxburst + * @ecc_strengths: Available ECC strengths array + * @nstrengths: Size of @ecc_strengths */ struct sunxi_nfc_caps { bool has_mdma; unsigned int reg_io_data; unsigned int dma_maxburst; + const u8 *ecc_strengths; + unsigned int nstrengths; }; =20 /** @@ -1619,9 +1623,9 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_ch= ip *nand, struct nand_ecc_ctrl *ecc, struct device_node *np) { - static const u8 strengths[] =3D { 16, 24, 28, 32, 40, 48, 56, 60, 64 }; struct sunxi_nand_chip *sunxi_nand =3D to_sunxi_nand(nand); struct sunxi_nfc *nfc =3D to_sunxi_nfc(nand->controller); + const u8 *strengths =3D nfc->caps->ecc_strengths; struct mtd_info *mtd =3D nand_to_mtd(nand); struct nand_device *nanddev =3D mtd_to_nanddev(mtd); int nsectors; @@ -1645,7 +1649,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_ch= ip *nand, =20 ecc->strength =3D bytes * 8 / fls(8 * ecc->size); =20 - for (i =3D 0; i < ARRAY_SIZE(strengths); i++) { + for (i =3D 0; i < nfc->caps->nstrengths; i++) { if (strengths[i] > ecc->strength) break; } @@ -1666,7 +1670,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_ch= ip *nand, } =20 /* Add ECC info retrieval from DT */ - for (i =3D 0; i < ARRAY_SIZE(strengths); i++) { + for (i =3D 0; i < nfc->caps->nstrengths; i++) { if (ecc->strength <=3D strengths[i]) { /* * Update ecc->strength value with the actual strength @@ -1677,7 +1681,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_ch= ip *nand, } } =20 - if (i >=3D ARRAY_SIZE(strengths)) { + if (i >=3D nfc->caps->nstrengths) { dev_err(nfc->dev, "unsupported strength\n"); return -ENOTSUPP; } @@ -2167,15 +2171,23 @@ static void sunxi_nfc_remove(struct platform_device= *pdev) dma_release_channel(nfc->dmac); } =20 +static const u8 sunxi_ecc_strengths_a10[] =3D { + 16, 24, 28, 32, 40, 48, 56, 60, 64 +}; + static const struct sunxi_nfc_caps sunxi_nfc_a10_caps =3D { .reg_io_data =3D NFC_REG_A10_IO_DATA, .dma_maxburst =3D 4, + .ecc_strengths =3D sunxi_ecc_strengths_a10, + .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), }; =20 static const struct sunxi_nfc_caps sunxi_nfc_a23_caps =3D { .has_mdma =3D true, .reg_io_data =3D NFC_REG_A23_IO_DATA, .dma_maxburst =3D 8, + .ecc_strengths =3D sunxi_ecc_strengths_a10, + .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), }; =20 static const struct of_device_id sunxi_nfc_ids[] =3D { From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id DFE002F7441 for ; Mon, 20 Oct 2025 10:13:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955236; cv=none; b=O56xPe0XukXwJ45JlJjfkoXJo60jGH6oBye2TyKQQEOjqOc4uRHOjD8FigHBvTtp+ciMwrthwFqfUcWetZvqUV6XMHGmIQQlHayjNeC9Qe148d6rSXLi2L8pMlRMomB2zGc5Wwj2x4Il9zPwhKrPQekJVEdUVEiUNEIpm+AfMZQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955236; c=relaxed/simple; bh=zCdVIfT3/lJV5ewa+JtXbF/AwV1pJJ2zuoy9j7fYm4o=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=b9E84NnKz2j/w0IqNncZ3LfCTjKftlzTrSTFqpMA5mS1GYl64xfA2CU7wVntBWHc9/x94NTKREF2LM3UmgQlYrNaYBR5EMLgNxY/vK/XweuMKg5YHvX3ArKf30spAMtwcURk8DkAa/wQE+My3v87pNg/i/RUma7Q6E6TfozwJlg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=icZmtu8+; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="icZmtu8+" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id A8611C0AFE9; Mon, 20 Oct 2025 10:13:32 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3ACD1606D5; Mon, 20 Oct 2025 10:13:52 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B5A9D102F23A5; Mon, 20 Oct 2025 12:13:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955231; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=+2C6Y7QvX0FPwTw070QW7rXZAP/U111s0G+dQuIpjU4=; b=icZmtu8+UOcMIKbJlpOsd4Wwa8U0D2ooOjfKcMW6ymE//hYV+rxK6iJjRSiumgNqjj/yBi knaQNIVCZBlutE9wrHRms+1WzXrH/2vHog6XtRgD2bS6sSgOQHGIo3siPx5utQ3Q1F5v9I MjbyrD2SyqZElX5LXWRHvzwpvvH7zoyGn8fEp96WGB93Nm8YjudKQb1o+Y/j7TSOsmax8w a8KmuuYUCcsJTiTffmyaQLpd0ygPRq2kj7gVoRvux73ls9uy4kRMsEhFUOrUWd9pARg27q BcYm/UAijOHd1y7GIgLYiBt14y6ykLh+y6BFvoxcJ0NtOchL8uIrB/nZ+rV/CQ== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 03/15] mtd: rawnand: sunxi: introduce reg_ecc_err_cnt in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:12:59 +0200 Message-ID: <20251020101311.256819-4-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 ECC_ERR_CNT register is not at the same offset as the A10/A23 one, so move its offset into sunxi_nfc_caps No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index d3b17d54f04c..0285e4d0ca7f 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -46,7 +46,8 @@ #define NFC_REG_ECC_CTL 0x0034 #define NFC_REG_ECC_ST 0x0038 #define NFC_REG_DEBUG 0x003C -#define NFC_REG_ECC_ERR_CNT(x) ((0x0040 + (x)) & ~0x3) +#define NFC_REG_A10_ECC_ERR_CNT 0x0040 +#define NFC_REG_ECC_ERR_CNT(nfc, x) ((nfc->caps->reg_ecc_err_cnt + (x)) & = ~0x3) #define NFC_REG_USER_DATA(x) (0x0050 + ((x) * 4)) #define NFC_REG_SPARE_AREA 0x00A0 #define NFC_REG_PAT_ID 0x00A4 @@ -212,6 +213,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @has_mdma: Use mbus dma mode, otherwise general dma * through MBUS on A23/A33 needs extra configuration. * @reg_io_data: I/O data register + * @reg_ecc_err_cnt: ECC error counter register * @dma_maxburst: DMA maxburst * @ecc_strengths: Available ECC strengths array * @nstrengths: Size of @ecc_strengths @@ -219,6 +221,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) struct sunxi_nfc_caps { bool has_mdma; unsigned int reg_io_data; + unsigned int reg_ecc_err_cnt; unsigned int dma_maxburst; const u8 *ecc_strengths; unsigned int nstrengths; @@ -790,7 +793,7 @@ static int sunxi_nfc_hw_ecc_correct(struct nand_chip *n= and, u8 *data, u8 *oob, return 0; } =20 - tmp =3D readl(nfc->regs + NFC_REG_ECC_ERR_CNT(step)); + tmp =3D readl(nfc->regs + NFC_REG_ECC_ERR_CNT(nfc, step)); =20 return NFC_ECC_ERR_CNT(step, tmp); } @@ -2177,6 +2180,7 @@ static const u8 sunxi_ecc_strengths_a10[] =3D { =20 static const struct sunxi_nfc_caps sunxi_nfc_a10_caps =3D { .reg_io_data =3D NFC_REG_A10_IO_DATA, + .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .dma_maxburst =3D 4, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), @@ -2185,6 +2189,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { static const struct sunxi_nfc_caps sunxi_nfc_a23_caps =3D { .has_mdma =3D true, .reg_io_data =3D NFC_REG_A23_IO_DATA, + .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .dma_maxburst =3D 8, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 44AA52F7445 for ; Mon, 20 Oct 2025 10:13:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955238; cv=none; b=bYsxsss7g68CUk0ZpWgyXmbv64otDfIZiPXgC3/KlDeQ1JAo8Nb8M7ZxKBkYPtfFwJ3dZAKADXl/hSUAbcWlMzVo1DguWfA/BcpN4VULZj/PVGa7hqwhhB9AEW82VfGU5Fl5zN2oWzP6lJ5xaqyXmg2kyCs4/5/MfDxcIT57Y/I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955238; c=relaxed/simple; bh=sKdPTZKVDf9izgHjArzrMu00cTpmD5hXprgFF+zlBd8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=cYwup0ZFKCqHpfie8T4CXngwozFiiZfl0IM4AknJuJS1C3UaidN3i/qGFOofX0I8IguRK4OdKut6BwWINdG0et02C8HlNJk3Bknv/fBkoeS0XXGEcBzbVswyRSTLgIc0D2ErnxS0R65KdprSrlYivxU+8JacvQgy3WcNdj3qsHk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=Xob6Lfmk; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="Xob6Lfmk" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 79D431A154B; Mon, 20 Oct 2025 10:13:54 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 4F586606D5; Mon, 20 Oct 2025 10:13:54 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B0A33102F0848; Mon, 20 Oct 2025 12:13:51 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955233; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=WVNi494X9+FHAVQizYRHT85ozYcDOUl/u6KHDtPy1K4=; b=Xob6LfmkEnoUjVj+hfPxFoXxUsffTqAa6eshmbcjTVmoEYZZXoh+/2KnSp5o24WWudlIOk URMh/f9vVxEWhHAiVu5h2MtP14wSjKgZ2W/4eUfPG6X4kpUQQycIe9YiQ5CEAjjiNgmSLR 1nw94UELD5dS4ZjlFc8W77Yc3i/o8dcv+eU99j7yiZt3jc+UoVg93rvik1dl3HISYxp6Rb 3KNBloUQjgxDeN5HlRPvInVZcfb0ABfKW3RsvNziPYfidXMQcWCXeK513h9xKuUvjMdBkP Eet9+xyQk8IlUR42L52WBO/ZYRkvxpql5wGKA/liX+ZtsYcDB0tFOG2Wkapn8g== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 04/15] mtd: rawnand: sunxi: introduce reg_user_data in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:13:00 +0200 Message-ID: <20251020101311.256819-5-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 USER_DATA register is not at the same offset as the A10/A23 one, so move its offset into sunxi_nfc_caps No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index 0285e4d0ca7f..8f5d8df19e33 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -48,7 +48,8 @@ #define NFC_REG_DEBUG 0x003C #define NFC_REG_A10_ECC_ERR_CNT 0x0040 #define NFC_REG_ECC_ERR_CNT(nfc, x) ((nfc->caps->reg_ecc_err_cnt + (x)) & = ~0x3) -#define NFC_REG_USER_DATA(x) (0x0050 + ((x) * 4)) +#define NFC_REG_A10_USER_DATA 0x0050 +#define NFC_REG_USER_DATA(nfc, x) (nfc->caps->reg_user_data + ((x) * 4)) #define NFC_REG_SPARE_AREA 0x00A0 #define NFC_REG_PAT_ID 0x00A4 #define NFC_REG_MDMA_ADDR 0x00C0 @@ -214,6 +215,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * through MBUS on A23/A33 needs extra configuration. * @reg_io_data: I/O data register * @reg_ecc_err_cnt: ECC error counter register + * @reg_user_data: User data register * @dma_maxburst: DMA maxburst * @ecc_strengths: Available ECC strengths array * @nstrengths: Size of @ecc_strengths @@ -222,6 +224,7 @@ struct sunxi_nfc_caps { bool has_mdma; unsigned int reg_io_data; unsigned int reg_ecc_err_cnt; + unsigned int reg_user_data; unsigned int dma_maxburst; const u8 *ecc_strengths; unsigned int nstrengths; @@ -723,8 +726,8 @@ static void sunxi_nfc_hw_ecc_get_prot_oob_bytes(struct = nand_chip *nand, u8 *oob, { struct sunxi_nfc *nfc =3D to_sunxi_nfc(nand->controller); =20 - sunxi_nfc_user_data_to_buf(readl(nfc->regs + NFC_REG_USER_DATA(step)), - oob); + sunxi_nfc_user_data_to_buf(readl(nfc->regs + + NFC_REG_USER_DATA(nfc, step)), oob); =20 /* De-randomize the Bad Block Marker. */ if (bbm && (nand->options & NAND_NEED_SCRAMBLING)) @@ -746,7 +749,7 @@ static void sunxi_nfc_hw_ecc_set_prot_oob_bytes(struct = nand_chip *nand, } =20 writel(sunxi_nfc_buf_to_user_data(oob), - nfc->regs + NFC_REG_USER_DATA(step)); + nfc->regs + NFC_REG_USER_DATA(nfc, step)); } =20 static void sunxi_nfc_hw_ecc_update_stats(struct nand_chip *nand, @@ -2181,6 +2184,7 @@ static const u8 sunxi_ecc_strengths_a10[] =3D { static const struct sunxi_nfc_caps sunxi_nfc_a10_caps =3D { .reg_io_data =3D NFC_REG_A10_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, + .reg_user_data =3D NFC_REG_A10_USER_DATA, .dma_maxburst =3D 4, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), @@ -2190,6 +2194,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .has_mdma =3D true, .reg_io_data =3D NFC_REG_A23_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, + .reg_user_data =3D NFC_REG_A10_USER_DATA, .dma_maxburst =3D 8, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81C212F83AB for ; Mon, 20 Oct 2025 10:13:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955239; cv=none; b=njcGI4XJw5lGkLcKoePTFdtxLdW/WgPDnOFmR+j9wd3b1mg3erMZ2gOZQ+9NVi6Ltmr/i0FNVCoPM/acDfchQsmuqDEsiq19k+q2+Wsb2rZwdGRhKz1OHj5udjmzeCibYd9VylWrp1ooyKq9ATsa9TkLv8RL2S/j5xW8DQm6SpE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955239; c=relaxed/simple; bh=Bj2bDkawb+eM4LEf6zTBVOXbBamk4BEp7t4QkbWGVF0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=IywjT0EZaHp+f0yYQhfJvciImhdIgFrZNp/hudx7xeHFP33YtQ6WzcshJKKqd2fjsWpyYhVnUBBrhe8/LLnW5W2k9FzkJl9VUcENwSMUB3dUIYxpd6qf0rbv7OmJAQLSwRqzX8IQPt9PAAl9xn8izwNd7LHfI2cZdF6yDxMrUh8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=W+Kl66iQ; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="W+Kl66iQ" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 0DF911A1547; Mon, 20 Oct 2025 10:13:56 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id D7F75606D5; Mon, 20 Oct 2025 10:13:55 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 86764102F23A7; Mon, 20 Oct 2025 12:13:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955235; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=tFIp35uHTqcsmvS0r9Kp5zCwmOEmNlNll/p8ijKVjUE=; b=W+Kl66iQqVGEN7WxNHCc2JaAb5If5Xkk8Letk+JE6GRJmuclBuAP7YnDmlbA7IgqXStQ2w B7IT40qxCMrt8h0Y1MdCdNAEfORD52oLCMapRtbxLOflePfHtR2gsH1cn2ch37Ij2yXSYV Nk3VS1QBS9D1odgv065dHm9sFyrxgz0bNVSPhofVZ6yHF9OZJgOGNmfIbbPhCz8F0XCqyt nyS2zKKCdoW6mS8Xgjrmlr6NxLPie3GjjzcoK+3jpIsh+mZIfbXa18QnUAjbFhf1RbsY74 t3KYBVSO0ivHoT5P+HiFKAkzOAK8THxD9S49epeOH0MdRT8C84St4+PpAJkiyg== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 05/15] mtd: rawnand: sunxi: rework pattern found registers Date: Mon, 20 Oct 2025 12:13:01 +0200 Message-ID: <20251020101311.256819-6-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" On H6/H616, the register ECC_PAT_FOUND is at its own address, and not part of ECC status register. So, introduce the pattern found register offset in sunxi_nfc_caps, along with its mask. Also, introduce a non compile-time field_get() because FIELD_GET() and u32_get_bits() don't work with non compile-time constant. https://lore.kernel.org/lkml/cover.1739540679.git.geert+renesas@glider.be/ No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 36 ++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index 8f5d8df19e33..4cfb5d3e9c06 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -29,6 +29,9 @@ #include #include =20 +/* non compile-time field get */ +#define field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1)) + #define NFC_REG_CTL 0x0000 #define NFC_REG_ST 0x0004 #define NFC_REG_INT 0x0008 @@ -150,7 +153,13 @@ /* define bit use in NFC_ECC_ST */ #define NFC_ECC_ERR(x) BIT(x) #define NFC_ECC_ERR_MSK GENMASK(15, 0) -#define NFC_ECC_PAT_FOUND(x) BIT(x + 16) + +/* + * define bit use in NFC_REG_PAT_FOUND + * For A10/A23, NFC_REG_PAT_FOUND =3D=3D NFC_ECC_ST register + */ +#define NFC_ECC_PAT_FOUND_MSK(nfc) (nfc->caps->pat_found_mask) + #define NFC_ECC_ERR_CNT(b, x) (((x) >> (((b) % 4) * 8)) & 0xff) =20 #define NFC_DEFAULT_TIMEOUT_MS 1000 @@ -216,6 +225,8 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @reg_io_data: I/O data register * @reg_ecc_err_cnt: ECC error counter register * @reg_user_data: User data register + * @reg_pat_found: Data Pattern Status Register + * @pat_found_mask: ECC_PAT_FOUND mask in NFC_REG_PAT_FOUND register * @dma_maxburst: DMA maxburst * @ecc_strengths: Available ECC strengths array * @nstrengths: Size of @ecc_strengths @@ -225,6 +236,8 @@ struct sunxi_nfc_caps { unsigned int reg_io_data; unsigned int reg_ecc_err_cnt; unsigned int reg_user_data; + unsigned int reg_pat_found; + unsigned int pat_found_mask; unsigned int dma_maxburst; const u8 *ecc_strengths; unsigned int nstrengths; @@ -766,7 +779,8 @@ static void sunxi_nfc_hw_ecc_update_stats(struct nand_c= hip *nand, } =20 static int sunxi_nfc_hw_ecc_correct(struct nand_chip *nand, u8 *data, u8 *= oob, - int step, u32 status, bool *erased) + int step, u32 status, u32 pattern_found, + bool *erased) { struct sunxi_nfc *nfc =3D to_sunxi_nfc(nand->controller); struct nand_ecc_ctrl *ecc =3D &nand->ecc; @@ -777,7 +791,7 @@ static int sunxi_nfc_hw_ecc_correct(struct nand_chip *n= and, u8 *data, u8 *oob, if (status & NFC_ECC_ERR(step)) return -EBADMSG; =20 - if (status & NFC_ECC_PAT_FOUND(step)) { + if (pattern_found & BIT(step)) { u8 pattern; =20 if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID) & 0x1))) { @@ -811,6 +825,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chip= *nand, struct sunxi_nfc *nfc =3D to_sunxi_nfc(nand->controller); struct nand_ecc_ctrl *ecc =3D &nand->ecc; int raw_mode =3D 0; + u32 pattern_found; bool erased; int ret; =20 @@ -838,8 +853,12 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chi= p *nand, =20 *cur_off =3D oob_off + ecc->bytes + 4; =20 + pattern_found =3D readl(nfc->regs + nfc->caps->reg_pat_found); + pattern_found =3D field_get(NFC_ECC_PAT_FOUND_MSK(nfc), pattern_found); + ret =3D sunxi_nfc_hw_ecc_correct(nand, data, oob_required ? oob : NULL, 0, readl(nfc->regs + NFC_REG_ECC_ST), + pattern_found, &erased); if (erased) return 1; @@ -920,7 +939,7 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nand= _chip *nand, uint8_t *buf unsigned int max_bitflips =3D 0; int ret, i, raw_mode =3D 0; struct scatterlist sg; - u32 status, wait; + u32 status, pattern_found, wait; =20 ret =3D sunxi_nfc_wait_cmd_fifo_empty(nfc); if (ret) @@ -961,6 +980,8 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nand= _chip *nand, uint8_t *buf return ret; =20 status =3D readl(nfc->regs + NFC_REG_ECC_ST); + pattern_found =3D readl(nfc->regs + nfc->caps->reg_pat_found); + pattern_found =3D field_get(NFC_ECC_PAT_FOUND_MSK(nfc), pattern_found); =20 for (i =3D 0; i < nchunks; i++) { int data_off =3D i * ecc->size; @@ -971,7 +992,8 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nand= _chip *nand, uint8_t *buf =20 ret =3D sunxi_nfc_hw_ecc_correct(nand, randomized ? data : NULL, oob_required ? oob : NULL, - i, status, &erased); + i, status, pattern_found, + &erased); =20 /* ECC errors are handled in the second loop. */ if (ret < 0) @@ -2185,6 +2207,8 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { .reg_io_data =3D NFC_REG_A10_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, + .reg_pat_found =3D NFC_REG_ECC_ST, + .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 4, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), @@ -2195,6 +2219,8 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .reg_io_data =3D NFC_REG_A23_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, + .reg_pat_found =3D NFC_REG_ECC_ST, + .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 8, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9F6B62F6181 for ; Mon, 20 Oct 2025 10:13:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955241; cv=none; b=K/GXf37h65NwP6jwnJZlcHtfDBBSIeaM1lSHNTX2QYmWo3YbNdQzGoAWUGNS20H8ys5KBHgzWiLJC99CdDwo6cgGn/pOQPze65Yg6vTw/8sbnhta689PPPByaPJVJobAHzqDiGtGWZ79mls78RaanuOhHBda8N0aIyTVs8kpWe0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955241; c=relaxed/simple; bh=Hnn8d1L69nr+BGHmp/NTgtAHLAUobVrpHbjzBTnFZi4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=tKZWbAIv6GOYfv/U+2Z6nQgwl2gNtoKnvzwY/NAcGSikhQVOYQQj4CYk/LtIJPhDKxIYhPGes+/SAOsij/Uso4zPvhpdWHXkgpLR6wR7SskK1pyPyHox/OrFo3M4S7L0dn+VeqqZhLcdJRH4zYk8FdJyDx+f2/hiIGniGOZ9VfQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=bC8koX7u; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="bC8koX7u" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 17F301A154C; Mon, 20 Oct 2025 10:13:58 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E1AEF606D5; Mon, 20 Oct 2025 10:13:57 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 51488102F23B2; Mon, 20 Oct 2025 12:13:55 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955236; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=HQ1IhgcFvXBkQ1TsRPeecT3KmPOkwdU0whK+wNY8jxI=; b=bC8koX7uJVqD67QaLxyhC/ytzw2wKkGKCOLexVp0xV5TULjmepqEmNRS+bb71IxFEb86yO SWInWPGqYQbhepePdNjH4FAH8osA0mJvyhKIVAyE5fvydq7XKBwN1Iq6KfDgD15GH3/GKe 59UBRu5MahJm+SlBXYrFrNS+lAV12gy4X9wYQf7ePcebWqNvYMWlLzB7GSJPLV9+eElu8P t+NuMX+cQ01IAuBD4jR4okTPLEy/VfMjIiAgBRYS995BUf8G2EzJUbjEbeIbcwXZgI21zs DYTjJTQ0J/kG5eKeWpb4gLVwS+zFHV9O+9t7ho7mQ8SJ5oXTMJHkMNX30+vpVQ== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 06/15] mtd: rawnand: sunxi: add has_ecc_block_512 capability Date: Mon, 20 Oct 2025 12:13:02 +0200 Message-ID: <20251020101311.256819-7-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H616 controller can't handle 512 bytes ECC block size. The NFC_ECC_BLOCK_512 bit disappeared in H6, and NDFC_RANDOM_EN took its place. So, add has_ecc_block_512 capability to only set this bit on SoC having it. No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index 4cfb5d3e9c06..70c940840dda 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -222,6 +222,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * * @has_mdma: Use mbus dma mode, otherwise general dma * through MBUS on A23/A33 needs extra configuration. + * @has_ecc_block_512: If the ECC can handle 512B or only 1024B chuncks * @reg_io_data: I/O data register * @reg_ecc_err_cnt: ECC error counter register * @reg_user_data: User data register @@ -233,6 +234,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) */ struct sunxi_nfc_caps { bool has_mdma; + bool has_ecc_block_512; unsigned int reg_io_data; unsigned int reg_ecc_err_cnt; unsigned int reg_user_data; @@ -1748,8 +1750,14 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_c= hip *nand, sunxi_nand->ecc.ecc_ctl =3D NFC_ECC_MODE(i) | NFC_ECC_EXCEPTION | NFC_ECC_PIPELINE | NFC_ECC_EN; =20 - if (ecc->size =3D=3D 512) - sunxi_nand->ecc.ecc_ctl |=3D NFC_ECC_BLOCK_512; + if (ecc->size =3D=3D 512) { + if (nfc->caps->has_ecc_block_512) { + sunxi_nand->ecc.ecc_ctl |=3D NFC_ECC_BLOCK_512; + } else { + dev_err(nfc->dev, "512B ECC block not supported\n"); + return -EOPNOTSUPP; + } + } =20 return 0; } @@ -2204,6 +2212,7 @@ static const u8 sunxi_ecc_strengths_a10[] =3D { }; =20 static const struct sunxi_nfc_caps sunxi_nfc_a10_caps =3D { + .has_ecc_block_512 =3D true, .reg_io_data =3D NFC_REG_A10_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, @@ -2216,6 +2225,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { =20 static const struct sunxi_nfc_caps sunxi_nfc_a23_caps =3D { .has_mdma =3D true, + .has_ecc_block_512 =3D true, .reg_io_data =3D NFC_REG_A23_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id F21CB2F9998 for ; Mon, 20 Oct 2025 10:14:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955243; cv=none; b=R+KVTwKnbe/luxHr7JDQHjvKO4QlezO3781096pemsqYKD60Um9lemCP0ayMMBcxymPijClG8lgcZpCxGA6lgoTmKHbO63ZIest/gPBDH3yuaJPXm61cQzMBFWdvGv0WKSB/38JUHnj5PGHGo4yM8ls6j3ZFEn7PkrsPR/hmQuM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955243; c=relaxed/simple; bh=nneC9LJDUxj4W8Oibk9vBwYYSpBKMUov7hzTQNgLfw4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=iGyeFoGueCQKzMM3WXFDF6RzUOOxOxIm/HcsdUr/b8KIyv5A5pYQ8TGw1AQNCeE2HhePkfG4BVoA5rampzvuduQUzs1Tdca8l93MkUacAAbiEZthkaV8SltgFP+olLtToS3f7g5vhVvoEGxMcBjZQNe6NbtJ4b6vklrhN0Dk/Eg= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=qIc/45Jy; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="qIc/45Jy" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id E7ED6C0AFE4; Mon, 20 Oct 2025 10:13:39 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 7A67E606D5; Mon, 20 Oct 2025 10:13:59 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 2B08B102F23B3; Mon, 20 Oct 2025 12:13:57 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955238; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=st75JxbS+dE80KXQ+nIOup4Lt/bHkhA0Xk0EIDuORe8=; b=qIc/45JyiTbHV3JOT20tU3BgAzN7QbWtUiQvk8cXiJ59uOqHEu/+LF2UWOAXidbLWOwa98 WN2sF7KqblmQD+ngSogrKTifka/z+PWdOelpSwnUESC746gyVD+hZW1NfKwt30wyHOBPSv ngyJOl4476E4xh5rWnIDEcd900vOZrkECIQYUNqXYB289E6GZmOrwU6U06ZPQuJON4figB Nm8FtbpM/aEX3J9g+4aM6f8HOwuszjIjY+/ffl3aK3ELVMgKJEj/LPMuqCcDkAJ2DHXtJj Do5ePnmArCGcHwJX7YCDw5Rsic8fPGKHBnpt6cGDc+bET+w0HXFdMa8jy7QROg== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 07/15] mtd: rawnand: sunxi: introduce ecc_mode_mask in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:13:03 +0200 Message-ID: <20251020101311.256819-8-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 ECC_MODE field is not at the same offset, and has not the same size. So move the mask into sunxi_nfc_caps. No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index 70c940840dda..4118307cac15 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -29,8 +29,9 @@ #include #include =20 -/* non compile-time field get */ +/* non compile-time field get/prep */ #define field_get(_mask, _reg) (((_reg) & (_mask)) >> (ffs(_mask) - 1)) +#define field_prep(_mask, _val) (((_val) << (ffs(_mask) - 1)) & (_mask)) =20 #define NFC_REG_CTL 0x0000 #define NFC_REG_ST 0x0004 @@ -145,8 +146,8 @@ #define NFC_ECC_BLOCK_512 BIT(5) #define NFC_RANDOM_EN BIT(9) #define NFC_RANDOM_DIRECTION BIT(10) -#define NFC_ECC_MODE_MSK GENMASK(15, 12) -#define NFC_ECC_MODE(x) ((x) << 12) +#define NFC_ECC_MODE_MSK(nfc) (nfc->caps->ecc_mode_mask) +#define NFC_ECC_MODE(nfc, x) field_prep(NFC_ECC_MODE_MSK(nfc), (x)) #define NFC_RANDOM_SEED_MSK GENMASK(30, 16) #define NFC_RANDOM_SEED(x) ((x) << 16) =20 @@ -227,6 +228,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @reg_ecc_err_cnt: ECC error counter register * @reg_user_data: User data register * @reg_pat_found: Data Pattern Status Register + * @ecc_mode_mask: ECC_MODE mask in NFC_ECC_CTL register * @pat_found_mask: ECC_PAT_FOUND mask in NFC_REG_PAT_FOUND register * @dma_maxburst: DMA maxburst * @ecc_strengths: Available ECC strengths array @@ -239,6 +241,7 @@ struct sunxi_nfc_caps { unsigned int reg_ecc_err_cnt; unsigned int reg_user_data; unsigned int reg_pat_found; + unsigned int ecc_mode_mask; unsigned int pat_found_mask; unsigned int dma_maxburst; const u8 *ecc_strengths; @@ -1747,7 +1750,7 @@ static int sunxi_nand_hw_ecc_ctrl_init(struct nand_ch= ip *nand, ecc->read_oob_raw =3D nand_read_oob_std; ecc->write_oob_raw =3D nand_write_oob_std; =20 - sunxi_nand->ecc.ecc_ctl =3D NFC_ECC_MODE(i) | NFC_ECC_EXCEPTION | + sunxi_nand->ecc.ecc_ctl =3D NFC_ECC_MODE(nfc, i) | NFC_ECC_EXCEPTION | NFC_ECC_PIPELINE | NFC_ECC_EN; =20 if (ecc->size =3D=3D 512) { @@ -2217,6 +2220,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, .reg_pat_found =3D NFC_REG_ECC_ST, + .ecc_mode_mask =3D GENMASK(15, 12), .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 4, .ecc_strengths =3D sunxi_ecc_strengths_a10, @@ -2230,6 +2234,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, .reg_pat_found =3D NFC_REG_ECC_ST, + .ecc_mode_mask =3D GENMASK(15, 12), .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 8, .ecc_strengths =3D sunxi_ecc_strengths_a10, From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1DB8F2FAC1E for ; Mon, 20 Oct 2025 10:14:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955245; cv=none; b=MieMlsXsXWOf/bgo3nqSB0qFH2bImkCVhrezoo3IbKacAdr2m18SGKGIRlMtwK5UvhIPuf6avkTmyYzaSHelTRHv+oEbxPCnkIuCwvaM9UlujA3KmX0cQ8MMuVALvdGQ0aKiki41DfBmZa2kTh6cScp3b7zFu61Nzj2pRP6CofY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955245; c=relaxed/simple; bh=8RyYfMa0gCTCjCsj5gpn/gbj5bBb2rdSiCdY8PgxtDo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=NagjrDOVFB+JMWrppzKfRDjcrOcSrBpbeij51J0FjOuEGcxom43TwwDV3F1c4eJnt4eCtHHEumpGtvB3Ndj3yCXuORT3QDXYIuHuyUd/Z/Q71/jEZSMHxdpBYDUXObWRqy9lcZ/r42uXkxDXIJ9Apsalq1DOATYM+jOkFO3r1AE= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=FPONONTu; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="FPONONTu" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 07304C0AFE3; Mon, 20 Oct 2025 10:13:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 8CD3A606D5; Mon, 20 Oct 2025 10:14:01 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 045D3102F23BA; Mon, 20 Oct 2025 12:13:58 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955240; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=O08ZQU7nzCm/CtBp+vh3SNifDt7t1M3uvSj4nDW/Pxk=; b=FPONONTu17DwjtFqnXc2CrtRVoFYP3Z81o35ENOszAxPICHAYiYlmpSFlBqtMJJTxAADye LjORyswaTFoo3p4deGa0ec0V0qtrz0fNgEvpmCjwOHUhq0QX85bI+YdfUUR8jkPMiY0u0F ilj70weAte5mxiRn+N8+vQUZF6AZXIqT0gLh6NJl60h134joxd0XLm1DybV4ceZWzA623R jDddQn4sRbQuFQdUyVG3rK5G0EU5scwMMQV++vLxUrFyCBWHOc4/i3slBwr74gALWja+nf gCHJy0OQkRQyZTb+nsZ1FYy+NFRRrhR7GAry/a3fOVLVoZee8FVSHXMAllxZjg== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 08/15] mtd: rawnand: sunxi: introduce random en/dir in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:13:04 +0200 Message-ID: <20251020101311.256819-9-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 RANDOM EN/DIRECTION masks are different from A10/A23. So move the masks into sunxi_nfc_caps. No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index 4118307cac15..3ccb7ea7cf17 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -144,8 +144,8 @@ #define NFC_ECC_EXCEPTION BIT(4) #define NFC_ECC_BLOCK_SIZE_MSK BIT(5) #define NFC_ECC_BLOCK_512 BIT(5) -#define NFC_RANDOM_EN BIT(9) -#define NFC_RANDOM_DIRECTION BIT(10) +#define NFC_RANDOM_EN(nfc) (nfc->caps->random_en_mask) +#define NFC_RANDOM_DIRECTION(nfc) (nfc->caps->random_dir_mask) #define NFC_ECC_MODE_MSK(nfc) (nfc->caps->ecc_mode_mask) #define NFC_ECC_MODE(nfc, x) field_prep(NFC_ECC_MODE_MSK(nfc), (x)) #define NFC_RANDOM_SEED_MSK GENMASK(30, 16) @@ -228,6 +228,8 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @reg_ecc_err_cnt: ECC error counter register * @reg_user_data: User data register * @reg_pat_found: Data Pattern Status Register + * @random_en_mask: RANDOM_EN mask in NFC_ECC_CTL register + * @random_dir_mask: RANDOM_DIRECTION mask in NFC_ECC_CTL register * @ecc_mode_mask: ECC_MODE mask in NFC_ECC_CTL register * @pat_found_mask: ECC_PAT_FOUND mask in NFC_REG_PAT_FOUND register * @dma_maxburst: DMA maxburst @@ -241,6 +243,8 @@ struct sunxi_nfc_caps { unsigned int reg_ecc_err_cnt; unsigned int reg_user_data; unsigned int reg_pat_found; + unsigned int random_en_mask; + unsigned int random_dir_mask; unsigned int ecc_mode_mask; unsigned int pat_found_mask; unsigned int dma_maxburst; @@ -669,7 +673,7 @@ static void sunxi_nfc_randomizer_enable(struct nand_chi= p *nand) if (!(nand->options & NAND_NEED_SCRAMBLING)) return; =20 - writel(readl(nfc->regs + NFC_REG_ECC_CTL) | NFC_RANDOM_EN, + writel(readl(nfc->regs + NFC_REG_ECC_CTL) | NFC_RANDOM_EN(nfc), nfc->regs + NFC_REG_ECC_CTL); } =20 @@ -680,7 +684,7 @@ static void sunxi_nfc_randomizer_disable(struct nand_ch= ip *nand) if (!(nand->options & NAND_NEED_SCRAMBLING)) return; =20 - writel(readl(nfc->regs + NFC_REG_ECC_CTL) & ~NFC_RANDOM_EN, + writel(readl(nfc->regs + NFC_REG_ECC_CTL) & ~NFC_RANDOM_EN(nfc), nfc->regs + NFC_REG_ECC_CTL); } =20 @@ -2220,6 +2224,8 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, .reg_pat_found =3D NFC_REG_ECC_ST, + .random_en_mask =3D BIT(9), + .random_dir_mask =3D BIT(10), .ecc_mode_mask =3D GENMASK(15, 12), .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 4, @@ -2234,6 +2240,8 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, .reg_pat_found =3D NFC_REG_ECC_ST, + .random_en_mask =3D BIT(9), + .random_dir_mask =3D BIT(10), .ecc_mode_mask =3D GENMASK(15, 12), .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 8, From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A1E712FB619 for ; Mon, 20 Oct 2025 10:14:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955246; cv=none; b=ChJJxiAKymxp2eQgtTeU/t/yVAfTXSATex4ySc+WsyR1HJNkELiK7a5IAdZ3haCpC3d2GlrQMoIr2Qex+QM64De1JkiHuFCg4ZEGSulteQoa5TjbbHnQkWFpKx7D91mA5nkDV3CWtmj0CJr1a3+5/FdOEqjSpzebeOzuPrJDhB0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955246; c=relaxed/simple; bh=QyBTlu0fjJBUYPzb88kv3Rt5dUWVEWEhPD5eAWj5Qc4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=em/VhoD2IzGgoMbJDQIzSHhY75rb65SGWnpPfV25k4VkBcb0ahhvw3emQsJR2ym6X1MJ1JmWEoWY4Rf4+sMkcoH7EcUvIw4LGBr5G5ay3wk9mzmE0NnhU2wT/zSFL/9bWHsUAF2+onopigeGLZqK8htWeg6MXRxoODTCyMNlMSs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=vOoGI1qw; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="vOoGI1qw" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 444101A1542; Mon, 20 Oct 2025 10:14:03 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 1A7F2606D5; Mon, 20 Oct 2025 10:14:03 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id BFB4E102F23BB; Mon, 20 Oct 2025 12:14:00 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955242; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=RRPaMbfJAZI7RCNqN6ObTFqj0JMSPmSj/5WzMmnBcMY=; b=vOoGI1qw7DlFId+6s4UIXGc8HxyTrsHYuV+RFf09g+/FQJWRrRh7G9peN4Vl0fMHBR52bt bfAYo8SdagcwSN3yYknuv9a8nneVVLjFnetXoaesAIhT3+cXS+RuZr2LdYLvbXDg3MMoc9 +tKEOv5iLN55QQxB4Xhdv9TQx0BfuzaMso9qFBq6u0VrM/c1Uc6Vqy/WgzYm8ffEt1VvYZ Mah0BCuBi94fxM48rmVZKAKYa9nnch7xXYUNdBgmR73uddi5ampY10RQUXdhlMwanpJEcH MPE0mSlxbIluXNb6vXOqn7JlDVVeozVm7jVXKhWtm4PEZVuZHKkGXm91Bj8xbQ== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 09/15] mtd: rawnand: sunxi: introduce reg_pat_id in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:13:05 +0200 Message-ID: <20251020101311.256819-10-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 pattern ID register is not at the same offset as the A10/A23 one, so move its offset into sunxi_nfc_caps. No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index 3ccb7ea7cf17..e8c08f0139d2 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -55,7 +55,8 @@ #define NFC_REG_A10_USER_DATA 0x0050 #define NFC_REG_USER_DATA(nfc, x) (nfc->caps->reg_user_data + ((x) * 4)) #define NFC_REG_SPARE_AREA 0x00A0 -#define NFC_REG_PAT_ID 0x00A4 +#define NFC_REG_PAT_ID(nfc) (nfc->caps->reg_pat_id) +#define NFC_REG_A10_PAT_ID 0x00A4 #define NFC_REG_MDMA_ADDR 0x00C0 #define NFC_REG_MDMA_CNT 0x00C4 #define NFC_RAM0_BASE 0x0400 @@ -227,6 +228,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @reg_io_data: I/O data register * @reg_ecc_err_cnt: ECC error counter register * @reg_user_data: User data register + * @reg_pat_id: Pattern ID Register * @reg_pat_found: Data Pattern Status Register * @random_en_mask: RANDOM_EN mask in NFC_ECC_CTL register * @random_dir_mask: RANDOM_DIRECTION mask in NFC_ECC_CTL register @@ -242,6 +244,7 @@ struct sunxi_nfc_caps { unsigned int reg_io_data; unsigned int reg_ecc_err_cnt; unsigned int reg_user_data; + unsigned int reg_pat_id; unsigned int reg_pat_found; unsigned int random_en_mask; unsigned int random_dir_mask; @@ -803,7 +806,7 @@ static int sunxi_nfc_hw_ecc_correct(struct nand_chip *n= and, u8 *data, u8 *oob, if (pattern_found & BIT(step)) { u8 pattern; =20 - if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID) & 0x1))) { + if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID(nfc)) & 0x1))) { pattern =3D 0x0; } else { pattern =3D 0xff; @@ -2223,6 +2226,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { .reg_io_data =3D NFC_REG_A10_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, + .reg_pat_id =3D NFC_REG_A10_PAT_ID, .reg_pat_found =3D NFC_REG_ECC_ST, .random_en_mask =3D BIT(9), .random_dir_mask =3D BIT(10), @@ -2239,6 +2243,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .reg_io_data =3D NFC_REG_A23_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, + .reg_pat_id =3D NFC_REG_A10_PAT_ID, .reg_pat_found =3D NFC_REG_ECC_ST, .random_en_mask =3D BIT(9), .random_dir_mask =3D BIT(10), From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 172212FBDF3 for ; Mon, 20 Oct 2025 10:14:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955249; cv=none; b=C/jU0Ko52/q1V1nZ6b8M/VPxbfiTlTg2QcPz9zG0YmKSeE+iDjzJOsj+S78eNUQwDuqmJ8dVaGakTK2i6irtL5Ey4S73lPTSZvB/1uFwbtsieHEoFaMCZKFQuMx+Xk35+aQOokkCQsfj2OSgnAF4uQfwC884qGBQklyn1DaOPfE= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955249; c=relaxed/simple; bh=MFyDMcWCo+UWJUpYXu4+2EBMuo5mynEUx0dy7DIkUfU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=drRmtphOGzIfr8Ksyp0zukukAEc8smh7si8P29dZWVMKlEyfUQ8KUojrM2IHnG/GxdZ3NMfSHoAN8AxJF60RvUQlJb9n7vnGOnfB51o+lh9tQMsybsHibYwijUQ8bD46mmVZ7vJLrjZRhpDmL7JbSFhKcpVp4D56ynblgedEbdk= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=1i+ActU8; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="1i+ActU8" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 917064E411F4; Mon, 20 Oct 2025 10:14:05 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 649F3606D5; Mon, 20 Oct 2025 10:14:05 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 8DD65102F23BD; Mon, 20 Oct 2025 12:14:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955244; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=SOkpWr5UpB5E+C7Aw7jnme4f1BA7kVlONeX9qzjGraw=; b=1i+ActU835wwY66VgxMHAxYxABmNNEAPjD9z6Ji7ZUKIVUg38G1ndRbOwPE17Js0p52NhW E1Eq+/l8jeYoFQzIxinTMwPq6ePFZPW2A2AgJpHkEnJ6wm3UXdn+qzbWRUlPxsOGlEQQp7 wX7XS/tpMUniw6a6oBXA4KO6/Daqe9SPcH9D2/bnWCiTx3PmLfdIx3FbrVB90FCS22MX9i SEBZC7lCvYhp7ZvHbPmnJGBi7NW3rPyHoBdb3AdOC04dV9ybeWrJ3Iy/lUp08LU70Xd7GK IE59Ks59zd9NvSnLuPONN6kx2Gs4T0KYIOf0mjHCOi6UN698QDA+DKSwbYgfeQ== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 10/15] mtd: rawnand: sunxi: introduce reg_spare_area in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:13:06 +0200 Message-ID: <20251020101311.256819-11-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 spare area register is not at the same offset as the A10/A23 one, so move its offset into sunxi_nfc_caps. No functional change. Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index e8c08f0139d2..da7b8b81d39e 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -54,7 +54,8 @@ #define NFC_REG_ECC_ERR_CNT(nfc, x) ((nfc->caps->reg_ecc_err_cnt + (x)) & = ~0x3) #define NFC_REG_A10_USER_DATA 0x0050 #define NFC_REG_USER_DATA(nfc, x) (nfc->caps->reg_user_data + ((x) * 4)) -#define NFC_REG_SPARE_AREA 0x00A0 +#define NFC_REG_SPARE_AREA(nfc) (nfc->caps->reg_spare_area) +#define NFC_REG_A10_SPARE_AREA 0x00A0 #define NFC_REG_PAT_ID(nfc) (nfc->caps->reg_pat_id) #define NFC_REG_A10_PAT_ID 0x00A4 #define NFC_REG_MDMA_ADDR 0x00C0 @@ -228,6 +229,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @reg_io_data: I/O data register * @reg_ecc_err_cnt: ECC error counter register * @reg_user_data: User data register + * @reg_spare_area: Spare Area Register * @reg_pat_id: Pattern ID Register * @reg_pat_found: Data Pattern Status Register * @random_en_mask: RANDOM_EN mask in NFC_ECC_CTL register @@ -244,6 +246,7 @@ struct sunxi_nfc_caps { unsigned int reg_io_data; unsigned int reg_ecc_err_cnt; unsigned int reg_user_data; + unsigned int reg_spare_area; unsigned int reg_pat_id; unsigned int reg_pat_found; unsigned int random_en_mask; @@ -466,7 +469,7 @@ static void sunxi_nfc_select_chip(struct nand_chip *nan= d, unsigned int cs) if (sel->rb >=3D 0) ctl |=3D NFC_RB_SEL(sel->rb); =20 - writel(mtd->writesize, nfc->regs + NFC_REG_SPARE_AREA); + writel(mtd->writesize, nfc->regs + NFC_REG_SPARE_AREA(nfc)); =20 if (nfc->clk_rate !=3D sunxi_nand->clk_rate) { clk_set_rate(nfc->mod_clk, sunxi_nand->clk_rate); @@ -2226,6 +2229,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { .reg_io_data =3D NFC_REG_A10_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, + .reg_spare_area =3D NFC_REG_A10_SPARE_AREA, .reg_pat_id =3D NFC_REG_A10_PAT_ID, .reg_pat_found =3D NFC_REG_ECC_ST, .random_en_mask =3D BIT(9), @@ -2243,6 +2247,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .reg_io_data =3D NFC_REG_A23_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, + .reg_spare_area =3D NFC_REG_A10_SPARE_AREA, .reg_pat_id =3D NFC_REG_A10_PAT_ID, .reg_pat_found =3D NFC_REG_ECC_ST, .random_en_mask =3D BIT(9), From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9FF0F2FC003 for ; Mon, 20 Oct 2025 10:14:08 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955250; cv=none; b=ATywifpOYDYk4VKjCCtib2I0EqEXGWKw6DpAZwy0SwPtlwHvjY3whV08fgeFM+qwZhYCkj0H0Le8XCKZ0y0I4CUdPW2TKyMpuyA9BQhptAFuz2yFznfmTet3bo2zU9Fus24DZW2xF24nPAN76GDNy53AbyAIU2iqG/v2aKuf6Zg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955250; c=relaxed/simple; bh=vo2EsEgL5782s2PoyUx3Sbpe6Jv2LpXCh5yn2MGkOTE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OAtsgGijsJhELtFDH3jz8U0pA2EMJp8WH0ElsesdHhZ9ualYqtxjhkmGHMDY9gVAMFa2t6xAkUkpKgwP5iHb0ID8/ibQu+WZS+Q74TJgfVuvuBZyQv27UGzjpB0J9eES7zmG/haPI3GPJlNiP3WO498ro4cLqCYrcNN8h3JcnM4= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=JTi3XvXq; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="JTi3XvXq" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 14F144E411EF; Mon, 20 Oct 2025 10:14:07 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id DEEF6606D5; Mon, 20 Oct 2025 10:14:06 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 85A58102F0848; Mon, 20 Oct 2025 12:14:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955246; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=FMTlrYQnhBYB/I9vVH4uQ6alkyuaVWds87Lxblu5MFA=; b=JTi3XvXqyLRTc+1kHnPUqWRUc9qyZwtWY0VW5qn0J0rDE6U+sZLJTLmaR8LU8yygaX35fJ Uq470RNzBS0TJKthvzrCIbdrpK6i4jU+74OyjQaz9ufFx3GNS7qWim3I+iQ7Flee+ro7KH x+A3/dXToE7lBwsAXWzCh1dgrZ/ySZVcLRPSTxu+2MVYUWfuRqodXv9/t3xOzz1L4+jylC Z8phuAlG4sP6WWhBcAqnFfy9VudrUXoAdYA/JYsb4SxdS06zazNzqE37SNEaVkr4+09y6O wlrEz9X1nNeTj7Z0PwTRDUiq8M++OSn+dDBsAk9bdemWuv0cFzsHuH3x0gtpwA== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 11/15] mtd: rawnand: sunxi: introduce ecc_err_mask in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:13:07 +0200 Message-ID: <20251020101311.256819-12-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 error mask register is bigger than the A10/A23 one, so move its mask into sunxi_nfc_caps. No functional change Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index da7b8b81d39e..3de5642c05a8 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -155,7 +155,7 @@ =20 /* define bit use in NFC_ECC_ST */ #define NFC_ECC_ERR(x) BIT(x) -#define NFC_ECC_ERR_MSK GENMASK(15, 0) +#define NFC_ECC_ERR_MSK(nfc) (nfc->caps->ecc_err_mask) =20 /* * define bit use in NFC_REG_PAT_FOUND @@ -235,6 +235,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @random_en_mask: RANDOM_EN mask in NFC_ECC_CTL register * @random_dir_mask: RANDOM_DIRECTION mask in NFC_ECC_CTL register * @ecc_mode_mask: ECC_MODE mask in NFC_ECC_CTL register + * @ecc_err_mask: NFC_ECC_ERR mask in NFC_ECC_ST register * @pat_found_mask: ECC_PAT_FOUND mask in NFC_REG_PAT_FOUND register * @dma_maxburst: DMA maxburst * @ecc_strengths: Available ECC strengths array @@ -252,6 +253,7 @@ struct sunxi_nfc_caps { unsigned int random_en_mask; unsigned int random_dir_mask; unsigned int ecc_mode_mask; + unsigned int ecc_err_mask; unsigned int pat_found_mask; unsigned int dma_maxburst; const u8 *ecc_strengths; @@ -1030,7 +1032,7 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct na= nd_chip *nand, uint8_t *buf sunxi_nfc_hw_ecc_update_stats(nand, &max_bitflips, ret); } =20 - if (status & NFC_ECC_ERR_MSK) { + if (status & NFC_ECC_ERR_MSK(nfc)) { for (i =3D 0; i < nchunks; i++) { int data_off =3D i * ecc->size; int oob_off =3D i * (ecc->bytes + 4); @@ -2235,6 +2237,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { .random_en_mask =3D BIT(9), .random_dir_mask =3D BIT(10), .ecc_mode_mask =3D GENMASK(15, 12), + .ecc_err_mask =3D GENMASK(15, 0), .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 4, .ecc_strengths =3D sunxi_ecc_strengths_a10, @@ -2253,6 +2256,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .random_en_mask =3D BIT(9), .random_dir_mask =3D BIT(10), .ecc_mode_mask =3D GENMASK(15, 12), + .ecc_err_mask =3D GENMASK(15, 0), .pat_found_mask =3D GENMASK(31, 16), .dma_maxburst =3D 8, .ecc_strengths =3D sunxi_ecc_strengths_a10, From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2EBA22FC034 for ; Mon, 20 Oct 2025 10:14:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.85.4 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955252; cv=none; b=aphfNaqz0ARZVczom7AGVdhDhw2e1ssTT6u5rGyN7mZYnOW/n29Fztn0ReYOc1HM8/ZRHB1vMXbhNXJP/+wa0fmRyIxTI5dFzP4LcWR9WnPSaa710FByz5CiwjK2P0ctBEKlr75mS9WhcMi6GD6l6+ZD6nWa8KXqUoXKKzPQtg8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955252; c=relaxed/simple; bh=K0oYsZ6cFw9iGy8+r3oBcuWDd0/GQbCaKNwulDoAXNU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=K+9b7a1nh5WYpVtMU8NFB5XF1Kh3EDkOEj4TC0y+Cjp7IhzZlkxVlTRtV+g6a0bzSE0fv2LbRNMXSxzoMnMFCNZyhP/V+KNlaT72mToZm99Pli7nI1NIoTteFd+3wItRvLCfdKSUpvWhEygUfdi5zKnhfc0W9utWNfEITQ15SY8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=DquPmCiB; arc=none smtp.client-ip=185.246.85.4 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="DquPmCiB" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id B36134E411F3; Mon, 20 Oct 2025 10:14:09 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 89F5C606D5; Mon, 20 Oct 2025 10:14:09 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 4259D102F23A7; Mon, 20 Oct 2025 12:14:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955248; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=/q4xGfH4m3Ql1gXYgaW0vYtiX8lDvyiypoqOC+0139Y=; b=DquPmCiBk9Tnp6fU5snRMWlqcQ63w9yIbYygg81OT0lH9aKenPFigVZyezfBUpRiVLGppa Zaq2ouiXxyvmAIIbq5ol07Dq/moE6j3MtXHagZR5IXG056GzHKsFJ9ZQBndBxukFypD6hv tyXjBydjabL7o+l0zEW92Vwcfr4P7cv32xN/rO5N+wNo6C0Cezrj8I8oCIZuNzShsYZfQ3 e7O4B4r6Oaq4iIXP4dXSMHYFn/yOi3Q5GPm4sjwGntho6z4T6S26jfFuarDb9omKUg5WFs SKfjaWvYYtymJdLENbujdihi8x1JuYgZjbUWWT2rGXrvU01EZtueSP9/atun9g== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 12/15] mtd: rawnand: sunxi: introduce sram_size in sunxi_nfc_caps Date: Mon, 20 Oct 2025 12:13:08 +0200 Message-ID: <20251020101311.256819-13-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H6/H616 the SRAM is bigger than the A10/A23 one, so move its size into sunxi_nfc_caps. No functional change Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index 3de5642c05a8..e69fb0ac22b8 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -167,8 +167,6 @@ =20 #define NFC_DEFAULT_TIMEOUT_MS 1000 =20 -#define NFC_SRAM_SIZE 1024 - #define NFC_MAX_CS 7 =20 /** @@ -240,6 +238,7 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(str= uct nand_chip *nand) * @dma_maxburst: DMA maxburst * @ecc_strengths: Available ECC strengths array * @nstrengths: Size of @ecc_strengths + * @sram_size: Size of the NAND controller SRAM */ struct sunxi_nfc_caps { bool has_mdma; @@ -258,6 +257,7 @@ struct sunxi_nfc_caps { unsigned int dma_maxburst; const u8 *ecc_strengths; unsigned int nstrengths; + int sram_size; }; =20 /** @@ -495,7 +495,7 @@ static void sunxi_nfc_read_buf(struct nand_chip *nand, = uint8_t *buf, int len) while (len > offs) { bool poll =3D false; =20 - cnt =3D min(len - offs, NFC_SRAM_SIZE); + cnt =3D min(len - offs, nfc->caps->sram_size); =20 ret =3D sunxi_nfc_wait_cmd_fifo_empty(nfc); if (ret) @@ -533,7 +533,7 @@ static void sunxi_nfc_write_buf(struct nand_chip *nand,= const uint8_t *buf, while (len > offs) { bool poll =3D false; =20 - cnt =3D min(len - offs, NFC_SRAM_SIZE); + cnt =3D min(len - offs, nfc->caps->sram_size); =20 ret =3D sunxi_nfc_wait_cmd_fifo_empty(nfc); if (ret) @@ -1861,7 +1861,7 @@ static int sunxi_nfc_exec_subop(struct nand_chip *nan= d, case NAND_OP_DATA_OUT_INSTR: start =3D nand_subop_get_data_start_off(subop, i); remaining =3D nand_subop_get_data_len(subop, i); - cnt =3D min_t(u32, remaining, NFC_SRAM_SIZE); + cnt =3D min_t(u32, remaining, nfc->caps->sram_size); cmd |=3D NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD; =20 if (instr->type =3D=3D NAND_OP_DATA_OUT_INSTR) { @@ -2242,6 +2242,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_caps= =3D { .dma_maxburst =3D 4, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), + .sram_size =3D 1024, }; =20 static const struct sunxi_nfc_caps sunxi_nfc_a23_caps =3D { @@ -2261,6 +2262,7 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_caps= =3D { .dma_maxburst =3D 8, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), + .sram_size =3D 1024, }; =20 static const struct of_device_id sunxi_nfc_ids[] =3D { From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4E8B82FC87A for ; Mon, 20 Oct 2025 10:14:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955254; cv=none; b=HuWY0ZL8bYAPi+2jh2c8foMTJtDuCcd/tU31Et9vfZS4yBY1QqMQgk945n4rguxTD8AgwYgD8W7cpC2De21w5XMYmKeVbh30xbOBv3GQrdtR+xJ8H7lUsmaJCJFyihOJ6RvvY3/dtMxaU3dxR0fbNY1wtKnvuEUai8x1XFq+p2I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955254; c=relaxed/simple; bh=tCvgZz3A9qMBCnDyci2YW0xGEeyAB4Xvf823pyJSvX4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KMnWYHsexn9ECFPhL+FcKP5cPfDkpoqYd0gOmHTIrT9rIaifbBoMijZ97Ktie6qXXczBctZlovFkhINsCBoj8FbMDh4/3j6FQOd9OZc+Ml/NCOY+TEiFcih9NjV/FSAOpNR+7LovjXb1kpstJzuW15NxClW15HLmTjZ5GEDJm50= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=wzu0A98o; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="wzu0A98o" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id 5A375C0AFE6; Mon, 20 Oct 2025 10:13:51 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id E02BC606D5; Mon, 20 Oct 2025 10:14:10 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 6A39D102F23A5; Mon, 20 Oct 2025 12:14:08 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955249; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=GfBP1kczq5JmM9vhXKgYikMwCIZLS/fzBTKxW7m2JPY=; b=wzu0A98ooBwK6a7ehRExjSF7bNObEsHCk0vQ2OMaCKgmEXcRTLX3qTw7WLGM3fmJRYU0/X tPKStFkTmcx1SSIxDd12qgcnSkfuyLo1T+8A8cVlCl5mtk/QG7NWEST4qcdJaWYCg0RoFw iEjLTJUcNmSwF8yTeH5aBY59JzYKSppJgyfQQwca+D/EKaEe5hiUArIREe7KMxxzQJKxjR 9LtfS0NAp3oQqgTEKGvz8/ce4dvtLku2jg1Pqyd3Wu7+M8BBXK62TyX5q7G3OPSsoHyGTH wTGf/eKwr34Yjqty88JMcLZeYt6ymfXVDDeYJVXPakZMiBMQ6Z55Vj1O0jxCEQ== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 13/15] mtd: rawnand: sunxi: Add support for H616 nand controller Date: Mon, 20 Oct 2025 12:13:09 +0200 Message-ID: <20251020101311.256819-14-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H616 nand controller has the same base as A10/A23, with some differences: - mdma is based on chained buffers - its ECC supports up to 80bit per 1024bytes - some registers layouts are a bit different, mainly due do the stronger ECC. - it uses USER_DATA_LEN registers along USER_DATA registers. - it needs a specific clock for ECC and MBUS. Introduce the basic support, with ECC and scrambling, but without DMA/MDMA. Tested on Whatsminer H616 board (with and without scrambling, ECC) Signed-off-by: Richard Genoud --- drivers/mtd/nand/raw/sunxi_nand.c | 190 ++++++++++++++++++++++++++++-- 1 file changed, 182 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/sunxi= _nand.c index e69fb0ac22b8..29d17d4a0913 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -49,17 +49,40 @@ #define NFC_REG_A23_IO_DATA 0x0300 #define NFC_REG_ECC_CTL 0x0034 #define NFC_REG_ECC_ST 0x0038 -#define NFC_REG_DEBUG 0x003C +#define NFC_REG_H6_PAT_FOUND 0x003C #define NFC_REG_A10_ECC_ERR_CNT 0x0040 +#define NFC_REG_H6_ECC_ERR_CNT 0x0050 #define NFC_REG_ECC_ERR_CNT(nfc, x) ((nfc->caps->reg_ecc_err_cnt + (x)) & = ~0x3) +#define NFC_REG_H6_RDATA_CTL 0x0044 +#define NFC_REG_H6_RDATA_0 0x0048 +#define NFC_REG_H6_RDATA_1 0x004C #define NFC_REG_A10_USER_DATA 0x0050 +#define NFC_REG_H6_USER_DATA 0x0080 #define NFC_REG_USER_DATA(nfc, x) (nfc->caps->reg_user_data + ((x) * 4)) +#define NFC_REG_H6_USER_DATA_LEN 0x0070 +/* A USER_DATA_LEN register can hold the length of 8 USER_DATA registers */ +#define NFC_REG_USER_DATA_LEN_CAPACITY 8 +#define NFC_REG_USER_DATA_LEN(nfc, step) \ + (nfc->caps->reg_user_data_len + \ + ((step) / NFC_REG_USER_DATA_LEN_CAPACITY) * 4) #define NFC_REG_SPARE_AREA(nfc) (nfc->caps->reg_spare_area) #define NFC_REG_A10_SPARE_AREA 0x00A0 #define NFC_REG_PAT_ID(nfc) (nfc->caps->reg_pat_id) #define NFC_REG_A10_PAT_ID 0x00A4 #define NFC_REG_MDMA_ADDR 0x00C0 #define NFC_REG_MDMA_CNT 0x00C4 +#define NFC_REG_H6_EFNAND_STATUS 0x0110 +#define NFC_REG_H6_SPARE_AREA 0x0114 +#define NFC_REG_H6_PAT_ID 0x0118 +#define NFC_REG_H6_DDR2_SPEC_CTL 0x011C +#define NFC_REG_H6_NDMA_MODE_CTL 0x0120 +#define NFC_REG_H6_MDMA_DLBA_REG 0x0200 +#define NFC_REG_H6_MDMA_STA 0x0204 +#define NFC_REG_H6_MDMA_INT_MAS 0x0208 +#define NFC_REG_H6_MDMA_DESC_ADDR 0x020C +#define NFC_REG_H6_MDMA_BUF_ADDR 0x0210 +#define NFC_REG_H6_MDMA_CNT 0x0214 + #define NFC_RAM0_BASE 0x0400 #define NFC_RAM1_BASE 0x0800 =20 @@ -71,6 +94,7 @@ #define NFC_BUS_WIDTH_16 (1 << 2) #define NFC_RB_SEL_MSK BIT(3) #define NFC_RB_SEL(x) ((x) << 3) +/* CE_SEL BIT 27 is meant to be used for GPIO chipselect */ #define NFC_CE_SEL_MSK GENMASK(26, 24) #define NFC_CE_SEL(x) ((x) << 24) #define NFC_CE_CTL BIT(6) @@ -89,6 +113,9 @@ #define NFC_STA BIT(4) #define NFC_NATCH_INT_FLAG BIT(5) #define NFC_RB_STATE(x) BIT(x + 8) +#define NFC_RB_STATE_MSK GENMASK(11, 8) +#define NDFC_RDATA_STA_1 BIT(12) +#define NDFC_RDATA_STA_0 BIT(13) =20 /* define bit use in NFC_INT */ #define NFC_B2R_INT_ENABLE BIT(0) @@ -100,6 +127,7 @@ =20 /* define bit use in NFC_TIMING_CTL */ #define NFC_TIMING_CTL_EDO BIT(8) +#define NFC_TIMING_CTL_E_EDO BIT(9) =20 /* define NFC_TIMING_CFG register layout */ #define NFC_TIMING_CFG(tWB, tADL, tWHR, tRHW, tCAD) \ @@ -107,9 +135,15 @@ (((tWHR) & 0x3) << 4) | (((tRHW) & 0x3) << 6) | \ (((tCAD) & 0x7) << 8)) =20 +#define NFC_TIMING_CFG2(tCDQSS, tSC, tCLHZ, tCSS, tWC) \ + ((((tCDQSS) & 0x1) << 11) | (((tSC) & 0x3) << 12) | \ + (((tCLHZ) & 0x3) << 14) | (((tCSS) & 0x3) << 16) | \ + (((tWC) & 0x3) << 18)) + /* define bit use in NFC_CMD */ #define NFC_CMD_LOW_BYTE_MSK GENMASK(7, 0) -#define NFC_CMD_HIGH_BYTE_MSK GENMASK(15, 8) +#define NFC_CMD_HIGH_BYTE_MSK GENMASK(15, 8) // 15-10 reserved on H6 +#define NFC_CMD_ADR_NUM_MSK GENMASK(9, 8) #define NFC_CMD(x) (x) #define NFC_ADR_NUM_MSK GENMASK(18, 16) #define NFC_ADR_NUM(x) (((x) - 1) << 16) @@ -122,6 +156,7 @@ #define NFC_SEQ BIT(25) #define NFC_DATA_SWAP_METHOD BIT(26) #define NFC_ROW_AUTO_INC BIT(27) +#define NFC_H6_SEND_RND_CMD2 BIT(27) #define NFC_SEND_CMD3 BIT(28) #define NFC_SEND_CMD4 BIT(29) #define NFC_CMD_TYPE_MSK GENMASK(31, 30) @@ -133,6 +168,7 @@ #define NFC_READ_CMD_MSK GENMASK(7, 0) #define NFC_RND_READ_CMD0_MSK GENMASK(15, 8) #define NFC_RND_READ_CMD1_MSK GENMASK(23, 16) +#define NFC_RND_READ_CMD2_MSK GENMASK(31, 24) =20 /* define bit use in NFC_WCMD_SET */ #define NFC_PROGRAM_CMD_MSK GENMASK(7, 0) @@ -150,6 +186,9 @@ #define NFC_RANDOM_DIRECTION(nfc) (nfc->caps->random_dir_mask) #define NFC_ECC_MODE_MSK(nfc) (nfc->caps->ecc_mode_mask) #define NFC_ECC_MODE(nfc, x) field_prep(NFC_ECC_MODE_MSK(nfc), (x)) +/* RANDOM_PAGE_SIZE: 0: ECC block size 1: page size */ +#define NFC_A23_RANDOM_PAGE_SIZE BIT(11) +#define NFC_H6_RANDOM_PAGE_SIZE BIT(7) #define NFC_RANDOM_SEED_MSK GENMASK(30, 16) #define NFC_RANDOM_SEED(x) ((x) << 16) =20 @@ -165,6 +204,9 @@ =20 #define NFC_ECC_ERR_CNT(b, x) (((x) >> (((b) % 4) * 8)) & 0xff) =20 +#define NFC_USER_DATA_LEN_MSK(step) \ + (0xf << (((step) % NFC_REG_USER_DATA_LEN_CAPACITY) * 4)) + #define NFC_DEFAULT_TIMEOUT_MS 1000 =20 #define NFC_MAX_CS 7 @@ -224,9 +266,12 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(st= ruct nand_chip *nand) * @has_mdma: Use mbus dma mode, otherwise general dma * through MBUS on A23/A33 needs extra configuration. * @has_ecc_block_512: If the ECC can handle 512B or only 1024B chuncks + * @has_ecc_clk: If the controller needs an ECC clock. + * @has_mbus_clk: If the controller needs a mbus clock. * @reg_io_data: I/O data register * @reg_ecc_err_cnt: ECC error counter register * @reg_user_data: User data register + * @reg_user_data_len: User data length register * @reg_spare_area: Spare Area Register * @reg_pat_id: Pattern ID Register * @reg_pat_found: Data Pattern Status Register @@ -238,14 +283,24 @@ static inline struct sunxi_nand_chip *to_sunxi_nand(s= truct nand_chip *nand) * @dma_maxburst: DMA maxburst * @ecc_strengths: Available ECC strengths array * @nstrengths: Size of @ecc_strengths + * @max_ecc_steps: Maximum supported steps for ECC, this is also the + * number of user data registers + * @user_data_len_tab: Table of lenghts supported by USER_DATA_LEN regist= er + * The table index is the value to set in NFC_USER_DATA_LEN + * registers, and the corresponding value is the number of + * bytes to write + * @nuser_data_tab: Size of @user_data_len_tab * @sram_size: Size of the NAND controller SRAM */ struct sunxi_nfc_caps { bool has_mdma; bool has_ecc_block_512; + bool has_ecc_clk; + bool has_mbus_clk; unsigned int reg_io_data; unsigned int reg_ecc_err_cnt; unsigned int reg_user_data; + unsigned int reg_user_data_len; unsigned int reg_spare_area; unsigned int reg_pat_id; unsigned int reg_pat_found; @@ -257,6 +312,9 @@ struct sunxi_nfc_caps { unsigned int dma_maxburst; const u8 *ecc_strengths; unsigned int nstrengths; + const u8 *user_data_len_tab; + unsigned int nuser_data_tab; + unsigned int max_ecc_steps; int sram_size; }; =20 @@ -268,6 +326,8 @@ struct sunxi_nfc_caps { * @regs: NAND controller registers * @ahb_clk: NAND controller AHB clock * @mod_clk: NAND controller mod clock + * @ecc_clk: NAND controller ECC clock + * @mbus_clk: NAND controller MBUS clock * @reset: NAND controller reset line * @assigned_cs: bitmask describing already assigned CS lines * @clk_rate: NAND controller current clock rate @@ -283,6 +343,8 @@ struct sunxi_nfc { void __iomem *regs; struct clk *ahb_clk; struct clk *mod_clk; + struct clk *ecc_clk; + struct clk *mbus_clk; struct reset_control *reset; unsigned long assigned_cs; unsigned long clk_rate; @@ -764,6 +826,53 @@ static void sunxi_nfc_hw_ecc_get_prot_oob_bytes(struct= nand_chip *nand, u8 *oob, sunxi_nfc_randomize_bbm(nand, page, oob); } =20 +/* + * On H6/H6 the user_data length has to be set in specific registers + * before writing. + */ +static void sunxi_nfc_reset_user_data_len(struct sunxi_nfc *nfc) +{ + int loop_step =3D NFC_REG_USER_DATA_LEN_CAPACITY; + + /* not all SoCs have this register */ + if (!nfc->caps->reg_user_data_len) + return; + + for (int i =3D 0; i < nfc->caps->max_ecc_steps; i +=3D loop_step) + writel(0, nfc->regs + NFC_REG_USER_DATA_LEN(nfc, i)); +} + +static void sunxi_nfc_set_user_data_len(struct sunxi_nfc *nfc, + int len, int step) +{ + bool found =3D false; + u32 val; + int i; + + /* not all SoCs have this register */ + if (!nfc->caps->reg_user_data_len) + return; + + for (i =3D 0; i < nfc->caps->nuser_data_tab; i++) { + if (len =3D=3D nfc->caps->user_data_len_tab[i]) { + found =3D true; + break; + } + } + + if (!found) { + dev_warn(nfc->dev, + "Unsupported length for user data reg: %d\n", len); + return; + } + + val =3D readl(nfc->regs + NFC_REG_USER_DATA_LEN(nfc, step)); + + val &=3D ~NFC_USER_DATA_LEN_MSK(step); + val |=3D field_prep(NFC_USER_DATA_LEN_MSK(step), i); + writel(val, nfc->regs + NFC_REG_USER_DATA_LEN(nfc, step)); +} + static void sunxi_nfc_hw_ecc_set_prot_oob_bytes(struct nand_chip *nand, const u8 *oob, int step, bool bbm, int page) @@ -858,6 +967,8 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct nand_chip= *nand, if (ret) return ret; =20 + sunxi_nfc_reset_user_data_len(nfc); + sunxi_nfc_set_user_data_len(nfc, 4, 0); sunxi_nfc_randomizer_config(nand, page, false); sunxi_nfc_randomizer_enable(nand); writel(NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD | NFC_ECC_OP, @@ -968,6 +1079,8 @@ static int sunxi_nfc_hw_ecc_read_chunks_dma(struct nan= d_chip *nand, uint8_t *buf return ret; =20 sunxi_nfc_hw_ecc_enable(nand); + sunxi_nfc_reset_user_data_len(nfc); + sunxi_nfc_set_user_data_len(nfc, 4, 0); sunxi_nfc_randomizer_config(nand, page, false); sunxi_nfc_randomizer_enable(nand); =20 @@ -1100,6 +1213,8 @@ static int sunxi_nfc_hw_ecc_write_chunk(struct nand_c= hip *nand, =20 sunxi_nfc_randomizer_config(nand, page, false); sunxi_nfc_randomizer_enable(nand); + sunxi_nfc_reset_user_data_len(nfc); + sunxi_nfc_set_user_data_len(nfc, 4, 0); sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, 0, bbm, page); =20 writel(NFC_DATA_TRANS | NFC_DATA_SWAP_METHOD | @@ -1344,10 +1459,12 @@ static int sunxi_nfc_hw_ecc_write_page_dma(struct n= and_chip *nand, if (ret) goto pio_fallback; =20 + sunxi_nfc_reset_user_data_len(nfc); for (i =3D 0; i < ecc->steps; i++) { const u8 *oob =3D nand->oob_poi + (i * (ecc->bytes + 4)); =20 sunxi_nfc_hw_ecc_set_prot_oob_bytes(nand, oob, i, !i, page); + sunxi_nfc_set_user_data_len(nfc, 4, i); } =20 nand_prog_page_begin_op(nand, page, 0, NULL, 0); @@ -2148,6 +2265,10 @@ static int sunxi_nfc_probe(struct platform_device *p= dev) if (irq < 0) return irq; =20 + nfc->caps =3D of_device_get_match_data(dev); + if (!nfc->caps) + return -EINVAL; + nfc->ahb_clk =3D devm_clk_get_enabled(dev, "ahb"); if (IS_ERR(nfc->ahb_clk)) { dev_err(dev, "failed to retrieve ahb clk\n"); @@ -2160,6 +2281,22 @@ static int sunxi_nfc_probe(struct platform_device *p= dev) return PTR_ERR(nfc->mod_clk); } =20 + if (nfc->caps->has_ecc_clk) { + nfc->ecc_clk =3D devm_clk_get_enabled(dev, "ecc"); + if (IS_ERR(nfc->ecc_clk)) { + dev_err(dev, "failed to retrieve ecc clk\n"); + return PTR_ERR(nfc->ecc_clk); + } + } + + if (nfc->caps->has_mbus_clk) { + nfc->mbus_clk =3D devm_clk_get_enabled(dev, "mbus"); + if (IS_ERR(nfc->mbus_clk)) { + dev_err(dev, "failed to retrieve mbus clk\n"); + return PTR_ERR(nfc->mbus_clk); + } + } + nfc->reset =3D devm_reset_control_get_optional_exclusive(dev, "ahb"); if (IS_ERR(nfc->reset)) return PTR_ERR(nfc->reset); @@ -2170,12 +2307,6 @@ static int sunxi_nfc_probe(struct platform_device *p= dev) return ret; } =20 - nfc->caps =3D of_device_get_match_data(&pdev->dev); - if (!nfc->caps) { - ret =3D -EINVAL; - goto out_ahb_reset_reassert; - } - ret =3D sunxi_nfc_rst(nfc); if (ret) goto out_ahb_reset_reassert; @@ -2226,8 +2357,18 @@ static const u8 sunxi_ecc_strengths_a10[] =3D { 16, 24, 28, 32, 40, 48, 56, 60, 64 }; =20 +static const u8 sunxi_ecc_strengths_h6[] =3D { + 16, 24, 28, 32, 40, 44, 48, 52, 56, 60, 64, 68, 72, 76, 80 +}; + +static const u8 sunxi_user_data_len_h6[] =3D { + 0, 4, 8, 12, 16, 20, 24, 28, 32 +}; + static const struct sunxi_nfc_caps sunxi_nfc_a10_caps =3D { .has_ecc_block_512 =3D true, + .has_ecc_clk =3D false, + .has_mbus_clk =3D false, .reg_io_data =3D NFC_REG_A10_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, .reg_user_data =3D NFC_REG_A10_USER_DATA, @@ -2242,11 +2383,14 @@ static const struct sunxi_nfc_caps sunxi_nfc_a10_ca= ps =3D { .dma_maxburst =3D 4, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), + .max_ecc_steps =3D 16, .sram_size =3D 1024, }; =20 static const struct sunxi_nfc_caps sunxi_nfc_a23_caps =3D { .has_mdma =3D true, + .has_ecc_clk =3D false, + .has_mbus_clk =3D false, .has_ecc_block_512 =3D true, .reg_io_data =3D NFC_REG_A23_IO_DATA, .reg_ecc_err_cnt =3D NFC_REG_A10_ECC_ERR_CNT, @@ -2262,9 +2406,35 @@ static const struct sunxi_nfc_caps sunxi_nfc_a23_cap= s =3D { .dma_maxburst =3D 8, .ecc_strengths =3D sunxi_ecc_strengths_a10, .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_a10), + .max_ecc_steps =3D 16, .sram_size =3D 1024, }; =20 +static const struct sunxi_nfc_caps sunxi_nfc_h616_caps =3D { + .has_mdma =3D false, // H616 supports only chained descriptors + .has_ecc_clk =3D true, + .has_mbus_clk =3D true, + .reg_io_data =3D NFC_REG_A23_IO_DATA, + .reg_ecc_err_cnt =3D NFC_REG_H6_ECC_ERR_CNT, + .reg_user_data =3D NFC_REG_H6_USER_DATA, + .reg_user_data_len =3D NFC_REG_H6_USER_DATA_LEN, + .reg_spare_area =3D NFC_REG_H6_SPARE_AREA, + .reg_pat_id =3D NFC_REG_H6_PAT_ID, + .reg_pat_found =3D NFC_REG_H6_PAT_FOUND, + .random_en_mask =3D BIT(5), + .random_dir_mask =3D BIT(6), + .ecc_mode_mask =3D GENMASK(15, 8), + .ecc_err_mask =3D GENMASK(31, 0), + .pat_found_mask =3D GENMASK(31, 0), + .dma_maxburst =3D 8, + .ecc_strengths =3D sunxi_ecc_strengths_h6, + .nstrengths =3D ARRAY_SIZE(sunxi_ecc_strengths_h6), + .user_data_len_tab =3D sunxi_user_data_len_h6, + .nuser_data_tab =3D ARRAY_SIZE(sunxi_user_data_len_h6), + .max_ecc_steps =3D 32, + .sram_size =3D 8192, +}; + static const struct of_device_id sunxi_nfc_ids[] =3D { { .compatible =3D "allwinner,sun4i-a10-nand", @@ -2274,6 +2444,10 @@ static const struct of_device_id sunxi_nfc_ids[] =3D= { .compatible =3D "allwinner,sun8i-a23-nand-controller", .data =3D &sunxi_nfc_a23_caps, }, + { + .compatible =3D "allwinner,sun50i-h616-nand-controller", + .data =3D &sunxi_nfc_h616_caps, + }, { /* sentinel */ } }; MODULE_DEVICE_TABLE(of, sunxi_nfc_ids); From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B8042FC899; Mon, 20 Oct 2025 10:14:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955256; cv=none; b=iJjGh6PHHnnvNHlUswFmvMoN2fFd1xvUsVotBtyD9+Yz34eXsRbvaAyxBkXnUrG+upOVvMn3ZfEJy9Ea1ljUFPD3tnQkQvXr1WP1vJt0IMOiIkFkIqvmQv55r6mKRT5gQ/Et90nrbfhGtvNgfmt00YF4Hka9x9C5tGxw4169a1Q= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955256; c=relaxed/simple; bh=ptMw9CSf8NeiaK7jBVCUOBFfd2vSRsLgkF/FG3xtYrk=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=UPQ23M1SGKBGjB39d4G+4Ms0TukOVdVeHcoeyROzkBxntcGEGrOW6Duuk1bN/HkHtVmlaBEbjiPgZpah6jpk6rCOuo1YtkwQiR1SZpHFZ63mhNCTLX5/G/3BmOMwGzwZEWFF6SE3KoVJs86icTFVRUcq1V/3TCXDWn0Zbmv6uj8= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=c4Ta6UE/; arc=none smtp.client-ip=185.246.84.56 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="c4Ta6UE/" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id 876D21A1537; Mon, 20 Oct 2025 10:14:13 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 5BFFC606D5; Mon, 20 Oct 2025 10:14:13 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 3C2AA102F23AF; Mon, 20 Oct 2025 12:14:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955252; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=EJZx7MjvWZvR+9dhB8zsNC40vJfrlNPlQ8ARjxiScT8=; b=c4Ta6UE/C0O36OnJN8Hs08sr6wpMsXXN+k9RfK9GLKLFJsXb/adbzcS0eAQR3SftGlEnNB gaNdULvdIQgZlNBEINquexRJnCHrIrnMCDx5jezUeHU+IeozY70Fd3ZummPIUEqEm7ROCY AVi5kk9xjAg/HHWOe9ljSuAXqG9Vy2HWFyLYjGsSu5IVmowQMW57/cHJNGpnceLvMQqlKR 05pBIEbomAo1ziXcqb3OJ+Tq68SGsWUZg4vqKm1TawT0dmC3i/E9mijvncOt8aVGVVeAMj weg3XzP3ZN6RTs3M+9zSW6PZVZm4gaxB6pKIUt/8nuVZvf6mk03/6fURDVzpJQ== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 14/15] dt-bindings: mtd: sunxi: Add H616 compatible Date: Mon, 20 Oct 2025 12:13:10 +0200 Message-ID: <20251020101311.256819-15-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H616 NAND controller is quite different from the A10 and A23 ones, some registers offset changed, and some new one are introduced. Also, the DMA handling is different (it uses chained descriptors) So, introduce a new compatible to represent this version of the IP. Signed-off-by: Richard Genoud Acked-by: Conor Dooley --- .../mtd/allwinner,sun4i-a10-nand.yaml | 41 +++++++++++++++++-- 1 file changed, 38 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/mtd/allwinner,sun4i-a10-nand= .yaml b/Documentation/devicetree/bindings/mtd/allwinner,sun4i-a10-nand.yaml index 054b6b8bf9b9..9d061e2216cb 100644 --- a/Documentation/devicetree/bindings/mtd/allwinner,sun4i-a10-nand.yaml +++ b/Documentation/devicetree/bindings/mtd/allwinner,sun4i-a10-nand.yaml @@ -6,9 +6,6 @@ $schema: http://devicetree.org/meta-schemas/core.yaml# =20 title: Allwinner A10 NAND Controller =20 -allOf: - - $ref: nand-controller.yaml - maintainers: - Chen-Yu Tsai - Maxime Ripard @@ -18,6 +15,8 @@ properties: enum: - allwinner,sun4i-a10-nand - allwinner,sun8i-a23-nand-controller + - allwinner,sun50i-h616-nand-controller + reg: maxItems: 1 =20 @@ -25,14 +24,20 @@ properties: maxItems: 1 =20 clocks: + minItems: 2 items: - description: Bus Clock - description: Module Clock + - description: ECC Clock + - description: MBus Clock =20 clock-names: + minItems: 2 items: - const: ahb - const: mod + - const: ecc + - const: mbus =20 resets: maxItems: 1 @@ -85,6 +90,36 @@ required: =20 unevaluatedProperties: false =20 +allOf: + - $ref: nand-controller.yaml + + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun4i-a10-nand + - allwinner,sun8i-a23-nand-controller + then: + properties: + clocks: + maxItems: 2 + clock-names: + maxItems: 2 + + - if: + properties: + compatible: + contains: + enum: + - allwinner,sun50i-h616-nand-controller + then: + properties: + clocks: + minItems: 4 + clock-names: + minItems: 4 + examples: - | #include From nobody Sun Feb 8 02:41:39 2026 Received: from smtpout-04.galae.net (smtpout-04.galae.net [185.171.202.116]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 681792FE567 for ; Mon, 20 Oct 2025 10:14:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.171.202.116 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955258; cv=none; b=oADCkCsHDie5bizvn+X+knJ7h5oxHvJXmWrQbkEwSs70r4G4Z5ERqX67D+sO9BMQC01Cgj5Gk2LAevBvIT0sJMPvSCib5zMhhO0We0ukW96Ldh+MHju6XJkAJ4y5EnPvyYlvo3gCQg/osz2DgYX3fs5MBA/vmtoKyDCHjE3A/CM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1760955258; c=relaxed/simple; bh=GgwJ7fWaulAietrHBtr8pXhbFEbm/bkrRwvdjItYaJI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=XHZO/D9pcXjfl0c1QwIeb2/ERBsT1zD8HOJPmPXzaguNev7Ks9mA8BuCsC++XPUgGl1Vlz2WTCaU5LU+Pwy6QsT5akz6LIiEXM/Sxg5Dtbk7GIVBD7UukhIausrpaqGV4wcVX4pYUFpuE/RzWqf00H5YFum46zN/UVMld/73ddI= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=mOLWAHZM; arc=none smtp.client-ip=185.171.202.116 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="mOLWAHZM" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-04.galae.net (Postfix) with ESMTPS id A8E09C0AFE4; Mon, 20 Oct 2025 10:13:55 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3A2E7606D5; Mon, 20 Oct 2025 10:14:15 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id B2346102F23B3; Mon, 20 Oct 2025 12:14:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760955254; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=rZByAZ4a1Es55m5EId/mrhQ7knVrzCU0ipEljdw7k+I=; b=mOLWAHZMEHaJ5DWrJzd5+jqoy2/ZuEto+BJiYKEPYIpIZznZ1Qpmclm7yQxwlw9M1ZrM4f QntYP/j3GqyB/SyXjRR16YLDSWgkO0vEQWE3zXUCzWYHZ1RBUmq3XAMBtgVf5m3OacbPlF 1LBUPIQp3Ovz4QkHPu8ukKB1TOjDgPxU7aqf3wsAHT7busdUDwGc18E0eUwS/Wyzf68+k3 s2vkBLgrjp000yuOw46dETNd/O81ldxNW15bxro6cfvCCl94KF3oYctxWNsFbEG0JHPQLY IaS36Q+uq5lzXVUouUtuWUlp+z1iVWIi3SSPWg0uKkf1a1gLLnJyaSb9Ve71pw== From: Richard Genoud To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Chen-Yu Tsai , Jernej Skrabec , Samuel Holland Cc: =?UTF-8?q?Uwe=20Kleine-K=C3=B6nig?= , Wentao Liang , Johan Hovold , Maxime Ripard , Thomas Petazzoni , linux-mtd@lists.infradead.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-sunxi@lists.linux.dev, linux-kernel@vger.kernel.org, Richard Genoud Subject: [PATCH v3 15/15] arm64: dts: allwinner: h616: add NAND controller Date: Mon, 20 Oct 2025 12:13:11 +0200 Message-ID: <20251020101311.256819-16-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251020101311.256819-1-richard.genoud@bootlin.com> References: <20251020101311.256819-1-richard.genoud@bootlin.com> 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 X-Last-TLS-Session-Version: TLSv1.3 Content-Type: text/plain; charset="utf-8" The H616 has a NAND controller quite similar to the A10/A23 ones, but with some register differences, more clocks (for ECC and MBUS), more ECC strengths, so this requires a new compatible string. Add the NAND controller node and pins in the device tree. Signed-off-by: Richard Genoud --- .../arm64/boot/dts/allwinner/sun50i-h616.dtsi | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi b/arch/arm64/bo= ot/dts/allwinner/sun50i-h616.dtsi index ceedae9e399b..2a4d70298655 100644 --- a/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi +++ b/arch/arm64/boot/dts/allwinner/sun50i-h616.dtsi @@ -304,6 +304,42 @@ mmc2_pins: mmc2-pins { bias-pull-up; }; =20 + /omit-if-no-ref/ + nand_pins: nand-pins { + pins =3D "PC0", "PC1", "PC2", "PC5", "PC8", "PC9", + "PC10", "PC11", "PC12", "PC13", "PC14", + "PC15", "PC16"; + function =3D "nand0"; + }; + + /omit-if-no-ref/ + nand_cs0_pin: nand-cs0-pin { + pins =3D "PC4"; + function =3D "nand0"; + bias-pull-up; + }; + + /omit-if-no-ref/ + nand_cs1_pin: nand-cs1-pin { + pins =3D "PC3"; + function =3D "nand0"; + bias-pull-up; + }; + + /omit-if-no-ref/ + nand_rb0_pin: nand-rb0-pin { + pins =3D "PC6"; + function =3D "nand0"; + bias-pull-up; + }; + + /omit-if-no-ref/ + nand_rb1_pin: nand-rb1-pin { + pins =3D "PC7"; + function =3D "nand0"; + bias-pull-up; + }; + /omit-if-no-ref/ spi0_pins: spi0-pins { pins =3D "PC0", "PC2", "PC4"; @@ -377,6 +413,22 @@ iommu: iommu@30f0000 { #iommu-cells =3D <1>; }; =20 + nfc: nand-controller@4011000 { + compatible =3D "allwinner,sun50i-h616-nand-controller"; + reg =3D <0x04011000 0x1000>; + interrupts =3D ; + clocks =3D <&ccu CLK_BUS_NAND>, <&ccu CLK_NAND0>, + <&ccu CLK_NAND1>, <&ccu CLK_MBUS_NAND>; + clock-names =3D "ahb", "mod", "ecc", "mbus"; + resets =3D <&ccu RST_BUS_NAND>; + reset-names =3D "ahb"; + dmas =3D <&dma 10>; + dma-names =3D "rxtx"; + #address-cells =3D <1>; + #size-cells =3D <0>; + status =3D "disabled"; + }; + mmc0: mmc@4020000 { compatible =3D "allwinner,sun50i-h616-mmc", "allwinner,sun50i-a100-mmc";