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