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: adc: ad7606: add support for writing registers when using backend

Add the logic for effectively enabling the software mode for the
iio-backend, i.e. enabling the software mode channel configuration and
implementing the register writing functions.

Signed-off-by: Guillaume Stols <gstols@baylibre.com>
Co-developed-by: Angelo Dureghello <adureghello@baylibre.com>
Signed-off-by: Angelo Dureghello <adureghello@baylibre.com>
Link: https://patch.msgid.link/20250210-wip-bl-ad7606_add_backend_sw_mode-v4-9-160df18b1da7@baylibre.com
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

Guillaume Stols and committed by
Jonathan Cameron
ac856912 5efb0a3c

+63 -4
+15
drivers/iio/adc/ad7606.h
··· 96 96 BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ 97 97 0, 0, 16) 98 98 99 + #define AD7606_BI_SW_CHANNEL(num) \ 100 + AD760X_CHANNEL(num, \ 101 + /* mask separate */ \ 102 + BIT(IIO_CHAN_INFO_SCALE), \ 103 + /* mask type */ \ 104 + 0, \ 105 + /* mask all */ \ 106 + BIT(IIO_CHAN_INFO_SAMP_FREQ) | \ 107 + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ 108 + /* mask separate available */ \ 109 + BIT(IIO_CHAN_INFO_SCALE), \ 110 + /* mask all available */ \ 111 + BIT(IIO_CHAN_INFO_OVERSAMPLING_RATIO), \ 112 + 16) 113 + 99 114 struct ad7606_state; 100 115 101 116 typedef int (*ad7606_scale_setup_cb_t)(struct iio_dev *indio_dev,
+48 -4
drivers/iio/adc/ad7606_par.c
··· 19 19 #include <linux/iio/iio.h> 20 20 21 21 #include "ad7606.h" 22 + #include "ad7606_bus_iface.h" 22 23 23 24 static const struct iio_chan_spec ad7606b_bi_channels[] = { 24 25 AD7606_BI_CHANNEL(0), ··· 32 31 AD7606_BI_CHANNEL(7), 33 32 }; 34 33 35 - static int ad7606_bi_update_scan_mode(struct iio_dev *indio_dev, const unsigned long *scan_mask) 34 + static const struct iio_chan_spec ad7606b_bi_sw_channels[] = { 35 + AD7606_BI_SW_CHANNEL(0), 36 + AD7606_BI_SW_CHANNEL(1), 37 + AD7606_BI_SW_CHANNEL(2), 38 + AD7606_BI_SW_CHANNEL(3), 39 + AD7606_BI_SW_CHANNEL(4), 40 + AD7606_BI_SW_CHANNEL(5), 41 + AD7606_BI_SW_CHANNEL(6), 42 + AD7606_BI_SW_CHANNEL(7), 43 + }; 44 + 45 + static int ad7606_par_bus_update_scan_mode(struct iio_dev *indio_dev, 46 + const unsigned long *scan_mask) 36 47 { 37 48 struct ad7606_state *st = iio_priv(indio_dev); 38 49 unsigned int c, ret; ··· 61 48 return 0; 62 49 } 63 50 64 - static int ad7606_bi_setup_iio_backend(struct device *dev, struct iio_dev *indio_dev) 51 + static int ad7606_par_bus_setup_iio_backend(struct device *dev, 52 + struct iio_dev *indio_dev) 65 53 { 66 54 struct ad7606_state *st = iio_priv(indio_dev); 67 55 unsigned int ret, c; ··· 100 86 return 0; 101 87 } 102 88 89 + static int ad7606_par_bus_reg_read(struct ad7606_state *st, unsigned int addr) 90 + { 91 + struct ad7606_platform_data *pdata = st->dev->platform_data; 92 + int val, ret; 93 + 94 + ret = pdata->bus_reg_read(st->back, addr, &val); 95 + if (ret) 96 + return ret; 97 + 98 + return val; 99 + } 100 + 101 + static int ad7606_par_bus_reg_write(struct ad7606_state *st, unsigned int addr, 102 + unsigned int val) 103 + { 104 + struct ad7606_platform_data *pdata = st->dev->platform_data; 105 + 106 + return pdata->bus_reg_write(st->back, addr, val); 107 + } 108 + 109 + static int ad7606_par_bus_sw_mode_config(struct iio_dev *indio_dev) 110 + { 111 + indio_dev->channels = ad7606b_bi_sw_channels; 112 + 113 + return 0; 114 + } 115 + 103 116 static const struct ad7606_bus_ops ad7606_bi_bops = { 104 - .iio_backend_config = ad7606_bi_setup_iio_backend, 105 - .update_scan_mode = ad7606_bi_update_scan_mode, 117 + .iio_backend_config = ad7606_par_bus_setup_iio_backend, 118 + .update_scan_mode = ad7606_par_bus_update_scan_mode, 119 + .reg_read = ad7606_par_bus_reg_read, 120 + .reg_write = ad7606_par_bus_reg_write, 121 + .sw_mode_config = ad7606_par_bus_sw_mode_config, 106 122 }; 107 123 108 124 static int ad7606_par16_read_block(struct device *dev,