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: ad7124: add debugfs to disable single cycle mode

Add a boolean debugfs attribute to allow disabling the SINGLE_CYCLE
bit in the FILTER registers.

This causes data to be read on every conversion instead of doing the
usual 3 or 4 conversions per sample (depending on the filter). This is
only needed for very specific use cases, such as validating the
performance of the ADC. So we just expose this feature through debugfs
for the rare cases where it is needed by people who really know what
they are doing.

Signed-off-by: David Lechner <dlechner@baylibre.com>
Reviewed-by: Nuno Sá <nuno.sa@analog.com>
Signed-off-by: Jonathan Cameron <Jonathan.Cameron@huawei.com>

authored by

David Lechner and committed by
Jonathan Cameron
5f31df50 3a866087

+23 -2
+23 -2
drivers/iio/adc/ad7124.c
··· 10 10 #include <linux/cleanup.h> 11 11 #include <linux/clk.h> 12 12 #include <linux/clk-provider.h> 13 + #include <linux/debugfs.h> 13 14 #include <linux/delay.h> 14 15 #include <linux/device.h> 15 16 #include <linux/err.h> ··· 224 223 */ 225 224 unsigned int gain_default; 226 225 DECLARE_KFIFO(live_cfgs_fifo, struct ad7124_channel_config *, AD7124_MAX_CONFIGS); 226 + bool enable_single_cycle; 227 227 }; 228 228 229 229 static const struct ad7124_chip_info ad7124_4_chip_info = { ··· 562 560 * sampling frequency even when only one channel is enabled in a 563 561 * buffered read. If it was not set, the N in ad7124_set_channel_odr() 564 562 * would be 1 and we would get a faster sampling frequency than what 565 - * was requested. 563 + * was requested. It may only be disabled through debugfs for testing 564 + * purposes. 566 565 */ 567 566 return ad_sd_write_reg(&st->sd, AD7124_FILTER(cfg->cfg_slot), 3, 568 567 FIELD_PREP(AD7124_FILTER_FILTER, filter) | 569 568 FIELD_PREP(AD7124_FILTER_REJ60, rej60) | 570 569 FIELD_PREP(AD7124_FILTER_POST_FILTER, post) | 571 - AD7124_FILTER_SINGLE_CYCLE | 570 + FIELD_PREP(AD7124_FILTER_SINGLE_CYCLE, 571 + st->enable_single_cycle) | 572 572 FIELD_PREP(AD7124_FILTER_FS, cfg->odr_sel_bits)); 573 573 } 574 574 ··· 1613 1609 regulator_disable(r); 1614 1610 } 1615 1611 1612 + static void ad7124_debugfs_init(struct iio_dev *indio_dev) 1613 + { 1614 + struct dentry *dentry = iio_get_debugfs_dentry(indio_dev); 1615 + struct ad7124_state *st = iio_priv(indio_dev); 1616 + 1617 + if (!IS_ENABLED(CONFIG_DEBUG_FS)) 1618 + return; 1619 + 1620 + debugfs_create_bool("enable_single_cycle", 0644, dentry, 1621 + &st->enable_single_cycle); 1622 + } 1623 + 1616 1624 static int ad7124_probe(struct spi_device *spi) 1617 1625 { 1618 1626 const struct ad7124_chip_info *info; ··· 1644 1628 st = iio_priv(indio_dev); 1645 1629 1646 1630 st->chip_info = info; 1631 + 1632 + /* Only disabled for debug/testing purposes. */ 1633 + st->enable_single_cycle = true; 1647 1634 1648 1635 indio_dev->name = st->chip_info->name; 1649 1636 indio_dev->modes = INDIO_DIRECT_MODE; ··· 1704 1685 ret = devm_iio_device_register(&spi->dev, indio_dev); 1705 1686 if (ret < 0) 1706 1687 return dev_err_probe(dev, ret, "Failed to register iio device\n"); 1688 + 1689 + ad7124_debugfs_init(indio_dev); 1707 1690 1708 1691 return 0; 1709 1692 }