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.

PROCESSOR-SDK-AM335X: Support SPI 3-wire

Part Number: PROCESSOR-SDK-AM335X

Tool/software:

Hi, 

I want to connect a TFT that works with SPI 3-wire. When in device tree add spi-3wire., I have this error in dmesg.

 spi spi0.0: setup: unsupported mode bits 10

Does the AM335x processor support 3-wire? Am I missing some configuration in the Linux Kernel?

Thanks, 

  • Hello,

    The thread owner is out for the rest of September. Feel free to ping the thread in early October.

    Regards,

    Nick

  • Hello,

    I hope you have already been able to return to work.

    When you have a moment, I would appreciate it if you could review my question?

    Greetings and thanks,

    Xavier

  • Hi Xavier,

    spi spi0.0: setup: unsupported mode bits 10

    Does the AM335x processor support 3-wire? Am I missing some configuration in the Linux Kernel?

    the "McSPI" peripheral module in AM335x can support 3-wire mode, however it is not supported from a driver POV currently. There's even a comment in this regard in the source code...

    $ git grep -C 10 SPI_3WIRE drivers/spi/spi-omap2-mcspi.c
    drivers/spi/spi-omap2-mcspi.c-          div = (ref_clk_hz + speed_hz - 1) / speed_hz;
    drivers/spi/spi-omap2-mcspi.c-          speed_hz = ref_clk_hz / div;
    drivers/spi/spi-omap2-mcspi.c-          clkd = (div - 1) & 0xf;
    drivers/spi/spi-omap2-mcspi.c-          extclk = (div - 1) >> 4;
    drivers/spi/spi-omap2-mcspi.c-          clkg = OMAP2_MCSPI_CHCONF_CLKG;
    drivers/spi/spi-omap2-mcspi.c-  }
    drivers/spi/spi-omap2-mcspi.c-
    drivers/spi/spi-omap2-mcspi.c-  l = mcspi_cached_chconf0(spi);
    drivers/spi/spi-omap2-mcspi.c-
    drivers/spi/spi-omap2-mcspi.c-  /* standard 4-wire host mode:  SCK, MOSI/out, MISO/in, nCS
    drivers/spi/spi-omap2-mcspi.c:   * REVISIT: this controller could support SPI_3WIRE mode.
    drivers/spi/spi-omap2-mcspi.c-   */
    drivers/spi/spi-omap2-mcspi.c-  if (mcspi->pin_dir == MCSPI_PINDIR_D0_IN_D1_OUT) {
    drivers/spi/spi-omap2-mcspi.c-          l &= ~OMAP2_MCSPI_CHCONF_IS;
    drivers/spi/spi-omap2-mcspi.c-          l &= ~OMAP2_MCSPI_CHCONF_DPE1;
    drivers/spi/spi-omap2-mcspi.c-          l |= OMAP2_MCSPI_CHCONF_DPE0;
    drivers/spi/spi-omap2-mcspi.c-  } else {
    drivers/spi/spi-omap2-mcspi.c-          l |= OMAP2_MCSPI_CHCONF_IS;
    drivers/spi/spi-omap2-mcspi.c-          l |= OMAP2_MCSPI_CHCONF_DPE1;
    drivers/spi/spi-omap2-mcspi.c-          l &= ~OMAP2_MCSPI_CHCONF_DPE0;
    drivers/spi/spi-omap2-mcspi.c-  }
    

    What you can do is one of two things:

    1. Add 3-wire SPI support to the driver yourself. Also ideally submitting the updated driver to the open source community (Linux kernel SPI SS-related mailing lists). Some basic hints how to do that can be found here: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/216583/am335x-spi-in-3-wire-mode-not-working

      or

    2. Use the existing bit-bang SPI driver, which does support 3-wire SPI mode. For this, enable CONFIG_SPI_BITBANG, and configure the device tree node accordingly.

    Regards, Andreas

  • Hi Andres, 

    Thanks for your reply. I've been researching how to do the first option and I haven't found any references about it and I think it's more complicated than option 2. So I'll try to implement the SPI_BITBANG.


    What should I do in the system that uses this type of SPI? In the Device Tree?

    Thanks, 

    Xavier