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.

AM335x : SPI on SDK 8 (with spidev)

Hi,

  I have some difficulties to read data on the SPI port.  I can send without any problem and when I read I have all zeros (and electrically I have data on the pin checked with an oscilloscope).  The Linux code was working fine on SDK 5.5.1, but with the change on SKD 8.0 I have something wrong.   Here is what is in the device tree and in my code.

spi0_pins: pinmux_spi0_pins {
pinctrl-single,pins = <
0x150 (PIN_OUTPUT | MUX_MODE0) /* spi0_clk.spi0_clk */
0x154 (PIN_OUTPUT | MUX_MODE0) /* spi0_d0.spi0_d0 */
0x158 (PIN_INPUT_PULLUP | MUX_MODE0) /* spi0_d1.spi0_d1 */
0x15C (PIN_OUTPUT | MUX_MODE0) /* spi0_cs0.spi0_cs0 */
>;
};

&spi0 {
compatible = "ti,omap4-mcspi";
pinctrl-names = "default";
pinctrl-0 = <&spi0_pins>;
ti,spi-num-cs = <1>;
ti,pindir-d0-out-d1-in;
status = "okay";

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

// User space application

Xfer[0].tx_buf = (unsigned long)((uint32_t*)&Address);
Xfer[0].len = 4;
Xfer[0].bits_per_word = 32;
Xfer[0].speed_hz = RxTxSpeed;

Xfer[1].rx_buf = (unsigned long)&Data;
Xfer[1].len = 4;
Xfer[1].bits_per_word = 32;
Xfer[1].speed_hz = RxTxSpeed;

Ret = ioctl(Handle, SPI_IOC_MESSAGE(2), &Xfer[0]);

Thanks,

Simon

  • Hi Simon,

    You must change

    0x150 (PIN_OUTPUT | MUX_MODE0) /* spi0_clk.spi0_clk */

    to

    0x150 (PIN_INPUT | MUX_MODE0) /* spi0_clk.spi0_clk */

    for read operations to work. The CLK pin must have input enabled because the clock that's used for reading is fed back to the SPI peripheral from the pin.