Skip to content

Commit b982267

Browse files
spectrum70nunojsa
authored andcommitted
iio: dac: adi-axi-dac: add data source get
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>
1 parent 67f0412 commit b982267

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/iio/dac/adi-axi-dac.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -536,6 +536,35 @@ static int axi_dac_data_source_set(struct iio_backend *back, unsigned int chan,
536536
}
537537
}
538538

539+
static int axi_dac_data_source_get(struct iio_backend *back, unsigned int chan,
540+
enum iio_backend_data_source *data)
541+
{
542+
struct axi_dac_state *st = iio_backend_get_priv(back);
543+
int ret;
544+
u32 val;
545+
546+
if (chan > AXI_DAC_CHAN_CNTRL_MAX)
547+
return -EINVAL;
548+
549+
ret = regmap_read(st->regmap, AXI_DAC_CHAN_CNTRL_7_REG(chan), &val);
550+
if (ret)
551+
return ret;
552+
553+
switch (val) {
554+
case AXI_DAC_DATA_INTERNAL_TONE:
555+
*data = IIO_BACKEND_INTERNAL_CONTINUOUS_WAVE;
556+
return 0;
557+
case AXI_DAC_DATA_DMA:
558+
*data = IIO_BACKEND_EXTERNAL;
559+
return 0;
560+
case AXI_DAC_DATA_INTERNAL_RAMP_16BIT:
561+
*data = IIO_BACKEND_INTERNAL_RAMP_16BIT;
562+
return 0;
563+
default:
564+
return -EIO;
565+
}
566+
}
567+
539568
static int axi_dac_set_sample_rate(struct iio_backend *back, unsigned int chan,
540569
u64 sample_rate)
541570
{
@@ -815,6 +844,7 @@ static const struct iio_backend_ops axi_ad3552r_ops = {
815844
.request_buffer = axi_dac_request_buffer,
816845
.free_buffer = axi_dac_free_buffer,
817846
.data_source_set = axi_dac_data_source_set,
847+
.data_source_get = axi_dac_data_source_get,
818848
.ddr_enable = axi_dac_ddr_enable,
819849
.ddr_disable = axi_dac_ddr_disable,
820850
.data_stream_enable = axi_dac_data_stream_enable,

0 commit comments

Comments
 (0)