From: Miquel Raynal <miquel.raynal@bootlin.com>
To: Cheng Ming Lin <linchengming884@gmail.com>
Cc: Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Rob Herring <robh@kernel.org>,
Krzysztof Kozlowski <krzk+dt@kernel.org>,
Conor Dooley <conor+dt@kernel.org>,
Tudor Ambarus <tudor.ambarus@linaro.org>,
Mikhail Kshevetskiy <mikhail.kshevetskiy@iopsys.eu>,
Pablo Martin-Gomez <pmartin-gomez@freebox.fr>,
Tianling Shen <cnsztl@gmail.com>,
Pratyush Yadav <pratyush@kernel.org>,
linux-mtd@lists.infradead.org, devicetree@vger.kernel.org,
linux-kernel@vger.kernel.org, alvinzhou@mxic.com.tw,
Cheng Ming Lin <chengminglin@mxic.com.tw>
Subject: Re: [PATCH v5 3/3] mtd: spi-nand: macronix: Enable randomizer support
Date: Thu, 12 Feb 2026 11:55:43 +0100 [thread overview]
Message-ID: <87ldgyxmc0.fsf@bootlin.com> (raw)
In-Reply-To: <20260211100553.907585-4-linchengming884@gmail.com> (Cheng Ming Lin's message of "Wed, 11 Feb 2026 18:05:53 +0800")
On 11/02/2026 at 18:05:53 +08, Cheng Ming Lin <linchengming884@gmail.com> wrote:
> From: Cheng Ming Lin <chengminglin@mxic.com.tw>
>
> Implement the 'set_randomizer' callback for Macronix SPI NAND chips.
> The randomizer is enabled by setting bit 1 of the Configuration Register
> (address 0x10).
>
> This patch adds support for the following chips:
> - MX35LFxG24AD series
> - MX35UFxG24AD series
>
> When the randomizer is enabled, data is scrambled internally during
> program operations and automatically descrambled during read operations.
> This helps reduce bit errors caused by program disturbance.
>
> Signed-off-by: Cheng Ming Lin <chengminglin@mxic.com.tw>
> ---
> drivers/mtd/nand/spi/macronix.c | 46 +++++++++++++++++++++++++--------
> 1 file changed, 35 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/mtd/nand/spi/macronix.c b/drivers/mtd/nand/spi/macronix.c
> index edf63b9996cf..3a9ab146426b 100644
> --- a/drivers/mtd/nand/spi/macronix.c
> +++ b/drivers/mtd/nand/spi/macronix.c
> @@ -14,6 +14,8 @@
> #define MACRONIX_ECCSR_BF_LAST_PAGE(eccsr) FIELD_GET(GENMASK(3, 0), eccsr)
> #define MACRONIX_ECCSR_BF_ACCUMULATED_PAGES(eccsr) FIELD_GET(GENMASK(7, 4), eccsr)
> #define MACRONIX_CFG_CONT_READ BIT(2)
> +#define MACRONIX_CFG_RANDOMIZER_EN BIT(1)
> +#define MACRONIX_FEATURE_ADDR_RANDOMIZER 0x10
> #define MACRONIX_FEATURE_ADDR_READ_RETRY 0x70
> #define MACRONIX_NUM_READ_RETRY_MODES 5
>
> @@ -146,7 +148,7 @@ static int macronix_set_cont_read(struct spinand_device *spinand, bool enable)
> * Return: 0 on success, a negative error code otherwise.
> */
> static int macronix_set_read_retry(struct spinand_device *spinand,
> - unsigned int retry_mode)
> + unsigned int retry_mode)
This is unrelated, it should be in an other commit.
> {
> struct spi_mem_op op = SPINAND_SET_FEATURE_1S_1S_1S_OP(MACRONIX_FEATURE_ADDR_READ_RETRY,
> spinand->scratchbuf);
> @@ -155,6 +157,18 @@ static int macronix_set_read_retry(struct spinand_device *spinand,
> return spi_mem_exec_op(spinand->spimem, &op);
> }
>
> +static int macronix_set_randomizer(struct spinand_device *spinand, bool enable)
> +{
> + int ret;
> +
> + ret = spinand_write_reg_op(spinand, MACRONIX_FEATURE_ADDR_RANDOMIZER,
> + enable ? MACRONIX_CFG_RANDOMIZER_EN :
> 0);
You can directly return. Same in the core BTW.
Otherwise with this and the binding document fixed, looks ok.
Thanks,
Miquèl
next prev parent reply other threads:[~2026-02-12 10:55 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-02-11 10:05 [PATCH v5 0/3] mtd: spi-nand: Add support for randomizer feature Cheng Ming Lin
2026-02-11 10:05 ` [PATCH v5 1/3] dt-bindings: mtd: spinand: Add randomizer enable/disable properties Cheng Ming Lin
2026-02-12 7:33 ` Krzysztof Kozlowski
2026-02-23 5:49 ` Cheng Ming Lin
2026-02-11 10:05 ` [PATCH v5 2/3] mtd: spi-nand: Add support for randomizer Cheng Ming Lin
2026-02-11 10:05 ` [PATCH v5 3/3] mtd: spi-nand: macronix: Enable randomizer support Cheng Ming Lin
2026-02-12 10:55 ` Miquel Raynal [this message]
2026-02-23 5:50 ` Cheng Ming Lin
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=87ldgyxmc0.fsf@bootlin.com \
--to=miquel.raynal@bootlin.com \
--cc=alvinzhou@mxic.com.tw \
--cc=chengminglin@mxic.com.tw \
--cc=cnsztl@gmail.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linchengming884@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mikhail.kshevetskiy@iopsys.eu \
--cc=pmartin-gomez@freebox.fr \
--cc=pratyush@kernel.org \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=tudor.ambarus@linaro.org \
--cc=vigneshr@ti.com \
/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