TK1 SPI cs-inactive-cycles

Looking at the source of the latest TK1 L4T 21.5 (spi-tegra114.c), there is no support for setting the CS_ACTIVE_BETWEEN_PACKETS and CYCLES_BETWEEN_PACKETS bits inside the SPI_TIMING2 registers.

The default value of CS_ACTIVE_BETWEEN_PACKETS is 1 which means CS is active between packets, and stays active through the SPI transaction. This is critical for some SPI peripherals like AD5542 DAC which requires the CS rising edge to work.

Is there any way to set this in the SPI driver for the TK1?

Hi notthetup,

We’re investigating this issue, the suggestion will be update soon.

Thanks

Hi,

We are facing the same issue. The first snippet does not change CS between transfers:

struct spi_message msg;
        struct spi_transfer tx[2] = {
                {
                        .tx_buf = write_map_cmd,
                        .len = ARRAY_SIZE(write_map_cmd),
                        // deassert CS, actually it does NOT change CS
                        .cs_change = 1,
                        .delay_usecs = 1
                }, {
                        .tx_buf = tx_buf,
                        .rx_buf = rx_buf,
                        .len = len,
                },
        };
 
        tx_buf[0] = SPI_READ_CMD;
 
        spi_message_init_with_transfers(&msg, tx, ARRAY_SIZE(tx));
        ret = spi_sync(spi, &msg);

Whilst this second snippet does change CS:

/* FIXME */
        spi_message_init(&msg);
        spi_message_add_tail(&tx[0], &msg);
        ret = spi_sync(spi, &msg);

        spi_message_init(&msg);
        spi_message_add_tail(&tx[1], &msg);
        ret = spi_sync(spi, &msg);

Hi notthetup
The CS_ACTIVE_BETWEEN_PACKETS and CYCLES_BETWEEN_PACKETS are implement after r24.2, for the TK1(r21) I made a patch pull from r24 but not verify it yet. You need add below information in the DT.

nvidia,clk-delay-between-packets : delay in terms of clock required between each packet
nvidia,chipselect-gpio: gpio value of the chip select in use for this client device. (SPI chip select will be left in gpio mode to emulate active delay while hardware does inactive delay)
spi.tar.gz (3.33 KB)

Great! Thanks @ShaneCCC. Where can I find this patch? What’s the git url for the Linux4Tegra kernel git repo?

There’s attached file spi.tar.gz. You can go to below link to download the kernel source.

Thanks!