On Sat, Dec 7, 2019 at 9:49 AM Marek Vasut <marex@xxxxxxx> wrote: > > The SPARE_AREA_SKIP_BYTES register is reset when the controller reset > signal is toggled. Yet, this register must be configured to match the > content of the NAND OOB area. The current default value is always set > to 8 and is programmed into the hardware in case the hardware was not > programmed before (e.g. in a bootloader) with a different value. This > however does not work when the block is reset properly by Linux. > > On Altera SoCFPGA CycloneV, ArriaV and Arria10, which are the SoCFPGA > platforms which support booting from NAND, the SPARE_AREA_SKIP_BYTES > value must be set to 2. On Socionext Uniphier, the value is 8. This > patch adds support for preconfiguring the default value and handles > the special SoCFPGA case by setting the default to 2 on all SoCFPGA > platforms, while retaining the original behavior and default value of > 8 on all the other platforms. > > Signed-off-by: Marek Vasut <marex@xxxxxxx> > Cc: Ley Foon Tan <ley.foon.tan@xxxxxxxxx> > Cc: Masahiro Yamada <yamada.masahiro@xxxxxxxxxxxxx> > Cc: Miquel Raynal <miquel.raynal@xxxxxxxxxxx> > Cc: Richard Weinberger <richard@xxxxxx> > Cc: Vignesh Raghavendra <vigneshr@xxxxxx> > To: linux-mtd@xxxxxxxxxxxxxxxxxxx > --- > drivers/mtd/nand/raw/denali.c | 13 ++++++++++--- > drivers/mtd/nand/raw/denali_dt.c | 6 ++++++ > 2 files changed, 16 insertions(+), 3 deletions(-) > > diff --git a/drivers/mtd/nand/raw/denali.c b/drivers/mtd/nand/raw/denali.c > index 3102ddbd8abdb..b6c463d021677 100644 > --- a/drivers/mtd/nand/raw/denali.c > +++ b/drivers/mtd/nand/raw/denali.c > @@ -1302,14 +1302,21 @@ int denali_init(struct denali_controller *denali) > > /* > * Set how many bytes should be skipped before writing data in OOB. > + * If a non-zero value has already been configured, update it in HW. > * If a non-zero value has already been set (by firmware or something), > * just use it. Otherwise, set the driver's default. > */ > - denali->oob_skip_bytes = ioread32(denali->reg + SPARE_AREA_SKIP_BYTES); > - if (!denali->oob_skip_bytes) { > - denali->oob_skip_bytes = DENALI_DEFAULT_OOB_SKIP_BYTES; > + if (denali->oob_skip_bytes) { > iowrite32(denali->oob_skip_bytes, > denali->reg + SPARE_AREA_SKIP_BYTES); > + } else { > + denali->oob_skip_bytes = > + ioread32(denali->reg + SPARE_AREA_SKIP_BYTES); > + if (!denali->oob_skip_bytes) { > + denali->oob_skip_bytes = DENALI_DEFAULT_OOB_SKIP_BYTES; > + iowrite32(denali->oob_skip_bytes, > + denali->reg + SPARE_AREA_SKIP_BYTES); This fallback is ugly, and should be removed, I think. It is only reachable by PCI platform (Intel MRST), where DENALI_DEFAULT_OOB_SKIP_BYTES is probably useless. > @@ -209,6 +213,8 @@ static int denali_dt_probe(struct platform_device *pdev) > denali->clk_rate = clk_get_rate(dt->clk); > denali->clk_x_rate = clk_get_rate(dt->clk_x); > > + denali->oob_skip_bytes = data->oob_skip_bytes; > + Please move this to the relevant hunk. Preferably, based on this: http://patchwork.ozlabs.org/patch/1205912/ > ret = denali_init(denali); > if (ret) > goto out_disable_clk_ecc; > -- > 2.24.0 > > > ______________________________________________________ > Linux MTD discussion mailing list > http://lists.infradead.org/mailman/listinfo/linux-mtd/ -- Best Regards Masahiro Yamada ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/