mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: David Lechner <dlechner@baylibre.com>
To: "Nuno Sá" <noname.nuno@gmail.com>,
	"Jonathan Santos" <Jonathan.Santos@analog.com>
Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org,
	nuno.sa@analog.com, michael.hennerich@analog.com,
	broonie@kernel.org, jonath4nns@gmail.com,
	marcelo.schmitt1@gmail.com, andy@kernel.org
Subject: Re: [PATCH 0/6] spi: add multi-CS and per-transfer lane mask support
Date: Tue, 14 Jul 2026 10:02:08 -0500	[thread overview]
Message-ID: <6576af52-19d1-4b79-879e-bbd09df40a7a@baylibre.com> (raw)
In-Reply-To: <eplbtsrc2rojtpuxdtcy7vp63fhzl4ckb5cobs45y6fmcjy3wj@g3ccws2qeg2d>

On 7/14/26 5:29 AM, Nuno Sá wrote:
> On Tue, Jul 14, 2026 at 02:55:31AM -0300, Jonathan Santos wrote:
>> This series introduces two SPI subsystem features: per-transfer chipselect
>> masks and multi-CS device support. Together they address the multi-device
>> setup described in [1] and the limitation noted in [2], where no SPI
>> controller completely handles logical chip selects beyond the first one.
>>
>> The first part of the set addresses multi-CS support. Some SPI controllers
>> can assert multiple chip selects simultaneously, but the existing code
>> hardcoded CS index 0 in both spi_set_cs() and of_spi_parse_dt(),
>> preventing this from working.
>>
>> The second part addresses dynamic lane selection for STRIPE mode. In
>> SPI_MULTI_LANE_MODE_STRIPE, all available lanes are currently always
>> active. Some peripherals need to select a different subset of rx/tx lanes
>> per transfer. New fields are added to the spi_transfer struct to allow
>> drivers to specify which lanes to use for each transfer. The documentation
>> is also updated to describe this new behavior.
>>
>> [1]: https://lore.kernel.org/linux-iio/af0EGv172ZMl%2F6N5@JSANTO12-L01.ad.analog.com/T/#t
>> [2]: https://lore.kernel.org/all/20250915183725.219473-1-jonas.gorski@gmail.com/
>>
>> Jonathan Santos (6):
>>   spi: support simultaneous assertion of multiple CS
>>   spi: add per-transfer CS mask
>>   spi: spi-engine-ex: Add support for multi-CS devices
>>   spi: Documentation: multiple-data-lanes: describe rx and tx lane mask
>>   spi: add rx and tx lane mask to spi_transfer struct
>>   spi: axi-spi-engine: add support for dynamic multi-lane selection
> 
> It would be nice to include an actual user for this in the series.

Agree.

For context, here is the scenario from [1] (with arrow directions fixed):

+---------------+                                                 
|     ADC 0     |                                                 
|               |                                                 
|        SYNC_IN|<--+---------------------------+                 
|          DRDY0|---|------------------------+  |                 
|               |   |                        |  |   +------------+
|          SCLK0|<--|------+                 |  |   |    HOST    |
|           SDI0|<--|------|--+              |  |   |            |
|            CS0|<--|------|--|-----------+  |  +---|ADC_SYNC    |
|          DOUT0|---|------|--|--------+  |  |      |            |
|               |   |      |  |        |  |  |      |            |
+---------------+   |      +--|--------|--|--|------|SCLK        |
                    |      |  +--------|--|--|------|MOSI        |
+---------------+   |      |  |        |  |  |      |            |
|     ADC 1     |   |      |  |        |  |  |      |            |
|               |   |      |  |        |  |  +----->|DRDY0       |
|        SYNC_IN|<--+      |  |        |  +---------|CS0         |
|          DRDY1|---|------|--|----+   +----------->|MISO0       |
|               |   |      |  |    |                |            |
|          SCLK1|<--|------+  |    |                |            |
|           SDI1|<--|------|--+    +--------------->|DRDY1       |
|            CS1|<--|------|--|---------------------|CS1         |
|          DOUT1|---|------|--|-------------------->|MISO1       |
|               |   |      |  |                     |            |
+---------------+   |      |  |                     | .          |
                    |      |  |                     | .          |
       ...          |      |  |                     | .          |
                    |      |  |                     |            |
+---------------+   |      |  |            +------->|DRDYN       |
|     ADC N     |   |      |  |            | +------|CSN         |
|               |   |      |  |            | | +--->|MISON       |
|        SYNC_IN|<--+      |  |            | | |    |            |
|          DRDYN|----------|--|------------+ | |    +------------+
|               |          |  |              | |                  
|          SCLKN|<---------+  |              | |                  
|           SDIN|<------------+              | |                  
|            CSN|<---------------------------+ |                  
|          DOUTN|------------------------------+                  
|               |                                                 
+---------------+  


And the proposed DT from the discussion in [1].

spi {
    #address-cells = <1>;
    #size-cells = <0>;

    adc@0 {
	compatible = "adi,adaq7768-1";
	reg = <0>, <1>, <2>, <3>;
        
        spi-rx-bus-width = <1>, <1>, <1>, <1>;

	/* other properties */
    };
};

As a refresher, the idea is that this is considered to be one big ADC
with more channels (for simultaneous sampling) even though it is
physically multiple chips. 

Currently, this series is treating CS selection and mutli-lane SPI line
selection as completely independent. However, clearly certain spi-rx-bus
lines are tightly coupled with certain CS lines.

To reflect that (and easier to use in peripheral drivers), I think we
could bake this correlation into the SPI core code.

So struct spi_device.rx_lane_map would become a 2-D array where the
first index is the logical CS (following the pattern of .chip_select)
and the second index is the existing one for the data lane.

The trivial implementation would be to assume that reg and spi-rx-bus-width
have the same length and there is just a 1-to-1 correspondence (first data
lane is associated with first CS, and so on).

And we could add a new DT property for more complex mappings (multiple
data lanes per CS or wires not connected in logical order). We probably
don't need to do that right now though if there are no expected users
at the moment.

Then we would only need to add the CS selection to struct spi_transfer
and the controller driver would just use the map to pick the correct
data lanes based on other parameters as it does now. (So no need to
add .rx_lane_mask to struct spi_transfer.)

This way, the ADC (SPI peripheral driver) can set 1 CS in order to
configure individual chips and then set all CS to read sample data.
And all of the data lane selection is all handled transparently between
the core SPI code and the SPI controller driver.

(And obviously everything above applies to tx too, I just wrote rx
everywhere to keep it shorter.)

> 
> - Nuno Sá
> 
>>
>>  Documentation/spi/multiple-data-lanes.rst |  30 ++++++
>>  drivers/spi/spi-axi-spi-engine.c          | 106 +++++++++++++++++-----
>>  drivers/spi/spi.c                         |  97 +++++++++++++++++---
>>  include/linux/spi/spi.h                   |  12 +++
>>  4 files changed, 206 insertions(+), 39 deletions(-)
>>
>>
>> base-commit: 093239070573637ad2b4cb56abc9c4c7ee109294
>> -- 
>> 2.34.1
>>


  reply	other threads:[~2026-07-14 15:02 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-14  5:55 Jonathan Santos
2026-07-14  5:55 ` [PATCH 1/6] spi: support simultaneous assertion of multiple CS Jonathan Santos
2026-07-14  9:06   ` Andy Shevchenko
2026-07-14  9:08   ` Nuno Sá
2026-07-14  5:56 ` [PATCH 2/6] spi: add per-transfer CS mask Jonathan Santos
2026-07-14  9:12   ` Nuno Sá
2026-07-14  9:23   ` Andy Shevchenko
2026-07-14  5:56 ` [PATCH 3/6] spi: spi-engine-ex: Add support for multi-CS devices Jonathan Santos
2026-07-14  9:17   ` Andy Shevchenko
2026-07-14  5:56 ` [PATCH 4/6] spi: Documentation: multiple-data-lanes: describe rx and tx lane mask Jonathan Santos
2026-07-14  5:56 ` [PATCH 5/6] spi: add rx and tx lane mask to spi_transfer struct Jonathan Santos
2026-07-14  9:22   ` Nuno Sá
2026-07-14  9:26   ` Andy Shevchenko
2026-07-14 15:18   ` David Lechner
2026-07-15 10:23     ` Nuno Sá
2026-07-14  5:57 ` [PATCH 6/6] spi: axi-spi-engine: add support for dynamic multi-lane selection Jonathan Santos
2026-07-14 10:29   ` Nuno Sá
2026-07-14  8:57 ` [PATCH 0/6] spi: add multi-CS and per-transfer lane mask support Andy Shevchenko
2026-07-14 14:09   ` David Lechner
2026-07-14 14:26     ` Andy Shevchenko
2026-07-14 14:44       ` David Lechner
2026-07-14 10:29 ` Nuno Sá
2026-07-14 15:02   ` David Lechner [this message]
2026-07-16 16:50     ` Jonathan Santos

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6576af52-19d1-4b79-879e-bbd09df40a7a@baylibre.com \
    --to=dlechner@baylibre.com \
    --cc=Jonathan.Santos@analog.com \
    --cc=andy@kernel.org \
    --cc=broonie@kernel.org \
    --cc=jonath4nns@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=marcelo.schmitt1@gmail.com \
    --cc=michael.hennerich@analog.com \
    --cc=noname.nuno@gmail.com \
    --cc=nuno.sa@analog.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome