Message ID | 20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com |
---|---|
Headers | show |
Series | hwmon: Add support for Amphenol ChipCap 2 | expand |
On Tue, Jan 30, 2024 at 10:06:45PM +0100, Javier Carrasco wrote: > 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. > > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Applied. Thanks, Guenter > --- > drivers/hwmon/hwmon.c | 2 ++ > include/linux/hwmon.h | 4 ++++ > 2 files changed, 6 insertions(+) > > diff --git a/drivers/hwmon/hwmon.c b/drivers/hwmon/hwmon.c > index c7dd3f5b2bd5..b51d13f08d27 100644 > --- a/drivers/hwmon/hwmon.c > +++ b/drivers/hwmon/hwmon.c > @@ -586,6 +586,8 @@ static const char * const hwmon_humidity_attr_templates[] = { > [hwmon_humidity_fault] = "humidity%d_fault", > [hwmon_humidity_rated_min] = "humidity%d_rated_min", > [hwmon_humidity_rated_max] = "humidity%d_rated_max", > + [hwmon_humidity_min_alarm] = "humidity%d_min_alarm", > + [hwmon_humidity_max_alarm] = "humidity%d_max_alarm", > }; > > static const char * const hwmon_fan_attr_templates[] = { > diff --git a/include/linux/hwmon.h b/include/linux/hwmon.h > index 8cd6a6b33593..f553f8cd6946 100644 > --- a/include/linux/hwmon.h > +++ b/include/linux/hwmon.h > @@ -293,6 +293,8 @@ enum hwmon_humidity_attributes { > hwmon_humidity_fault, > hwmon_humidity_rated_min, > hwmon_humidity_rated_max, > + hwmon_humidity_min_alarm, > + hwmon_humidity_max_alarm, > }; > > #define HWMON_H_ENABLE BIT(hwmon_humidity_enable) > @@ -306,6 +308,8 @@ enum hwmon_humidity_attributes { > #define HWMON_H_FAULT BIT(hwmon_humidity_fault) > #define HWMON_H_RATED_MIN BIT(hwmon_humidity_rated_min) > #define HWMON_H_RATED_MAX BIT(hwmon_humidity_rated_max) > +#define HWMON_H_MIN_ALARM BIT(hwmon_humidity_min_alarm) > +#define HWMON_H_MAX_ALARM BIT(hwmon_humidity_max_alarm) > > enum hwmon_fan_attributes { > hwmon_fan_enable,
On Tue, Jan 30, 2024 at 10:06:46PM +0100, Javier Carrasco wrote: > This attributes have been recently introduced and require the > corresponding ABI documentation. > > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Applied. Thanks, Guenter
On Tue, Jan 30, 2024 at 10:06:48PM +0100, Javier Carrasco wrote: > 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 includes the following part numbers: > - non-sleep measurement mode (CC2D23, CC2D25, CC2D33, CC2D35) > - sleep measurement mode (CC2D23S, CC2D25S, CC2D33S, CC2D35S) > > 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. A dedicated, external regulator is required for that. > > This driver keeps the device off until a measurement or access to the > EEPROM is required, making use of the first automatic measurement to > avoid different code paths for sleep and non-sleep devices. > > The minimum and maximum humidity alarms are configured with two > registers per alarm: one stores the alarm threshold and the other one > keeps the value that turns off the alarm. The alarm signals are only > updated when a measurement is carried out. > > Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> Applied. Thanks, Guenter
This series adds support and documentation for the Amphenol ChipCap 2 humidity and temperature sensor in its digital version. The Chipcap 2 is an I2C device that 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 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 connected to a Raspberry Pi Zero 2 w. Different device tree node definitions (with and without ready and/or alarm signals) have been positively tested. Signed-off-by: Javier Carrasco <javier.carrasco.cruz@gmail.com> --- Changes in v6: - chipcap2.c: remove TODO about regulator delays (handled by the regulator core). - chipcap2.c: add comment to clarify regularor enable checks (exclusive regulator). - chipcap2.c: simplify irq handling (irqs disabled while the device is switched off). - Link to v5: https://lore.kernel.org/r/20240115-topic-chipcap2-v5-0-0cc7a15aeece@gmail.com Changes in v5: - dt-bindings: add "amphenol,cc2d23" to "compatible" in the example. - Link to v4: https://lore.kernel.org/r/20231020-topic-chipcap2-v4-0-7940cfa7613a@gmail.com Changes in v4: - chipcap2.c: require exclusive regulator to trigger command mode. - chipcap2.c: keep the device off until a measurement is required. Because the device makes an automatic measurement after the power-up sequence, no differentiation between sleep and non-sleep modes is required anymore. - chipcap2.c: retrieve alarm settings from the device instead of storing them locally. - dt-bindings: add vdd-supply to required properties. - dt-bindings: default to 'amphenol,cc2d23' compatible (same functionality for all compatibles). - Link to v3: https://lore.kernel.org/r/20231020-topic-chipcap2-v3-0-5b3bb50a5f0b@gmail.com 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/20231020-topic-chipcap2-v2-0-f5c325966fdb@gmail.com 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/20231020-topic-chipcap2-v1-0-087e21d4b1ed@gmail.com --- 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 | 77 ++ .../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 | 816 +++++++++++++++++++++ drivers/hwmon/hwmon.c | 2 + include/linux/hwmon.h | 4 + 11 files changed, 1012 insertions(+) --- base-commit: 6613476e225e090cc9aad49be7fa504e290dd33d change-id: 20231020-topic-chipcap2-e2d8985430c2 Best regards,