From: Ariana Lazar <ariana.lazar@microchip.com>
To: "Jonathan Cameron" <jic23@kernel.org>,
"Guenter Roeck" <linux@roeck-us.net>,
"David Lechner" <dlechner@baylibre.com>,
"Nuno Sá" <nuno.sa@analog.com>,
"Andy Shevchenko" <andy@kernel.org>,
"Rob Herring" <robh@kernel.org>,
"Krzysztof Kozlowski" <krzk+dt@kernel.org>,
"Conor Dooley" <conor+dt@kernel.org>
Cc: <linux-iio@vger.kernel.org>, <devicetree@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-hwmon@vger.kernel.org>,
Ariana Lazar <ariana.lazar@microchip.com>
Subject: [PATCH v4 1/3] iio: core: add IIO_CHARGE channel type
Date: Wed, 7 Oct 2026 17:41:53 +0300 [thread overview]
Message-ID: <20261007-pac1711-v4-1-6ef34d7a7947@microchip.com> (raw)
In-Reply-To: <20261007-pac1711-v4-0-6ef34d7a7947@microchip.com>
Add a new channel type for Coulomb counters, which accumulate current
measurements over time. The sysfs attribute is in_chargeY_raw and after
applying in_chargeY_scale, the value exposed is in milliCoulombs,
following the SI convention used by the IIO subsystem.
This new channel type will first be used by the pac1711 driver to report
Coulomb counter measurements.
Signed-off-by: Ariana Lazar <ariana.lazar@microchip.com>
---
Documentation/ABI/testing/sysfs-bus-iio | 13 +++++++++++++
drivers/iio/industrialio-core.c | 1 +
include/uapi/linux/iio/types.h | 1 +
tools/iio/iio_event_monitor.c | 2 ++
4 files changed, 17 insertions(+)
diff --git a/Documentation/ABI/testing/sysfs-bus-iio b/Documentation/ABI/testing/sysfs-bus-iio
index a4f5595722ade77e81b49efffc68c971e60a2e5b..3d569a2169c2100b3fc81d38bd63124fb8b67e84 100644
--- a/Documentation/ABI/testing/sysfs-bus-iio
+++ b/Documentation/ABI/testing/sysfs-bus-iio
@@ -510,6 +510,8 @@ What: /sys/bus/iio/devices/iio:deviceX/in_intensity_blue_scale
What: /sys/bus/iio/devices/iio:deviceX/in_concentration_co2_scale
What: /sys/bus/iio/devices/iio:deviceX/in_volumeflow_scale
What: /sys/bus/iio/devices/iio:deviceX/in_volumeflowY_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_charge_scale
+What: /sys/bus/iio/devices/iio:deviceX/in_chargeY_scale
KernelVersion: 2.6.35
Contact: linux-iio@vger.kernel.org
Description:
@@ -1781,6 +1783,7 @@ What: /sys/.../iio:deviceX/in_energy_en
What: /sys/.../iio:deviceX/in_distance_en
What: /sys/.../iio:deviceX/in_velocity_sqrt(x^2+y^2+z^2)_en
What: /sys/.../iio:deviceX/in_steps_en
+What: /sys/.../iio:deviceX/in_charge_en
KernelVersion: 3.19
Contact: linux-iio@vger.kernel.org
Description:
@@ -2509,3 +2512,13 @@ Description:
Raw (unscaled) volumetric flow rate reading from the channel.
To convert to standard units (cubic metres per second, m^3/s)
apply the channel's _scale (and _offset, when present).
+
+What: /sys/bus/iio/devices/iio:deviceX/in_charge_raw
+What: /sys/bus/iio/devices/iio:deviceX/in_chargeY_raw
+KernelVersion: 7.4
+Contact: linux-iio@vger.kernel.org
+Description:
+ Raw charge value read from the channel. The device acts as
+ a Coulomb counter by accumulating current measurements over
+ time. Units after application of scale are milliCoulombs. X
+ is the IIO index of the device.
diff --git a/drivers/iio/industrialio-core.c b/drivers/iio/industrialio-core.c
index 767a7794624a5026742087eb8885eb2a5ded05f0..90c92e57e8605d2ab443541b88944dab7084babc 100644
--- a/drivers/iio/industrialio-core.c
+++ b/drivers/iio/industrialio-core.c
@@ -100,6 +100,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_ALTCURRENT] = "altcurrent",
[IIO_COVERAGE] = "coverage",
[IIO_VOLUMEFLOW] = "volumeflow",
+ [IIO_CHARGE] = "charge",
};
static const char * const iio_modifier_names[] = {
diff --git a/include/uapi/linux/iio/types.h b/include/uapi/linux/iio/types.h
index d0fb714ca0fd97421d2c8345e3bc34329f1cb1b9..8acf4105216c11718c07f76ac67b93a8ba7fd6a0 100644
--- a/include/uapi/linux/iio/types.h
+++ b/include/uapi/linux/iio/types.h
@@ -55,6 +55,7 @@ enum iio_chan_type {
IIO_ALTCURRENT,
IIO_COVERAGE,
IIO_VOLUMEFLOW,
+ IIO_CHARGE,
};
enum iio_modifier {
diff --git a/tools/iio/iio_event_monitor.c b/tools/iio/iio_event_monitor.c
index b5c5479b9d78f70cab9d6939ceaab32e42b3f718..50c12395767c0c91916eabc420c62631e834a4e5 100644
--- a/tools/iio/iio_event_monitor.c
+++ b/tools/iio/iio_event_monitor.c
@@ -67,6 +67,7 @@ static const char * const iio_chan_type_name_spec[] = {
[IIO_ALTCURRENT] = "altcurrent",
[IIO_COVERAGE] = "coverage",
[IIO_VOLUMEFLOW] = "volumeflow",
+ [IIO_CHARGE] = "charge",
};
static const char * const iio_ev_type_text[] = {
@@ -198,6 +199,7 @@ static bool event_is_known(struct iio_event_data *event)
case IIO_ALTCURRENT:
case IIO_COVERAGE:
case IIO_VOLUMEFLOW:
+ case IIO_CHARGE:
break;
default:
return false;
--
2.43.0
next prev parent reply other threads:[~2026-10-07 14:42 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-07 14:41 [PATCH v4 0/3] Add support for Microchip PAC1711 Power Monitor Ariana Lazar
2026-10-07 14:41 ` Ariana Lazar [this message]
2026-10-07 14:41 ` [PATCH v4 2/3] dt-bindings: iio: adc: add support for PAC1711 Ariana Lazar
2026-10-07 20:47 ` Rob Herring (Arm)
2026-10-07 14:41 ` [PATCH v4 3/3] " Ariana Lazar
2026-10-08 16:46 ` kernel test robot
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=20261007-pac1711-v4-1-6ef34d7a7947@microchip.com \
--to=ariana.lazar@microchip.com \
--cc=andy@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=dlechner@baylibre.com \
--cc=jic23@kernel.org \
--cc=krzk+dt@kernel.org \
--cc=linux-hwmon@vger.kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@roeck-us.net \
--cc=nuno.sa@analog.com \
--cc=robh@kernel.org \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®