Skip to contentSkip to conversation

hwmon: Add support for Amphenol ChipCap 2

PATCH Superseded Javier Carrasco 3 participants 11 messages Dec 7, 2023 – Dec 8, 2023

Subsystems (4)

v3 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Javier Carrasco

author maintainer
#0 lore raw

v3 cover hwmon: Add support for Amphenol ChipCap 2

This series adds support and documentation for the Amphenol ChipCap 2 humidity and temperature sensor in its digital version.

This I2C device provides 14-bit humidity and temperature measurements as well as low (minimum) and high (maximum) humidity alarms. A ready signal is also available to reduce delays while fetching data.

The proposed driver implements the logic to perform measurements with and without the ready signal, EEPROM configuration and alarm signaling.

The features this driver does not support (I2C address and command window length modification) have been documented in the "Known Issues" section.

The complete supported functionality has been tested with a CC2D33S sensor (a 'sleep' device) connected to a Raspberry Pi Zero 2 w. Different device tree node definitions (with and without regulator, ready and/or alarm signals) have been positively tested.

The non-sleep measurement mechanism has been inferred from the first measurement, which is carried out automatically and it is common for all part numbers. Any testing or improvements with a non-sleep device is more than welcome.

The tests have also covered the properties added to the hwmon core to account for minimum and maximum humidity alarms.

---
Changes in v3:
- ABI: sysfs-class-hwmon: documented humidity min/max alarms.
- General: reorder patches (bindings first to remove checkpatch
warnings).
- General: remove part number wildcards and use real part numbers.
- chipcap2.c: improve error path in probe function.
- chipcap2.c: fix error handling if regulator could not be registered.
- chipcap2.c: use absolute values for hysteresis (for both ABI
compatibility and simplicity).
- chipcap2.c: minor code-style fixes and variable renaming.
- Link to v2: https://lore.kernel.org/r/[email protected]

Changes in v2:
- vendor-prefixes: full company name in the vendor description (Krzystof Kozlowski)
- chipcap2.c: proper i2c_device_id table, coding style fixes, cleaner
error path in the probe function (Krzystof Kozlowski)
- dt-bindings: per-item description and lowercase names (Krzystof
Kozlowski)
- MAINTAINERS: fix manufacturer name (Krzystof Kozlowski)
- Link to v1: https://lore.kernel.org/r/[email protected]

---
Javier Carrasco (5):
dt-bindings: vendor-prefixes: add Amphenol
hwmon: (core) Add support for humidity min/max alarm
ABI: sysfs-class-hwmon: add descriptions for humidity min/max alarms
dt-bindings: hwmon: Add Amphenol ChipCap 2
hwmon: Add support for Amphenol ChipCap 2

 Documentation/ABI/testing/sysfs-class-hwmon        |   18 +
 .../bindings/hwmon/amphenol,chipcap2.yaml          |   74 ++
 .../devicetree/bindings/vendor-prefixes.yaml       |    2 +
 Documentation/hwmon/chipcap2.rst                   |   73 ++
 Documentation/hwmon/index.rst                      |    1 +
 MAINTAINERS                                        |    8 +
 drivers/hwmon/Kconfig                              |   10 +
 drivers/hwmon/Makefile                             |    1 +
 drivers/hwmon/chipcap2.c                           | 1040 ++++++++++++++++++++
 drivers/hwmon/hwmon.c                              |    2 +
 include/linux/hwmon.h                              |    4 +
 11 files changed, 1233 insertions(+)

---
base-commit: 33cc938e65a98f1d29d0a18403dbbee050dcad9a
change-id: 20231020-topic-chipcap2-e2d8985430c2

Best regards,

Signature · 1 line
Javier Carrasco <[email protected]>
author maintainer
#1 lore raw

PATCH v3 1/5 dt-bindings: vendor-prefixes: add Amphenol

Add vendor prefix for Amphenol (https://www.amphenol-sensors.com)

---
 Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++
 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/vendor-prefixes.yaml +2 -0
index 309b94c328c8..4a49f24b906b 100644
@@ -105,6 +105,8 @@ patternProperties:
     description: Amlogic, Inc.
   "^ampere,.*":
     description: Ampere Computing LLC
+  "^amphenol,.*":
+    description: Amphenol Advanced Sensors
   "^ampire,.*":
     description: Ampire Co., Ltd.
   "^ams,.*":
Signature · 1 line
2.39.2
author maintainer
#2 lore raw

PATCH v3 2/5 hwmon: (core) Add support for humidity min/max alarm

In reply to Javier Carrasco

Add min_alarm and max_alarm attributes for humidityX to support devices that can generate these alarms.
Such attributes already exist for other magnitudes such as tempX.

Tested with a ChipCap 2 temperature-humidity sensor.

---
 drivers/hwmon/hwmon.c | 2 ++
 include/linux/hwmon.h | 4 ++++
 2 files changed, 6 insertions(+)
drivers/hwmon/hwmon.c +2 -0
index c7dd3f5b2bd5..7f92984c37d9 100644
@@ -579,8 +579,10 @@ static const char * const hwmon_humidity_attr_templates[] = {
 	[hwmon_humidity_input] = "humidity%d_input",
 	[hwmon_humidity_label] = "humidity%d_label",
 	[hwmon_humidity_min] = "humidity%d_min",
+	[hwmon_humidity_min_alarm] = "humidity%d_min_alarm",
 	[hwmon_humidity_min_hyst] = "humidity%d_min_hyst",
 	[hwmon_humidity_max] = "humidity%d_max",
+	[hwmon_humidity_max_alarm] = "humidity%d_max_alarm",
 	[hwmon_humidity_max_hyst] = "humidity%d_max_hyst",
 	[hwmon_humidity_alarm] = "humidity%d_alarm",
 	[hwmon_humidity_fault] = "humidity%d_fault",
include/linux/hwmon.h +4 -0
index 8cd6a6b33593..154de35e34ac 100644
@@ -286,8 +286,10 @@ enum hwmon_humidity_attributes {
 	hwmon_humidity_input,
 	hwmon_humidity_label,
 	hwmon_humidity_min,
+	hwmon_humidity_min_alarm,
 	hwmon_humidity_min_hyst,
 	hwmon_humidity_max,
+	hwmon_humidity_max_alarm,
 	hwmon_humidity_max_hyst,
 	hwmon_humidity_alarm,
 	hwmon_humidity_fault,
@@ -299,8 +301,10 @@ enum hwmon_humidity_attributes {
 #define HWMON_H_INPUT			BIT(hwmon_humidity_input)
 #define HWMON_H_LABEL			BIT(hwmon_humidity_label)
 #define HWMON_H_MIN			BIT(hwmon_humidity_min)
+#define HWMON_H_MIN_ALARM		BIT(hwmon_humidity_min_alarm)
 #define HWMON_H_MIN_HYST		BIT(hwmon_humidity_min_hyst)
 #define HWMON_H_MAX			BIT(hwmon_humidity_max)
+#define HWMON_H_MAX_ALARM		BIT(hwmon_humidity_max_alarm)
 #define HWMON_H_MAX_HYST		BIT(hwmon_humidity_max_hyst)
 #define HWMON_H_ALARM			BIT(hwmon_humidity_alarm)
 #define HWMON_H_FAULT			BIT(hwmon_humidity_fault)
Signature · 1 line
2.39.2
author maintainer
#3 lore raw

PATCH v3 3/5 ABI: sysfs-class-hwmon: add descriptions for humidity min/max alarms

In reply to Javier Carrasco

This attributes have been recently introduced and require the corresponding ABI documentation.

---
 Documentation/ABI/testing/sysfs-class-hwmon | 18 ++++++++++++++++++
 1 file changed, 18 insertions(+)
Documentation/ABI/testing/sysfs-class-hwmon +18 -0
index 638f4c6d4ec7..af94c1f373de 100644
@@ -908,6 +908,24 @@ Description:
 
 		RW
 
+What:		/sys/class/hwmon/hwmonX/humidityY_min_alarm
+Description:
+		Minimum humidity detection
+
+		- 0: OK
+		- 1: Minimum humidity detected
+
+		RO
+
+What:		/sys/class/hwmon/hwmonX/humidityY_max_alarm
+Description:
+		Maximum humidity detection
+
+		- 0: OK
+		- 1: Maximum humidity detected
+
+		RO
+
 What:		/sys/class/hwmon/hwmonX/humidityY_rated_min
 Description:
 		Minimum rated humidity.
Signature · 1 line
2.39.2
author maintainer
#4 lore raw

PATCH v3 4/5 dt-bindings: hwmon: Add Amphenol ChipCap 2

In reply to Javier Carrasco

Add device tree bindings and an example for the ChipCap 2 humidity and temperature sensor.

---
 .../bindings/hwmon/amphenol,chipcap2.yaml          | 74 ++++++++++++++++++++++
 1 file changed, 74 insertions(+)
Documentation/devicetree/bindings/hwmon/amphenol,chipcap2.yaml new file +74 -0
new file mode 100644
index 000000000000..b83bbc2719ff
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
+%YAML 1.2
+---
+$id: http://devicetree.org/schemas/hwmon/amphenol,chipcap2.yaml#
+$schema: http://devicetree.org/meta-schemas/core.yaml#
+
+title: ChipCap 2 humidity and temperature iio sensor
+
+maintainers:
+  - Javier Carrasco <[email protected]>
+
+description: |
+  Relative humidity and temperature sensor on I2C bus.
+
+  Datasheets:
+    https://www.amphenol-sensors.com/en/telaire/humidity/527-humidity-sensors/3095-chipcap-2
+
+properties:
+  compatible:
+    enum:
+      - amphenol,cc2d23
+      - amphenol,cc2d23s
+      - amphenol,cc2d25
+      - amphenol,cc2d25s
+      - amphenol,cc2d33
+      - amphenol,cc2d33s
+      - amphenol,cc2d35
+      - amphenol,cc2d35s
+
+  reg:
+    maxItems: 1
+
+  interrupts:
+    items:
+      - description: measurement ready indicator
+      - description: low humidity alarm
+      - description: high humidity alarm
+
+  interrupt-names:
+    items:
+      - const: ready
+      - const: low
+      - const: high
+
+  vdd-supply:
+    description:
+      Dedicated, controllable supply-regulator to reset the device and
+      enter in command mode.
+      If not defined, no alarms will be available.
+
+required:
+  - compatible
+  - reg
+
+additionalProperties: false
+
+examples:
+  - |
+    #include <dt-bindings/interrupt-controller/irq.h>
+    i2c {
+        #address-cells = <1>;
+        #size-cells = <0>;
+
+        humidity@28 {
+            compatible = "amphenol,cc2d23s";
+            reg = <0x28>;
+            interrupt-parent = <&gpio>;
+            interrupts = <4 IRQ_TYPE_EDGE_RISING>,
+                         <5 IRQ_TYPE_EDGE_RISING>,
+                         <6 IRQ_TYPE_EDGE_RISING>;
+            interrupt-names = "ready", "low", "high";
+            vdd-supply = <&reg_vdd>;
+        };
+    };
Signature · 1 line
2.39.2
author maintainer
#6 lore raw

PATCH v3 5/5 hwmon: Add support for Amphenol ChipCap 2

In reply to Javier Carrasco

The Amphenol ChipCap 2 is a capacitive polymer humidity and temperature sensor with an integrated EEPROM and minimum/maximum humidity alarms.

All device variants offer an I2C interface and depending on the part number, two different output modes:
- CC2D: digital output
- CC2A: analog (PDM) output

This driver adds support for the digital variant (CC2D part numbers), which is also divided into two subfamilies [1]:
- non-sleep measurement mode (CC2D23, CC2D25, CC2D33, CC2D35)
- sleep measurement mode (CC2D23S, CC2D25S, CC2D33S, CC2D35S)

The only difference between them is that the non-sleep parts carry out measurements periodically, whereas the sleep counterparts require the user to trigger each measurement, staying in sleep mode otherwise to increase power savings.

The Chipcap 2 EEPROM can be accessed to configure a series of parameters like the minimum/maximum humidity alarm threshold and hysteresis. The EEPROM is only accessible in the command window after a power-on reset. The default window lasts 10 ms if no Start_CM command is sent. After the command window is finished (either after the mentioned timeout of after a Start_NOM command is sent), the device enters the normal operation mode and makes a first measurement automatically.

Unfortunately, the device does not provide any hardware or software reset and therefore the driver must trigger power cycles to enter the command mode. An external regulator is required for that and if it is not available, the driver cannot configure the alarms and it must limit the device operation to humidity and temperature measurements.

Given the high cost of accessing the command mode, an EEPROM read is made in the probe function and the alarm parameters are stored for further readings, only accessing the command mode again to overwrite those parameters.

The measurement process makes use of the ready signal if available, using maximum delay values from the datasheet otherwise. In non-sleep mode, a single "data fetch" command is required to read the measurements and no trigger is required. Sleep devices require an additional "measurement request" command to trigger the measurement, followed by a data fetch to retrieve the measured values. In both cases the ready signal goes high when valid data can be fetched. The ready signal stays high until the data is retrieved even if further measurements are made.

The minimum and maximum humidity alarms can be configured with two registers per alarm: one stores the alarm threshold and the other one keeps the value that turns off the alarm. Note that the second register stores an absolute value and not the hysteresis. The hysteresis is therefore obtained as a subtraction of the two registers. The alarm signals are only updated when a measurement is carried out. Sleep mode devices will not trigger their alarms until a measurement is requested.

This driver has been tested with a sleep device and the non-sleep mechanism has been inferred from the common behavior after power-on reset explained above, where a first measurement is made without user intervention. Therefore there is no guarantee that no adjustments in the measurement function will be required if the driver ever controls a non-sleep device.

[1] Note that the measurement mode is programmed in the manufacturing process. The datasheet mentions the name of the register and exact bit to set the measurement mode, but no addresses are provided and according to the manufacturer, it is not modifiable by the user.

---
 Documentation/hwmon/chipcap2.rst |   73 +++
 Documentation/hwmon/index.rst    |    1 +
 MAINTAINERS                      |    8 +
 drivers/hwmon/Kconfig            |   10 +
 drivers/hwmon/Makefile           |    1 +
 drivers/hwmon/chipcap2.c         | 1040 ++++++++++++++++++++++++++++++++++++++
 6 files changed, 1133 insertions(+)
Documentation/hwmon/chipcap2.rst new file +73 -0
new file mode 100644
index 000000000000..35a968aaac4e
@@ -0,0 +1,73 @@
+.. SPDX-License-Identifier: GPL-2.0-or-later
+
+Kernel driver ChipCap2
+======================
+
+Supported chips:
+
+  * Amphenol CC2D23, CC2D23S, CC2D25, CC2D25S, CC2D33, CC2D33S, CC2D35, CC2D35S
+
+    Prefix: 'chipcap2'
+
+    Addresses scanned: -
+
+    Datasheet: https://www.amphenol-sensors.com/en/telaire/humidity/527-humidity-sensors/3095-chipcap-2
+
+Author:
+
+  - Javier Carrasco <[email protected]>
+
+Description
+-----------
+
+This driver implements support for the Amphenol ChipCap 2 chips, a humidity
+and temperature family. Temperature is measured in milli degrees celsius,
+relative humidity is expressed as a per cent mille. The measurement ranges
+are the following:
+
+  - Relative humidity: 0 to 100000 pcm (14-bit resolution)
+  - Temperature: -40000 to +125000 m°C (14-bit resolution)
+
+The device communicates with the I2C protocol and uses the I2C address 0x28
+by default.
+
+Depending on the hardware configuration, up to two humidity alarms to control
+minimum and maximum values are provided. Their thresholds and hystersis can be
+configured via sysfs.
+
+Thresholds and hysteris must be provided as a per cent mille. These values
+might be truncated to match the 14-bit device resolution (6.1 pcm/LSB)
+
+Known Issues
+------------
+
+The driver does not support I2C address and command window length modification.
+
+sysfs-Interface
+---------------
+
+The following list includes the sysfs attributes that the driver always provides,
+their permissions and a short description:
+
+=============================== ======= ========================================
+Name                            Perm    Description
+=============================== ======= ========================================
+temp1_input:                    RO      temperature input
+humidity1_input:                RO      humidity input
+=============================== ======= ========================================
+
+The following list includes the sysfs attributes that the driver may provide
+depending on the hardware configuration:
+
+=============================== ======= ========================================
+Name                            Perm    Description
+=============================== ======= ========================================
+humidity1_min:                  RW      humidity low limit. Measurements under
+                                        this limit trigger a humidity low alarm
+humidity1_max:                  RW      humidity high limit. Measurements above
+                                        this limit trigger a humidity high alarm
+humidity1_min_hyst:             RW      humidity low hystersis
+humidity1_max_hyst:             RW      humidity high hystersis
+humidity1_min_alarm:            RO      humidity low alarm indicator
+humidity1_max_alarm:            RO      humidity high alarm indicator
+=============================== ======= ========================================
Documentation/hwmon/index.rst +1 -0
index 72f4e6065bae..35f7573b4822 100644
@@ -51,6 +51,7 @@ Hardware Monitoring Kernel Drivers
    bel-pfe
    bpa-rs600
    bt1-pvt
+   chipcap2
    coretemp
    corsair-cpro
    corsair-psu
MAINTAINERS +8 -0
index 788be9ab5b73..88eec0adec49 100644
@@ -1086,6 +1086,14 @@ F:	Documentation/devicetree/bindings/perf/amlogic,g12-ddr-pmu.yaml
 F:	drivers/perf/amlogic/
 F:	include/soc/amlogic/
 
+AMPHENOL CHIPCAP 2 HUMIDITY-TEMPERATURE IIO DRIVER
+M:	Javier Carrasco <[email protected]>
+L:	[email protected]
+S:	Maintained
+F:	Documentation/devicetree/bindings/hwmon/amphenol,chipcap2.yaml
+F:	Documentation/hwmon/chipcap2.rst
+F:	drivers/hwmon/chipcap2.c
+
 AMPHION VPU CODEC V4L2 DRIVER
 M:	Ming Qian <[email protected]>
 M:	Zhou Peng <[email protected]>
drivers/hwmon/Kconfig +10 -0
index cf27523eed5a..11b133ef2384 100644
@@ -452,6 +452,16 @@ config SENSORS_BT1_PVT_ALARMS
 	  the data conversion will be periodically performed and the data will be
 	  saved in the internal driver cache.
 
+config SENSORS_CHIPCAP2
+	tristate "Amphenol ChipCap 2 relative humidity and temperature sensor"
+	depends on I2C
+	help
+	  Say yes here to build support for the Amphenol ChipCap 2
+	  relative humidity and temperature sensor.
+
+	  To compile this driver as a module, choose M here: the module
+	  will be called chipcap2.
+
 config SENSORS_CORSAIR_CPRO
 	tristate "Corsair Commander Pro controller"
 	depends on HID
drivers/hwmon/Makefile +1 -0
index e84bd9685b5c..daf0acef1482 100644
@@ -58,6 +58,7 @@ obj-$(CONFIG_SENSORS_ASPEED)	+= aspeed-pwm-tacho.o
 obj-$(CONFIG_SENSORS_ATXP1)	+= atxp1.o
 obj-$(CONFIG_SENSORS_AXI_FAN_CONTROL) += axi-fan-control.o
 obj-$(CONFIG_SENSORS_BT1_PVT)	+= bt1-pvt.o
+obj-$(CONFIG_SENSORS_CHIPCAP2) += chipcap2.o
 obj-$(CONFIG_SENSORS_CORETEMP)	+= coretemp.o
 obj-$(CONFIG_SENSORS_CORSAIR_CPRO) += corsair-cpro.o
 obj-$(CONFIG_SENSORS_CORSAIR_PSU) += corsair-psu.o
drivers/hwmon/chipcap2.c new file +1040 -0

1,040 lines not on this page · raw message

Signature · 1 line
2.39.2
#7 lore raw

drivers/hwmon/chipcap2.c line 328

Quoted 11 lines · Javier Carrasco
drivers/hwmon/chipcap2.c new file +11 -0
+       if (regulator_is_enabled(data->regulator)) {
+               ret = regulator_disable(data->regulator);
+               if (ret < 0)
+                       return ret;
+
+               msleep(CC2_POWER_CYCLE_MS); /* ensure a clean power cycle */
+       }
+
+       ret = regulator_enable(data->regulator);
+       if (ret < 0)
+               return ret;

This is very buggy. A consumer should only disable a regulator if it itself enabled that regulator (or it *requires* an exclusive regulator which isn't a good fit here), and there's no guarantee that disabling a regulator will actually result in a power off. Either the board might not physically or through constraints permit the state to change or another user may have enabled the regulator. The driver needs to keep track of if it enabled the regulator and only disable it as many times as it enabled it.

For this usage with trying to bounce the power of the regulator you can keep track of the actual power state of the supply by listening to notifications, and should possibly just keep the regulator disabled when it's not actively in use (if no alarm is active or measurement in progress?).

drivers/hwmon/chipcap2.c line 975

Quoted 1 line
drivers/hwmon/chipcap2.c new file +1 -0
+	data->regulator = devm_regulator_get_optional(dev, "vdd");

Does the device *really* work without power? The datasheet appears to suggest that the device has a non-optional supply Vdd

https://f.hubspotusercontent40.net/hubfs/9035299/Documents/AAS-916-127J-Telaire-ChipCap2-022118-web.pdf

(there's also a Vcore pin but that appears to be for connecting a decoupling capacitor rather than a supply).

In general _optional() should only be used for supplies which may be physically absent.

author maintainer
#8 lore raw
Quoted 14 lines · Mark Brown

drivers/hwmon/chipcap2.c line 328

Quoted 11 lines · Javier Carrasco
drivers/hwmon/chipcap2.c new file +11 -0
+       if (regulator_is_enabled(data->regulator)) {
+               ret = regulator_disable(data->regulator);
+               if (ret < 0)
+                       return ret;
+
+               msleep(CC2_POWER_CYCLE_MS); /* ensure a clean power cycle */
+       }
+
+       ret = regulator_enable(data->regulator);
+       if (ret < 0)
+               return ret;
Quoted 8 lines

This is very buggy. A consumer should only disable a regulator if it itself enabled that regulator (or it *requires* an exclusive regulator which isn't a good fit here), and there's no guarantee that disabling a regulator will actually result in a power off. Either the board might not physically or through constraints permit the state to change or another user may have enabled the regulator. The driver needs to keep track of if it enabled the regulator and only disable it as many times as it enabled it.

The idea is actually that if alarms are required, an exclusive regulator will be necessary to trigger power cycles and enter the command mode.

In summary there would be two options: either a regulator is defined and can be controlled to trigger the command mode or no regulator was defined for this device and therefore no command mode is available i.e. interrupts cannot be configured. That would be the case for example when the supply is always on.

Quoted 7 lines

For this usage with trying to bounce the power of the regulator you can keep track of the actual power state of the supply by listening to notifications, and should possibly just keep the regulator disabled when it's not actively in use (if no alarm is active or measurement in progress?).

Quoted 7 lines

drivers/hwmon/chipcap2.c line 975

Quoted 1 line
drivers/hwmon/chipcap2.c new file +1 -0
+	data->regulator = devm_regulator_get_optional(dev, "vdd");

Does the device *really* work without power? The datasheet appears to suggest that the device has a non-optional supply Vdd

   https://f.hubspotusercontent40.net/hubfs/9035299/Documents/AAS-916-127J-Telaire-ChipCap2-022118-web.pdf

The vdd is a non-optional supply and the device cannot run without it. What is optional is the controllable regulator to enter the command window. Hence why I used _optional() functions.

I could ban any use without a controllable regulator to make things simpler, but if no alarms are required, the device should work fine without command mode. Either way the driver must have some control over a regulator for the mentioned command window.

Quoted 5 lines

(there's also a Vcore pin but that appears to be for connecting a decoupling capacitor rather than a supply).

In general _optional() should only be used for supplies which may be physically absentIn the end I need a way to control a regulator to enter in command mode,

but still offering measurement functionality if there is no regulator to control.
The current approach is that there must be a supply, but the regulator might be controllable or not.

Thank you for your feedback and best regards,
Javier Carrasco

#9 lore raw
Quoted 11 lines · Javier Carrasco
Quoted 8 lines · Mark Brown

This is very buggy. A consumer should only disable a regulator if it itself enabled that regulator (or it *requires* an exclusive regulator which isn't a good fit here), and there's no guarantee that disabling a regulator will actually result in a power off. Either the board might not physically or through constraints permit the state to change or another user may have enabled the regulator. The driver needs to keep track of if it enabled the regulator and only disable it as many times as it enabled it.

Quoted 2 lines

The idea is actually that if alarms are required, an exclusive regulator will be necessary to trigger power cycles and enter the command mode.

There is a specific API for exclusive regulators which the driver is not using, and it's unconditionally doing the disable/enable cycle here.

Quoted 5 lines

In summary there would be two options: either a regulator is defined and can be controlled to trigger the command mode or no regulator was defined for this device and therefore no command mode is available i.e. interrupts cannot be configured. That would be the case for example when the supply is always on.

The driver needs to be explicitly configured for this and have separate code paths for normal operation and operation where the supply can be bounced like this. In neither code path should the supply be optional. Right now we don't have a mechanism for discovering optionally exclusive and enable/disablable supplies which is what the device needs, we could potentially add that since this does seem like a viable use case and we already have enough information in the DT to say if the supply matches the constraints. Probably the two properties queryable separately. If that API were added then the driver would do a normal regulator_get() then check if it has the capabilities it needs and either keep the supply on all the time (or possibly just during measurements?) or enable the alarm functionality.

author maintainer
#10 lore raw
Quoted 3 lines · Mark Brown

There is a specific API for exclusive regulators which the driver is not using, and it's unconditionally doing the disable/enable cycle here.

That is right, I will call regulator_get_exclusive() instead.

Quoted 4 lines

The driver needs to be explicitly configured for this and have separate code paths for normal operation and operation where the supply can be bounced like this. In neither code path should the supply be optional. Right now we don't have a mechanism for discovering optionally exclusive

Quoted 8 lines

and enable/disablable supplies which is what the device needs, we could potentially add that since this does seem like a viable use case and we already have enough information in the DT to say if the supply matches the constraints. Probably the two properties queryable separately. If that API were added then the driver would do a normal regulator_get() then check if it has the capabilities it needs and either keep the supply on all the time (or possibly just during measurements?) or enable the alarm functionality.

In that case I will split the driver development into two steps. First I will stick to the existing API and implement only the code path where an exclusive regulator is required i.e. not optional, which will simplify the review process considerably.

When the driver makes it through and all other issues are also solved, I will work on the optional exclusive regulator. This is probably an edge case and it will increase complexity to actually use half of the device capabilities to save the exclusive regulator, but at some point I would like to offer that as well.

Thank you again and best regards,
Javier Carrasco