Hi Erica,
the flexspi port connects to an OctaSPI flash (serial flash with 8 SPI lines), so this is most likley not the SPI port you are looking for. The flash type on the 8QM board is a MICRON MT35XU512, that's why you find the name in this section.
On our 8QM board we don't have anything connected to standard SPI, that's why you don't find any setup for it.
>> I read a lot of stuff about dts files but still do not understand how they work.
You're not alone :smileycool:
OK, this is the SPI setup on the i.MX 8QM:
- There are four LPSPI ports on the 8QM ( LPSPI[3:0] ), in the Reference Manual you find the LPSPI ports in chapter 9.1.
- The standard SPI port has 4 pins: SCK / PCS / SIN / SOUT
- The SPI peripherals 0/1/2/3 are located at 0x5A000000 / 0x5A010000 / 0x5A020000 / 0x5A030000
This is what you need to do:
- Add SPI port(s) to the file fsl-imx8qm.dts
- The file can be found in the folder /tmp/work-shared/imx8qmmek/kernel-source/arch/arm64/boot/dts/freescale
- In the current beta-release there is already an entry for the lpspi0
- The address of the LPSPI port can be found in the Reference Manual --> System Memory Map --> Audio DMA Memory Maps
- There is also an LPSPI peripheral in the i.MX7ULP, so for now you can keep this entry in "compatible". Maybe later on, when the i.MX8 became more popular in the Linux world, there might be other strings.
- The defines for the clocks can be found in the file imx8qm-clock.h
lpspi0: lpspi@5a000000 {
compatible = "fsl,imx7ulp-spi";
reg = <0x0 0x5a000000 0x0 0x10000>;
interrupts = <GIC_SPI 216 IRQ_TYPE_LEVEL_HIGH>;
interrupt-parent = <&gic>;
clocks = <&clk IMX8QM_SPI0_CLK>,
<&clk IMX8QM_SPI0_IPG_CLK>;
clock-names = "per", "ipg";
assigned-clocks = <&clk IMX8QM_SPI0_CLK>;
assigned-clock-rates = <20000000>;
power-domains = <&pd_dma_lpspi0>;
status = "disabled";
};
lpspi1: lpspi@5a010000 {
compatible = "fsl,imx7ulp-spi";
reg = <0x0 0x5a010000 0x0 0x10000>;
interrupts = <GIC_SPI 217 IRQ_TYPE_LEVEL_HIGH>;
interrupt-parent = <&gic>;
clocks = <&clk IMX8QM_SPI1_CLK>,
<&clk IMX8QM_SPI1_IPG_CLK>;
clock-names = "per", "ipg";
assigned-clocks = <&clk IMX8QM_SPI1_CLK>;
assigned-clock-rates = <20000000>;
power-domains = <&pd_dma_lpspi1>;
status = "disabled";
};
- You need to define the pins for the SPI ports you want to use.
- There is an example for the lpspi0 in the file fsl-imx8qm-lpddr4-arm2-lpspi.dts in the folder /tmp/work-shared/imx8qmmek/kernel-source/arch/arm64/boot/dts/freescale
&iomuxc {
imx8qm-arm2 {
pinctrl_lpspi0: lpspi0grp {
fsl,pins = <
SC_P_SPI0_SCK_DMA_SPI0_SCK 0x0600004c
SC_P_SPI0_SDO_DMA_SPI0_SDO 0x0600004c
SC_P_SPI0_SDI_DMA_SPI0_SDI 0x0600004c
>;
};
pinctrl_lpspi0_cs: lpspi0cs {
fsl,pins = <
SC_P_SPI0_CS0_LSIO_GPIO3_IO05 0x21
>;
};
};
};
&lpspi0 {
#address-cells = <1>;
#size-cells = <0>;
fsl,spi-num-chipselects = <1>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_lpspi0 &pinctrl_lpspi0_cs>;
cs-gpios = <&gpio3 5 GPIO_ACTIVE_LOW>;
status = "okay";
flash: at45db041e@0 {
#address-cells = <1>;
#size-cells = <1>;
compatible = "atmel,at45", "atmel,dataflash";
spi-max-frequency = <500000>;
reg = <0>;
};
};
- Configure the Kernel config for SPI support
- Please check if the Kernel config file contains the following defines:
CONFIG_SPI=y
CONFIG_SPI_IMX=y
CONFIG_SPI_FSL_LPSPI=y - If you want this as a default Kernel config setting, please edit the file defconfig in the folder /tmp/work-shared/imx8qmmek/kernel-source/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig
- Test the SPI port
- After creating an image you can test the SPI port on device level and on hardware level
- To load the SPI driver on command line: $ modprobe spidev
- The standard SPI driver in the Linux Kernel (spi-imx.c) would allow you to use the port and finally you should see something on the port when you try to send data.
I need to admit that at the time of writing I didn't test it on the 8QM board, so if you can't make it working please come back to me and I will give it a try on my side.
Regards,
Bernhard.