Received: by 2002:ab2:6816:0:b0:1f9:5764:f03e with SMTP id t22csp3142025lqo; Tue, 21 May 2024 08:02:43 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXLUZa83U5fHsl4VWMoX7uaEAKk4OufSSfBzUUL4fedWuov2Kkhwf/zrf8iOZdORnpAqh/9F2bcmXepPEgDaBNUFAyz6TB1e7q2v4gBdA== X-Google-Smtp-Source: AGHT+IHkjIpuOz5aBkaZ91PICrBXbMSxCmN3449y7kZgzXCyzXeARewzluPHVOhyh+aQPUw9iFZD X-Received: by 2002:a50:8a84:0:b0:572:7280:89d6 with SMTP id 4fb4d7f45d1cf-5734d597a25mr22647098a12.7.1716303763619; Tue, 21 May 2024 08:02:43 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1716303763; cv=pass; d=google.com; s=arc-20160816; b=zDQ0bq9pFZdrYtMmerDwSxwjPEqleUv59dAlvIeIN7nxwRUA2l68ue6tzWlaD5WYqP c1+so+Qm+dLG4qwhzGej+vq+lEAiT7IzEWw+l3rGKtt470hP6/dePtgvjR7u+d2xzrV1 L4uymF4clFTbQ823yqwcywGhLZh5elxkyIRuMo904cJaez5bKUm/9StjZjkbSSY80gxp McCGw6fjt3qTxJtGHM8+4D0zw6paKXTzsTJ3ULCnmyEQoJRMdjhXOP1MmWIf3pKratSI TtQDR8WpzwnFBVKt9VZFDFmmmPY4RjR6pAjngQxBZQnp4G6gboFMS19ufuf6MEflPnBI JeQw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence:dkim-signature; bh=UFu95vOoj5bW2XTxghArbd4qSupe0m5MmILzZ30l7Aw=; fh=j3dj3fiydNY7rGeJ6NoaDdglzZ/XnvFeDWmPzVtpx54=; b=ohbECd5NGiQ3MgxeyjHH8W7EFqIWQQa+RFlk/gmTO5/iLyxHMkvTUmayEDH+93cd7q JJODyGNCMij6icxS7lXg13LQID5iD2NRcpQ9ulijro72aqFvJdKZOWjCcHJE7sypVu3X ktl8MApk7jEIMy2UxgbPYIaYaHZiQQEnIjV0NJzcEqi2tJQpZWRzl79vM031pF6I50po BJLYQWfLMKuE/CmQ3fF5fGlC6CK4BWVIoTCA0DmJPzsAy/Uaw9Z9Y+xf9dRaTTgVoNke fZ7hJS2Dzly+Il06hQWWt9P+mW148gtE6qwvyvNZno1la6vsi9Oa/HgOJNXZ9EM3zTZ2 wNsQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=15jF+70K; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-185122-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185122-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id 4fb4d7f45d1cf-5733c378189si14832081a12.636.2024.05.21.08.02.43 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 21 May 2024 08:02:43 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-185122-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@baylibre-com.20230601.gappssmtp.com header.s=20230601 header.b=15jF+70K; arc=pass (i=1 spf=pass spfdomain=baylibre.com dkim=pass dkdomain=baylibre-com.20230601.gappssmtp.com); spf=pass (google.com: domain of linux-kernel+bounces-185122-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-185122-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 799801F24E97 for ; Tue, 21 May 2024 14:55:06 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 478BD142E71; Tue, 21 May 2024 14:54:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b="15jF+70K" Received: from mail-lj1-f170.google.com (mail-lj1-f170.google.com [209.85.208.170]) (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 E026212F58F for ; Tue, 21 May 2024 14:54:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716303296; cv=none; b=IuxWqVmOQh0RmwFesxX1EC84JulcVQXf0sLvLIN5Z6ReMkNkHF/oURqD82QP1cBUS+VBlHb7I45iiLvjtmYQAkRO8STpX6NNsbUX5aZxMn/fLqBVL0FB5fMpVV0px1jba4OZE8bO7UyAASQjGOxuuWGM5sBUi6D+SVjlgt4Bo6Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716303296; c=relaxed/simple; bh=HExgP0UYmWHiIsG1bF7bZ/RKwazxb3rDDOvRb04YALU=; h=MIME-Version:References:In-Reply-To:From:Date:Message-ID:Subject: To:Cc:Content-Type; b=WOxJiMlZX23QfH5F/JxVZJnU3Yv4uE+vSCbj1bWjNf09XrNSIdz/iTgfcZjy7r5DR8Fwxpe7FMP4CDsA7YrT23nqSh4MKguqtgNO0atBqwnYOMEHuwuX/hAshvzvl/flkFLSptIAJn05Acr+VQzzMk4IYS7+qbcx7dqT4CSnbJQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com; spf=pass smtp.mailfrom=baylibre.com; dkim=pass (2048-bit key) header.d=baylibre-com.20230601.gappssmtp.com header.i=@baylibre-com.20230601.gappssmtp.com header.b=15jF+70K; arc=none smtp.client-ip=209.85.208.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=baylibre.com Received: by mail-lj1-f170.google.com with SMTP id 38308e7fff4ca-2e72224c395so25914901fa.3 for ; Tue, 21 May 2024 07:54:52 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20230601.gappssmtp.com; s=20230601; t=1716303291; x=1716908091; darn=vger.kernel.org; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=UFu95vOoj5bW2XTxghArbd4qSupe0m5MmILzZ30l7Aw=; b=15jF+70KSeCvYTvP8SJ/CYiNXtKpONI1YdvEx/HTJlhKzjovqGoQo64XPrFZiF7sOD dKegC9zl0ibkZdQRb2IFT/b4A9ha4i3luzcAljZLF6mFDtVgbB2cCZtt5qPh9wPUrYvX osoUmApFOQmRfhszXyJ6FOv1EOixUWGehiiYAPf+hRmNkTfvx0/xva1UmnZ/IgHkk44U AmXyPBnG32+/nJPrEVgcYiRQHJIkDKZAaGSydV90Wm/6YkRfStNYdC8HVHzeqXnM4MCu 2pavInw/OWIIGMMXmA3xAMpXWAViCV52aBUMoQpjShFTygsR1AGnrWzWG6aj4tNdC79n ScWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716303291; x=1716908091; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=UFu95vOoj5bW2XTxghArbd4qSupe0m5MmILzZ30l7Aw=; b=nYoGetN8WRWr79ah4tWBKSuHUe4Rpwi4vPaS6NTWDRi338K8hL7OQQwuawgnnF9hXU 5qeygyPY2y0Xo010BZwGR5+RS1saY4zrWLZcMElxje20jzhQMSYTeRRmRfskkVS71wsy x0lxYU93QpA0My1x6eqOFSL0KpgJiEQPyf2vXFx4UiMXKjfW35Fcxl/CPv+tl9KOmSGY 8ITXGgy9boE0LD3ke4BmCpwAf1BOMTXvdWc1myOHVrO7VFFmR/Ez8yLaH/MBaEGlAa2o QaC9nGXGy/hpDcJIGGstO6Z3YPumwoWZIuNPkJ32xvqVxD8YkX4CImm1cqk5t2BaJfDs v7Qw== X-Forwarded-Encrypted: i=1; AJvYcCUd/fYS5sJRpALHMONTtBYewAstXzH6ObQj74gQXSkNR45sIw0/2aSpJBUsi7ghJkZbwZKEnDsM4DkuNrVTP8yUmxNFMSYSwlfIiMzc X-Gm-Message-State: AOJu0YxsUAgUoclcpZqNm5JfAY5rUhrOZPdyHobSxgidzFoiwvos3EmM FYbLGEAYO9t+3O05FBASbzvFIM89WIcxirM2Qf2cED9Fyk5Yo3dpskqMTD+jWXbPPZpNNqrOvMk DTKrhg6I65qXUjyHTrbmNpXoZpy5WNkWXEctTEg== X-Received: by 2002:a2e:95cc:0:b0:2e7:b29:c0a9 with SMTP id 38308e7fff4ca-2e70b29c0e8mr88170311fa.30.1716303290827; Tue, 21 May 2024 07:54:50 -0700 (PDT) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20240510-dlech-mainline-spi-engine-offload-2-v2-0-8707a870c435@baylibre.com> <20240510-dlech-mainline-spi-engine-offload-2-v2-1-8707a870c435@baylibre.com> <20240513-headsman-hacking-d51fcc811695@spud> <20240514-aspire-ascension-449556da3615@spud> <20240516-rudder-reburial-dcf300504c0a@spud> <20240519-abreast-haziness-096a57ef57d3@spud> In-Reply-To: <20240519-abreast-haziness-096a57ef57d3@spud> From: David Lechner Date: Tue, 21 May 2024 09:54:39 -0500 Message-ID: Subject: Re: [PATCH RFC v2 1/8] spi: dt-bindings: spi-peripheral-props: add spi-offloads property To: Conor Dooley Cc: Mark Brown , Jonathan Cameron , Rob Herring , Krzysztof Kozlowski , Conor Dooley , =?UTF-8?B?TnVubyBTw6E=?= , Michael Hennerich , Lars-Peter Clausen , David Jander , Martin Sperl , linux-spi@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-iio@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Sun, May 19, 2024 at 7:53=E2=80=AFAM Conor Dooley wro= te: > > On Fri, May 17, 2024 at 11:51:58AM -0500, David Lechner wrote: > > On Thu, May 16, 2024 at 4:32=E2=80=AFPM Conor Dooley = wrote: > > > On Tue, May 14, 2024 at 05:56:47PM -0500, David Lechner wrote: > > > > > Back to "something beyond the SPI controller": > > > > > > > > Here are some examples of how I envision this would work. > > > > > > > > Let's suppose we have a SPI controller that has some sort of offloa= d > > > > capability with a configurable trigger source. The trigger can eith= er > > > > be an internal software trigger (i.e. writing a register of the SPI > > > > controller) or and external trigger (i.e. a input signal from a pin= on > > > > the SoC). The SPI controller has a lookup table with 8 slots where = it > > > > can store a series of SPI commands that can be played back by > > > > asserting the trigger (this is what provides the "offloading"). > > > > > > > > So this SPI controller would have #spi-offload-cells =3D <2>; where= the > > > > first cell would be the index in the lookup table 0 to 7 and the > > > > second cell would be the trigger source 0 for software or 1 for > > > > hardware. > > > > > > > > Application 1: a network controller > > > > > > > > This could use two offloads, one for TX and one for RX. For TX, we = use > > > > the first slot with a software trigger because the data is coming f= rom > > > > Linux. For RX we use the second slot with a hardware trigger since > > > > data is coming from the network controller (i.e. a data ready signa= l > > > > that would normally be wired to a gpio for interrupt but wired to t= he > > > > SPI offload trigger input pin instead). So the peripheral bindings > > > > would be: > > > > > > > > #define SOFTWARE_TRIGGER 0 > > > > #define HARDWARE_TRIGGER 1 > > > > > > > > can@0 { > > > > ... > > > > spi-offloads =3D <0 SOFTWARE_TRIGGER>, <1 HARDWARE_TRIGGER>; > > > > /* maybe we need names too? */ > > > > spi-offload-names =3D "tx", "rx"; > > > > }; > > > > > > > > In this case, there is nothing extra beyond the SPI controller and = the > > > > network controller, so no extra bindings beyond this are needed. > > > > > > > > Application 2: an advanced ADC + FPGA > > > > > > > > This is basically the same as the ad7944 case seen already with one > > > > extra feature. In this case, the sample data also contains a CRC by= te > > > > for error checking. So instead of SPI RX data going directly to DMA= , > > > > the FPGA removes the CRC byte from the data stream an only the samp= le > > > > data goes to the DMA buffer. The CRC is checked and if bad, an > > > > interrupt is asserted. > > > > > > > > Since this is an FPGA, most everything is hardwired rather than hav= ing > > > > any kind of mux selection so #spi-offload-cells =3D <1>; for this > > > > controller. > > > > > > > > By adding spi-offloads to the peripheral node, it also extends the > > > > peripheral binding to include the additional properties needed for = the > > > > extra features provided by the FPGA. In other words, we are saying > > > > this DT node now represents the ADC chip plus everything connected = to > > > > the offload instance used by the ADC chip. > > > > > > It seems very strange to me that the dmas and the clock triggers are > > > going into the spi device nodes. The description is > > > | + dmas: > > > | + maxItems: 1 > > > | + description: RX DMA Channel for receiving a samples from the S= PI offload. > > > But as far as I can tell this device is in a package of its own and n= ot > > > some IP provided by Analog that an engine on the FPGA can actually do > > > DMA to, and the actual connection of the device is "just" SPI. > > > The dmas and clock triggers etc appear to be resources belonging to t= he > > > controller that can "assigned" to a particular spi device. If the adc > > > gets disconnected from the system, the dmas and clock triggers are st= ill > > > connected to the spi controller/offload engine, they don't end up n/c= , > > > right? (Well maybe they would in the case of a fancy SPI device that > > > provides it's own sampling clock or w/e, but then it'd be a clock > > > provider of sorts). I'd be expecting the spi-offloads property to be > > > responsible for selecting which of the various resources belonging to > > > the controller are to be used by a device. > > > Maybe it overcomplicates the shit out of things and Rob or Mark are > > > gonna start screaming at me but w/e, looking at it from the point of > > > view of how the hardware is laid out (or at least how it is described > > > in your FPGA case above) the dma/clock properties looks like they're > > > misplaced. IOW, I don't think that adding the spi-offloads property > > > should convert a node from representing an ADC in a qfn-20 or w/e > > > to "the ADC chip plus everything connected to the offload instance > > > used by the ADC chip". > > > > This is the same reasoning that led me to the binding proposed in v1. > > Rob suggested that these extras (dmas/clocks) should just be > > properties directly of the SPI controller. > > > But the issue I have with > > that is that since this is an FPGA, these properties are not fixed. > > I don't think whether or not we're talking about an FPGA or an ASIC > matters at all here to be honest. In my view the main thing that FPGA > impact in terms of bindings is the number of properties required to > represent the configurability of a particular IP. Sure, you're gonna > have to change the dts around in a way you'll never have to with an > ASIC, but the description of individual devices or relations between > them doesn't change. > > > Maybe there are more clocks or no clocks or interrupts or something we > > didn't think of yet. > > This could happen with a new generation of an ASIC and is not specific > to an FPGA IP core. Even with FPGA IP, while there may be lots of > different configuration parameters, they are known & limited - you can > look at the IP's documentation (or failing that, the HDL) to figure out > what the points of variability are. It's not particularly difficult to > account for there being a configurable number of clocks or interrupts. > For "something we didn't think of yet" to be a factor, someone has to > think of it and add it to the IP core, and which point we can absolutely > change the bindings and software to account for the revised IP. > > > So it doesn't really seem possible to write a > > binding for the SPI controller node to cover all of these cases. > > I dunno, I don't think your concerns about numbers of clocks (or any > other such property) are unique to this particular use-case. > > > These > > extras are included in the FPGA bitstream only for a specific type of > > peripheral, not for general use of the SPI controller with any type of > > peripheral. > > I accept that, but what I was trying to get across was that you could > configure the FPGA with a bitstream that contains these extra resources > and then connect a peripheral device that does not make use of them at > all. Sure, in this case the peripheral has no spi-offloads property and the SPI controller acts as a typical SPI controller. > Or you could connect a range of different peripherals that do use > them. OK, you've got me thinking about something I hadn't really thought about ye= t. > Whether or not the resources are there and how they are connected > in the FPGA bitstream is not a property of the device connected to the > SPI controller, only whether or not you use them is. > Even when those things are connected directly to a specific peripheral device? Or not connected to the offload? Here is another potential ADC trigger case to consider. +-------------------------------+ +------------------+ | | | | | SOC/FPGA | | ADC | | +---------------------+ | | | | | AXI SPI Engine | | | | | | SPI Bus =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SPI Bus = | | | | | | | | | +---------------+ | < < < < < BUSY | | | | Offload 0 | | v | | | | | | | | v > > > > CNV | | | | TRIGGER IN < < < ^ | | | | | +---------------+ | ^ | +------------------+ | +---------------------+ ^ | | | AXI PWM | ^ | | | CH0 > > ^ | | +---------------------+ | | | +-------------------------------+ This time, the periodic trigger (PWM) is connected to the pin on the ADC that triggers a sample conversion (CNV). The ADC has a BUSY output that will go high at the start of the conversion and go low at the end of the conversion. The BUSY output of the ADC is wired as the hardware trigger input of the offload. In this case would we still consider the PWM as part of the SPI controller/offload since it can only be used in conjunction with the SPI offload? It isn't connected to it at all though. Another case could be a self-clocked ADC. Here, the ADC has it's own periodic sample trigger on the chip and the RDY output goes high whenever a sample is ready to read. +-------------------------------+ +------------------+ | | | | | SOC/FPGA | | ADC | | +---------------------+ | | | | | AXI SPI Engine | | | | | | SPI Bus =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D SPI Bus = | | | | | | | | | +---------------+ | < < < < < RDY | | | | Offload 0 | | v | | | | | | | | v | | | | | | TRIGGER IN < < < | | | | | +---------------+ | | +------------------+ | +---------------------+ | | | +-------------------------------+ If both of these are valid wiring configurations for the same ADC, wouldn't it make more sense to describe this in the peripheral node rather than having to query the controller to see how the peripheral is wired up? > In fact, looking at the documentation for the "spi engine" some more, I > am even less convinced that the right place for describing the offload is > the peripheral as I (finally?) noticed that the registers for the offload > engine are mapped directly into the "spi engine"'s memory map, rather tha= n > it being a entirely separate IP in the FPGA fabric. True, but we don't use these registers, e.g., to configure the sampling frequency of a trigger (if it can even be done). That is done in a completely separate IP block with it's own registers. > > Further, what resources are available depends on what the SPI offload > engine IP is. If my employer decides to start shipping some SPI offload > IP in our catalogue that can work with ADI's ADCs, the set of offload > related properties or their names may well differ. If all of these resources were fairly generic, like the periodic trigger we've been discussing, then I could see the case for trying to accommodate this the same way we do for other common features of SPI controllers. But for cases like "Application 2" that I described previously, these resources can get very specific to a peripheral (like the example given of having a data processing unit that knows about the exact data format and CRC algorithm used by a specific ADC). These seems like too specific of a thing to say that a SPI controller "supports". But, OK, let's go with the idea of putting everything related to the offloads in the SPI controller node an see where it takes us... spi@1000 { compatible =3D "adi,axi-spi-engine"; #spi-offload-cells =3D <1>; /* PWM is connected to offload hardware trigger. DMA for streaming samp= le * data can only handle 16-bit words. IIO hardware buffer will be CPU- * endian because data is streamed one word at a time. */ spi-offload-0-capabilities =3D "pwm-trigger", "16-bit-rx-dma"; /* pwm properties are only allowed because spi-offload-0-capabilities * contains "pwm-trigger" */ pwms =3D <&pwm 0>; pwm-names =3D "offload-0-pwm-trigger"; /* dma properties are only allowed because spi-offload-0-capabilities * contains "16-bit-rx-dma" */ dmas =3D <&dma 0>; dma-names =3D "offload-0-16-bit-rx"; ... adc@0 { compatible =3D "adi,ad7944"; spi-offloads =3D <0>; ... }; }; spi@2000 { compatible =3D "not-adi,other-spi-engine"; #spi-offload-cells =3D <1>; /* Clock is connected to offload hardware trigger. DMA for streaming sa= mple * data can only handle one byte at a time. IIO hardware buffer will be= big- * endian because data is streamed one byte at a time. */ spi-offload-0-capabilities =3D "clock-trigger", "8-bit-rx-dma"; /* Clock properties are extended because spi-offload-0-capabilities con= tains * "clock-trigger" and SPI controller itself has a clock */ clocks =3D <&cpu_clock 0>, <&extra_clock 0>; clock-names =3D "sclk", "offload-0-pwm-trigger"; /* DMA properties are extended because spi-offload-0-capabilities conta= ins * "8-bit-rx-dma". "tx" and "rx" are for non-offload use. */ dmas =3D <&dma1 0>, <&dma1 1>, <&dma2 0>; dma-names =3D "tx", "rx", "offload-0-16-bit-rx"; ... adc@0 { compatible =3D "adi,ad7944"; spi-offloads =3D <0>; ... }; }; spi@3000 { compatible =3D "adi,axi-spi-engine"; #spi-offload-cells =3D <1>; /* Sample ready signal (~BSY) from ADC is connected to offload hardware * trigger. DMA for streaming sample data can only handle 16-bit words.= */ spi-offload-0-capabilities =3D "sample-trigger", "16-bit-rx-dma"; /* Do we need a property to say that the sample trigger is connected to * adc@0 so that if adc@1 tries to use it, it will fail? */ /* dma properties are only allowed because spi-offload-0-capabilities * contains "16-bit-rx-dma" */ dmas =3D <&dma 0>; dma-names =3D "offload-0-16-bit-rx"; ... adc@0 { compatible =3D "adi,ad7944"; spi-offloads =3D <0>; ... /* PWM connected to the conversion pin (CNV). This only makes sense * when offload is used with BSY signal, otherwise we would have CN= V * connected to SPI CS. */ pwms =3D <&pwm 0>; pwm-names =3D "cnv"; }; }; spi@4000 { compatible =3D "adi,axi-spi-engine"; #spi-offload-cells =3D <1>; /* Sample ready signal (~BSY) from ADC is connected to offload hardware * trigger. DMA for streaming sample data can only handle 32-bit words. * This also has the CRC validation that strips off the CRC byte of the * raw data before passing the sample to DMA. */ spi-offload-0-capabilities =3D "sample-trigger", "32-bit-rx-dma-with-ad4630-crc-check"; /* dma properties are only allowed because spi-offload-0-capabilities * contains "16-bit-rx-dma" */ dmas =3D <&dma 0>; dma-names =3D "offload-0-16-bit-rx"; interrupt-parent =3D <&intc>; /* First interrupt is for the SPI controller (always present), second * interrupt is CRC error from the "32-bit-rx-dma-with-ad4630-crc-check= " * of offload 0. */ interrupts =3D <0 56 IRQ_TYPE_LEVEL_HIGH>, <0 58 IRQ_TYPE_LEVEL_HIGH>; interrupt-names =3D "controller", "offload-0-crc-error"; ... adc@0 { compatible =3D "adi,ad4630"; spi-offloads =3D <0>; ... /* PWM connected to the conversion pin (CNV). Without offload, we w= ould * have cnv-gpios instead. */ pwms =3D <&pwm 0>; pwm-names =3D "cnv"; }; }; So this is what I came up with of how things could look (combining suggestions from Rob in v1 and Conor's suggestions here). I can see how we can make this work. But the thing I don't like about it is that the peripheral drivers still need to know all of the information about the offload capabilities and need to interact with the pwms/clocks/interrupts/dmas/etc. So this is just adding layers of indirection where all of this stuff has to go through the SPI controller driver. > > > Another idea I had was to perhaps use the recently added IIO backend > > framework for the "extras". The idea there is that we are creating a > > "composite" IIO device that consists of the ADC chip (frontend) plus > > these extra hardware trigger and hardware buffer functions provided by > > the FPGA (backend). > > > > offload_backend: adc0-backend { > > /* http://analogdevicesinc.github.io/hdl/projects/pulsar_adc/index.= html */ > > compatible =3D "adi,pulsar-adc-offload"; > > #io-backend-cells =3D <0>; > > dmas =3D <&dma 0>; > > dma-names =3D "rx"; > > clocks =3D <&trigger_clock>; > > }; > > > > spi { > > ... > > adc@0 { > > ... > > spi-offloads =3D <0>; > > io-backends =3D <&offload_backend>; > > }; > > }; > > > > While this could be a solution for IIO devices, this wouldn't solve > > the issue in general though for SPI offloads used with non-IIO > > peripherals. > > Yeah, I agree that using something specific to IIO isn't really a good > solution. > > Cheers, > Conor. > > > So I don't think it is the right thing to do here. But, I > > think this idea of a "composite" device helps explain why we are > > pushing for putting the "extras" with the peripheral node rather than > > the controller node, at least for the specific case of the AXI SPI > > Engine controller. >