From 805c422ae9390dfc99acb1ac1f3204ae81ad2780 Mon Sep 17 00:00:00 2001 From: Michael Hennerich Date: Mon, 17 Jun 2024 14:07:54 +0200 Subject: [PATCH] iio: frequency: ltc6952: keep unused channels disabled * On POR all channels are fully enabled. This patch keeps those disabled which are not represented by a node in the device-tree. * We also clear the POR reset bit, which might not be necessary but looks cleaner. * We also fix LTC6952_PD(x) mask which wasn't doing anything until now. Signed-off-by: Michael Hennerich (cherry picked from commit 0ba34a19b9bb62d05eab146c60e6b01cda7d4b96) --- drivers/iio/frequency/ltc6952.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/drivers/iio/frequency/ltc6952.c b/drivers/iio/frequency/ltc6952.c index 4a7ebe7f4301ae..fa82c280530a1b 100644 --- a/drivers/iio/frequency/ltc6952.c +++ b/drivers/iio/frequency/ltc6952.c @@ -84,7 +84,7 @@ #define LTC6952_PD8(x) FIELD_PREP(LTC6952_PD8_MSK, x) #define LTC6952_PD_MSK(ch) GENMASK(((ch) & 0x03) * 2 + 1, ((ch) & 0x03) * 2) -#define LTC6952_PD(ch, x) ((x) << ((ch) & 0x03)) +#define LTC6952_PD(ch, x) ((x) << ((ch) & 0x03) * 2) /* LTC6952_REG6 */ #define LTC6952_RAO_MSK BIT(7) @@ -618,6 +618,23 @@ static int ltc6952_setup(struct iio_dev *indio_dev) if (ret < 0) goto err_unlock; + ret = ltc6952_write_mask(indio_dev, LTC6952_REG(0x02), + LTC6952_POR_MSK, LTC6952_POR(0)); + if (ret < 0) + goto err_unlock; + + ret = ltc6952_write(indio_dev, LTC6952_REG(0x03), 0xFF); + if (ret < 0) + goto err_unlock; + + ret = ltc6952_write(indio_dev, LTC6952_REG(0x04), 0xFF); + if (ret < 0) + goto err_unlock; + + ret = ltc6952_write(indio_dev, LTC6952_REG(0x05), 0x3F); + if (ret < 0) + goto err_unlock; + ret = ltc6952_write_mask(indio_dev, LTC6952_REG(0x02), LTC6952_FILTV_MSK, LTC6952_FILTV(st->filtv_enable));