This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Keystone II SPI

I am trying to access the SPI from the Keystone II EVMK2K. On the EVM SPI2 breaks out on the 120 pin MIPI connector. I am trying to gain access to this device from Userspace. Currently I am running a 3.8 kernel, but the documentation for SPI has not been updated to show how to add spidev to the device tree, it still only shows how to add it to the board file in older kernel versions. I have setup the davinici-spi-v1 bindings according to the documentation and the SPI0 (nor flash) bindings. I am now trying to figure out how to add a /dev/spidevX.Y for each chip select. Here are the binding I am currently using:

spi2@21000800 {
                        #address-cells = <0x1>;
                        #size-cells = <0x0>;
                        compatible = "ti,davinci-spi-v1";
                        reg = <0x21000800 0x200>;
                        ti,davinci-spi-num-cs = <0x4>;
                        ti,davinci-spi-intr-line = <0x0>;
                        interrupts = <0x0 0x128 0xf01>;
                        clocks = <&clkspi>;
                        
                        spidev10:spi@0 {
                                #address-cells = <1>;
                                #size-cells = <1>;
                                compatible = "rohm,dh2228fv";
                                spi-max-frequency = <100000>;
                                reg = <3>;
                        };
                        spidev11:spi@1 {
                                #address-cells = <1>;
                                #size-cells = <1>;
                                compatible = "rohm,dh2228fv";
                                spi-max-frequency = <100000>;
                                ti,davinci-spi-io-type = <2>;
                                reg = <1>;
                        };
                        spidev12:spi@2 {
                                #address-cells = <1>;
                                #size-cells = <1>;
                                compatible = "rohm,dh2228fv";
                                spi-max-frequency = <100000>;
                                ti,davinci-spi-io-type = <2>;
                                reg = <2>;
                        };
                        spidev13:spi@3 {
                                #address-cells = <1>;
                                #size-cells = <1>;
                                compatible = "rohm,dh2228fv";
                                spi-max-frequency = <100000>;
                                ti,davinci-spi-io-type = <2>;
                                reg = <3>;
                        };

};


Here are my questions:
1) I see that the spidev for the nor device uses the dh2228fv driver. I see in spidev.c that this is the compatible string for the spidev character device, but why use a DAC as the compatible string for spidev?

2) Where is the complete list of binding for the spidev device?

3) Looking at spi-davinci.c it seems to use spi_bitbang, is it actually bitbanging the SPI, or is this a hardware SPI driver?

4) From userspace when I issue and open(), followed by write() on the device file. I see the transaction begin on an Oscope, but only the first byte is sent and then the write() blocks, the clock stops, and the chip select is not released and my program freezes. Could this be a setup issue?


  • Ok so I found out that the Interrupt line was incorrect which is why it was freezing up. I needed interrupt 300 instead of 0x128. Now I am able to see the data on an Oscilloscope, but when I drive the MISO line to ground (representing all zeros) and call spidev_test I end up with:

    spi mode: 0[ 747.745300] spidev spi32765.3: SPI data transfer error

    bits per word: 8
    max speed: 500000 Hz (500 KHz)
    can't send spi message: Input/output error
    Aborted

    When I connect MOSI and MISO in loopback, i get the same data back indicating that it is working. Why does the all zeroes transfer cause and error? Also, how do I go about setting the Clock phase and polarity for each of the chip selects?

    Thanks,
    Bill
  • Hi Bill,


    Did you build the below code and testing ?

    Documentation/spi/spidev_test.c

    How about your "tx[]" transmit buffer?

    Also, how do I go about setting the Clock phase and polarity for each of the chip selects?

    You can mention about the SPI mode through "H" (clock phase) and "-O" (clock poloarity) option while running the spidev app.