From nobody Fri Dec 19 12:14:58 2025 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 C09732D6E62 for ; Tue, 28 Oct 2025 07:36:19 +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=1761636981; cv=none; b=JzG4JWKiydUuGXQEW2nfh9TFMcMQsXy4BmW2lXa2Km7eA8LHI5YCRY8FPa2+s2bGJ7yDoA1JfEP64OBRYpPGZTeJYjtIh6U+UHdPmkOhxVQQHjn3AwJ+9Yr/ScsAv7nk1jCjOtJ/XF/waCF+KHYNWXHEsBgY1l7pCOihGfJWkSo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1761636981; c=relaxed/simple; bh=EIIOk1ZFP41aAgmYg4hqiLo+aD9DDaXjmZm9zWA+33U=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ItGfwRH3DbQaHo4qZ24cTblriZbo/+n+iGsyB78LBk3dbH3BCSgMjTTvjiwetHASvwIng4juQRQY9lCUnUhVVuM7RP7LAlGsvRxMQd5tlly0EII9swF7HyuCeuy92P/VJc8TxApOhtk68Q6nGmslFivPzWmZ1TNfL+oP7jnmCeQ= 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=gwLIEl3q; 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="gwLIEl3q" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 5B6794E41391; Tue, 28 Oct 2025 07:36:18 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 3117B606AB; Tue, 28 Oct 2025 07:36:18 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 666E4102F251E; Tue, 28 Oct 2025 08:36:15 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1761636977; h=from:subject:date:message-id:to:cc:mime-version: content-transfer-encoding:in-reply-to:references; bh=/M/jMwPlbBN6qYrgDuj/YgdYHhhq/RJErSe+NmtVYeE=; b=gwLIEl3qhp1vCUnO5dzy1L2S3p9jLXPFjc7T2ARYJMU3MSMYoBup16Kv56U0uwwlR7qmnV 4l8+FPG5VeKwPLEA4zkB36fgB7c8niHcuNDhpzWH9tKF2nHyzVQmGohT84T9BzOScjrtns 0I1ApR2M4/5QQWw6krRCsZOvsjG1Qb8tAX2X9ois75FX0opbW3jTIdSX0iCoMMfbC5aots dl7dGoUgd4AjI1Oyrjx/MW1upKAyysrPwvlMukDyzIMHWdt9bKTvYzE1hOND2D2NPup8K8 Ns6d9scVKG4Ri7On4l+5qGz6GE8d+1DdHvNX0ThRsY5ZTdHMDhRKkEhCB+AIuQ== 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 v4 08/16] mtd: rawnand: sunxi: add has_ecc_block_512 capability Date: Tue, 28 Oct 2025 08:35:01 +0100 Message-ID: <20251028073534.526992-9-richard.genoud@bootlin.com> X-Mailer: git-send-email 2.47.3 In-Reply-To: <20251028073534.526992-1-richard.genoud@bootlin.com> References: <20251028073534.526992-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 Reviewed-by: Jernej Skrabec --- 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 021034a761b7..7976cd862b1b 100644 --- a/drivers/mtd/nand/raw/sunxi_nand.c +++ b/drivers/mtd/nand/raw/sunxi_nand.c @@ -233,6 +233,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 @@ -244,6 +245,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; @@ -1758,8 +1760,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; } @@ -2214,6 +2222,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, @@ -2226,6 +2235,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, --=20 2.47.3