Skip to content

Commit 8488574

Browse files
amiclausgregkh
authored andcommitted
iio: adc: ad4080: fix chip identification
commit b66cddc upstream. Fix AD4080 chip identification by using the correct 16-bit product ID (0x0050) instead of GENMASK(2, 0). Update the chip reading logic to use regmap_bulk_read to read both PRODUCT_ID_L and PRODUCT_ID_H registers and combine them into a 16-bit value. The original implementation was incorrectly reading only 3 bits, which would not correctly identify the AD4080 chip. Fixes: 6b31ba1 ("iio: adc: ad4080: add driver support") Signed-off-by: Antoniu Miclaus <antoniu.miclaus@analog.com> Reviewed-by: Nuno Sá <nuno.sa@analog.com> Cc: <Stable@vger.kernel.org> Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 4f5d9ea commit 8488574

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

drivers/iio/adc/ad4080.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@
125125

126126
/* Miscellaneous Definitions */
127127
#define AD4080_SPI_READ BIT(7)
128-
#define AD4080_CHIP_ID GENMASK(2, 0)
128+
#define AD4080_CHIP_ID 0x0050
129129

130130
#define AD4080_LVDS_CNV_CLK_CNT_MAX 7
131131

@@ -445,7 +445,8 @@ static int ad4080_setup(struct iio_dev *indio_dev)
445445
{
446446
struct ad4080_state *st = iio_priv(indio_dev);
447447
struct device *dev = regmap_get_device(st->regmap);
448-
unsigned int id;
448+
__le16 id_le;
449+
u16 id;
449450
int ret;
450451

451452
ret = regmap_write(st->regmap, AD4080_REG_INTERFACE_CONFIG_A,
@@ -458,10 +459,12 @@ static int ad4080_setup(struct iio_dev *indio_dev)
458459
if (ret)
459460
return ret;
460461

461-
ret = regmap_read(st->regmap, AD4080_REG_CHIP_TYPE, &id);
462+
ret = regmap_bulk_read(st->regmap, AD4080_REG_PRODUCT_ID_L, &id_le,
463+
sizeof(id_le));
462464
if (ret)
463465
return ret;
464466

467+
id = le16_to_cpu(id_le);
465468
if (id != AD4080_CHIP_ID)
466469
dev_info(dev, "Unrecognized CHIP_ID 0x%X\n", id);
467470

0 commit comments

Comments
 (0)