SPI not working in IMX8QM

Hi Team Toradex,
I hope you are doing well.

Setup 1)
Below are our hardware and firmware specifications.
Operating System : Android 10
Kernel Version : 5.4
SOM : IMX8QM
Carrier Board : IXORA Carrier board v1.1.
SPI Slave : MAX7219 SPI dot matrix display

We are trying to up the MAX7219 LED Dot Matrix display from the user space (We don’t have any linux kernel driver). This is the link of the display.

We are facing the communication problem of SPI bus in our setup. The chip select pin is not getting low, and the clock is not being generated. Below are the device tree nodes of the SPI bus that we have tried. The use space code for the display is zipped and attached.
trpmk.tar.gz (3.1 KB)
.
1)
/* Apalis SPI1 */
&lpspi0 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_lpspi0 &pinctrl_lpspi0_cs>;
cs-gpios = <&lsio_gpio3 5 GPIO_ACTIVE_LOW> ;
status = “okay”;

spidev0: spi@0 {
    compatible = "toradex,evalspi";
    reg = <0>;
    spi-max-frequency = <12000000>;
};

};

/* Apalis SPI1 */
pinctrl_lpspi0: lpspi0grp {
fsl,pins = <
IMX8QM_SPI0_SCK_DMA_SPI0_SCK 0x0600004c
IMX8QM_SPI0_SDO_DMA_SPI0_SDO 0x0600004c
IMX8QM_SPI0_SDI_DMA_SPI0_SDI 0x0600004c
IMX8QM_SPI0_CS0_DMA_SPI0_CS0 0x0600004c
>;
};

    pinctrl_lpspi0_cs: lpspi0cs {
        fsl,pins = <
            IMX8QM_SPI0_CS0_LSIO_GPIO3_IO05            0x21
        >;
    };

2)
/* Apalis SPI1 */
&lpspi0 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_lpspi0>;
cs-gpios = <&lsio_gpio3 5 GPIO_ACTIVE_LOW> ;
status = “okay”;

spidev0: spi@0 {
    compatible = "toradex,evalspi";
    reg = <0>;
    spi-max-frequency = <12000000>;
};

};

/* Apalis SPI1 */
pinctrl_lpspi0: lpspi0grp {
fsl,pins = <
IMX8QM_SPI0_SCK_DMA_SPI0_SCK 0x0600004c
IMX8QM_SPI0_SDO_DMA_SPI0_SDO 0x0600004c
IMX8QM_SPI0_SDI_DMA_SPI0_SDI 0x0600004c
IMX8QM_SPI0_CS0_LSIO_GPIO3_IO05 0x0600004c
>;
};

The same code we have compiled (Compiled inside Raspberry Pi) in Raspberry Pi and run from the user space, and it is working. We have also tried (only for testing, not part of the project) to communicate with the SPI sensors : accelerometer, pressure sensor from the user space, but we are not able to bring up any of the SPI sensor. The same sensor were working fine with the Raspberry Pi from the user space.
Kindly help us to solve this issue.

Setup 2)
Below are our hardware and firmware specifications.
Operating System : Android 10
Kernel Version : 5.4
SOM : IMX8QM
Carrier Board : Our in-house board

  1. We have also tried to communicate to the dot matrix display by connecting it to our carrier board and facing the same issue, we are not able to communicate with the display, the chip select pin is not getting low and clock is not being generated. The schematic and pin layout of the hardware are attached for your reference.

  2. we have a question regarding the design (Our end goal is to connect the dot matrix display to our in house board on SPI): Below is the schematic image of SPI lined of the Ixora board. There are 22 ohms resistors are connected on the output of the SPI bus and connector X27, That’s makes the 22R resistor in series between the SPI lines of the SOM module and the Display module.
    What is the use case of the 22R resistor on SPI lines? Can we connect the 0hms instead of the 22 ohms? How to decide the resistor values if it is matters in solid communication between the SOM and slave device ? Kindly share your views and answer on this.
    - Ixora carrier board design


Our inhouse design


Hi,
pinctrl-0 = <&pinctrl_lpspi0 &pinctrl_lpspi0_cs> looks wrong.
Where did you get this devicetree source code from?
The 2nd version looks correct. If active, you should be able to read/write.
How do you do this?
SPI (LINUX)
In the in-house scematic, cs for spi1 and cs for spi2 are connected.
Why are you doing that?

Best
Gerald

Hi @gerko ,
Please consider below node,

1)
/* Apalis SPI1 */
&lpspi0 {
fsl,spi-num-chipselects = <1>;
pinctrl-names = “default”;
pinctrl-0 = <&pinctrl_lpspi0 &pinctrl_lpspi0_cs>;
cs-gpios = <&lsio_gpio3 5 GPIO_ACTIVE_LOW>;
status = “okay”;

    spidev0: spi@0 {
                    compatible = "toradex,evalspi";
                    reg = <0>;
                    spi-max-frequency = <12000000>;
     };

}

/* Apalis SPI1 */

    pinctrl_lpspi0: lpspi0grp {
	fsl,pins = <
		IMX8QM_SPI0_SCK_DMA_SPI0_SCK		0x600004c
		IMX8QM_SPI0_SDO_DMA_SPI0_SDO		0x600004c
		IMX8QM_SPI0_SDI_DMA_SPI0_SDI		0x600004c
	>;
};

pinctrl_lpspi0_cs: lpspi0cs {
	fsl,pins = <
		IMX8QM_SPI0_CS0_LSIO_GPIO3_IO05		0x21
	>;
};

This reference node was provided inside the Android 10 source code. We have modified the spidev0 sub node as per our requirement.
Mainly, We used the 2) node, but facing the issue in SPI, So we have taken write 1) reference from the another device tree available in source code and still facing the issue.

Below is the code we are using the to work with the MAX7219, which has IOCTL funcations to communicate with dotmatrix display.
trpmk.tar.gz (3.1 KB)

The SPI (LINUX) you have provided is for Linux and we need to convert it for Android platform.
We will convert it and update you.

In the in-house schematic, we are using he SPI1 and CS of SPI1. The SPI2 is a spare SPI that is designed in hardware but not considered in the firmware. We may use the SPI2 in the firmware in feature.

So, could you tell us what modification we require in the source code to communicate with the dot matrix display? How we can show the data on the display? We don’t have any kernel driver for it. If you know any driver, please provide. Or suggest us the other way to communicate with the display like we are currently doping the IOCTL.

OK, I would have thought that basic functions like echo or cat would be available on the Android OS. I do not know about it.
I only have a little experience with SPI on an Apalis iMX8QM with TorizonCore/TorizonOS.
If everything is different in Android, I should stay out of it.

Have a nice day …