Search code examples
linux-kernelu-bootdevice-treeimx6

Spansion S25HS512T NOR Flash not working on linux or u-boot


I have a custom board (NXP iMX6UL) with Spansion Flash 25HS512TFANHI010 which I cant seem to get working.

My dtsi has the following

...
pinctrl_qspi: qspigrp {
                fsl,pins = <
                        MX6UL_PAD_NAND_WP_B__QSPI_A_SCLK        0x70a1
                        MX6UL_PAD_NAND_READY_B__QSPI_A_DATA00   0x70a1
                        MX6UL_PAD_NAND_CE0_B__QSPI_A_DATA01     0x70a1
                        MX6UL_PAD_NAND_CE1_B__QSPI_A_DATA02     0x70a1
                        MX6UL_PAD_NAND_CLE__QSPI_A_DATA03       0x70a1
                        MX6UL_PAD_NAND_DQS__QSPI_A_SS0_B        0x70a1
                >;
        };
...
&qspi {
        pinctrl-names = "default";
        pinctrl-0 = <&pinctrl_qspi>;
        status = "okay";
        //cs-gpios = <&gpio4 16 0>;

        flash0: s25hs512t@0 {
                #address-cells = <1>;
                #size-cells = <1>;
                compatible = "spansion,s25hs512t", "jedec,spi-nor";
                spi-max-frequency = <40000000>;
                spi-rx-bus-width = <4>;
                spi-tx-bus-width = <4>;
                reg = <0>;
                spi-mode = <0>;
                spi-cpha;
                spi-cpol;
                m25p,fast-read;
                //wp-gpios = <&gpio4 14 0>;
                //hold-gpios = <&gpio4 15 0>;
                status = "okay";
         };
};

For u-boot my defconfig has the following

CONFIG_DM=y
CONFIG_SPI=y
CONFIG_SPI_FLASH=y
CONFIG_SPI_FLASH_SPANSION=y
CONFIG_DM_SPI=y
CONFIG_DM_SPI_FLASH=y
CONFIG_FSL_QSPI=y
CONFIG_SF_DEFAULT_MODE=0

for linux my defconfig has basically (among a lot of other stuff)

CONFIG_SPI_FSL_QUADSPI=y

so both u-boot and Linux doesn't seem to work well

u-boot Error

U-Boot 2021.10-rc2-00044-g4865db0716-dirty (Aug 24 2021 - 23:15:49 +0530)
...
=> sf probe
fsl_qspi spi@21e0000: spi_find_chip_select: plat=9ef61e10, cs=0
fsl_qspi spi@21e0000: spi_find_chip_select: plat=9ef61e10, cs=0
jedec_spi_nor s25hs512t@0: set_state_simple op missing
fsl_qspi spi@21e0000: CMD[9f] lutval[0:1c00049f          1:0     2:0     3:0]
Failed to initialize SPI flash at 0:0 (error -524)

DM Tree

=> dm tree 
 Class     Index  Probed  Driver                Name
-----------------------------------------------------------
 root          0  [ + ]   root_driver           root_driver
 thermal       0  [   ]   imx_thermal           |-- imx_thermal
 simple_bus    0  [ + ]   simple_bus            |-- soc
 simple_bus    1  [ + ]   simple_bus            |   |-- aips-bus@2000000
 simple_bus    2  [   ]   simple_bus            |   |   |-- spba-bus@2000000
 gpio          0  [   ]   gpio_mxc              |   |   |-- gpio@209c000
 gpio          1  [   ]   gpio_mxc              |   |   |-- gpio@20a0000
 gpio          2  [   ]   gpio_mxc              |   |   |-- gpio@20a4000
 gpio          3  [   ]   gpio_mxc              |   |   |-- gpio@20a8000
 gpio          4  [   ]   gpio_mxc              |   |   |-- gpio@20ac000
 simple_bus    3  [   ]   simple_bus            |   |   |-- anatop@20c8000
 simple_bus    4  [   ]   simple_bus            |   |   |-- snvs@20cc000
 pinctrl       0  [ + ]   fsl_imx6q_iomuxc      |   |   `-- iomuxc@20e0000
 pinconfig     0  [   ]   pinconfig             |   |       |-- i2c1grp
 pinconfig     1  [   ]   pinconfig             |   |       |-- i2c2grp
 pinconfig     2  [ + ]   pinconfig             |   |       |-- qspigrp
 pinconfig     3  [   ]   pinconfig             |   |       |-- tscgrp
 pinconfig     4  [   ]   pinconfig             |   |       |-- uart1grp
 pinconfig     5  [ + ]   pinconfig             |   |       |-- usdhc2grp
 pinconfig     6  [   ]   pinconfig             |   |       `-- wdoggrp
 simple_bus    5  [ + ]   simple_bus            |   `-- aips-bus@2100000
 mmc           0  [ + ]   fsl_esdhc             |       |-- usdhc@2194000
 blk           0  [   ]   mmc_blk               |       |   `-- [email protected]
 i2c           0  [   ]   i2c_mxc               |       |-- i2c@21a0000
 i2c           1  [   ]   i2c_mxc               |       |-- i2c@21a4000
 spi           0  [ + ]   fsl_qspi              |       `-- spi@21e0000
 spi_flash     0  [   ]   jedec_spi_nor         |           `-- s25hs512t@0
 regulator     0  [   ]   regulator_fixed       `-- regulator-sd2-vmmc

Linux Error

[    0.000000] Booting Linux on physical CPU 0x0
[    0.000000] Linux version 5.14.0-rc7-413454-gd5ae8d7f85b7 (harkirat@harkirat-devsys) (arm-linux-gnueabihf-gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0, GNU ld (GNU Binutils for Ubuntu) 2.34) #3 SMP Tue Aug 24 22:47:19 IST 2021
[    0.000000] CPU: ARMv7 Processor [410fc075] revision 5 (ARMv7), cr=10c5387d
...
[    2.639396] spi spi0.0: setup: unsupported mode bits 3
[    2.645215] fsl-quadspi 21e0000.spi: can't setup spi0.0, status -22
[    2.651590] spi_master spi0: spi_device register error /soc/bus@2100000/spi@21e0000/s25hs512t@0
[    2.660817] spi_master spi0: Failed to create SPI device for /soc/bus@2100000/spi@21e0000/s25hs512t@0
...

I have tried almost every iteration possible, but I can seem to get to the issue. I have a feeling its something to do with the dtsi. Any help will be appreciated, am at wits end.

PS: tried the cypress forums but they have been very non responsive. they have a u-boot patch from 2018.01 which is as such not compatible with 2021.10


Solution

  • Support for S25HL/S25HS series has been added in u-boot 2021.10-rc3.

    Ensure:

    CONFIG_SPI_FLASH_SFDP_SUPPORT is set and
    CONFIG_SPI_FLASH_BAR is not set
    

    Thanks to Mr. Kuwano of Infineon for the support.

    PS: Not tested on Linux. Not working on Barebox yet (getting detected but not writing).