public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Richard GENOUD <richard.genoud@bootlin.com>
To: Andre Przywara <andre.przywara@arm.com>,
	Jagan Teki <jagan@amarulasolutions.com>,
	Tom Rini <trini@konsulko.com>,
	Hans de Goede <hdegoede@redhat.com>,
	Lukasz Majewski <lukma@denx.de>,
	Sean Anderson <seanga2@gmail.com>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Michael Trimarchi <michael@amarulasolutions.com>
Cc: Jernej Skrabec <jernej.skrabec@gmail.com>,
	Chen-Yu Tsai <wens@csie.org>,
	Andrey Skvortsov <andrej.skvortzov@gmail.com>,
	Marek Vasut <marek.vasut+renesas@mailbox.org>,
	Anand Gore <anand.gore@broadcom.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	david regan <dregan@broadcom.com>,
	Andrew Goodbody <andrew.goodbody@linaro.org>,
	Miquel Raynal <miquel.raynal@bootlin.com>,
	Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
	u-boot@lists.denx.de
Subject: Re: [PATCH 11/24] mtd: rawnand: sunxi: cosmetic: add has_ecc_block_512 capability
Date: Mon, 20 Oct 2025 09:02:58 +0200	[thread overview]
Message-ID: <3b261c3e-35a8-461d-ab12-bdf9d8ec671e@bootlin.com> (raw)
In-Reply-To: <7faa8c8a-cc41-4108-bee9-ef7e24af94ce@arm.com>

Hi,
Le 18/10/2025 à 01:11, Andre Przywara a écrit :
> Hi,
> 
> On 16/10/2025 15:27, Richard Genoud wrote:
>> Introduce has_ecc_block_512 capability
>>
>> The H616 controller can't handle 512 bytes ECC block size.
>> Let it be a capability.
>>
>> No functional change.
>>
>> Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
>> ---
>>   drivers/mtd/nand/raw/sunxi_nand.c | 14 +++++++++++---
>>   drivers/mtd/nand/raw/sunxi_nand.h |  2 ++
>>   2 files changed, 13 insertions(+), 3 deletions(-)
>>
>> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/ 
>> sunxi_nand.c
>> index 869b3ddd971c..fddb1cada023 100644
>> --- a/drivers/mtd/nand/raw/sunxi_nand.c
>> +++ b/drivers/mtd/nand/raw/sunxi_nand.c
>> @@ -660,11 +660,12 @@ static void sunxi_nfc_hw_ecc_enable(struct 
>> mtd_info *mtd)
>>       u32 ecc_ctl;
>>       ecc_ctl = readl(nfc->regs + NFC_REG_ECC_CTL);
>> -    ecc_ctl &= ~(NFC_ECC_MODE_MSK | NFC_ECC_PIPELINE |
>> -             NFC_ECC_BLOCK_SIZE_MSK);
>> +    ecc_ctl &= ~(NFC_ECC_MODE_MSK | NFC_ECC_PIPELINE);
>> +    if (nfc->caps->has_ecc_block_512)
>> +        ecc_ctl &= ~NFC_ECC_BLOCK_SIZE_MSK;
> 
> So if I get this correctly, then NFC_ECC_BLOCK_SIZE_MSK and 
> NFC_ECC_BLOCK_512 are referring to the same single bit register field, 
> in bit 5? Can we lose the MSK definition then, and clear the field 
> unconditionally? Or is it that on the H6/H616 we must never touch bit 5, 
> because it refers to something else (NDFC_RANDOM_EN?)?
> In any case I think we don't need identical MSK and BLOCK_512 
> definitions, do we?
Yes, 2nd case:
On A23/A10, the bit 5 (NFC_ECC_BLOCK_512) in NDFC_ECC_CTL register 
(0x34) is controlling the size of one ECC data block (0: 1024bytes 1:512 
bytes).
On H6, this bit NFC_ECC_BLOCK_512 doesn't exists anymore, but instead, 
bit 5 of NDFC_ECC_CTL register (0x34) is NDFC_RANDOM_EN (which was 
itself on bit 9 for A10/A23)
So yes, we can definitely loose NFC_ECC_BLOCK_SIZE_MSK, and keep 
has_ecc_block_512 to differentiate A10 from H6.

> 
> By the way: Do you have any MMIO frame register description for the old 
> NAND device? I checked some of the older manuals, but the ones I looked 
> at were only showing timing diagrams, but no register map.
Yes, the NAND controller in A33 is the same (AFAIK) than on A23:
https://linux-sunxi.org/images/4/49/A33_Nand_Flash_Controller_Specification.pdf


Thanks!

> 
> Cheers,
> Andre
> 
>>       ecc_ctl |= NFC_ECC_EN | NFC_ECC_MODE(data->mode) | 
>> NFC_ECC_EXCEPTION;
>> -    if (nand->ecc.size == 512)
>> +    if (nand->ecc.size == 512 && nfc->caps->has_ecc_block_512)
>>           ecc_ctl |= NFC_ECC_BLOCK_512;
>>       writel(ecc_ctl, nfc->regs + NFC_REG_ECC_CTL);
>> @@ -1454,6 +1455,8 @@ static void sunxi_nand_ecc_cleanup(struct 
>> nand_ecc_ctrl *ecc)
>>   static int sunxi_nand_ecc_init(struct mtd_info *mtd, struct 
>> nand_ecc_ctrl *ecc)
>>   {
>>       struct nand_chip *nand = mtd_to_nand(mtd);
>> +    struct sunxi_nand_chip *sunxi_nand = to_sunxi_nand(nand);
>> +    struct sunxi_nfc *nfc = to_sunxi_nfc(sunxi_nand->nand.controller);
>>       int ret;
>>       if (!ecc->size) {
>> @@ -1464,6 +1467,10 @@ static int sunxi_nand_ecc_init(struct mtd_info 
>> *mtd, struct nand_ecc_ctrl *ecc)
>>       if (!ecc->size || !ecc->strength)
>>           return -EINVAL;
>> +    /* If 512B ECC is not supported, switch to 1024 */
>> +    if (ecc->size == 512 && !nfc->caps->has_ecc_block_512)
>> +        ecc->size = 1024;
>> +
>>       switch (ecc->mode) {
>>       case NAND_ECC_SOFT_BCH:
>>           break;
>> @@ -1715,6 +1722,7 @@ static int sunxi_nand_probe(struct udevice *dev)
>>   }
>>   static const struct sunxi_nfc_caps sunxi_nfc_a10_caps = {
>> +    .has_ecc_block_512 = true,
>>       .nstrengths = 9,
>>       .reg_ecc_err_cnt = NFC_REG_A10_ECC_ERR_CNT,
>>       .reg_user_data = NFC_REG_A10_USER_DATA,
>> diff --git a/drivers/mtd/nand/raw/sunxi_nand.h b/drivers/mtd/nand/raw/ 
>> sunxi_nand.h
>> index 35079d37bb1f..be294d7cea0a 100644
>> --- a/drivers/mtd/nand/raw/sunxi_nand.h
>> +++ b/drivers/mtd/nand/raw/sunxi_nand.h
>> @@ -169,6 +169,7 @@
>>    * NAND Controller capabilities structure: stores NAND controller 
>> capabilities
>>    * for distinction between compatible strings.
>>    *
>> + * @has_ecc_block_512:    If the ECC can handle 512B or only 1024B 
>> chuncks
>>    * @nstrengths:        Number of element of ECC strengths array
>>    * @reg_ecc_err_cnt:    ECC error counter register
>>    * @reg_user_data:    User data register
>> @@ -176,6 +177,7 @@
>>    * @pat_found_mask:    ECC_PAT_FOUND mask in NFC_REG_PAT_FOUND register
>>    */
>>   struct sunxi_nfc_caps {
>> +    bool has_ecc_block_512;
>>       unsigned int nstrengths;
>>       unsigned int reg_ecc_err_cnt;
>>       unsigned int reg_user_data;
> 


-- 
Richard Genoud, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com

  reply	other threads:[~2025-10-20  7:03 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-16 14:27 [PATCH 00/24] Introduce Allwinner H6/H616 NAND controller support Richard Genoud
2025-10-16 14:27 ` [PATCH 01/24] mtd: rawnand: sunxi: cosmetic: remove needless comment Richard Genoud
2025-10-17  7:56   ` Andre Przywara
2025-10-16 14:27 ` [PATCH 02/24] mtd: rawnand: sunxi_spl: fix pointer from integer without a cast Richard Genoud
2025-10-17  7:57   ` Andre Przywara
2025-10-17 12:48     ` Richard GENOUD
2025-10-16 14:27 ` [PATCH 03/24] mtd: rawnand: sunxi_spl: cosmetic: harmonize register defines with non spl file Richard Genoud
2025-10-17  7:57   ` Andre Przywara
2025-10-17 14:22     ` Richard GENOUD
2025-10-17 14:27       ` Andre Przywara
2025-10-16 14:27 ` [PATCH 04/24] mtd: rawnand: sunxi_spl: cosmetic: use definitions from linux/mtd/rawnand.h Richard Genoud
2025-10-17  9:35   ` Andre Przywara
2025-10-16 14:27 ` [PATCH 05/24] mtd: rawnand: sunxi_spl: cosmetic: replace AHB_DIV_1 by CCM_NAND_CTRL_M/N Richard Genoud
2025-10-17  9:36   ` Andre Przywara
2025-10-17 14:26     ` Richard GENOUD
2025-10-16 14:27 ` [PATCH 06/24] mtd: rawnand: sunxi: cosmetic: merge register definitions for sunxi_nand{, _spl}.c Richard Genoud
2025-10-17 23:09   ` [PATCH 06/24] mtd: rawnand: sunxi: cosmetic: merge register definitions for sunxi_nand{,_spl}.c Andre Przywara
2025-10-16 14:27 ` [PATCH 07/24] mtd: rawnand: sunxi: cosmetic: add per SoC capabilities Richard Genoud
2025-10-17 23:10   ` Andre Przywara
2025-10-16 14:27 ` [PATCH 08/24] mtd: rawnand: sunxi: cosmetic: move ECC_ERR_CNT register offset in SoC caps Richard Genoud
2025-10-17 23:10   ` Andre Przywara
2025-10-16 14:27 ` [PATCH 09/24] mtd: rawnand: sunxi: cosmetic: move USER_DATA " Richard Genoud
2025-10-17 23:10   ` Andre Przywara
2025-10-16 14:27 ` [PATCH 10/24] mtd: rawnand: sunxi: cosmetic: move ECC_PAT_FOUND register " Richard Genoud
2025-10-17 23:11   ` Andre Przywara
2025-10-20  6:46     ` Richard GENOUD
2025-10-16 14:27 ` [PATCH 11/24] mtd: rawnand: sunxi: cosmetic: add has_ecc_block_512 capability Richard Genoud
2025-10-17 23:11   ` Andre Przywara
2025-10-20  7:02     ` Richard GENOUD [this message]
2025-10-16 14:27 ` [PATCH 12/24] mtd: rawnand: sunxi: cosmetic: move NFC_ECC_MODE offset in SoC caps Richard Genoud
2025-10-16 14:27 ` [PATCH 13/24] mtd: rawnand: sunxi: cosmetic: introduce reg_pat_id in sunxi_nfc_caps Richard Genoud
2025-10-16 14:27 ` [PATCH 14/24] mtd: rawnand: sunxi_spl: cosmetic: add per SoC capabilities Richard Genoud
2025-10-16 14:27 ` [PATCH 15/24] mtd: rawnand: sunxi: cosmetic: move NFC_RANDOM_EN register offset in SoC caps Richard Genoud
2025-10-16 14:27 ` [PATCH 16/24] mtd: rawnand: sunxi: cosmetic: introduce reg_spare_area in sunxi_nfc_caps Richard Genoud
2025-10-16 14:27 ` [PATCH 17/24] mtd: rawnand: sunxi_spl: use NFC_ECC_ERR_MSK and NFC_ECC_PAT_FOUND Richard Genoud
2025-10-16 14:27 ` [PATCH 18/24] mtd: rawnand: sunxi_spl: increase max_oobsize for 2KiB pages Richard Genoud
2025-10-16 14:27 ` [PATCH 19/24] mtd: rawnand: sunxi_spl: cosmetic: use NFC_ECC_MODE and NFC_RANDOM_SEED macros Richard Genoud
2025-10-16 14:27 ` [PATCH 20/24] sunxi: clock: H6: add NAND controller clock registers Richard Genoud
2025-10-16 14:27 ` [PATCH 21/24] clk: sunxi: Add MBUS Master Clock Gating Register Richard Genoud
2025-10-16 14:27 ` [PATCH 22/24] mtd: rawnand: sunxi: add support for H6/H616 nand controller Richard Genoud
2025-10-20 14:05   ` Richard GENOUD
2025-10-16 14:27 ` [PATCH 23/24] mtd: rawnand: sunxi_spl: " Richard Genoud
2025-10-16 14:27 ` [PATCH 24/24] mtd: rawnand: sunxi_spl: Fix cast to pointer from integer warnings Richard Genoud

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3b261c3e-35a8-461d-ab12-bdf9d8ec671e@bootlin.com \
    --to=richard.genoud@bootlin.com \
    --cc=anand.gore@broadcom.com \
    --cc=andre.przywara@arm.com \
    --cc=andrej.skvortzov@gmail.com \
    --cc=andrew.goodbody@linaro.org \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=dregan@broadcom.com \
    --cc=hdegoede@redhat.com \
    --cc=jagan@amarulasolutions.com \
    --cc=jernej.skrabec@gmail.com \
    --cc=linus.walleij@linaro.org \
    --cc=lukma@denx.de \
    --cc=marek.vasut+renesas@mailbox.org \
    --cc=michael@amarulasolutions.com \
    --cc=miquel.raynal@bootlin.com \
    --cc=seanga2@gmail.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=wens@csie.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox