OSL SPI Driver

This information corresponds to the SPI driver that's in the development branch of the GIT tree. This driver is also in the master branch, but not updated for device tree there. It's in the development branch as a patch has been submitted to the mainline kernel so that it works with the device tree and also finds nodes on the SPI such as an EEPROM.

Xilinx SPI Driver Kernel Configuration

SPI is not enabled in the current default kernel configuration. The following steps may be used to enable the driver in the kernel configuration

  1. From the device drivers menu, select SPI support
  2. Select the Xilinx SPI controller

Accessing An SPI Device From A User Space Program

This should work, but has not been tested yet. The SPI Dev device driver must be enable in the kernel configuration.

Using An SPI EEPROM Driver As A Higher Layer

There are higher layer drivers that allow the SPI driver to be used to access other devices such as an SPI serial EEPROM. A change was needed in the SPI AT25 driver of the kernel to use device tree and this change is also in the development branch as it is being submitted to the mainline also.

The following steps may be used to enable the driver in the kernel configuration.

  1. From the device drivers menu, select SPI support
  2. Select SPI EEPROMs from most vendors

Adding An SPI EEPROM To The Device Tree

The following example shows adding an SPI EEPROM to a device tree. This example was used to access an SPI EEPROM on the Aardvark board.

The device-tree generator for the EDK does not create the EEPROM device on the SPI bus.

The value of 0 in the reg entry is the chip select for the EEPROM. The value in the spi-max-frequency is the bus frequency. This field is required, but has not been tested with other values.

        xps_spi_0: xps-spi@84000000 {
            compatible = "xlnx,xps-spi-2.00.b";
            interrupt-parent = <&xps_intc_0>;
            interrupts = < 0 2 >;
            reg = < 0x84000000 0x1000 >;
            xlnx,family = "virtex4";
            xlnx,fifo-exist = <0x1>;
            xlnx,num-ss-bits = <0x1>;
            xlnx,num-transfer-bits = <0x8>;
            xlnx,sck-ratio = <0x20>;
            #address-cells = <1>;
            #size-cells = <0>;

            eeprom@0 {
                compatible = "at,at25";
                spi-max-frequency = <100000000>;
                reg = <0>;
                addr-size = <2>;
                page-size = <32>;
                eeprom-size = <1024>;
                eeprom-name = "johnsat25";
        } ;

Kernel Console Output

The following kernel output (or similar) shows the EEPROM driver was started.

xilinx-xps-spi 84000000.xps-spi: at 0x84000000 mapped to 0xC9014000, irq=20
at25 spi32766.0: 1 KByte johnsat25 eeprom, pagesize 32

SysFs Interface

The EEPROM driver allows the contents of the EEPROM to be seen in the sys file system at /sys/bus/spi/devices/spi32766.0/eeprom. The file, eeprom, is a file that can be read and written from user space.

If the sys file system is not mounted (no /sys dir), then the following commands will create and mount it.

bash>mkdir /sys
bash>mount - t sysfs sysfs sys

The following shell commands can view the contents of the eeprom by 1st capturing it and then displaying the file as binary data.

bash>more /sys/bus/spi/devices/spi32766.0/eeprom | od -x

The following command will write "01234567890DEADBEEFCAFE" to the EEPROM.

bash>echo 0123456789DEADBEEFCAFE > /sys/bus/spi/devices/spi32766.0/eeprom

Using An Aardvark I2C/SPI Activity Board For SPI EEPROM Testing

TotalPhase, the company that sells the Aardvark I2C/SPI test equipment, also sells a small board that we can use for our own testing, independent of the Aardvark. The board has an I2C EEPROM and an SPI EEPROM on it such that it can be connected to an FPGA board pretty easy.


The point of this exercise is to have a standard test for the SPI that can be used across all boards.

See the following page, SPI With The Aardvark Board, for more information on how to do it.

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License