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/dev_printk.h> 9 #include <linux/err.h> 10 #include <linux/mod_devicetable.h> 11 #include <linux/module.h> 12 #include <linux/platform_device.h> 13 #include <linux/property.h> 14 #include <linux/spi/offload/provider.h> 15 #include <linux/spi/offload/types.h> 16 #include <linux/types.h> 17 18 static bool adi_util_sigma_delta_match(struct spi_offload_trigger *trigger, 19 enum spi_offload_trigger_type type, 20 u64 *args, u32 nargs) 21 { 22 return type == SPI_OFFLOAD_TRIGGER_DATA_READY && nargs == 0; 23 } 24 25 static const struct spi_offload_trigger_ops adi_util_sigma_delta_ops = { 26 .match = adi_util_sigma_delta_match, 27 }; 28 29 static int adi_util_sigma_delta_probe(struct platform_device *pdev) 30 { 31 struct device *dev = &pdev->dev; 32 struct spi_offload_trigger_info info = { 33 .fwnode = dev_fwnode(dev), 34 .ops = &adi_util_sigma_delta_ops, 35 }; 36 struct clk *clk; 37 38 clk = devm_clk_get_enabled(dev, NULL); 39 if (IS_ERR(clk)) 40 return dev_err_probe(dev, PTR_ERR(clk), "Failed to get clock\n"); 41 42 return devm_spi_offload_trigger_register(dev, &info); 43 } 44 45 static const struct of_device_id adi_util_sigma_delta_of_match_table[] = { 46 { .compatible = "adi,util-sigma-delta-spi", }, 47 { } 48 }; 49 MODULE_DEVICE_TABLE(of, adi_util_sigma_delta_of_match_table); 50 51 static struct platform_driver adi_util_sigma_delta_driver = { 52 .probe = adi_util_sigma_delta_probe, 53 .driver = { 54 .name = "adi-util-sigma-delta-spi", 55 .of_match_table = adi_util_sigma_delta_of_match_table, 56 }, 57 }; 58 module_platform_driver(adi_util_sigma_delta_driver); 59 60 MODULE_AUTHOR("David Lechner <dlechner@baylibre.com>"); 61 MODULE_DESCRIPTION("ADI Sigma-Delta SPI offload trigger utility driver"); 62 MODULE_LICENSE("GPL"); 63