Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

iio: dac: ad5791: Add support for controlling RBUF via devicetree

This patch adds support for an external amplifier to be connected in a
gain of two configuration.

Signed-off-by: Michael Hennerich <michael.hennerich@analog.com>
Signed-off-by: Nuno Sa <nuno.sa@analog.com>
Link: https://lore.kernel.org/r/20231129-ad5791-michael-stuff-v3-2-48e192b00909@analog.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Michael Hennerich and committed by
Jonathan Cameron
e737d495 d49f6942

+8 -1
+8 -1
drivers/iio/dac/ad5791.c
··· 345 345 struct iio_dev *indio_dev; 346 346 struct ad5791_state *st; 347 347 int ret, pos_voltage_uv = 0, neg_voltage_uv = 0; 348 + bool use_rbuf_gain2; 348 349 349 350 indio_dev = devm_iio_device_alloc(&spi->dev, sizeof(*st)); 350 351 if (!indio_dev) ··· 380 379 st->pwr_down = true; 381 380 st->spi = spi; 382 381 382 + if (pdata) 383 + use_rbuf_gain2 = pdata->use_rbuf_gain2; 384 + else 385 + use_rbuf_gain2 = device_property_read_bool(&spi->dev, 386 + "adi,rbuf-gain2-en"); 387 + 383 388 if (!IS_ERR(st->reg_vss) && !IS_ERR(st->reg_vdd)) { 384 389 st->vref_mv = (pos_voltage_uv + neg_voltage_uv) / 1000; 385 390 st->vref_neg_mv = neg_voltage_uv / 1000; ··· 405 398 406 399 407 400 st->ctrl = AD5761_CTRL_LINCOMP(st->chip_info->get_lin_comp(st->vref_mv)) 408 - | ((pdata && pdata->use_rbuf_gain2) ? 0 : AD5791_CTRL_RBUF) | 401 + | (use_rbuf_gain2 ? 0 : AD5791_CTRL_RBUF) | 409 402 AD5791_CTRL_BIN2SC; 410 403 411 404 ret = ad5791_spi_write(st, AD5791_ADDR_CTRL, st->ctrl |