mtd: rawnand: sunxi: move ECC_PAT_FOUND register in SoC caps

Move ECC_PAT_FOUND register in SoC capabilities structure

This register offset moved in H616, it's now its own register (@0x3c,
bits 0-31), not shared with NFC_ECC_ST any more (was @0x38 bits 16-31).
Push that specificity in caps structure.

Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Richard Genoud <richard.genoud@bootlin.com>
Signed-off-by: Michael Trimarchi <michael@amarulasolutions.com>
This commit is contained in:
Richard Genoud 2026-01-23 12:44:45 +01:00 committed by Michael Trimarchi
parent eb66861acc
commit 2e6852a841
2 changed files with 22 additions and 3 deletions

View File

@ -698,6 +698,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)
@ -723,8 +724,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)))
@ -743,6 +745,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
@ -1714,6 +1717,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[] = {

View File

@ -25,6 +25,9 @@
#include <linux/bitops.h>
/* 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