patch "iio: adc: ad7606: remove frstdata check for serial mode" added to char-misc-linus
Subsystems (3)
This is a note to let you know that I've just added the patch titled
iio: adc: ad7606: remove frstdata check for serial mode
to my char-misc git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/char-misc.git
in the char-misc-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 90826e08468ba7fb35d8b39645b22d9e80004afe Mon Sep 17 00:00:00 2001
From: Guillaume Stols <[email protected]>
Date: Tue, 2 Jul 2024 12:52:51 +0000
Subject: iio: adc: ad7606: remove frstdata check for serial mode
The current implementation attempts to recover from an eventual glitch in the clock by checking frstdata state after reading the first channel's sample: If frstdata is low, it will reset the chip and return -EIO.
This will only work in parallel mode, where frstdata pin is set low after the 2nd sample read starts.
For the serial mode, according to the datasheet, "The FRSTDATA output returns to a logic low following the 16th SCLK falling edge.", thus after the Xth pulse, X being the number of bits in a sample, the check will always be true, and the driver will not work at all in serial mode if frstdata(optional) is defined in the devicetree as it will reset the chip, and return -EIO every time read_sample is called.
Hence, this check must be removed for serial mode.
--- drivers/iio/adc/ad7606.c | 28 ++-------------------- drivers/iio/adc/ad7606.h | 2 ++ drivers/iio/adc/ad7606_par.c | 46 ++++++++++++++++++++++++++++++++++-- 3 files changed, 48 insertions(+), 28 deletions(-)
drivers/iio/adc/ad7606.c +2 -26
@@ -49,7 +49,7 @@ static const unsigned int ad7616_oversampling_avail[8] = { 1, 2, 4, 8, 16, 32, 64, 128, }; -static int ad7606_reset (struct ad7606_state *st) +int ad7606_reset (struct ad7606_state *st) {if (st->gpio_reset) {gpiod_set_value (st->gpio_reset,1 );
@@ -60,6 +60,7 @@ static int ad7606_reset(struct ad7606_state *st)return -ENODEV ; } +EXPORT_SYMBOL_NS_GPL (ad7606_reset,IIO_AD7606 ); static int ad7606_reg_access(struct iio_dev *indio_dev, unsigned int reg,
@@ -88,31 +89,6 @@ static int ad7606_read_samples(struct ad7606_state *st) {unsigned int num = st->chip_info->num_channels -1 ;u16 *data = st->data; -int ret; - -/* -* The frstdata signal is set to high while and after reading the sample -* of the first channel and low for all other channels. This can be used -* to check that the incoming data is correctly aligned. During normal -* operation the data should never become unaligned, but some glitch or -* electrostatic discharge might cause an extra read or clock cycle. -* Monitoring the frstdata signal allows to recover from such failure -* situations. -*/ - -if (st->gpio_frstdata) { - ret = st->bops->read_block (st->dev,1 , data); -if (ret) -return ret; - -if (!gpiod_get_value (st->gpio_frstdata)) { -ad7606_reset (st); -return -EIO ; - } - - data++; - num--; - }return st->bops->read_block (st->dev, num, data); }
drivers/iio/adc/ad7606.h +2 -0
@@ -151,6 +151,8 @@ int ad7606_probe(struct device *dev, int irq, void __iomem *base_address, const char *name, unsigned int id, const struct ad7606_bus_ops *bops); +int ad7606_reset (struct ad7606_state *st); +enum ad7606_supported_device_ids {ID_AD7605_4 ,ID_AD7606_8 ,
drivers/iio/adc/ad7606_par.c +44 -2
66 lines not on this page · raw message
Signature · 1 line
2.46.0