Skip to content

Commit f46eb2b

Browse files
committed
spi: axi-spi-engine: add offload support
Merge series from David Lechner <[email protected]>: 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 < < < | | +---------------------+ | | | +-------------------------------+
2 parents 9bbbf33 + 5a19e19 commit f46eb2b

File tree

13 files changed

+1243
-7
lines changed

13 files changed

+1243
-7
lines changed

Documentation/devicetree/bindings/spi/adi,axi-spi-engine.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,26 @@ properties:
4141
- const: s_axi_aclk
4242
- const: spi_clk
4343

44+
trigger-sources:
45+
description:
46+
An array of trigger source phandles for offload instances. The index in
47+
the array corresponds to the offload instance number.
48+
minItems: 1
49+
maxItems: 32
50+
51+
dmas:
52+
description:
53+
DMA channels connected to the input or output stream interface of an
54+
offload instance.
55+
minItems: 1
56+
maxItems: 32
57+
58+
dma-names:
59+
items:
60+
pattern: "^offload(?:[12]?[0-9]|3[01])-[tr]x$"
61+
minItems: 1
62+
maxItems: 32
63+
4464
required:
4565
- compatible
4666
- reg
@@ -59,6 +79,10 @@ examples:
5979
clocks = <&clkc 15>, <&clkc 15>;
6080
clock-names = "s_axi_aclk", "spi_clk";
6181
82+
trigger-sources = <&trigger_clock>;
83+
dmas = <&dma 0>;
84+
dma-names = "offload0-rx";
85+
6286
#address-cells = <1>;
6387
#size-cells = <0>;
6488
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/trigger-source/pwm-trigger.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Generic trigger source using PWM
8+
9+
description: Remaps a PWM channel as a trigger source.
10+
11+
maintainers:
12+
- David Lechner <[email protected]>
13+
14+
properties:
15+
compatible:
16+
const: pwm-trigger
17+
18+
'#trigger-source-cells':
19+
const: 0
20+
21+
pwms:
22+
maxItems: 1
23+
24+
required:
25+
- compatible
26+
- '#trigger-source-cells'
27+
- pwms
28+
29+
additionalProperties: false
30+
31+
examples:
32+
- |
33+
trigger {
34+
compatible = "pwm-trigger";
35+
#trigger-source-cells = <0>;
36+
pwms = <&pwm 0 1000000 0>;
37+
};

MAINTAINERS

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22295,6 +22295,13 @@ F: Documentation/devicetree/bindings/mtd/jedec,spi-nor.yaml
2229522295
F: drivers/mtd/spi-nor/
2229622296
F: include/linux/mtd/spi-nor.h
2229722297

22298+
SPI OFFLOAD
22299+
R: David Lechner <[email protected]>
22300+
F: drivers/spi/spi-offload-trigger-pwm.c
22301+
F: drivers/spi/spi-offload.c
22302+
F: include/linux/spi/spi-offload.h
22303+
K: spi_offload
22304+
2229822305
SPI SUBSYSTEM
2229922306
M: Mark Brown <[email protected]>
2230022307
@@ -24050,6 +24057,11 @@ W: https://github.com/srcres258/linux-doc
2405024057
T: git git://github.com/srcres258/linux-doc.git doc-zh-tw
2405124058
F: Documentation/translations/zh_TW/
2405224059

24060+
TRIGGER SOURCE - PWM
24061+
M: David Lechner <[email protected]>
24062+
S: Maintained
24063+
F: Documentation/devicetree/bindings/trigger-source/pwm-trigger.yaml
24064+
2405324065
TRUSTED SECURITY MODULE (TSM) ATTESTATION REPORTS
2405424066
M: Dan Williams <[email protected]>
2405524067

drivers/spi/Kconfig

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,9 @@ config SPI_MEM
5555
This extension is meant to simplify interaction with SPI memories
5656
by providing a high-level interface to send memory-like commands.
5757

58+
config SPI_OFFLOAD
59+
bool
60+
5861
comment "SPI Master Controller Drivers"
5962

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

1324+
if SPI_OFFLOAD
1325+
1326+
comment "SPI Offload triggers"
1327+
1328+
config SPI_OFFLOAD_TRIGGER_PWM
1329+
tristate "SPI offload trigger using PWM"
1330+
depends on PWM
1331+
help
1332+
Generic SPI offload trigger implemented using PWM output.
1333+
1334+
endif # SPI_OFFLOAD
1335+
13201336
endif # SPI

drivers/spi/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ ccflags-$(CONFIG_SPI_DEBUG) := -DDEBUG
1010
obj-$(CONFIG_SPI_MASTER) += spi.o
1111
obj-$(CONFIG_SPI_MEM) += spi-mem.o
1212
obj-$(CONFIG_SPI_MUX) += spi-mux.o
13+
obj-$(CONFIG_SPI_OFFLOAD) += spi-offload.o
1314
obj-$(CONFIG_SPI_SPIDEV) += spidev.o
1415
obj-$(CONFIG_SPI_LOOPBACK_TEST) += spi-loopback-test.o
1516

@@ -163,3 +164,6 @@ obj-$(CONFIG_SPI_AMD) += spi-amd.o
163164
# SPI slave protocol handlers
164165
obj-$(CONFIG_SPI_SLAVE_TIME) += spi-slave-time.o
165166
obj-$(CONFIG_SPI_SLAVE_SYSTEM_CONTROL) += spi-slave-system-control.o
167+
168+
# SPI offload triggers
169+
obj-$(CONFIG_SPI_OFFLOAD_TRIGGER_PWM) += spi-offload-trigger-pwm.o

0 commit comments

Comments
 (0)