Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

iio: dac: adi-axi-dac: add bus mode setup

The ad354xr requires DSPI mode (2 data lanes) to work in buffering
mode, so, depending on the DAC type, target TRANSFER_REGISTER
"MULTI_IO_MODE" bitfield can be set between:
SPI (configuration, entire ad35xxr family),
DSPI (ad354xr),
QSPI (ad355xr).
Also bus IO_MODE must be set accordingly.

About removal of AXI_DAC_CUSTOM_CTRL_SYNCED_TRANSFER, according to
the HDL history the flag has never been used. So looks like the driver
was including it by mistake or in anticipation for something that was
never implemented on HDL side.

Current HDL updated documentation confirm it is actually not in use
anymore and replaced by the IO_MODE bits.

Reviewed-by: Nuno Sa <nuno.sa@analog.com>
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250114-wip-bl-ad3552r-axi-v0-iio-testing-carlos-v4-4-979402e33545@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Angelo Dureghello and committed by
Jonathan Cameron
8ab67b37 6cc60bc3

+29 -1
+8
drivers/iio/dac/ad3552r-hs.h
··· 8 8 9 9 struct iio_backend; 10 10 11 + enum ad3552r_io_mode { 12 + AD3552R_IO_MODE_SPI, 13 + AD3552R_IO_MODE_DSPI, 14 + AD3552R_IO_MODE_QSPI, 15 + }; 16 + 11 17 struct ad3552r_hs_platform_data { 12 18 int (*bus_reg_read)(struct iio_backend *back, u32 reg, u32 *val, 13 19 size_t data_size); 14 20 int (*bus_reg_write)(struct iio_backend *back, u32 reg, u32 val, 15 21 size_t data_size); 22 + int (*bus_set_io_mode)(struct iio_backend *back, 23 + enum ad3552r_io_mode mode); 16 24 u32 bus_sample_data_clock_hz; 17 25 }; 18 26
+21 -1
drivers/iio/dac/adi-axi-dac.c
··· 64 64 #define AXI_DAC_UI_STATUS_IF_BUSY BIT(4) 65 65 #define AXI_DAC_CUSTOM_CTRL_REG 0x008C 66 66 #define AXI_DAC_CUSTOM_CTRL_ADDRESS GENMASK(31, 24) 67 - #define AXI_DAC_CUSTOM_CTRL_SYNCED_TRANSFER BIT(2) 67 + #define AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE GENMASK(3, 2) 68 68 #define AXI_DAC_CUSTOM_CTRL_STREAM BIT(1) 69 69 #define AXI_DAC_CUSTOM_CTRL_TRANSFER_DATA BIT(0) 70 70 ··· 722 722 return regmap_read(st->regmap, AXI_DAC_CUSTOM_RD_REG, val); 723 723 } 724 724 725 + static int axi_dac_bus_set_io_mode(struct iio_backend *back, 726 + enum ad3552r_io_mode mode) 727 + { 728 + struct axi_dac_state *st = iio_backend_get_priv(back); 729 + int ival, ret; 730 + 731 + guard(mutex)(&st->lock); 732 + 733 + ret = regmap_update_bits(st->regmap, AXI_DAC_CUSTOM_CTRL_REG, 734 + AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE, 735 + FIELD_PREP(AXI_DAC_CUSTOM_CTRL_MULTI_IO_MODE, mode)); 736 + if (ret) 737 + return ret; 738 + 739 + return regmap_read_poll_timeout(st->regmap, AXI_DAC_UI_STATUS_REG, ival, 740 + FIELD_GET(AXI_DAC_UI_STATUS_IF_BUSY, ival) == 0, 10, 741 + 100 * KILO); 742 + } 743 + 725 744 static void axi_dac_child_remove(void *data) 726 745 { 727 746 platform_device_unregister(data); ··· 752 733 struct ad3552r_hs_platform_data pdata = { 753 734 .bus_reg_read = axi_dac_bus_reg_read, 754 735 .bus_reg_write = axi_dac_bus_reg_write, 736 + .bus_set_io_mode = axi_dac_bus_set_io_mode, 755 737 .bus_sample_data_clock_hz = st->dac_clk_rate, 756 738 }; 757 739 struct platform_device_info pi = {