From: Jonathan Cameron <jic23@kernel.org>
To: Marc Titinger <mtitinger@baylibre.com>,
knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
linux@roeck-us.net, jdelvare@suse.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org
Subject: Re: [PATCH v3 2/2] iio: ina2xx: provide a sysfs parameter to allow async readout of the ADCs
Date: Sat, 12 Dec 2015 15:56:11 +0000 [thread overview]
Message-ID: <566C439B.5080406@kernel.org> (raw)
In-Reply-To: <1449479375-4061-3-git-send-email-mtitinger@baylibre.com>
On 07/12/15 09:09, Marc Titinger wrote:
> This can lead to repeated or skipped samples depending on the clock beat
> between the capture thread and the chip sampling clock, but will also spare
> reading/waiting for the Capture Ready Flag and improve the available i2c
> bandwidth for reading measurements.
>
> Output of iio_info:
> ...snip...
> 4 device-specific attributes found:
> attr 0: in_oversampling_ratio value: 4
> attr 1: in_allow_async_readout value: 0
> attr 2: integration_time_available value: 140 204 332 588 1100 2116...
> attr 3: in_sampling_frequency value: 114
>
> Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders
to play with it.
Could you prepare a follow up patch adding abi docs to
Documentation/ABI/testing/sysfs-bus-iio-ina2xx-adc
please.
I didn't want to hold this up by insisting on docs now, but it does need
doing asap.
Jonathan
> ---
> drivers/iio/adc/ina2xx-adc.c | 54 ++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 45 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index 0e7c474..615c203 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -111,6 +111,7 @@ struct ina2xx_chip_info {
> s64 prev_ns; /* track buffer capture time, check for underruns*/
> int int_time_vbus; /* Bus voltage integration time uS */
> int int_time_vshunt; /* Shunt voltage integration time uS */
> + bool allow_async_readout;
> };
>
> static const struct ina2xx_config ina2xx_config[] = {
> @@ -326,6 +327,33 @@ _err:
> }
>
>
> +static ssize_t ina2xx_allow_async_readout_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev));
> +
> + return sprintf(buf, "%d\n", chip->allow_async_readout);
> +}
> +
> +static ssize_t ina2xx_allow_async_readout_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev));
> + bool val;
> + int ret;
> +
> + ret = strtobool((const char *) buf, &val);
> + if (ret)
> + return ret;
> +
> + chip->allow_async_readout = val;
> +
> + return len;
> +}
> +
> +
> #define INA2XX_CHAN(_type, _index, _address) { \
> .type = (_type), \
> .address = (_address), \
> @@ -392,16 +420,17 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
> * GPIO a triggered buffer could be used instead.
> * For now, we pay for that extra read of the ALERT register
> */
> - do {
> - ret = regmap_read(chip->regmap, INA226_ALERT_MASK,
> - &alert);
> - if (ret < 0)
> - return ret;
> + if (!chip->allow_async_readout)
> + do {
> + ret = regmap_read(chip->regmap, INA226_ALERT_MASK,
> + &alert);
> + if (ret < 0)
> + return ret;
>
> - alert &= INA266_CVRF;
> - trace_printk("Conversion ready: %d\n", !!alert);
> + alert &= INA266_CVRF;
> + trace_printk("Conversion ready: %d\n", !!alert);
>
> - } while (!alert);
> + } while (!alert);
>
> /*
> * Single register reads: bulk_read will not work with ina226
> @@ -446,7 +475,8 @@ static int ina2xx_capture_thread(void *data)
> * Poll a bit faster than the chip internal Fs, in case
> * we wish to sync with the conversion ready flag.
> */
> - sampling_us -= 200;
> + if (!chip->allow_async_readout)
> + sampling_us -= 200;
>
> do {
> buffer_us = ina2xx_work_buffer(indio_dev);
> @@ -471,6 +501,7 @@ int ina2xx_buffer_enable(struct iio_dev *indio_dev)
> 1000000/sampling_us, chip->avg);
>
> trace_printk("Expected work period: %u us\n", sampling_us);
> + trace_printk("Async readout mode: %d\n", chip->allow_async_readout);
>
> chip->prev_ns = iio_get_time_ns();
>
> @@ -512,7 +543,12 @@ static int ina2xx_debug_reg(struct iio_dev *indio_dev,
> static IIO_CONST_ATTR_INT_TIME_AVAIL \
> ("0.000140 0.000204 0.000332 0.000588 0.001100 0.002116 0.004156 0.008244");
>
> +static IIO_DEVICE_ATTR(in_allow_async_readout, S_IRUGO | S_IWUSR,
> + ina2xx_allow_async_readout_show,
> + ina2xx_allow_async_readout_store, 0);
> +
> static struct attribute *ina2xx_attributes[] = {
> + &iio_dev_attr_in_allow_async_readout.dev_attr.attr,
> &iio_const_attr_integration_time_available.dev_attr.attr,
> NULL,
> };
>
WARNING: multiple messages have this Message-ID (diff)
From: Jonathan Cameron <jic23@kernel.org>
To: Marc Titinger <mtitinger@baylibre.com>,
knaack.h@gmx.de, lars@metafoo.de, pmeerw@pmeerw.net,
linux@roeck-us.net, jdelvare@suse.com
Cc: linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
lm-sensors@lm-sensors.org
Subject: Re: [lm-sensors] [PATCH v3 2/2] iio: ina2xx: provide a sysfs parameter to allow async readout of the
Date: Sat, 12 Dec 2015 15:56:11 +0000 [thread overview]
Message-ID: <566C439B.5080406@kernel.org> (raw)
In-Reply-To: <1449479375-4061-3-git-send-email-mtitinger@baylibre.com>
On 07/12/15 09:09, Marc Titinger wrote:
> This can lead to repeated or skipped samples depending on the clock beat
> between the capture thread and the chip sampling clock, but will also spare
> reading/waiting for the Capture Ready Flag and improve the available i2c
> bandwidth for reading measurements.
>
> Output of iio_info:
> ...snip...
> 4 device-specific attributes found:
> attr 0: in_oversampling_ratio value: 4
> attr 1: in_allow_async_readout value: 0
> attr 2: integration_time_available value: 140 204 332 588 1100 2116...
> attr 3: in_sampling_frequency value: 114
>
> Signed-off-by: Marc Titinger <mtitinger@baylibre.com>
Applied to the togreg branch of iio.git - initially pushed out as testing for the autobuilders
to play with it.
Could you prepare a follow up patch adding abi docs to
Documentation/ABI/testing/sysfs-bus-iio-ina2xx-adc
please.
I didn't want to hold this up by insisting on docs now, but it does need
doing asap.
Jonathan
> ---
> drivers/iio/adc/ina2xx-adc.c | 54 ++++++++++++++++++++++++++++++++++++--------
> 1 file changed, 45 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/iio/adc/ina2xx-adc.c b/drivers/iio/adc/ina2xx-adc.c
> index 0e7c474..615c203 100644
> --- a/drivers/iio/adc/ina2xx-adc.c
> +++ b/drivers/iio/adc/ina2xx-adc.c
> @@ -111,6 +111,7 @@ struct ina2xx_chip_info {
> s64 prev_ns; /* track buffer capture time, check for underruns*/
> int int_time_vbus; /* Bus voltage integration time uS */
> int int_time_vshunt; /* Shunt voltage integration time uS */
> + bool allow_async_readout;
> };
>
> static const struct ina2xx_config ina2xx_config[] = {
> @@ -326,6 +327,33 @@ _err:
> }
>
>
> +static ssize_t ina2xx_allow_async_readout_show(struct device *dev,
> + struct device_attribute *attr,
> + char *buf)
> +{
> + struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev));
> +
> + return sprintf(buf, "%d\n", chip->allow_async_readout);
> +}
> +
> +static ssize_t ina2xx_allow_async_readout_store(struct device *dev,
> + struct device_attribute *attr,
> + const char *buf, size_t len)
> +{
> + struct ina2xx_chip_info *chip = iio_priv(dev_to_iio_dev(dev));
> + bool val;
> + int ret;
> +
> + ret = strtobool((const char *) buf, &val);
> + if (ret)
> + return ret;
> +
> + chip->allow_async_readout = val;
> +
> + return len;
> +}
> +
> +
> #define INA2XX_CHAN(_type, _index, _address) { \
> .type = (_type), \
> .address = (_address), \
> @@ -392,16 +420,17 @@ static int ina2xx_work_buffer(struct iio_dev *indio_dev)
> * GPIO a triggered buffer could be used instead.
> * For now, we pay for that extra read of the ALERT register
> */
> - do {
> - ret = regmap_read(chip->regmap, INA226_ALERT_MASK,
> - &alert);
> - if (ret < 0)
> - return ret;
> + if (!chip->allow_async_readout)
> + do {
> + ret = regmap_read(chip->regmap, INA226_ALERT_MASK,
> + &alert);
> + if (ret < 0)
> + return ret;
>
> - alert &= INA266_CVRF;
> - trace_printk("Conversion ready: %d\n", !!alert);
> + alert &= INA266_CVRF;
> + trace_printk("Conversion ready: %d\n", !!alert);
>
> - } while (!alert);
> + } while (!alert);
>
> /*
> * Single register reads: bulk_read will not work with ina226
> @@ -446,7 +475,8 @@ static int ina2xx_capture_thread(void *data)
> * Poll a bit faster than the chip internal Fs, in case
> * we wish to sync with the conversion ready flag.
> */
> - sampling_us -= 200;
> + if (!chip->allow_async_readout)
> + sampling_us -= 200;
>
> do {
> buffer_us = ina2xx_work_buffer(indio_dev);
> @@ -471,6 +501,7 @@ int ina2xx_buffer_enable(struct iio_dev *indio_dev)
> 1000000/sampling_us, chip->avg);
>
> trace_printk("Expected work period: %u us\n", sampling_us);
> + trace_printk("Async readout mode: %d\n", chip->allow_async_readout);
>
> chip->prev_ns = iio_get_time_ns();
>
> @@ -512,7 +543,12 @@ static int ina2xx_debug_reg(struct iio_dev *indio_dev,
> static IIO_CONST_ATTR_INT_TIME_AVAIL \
> ("0.000140 0.000204 0.000332 0.000588 0.001100 0.002116 0.004156 0.008244");
>
> +static IIO_DEVICE_ATTR(in_allow_async_readout, S_IRUGO | S_IWUSR,
> + ina2xx_allow_async_readout_show,
> + ina2xx_allow_async_readout_store, 0);
> +
> static struct attribute *ina2xx_attributes[] = {
> + &iio_dev_attr_in_allow_async_readout.dev_attr.attr,
> &iio_const_attr_integration_time_available.dev_attr.attr,
> NULL,
> };
>
_______________________________________________
lm-sensors mailing list
lm-sensors@lm-sensors.org
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
next prev parent reply other threads:[~2015-12-12 15:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 9:09 [PATCH v3 0/2] IIO version of INA2xx Marc Titinger
2015-12-07 9:09 ` [PATCH v3 1/2] iio: ina2xx: add support for TI INA2xx Power Monitors Marc Titinger
2015-12-12 17:14 ` Jonathan Cameron
2015-12-12 17:14 ` [lm-sensors] " Jonathan Cameron
2015-12-15 15:26 ` [PATCH] iio: ina2xx: fix channel order in software buffer Marc Titinger
2015-12-19 15:07 ` Jonathan Cameron
2015-12-16 17:45 ` [PATCH v3 1/2] iio: ina2xx: add support for TI INA2xx Power Monitors Andrew F. Davis
2015-12-16 17:54 ` Marc Titinger
2015-12-16 18:09 ` Andrew F. Davis
2015-12-07 9:09 ` [PATCH v3 2/2] iio: ina2xx: provide a sysfs parameter to allow async readout of the ADCs Marc Titinger
2015-12-12 15:56 ` Jonathan Cameron [this message]
2015-12-12 15:56 ` [lm-sensors] [PATCH v3 2/2] iio: ina2xx: provide a sysfs parameter to allow async readout of the Jonathan Cameron
2015-12-14 11:01 ` [PATCH] iio: ina2xx: add ABI documentation entry sysfs-bus-iio-ina2xx-adc Marc Titinger
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=566C439B.5080406@kernel.org \
--to=jic23@kernel.org \
--cc=jdelvare@suse.com \
--cc=knaack.h@gmx.de \
--cc=lars@metafoo.de \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=lm-sensors@lm-sensors.org \
--cc=mtitinger@baylibre.com \
--cc=pmeerw@pmeerw.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.