Help adding macronix nand chip to DTS

I have an mt7620 board with a Macronix MX30LF2G18AC nand chip. This was configured in an older version of openwrt, and I am attempting to migrate the configuration to a new version.

In the old version the chip was defined in nand_device_list.h as so:

static const flashdev_info gen_FlashTable[]={
    {0xC2DA, 0x909506, 5, 8, 256, 128, 2048, 64, 0x30C77fff, "MX30LF2G18AC", 0}
};

with this partition info in the old bootlog:

[    1.504000] !!! nand page size = 2048, addr len=5
[    1.516000] ra_nand_init: alloc 1468, at 8fca2000 , btt(8fca30c0, 200), ranfc_mtd:8fca32c0
[    1.532000] Creating 9 MTD partitions on "ra_nfc":
[    1.540000] 0x000000000000-0x000010000000 : "ALL"
[    1.640000] 0x000000000000-0x000000040000 : "uboot"
[    1.652000] 0x000000040000-0x000000080000 : "uboot-env"
[    1.664000] 0x000000080000-0x000000480000 : "uImage"
[    1.676000] 0x000000480000-0x000000880000 : "uImage2"
[    1.688000] 0x000000880000-0x000005880000 : "rootfs"
[    1.700000] 0x000005880000-0x00000a880000 : "rootfs2"
[    1.712000] 0x00000a880000-0x00000b880000 : "config"
[    1.720000] 0x00000b880000-0x00000fe80000 : "storage"

This is the nand setup in the default dts for the MT7620 eval board:

&spi0 {
	status = "okay";

	m25p80@0 {
		#address-cells = <1>;
		#size-cells = <1>;
		compatible = "jedec,spi-nor";
		reg = <0>;
		spi-max-frequency = <10000000>;

		partition@0 {
			label = "u-boot";
			reg = <0x0 0x30000>;
			read-only;
		};

		partition@30000 {
			label = "u-boot-env";
			reg = <0x30000 0x10000>;
			read-only;
		};

		factory: partition@40000 {
			label = "factory";
			reg = <0x40000 0x10000>;
			read-only;
		};

		partition@50000 {
			label = "firmware";
			reg = <0x50000 0x7b0000>;
		};
	};
};

I can probably figure out the partitions, but am confused as to what to use in place of "m25p80@0" and if I need to be under &spi0. Can I get any help getting started?

Things may be different on the mt7620, but for the ath79 platform, Linux 4.19 is needed for SPI NAND. (The "hackish" way of twisting the SPI NOR code for SPI NAND was rejected upstream in favor of the SPI-NAND framework.)

linux-4.19.34/drivers/mtd/nand/spi/macronix.c looks to be present with the two chips populated

  • MX35LF1GE4AB
  • MX35LF2GE4AB

The setup is probably similar to what you've shown if it's on SPI, though compatible will be spi-nand

I wish I had more insight, but I just started to try to port then AR750S and its GigaDevice GD5F1GQ4UFxxG onto ath79 / 4.19 in the last day.

MX30LF2G18AC is a parallel NAND flash, not SPI NAND.
http://www.macronix.com/en-us/products/NAND-Flash/SLC-NAND-Flash/Pages/spec.aspx?p=MX30LF2G18AC&m=SLC%20NAND&n=PM2129

1 Like

Hmm, so what interface would I need to try to add it to in the dts?

Looks like there is no support for parallel NAND on MT7620 in current OpenWrt.
By Kernel 4.4 there was a patch to support it, but after 4.9 it seems not.

There was a PR for Xiaomi R3 support a year ago.
It included a patch to restore the NAND driver for MT7620, you can dig it out of there and after a refresh, it can likely work.

1 Like

I tried that patch, but its dependent on a struct that was expelled in 4.9
https://patchwork.kernel.org/patch/8518251/

Well, that PR includes a reworked version without the nand_ecclayout struct

I found this version which worked.

I must have missed the other version in the one you linked. Thanks!

Also was able to define partitions in the dts.

1 Like