In case anyone else has this question, here's what I did to enable it:
Enable User Mode SPI Device Driver Support with menuconfig
bitbake linux-imx -c menuconfig
The rest of the options that Carlos suggester were already enabled.
Add these lines to the iomux section of the fsl-imx8mmevk.dts (<yocto_dir>/<build_dir>/imx8_base_bsp/tmp/work/imx8mmevk-poky-linux/linux-imx/4.14.78-r0/git/arch/arm64/boot/dts/fsl-imx8mmevk.dts):
pinctrl_wdog: wdoggrp {
fsl,pins = <
MX8MM_IOMUXC_GPIO1_IO02_WDOG1_WDOG_B 0xc6
>;
};
pinctrl_ecspi2: ecspi2grp {
fsl,pins = <
MX8MM_IOMUXC_ECSPI2_MISO_ECSPI2_MISO 0x00000116
MX8MM_IOMUXC_ECSPI2_MOSI_ECSPI2_MOSI 0x00000116
MX8MM_IOMUXC_ECSPI2_SCLK_ECSPI2_SCLK 0x00001916
MX8MM_IOMUXC_ECSPI2_SS0_ECSPI2_SS0 0x00000116
>;
};
...
&micfil {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_pdm>;
assigned-clocks = <&clk IMX8MM_CLK_PDM_SRC>, <&clk IMX8MM_CLK_PDM_DIV>;
assigned-clock-parents = <&clk IMX8MM_AUDIO_PLL1_OUT>;
assigned-clock-rates = <0>, <196608000>;
status = "okay";
};
&ecspi2 {
fsl,spi-num-chipselects = <1>;
cs-gpios = <0>;
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_ecspi2>;
status = "okay";
spidev@0x00 {
compatible = "spidev";
spi-max-frequency = <10000000>;
spi-cs-high;
reg = <0>;
};
};
For some reason, the chip select was the wrong polarity (active high) until I added the spi-cs-high field in the device tree. Either way, it clearly changes the polarity.
I also modified the macro for DEV_SPI1 in the NXP test code (<yocto_dir>/<build_dir>/bsp/imx8_base_bsp3/tmp/work/imx8mmevk-poky-linux/imx-test/1_7.0+AUTOINC+04ec1d8040-r0/git/test/mxc_spi_test/mxc_spi_test1.c) so that it would work with /dev/spidev1.0:
#define DEV_SPI1 "/dev/spidev1.0"
bitbake linux-imx -f -c compile
bitbake fsl-image-validation-imx
After loading the kernal and device tree, I see CONFIG_SPI_SPIDEV=y when I run zgrep SPI /proc/config.gz | grep -v SPIN | grep -v '^#', which tells me that the menuconfig change worked. Also, I see /dev/spidev1.0 on the board, so now ecspi2 is in the device tree.