]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: dac: adi-axi-dac: add data source get
authorAngelo Dureghello <adureghello@baylibre.com>
Wed, 9 Apr 2025 18:36:31 +0000 (20:36 +0200)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Tue, 22 Apr 2025 18:10:03 +0000 (19:10 +0100)
Add data source getter.

Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250409-wip-bl-ad3552r-fixes-v5-4-fb429c3a6515@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/dac/adi-axi-dac.c

index f86acb98b0cffb09bf4d4626f932bf1edc911e2b..8ed5ad1fa24cef649056bc5f4ca80abbf28b9323 100644 (file)
@@ -536,6 +536,35 @@ static int axi_dac_data_source_set(struct iio_backend *back, unsigned int chan,
        }
 }
 
+static int axi_dac_data_source_get(struct iio_backend *back, unsigned int chan,
+                                  enum iio_backend_data_source *data)
+{
+       struct axi_dac_state *st = iio_backend_get_priv(back);
+       int ret;
+       u32 val;
+
+       if (chan > AXI_DAC_CHAN_CNTRL_MAX)
+               return -EINVAL;
+
+       ret = regmap_read(st->regmap, AXI_DAC_CHAN_CNTRL_7_REG(chan), &val);
+       if (ret)
+               return ret;
+
+       switch (val) {
+       case AXI_DAC_DATA_INTERNAL_TONE:
+               *data = IIO_BACKEND_INTERNAL_CONTINUOUS_WAVE;
+               return 0;
+       case AXI_DAC_DATA_DMA:
+               *data = IIO_BACKEND_EXTERNAL;
+               return 0;
+       case AXI_DAC_DATA_INTERNAL_RAMP_16BIT:
+               *data = IIO_BACKEND_INTERNAL_RAMP_16BIT;
+               return 0;
+       default:
+               return -EIO;
+       }
+}
+
 static int axi_dac_set_sample_rate(struct iio_backend *back, unsigned int chan,
                                   u64 sample_rate)
 {
@@ -818,6 +847,7 @@ static const struct iio_backend_ops axi_ad3552r_ops = {
        .request_buffer = axi_dac_request_buffer,
        .free_buffer = axi_dac_free_buffer,
        .data_source_set = axi_dac_data_source_set,
+       .data_source_get = axi_dac_data_source_get,
        .ddr_enable = axi_dac_ddr_enable,
        .ddr_disable = axi_dac_ddr_disable,
        .data_stream_enable = axi_dac_data_stream_enable,