[PATCH v2 3/3] mtd: spi-nand: macronix: Add randomizer support

Cheng Ming Lin linchengming884 at gmail.com
Wed Sep 10 22:15:53 PDT 2025


Hi Miquel,

Miquel Raynal <miquel.raynal at bootlin.com> 於 2025年9月10日 週三 下午5:43寫道:
>
> On 10/09/2025 at 17:26:13 +08, Cheng Ming Lin <linchengming884 at gmail.com> wrote:
>
> > Hi Miquel,
> >
> > Miquel Raynal <miquel.raynal at bootlin.com> 於 2025年9月10日 週三 下午5:12寫道:
> >>
> >>
> >> > +static int macronix_set_randomizer(struct spinand_device *spinand)
> >> > +{
> >> > +     struct spi_mem_op exec_op = SPINAND_PROG_EXEC_1S_1S_0_OP(0);
> >> > +     struct nand_device *nand = spinand_to_nand(spinand);
> >> > +     struct device_node *dn = nanddev_get_of_node(nand);
> >> > +     int randopt, ret;
> >> > +     u8 cfg, status;
> >> > +
> >> > +     ret = spinand_read_reg_op(spinand, MACRONIX_FEATURE_ADDR_RANDOMIZER, &cfg);
> >> > +     if (ret)
> >> > +             return ret;
> >> > +     if (cfg)
> >> > +             return 0;
> >> > +
> >> > +     cfg = MACRONIX_CFG_ENPGM | MACRONIX_CFG_RANDEN;
> >> > +     randopt = of_property_read_bool(dn, "mxic,randopt");
> >>
> >> Isn't that a leftover?
> >
> > The property "mxic,randopt" corresponds to bit2 of the configuration
> > register 0x10. Its purpose is to control whether the randomizer also
> > covers the initial portion of the spare area.
>
> Do we need a DT property for that?
>
> In any case, it must be declared in the bindings (which I do not think
> it is?).
>
> > Since the randomizer feature is only documented in Macronix datasheets,
> > it is not clear whether the "randopt" bit is used by all vendors. For
> > this reason, the handling is placed inside macronix.c.
>
> Didn't we discuss in the past of a volatile version for SPI NAND
> devices? I thought we could use a volatile approach instead.

I think a DT property makes sense here. Once the randomizer feature is
enabled, the range it covers must be defined as well. If we rely on a
volatile approach, the randomizer coverage might change dynamically,
which I believe is less safe and harder to guarantee consistency.

>
> Thanks,
> Miquèl

Thanks,
Cheng Ming Lin



More information about the linux-mtd mailing list