Skip to content

Commit 3fcd3d2

Browse files
dlechbroonie
authored andcommitted
spi: offload trigger: add ADI Util Sigma-Delta SPI driver
Add a new driver for the ADI Util Sigma-Delta SPI FPGA IP core. This is used to trigger a SPI offload based on a RDY signal from an ADC while masking out other signals on the same line. Signed-off-by: David Lechner <[email protected]> Link: https://patch.msgid.link/20250627-iio-adc-ad7173-add-spi-offload-support-v2-9-f49c55599113@baylibre.com Signed-off-by: Mark Brown <[email protected]>
1 parent e47a324 commit 3fcd3d2

File tree

4 files changed

+66
-1
lines changed

4 files changed

+66
-1
lines changed

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23413,7 +23413,7 @@ F: include/linux/mtd/spi-nor.h
2341323413

2341423414
SPI OFFLOAD
2341523415
R: David Lechner <[email protected]>
23416-
F: drivers/spi/spi-offload-trigger-pwm.c
23416+
F: drivers/spi/spi-offload-trigger-*.c
2341723417
F: drivers/spi/spi-offload.c
2341823418
F: include/linux/spi/offload/
2341923419
K: spi_offload

drivers/spi/Kconfig

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1355,6 +1355,11 @@ if SPI_OFFLOAD
13551355

13561356
comment "SPI Offload triggers"
13571357

1358+
config SPI_OFFLOAD_TRIGGER_ADI_UTIL_SD
1359+
tristate "SPI offload trigger using ADI sigma-delta utility"
1360+
help
1361+
SPI offload trigger from ADI sigma-delta utility FPGA IP block.
1362+
13581363
config SPI_OFFLOAD_TRIGGER_PWM
13591364
tristate "SPI offload trigger using PWM"
13601365
depends on PWM

drivers/spi/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,4 @@ obj-$(CONFIG_SPI_SLAVE_SYSTEM_CONTROL) += spi-slave-system-control.o
170170

171171
# SPI offload triggers
172172
obj-$(CONFIG_SPI_OFFLOAD_TRIGGER_PWM) += spi-offload-trigger-pwm.o
173+
obj-$(CONFIG_SPI_OFFLOAD_TRIGGER_ADI_UTIL_SD) += spi-offload-trigger-adi-util-sigma-delta.o
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// SPDX-License-Identifier: GPL-2.0-only
2+
/*
3+
* Copyright (C) 2025 Analog Devices Inc.
4+
* Copyright (C) 2025 BayLibre, SAS
5+
*/
6+
7+
#include <linux/clk.h>
8+
#include <linux/device.h>
9+
#include <linux/mod_devicetable.h>
10+
#include <linux/module.h>
11+
#include <linux/platform_device.h>
12+
#include <linux/property.h>
13+
#include <linux/spi/offload/provider.h>
14+
15+
static bool adi_util_sigma_delta_match(struct spi_offload_trigger *trigger,
16+
enum spi_offload_trigger_type type,
17+
u64 *args, u32 nargs)
18+
{
19+
return type == SPI_OFFLOAD_TRIGGER_DATA_READY && nargs == 0;
20+
}
21+
22+
static const struct spi_offload_trigger_ops adi_util_sigma_delta_ops = {
23+
.match = adi_util_sigma_delta_match,
24+
};
25+
26+
static int adi_util_sigma_delta_probe(struct platform_device *pdev)
27+
{
28+
struct device *dev = &pdev->dev;
29+
struct spi_offload_trigger_info info = {
30+
.fwnode = dev_fwnode(dev),
31+
.ops = &adi_util_sigma_delta_ops,
32+
};
33+
struct clk *clk;
34+
35+
clk = devm_clk_get_enabled(dev, NULL);
36+
if (IS_ERR(clk))
37+
return dev_err_probe(dev, PTR_ERR(clk), "Failed to get clock\n");
38+
39+
return devm_spi_offload_trigger_register(dev, &info);
40+
}
41+
42+
static const struct of_device_id adi_util_sigma_delta_of_match_table[] = {
43+
{ .compatible = "adi,util-sigma-delta-spi", },
44+
{ }
45+
};
46+
MODULE_DEVICE_TABLE(of, adi_util_sigma_delta_of_match_table);
47+
48+
static struct platform_driver adi_util_sigma_delta_driver = {
49+
.probe = adi_util_sigma_delta_probe,
50+
.driver = {
51+
.name = "adi-util-sigma-delta-spi",
52+
.of_match_table = adi_util_sigma_delta_of_match_table,
53+
},
54+
};
55+
module_platform_driver(adi_util_sigma_delta_driver);
56+
57+
MODULE_AUTHOR("David Lechner <[email protected]>");
58+
MODULE_DESCRIPTION("ADI Sigma-Delta SPI offload trigger utility driver");
59+
MODULE_LICENSE("GPL");

0 commit comments

Comments
 (0)