From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 925C0CCD193 for ; Mon, 20 Oct 2025 06:46:28 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E94DD82C84; Mon, 20 Oct 2025 08:46:26 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=bootlin.com header.i=@bootlin.com header.b="KhjP1jxw"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 5C05582E34; Mon, 20 Oct 2025 08:46:26 +0200 (CEST) Received: from smtpout-03.galae.net (smtpout-03.galae.net [185.246.85.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id C3084807C0 for ; Mon, 20 Oct 2025 08:46:23 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=richard.genoud@bootlin.com Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-03.galae.net (Postfix) with ESMTPS id 226FD4E411D6; Mon, 20 Oct 2025 06:46:23 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id BEDC5606D5; Mon, 20 Oct 2025 06:46:22 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 09DB5102F238E; Mon, 20 Oct 2025 08:46:02 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1760942777; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:content-language:in-reply-to:references; bh=jkNn3whwZJL8loFbi/pknmWbrXgHUCjZPg5og50XROg=; b=KhjP1jxwGN5XP++NURmpOQAY1hDu1Nb5b1sY0BThRzfcx0i+m1StLbRz1Ceyip6NjblriL OOehLhdgSzmqMv1eYP4J1zwlcujo6lQVbDHIya+Z+6SoX0R+wcnVNRF3R5kiLXwHSA9a1P 8ktufBFCN55yvgTJ7g4cHu4baqm+taHQ/9wY8NQ3hKu6fx8Sx3zZdBEXyNAyAliJ+58wxh Y9XeAhGSj9OYFEc9Xg8LsC0sypBQvUVlt6THK8RqLTD9qJ5N1VRhankJ9pjgJt0nblyMC7 mambXVMxXjeCDLZUwIUDp4kooA/hR6jWXuNbcvdnGHxd7joy8cG2AyEoOeN1zg== Message-ID: Date: Mon, 20 Oct 2025 08:46:01 +0200 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 10/24] mtd: rawnand: sunxi: cosmetic: move ECC_PAT_FOUND register in SoC caps To: Andre Przywara , Jagan Teki , Tom Rini , Hans de Goede , Lukasz Majewski , Sean Anderson , Dario Binacchi , Michael Trimarchi Cc: Jernej Skrabec , Chen-Yu Tsai , Andrey Skvortsov , Marek Vasut , Anand Gore , Linus Walleij , david regan , Andrew Goodbody , Miquel Raynal , Thomas Petazzoni , u-boot@lists.denx.de References: <20251016142752.2627710-1-richard.genoud@bootlin.com> <20251016142752.2627710-11-richard.genoud@bootlin.com> <16241b87-7589-40ff-9280-cbacf32dc227@arm.com> From: Richard GENOUD Content-Language: en-US, fr Organization: Bootlin In-Reply-To: <16241b87-7589-40ff-9280-cbacf32dc227@arm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Last-TLS-Session-Version: TLSv1.3 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean Hi, Le 18/10/2025 à 01:11, Andre Przywara a écrit : > Hi, > > On 16/10/2025 15:27, Richard Genoud wrote: >> Move ECC_PAT_FOUND register in SoC capabilities structure >> >> This register offset moved in H616, it's now its own register, not >> shared with NFC_ECC_ST. >> Push that specificity in caps structure. > > Right, so if I understand correctly, this moves from bits[31:16] of > ECC_ST to bits[31:0] of a new separate register. > If this is correct, can you add this piece of information to the commit > message, to motivate the addition of the whole field masking operation? Yes, exactly. I'll add that this info in the commit message. Thanks! > > Assuming that this looks alright to me: > >> Signed-off-by: Richard Genoud > > Reviewed-by: Andre Przywara > > Cheers, > Andre > > >> --- >>   drivers/mtd/nand/raw/sunxi_nand.c |  9 +++++++-- >>   drivers/mtd/nand/raw/sunxi_nand.h | 16 +++++++++++++++- >>   2 files changed, 22 insertions(+), 3 deletions(-) >> >> diff --git a/drivers/mtd/nand/raw/sunxi_nand.c b/drivers/mtd/nand/raw/ >> sunxi_nand.c >> index 64a0db37f3f0..869b3ddd971c 100644 >> --- a/drivers/mtd/nand/raw/sunxi_nand.c >> +++ b/drivers/mtd/nand/raw/sunxi_nand.c >> @@ -699,6 +699,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct >> mtd_info *mtd, >>       struct nand_ecc_ctrl *ecc = &nand->ecc; >>       int raw_mode = 0; >>       u32 status; >> +    u32 pattern_found; >>       int ret; >>       if (*cur_off != data_off) >> @@ -724,8 +725,9 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct >> mtd_info *mtd, >>       *cur_off = oob_off + ecc->bytes + 4; >> -    status = readl(nfc->regs + NFC_REG_ECC_ST); >> -    if (status & NFC_ECC_PAT_FOUND(0)) { >> +    pattern_found = readl(nfc->regs + nfc->caps->reg_pat_found); >> +    pattern_found = field_get(NFC_ECC_PAT_FOUND_MSK(nfc), >> pattern_found); >> +    if (pattern_found & NFC_ECC_PAT_FOUND(0)) { >>           u8 pattern = 0xff; >>           if (unlikely(!(readl(nfc->regs + NFC_REG_PAT_ID) & 0x1))) >> @@ -744,6 +746,7 @@ static int sunxi_nfc_hw_ecc_read_chunk(struct >> mtd_info *mtd, >>       nand->cmdfunc(mtd, NAND_CMD_RNDOUT, oob_off, -1); >>       sunxi_nfc_randomizer_read_buf(mtd, oob, ecc->bytes + 4, true, >> page); >> +    status = readl(nfc->regs + NFC_REG_ECC_ST); >>       if (status & NFC_ECC_ERR(0)) { >>           /* >>            * Re-read the data with the randomizer disabled to identify >> @@ -1715,6 +1718,8 @@ static const struct sunxi_nfc_caps >> sunxi_nfc_a10_caps = { >>       .nstrengths = 9, >>       .reg_ecc_err_cnt = NFC_REG_A10_ECC_ERR_CNT, >>       .reg_user_data = NFC_REG_A10_USER_DATA, >> +    .reg_pat_found = NFC_REG_ECC_ST, >> +    .pat_found_mask = GENMASK(31, 16), >>   }; >>   static const struct udevice_id sunxi_nand_ids[] = { >> diff --git a/drivers/mtd/nand/raw/sunxi_nand.h b/drivers/mtd/nand/raw/ >> sunxi_nand.h >> index 1977d1bd8eaf..35079d37bb1f 100644 >> --- a/drivers/mtd/nand/raw/sunxi_nand.h >> +++ b/drivers/mtd/nand/raw/sunxi_nand.h >> @@ -25,6 +25,9 @@ >>   #include >> +/* 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 >> @@ -146,7 +149,14 @@ >>   /* define bit use in NFC_ECC_ST */ >>   #define NFC_ECC_ERR(x)        BIT(x) >> -#define NFC_ECC_PAT_FOUND(x)    BIT((x) + 16) >> + >> +/* >> + * define bit use in NFC_REG_PAT_FOUND >> + * For A10/A23, NFC_REG_PAT_FOUND == NFC_ECC_ST register >> + */ >> +#define NFC_ECC_PAT_FOUND(x)    BIT(x) >> +#define NFC_ECC_PAT_FOUND_MSK(nfc) ((nfc)->caps->pat_found_mask) >> + >>   #define NFC_ECC_ERR_CNT(b, x)    (((x) >> ((b) * 8)) & 0xff) >>   #define NFC_DEFAULT_TIMEOUT_MS    1000 >> @@ -162,11 +172,15 @@ >>    * @nstrengths:        Number of element of ECC strengths array >>    * @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 >>    */ >>   struct sunxi_nfc_caps { >>       unsigned int nstrengths; >>       unsigned int reg_ecc_err_cnt; >>       unsigned int reg_user_data; >> +    unsigned int reg_pat_found; >> +    unsigned int pat_found_mask; >>   }; >>   #endif > -- Richard Genoud, Bootlin Embedded Linux and Kernel engineering https://bootlin.com