Lantiq xway NAND driver hard coded ECC settings neccessary?

My guess is that the xway_nand.c driver was written at a time, where the kernel did not support some of the nand chips that have drivers now in the kernel.
I discovered that the reason for sysupgrade not working for my fritzbox 7490 is the hardcoded ECC settings in the xway_attach_chip method in xway_nand.c.
If I make that function a noop, the nand ecc errors are all gone and the device even boots from nand. My device has Micron NAND chips which have hardware on die ECC.

Now I wonder how to resolve this. Are those hardcoded settings still needed? If yes, there should probably be another way e.g. in DT to overwrite the NAND chip driver settings?!

Hi,
There is also a new driver for HSNAND, but it has not been tested for older SoCs[1].
Take a look at the nand controller documentation. It looks like this should be configured in DT[2].

  1. https://github.com/torvalds/linux/blob/5bfc75d92efd494db37f5c4c173d3639d4772966/drivers/mtd/nand/raw/intel-nand-controller.c
  2. https://github.com/torvalds/linux/blob/5bfc75d92efd494db37f5c4c173d3639d4772966/Documentation/devicetree/bindings/mtd/nand-controller.yaml

@olek210 I had a look at it. This driver uses dma but none of the ltq_dma functions and the lantiq stuff in the kernel sources has no definitions for HSNAND dma port 6 as well as misses the relevant irqs for the dma channels 26 and 27. It lacks some flags and commands written to lantiq hardware that are present in the old AVM fritzbox kernel driver and in the xway_nand driver. The new driver does not work without at least rewriting the dma part of the driver to use the ltq_dma functions or to change the lantiq dma implementation of the kernel to expose the dma methods by using platform_set_drvdata and set the methods in the dma_device structure.

@olek210 @hauke If I create a kernel patch (it will be my first one), should it be like:
a) create a dtb property e.g. lantiq,no-default-ecc and only remove the hardcoded ecc setting if that property is set?
or the other way around
b) create a dtb property e.g. lantiq,use-default-ecc and execute the hardcoded ecc setting if that property is set? This would require for all existing lantiq devices to add that property to the dtb?!
What is more likely to be accepted without lots of discussions with the linux kernel maintainers?

Thanks.

@olek210 I am working with the kernel maintainers to make a change that removes the hardcoded setting. It would be great if someone could verify that adding nand-ecc-mode = "soft" makes the hardcoded setting obsolete for other devices. This is the PR to test the change.
Thanks.