Unverified Commit f46eb2bf authored by Mark Brown's avatar Mark Brown
Browse files

spi: axi-spi-engine: add offload support

Merge series from David Lechner <dlechner@baylibre.com>:

As a recap, here is the background and end goal of this series:

The AXI SPI Engine is a SPI controller that has the ability to record a
series of SPI transactions and then play them back using a hardware
trigger. This allows operations to be performed, repeating many times,
without any CPU intervention. This is needed for achieving high data
rates (millions of samples per second) from ADCs and DACs that are
connected via a SPI bus.

The offload hardware interface consists of a trigger input and a data
output for the RX data. These are connected to other hardware external
to the SPI controller.

To record one or more transactions, commands and TX data are written
to memories in the controller (RX buffer is not used since RX data gets
streamed to an external sink). This sequence of transactions can then be
played back when the trigger input is asserted.

This series includes core SPI support along with the first SPI
controller (AXI SPI Engine) and SPI peripheral (AD7944 ADC) that use
them. This enables capturing analog data at 2 million samples per
second.

The hardware setup looks like this:

+-------------------------------+   +------------------+
|                               |   |                  |
|  SOC/FPGA                     |   |  AD7944 ADC      |
|  +---------------------+      |   |                  |
|  | AXI SPI Engine      |      |   |                  |
|  |             SPI Bus ============ SPI Bus          |
|  |                     |      |   |                  |
|  |  +---------------+  |      |   |                  |
|  |  | Offload 0     |  |      |   +------------------+
|  |  |   RX DATA OUT > > > >   |
|  |  |    TRIGGER IN < < <  v  |
|  |  +---------------+  | ^ v  |
|  +---------------------+ ^ v  |
|  | AXI PWM             | ^ v  |
|  |                 CH0 > ^ v  |
|  +---------------------+   v  |
|  | AXI DMA             |   v  |
|  |                 CH0 < < <  |
|  +---------------------+      |
|                               |
+-------------------------------+
parents 9bbbf33a 5a19e198
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -41,6 +41,26 @@ properties:
      - const: s_axi_aclk
      - const: spi_clk

  trigger-sources:
    description:
      An array of trigger source phandles for offload instances. The index in
      the array corresponds to the offload instance number.
    minItems: 1
    maxItems: 32

  dmas:
    description:
      DMA channels connected to the input or output stream interface of an
      offload instance.
    minItems: 1
    maxItems: 32

  dma-names:
    items:
      pattern: "^offload(?:[12]?[0-9]|3[01])-[tr]x$"
    minItems: 1
    maxItems: 32

required:
  - compatible
  - reg
@@ -59,6 +79,10 @@ examples:
        clocks = <&clkc 15>, <&clkc 15>;
        clock-names = "s_axi_aclk", "spi_clk";

        trigger-sources = <&trigger_clock>;
        dmas = <&dma 0>;
        dma-names = "offload0-rx";

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

+37 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/trigger-source/pwm-trigger.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Generic trigger source using PWM

description: Remaps a PWM channel as a trigger source.

maintainers:
  - David Lechner <dlechner@baylibre.com>

properties:
  compatible:
    const: pwm-trigger

  '#trigger-source-cells':
    const: 0

  pwms:
    maxItems: 1

required:
  - compatible
  - '#trigger-source-cells'
  - pwms

additionalProperties: false

examples:
  - |
    trigger {
        compatible = "pwm-trigger";
        #trigger-source-cells = <0>;
        pwms = <&pwm 0 1000000 0>;
    };
+12 −0
Original line number Diff line number Diff line
@@ -22295,6 +22295,13 @@ F: Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
F:	drivers/mtd/spi-nor/
F:	include/linux/mtd/spi-nor.h
SPI OFFLOAD
R:	David Lechner <dlechner@baylibre.com>
F:	drivers/spi/spi-offload-trigger-pwm.c
F:	drivers/spi/spi-offload.c
F:	include/linux/spi/spi-offload.h
K:	spi_offload
SPI SUBSYSTEM
M:	Mark Brown <broonie@kernel.org>
L:	linux-spi@vger.kernel.org
@@ -24050,6 +24057,11 @@ W: https://github.com/srcres258/linux-doc
T:	git git://github.com/srcres258/linux-doc.git doc-zh-tw
F:	Documentation/translations/zh_TW/
TRIGGER SOURCE - PWM
M:	David Lechner <dlechner@baylibre.com>
S:	Maintained
F:	Documentation/devicetree/bindings/trigger-source/pwm-trigger.yaml
TRUSTED SECURITY MODULE (TSM) ATTESTATION REPORTS
M:	Dan Williams <dan.j.williams@intel.com>
L:	linux-coco@lists.linux.dev
+16 −0
Original line number Diff line number Diff line
@@ -55,6 +55,9 @@ config SPI_MEM
	  This extension is meant to simplify interaction with SPI memories
	  by providing a high-level interface to send memory-like commands.

config SPI_OFFLOAD
	bool

comment "SPI Master Controller Drivers"

config SPI_AIROHA_SNFI
@@ -176,6 +179,7 @@ config SPI_AU1550
config SPI_AXI_SPI_ENGINE
	tristate "Analog Devices AXI SPI Engine controller"
	depends on HAS_IOMEM
	select SPI_OFFLOAD
	help
	  This enables support for the Analog Devices AXI SPI Engine SPI controller.
	  It is part of the SPI Engine framework that is used in some Analog Devices
@@ -1317,4 +1321,16 @@ endif # SPI_SLAVE
config SPI_DYNAMIC
	def_bool ACPI || OF_DYNAMIC || SPI_SLAVE

if SPI_OFFLOAD

comment "SPI Offload triggers"

config SPI_OFFLOAD_TRIGGER_PWM
	tristate "SPI offload trigger using PWM"
	depends on PWM
	help
	  Generic SPI offload trigger implemented using PWM output.

endif # SPI_OFFLOAD

endif # SPI
+4 −0
Original line number Diff line number Diff line
@@ -10,6 +10,7 @@ ccflags-$(CONFIG_SPI_DEBUG) := -DDEBUG
obj-$(CONFIG_SPI_MASTER)		+= spi.o
obj-$(CONFIG_SPI_MEM)			+= spi-mem.o
obj-$(CONFIG_SPI_MUX)			+= spi-mux.o
obj-$(CONFIG_SPI_OFFLOAD)		+= spi-offload.o
obj-$(CONFIG_SPI_SPIDEV)		+= spidev.o
obj-$(CONFIG_SPI_LOOPBACK_TEST)		+= spi-loopback-test.o

@@ -163,3 +164,6 @@ obj-$(CONFIG_SPI_AMD) += spi-amd.o
# SPI slave protocol handlers
obj-$(CONFIG_SPI_SLAVE_TIME)		+= spi-slave-time.o
obj-$(CONFIG_SPI_SLAVE_SYSTEM_CONTROL)	+= spi-slave-system-control.o

# SPI offload triggers
obj-$(CONFIG_SPI_OFFLOAD_TRIGGER_PWM)	+= spi-offload-trigger-pwm.o
Loading