Search code examples
linux-kernellinux-device-driverkernel-moduledevice-tree

jedec,spi-nor not executing in linux kernel


I am trying to use a MTD device for storage on a Licheepi Zero. I have been able to add and use i2c and spidev succesfully, however I cannot make jedec,spi-nor execute during kernel bootup.

My dts is (I have tried many variations of this):

&spi0 {
    pinctrl-0 = <&spi0_pins>; // tried without these two lines
    pinctrl-names = "default";

    status = "okay";
 
  /* tried with and without this */
  /*cs-gpios = <&pio 2 2 GPIO_ACTIVE_LOW>, <&pio 1 0 GPIO_ACTIVE_LOW>;*/

  flash@0 {
    compatible = "winbond,w25q64", "jedec,spi-nor"; // I tried deleting winbond,w25q64
    status = "okay"; // I added this line on desperation
    spi-max-frequency = <50000000>; // I tried lowering this to 10MHz
    reg = <0>;
    #address-cells = <1>;
    #size-cells = <1>;
  };

};

When I boot the kernel using this dts I cannot see jedec,spi-nor trying to probe for the NOR-FLASH, it is like if "jedec,spi-nor" is simply not executing. I know my changes are working because if I replace flash@0{compatible="jedec,spi-nor";..} with spidev@0{compatible = "spidev";..} I get a spidev device (which is functional) and can also see it on dmesg.

Some other outputs:

cat /proc/mtd
dev:   size:   erasesize  name

ls /sys/class/mtd is empty

# cat /sys/class/spi_master/spi0/spi0.0/uevent
OF_NAME=flash
OF_FULLNAME=/soc/spi@1c68000/flash@0
OF_COMPATIBLE_0=winbond,w25q64
OF_COMPATIBLE_1=jedec,spi-nor
OF_COMPATIBLE_N=2
MODALIAS=spi:w25q64

MTD_SPI_NOR is enabled in menuconfig. I also added it as a module and tried running modprobe -v jedec_probe.ko and modprobe -v spi-nor.ko but I see absolutely no verbose. mtdinfo userspace counts 0 MTD devices.

The linux kernel I am using is 5.3.5. I am compilling it with buildroot. I checked and w25q64 is supported in jdec,spi-nor (linux-5.3.5/drivers/mtd/spi-nor/spi-nor.c)


Solution

  • It seems I was missing CONFIG_MTD_M25P80, now I get:

    [    0.781483] m25p80 spi0.0: found s25fl064k, expected w25q64
    [    0.787181] m25p80 spi0.0: s25fl064k (8192 Kbytes)