All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] iio: adc: ad_sigma_delta: Add sequencer support
@ 2021-11-10 11:17 alexandru.tachici
  2021-11-10 11:17 ` [PATCH 1/5] iio: adc: ad7124: Add update_scan_mode alexandru.tachici
                   ` (4 more replies)
  0 siblings, 5 replies; 12+ messages in thread
From: alexandru.tachici @ 2021-11-10 11:17 UTC (permalink / raw)
  To: linux-iio, linux-kernel; +Cc: jic23, Alexandru Tachici

From: Alexandru Tachici <alexandru.tachici@analog.com>

Some sigma-delta chips support sampling of multiple
channels in continuous mode.

When the operating with more than one channel enabled,
the channel sequencer cycles through the enabled channels
in sequential order, from first channel to the last one.
If a channel is disabled, it is skipped by the sequencer.

If more than one channel is used in continuous mode,
instruct the device to append the status to the SPI transfer
(1 extra byte) every time we receive a sample.
All sigma-delta chips possessing a sampling sequencer have
this ability. Inside the status register there will be
the number of the converted channel. In this way, even
if the CPU won't keep up with the sampling rate, it won't
send to userspace wrong channel samples.

1. Fix bug in AD7124 where channels stayed enabled
even when they are not supposed to, in continuous mode.

2. Fix bug in AD7192 where channels stayed enabled
even when they are not supposed to, in continuous mode.

3. Add sequencer support for sigma_delta library.

4. Add sigma_delta_info values and callbacks for sequencer
support in AD7124.

5. Add sigma_delta_info values and callbacks for sequencer
support in AD7192.

Alexandru Tachici (5):
  iio: adc: ad7124: Add update_scan_mode
  iio: adc: ad7192: Add update_scan_mode
  iio: adc: ad_sigma_delta: Add sequencer support
  iio: adc: ad7124: add sequencer support
  iio: adc: ad7192: add sequencer support

 drivers/iio/adc/ad7124.c               |  38 ++++++++-
 drivers/iio/adc/ad7192.c               |  32 +++++++-
 drivers/iio/adc/ad_sigma_delta.c       | 106 ++++++++++++++++++++-----
 include/linux/iio/adc/ad_sigma_delta.h |  22 +++++
 4 files changed, 178 insertions(+), 20 deletions(-)

--
2.25.1

^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: [PATCH 3/5] iio: adc: ad_sigma_delta: Add sequencer support
@ 2021-11-19  4:59 kernel test robot
  0 siblings, 0 replies; 12+ messages in thread
From: kernel test robot @ 2021-11-19  4:59 UTC (permalink / raw)
  To: kbuild

[-- Attachment #1: Type: text/plain, Size: 8075 bytes --]

CC: kbuild-all(a)lists.01.org
In-Reply-To: <20211110111750.27263-4-alexandru.tachici@analog.com>
References: <20211110111750.27263-4-alexandru.tachici@analog.com>
TO: alexandru.tachici(a)analog.com
TO: linux-iio(a)vger.kernel.org
TO: linux-kernel(a)vger.kernel.org
CC: jic23(a)kernel.org
CC: Alexandru Tachici <alexandru.tachici@analog.com>
CC: "Lars-Peter Clausen" <lars@metafoo.de>

Hi,

I love your patch! Perhaps something to improve:

[auto build test WARNING on jic23-iio/togreg]
[also build test WARNING on linux/master linus/master v5.16-rc1 next-20211118]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/alexandru-tachici-analog-com/iio-adc-ad_sigma_delta-Add-sequencer-support/20211110-190925
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jic23/iio.git togreg
:::::: branch date: 9 days ago
:::::: commit date: 9 days ago
config: i386-randconfig-m021-20211115 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-22) 9.3.0

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>

smatch warnings:
drivers/iio/adc/ad_sigma_delta.c:457 ad_sd_trigger_handler() error: uninitialized symbol 'status_pos'.

vim +/status_pos +457 drivers/iio/adc/ad_sigma_delta.c

af3008485ea037 Lars-Peter Clausen 2012-08-10  410  
af3008485ea037 Lars-Peter Clausen 2012-08-10  411  static irqreturn_t ad_sd_trigger_handler(int irq, void *p)
af3008485ea037 Lars-Peter Clausen 2012-08-10  412  {
af3008485ea037 Lars-Peter Clausen 2012-08-10  413  	struct iio_poll_func *pf = p;
af3008485ea037 Lars-Peter Clausen 2012-08-10  414  	struct iio_dev *indio_dev = pf->indio_dev;
af3008485ea037 Lars-Peter Clausen 2012-08-10  415  	struct ad_sigma_delta *sigma_delta = iio_device_get_drvdata(indio_dev);
0fb6ee8d0b5e90 Lars-Peter Clausen 2020-11-24  416  	uint8_t *data = sigma_delta->rx_buf;
1d2220fad25a99 Alexandru Tachici  2021-11-10  417  	unsigned int transfer_size;
1d2220fad25a99 Alexandru Tachici  2021-11-10  418  	unsigned int sample_size;
1d2220fad25a99 Alexandru Tachici  2021-11-10  419  	unsigned int sample_pos;
1d2220fad25a99 Alexandru Tachici  2021-11-10  420  	unsigned int status_pos;
af3008485ea037 Lars-Peter Clausen 2012-08-10  421  	unsigned int reg_size;
f0aef2d0186431 Lars-Peter Clausen 2018-11-13  422  	unsigned int data_reg;
af3008485ea037 Lars-Peter Clausen 2012-08-10  423  
af3008485ea037 Lars-Peter Clausen 2012-08-10  424  	reg_size = indio_dev->channels[0].scan_type.realbits +
af3008485ea037 Lars-Peter Clausen 2012-08-10  425  			indio_dev->channels[0].scan_type.shift;
af3008485ea037 Lars-Peter Clausen 2012-08-10  426  	reg_size = DIV_ROUND_UP(reg_size, 8);
af3008485ea037 Lars-Peter Clausen 2012-08-10  427  
f0aef2d0186431 Lars-Peter Clausen 2018-11-13  428  	if (sigma_delta->info->data_reg != 0)
f0aef2d0186431 Lars-Peter Clausen 2018-11-13  429  		data_reg = sigma_delta->info->data_reg;
f0aef2d0186431 Lars-Peter Clausen 2018-11-13  430  	else
f0aef2d0186431 Lars-Peter Clausen 2018-11-13  431  		data_reg = AD_SD_REG_DATA;
f0aef2d0186431 Lars-Peter Clausen 2018-11-13  432  
1d2220fad25a99 Alexandru Tachici  2021-11-10  433  	/* Status word will be appended to the sample during transfer */
1d2220fad25a99 Alexandru Tachici  2021-11-10  434  	if (sigma_delta->status_appended)
1d2220fad25a99 Alexandru Tachici  2021-11-10  435  		transfer_size = reg_size + 1;
1d2220fad25a99 Alexandru Tachici  2021-11-10  436  	else
1d2220fad25a99 Alexandru Tachici  2021-11-10  437  		transfer_size = reg_size;
1d2220fad25a99 Alexandru Tachici  2021-11-10  438  
af3008485ea037 Lars-Peter Clausen 2012-08-10  439  	switch (reg_size) {
af3008485ea037 Lars-Peter Clausen 2012-08-10  440  	case 4:
af3008485ea037 Lars-Peter Clausen 2012-08-10  441  	case 2:
af3008485ea037 Lars-Peter Clausen 2012-08-10  442  	case 1:
1d2220fad25a99 Alexandru Tachici  2021-11-10  443  		status_pos = reg_size;
1d2220fad25a99 Alexandru Tachici  2021-11-10  444  		ad_sd_read_reg_raw(sigma_delta, data_reg, transfer_size, &data[0]);
af3008485ea037 Lars-Peter Clausen 2012-08-10  445  		break;
af3008485ea037 Lars-Peter Clausen 2012-08-10  446  	case 3:
1d2220fad25a99 Alexandru Tachici  2021-11-10  447  		status_pos = reg_size + 1;
af3008485ea037 Lars-Peter Clausen 2012-08-10  448  		/* We store 24 bit samples in a 32 bit word. Keep the upper
af3008485ea037 Lars-Peter Clausen 2012-08-10  449  		 * byte set to zero. */
1d2220fad25a99 Alexandru Tachici  2021-11-10  450  		ad_sd_read_reg_raw(sigma_delta, data_reg, transfer_size, &data[1]);
af3008485ea037 Lars-Peter Clausen 2012-08-10  451  		break;
af3008485ea037 Lars-Peter Clausen 2012-08-10  452  	}
af3008485ea037 Lars-Peter Clausen 2012-08-10  453  
1d2220fad25a99 Alexandru Tachici  2021-11-10  454  	if (sigma_delta->status_appended) {
1d2220fad25a99 Alexandru Tachici  2021-11-10  455  		u8 converted_channel;
1d2220fad25a99 Alexandru Tachici  2021-11-10  456  
1d2220fad25a99 Alexandru Tachici  2021-11-10 @457  		converted_channel = data[status_pos] & sigma_delta->info->status_ch_mask;
1d2220fad25a99 Alexandru Tachici  2021-11-10  458  		if (converted_channel != sigma_delta->slots[sigma_delta->current_slot]) {
1d2220fad25a99 Alexandru Tachici  2021-11-10  459  			/* Desynq occurred during continuous sampling of multiple channels.
1d2220fad25a99 Alexandru Tachici  2021-11-10  460  			 * Drop this incomplete sample and start from first channel again.
1d2220fad25a99 Alexandru Tachici  2021-11-10  461  			 */
1d2220fad25a99 Alexandru Tachici  2021-11-10  462  
1d2220fad25a99 Alexandru Tachici  2021-11-10  463  			sigma_delta->current_slot = 0;
1d2220fad25a99 Alexandru Tachici  2021-11-10  464  			iio_trigger_notify_done(indio_dev->trig);
1d2220fad25a99 Alexandru Tachici  2021-11-10  465  			sigma_delta->irq_dis = false;
1d2220fad25a99 Alexandru Tachici  2021-11-10  466  			enable_irq(sigma_delta->spi->irq);
1d2220fad25a99 Alexandru Tachici  2021-11-10  467  
1d2220fad25a99 Alexandru Tachici  2021-11-10  468  			return IRQ_HANDLED;
1d2220fad25a99 Alexandru Tachici  2021-11-10  469  		}
1d2220fad25a99 Alexandru Tachici  2021-11-10  470  	}
1d2220fad25a99 Alexandru Tachici  2021-11-10  471  
1d2220fad25a99 Alexandru Tachici  2021-11-10  472  	sample_size = indio_dev->channels[0].scan_type.storagebits / 8;
1d2220fad25a99 Alexandru Tachici  2021-11-10  473  	sample_pos = sample_size * sigma_delta->current_slot;
1d2220fad25a99 Alexandru Tachici  2021-11-10  474  	memcpy(&sigma_delta->samples_buf[sample_pos], data, sample_size);
1d2220fad25a99 Alexandru Tachici  2021-11-10  475  	sigma_delta->current_slot++;
1d2220fad25a99 Alexandru Tachici  2021-11-10  476  
1d2220fad25a99 Alexandru Tachici  2021-11-10  477  	if (sigma_delta->current_slot == sigma_delta->active_slots) {
1d2220fad25a99 Alexandru Tachici  2021-11-10  478  		sigma_delta->current_slot = 0;
1d2220fad25a99 Alexandru Tachici  2021-11-10  479  		iio_push_to_buffers_with_timestamp(indio_dev, sigma_delta->samples_buf,
1d2220fad25a99 Alexandru Tachici  2021-11-10  480  						   pf->timestamp);
1d2220fad25a99 Alexandru Tachici  2021-11-10  481  	}
af3008485ea037 Lars-Peter Clausen 2012-08-10  482  
af3008485ea037 Lars-Peter Clausen 2012-08-10  483  	iio_trigger_notify_done(indio_dev->trig);
af3008485ea037 Lars-Peter Clausen 2012-08-10  484  	sigma_delta->irq_dis = false;
af3008485ea037 Lars-Peter Clausen 2012-08-10  485  	enable_irq(sigma_delta->spi->irq);
af3008485ea037 Lars-Peter Clausen 2012-08-10  486  
af3008485ea037 Lars-Peter Clausen 2012-08-10  487  	return IRQ_HANDLED;
af3008485ea037 Lars-Peter Clausen 2012-08-10  488  }
af3008485ea037 Lars-Peter Clausen 2012-08-10  489  

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org

[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 38013 bytes --]

^ permalink raw reply	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2021-11-19  4:59 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-11-10 11:17 [PATCH 0/5] iio: adc: ad_sigma_delta: Add sequencer support alexandru.tachici
2021-11-10 11:17 ` [PATCH 1/5] iio: adc: ad7124: Add update_scan_mode alexandru.tachici
2021-11-12 16:54   ` Jonathan Cameron
2021-11-10 11:17 ` [PATCH 2/5] iio: adc: ad7192: " alexandru.tachici
2021-11-12 16:57   ` Jonathan Cameron
2021-11-10 11:17 ` [PATCH 3/5] iio: adc: ad_sigma_delta: Add sequencer support alexandru.tachici
2021-11-12 17:14   ` Jonathan Cameron
2021-11-13 17:00     ` Andy Shevchenko
2021-11-13 18:23       ` Jonathan Cameron
2021-11-10 11:17 ` [PATCH 4/5] iio: adc: ad7124: add " alexandru.tachici
2021-11-10 11:17 ` [PATCH 5/5] iio: adc: ad7192: " alexandru.tachici
  -- strict thread matches above, loose matches on Subject: below --
2021-11-19  4:59 [PATCH 3/5] iio: adc: ad_sigma_delta: Add " kernel test robot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.