]> www.infradead.org Git - linux.git/commitdiff
iio: adc: ad7173: fix buffers enablement for ad7176-2
authorDumitru Ceclan <dumitru.ceclan@analog.com>
Tue, 21 May 2024 08:45:39 +0000 (11:45 +0300)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Mon, 27 May 2024 08:49:20 +0000 (09:49 +0100)
AD7176-2 does not feature input buffers and marks corespondent register
bits as read only. Enable buffers only on supported models.

Fixes: 76a1e6a42802 ("iio: adc: ad7173: add AD7173 driver")
Reviewed-by: David Lechner <dlechner@baylibre.com>
Signed-off-by: Dumitru Ceclan <dumitru.ceclan@analog.com>
Link: https://lore.kernel.org/r/20240521-ad7173-fixes-v1-1-8161cc7f3ad1@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/adc/ad7173.c

index a7826bba0852afc2fa560fa7029922259f1bf8a3..91acedaddb576f6e50ef245cb86eac7bbd560f6e 100644 (file)
@@ -145,6 +145,7 @@ struct ad7173_device_info {
        unsigned int id;
        char *name;
        bool has_temp;
+       bool has_input_buf;
        bool has_int_ref;
        bool has_ref2;
        u8 num_gpios;
@@ -212,6 +213,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
                .num_configs = 4,
                .num_gpios = 2,
                .has_temp = true,
+               .has_input_buf = true,
                .has_int_ref = true,
                .clock = 2 * HZ_PER_MHZ,
                .sinc5_data_rates = ad7173_sinc5_data_rates,
@@ -224,6 +226,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
                .num_configs = 8,
                .num_gpios = 4,
                .has_temp = false,
+               .has_input_buf = true,
                .has_ref2 = true,
                .clock = 2 * HZ_PER_MHZ,
                .sinc5_data_rates = ad7173_sinc5_data_rates,
@@ -237,6 +240,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
                .num_configs = 8,
                .num_gpios = 4,
                .has_temp = true,
+               .has_input_buf = true,
                .has_int_ref = true,
                .has_ref2 = true,
                .clock = 2 * HZ_PER_MHZ,
@@ -251,6 +255,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
                .num_configs = 4,
                .num_gpios = 2,
                .has_temp = true,
+               .has_input_buf = true,
                .has_int_ref = true,
                .clock = 16 * HZ_PER_MHZ,
                .sinc5_data_rates = ad7175_sinc5_data_rates,
@@ -263,6 +268,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
                .num_configs = 8,
                .num_gpios = 4,
                .has_temp = true,
+               .has_input_buf = true,
                .has_int_ref = true,
                .has_ref2 = true,
                .clock = 16 * HZ_PER_MHZ,
@@ -277,6 +283,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
                .num_configs = 4,
                .num_gpios = 2,
                .has_temp = false,
+               .has_input_buf = false,
                .has_int_ref = true,
                .clock = 16 * HZ_PER_MHZ,
                .sinc5_data_rates = ad7175_sinc5_data_rates,
@@ -289,6 +296,7 @@ static const struct ad7173_device_info ad7173_device_info[] = {
                .num_configs = 4,
                .num_gpios = 2,
                .has_temp = true,
+               .has_input_buf = true,
                .has_int_ref = true,
                .clock = 16 * HZ_PER_MHZ,
                .odr_start_value = AD7177_ODR_START_VALUE,
@@ -932,7 +940,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
                        AD7173_CH_ADDRESS(chan_arr[chan_index].channel,
                                          chan_arr[chan_index].channel2);
                chan_st_priv->cfg.bipolar = false;
-               chan_st_priv->cfg.input_buf = true;
+               chan_st_priv->cfg.input_buf = st->info->has_input_buf;
                chan_st_priv->cfg.ref_sel = AD7173_SETUP_REF_SEL_INT_REF;
                st->adc_mode |= AD7173_ADC_MODE_REF_EN;
 
@@ -989,7 +997,7 @@ static int ad7173_fw_parse_channel_config(struct iio_dev *indio_dev)
 
                chan_st_priv->ain = AD7173_CH_ADDRESS(ain[0], ain[1]);
                chan_st_priv->chan_reg = chan_index;
-               chan_st_priv->cfg.input_buf = true;
+               chan_st_priv->cfg.input_buf = st->info->has_input_buf;
                chan_st_priv->cfg.odr = 0;
 
                chan_st_priv->cfg.bipolar = fwnode_property_read_bool(child, "bipolar");