iio: addac: ad74413r: fix Current Input, Loop Powered Mode
authorRasmus Villemoes <linux@rasmusvillemoes.dk>
Wed, 1 Mar 2023 11:55:11 +0000 (12:55 +0100)
committerJonathan Cameron <Jonathan.Cameron@huawei.com>
Sun, 12 Mar 2023 15:50:15 +0000 (15:50 +0000)
commit0088dd6869579f7022b226d1266e6dc23789ed41
treeb0da137759dcd61ea5b32662a45bb4efda2049c8
parent504eb485589d146e99a53cd982b52fe1728fc19e
iio: addac: ad74413r: fix Current Input, Loop Powered Mode

Currently, the driver handles CH_FUNC_CURRENT_INPUT_LOOP_POWER and
CH_FUNC_CURRENT_INPUT_EXT_POWER completely identically. But that's not
correct. In order for CH_FUNC_CURRENT_INPUT_LOOP_POWER to work, two
changes must be made:

(1) expose access to the DAC_CODE_x register so that the intended
output current can be set, i.e. expose the channel as both current
output and current input, and

(2) per the data sheet

  When selecting the current input loop powered function, tie the
  VIOUTN_x pin to ground via the on-chip 200 kΩ resistor by enabling
  the CH_200K_TO_GND bit in the ADC_CONFIGx registers.

Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Link: https://lore.kernel.org/r/20230301115511.849418-1-linux@rasmusvillemoes.dk
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>
drivers/iio/addac/ad74413r.c