DART-MX8M SPI

From Variscite Wiki
Revision as of 15:48, 11 July 2018 by Admin (talk | contribs) (Created page with "{{PageHeader|DART-MX8M - SPI}} {{DocImage|category1=DART-MX8M}}Category:Yocto __toc__ In this example we will show how to configure SPI1 on DART-MX8M = Kernel configuratio...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
DART-MX8M - SPI

[[Category:{{{category2}}}]]

In this example we will show how to configure SPI1 on DART-MX8M

Kernel configuration

Verify that the User mode SPI driver (CONFIG_SPI_SPIDEV) is enabled in your kernel configuration:

  • In menuconfig: Device Drivers -> SPI support -> <*> User mode SPI device driver support

SPI 1

Edit arch/arm64/boot/dts/variscite/imx8m-var-dart-common.dtsi and add spidev node

&ecspi1 {
	#address-cells = <1>;
	#size-cells = <0>;
	num-cs = <1>;
	pinctrl-names = "default";
	pinctrl-0 = <&pinctrl_ecspi1>;
	status = "okay";

        chip1: spidev@0 {
               compatible = "spidev";
               spi-max-frequency = <12000000>;
               reg = <0>;
        };
};

Configure SPI1 pins

&iomuxc {
	imx8mq-evk {
                ...
		pinctrl_ecspi1: ecspi1grp {
			fsl,pins = <
				MX8MQ_IOMUXC_ECSPI1_SCLK_ECSPI1_SCLK		0x11
				MX8MQ_IOMUXC_ECSPI1_MOSI_ECSPI1_MOSI		0x11
				MX8MQ_IOMUXC_ECSPI1_MISO_ECSPI1_MISO		0x11
				MX8MQ_IOMUXC_ECSPI1_SS0_ECSPI1_SS0		0x11
			>;
		};
                ...
	};
};

Note: The pins here were set arbitrarily. You should set them based on your hardware design, and make sure they are not conflicting with other devices in the device tree.
you can also have multiple chip selects.

Compile

Compile the kernel and device tree and update the SOM.

Testing

There's an SPI testing utility C code example in the kernel source tree: tools/spi/spidev_test.c (in older kernels: Documentation/spi/spidev_test.c)
To cross compile it use the following command

$ $CC ./tools/spi/spidev_test.c -o ./spidev_test

Run SPI Test

Transfer

SPI 1 External Connector

SPI 1 will be accessible on the following EVK pins:

  • J16.2 - SPI1.SCLK
  • J16.4 - SPI1.SS0
  • J16.6 - SPI1.MOSI
  • J16.8 - SPI1.MISO