From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f53.google.com (mail-ed1-f53.google.com [209.85.208.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id ADE703D7A0C for ; Thu, 16 Jul 2026 13:51:00 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.53 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784209862; cv=none; b=WQSF9nPOlz9ueqSeop9ahdHhXy6+CLgakcDeFwBao8dyachJZ7v3VXdhp3KkgJWUkWbwuN+z2IvMEC8aBwLedXlTg126yG3p4GofO1Xv7ymOZazYaHDKh9/w610D+xNiAxp6IOH+aYeU2TLrzhSuInlwhBsvbSv55vNKf+2+wtg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1784209862; c=relaxed/simple; bh=LtCVk3GlRvz5O/3cpR8WnyAUtXQ+EmvpDFP2wCdQ7gM=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Ur2fSSLJSBIqZSdjnQscmIV7IBHVn8RJ1w9ipBL9d3CHjRGj/2fIvkKzrCbCLYn+SIHj0eNwHaoJCV12WSN+UHwEczxnNZ43/gjSumgLnCsP7Gx5g2n4S3BEby7oJpbpq0ji4OPy7b+dhw5izp9fw2w1npvtfqjERazy88Uu31k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=T0C4XiTc; arc=none smtp.client-ip=209.85.208.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T0C4XiTc" Received: by mail-ed1-f53.google.com with SMTP id 4fb4d7f45d1cf-69c3044e4b2so1156092a12.2 for ; Thu, 16 Jul 2026 06:51:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20251104; t=1784209859; x=1784814659; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:from:to:cc:subject:date:message-id:reply-to:content-type; bh=0lc7I38yh7L/gqBncqtshTplNceE/IFKEhJvkcN3z1E=; b=T0C4XiTcMLFLW2jbfq8QujKdiZe3I6jI/rxrlP6ZR1/UmYxFjFUfj3SPe4S8L/tLM6 B9dJDlQkJS+v2GDWGbNqVQu2+CnJMzYyryz0sJgujI5NKNiaYpGo8jvtTYW2TJpVAlNB scF5cH5Hpvt4Jt4BJ6otS+mNMRrvx2xzc6GpVrFYAz82RpYmewopFFKH7mMEy7JlBuuu 1sYm1DDPj9Q/U7ZWM4Qk0qG4g7EoFdZXEoS7bEjhU8ME/6pwzTfp/rZvJvCfqYouQewu MdsrT2TXCqHYHgSVw1EM/9udnEHnZvmXNTA/a20eygBhpYbuusfyVhTghBwqbUA9WtkT ucpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1784209859; x=1784814659; h=in-reply-to:content-transfer-encoding:content-disposition :content-type:mime-version:references:message-id:subject:cc:to:from :date:x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to:content-type; bh=0lc7I38yh7L/gqBncqtshTplNceE/IFKEhJvkcN3z1E=; b=c5UneAOGhzf7pEdPBwkkaaUfRrGuW53ez4jgHumSfw3V2GqYQm9Xq2wqCviTNiRwXJ sOgzSRuEHThxbY/+HhqZkS22iXOqALPOqfYSj9v9k2DygWlHLHnP+xkSBnY4cOkywVL+ u50EbIURFoTKy7xYiAUbOinEachG6MdNELsFcbJ4pOl3Jgdz1jyqLHkoVFZ23bUOrPEU zTZbz6mPq8uuz/hqb2rRXHGg9FTCukC89yFynzfQXZATlW36Cn6/NBMuDvrc4pB3iKF3 qsXiGNU5t0rKRa1ESjiFl9g6VY1y1Unvy7S1r1GoDAEnqBdAPu21Nq4uVETNr+gwbxzV VN4w== X-Forwarded-Encrypted: i=1; AHgh+RqpXqTugloWYe224nvcRqYrA7bAcynFEnCo29Ifmb8WDC/OA1dmcfwqt4LJ1DQl44/ctSJj23U4NIm1SjU=@vger.kernel.org X-Gm-Message-State: AOJu0Yz9hQ9lTfIpntGLlga4VFHsiF4asMEihdry26ClxdvnlbjwTolf cxCY1wcVLtOxe4i5d5wpSmk6zOLbjCOUvtQS/9P+5kModWdSZ4DoiGP3 X-Gm-Gg: AfdE7cnE7Yb3cFeKCyWXapl65esvR9+EVsjJyKk7WIPxOBeLh8O3O1Spbq08Td8F7R9 pbTN0BMX/+UnISj1vzKxpD/GfrPeormy4IuZxX63RF2I5TQ5K/spNlX149ilBLORAwQJJ7ZWlTh lrxp5R+flnhqbWFyvrZNupRhH/ht5OXOBLAKfDhAgOWAxZ+EVKjl0/dbODRD3RHXT0xbGwWXy94 j/X32eNhDqE8/ot2XFoBwKIl2H+TuwEEmw1poNGPjInGZH14JkHs4/VxMPv9wB2iJBUt70XGOdX Iyrw3zaDp8C0NzmTJY9QiDp8SOHDv+TjS427IqFUcCrLh52d9Km/nZ/wkOKBGCq4YbQbTD9vBqU LhPKK+IjHz+hWUA1XaftKEZrzapfD7GdBEvJkUqH7KeFmJ5ap+1rGMZFhA2EY336ZfdCS8WndBa m80CI0xzFKmlHxvb5c5ZkNeRVr2+zZCGmr X-Received: by 2002:a05:6402:2694:b0:699:6415:751e with SMTP id 4fb4d7f45d1cf-69c5f130032mr5962038a12.4.1784209858553; Thu, 16 Jul 2026 06:50:58 -0700 (PDT) Received: from JSANTO12-L01.ad.analog.com ([191.255.131.70]) by smtp.gmail.com with ESMTPSA id 4fb4d7f45d1cf-69e12ccd067sm2823890a12.21.2026.07.16.06.50.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 16 Jul 2026 06:50:57 -0700 (PDT) Date: Thu, 16 Jul 2026 13:50:37 -0300 From: Jonathan Santos To: David Lechner Cc: Nuno =?iso-8859-1?Q?S=E1?= , Jonathan Santos , linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, nuno.sa@analog.com, michael.hennerich@analog.com, broonie@kernel.org, marcelo.schmitt1@gmail.com, andy@kernel.org Subject: Re: [PATCH 0/6] spi: add multi-CS and per-transfer lane mask support Message-ID: References: <6576af52-19d1-4b79-879e-bbd09df40a7a@baylibre.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <6576af52-19d1-4b79-879e-bbd09df40a7a@baylibre.com> On 07/14, David Lechner wrote: > 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 Hi david, Thanks for the suggestions! > > > > 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). > I like the idea of binding the CS to rx/tx lanes. I have a concern though: could this 1-1 correspondence break the current implementations where we have multiple data lanes per channel and only one CS? (and in those cases spi-rx-lane-map is ommited, so it is used the default mapping based on the spi-rx-bus-width). Also, could we extend the ancillary device framework to deal with the multiple data lanes? Maybe it is easier to bind the logical CS with the data lanes in there because there is the assumption of sub-devices with multiple CS (even if we don't use the ancillary device for this case). > 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.) > Yes, this is less prone to mistakes. > 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. > Another concern with the CS selection is how to handle this in the driver using regmap (i will add the driver patches in the next version). I Created custom regmap write and read handlers and a regmap instace for each sub-device. Each instace have a context data with the corresponding CS mask, but it looks overcomplicated. Dealing with this correlation in the ancillary would be simpler. Don't know if this makes sense. > (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 > >>