]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
iio: adc: ad7173: add SPI offload support
authorDavid Lechner <dlechner@baylibre.com>
Thu, 10 Jul 2025 22:22:00 +0000 (17:22 -0500)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sat, 16 Aug 2025 10:57:06 +0000 (11:57 +0100)
Enable SPI offload support for the AD7173 ADC driver.

The scan_type used for SPI offload is assuming that we are using the
ad411x_ad717x HDL project [1] which always stores data words in 32-bits.

Link: https://analogdevicesinc.github.io/hdl/projects/ad411x_ad717x/index.html
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: David Lechner <dlechner@baylibre.com>
Link: https://patch.msgid.link/20250710-iio-adc-ad7173-add-spi-offload-support-v4-1-536857c4e043@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7173.c

index 4413207be28f60a4d9529e3522f5d2fd6276bcc2..9a32a18cc8040830ea2de5616162b8bcee3c0739 100644 (file)
@@ -746,6 +746,7 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info_4_slots = {
        .set_mode = ad7173_set_mode,
        .has_registers = true,
        .has_named_irqs = true,
+       .supports_spi_offload = true,
        .addr_shift = 0,
        .read_mask = BIT(6),
        .status_ch_mask = GENMASK(3, 0),
@@ -762,6 +763,7 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info_8_slots = {
        .set_mode = ad7173_set_mode,
        .has_registers = true,
        .has_named_irqs = true,
+       .supports_spi_offload = true,
        .addr_shift = 0,
        .read_mask = BIT(6),
        .status_ch_mask = GENMASK(3, 0),
@@ -778,6 +780,7 @@ static const struct ad_sigma_delta_info ad7173_sigma_delta_info_16_slots = {
        .set_mode = ad7173_set_mode,
        .has_registers = true,
        .has_named_irqs = true,
+       .supports_spi_offload = true,
        .addr_shift = 0,
        .read_mask = BIT(6),
        .status_ch_mask = GENMASK(3, 0),
@@ -1595,6 +1598,11 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
                if (st->info->data_reg_only_16bit)
                        chan_arr[chan_index].scan_type = ad4113_scan_type;
 
+               if (ad_sigma_delta_has_spi_offload(&st->sd)) {
+                       chan_arr[chan_index].scan_type.storagebits = 32;
+                       chan_arr[chan_index].scan_type.endianness = IIO_CPU;
+               }
+
                chan_index++;
        }
 
@@ -1685,6 +1693,12 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
                if (st->info->data_reg_only_16bit)
                        chan_arr[chan_index].scan_type = ad4113_scan_type;
 
+               /* Assuming SPI offload is ad411x_ad717x HDL project. */
+               if (ad_sigma_delta_has_spi_offload(&st->sd)) {
+                       chan_arr[chan_index].scan_type.storagebits = 32;
+                       chan_arr[chan_index].scan_type.endianness = IIO_CPU;
+               }
+
                chan_index++;
        }
        return 0;