Skip to content

Commit

Permalink
iio: frequency: ltc6952: keep unused channels disabled
Browse files Browse the repository at this point in the history
 * 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 <[email protected]>
(cherry picked from commit 0ba34a1)
  • Loading branch information
mhennerich authored and SRaus committed Jun 18, 2024
1 parent 20e9045 commit 805c422
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion drivers/iio/frequency/ltc6952.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit 805c422

Please sign in to comment.