* [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support
@ 2026-07-24 20:49 David Lechner (TI)
2026-07-24 20:49 ` [PATCH 1/2] " David Lechner (TI)
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: David Lechner (TI) @ 2026-07-24 20:49 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko
Cc: Chris Hall, Patrick Edwards, Kurt Borja, linux-iio, linux-kernel,
David Lechner (TI)
The TI ADS112C14 ADC has a feature to enable a "burnout" current when
taking a measurement. This can be used to detect open/short circuit
conditions of a connected sensor. However, enabling this affects the
accuracy of the reading. So we add a custom "burnoutraw" attribute for
this. This works like the standard raw attribute to do a direct read
but does so with the burnout current enabled.
If this sounds familiar, it is because we discussed this on a similar
chip recently [1]. And this is why I put the ABI docs in a common ADC
file rather than one specific to this chip.
[1]: https://lore.kernel.org/linux-iio/20260622110223.7e854dde@jic23-huawei/
Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
---
David Lechner (TI) (2):
iio: adc: ti-ads112c14: add burnout current support
iio: ABI: add sysfs attribute for _burnoutraw
Documentation/ABI/testing/sysfs-bus-iio-adc | 9 ++
drivers/iio/adc/ti-ads112c14.c | 126 ++++++++++++++++++++++++++--
2 files changed, 126 insertions(+), 9 deletions(-)
---
base-commit: 0b5e142ced4bcf20532da051934bd694d1bbd470
change-id: 20260724-iio-adc-ti-ads112c14-burnout-184304669165
prerequisite-change-id: 20260714-iio-adc-ti-ads112c14-buffered-read-41e5d1ca0dc3:v2
prerequisite-patch-id: 8723aa599dcf5b836fb81cf1efb6c9096bf60b7a
prerequisite-patch-id: 12754335ccf210bcdeaa8a5d60b2280618d50993
prerequisite-change-id: 20260724-iio-adc-ti-ads112c14-continuous-mode-dd1580754609:v1
prerequisite-patch-id: 8723aa599dcf5b836fb81cf1efb6c9096bf60b7a
prerequisite-patch-id: 12754335ccf210bcdeaa8a5d60b2280618d50993
prerequisite-patch-id: ed5d4c1628ef60ed542339fe5fb490383ee8074f
prerequisite-patch-id: b92f5609fcf39e958e78b4dd74c3d323ebb6a161
Best regards,
--
David Lechner (TI) <dlechner@baylibre.com>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH 1/2] iio: adc: ti-ads112c14: add burnout current support
2026-07-24 20:49 [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support David Lechner (TI)
@ 2026-07-24 20:49 ` David Lechner (TI)
2026-07-24 20:49 ` [PATCH 2/2] iio: ABI: add sysfs attribute for _burnoutraw David Lechner (TI)
2026-07-27 2:08 ` [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: David Lechner (TI) @ 2026-07-24 20:49 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko
Cc: Chris Hall, Patrick Edwards, Kurt Borja, linux-iio, linux-kernel,
David Lechner (TI)
Add a custom attribute via ext_info when a channel has a burnout current
specified in the devicetree. This adds an in_{voltageY,resistanceY,
voltageY-voltageX}_burnoutraw sysfs attribute for the channel that
performs a single conversion (same as _raw attribute) except that it
enables the burnout current. The chip also has a restriction that input
chopping cannot be enabled when burnout current is enabled, so we also
disable input chopping when burnout current is active.
Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
---
drivers/iio/adc/ti-ads112c14.c | 126 ++++++++++++++++++++++++++++++++++++++---
1 file changed, 117 insertions(+), 9 deletions(-)
diff --git a/drivers/iio/adc/ti-ads112c14.c b/drivers/iio/adc/ti-ads112c14.c
index f3a2eba55362..0c79bfc0607a 100644
--- a/drivers/iio/adc/ti-ads112c14.c
+++ b/drivers/iio/adc/ti-ads112c14.c
@@ -76,6 +76,11 @@
#define ADS112C14_DEVICE_CFG_PWDN BIT(7)
#define ADS112C14_DEVICE_CFG_STBY_MODE BIT(6)
#define ADS112C14_DEVICE_CFG_BOCS GENMASK(5, 4)
+#define ADS112C14_DEVICE_CFG_BOCS_DISABLED 0
+#define ADS112C14_DEVICE_CFG_BOCS_200_nA 1
+#define ADS112C14_DEVICE_CFG_BOCS_1_uA 2
+#define ADS112C14_DEVICE_CFG_BOCS_10_uA 3
+
#define ADS112C14_DEVICE_CFG_CLK_SEL BIT(3)
#define ADS112C14_DEVICE_CFG_CONV_MODE BIT(2)
#define ADS112C14_DEVICE_CFG_CONV_MODE_CONTINUOUS 0
@@ -251,6 +256,7 @@ struct ads112c14_measurement {
u8 idac2_mux;
u8 iadc_count;
u8 gain_val;
+ u8 burnout;
bool global_chop;
bool bipolar;
int scale_available[ARRAY_SIZE(ads112c14_pga_gains_x10)][2];
@@ -474,7 +480,8 @@ static const struct regmap_config ads112c14_regmap_config = {
};
static int ads112c14_prepare_measurement_channel(struct ads112c14_data *data,
- const struct iio_chan_spec *chan)
+ const struct iio_chan_spec *chan,
+ bool en_burnout)
{
struct ads112c14_measurement *measurement = &data->measurements[chan->scan_index];
u32 refp_buf_en, refn_buf_en, ref_val, ref_sel;
@@ -528,7 +535,7 @@ static int ads112c14_prepare_measurement_channel(struct ads112c14_data *data,
ret = regmap_update_bits(data->regmap, ADS112C14_REG_DATA_RATE_CFG,
ADS112C14_DATA_RATE_CFG_GC_EN,
FIELD_PREP(ADS112C14_DATA_RATE_CFG_GC_EN,
- measurement->global_chop));
+ measurement->global_chop && !en_burnout));
if (ret)
return ret;
@@ -626,10 +633,11 @@ static int ads112c14_prepare_sys_mon_channel(struct ads112c14_data *data,
}
static int ads112c14_prepare_channel(struct ads112c14_data *data,
- const struct iio_chan_spec *chan)
+ const struct iio_chan_spec *chan,
+ bool en_burnout)
{
if (chan->channel < ADS112C14_SYS_MON_CHANNEL_BASE)
- return ads112c14_prepare_measurement_channel(data, chan);
+ return ads112c14_prepare_measurement_channel(data, chan, en_burnout);
return ads112c14_prepare_sys_mon_channel(data, chan);
}
@@ -653,7 +661,7 @@ static int ads112c14_scan_read(struct ads112c14_data *data, u8 *buf)
static int ads112c14_single_conversion(struct ads112c14_data *data,
const struct iio_chan_spec *chan,
- u8 *buf, bool for_scan)
+ u8 *buf, bool en_burnout, bool for_scan)
{
struct i2c_client *client = to_i2c_client(regmap_get_device(data->regmap));
u32 reg_val;
@@ -661,7 +669,7 @@ static int ads112c14_single_conversion(struct ads112c14_data *data,
guard(mutex)(&data->lock);
- ret = ads112c14_prepare_channel(data, chan);
+ ret = ads112c14_prepare_channel(data, chan, en_burnout);
if (ret)
return ret;
@@ -736,7 +744,7 @@ static int ads112c14_read_raw(struct iio_dev *indio_dev,
if (IIO_DEV_ACQUIRE_FAILED(claim))
return -EBUSY;
- ret = ads112c14_single_conversion(data, chan, buf, false);
+ ret = ads112c14_single_conversion(data, chan, buf, false, false);
if (ret)
return ret;
@@ -999,7 +1007,7 @@ static irqreturn_t ads112c14_trigger_handler(int irq, void *private)
ret = ads112c14_single_conversion(data, chan,
(u8 *)&data->scan[offset++],
- true);
+ false, true);
if (ret) {
dev_err_once(indio_dev->dev.parent,
"failed to read channel %d: %pe; additional errors will be suppressed\n",
@@ -1060,7 +1068,7 @@ static int ads112c14_buffer_postenable(struct iio_dev *indio_dev)
guard(mutex)(&data->lock);
- ret = ads112c14_prepare_channel(data, chan);
+ ret = ads112c14_prepare_channel(data, chan, false);
if (ret)
return ret;
@@ -1109,6 +1117,78 @@ static const struct iio_buffer_setup_ops ads112c14_buffer_setup_ops = {
.validate_scan_mask = ads112c14_validate_scan_mask,
};
+static ssize_t ads112c14_read_burnout_raw(struct iio_dev *indio_dev,
+ uintptr_t private,
+ struct iio_chan_spec const *chan,
+ char *buf)
+{
+ struct ads112c14_data *data = iio_priv(indio_dev);
+ struct ads112c14_measurement *measurement;
+ int ret, ret2, val;
+ u8 raw_buf[3];
+
+ if (chan->channel >= ADS112C14_SYS_MON_CHANNEL_BASE)
+ return -EINVAL;
+
+ measurement = &data->measurements[chan->scan_index];
+
+ if (!measurement->burnout)
+ return -EINVAL;
+
+ IIO_DEV_ACQUIRE_DIRECT_MODE(indio_dev, claim);
+ if (IIO_DEV_ACQUIRE_FAILED(claim))
+ return -EBUSY;
+
+ ret = regmap_update_bits(data->regmap, ADS112C14_REG_DEVICE_CFG,
+ ADS112C14_DEVICE_CFG_BOCS,
+ FIELD_PREP(ADS112C14_DEVICE_CFG_BOCS,
+ measurement->burnout));
+ if (ret)
+ return ret;
+
+ ret = ads112c14_single_conversion(data, chan, raw_buf, true, false);
+
+ /*
+ * Important to always turn off burnout current even if the conversion
+ * fails so that it does not affect subsequent measurements. This error
+ * also takes precedence over the conversion error since the device may
+ * be left in a bad state.
+ */
+ ret2 = regmap_update_bits(data->regmap, ADS112C14_REG_DEVICE_CFG,
+ ADS112C14_DEVICE_CFG_BOCS,
+ FIELD_PREP(ADS112C14_DEVICE_CFG_BOCS,
+ ADS112C14_DEVICE_CFG_BOCS_DISABLED));
+ if (ret2)
+ return ret2;
+
+ if (ret < 0)
+ return ret;
+
+ switch (data->chip_info->resolution_bits) {
+ case 16:
+ val = get_unaligned_be16(raw_buf);
+ break;
+ case 24:
+ val = get_unaligned_be24(raw_buf);
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ if (measurement->bipolar)
+ val = sign_extend32(val, data->chip_info->resolution_bits - 1);
+
+ return sysfs_emit(buf, "%d\n", val);
+}
+
+static const struct iio_chan_spec_ext_info ads112c14_ext_info_burnout[] = {
+ {
+ .name = "burnoutraw",
+ .read = ads112c14_read_burnout_raw,
+ },
+ { }
+};
+
static int ads112c14_populate_idac_mag(u32 current_nA, u8 *idac_mag)
{
u32 current_uA = current_nA / (NANO / MICRO);
@@ -1277,6 +1357,34 @@ static int ads112c14_parse_channels(struct iio_dev *indio_dev,
measurement->global_chop = fwnode_property_read_bool(child,
"input-chopping");
+ if (fwnode_property_present(child, "burn-out-current-nanoamp")) {
+ u32 burnout_nA;
+
+ ret = fwnode_property_read_u32(child, "burn-out-current-nanoamp",
+ &burnout_nA);
+ if (ret)
+ return dev_err_probe(dev, ret,
+ "failed to read burn-out-current-nanoamp property\n");
+
+ switch (burnout_nA) {
+ case 200:
+ measurement->burnout = ADS112C14_DEVICE_CFG_BOCS_200_nA;
+ break;
+ case 1000:
+ measurement->burnout = ADS112C14_DEVICE_CFG_BOCS_1_uA;
+ break;
+ case 10000:
+ measurement->burnout = ADS112C14_DEVICE_CFG_BOCS_10_uA;
+ break;
+ default:
+ return dev_err_probe(dev, -EINVAL,
+ "invalid burn-out-current-nanoamp value\n");
+ }
+
+ if (measurement->burnout)
+ spec->ext_info = ads112c14_ext_info_burnout;
+ }
+
if (fwnode_property_present(child, "reference-sources")) {
ret = fwnode_property_match_property_string(child,
"reference-sources", ads112c14_vref_source_names,
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH 2/2] iio: ABI: add sysfs attribute for _burnoutraw
2026-07-24 20:49 [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support David Lechner (TI)
2026-07-24 20:49 ` [PATCH 1/2] " David Lechner (TI)
@ 2026-07-24 20:49 ` David Lechner (TI)
2026-07-27 2:08 ` [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support Jonathan Cameron
2 siblings, 0 replies; 5+ messages in thread
From: David Lechner (TI) @ 2026-07-24 20:49 UTC (permalink / raw)
To: Jonathan Cameron, Nuno Sá, Andy Shevchenko
Cc: Chris Hall, Patrick Edwards, Kurt Borja, linux-iio, linux-kernel,
David Lechner (TI)
Add a new _burnoutraw attribute to the IIO ADC ABI. This is likely only
applicable to ADCs (but is seen on multiple chips and vendors) so it
gets its own file instead of being added to the main IIO ABI file.
Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
---
Documentation/ABI/testing/sysfs-bus-iio-adc | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-iio-adc b/Documentation/ABI/testing/sysfs-bus-iio-adc
new file mode 100644
index 000000000000..d45f0a4eb18e
--- /dev/null
+++ b/Documentation/ABI/testing/sysfs-bus-iio-adc
@@ -0,0 +1,9 @@
+What: /sys/bus/iio/devices/iio:deviceX/in_resistanceY_burnoutraw
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY_burnoutraw
+What: /sys/bus/iio/devices/iio:deviceX/in_voltageY-voltageZ_burnoutraw
+KernelVersion: 7.3
+Contact: linux-iio@vger.kernel.org
+Description:
+ Raw value from channel Y read using a single conversion with
+ the channel burnout current enabled. This is typically used
+ for diagnostic purposes to detect an open or shorted input.
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support
2026-07-24 20:49 [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support David Lechner (TI)
2026-07-24 20:49 ` [PATCH 1/2] " David Lechner (TI)
2026-07-24 20:49 ` [PATCH 2/2] iio: ABI: add sysfs attribute for _burnoutraw David Lechner (TI)
@ 2026-07-27 2:08 ` Jonathan Cameron
2026-08-23 22:20 ` Jonathan Cameron
2 siblings, 1 reply; 5+ messages in thread
From: Jonathan Cameron @ 2026-07-27 2:08 UTC (permalink / raw)
To: David Lechner (TI)
Cc: Nuno Sá, Andy Shevchenko, Chris Hall, Patrick Edwards,
Kurt Borja, linux-iio, linux-kernel
On Fri, 24 Jul 2026 15:49:16 -0500
"David Lechner (TI)" <dlechner@baylibre.com> wrote:
> The TI ADS112C14 ADC has a feature to enable a "burnout" current when
> taking a measurement. This can be used to detect open/short circuit
> conditions of a connected sensor. However, enabling this affects the
> accuracy of the reading. So we add a custom "burnoutraw" attribute for
> this. This works like the standard raw attribute to do a direct read
> but does so with the burnout current enabled.
>
> If this sounds familiar, it is because we discussed this on a similar
> chip recently [1]. And this is why I put the ABI docs in a common ADC
> file rather than one specific to this chip.
>
> [1]: https://lore.kernel.org/linux-iio/20260622110223.7e854dde@jic23-huawei/
>
> Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
Seems fine to me, but given it is new ABI, I'd like some more eyes on the documentation
patch in particular.
Thanks
Jonathan
> ---
> David Lechner (TI) (2):
> iio: adc: ti-ads112c14: add burnout current support
> iio: ABI: add sysfs attribute for _burnoutraw
>
> Documentation/ABI/testing/sysfs-bus-iio-adc | 9 ++
> drivers/iio/adc/ti-ads112c14.c | 126 ++++++++++++++++++++++++++--
> 2 files changed, 126 insertions(+), 9 deletions(-)
> ---
> base-commit: 0b5e142ced4bcf20532da051934bd694d1bbd470
> change-id: 20260724-iio-adc-ti-ads112c14-burnout-184304669165
> prerequisite-change-id: 20260714-iio-adc-ti-ads112c14-buffered-read-41e5d1ca0dc3:v2
> prerequisite-patch-id: 8723aa599dcf5b836fb81cf1efb6c9096bf60b7a
> prerequisite-patch-id: 12754335ccf210bcdeaa8a5d60b2280618d50993
> prerequisite-change-id: 20260724-iio-adc-ti-ads112c14-continuous-mode-dd1580754609:v1
> prerequisite-patch-id: 8723aa599dcf5b836fb81cf1efb6c9096bf60b7a
> prerequisite-patch-id: 12754335ccf210bcdeaa8a5d60b2280618d50993
> prerequisite-patch-id: ed5d4c1628ef60ed542339fe5fb490383ee8074f
> prerequisite-patch-id: b92f5609fcf39e958e78b4dd74c3d323ebb6a161
>
> Best regards,
> --
> David Lechner (TI) <dlechner@baylibre.com>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support
2026-07-27 2:08 ` [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support Jonathan Cameron
@ 2026-08-23 22:20 ` Jonathan Cameron
0 siblings, 0 replies; 5+ messages in thread
From: Jonathan Cameron @ 2026-08-23 22:20 UTC (permalink / raw)
To: David Lechner (TI)
Cc: Nuno Sá, Andy Shevchenko, Chris Hall, Patrick Edwards,
Kurt Borja, linux-iio, linux-kernel
On Mon, 27 Jul 2026 03:08:22 +0100
Jonathan Cameron <jic23@kernel.org> wrote:
> On Fri, 24 Jul 2026 15:49:16 -0500
> "David Lechner (TI)" <dlechner@baylibre.com> wrote:
>
> > The TI ADS112C14 ADC has a feature to enable a "burnout" current when
> > taking a measurement. This can be used to detect open/short circuit
> > conditions of a connected sensor. However, enabling this affects the
> > accuracy of the reading. So we add a custom "burnoutraw" attribute for
> > this. This works like the standard raw attribute to do a direct read
> > but does so with the burnout current enabled.
> >
> > If this sounds familiar, it is because we discussed this on a similar
> > chip recently [1]. And this is why I put the ABI docs in a common ADC
> > file rather than one specific to this chip.
> >
> > [1]: https://lore.kernel.org/linux-iio/20260622110223.7e854dde@jic23-huawei/
> >
> > Signed-off-by: David Lechner (TI) <dlechner@baylibre.com>
>
> Seems fine to me, but given it is new ABI, I'd like some more eyes on the documentation
> patch in particular.
Seems no interest in this from others. I've no idea what this was on top
of so please rebase or resend alongside those other series.
All I know is it doesn't apply to my tree - which isn't that surprising
given all the series around for this driver!
Jonathan
>
> Thanks
>
> Jonathan
>
> > ---
> > David Lechner (TI) (2):
> > iio: adc: ti-ads112c14: add burnout current support
> > iio: ABI: add sysfs attribute for _burnoutraw
> >
> > Documentation/ABI/testing/sysfs-bus-iio-adc | 9 ++
> > drivers/iio/adc/ti-ads112c14.c | 126 ++++++++++++++++++++++++++--
> > 2 files changed, 126 insertions(+), 9 deletions(-)
> > ---
> > base-commit: 0b5e142ced4bcf20532da051934bd694d1bbd470
> > change-id: 20260724-iio-adc-ti-ads112c14-burnout-184304669165
> > prerequisite-change-id: 20260714-iio-adc-ti-ads112c14-buffered-read-41e5d1ca0dc3:v2
> > prerequisite-patch-id: 8723aa599dcf5b836fb81cf1efb6c9096bf60b7a
> > prerequisite-patch-id: 12754335ccf210bcdeaa8a5d60b2280618d50993
> > prerequisite-change-id: 20260724-iio-adc-ti-ads112c14-continuous-mode-dd1580754609:v1
> > prerequisite-patch-id: 8723aa599dcf5b836fb81cf1efb6c9096bf60b7a
> > prerequisite-patch-id: 12754335ccf210bcdeaa8a5d60b2280618d50993
> > prerequisite-patch-id: ed5d4c1628ef60ed542339fe5fb490383ee8074f
> > prerequisite-patch-id: b92f5609fcf39e958e78b4dd74c3d323ebb6a161
> >
> > Best regards,
> > --
> > David Lechner (TI) <dlechner@baylibre.com>
> >
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-08-23 22:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-24 20:49 [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support David Lechner (TI)
2026-07-24 20:49 ` [PATCH 1/2] " David Lechner (TI)
2026-07-24 20:49 ` [PATCH 2/2] iio: ABI: add sysfs attribute for _burnoutraw David Lechner (TI)
2026-07-27 2:08 ` [PATCH 0/2] iio: adc: ti-ads112c14: add burnout current support Jonathan Cameron
2026-08-23 22:20 ` Jonathan Cameron
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox