Twitter E-mail RSS
formats

SPI – Serial Periferial Interface

The i.MX23 has two identical synchronous serial ports (SSP). The SSP supports four modes of operation’s: Motorola SPI, Windbond SPI, Texas Instruments SSI and SD/SDIO/MMC (1-bit, 4-bit, and 8-bit) mode. Mode of operation is determined with SSP1 control register’s at address space beginning at 0x8001_0000 and SSP2 beginning at 0x8003_4000. The SSP also supports slave operation for the SPI and SSI modes.

On imx23-olinuxino boards SSP1 is in SD/MMC mode and SSP2 in master SPI mode. Implemented is four wire wariant with MISO, MOSI, SCK and slave select pin SS. SPI pins are exposed on UEXT connector:

Representing SPI connections in kernel

SPI pins are described in following segment of imx23.dtsi file:

				spi2_pins_a: spi2@0 {
					reg = <0>;
					fsl,pinmux-ids = <
						0x0182 /* MX23_PAD_GPMI_WRN__SSP2_SCK */
						0x0142 /* MX23_PAD_GPMI_RDY1__SSP2_CMD */
						0x0002 /* MX23_PAD_GPMI_D00__SSP2_DATA0 */
						0x0032 /* MX23_PAD_GPMI_D03__SSP2_DATA3 */
					>;
					fsl,drive-strength = <1>;
					fsl,voltage = <1>;
					fsl,pull-up = <1>;
				};

SPI interface is activated on kernel with following segment in imx23-olinuxino.dts file:

 
			ssp1: ssp@80034000 {
				#address-cells = <1>;
				#size-cells = <0>;
				compatible = "fsl,imx23-spi";
				pinctrl-names = "default";
				pinctrl-0 = <&spi2_pins_a>;
				status = "okay";
                        };

When slave device is connected on board, device tree fileimx23-olinuxino.dts need to be modified. Here are some exaples:

EXAMPLE-1

To controll slave device from user space with spidev driver, imx23-olinuxino.dts file need to change as follow:

			ssp1: ssp@80034000 {
				#address-cells = <1>;
				#size-cells = <0>;
				compatible = "fsl,imx23-spi";
				pinctrl-names = "default";
				pinctrl-0 = <&spi2_pins_a>;
				status = "okay";
                      /* Add slave node here */
                         spidev: spidev@0 {
                                compatible = "spidev";
                                spi-max-frequency = <100000>;
                                reg = <0>;
                                };
 
                        };

After changes, compile kernel and create new blob DTB file.

EXAMPLE-2

To add spi flash, imx23-olinuxino.dts file is updated with child node as follow:

			ssp1: ssp@80034000 {
				#address-cells = <1>;
				#size-cells = <0>;
				compatible = "fsl,imx23-spi";
				pinctrl-names = "default";
				pinctrl-0 = <&spi2_pins_a>;
				status = "okay";

				flash: m25p80@0 {
					#address-cells = <1>;
					#size-cells = <1>;
					compatible = "sst,sst25vf016b";
					spi-max-frequency = <40000000>;	
				        reg = <0>;
				};
                        };

In both examples, mandatory fields are:

  • compatible – defines driver,
  • spi-max-frequency – SPI frequency,
  • reg – SPI address.

Creative Commons License
This work by http://g-lab.ca is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License

Home imx23-olinuxino kernel 3.x SPI SPI – Serial Periferial Interface