Enable SPI for WARP7

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Enable SPI for WARP7

Jump to solution
1,521 Views
chaunguyenngoc
Contributor III

I want to use FBTFT Driver to enable OLED via SPI

1. I 've checked SPI in menuconfig, spidev.ko was built and installed.
2. I 've also modified imx7s-warp.dts => change ecspi1-2-3-4 from "Disabled" to "okay"

3. Then I rebuild Linux Kernel success.

4. But when I install kernel (copy zImage, imx7s-warp.dtb, imx7s-warp.dts to /boot folder) & reboot again.

5. there are no /dev/spi* folder.

6. when I run "modprobe fbtft_device name=pioled" to test it. It always return error "spi_busnum_to_master(0) returned NULL"

7. I searched a lot in google and NXP forum, there are no specific answer.

8. I tried to modify Device Tree as some discussion suggested.

===== imx7s-warp.dts

......

&ecspi1 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1>;
status = "okay";
};

&ecspi2 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi1>;
status = "okay";
};

&ecspi3 {
fsl,spi-num-chipselects = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi3>;
status = "okay";
spidev@0x00 {
compatible = "spidev";
spi-max-frequency = <20000000>;
reg = <0>;
};
spidev@0x01 {
compatible = "spidev";
spi-max-frequency = <20000000>;
reg = <1>;
};
};

&iomuxc {
pinctrl-names = "default";
ecspi3 {
pinctrl_ecspi3: ecspi3grp {
fsl,pins = <
MX7D_PAD_ECSPI2_SCLK__MKBUS_ESPI3_SCLK 0x80000000
MX7D_PAD_ECSPI2_MOSI__MKBUS_ESPI3_MOSI 0x80000000
MX7D_PAD_ECSPI2_MISO__MKBUS_ESPI3_MISO 0x80000000
MX7D_PAD_ECSPI2_SS0__MKBUS_ESPI3_SS0_B 0x80000000
>;
};
imx7d-sdb {
.................
.................
pinctrl_ecspi1: ecspi1grp {
fsl,pins = <
MX7D_PAD_ECSPI1_SCLK__MKBUS_UART5_TXD 0x80000000
MX7D_PAD_ECSPI1_MOSI__MKBUS_UART5_RXD 0x80000000
>;
};
pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX7D_PAD_ECSPI2_SCLK__MKBUS_ESPI3_SCLK 0x80000000
MX7D_PAD_ECSPI2_MOSI__MKBUS_ESPI3_MOSI 0x80000000
MX7D_PAD_ECSPI2_MISO__MKBUS_ESPI3_MISO 0x80000000
MX7D_PAD_ECSPI2_SS0__MKBUS_ESPI3_SS0_B 0x80000000
>;
};
.....
};

=====

9. There is error when I rebuild my imx7s-warp.dtb.

====

But error occured when I build imx7s-warp.dtb file.
Error: arch/arm/boot/dts/imx7s-warp.dts:388.5-6 syntax error
FATAL ERROR: Unable to parse input tree
make[1]: *** [arch/arm/boot/dts/imx7s-warp.dtb] Error 1
make: *** [imx7s-warp.dtb] Error 2

====

- What is wrong in my modification ?

- Am I going in right way ?

Note: 

- I modify it follow schematic "warp7_cpu_1109.pdf"

- Linux Kernel: GitHub - WaRP7/linux-fslc: Linux kernel source tree 

- I also refer some file: pinctrl-imx7d.c, imx7d.dtsi but no hope :smileysad: 

It is very thankful if there is a specific way to enable SPI for WARP7

Labels (1)
Tags (1)
1 Solution
1,110 Views
texierp
Contributor III

Hi chaunguyenngoc‌,

I've also a WaRP7 and spidev works perfectly.

Here are the different steps:

1) Modify the device tree as follow:

&ecspi2 {

    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio4 23 GPIO_ACTIVE_LOW>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ecspi2>;
    status = "okay";        
    
    spidev@0 {
        compatible = "rohm,dh2228fv"; // For this test
        reg = <0>;
        spi-max-frequency = <10000000>;
        spi-cs-high;
    };
};

&iomuxc {
    pinctrl-names = "default";

    imx7s-warp {

        pinctrl_ecspi2: ecspi2grp {
            fsl,pins = <
                MX7D_PAD_ECSPI2_MISO__ECSPI2_MISO          0x00000014    /* MISO */
                MX7D_PAD_ECSPI2_MOSI__ECSPI2_MOSI          0x00000014    /* MOSI */
                MX7D_PAD_ECSPI2_SCLK__ECSPI2_SCLK          0x00000014    /* SCLK */
                MX7D_PAD_ECSPI2_SS0__GPIO4_IO23            0x00000014    /* CS1 */
            >;
        };
    };
};

Do not fill in explicitly "spidev" in compatible string (please see Using spidev with the Linux kernel device tree · /var/log/andrey  and spidev: Add "spidev" compatible string to silence warning · raspberrypi/linux@133b98e · GitHub )

2) After that, update your dts file and zImage into the first partition (Boot) => used in mass storage mode :smileyhappy:

3) When linux is up, you would be able to see /de/spidev*

BR

PJ

View solution in original post

8 Replies
1,110 Views
chaunguyenngoc
Contributor III

I fixed it now.

this error because I modified imx7d.dtsi file before.

Change status of ecspi1-2-3-4 from "okay" to "disabled" (default).

Everything is now ok. My display still black =)) 

But I guest it will be another thead.

1,110 Views
chaunguyenngoc
Contributor III

Hi PJ

I also use the same PAD name & functions as yours.

But there is another error that I met before

"ERROR (phandle_references): Reference to non-existent node or label "pinctrl_spi1"

I search all the file & imx7d.dtsi & pinctrl files but there is no definition or usage of "pinctrl_sp1".

0 Kudos
1,110 Views
chaunguyenngoc
Contributor III

I also added "spidev" compatible in spidev.c

0 Kudos
1,110 Views
chaunguyenngoc
Contributor III

I correct it.
=== Now DTS file is
.....
&iomuxc {
pinctrl-names = "default";
ecspi3 {
pinctrl_ecspi3: ecspi3grp {
fsl,pins = <
MX7D_PAD_ECSPI2_SCLK__GPIO4_IO20 0x80000000
MX7D_PAD_ECSPI2_MOSI__GPIO4_IO21 0x80000000
MX7D_PAD_ECSPI2_MISO__GPIO4_IO22 0x80000000
MX7D_PAD_ECSPI2_SS0__GPIO4_IO23 0x80000000 /* NOT SURE /
>;
};
};
imx7d-sdb {
......
pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX7D_PAD_ECSPI2_SCLK__GPIO4_IO20 0x80000000
MX7D_PAD_ECSPI2_MOSI__GPIO4_IO21 0x80000000
MX7D_PAD_ECSPI2_MISO__GPIO4_IO22 0x80000000
MX7D_PAD_ECSPI2_SS0__GPIO4_IO23 0x80000000 /
NOT SURE */
>;
};
pinctrl_i2c1: i2c1grp {
fsl,pins = <
MX7D_PAD_I2C1_SDA__I2C1_SDA 0x4000007f
MX7D_PAD_I2C1_SCL__I2C1_SCL 0x4000007f
>;
};

Next error is: Reference to non-existent node or label "pinctrl_spi1"
I can not find pinctrl_spi1 usage or definition anywhere

0 Kudos
1,111 Views
texierp
Contributor III

Hi chaunguyenngoc‌,

I've also a WaRP7 and spidev works perfectly.

Here are the different steps:

1) Modify the device tree as follow:

&ecspi2 {

    fsl,spi-num-chipselects = <1>;
    cs-gpios = <&gpio4 23 GPIO_ACTIVE_LOW>;
    pinctrl-names = "default";
    pinctrl-0 = <&pinctrl_ecspi2>;
    status = "okay";        
    
    spidev@0 {
        compatible = "rohm,dh2228fv"; // For this test
        reg = <0>;
        spi-max-frequency = <10000000>;
        spi-cs-high;
    };
};

&iomuxc {
    pinctrl-names = "default";

    imx7s-warp {

        pinctrl_ecspi2: ecspi2grp {
            fsl,pins = <
                MX7D_PAD_ECSPI2_MISO__ECSPI2_MISO          0x00000014    /* MISO */
                MX7D_PAD_ECSPI2_MOSI__ECSPI2_MOSI          0x00000014    /* MOSI */
                MX7D_PAD_ECSPI2_SCLK__ECSPI2_SCLK          0x00000014    /* SCLK */
                MX7D_PAD_ECSPI2_SS0__GPIO4_IO23            0x00000014    /* CS1 */
            >;
        };
    };
};

Do not fill in explicitly "spidev" in compatible string (please see Using spidev with the Linux kernel device tree · /var/log/andrey  and spidev: Add "spidev" compatible string to silence warning · raspberrypi/linux@133b98e · GitHub )

2) After that, update your dts file and zImage into the first partition (Boot) => used in mass storage mode :smileyhappy:

3) When linux is up, you would be able to see /de/spidev*

BR

PJ

1,110 Views
chaunguyenngoc
Contributor III

Hi PJ

It is strange that I use code above. 

But when I copied all PAD function again from imx7d-pinfunc.h.

Build is OK now.

I copied zImage, imx7s-warp.dts, imx7s-warp.dtb to "Boot" partitions.

But it seem some error occur when Linux Kernel is boot.

My final dts is 

=====

.........

&ecspi2 {
fsl,spi-num-chipselects = <1>;
cs-gpios = <&gpio4 23 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi2>;
status = "okay";

spidev@0 {
compatible = "spidev";
reg = <0>;
spi-max-frequency = <20000000>;
spi-cs-high;
};
};

&iomuxc {
pinctrl-names = "default";
imx7s-warp {
pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX7D_PAD_ECSPI2_MISO__GPIO4_IO22 0x00000014 /* MISO */
MX7D_PAD_ECSPI2_MOSI__GPIO4_IO21 0x00000014 /* MOSI */
MX7D_PAD_ECSPI2_SCLK__GPIO4_IO20 0x00000014 /* SCLK */
MX7D_PAD_ECSPI2_SS0__GPIO4_IO23 0x00000014 /* CS1 */
>;
};
};

imx7d-sdb {

.............

=====

0 Kudos
1,110 Views
chaunguyenngoc
Contributor III

We updated imx7s-warp.dts file But error still occur. I searched & compared with others but there is no different with my code. other part of dts are also the same. 

=====

Error: arch/arm/boot/dts/imx7s-warp.dts:333.12-13 syntax error
FATAL ERROR: Unable to parse input tree
make[1]: *** [arch/arm/boot/dts/imx7s-warp.dtb] Error 1
make: *** [imx7s-warp.dtb] Error 2

=====

it always give an error in line "MX7D_PAD_ECSPI2_MISO__GPIO4_IO20 0x00000014 /* MISO */ "

Because I want to use MikroBus (My oled display is MikroBus standard) then I modified from "ECSPI2_MISO" to "GPIO4_IO20" follow PAD functions.

my modification is as below:

...

...

&ecspi2 {
fsl,spi-num-chipselects = <1>;
cs-gpios = <&gpio4 23 GPIO_ACTIVE_LOW>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi2>;
status = "okay";

spidev@0 {
compatible = "spidev";
reg = <0>;
spi-max-frequency = <20000000>;
spi-cs-high;
};
};

&iomuxc {
pinctrl-names = "default";
imx7s-warp {
pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX7D_PAD_ECSPI2_MISO__GPIO4_IO20 0x00000014 /* MISO */
MX7D_PAD_ECSPI2_MOSI__GPIO4_IO21 0x00000014 /* MOSI */
MX7D_PAD_ECSPI2_SCLK__GPIO4_IO22 0x00000014 /* SCLK */
MX7D_PAD_ECSPI2_SS0__GPIO4_IO23 0x00000014 /* CS1 */
>;
};
};

imx7d-sdb {...

.........

0 Kudos
1,110 Views
chaunguyenngoc
Contributor III

Hi PJ

Thank you. We will try again

0 Kudos