From patchwork Tue Jan 30 21:06:44 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13538069 Received: from mail-lf1-f43.google.com (mail-lf1-f43.google.com [209.85.167.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 313F371B52; Tue, 30 Jan 2024 21:06:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648815; cv=none; b=TefC9DVorK4kmLfipRXNE48n8St2b/IxXWkd4IFseS6l0Sm3cQb5CFCUisZArSrGlLbOVKtefhCE/3od8nvZP1JDobqjgLdMCyONsMcGlQSzJAGLd8Hn8wouCgCi0eyyFzZn4LYX9xes4biUUH09XV996tlNZeZKBiQFLCGqkt8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648815; c=relaxed/simple; bh=pBakjDF9u3VEIbwvo6t1HrfC65+zkN2H7ZEX/eg+pv8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VA7XggSynqja3l/h5OH/kpuX9zw+dSVZ2Ex5wWHJcnyMUwvJRd/F02NscMoGwma7dMR8/0gFcuUCIGKPDHBRsZhax7+E8bUCWHmoBC5o2md04d9LdPwN7i8GnHkQDMCIE3H/4o6IU2PY6KCdJpPkxF28SZD1R8+DX/nOkoIJC2E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=aUrGF28o; arc=none smtp.client-ip=209.85.167.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="aUrGF28o" Received: by mail-lf1-f43.google.com with SMTP id 2adb3069b0e04-51120e285f6so783379e87.2; Tue, 30 Jan 2024 13:06:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706648811; x=1707253611; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=ISMBkNudHXdkcESLM4GR2mZ6tTZ9A6XlLdPhEHw2Btg=; b=aUrGF28oXYzP0Ll403cDEHt6MsE9NLZjnDyq2kBuSTmUk1wmleldAt92hg6+830+Zo CpAHKv0Inp4p7WK4oDvfrS8x4A1JfIpQABJyeyzeqpk8f3J85lekrYSDTkUQZcE3sjlg rMVEqRLCgE8rlQGiZ33/i/YwrkzYKTNPtwEYLiKWlGJzwFs+wZrGgW2KwOAT+rzCO6iN aiZOATDeNEQRCI1kDnPDZD/aX/HOKBFfEF/eJCaWX6Gw1J3drbgPFYBnXK9AZAx9EGDU t4JswR3xkosRi3FC0HOtpgYfxSsZXzxso9ats0VJq3S/9FCAat35EkLc3yZ67Zx5qpA5 QqqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706648811; x=1707253611; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ISMBkNudHXdkcESLM4GR2mZ6tTZ9A6XlLdPhEHw2Btg=; b=MmvF7X/ki4iSyjAUT68IW+HWgCvC8bmRNm0WiOS2QFw/ywJpe7ZXSw0dm6lI2wNZL0 dHQA84aAjLWydIJ7ApdfNM+7P5R/u/rUAqeaj/K3S8NmArRVvETD3Qg6DTbcnO8xXrrZ U/3pE+IWDbwoSx/FYTo5fsLCDdUVLaflX5Wckqw+VrMKHG8GiNk63jJVbyhLyNG9mFL/ D86vcGX6Jo3pu4duePcF0CdH+txhhOU24bcHQBPSiiOpI8tbafSq8fRMsk0KQI7VPmL6 X8GEokHeyR98a6jzK0K1EEyRZRgdnbrY7fTVKY04rLZ86sBOI977ziAN+bjHqA7bi+LG GmUw== X-Gm-Message-State: AOJu0YyoQ+03NTrZTC5jF8MUKDG3TSecdKSB4L9KQTh+JIJ4N2ifA2t+ 80sw+2vZKqWQ0YfpmZj6vrJVZ77L2mBV1GqqQn4f7Hr9TwxfFwtJ X-Google-Smtp-Source: AGHT+IERyYODG8+xDHQhK/Z7O01m7wJQFeW0i+O6jhWPmY5zjhUbKTuT7gxkEBspp5cJ9eoU59eGiQ== X-Received: by 2002:a19:5513:0:b0:511:21e4:5a69 with SMTP id n19-20020a195513000000b0051121e45a69mr413103lfe.40.1706648810964; Tue, 30 Jan 2024 13:06:50 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-7400-ff68-7ab4-4169.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:7400:ff68:7ab4:4169]) by smtp.gmail.com with ESMTPSA id vv9-20020a170907a68900b00a354a5d2c39sm4177658ejc.31.2024.01.30.13.06.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:06:50 -0800 (PST) From: Javier Carrasco Date: Tue, 30 Jan 2024 22:06:44 +0100 Subject: [PATCH v6 1/5] dt-bindings: vendor-prefixes: add Amphenol Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240130-topic-chipcap2-v6-1-260bea05cf9b@gmail.com> References: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> In-Reply-To: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jean Delvare , Guenter Roeck , Jonathan Corbet , Liam Girdwood , Mark Brown Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, Javier Carrasco , Krzysztof Kozlowski X-Mailer: b4 0.13-dev-0434a X-Developer-Signature: v=1; a=ed25519-sha256; t=1706648808; l=874; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=pBakjDF9u3VEIbwvo6t1HrfC65+zkN2H7ZEX/eg+pv8=; b=6ABM6vQxe9xrfSPvtPn+CADP1c75AP2WG5SR0O6NH6rBb/7vKG2Ea/7RRNtsTOF1mJdBaNxuH EcGm7Pebi8WBb4+1IcikBcJxsCidBv9HuVzw7MgZUdNU9dC7TUu8kS6 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= Add vendor prefix for Amphenol (https://www.amphenol-sensors.com) Acked-by: Krzysztof Kozlowski Signed-off-by: Javier Carrasco --- Documentation/devicetree/bindings/vendor-prefixes.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/vendor-prefixes.yaml b/Documentation/devicetree/bindings/vendor-prefixes.yaml index 1a0dc04f1db4..25158559471c 100644 --- a/Documentation/devicetree/bindings/vendor-prefixes.yaml +++ b/Documentation/devicetree/bindings/vendor-prefixes.yaml @@ -107,6 +107,8 @@ patternProperties: description: Amlogic, Inc. "^ampere,.*": description: Ampere Computing LLC + "^amphenol,.*": + description: Amphenol Advanced Sensors "^ampire,.*": description: Ampire Co., Ltd. "^ams,.*": From patchwork Tue Jan 30 21:06:45 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13538070 Received: from mail-ej1-f52.google.com (mail-ej1-f52.google.com [209.85.218.52]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 98EBA762DD; Tue, 30 Jan 2024 21:06:54 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.52 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648816; cv=none; b=Bh3uZIiI0rkCCgoVRrDzMzB+q+V09rbuhDgyskfbd/E0ilSkbp5fGLyT8+QhPvvBxNjeK4lKessL7CX6Mln/hi+8O2xUPRMXKK0rd2QI/Ce8EVPVdYAibjHd1usYJghiJEFibk08Gy1+mrTvQKQhrXbZNUXIdkcJxonHs/aqgeA= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648816; c=relaxed/simple; bh=uLF/Qmue1+Wzk3XhIihfzQTCEXmbPTvk9jP+cW/SKMg=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MxMUlQZiefJw0TQP2iWcgTzQnNg4yzUmATM53Hq3pzf4kuZmYlY0QbIagh4PYRak2YrEdaXpgmjAMLNoGTlFH7Zq6zY7CrYD/sLOyMDtiv2/7SgC2b9+c1e8CGMNVJPcXKTr5fpnOIrAWneaoBlvPXRUzswkV9G3MJyVz9kd1HQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=MYeLN6qN; arc=none smtp.client-ip=209.85.218.52 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="MYeLN6qN" Received: by mail-ej1-f52.google.com with SMTP id a640c23a62f3a-a34c5ca2537so499045566b.0; Tue, 30 Jan 2024 13:06:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706648813; x=1707253613; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=IQtvJUU+OqNUf9TfCmUtoX2TLTtaGeLRFukm+fQ1w2U=; b=MYeLN6qNjVVNybaJRV9FGYXqcsbFl/yr0Xz3BVO6n4UbecLHUpYtUn9/c4JDpjBVkk EjDTfZh9E0a2pvI/IBK3Fg9pX2aeUuieHVqHZa86RbC6Xs1QQqLr5cCaZl9S5LRB0dO9 z0MntVlI3oBxp6eVUdCqOC2MhdwYHeNupbZir/Yo/oWNxbLMrMkb2DJhHKK0DW9Ojqq0 OvXBOk0CQO2ztSiGO3Hn28bjWjbr2JrPaWuJI8NDwfbIUlSlfdqOUrjfd+d0zvCPj7Vt rThhsWL3x48uyNProxlNl1CwjFqPmMB2BVrWY63GPpUA8N4eOMtvhRV6X/P3aPwdbEh/ K5MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706648813; x=1707253613; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=IQtvJUU+OqNUf9TfCmUtoX2TLTtaGeLRFukm+fQ1w2U=; b=F3dwt5kIxl3SZdugev3FoOUgyWb5QJJ/Zjpam5S7Y37tRXgbrk59+I5UMKn67BksGt IdFOmU2IP2J2wcrb4y88UloJRrzSZ8fsbMfB6ZfF5P8bNoheg2NfQYe0FP8TbSLB/K+X 08FO1Exh1Ycscga5uYEMh5xT5+yqTDyFKTUckrEeJY0oJSxrJgBDPuTZcOqejCfICyVW alzxrYgNuaxJRAiTjIyjZKIhS1c5OgzouynfCV4zSLwTIe67k8oFUUtRfkXRO5TaGlWw JzSBsy/pPczmJySWYXyIIH4yOIrfgtzGKOfm9B6050P1M6l0UU5EY1mYchstTZPLYy8Q ZFvQ== X-Gm-Message-State: AOJu0YxLST6uR1jEhOuZbwmi4RT2vIO45vBgAkoXI0SSry4RrIhz9lXa o4N8+J3QYmtpRmJrU8rPUrMGiNpfEUHclQ8ilWQyuQZzmEIm3zql X-Google-Smtp-Source: AGHT+IE7jIrmgeOq4vCSI0+9AQSg9oLjTu6kevG43kjrQUqhj1DyGkMA7jqRnBAGjEF9+kaQM9OzeA== X-Received: by 2002:a17:906:1703:b0:a28:2165:7c74 with SMTP id c3-20020a170906170300b00a2821657c74mr6714400eje.13.1706648812450; Tue, 30 Jan 2024 13:06:52 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-7400-ff68-7ab4-4169.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:7400:ff68:7ab4:4169]) by smtp.gmail.com with ESMTPSA id vv9-20020a170907a68900b00a354a5d2c39sm4177658ejc.31.2024.01.30.13.06.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:06:52 -0800 (PST) From: Javier Carrasco Date: Tue, 30 Jan 2024 22:06:45 +0100 Subject: [PATCH v6 2/5] hwmon: (core) Add support for humidity min/max alarm Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240130-topic-chipcap2-v6-2-260bea05cf9b@gmail.com> References: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> In-Reply-To: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jean Delvare , Guenter Roeck , Jonathan Corbet , Liam Girdwood , Mark Brown Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.13-dev-0434a X-Developer-Signature: v=1; a=ed25519-sha256; t=1706648808; l=1810; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=uLF/Qmue1+Wzk3XhIihfzQTCEXmbPTvk9jP+cW/SKMg=; b=Rw6EQWW4CWmGJ3m9Vp1Pt2qAtCMUx4XzR/QlV8oumy6at0oar4qK3QBRzng+inKt/Z1oYG3ID VYxEk5A8TEQDCtZQdVQnSHcvwqidbJiqEa6tbENi5lPscRlVarkpvwv X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= 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 --- 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, From patchwork Tue Jan 30 21:06:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13538071 Received: from mail-ed1-f44.google.com (mail-ed1-f44.google.com [209.85.208.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D17D078B4C; Tue, 30 Jan 2024 21:06:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.44 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648817; cv=none; b=aqJaSm6brfJFvqpMX5TEfR/BtpQ1LzDU+FjplUscYds5jZEtTzMsn9tCEpnjasRwrTNtVjbtZzRCU0qmyTi5aMP204JPBCpM3/5/tKSDMNCxmVM8WdZ2EH1sx69FSwrP6UYP97xdcyLVffth16GqzLpOh4rc9fXDy+dzwjZW1UM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648817; c=relaxed/simple; bh=o3nT/glgE9OrStOuUiwSZUfHVTS4KfV9GDtahhSGb3M=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=MCoD8l5HOHzgnkyakMj0SPke5Hf+iqCYvFSjGjWOtv/f6LzUDcQ3+B6Ijl1ReZ2PPhNXvp2pRKXB3Fb/JETcfsZKKoyLYPErkIQIrPcfenrQ3KmyZM1k7mC+8AN9/patQCVai5sGHkn3LOt5Qg6yy/VntANn7mxUoEoW7AodWTQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TYvzlZeU; arc=none smtp.client-ip=209.85.208.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TYvzlZeU" Received: by mail-ed1-f44.google.com with SMTP id 4fb4d7f45d1cf-55c33773c0aso4690350a12.1; Tue, 30 Jan 2024 13:06:55 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706648814; x=1707253614; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=qOeyQrTpUXsRQpxgsiXlfqixsQT8OxPjhvcSfqQoa6Y=; b=TYvzlZeU6byz3MILGl6PsjKlUobWM6oRGsg4uCZVU3i3VJOmd3CRqYKlTJqHfBF6xD IVGvu0pwpJgg0EWW0/j379Bz99DSdF1hmiGyfcvisezv+apFXPcEb8UtV7gM6H4OjT2L dV0/NaO4Kleas+8+z/qzwDnR2IOCe//QUJgz8trbI72Wdc3pEE4I7ismtqrm8+bvYFZE UkWO9w0ZskP5HnCA75o9CUqc3xg2okL9nKz32y6yl4XwhIFKO7O+wUCoJH7sRNNt5GrS H1QWSVabSezUrtaenQ9eUqUz996cC55ItQ5soYcRDk+H1fmJLf4rIyC5Hfse+zC656tT 9jqA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706648814; x=1707253614; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qOeyQrTpUXsRQpxgsiXlfqixsQT8OxPjhvcSfqQoa6Y=; b=czutG/NjE5XgZOYTMdKeC+FF+WwPoQIECH0dP/XGj8YPEGRrijKR5YJwaIaUJWVjBk HEOgEYO84IC+zRv5vHtQddhHlo4pp9kusiIor+Bf+xiK9Vru0d3bZe0xidoVv4x4zBfe ixeaCqcElcC2ll8zEAyEv6SNkf2k175lueEcf6gZ1AzLa7PDZv7g6pV/AywMusmNhVv5 MSFYY7693rWiZ/mdhxJYPHCwgXfWqVzn8Di0cShg6ZVxS5V80QCCtej4MUlOO4af8dlK qxLzDc/KFZtfBd+isK9dRAlush/g/DfPbHUJYLyvn6HyExkn6KuSiwrfwg3rbXLTaEf/ YCWw== X-Gm-Message-State: AOJu0YzNMsx+3DsSt9MYI1Xcj1wG0ldYQ/q60lg/HkB7RtZ1mRpzYceo 8RtYnGpNHCWYNY2ssAn4Sg2MeNTnpI2QYUIU0TyRMdg0SoJhNVJl X-Google-Smtp-Source: AGHT+IHtgaSfofm4Uz1ULKZyzmTNLRaRTlatfudObUCDNuBU0Kvdb1Kl8VbkLY4gy6MlTmbc2g1Eyg== X-Received: by 2002:a17:906:c78d:b0:a28:f8d2:7897 with SMTP id cw13-20020a170906c78d00b00a28f8d27897mr357989ejb.20.1706648813935; Tue, 30 Jan 2024 13:06:53 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-7400-ff68-7ab4-4169.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:7400:ff68:7ab4:4169]) by smtp.gmail.com with ESMTPSA id vv9-20020a170907a68900b00a354a5d2c39sm4177658ejc.31.2024.01.30.13.06.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:06:53 -0800 (PST) From: Javier Carrasco Date: Tue, 30 Jan 2024 22:06:46 +0100 Subject: [PATCH v6 3/5] ABI: sysfs-class-hwmon: add descriptions for humidity min/max alarms Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240130-topic-chipcap2-v6-3-260bea05cf9b@gmail.com> References: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> In-Reply-To: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jean Delvare , Guenter Roeck , Jonathan Corbet , Liam Girdwood , Mark Brown Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.13-dev-0434a X-Developer-Signature: v=1; a=ed25519-sha256; t=1706648808; l=1182; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=o3nT/glgE9OrStOuUiwSZUfHVTS4KfV9GDtahhSGb3M=; b=NQPUHdmz8bnHf+lrgBvR0GnjgcuD+5TTJ15c126eMhap9gv3WNm/8AxPnZdD6xbimgixQabfv ZJ2OboeSoDLAEVeujJOlHmlc1oO/pgWXM9/phnye3ULjMV2a4UW2CZI X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= This attributes have been recently introduced and require the corresponding ABI documentation. Signed-off-by: Javier Carrasco --- Documentation/ABI/testing/sysfs-class-hwmon | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-class-hwmon b/Documentation/ABI/testing/sysfs-class-hwmon index 3dac923c9b0e..8446e95f23b1 100644 --- a/Documentation/ABI/testing/sysfs-class-hwmon +++ b/Documentation/ABI/testing/sysfs-class-hwmon @@ -968,6 +968,15 @@ Description: RW +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_max_hyst Description: Humidity hysteresis value for max limit. @@ -987,6 +996,15 @@ 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_min_hyst Description: Humidity hysteresis value for min limit. From patchwork Tue Jan 30 21:06:47 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13538072 Received: from mail-ej1-f54.google.com (mail-ej1-f54.google.com [209.85.218.54]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6A690762F4; Tue, 30 Jan 2024 21:06:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.54 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648819; cv=none; b=fnWUKV7Yoep6FeLlHf2nmOekEIrx67RZzAujBn5m5SatbNqSrNgADj+9+8LoHflrvuIQ45D+cCTTwSnpDhxl3OtA2RMejYfnipLKruf2D8AsY5KupFHHtPRy4lqb0i4QwvIkZjJNbNWqHC5cb9G60fXUQcH6pvQBwNe8B12H0ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648819; c=relaxed/simple; bh=fNJt6Q/D/Alnf1fohB1Z7SdgiB8iUvgMdRCGPeqchec=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=pLycXFvjOAgRJXl4YSz2I9aqcmr535hWdcV33kkKNZDwXXfD3F977qjobSlSX+hRPg8ZdQTNKgtjZSfx+qIi6bzwjL47C5uTRXrofELSoE1DM7iH0GBMBy0OlDRz3eog54IsbexZUWHQoid/yjsbeOf7C1eFr+wdmhfCWq8LY9U= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=TqfX1oFA; arc=none smtp.client-ip=209.85.218.54 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="TqfX1oFA" Received: by mail-ej1-f54.google.com with SMTP id a640c23a62f3a-a35e9161b8cso309430666b.3; Tue, 30 Jan 2024 13:06:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706648815; x=1707253615; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=CLDQhSu6kRqZGxiyHOr+RblF6k83oiX6rLk/meipQMA=; b=TqfX1oFA6owraA4egYBHaJsxAyo7ngxiou7GiBswvpkxHcn4sgAxQpLPoUiMRFHpkp Hicm+hTkzWLMNMkjNZCxrOYoz5adgJXJhGXfO2Mb5J2vCMq17O0ZqRJIiiktuXT4C42n tpo8/hxZCU3lhkxIz1XEbIeov8M0iO6q4G0FWaXTj0iJWVOPQfNKYXDh74VdxFXrlJy3 k0tR6fnGKxnA95PL8d6BUfXFZeSjAdytaywA2hkjP0+SDTcPk1cerGIW48UUIYtnVfbC nQsMz8JGqN1SAIy5ig7Jozxa8FLMhloLrtNSBhslXijcOsj67seMB1IPOJEtRfYu4qnG aJvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706648815; x=1707253615; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=CLDQhSu6kRqZGxiyHOr+RblF6k83oiX6rLk/meipQMA=; b=YAqD+DPufPFuYlOcT0c1X7Gt/0q7mj3nyl0gNgUr5kHA2D0iytlStrTJ59/MRq0cCK J3fXtkMLEK5e2MwjfgzLBP8qV8YB5PMjNFXmW8UN/KuKDvQE/EM+yeY/6/2MJLHUuMEU 5Ci0FpFebuIrdbo3EXAVY/Au0VP8JnVUWN2j3Iua8y1JnaWi87GMkGv/DnsPs+6UIh7x vfJzAbECFSMifqvYNm7tGr0A5XKNgfKI+5JeYrZizFiHnKREq3ioiFwZnpgSak832rx/ gyUckIy2/4NCs284kI6vgBtjFFmahriyUx7ydPk5EF9le+TYfBE4bNGgbdrJqlRCeyvs gPQQ== X-Gm-Message-State: AOJu0Yzju1DY8BVv+kQ88++E1ygqkM6mQghj6r8egW8MaLT74R33wCTA waYCC+hFXdQTcMdoYTFBNfxgVTnwG5yEvZBz+Jahy4mDces+ffRC X-Google-Smtp-Source: AGHT+IGk6r9KlNzje7atnk4nKVE+RhaI2llH4SByjhzfH3V9RToNtOYhP4sic9HHF0riJEA1uADvBw== X-Received: by 2002:a17:906:26d6:b0:a36:239:77a with SMTP id u22-20020a17090626d600b00a360239077amr2770503ejc.23.1706648815369; Tue, 30 Jan 2024 13:06:55 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-7400-ff68-7ab4-4169.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:7400:ff68:7ab4:4169]) by smtp.gmail.com with ESMTPSA id vv9-20020a170907a68900b00a354a5d2c39sm4177658ejc.31.2024.01.30.13.06.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:06:55 -0800 (PST) From: Javier Carrasco Date: Tue, 30 Jan 2024 22:06:47 +0100 Subject: [PATCH v6 4/5] dt-bindings: hwmon: Add Amphenol ChipCap 2 Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240130-topic-chipcap2-v6-4-260bea05cf9b@gmail.com> References: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> In-Reply-To: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jean Delvare , Guenter Roeck , Jonathan Corbet , Liam Girdwood , Mark Brown Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, Javier Carrasco , Conor Dooley X-Mailer: b4 0.13-dev-0434a X-Developer-Signature: v=1; a=ed25519-sha256; t=1706648808; l=2700; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=fNJt6Q/D/Alnf1fohB1Z7SdgiB8iUvgMdRCGPeqchec=; b=MAPNCwHqUhbiKclSBeuhCBTF8oR3TzEGbpJ7+X1TyFsGcwyuTBxjXe4VbItX8JQ0V0h6G9rQy xD+aGaGSlUsDi1NnuBkFF7V8fByqizgn52ePwweamWNiH29+NEvukzA X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= Add device tree bindings and an example for the ChipCap 2 humidity and temperature sensor. Reviewed-by: Conor Dooley Signed-off-by: Javier Carrasco --- .../bindings/hwmon/amphenol,chipcap2.yaml | 77 ++++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/amphenol,chipcap2.yaml b/Documentation/devicetree/bindings/hwmon/amphenol,chipcap2.yaml new file mode 100644 index 000000000000..17351fdbefce --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/amphenol,chipcap2.yaml @@ -0,0 +1,77 @@ +# 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 + +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: + oneOf: + - const: amphenol,cc2d23 + - items: + - enum: + - amphenol,cc2d23s + - amphenol,cc2d25 + - amphenol,cc2d25s + - amphenol,cc2d33 + - amphenol,cc2d33s + - amphenol,cc2d35 + - amphenol,cc2d35s + - const: amphenol,cc2d23 + + 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. + +required: + - compatible + - reg + - vdd-supply + +additionalProperties: false + +examples: + - | + #include + i2c { + #address-cells = <1>; + #size-cells = <0>; + + humidity@28 { + compatible = "amphenol,cc2d23s", "amphenol,cc2d23"; + 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 = <®_vdd>; + }; + }; From patchwork Tue Jan 30 21:06:48 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Javier Carrasco X-Patchwork-Id: 13538073 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EB9587AE63; Tue, 30 Jan 2024 21:06:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648821; cv=none; b=Zeu5rEuYd7vak/QwzlX9fYiKu6eHVqFgZ0Zq98UJ4B1VU79NyN8cISnhSpsN1Lp1k4DdwhNZKVwhzQYPsMnOl4nYW1V1ctUvzbIW7334A6zq03o4/MVO5dp3AoyuTB7lZU13QKlcSHjzaojK3V0wWtVa4f4aLOC0W4Lx+5VPso4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706648821; c=relaxed/simple; bh=+VoUQzlE3WS6+hzCS2DHp1tirunKoDbBVPpGcYyRzTM=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=VHOpCQ1FWybD5O/tMxu6qBQMHCbvjF5D9Qj+W5nCOyqzTgfuKqaNl20X7jSusq7Unfvs4OB2dLHr74FVZ8jDEL+Chg8SBG5N0fuBWiGHIFpqpKg8B1rxTiW9E/yNHsMYezx6crEtD0FrJUg++VOR0QKKqxbQJbwqiljoNZfyfCM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BDcdrutW; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BDcdrutW" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a271a28aeb4so556433066b.2; Tue, 30 Jan 2024 13:06:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706648817; x=1707253617; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=2exZDG0g5Ieet+FmJl3JavYfviKzDHvPPGfR5ChVTVA=; b=BDcdrutWYt+QsfP+wVqhauwNftUHK7JBhA0SIc1hcw9fgp/yWrueyXQmQXQ0lwnX4i 3sP6Jo+06Kw8cFrWhnUaWYgHQ6NBMTZLeNVoUDYPad8p1hxszUk2SeYBT8WehqTXmUSb +BJmXg1dpqxFpC4+c8yroU+UXl8dvOJIdCsLa0RGaAO9RIG9Y1gybQlIvq0Y6TVqbLw6 vWYo7ORFYfoufGFTkmJ7vqg8qv469CTnBQNvmKvpMaV1z5BT6cXKcPRATfNxVDb3geC2 4AJKgiuDv1zCd5UMgNCx5J8cdmXyGZb+nTveh+JkgS0yvfWEiS1Gk6Oa1WQJpakbTA6k CYgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706648817; x=1707253617; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2exZDG0g5Ieet+FmJl3JavYfviKzDHvPPGfR5ChVTVA=; b=s58dcm4+tMnRCksXKZiNQEzEJ/qMi79cle10PMuE5dn2jOVXLuDbpP8Zdd40WqB0GE 2BX7eFk0ZPZ//j8ZcdtP/56CsO0JB/s7XMsuvuAmTuwZ8G9uVQtM/YR/iORDyVm0m8kO NvTbGUdMxvNzilzsFYrdXogiAE5jhRoEqgrlSve7cIB7DBBmJdyiydOmF77xPjfeiRmZ 4uuOj1k/IXZBPRmprcAfA9INRrIEGcIKyQ0TpInsWlFXQk+jqH57pvJ/kNhUepaUTKeZ 1BYMYc4r7gFZXLg4SHccKOuWwx0kPA/8W32LJRyM58JlQF78xrufQKBYztDHBsI0ZDsW 4SKg== X-Gm-Message-State: AOJu0YxFka4RS5DAo5XEoPgmpAUEz3O1ifrJJX6Mt53YkhvX7SaWaFIY EzjwPBxUs4nuXukgpJ2qB+FTnhsrQ/e86LzrfwFLQrXwoOeJVze2 X-Google-Smtp-Source: AGHT+IFR6uBLuVVyzMUpsP0g8sPnVmHMPJNcrP1wlQKL1M1Y6maHFx0qb08DI1FG3PqYQX/hqltofQ== X-Received: by 2002:a17:906:b2d0:b0:a35:e524:c9a1 with SMTP id cf16-20020a170906b2d000b00a35e524c9a1mr3757956ejb.14.1706648816895; Tue, 30 Jan 2024 13:06:56 -0800 (PST) Received: from [127.0.1.1] (2a02-8389-41cf-e200-7400-ff68-7ab4-4169.cable.dynamic.v6.surfer.at. [2a02:8389:41cf:e200:7400:ff68:7ab4:4169]) by smtp.gmail.com with ESMTPSA id vv9-20020a170907a68900b00a354a5d2c39sm4177658ejc.31.2024.01.30.13.06.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Jan 2024 13:06:56 -0800 (PST) From: Javier Carrasco Date: Tue, 30 Jan 2024 22:06:48 +0100 Subject: [PATCH v6 5/5] hwmon: Add support for Amphenol ChipCap 2 Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-Id: <20240130-topic-chipcap2-v6-5-260bea05cf9b@gmail.com> References: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> In-Reply-To: <20240130-topic-chipcap2-v6-0-260bea05cf9b@gmail.com> To: Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jean Delvare , Guenter Roeck , Jonathan Corbet , Liam Girdwood , Mark Brown Cc: Rob Herring , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org, Javier Carrasco X-Mailer: b4 0.13-dev-0434a X-Developer-Signature: v=1; a=ed25519-sha256; t=1706648808; l=28260; i=javier.carrasco.cruz@gmail.com; s=20230509; h=from:subject:message-id; bh=+VoUQzlE3WS6+hzCS2DHp1tirunKoDbBVPpGcYyRzTM=; b=8Vvh6j9nYWNFCZ5hh4onfyLRWzvVm5PxOPCkmz7EJcxHz/keDSpT/E96/YWpQ771JtEpVvRmP kTW8ebICAvuDl0NDb46rm1yzXSPNi+KPIbsevMQB9cbYvTaVfSNmsE8 X-Developer-Key: i=javier.carrasco.cruz@gmail.com; a=ed25519; pk=tIGJV7M+tCizagNijF0eGMBGcOsPD+0cWGfKjl4h6K8= 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 --- 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 +++++++++++++++++++++++++++++++++++++++ 6 files changed, 909 insertions(+) diff --git a/Documentation/hwmon/chipcap2.rst b/Documentation/hwmon/chipcap2.rst new file mode 100644 index 000000000000..dc165becc64c --- /dev/null +++ b/Documentation/hwmon/chipcap2.rst @@ -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 + +Description +----------- + +This driver implements support for the Amphenol ChipCap 2, a humidity and +temperature chip 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 +=============================== ======= ======================================== diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index c7ed1f73ac06..99ba35f47868 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -51,6 +51,7 @@ Hardware Monitoring Kernel Drivers bel-pfe bpa-rs600 bt1-pvt + chipcap2 coretemp corsair-cpro corsair-psu diff --git a/MAINTAINERS b/MAINTAINERS index 8d1052fa6a69..e70231735f71 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1098,6 +1098,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 +L: linux-hwmon@vger.kernel.org +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 M: Zhou Peng diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index a608264da87d..cb38f30411f7 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -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 diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 47be39af5c03..1ea4f42630fb 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -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 diff --git a/drivers/hwmon/chipcap2.c b/drivers/hwmon/chipcap2.c new file mode 100644 index 000000000000..a62c507b1042 --- /dev/null +++ b/drivers/hwmon/chipcap2.c @@ -0,0 +1,816 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * cc2.c - Support for the Amphenol ChipCap 2 relative humidity, temperature sensor + * + * Part numbers supported: + * CC2D23, CC2D23S, CC2D25, CC2D25S, CC2D33, CC2D33S, CC2D35, CC2D35S + * + * Author: Javier Carrasco + * + * Datasheet and application notes: + * https://www.amphenol-sensors.com/en/telaire/humidity/527-humidity-sensors/3095-chipcap-2 + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define CC2_START_CM 0xA0 +#define CC2_START_NOM 0x80 +#define CC2_R_ALARM_H_ON 0x18 +#define CC2_R_ALARM_H_OFF 0x19 +#define CC2_R_ALARM_L_ON 0x1A +#define CC2_R_ALARM_L_OFF 0x1B +#define CC2_RW_OFFSET 0x40 +#define CC2_W_ALARM_H_ON (CC2_R_ALARM_H_ON + CC2_RW_OFFSET) +#define CC2_W_ALARM_H_OFF (CC2_R_ALARM_H_OFF + CC2_RW_OFFSET) +#define CC2_W_ALARM_L_ON (CC2_R_ALARM_L_ON + CC2_RW_OFFSET) +#define CC2_W_ALARM_L_OFF (CC2_R_ALARM_L_OFF + CC2_RW_OFFSET) + +#define CC2_STATUS_FIELD GENMASK(7, 6) +#define CC2_STATUS_VALID_DATA 0x00 +#define CC2_STATUS_STALE_DATA 0x01 +#define CC2_STATUS_CMD_MODE 0x02 + +#define CC2_RESPONSE_FIELD GENMASK(1, 0) +#define CC2_RESPONSE_BUSY 0x00 +#define CC2_RESPONSE_ACK 0x01 +#define CC2_RESPONSE_NACK 0x02 + +#define CC2_ERR_CORR_EEPROM BIT(2) +#define CC2_ERR_UNCORR_EEPROM BIT(3) +#define CC2_ERR_RAM_PARITY BIT(4) +#define CC2_ERR_CONFIG_LOAD BIT(5) + +#define CC2_EEPROM_SIZE 10 +#define CC2_EEPROM_DATA_LEN 3 +#define CC2_MEASUREMENT_DATA_LEN 4 + +#define CC2_RH_DATA_FIELD GENMASK(13, 0) + +/* ensure clean off -> on transitions */ +#define CC2_POWER_CYCLE_MS 80 + +#define CC2_STARTUP_TO_DATA_MS 55 +#define CC2_RESP_START_CM_US 100 +#define CC2_RESP_EEPROM_R_US 100 +#define CC2_RESP_EEPROM_W_MS 12 +#define CC2_STARTUP_TIME_US 1250 + +#define CC2_RH_MAX (100 * 1000U) + +#define CC2_CM_RETRIES 5 + +struct cc2_rh_alarm_info { + bool low_alarm; + bool high_alarm; + bool low_alarm_visible; + bool high_alarm_visible; +}; + +struct cc2_data { + struct cc2_rh_alarm_info rh_alarm; + struct completion complete; + struct device *hwmon; + struct i2c_client *client; + struct mutex dev_access_lock; /* device access lock */ + struct regulator *regulator; + const char *name; + int irq_ready; + int irq_low; + int irq_high; + bool process_irqs; +}; + +enum cc2_chan_addr { + CC2_CHAN_TEMP = 0, + CC2_CHAN_HUMIDITY, +}; + +/* %RH as a per cent mille from a register value */ +static long cc2_rh_convert(u16 data) +{ + unsigned long tmp = (data & CC2_RH_DATA_FIELD) * CC2_RH_MAX; + + return tmp / ((1 << 14) - 1); +} + +/* convert %RH to a register value */ +static u16 cc2_rh_to_reg(long data) +{ + return data * ((1 << 14) - 1) / CC2_RH_MAX; +} + +/* temperature in milli degrees celsius from a register value */ +static long cc2_temp_convert(u16 data) +{ + unsigned long tmp = ((data >> 2) * 165 * 1000U) / ((1 << 14) - 1); + + return tmp - 40 * 1000U; +} + +static int cc2_enable(struct cc2_data *data) +{ + int ret; + + /* exclusive regulator, check in case a disable failed */ + if (regulator_is_enabled(data->regulator)) + return 0; + + /* clear any pending completion */ + try_wait_for_completion(&data->complete); + + ret = regulator_enable(data->regulator); + if (ret < 0) + return ret; + + usleep_range(CC2_STARTUP_TIME_US, CC2_STARTUP_TIME_US + 125); + + data->process_irqs = true; + + return 0; +} + +static void cc2_disable(struct cc2_data *data) +{ + int err; + + /* ignore alarms triggered by voltage toggling when powering up */ + data->process_irqs = false; + + /* exclusive regulator, check in case an enable failed */ + if (regulator_is_enabled(data->regulator)) { + err = regulator_disable(data->regulator); + if (err) + dev_dbg(&data->client->dev, "Failed to disable device"); + } +} + +static int cc2_cmd_response_diagnostic(struct device *dev, u8 status) +{ + int resp; + + if (FIELD_GET(CC2_STATUS_FIELD, status) != CC2_STATUS_CMD_MODE) { + dev_dbg(dev, "Command sent out of command window\n"); + return -ETIMEDOUT; + } + + resp = FIELD_GET(CC2_RESPONSE_FIELD, status); + switch (resp) { + case CC2_RESPONSE_ACK: + return 0; + case CC2_RESPONSE_BUSY: + return -EBUSY; + case CC2_RESPONSE_NACK: + if (resp & CC2_ERR_CORR_EEPROM) + dev_dbg(dev, "Command failed: corrected EEPROM\n"); + if (resp & CC2_ERR_UNCORR_EEPROM) + dev_dbg(dev, "Command failed: uncorrected EEPROM\n"); + if (resp & CC2_ERR_RAM_PARITY) + dev_dbg(dev, "Command failed: RAM parity\n"); + if (resp & CC2_ERR_RAM_PARITY) + dev_dbg(dev, "Command failed: configuration error\n"); + return -ENODATA; + default: + dev_dbg(dev, "Unknown command reply\n"); + return -EINVAL; + } +} + +static int cc2_read_command_status(struct i2c_client *client) +{ + u8 status; + int ret; + + ret = i2c_master_recv(client, &status, 1); + if (ret != 1) { + ret = ret < 0 ? ret : -EIO; + return ret; + } + + return cc2_cmd_response_diagnostic(&client->dev, status); +} + +/* + * The command mode is only accessible after sending the START_CM command in the + * first 10 ms after power-up. Only in case the command window is missed, + * CC2_CM_RETRIES retries are attempted before giving up and returning an error. + */ +static int cc2_command_mode_start(struct cc2_data *data) +{ + unsigned long timeout; + int i, ret; + + for (i = 0; i < CC2_CM_RETRIES; i++) { + ret = cc2_enable(data); + if (ret < 0) + return ret; + + ret = i2c_smbus_write_word_data(data->client, CC2_START_CM, 0); + if (ret < 0) + return ret; + + if (data->irq_ready > 0) { + timeout = usecs_to_jiffies(2 * CC2_RESP_START_CM_US); + ret = wait_for_completion_timeout(&data->complete, + timeout); + if (!ret) + return -ETIMEDOUT; + } else { + usleep_range(CC2_RESP_START_CM_US, + 2 * CC2_RESP_START_CM_US); + } + ret = cc2_read_command_status(data->client); + if (ret != -ETIMEDOUT || i == CC2_CM_RETRIES) + break; + + /* command window missed, prepare for a retry */ + cc2_disable(data); + msleep(CC2_POWER_CYCLE_MS); + } + + return ret; +} + +/* Sending a Start_NOM command finishes the command mode immediately with no + * reply and the device enters normal operation mode + */ +static int cc2_command_mode_finish(struct cc2_data *data) +{ + int ret; + + ret = i2c_smbus_write_word_data(data->client, CC2_START_NOM, 0); + if (ret < 0) + return ret; + + return 0; +} + +static int cc2_write_reg(struct cc2_data *data, u8 reg, u16 val) +{ + unsigned long timeout; + int ret; + + ret = cc2_command_mode_start(data); + if (ret < 0) + goto disable; + + cpu_to_be16s(&val); + ret = i2c_smbus_write_word_data(data->client, reg, val); + if (ret < 0) + goto disable; + + if (data->irq_ready > 0) { + timeout = msecs_to_jiffies(2 * CC2_RESP_EEPROM_W_MS); + ret = wait_for_completion_timeout(&data->complete, timeout); + if (!ret) { + ret = -ETIMEDOUT; + goto disable; + } + } else { + msleep(CC2_RESP_EEPROM_W_MS); + } + + ret = cc2_read_command_status(data->client); + +disable: + cc2_disable(data); + + return ret; +} + +static int cc2_read_reg(struct cc2_data *data, u8 reg, u16 *val) +{ + u8 buf[CC2_EEPROM_DATA_LEN]; + unsigned long timeout; + int ret; + + ret = cc2_command_mode_start(data); + if (ret < 0) + return ret; + + ret = i2c_smbus_write_word_data(data->client, reg, 0); + if (ret < 0) + return ret; + + if (data->irq_ready > 0) { + timeout = usecs_to_jiffies(2 * CC2_RESP_EEPROM_R_US); + ret = wait_for_completion_timeout(&data->complete, timeout); + if (!ret) + return -ETIMEDOUT; + + } else { + usleep_range(CC2_RESP_EEPROM_R_US, CC2_RESP_EEPROM_R_US + 10); + } + ret = i2c_master_recv(data->client, buf, CC2_EEPROM_DATA_LEN); + if (ret != CC2_EEPROM_DATA_LEN) + return ret < 0 ? ret : -EIO; + + *val = be16_to_cpup((__be16 *)&buf[1]); + + return cc2_read_command_status(data->client); +} + +static int cc2_get_reg_val(struct cc2_data *data, u8 reg, long *val) +{ + u16 reg_val; + int ret; + + ret = cc2_read_reg(data, reg, ®_val); + *val = cc2_rh_convert(reg_val); + cc2_disable(data); + + return ret; +} + +static int cc2_data_fetch(struct i2c_client *client, + enum hwmon_sensor_types type, long *val) +{ + u8 data[CC2_MEASUREMENT_DATA_LEN]; + u8 status; + int ret; + + ret = i2c_master_recv(client, data, CC2_MEASUREMENT_DATA_LEN); + if (ret != CC2_MEASUREMENT_DATA_LEN) { + ret = ret < 0 ? ret : -EIO; + return ret; + } + status = FIELD_GET(CC2_STATUS_FIELD, data[0]); + if (status == CC2_STATUS_STALE_DATA) + return -EBUSY; + + if (status != CC2_STATUS_VALID_DATA) + return -EIO; + + switch (type) { + case hwmon_humidity: + *val = cc2_rh_convert(be16_to_cpup((__be16 *)&data[0])); + break; + case hwmon_temp: + *val = cc2_temp_convert(be16_to_cpup((__be16 *)&data[2])); + break; + default: + return -EINVAL; + } + + return 0; +} + +static int cc2_read_measurement(struct cc2_data *data, + enum hwmon_sensor_types type, long *val) +{ + unsigned long timeout; + int ret; + + if (data->irq_ready > 0) { + timeout = msecs_to_jiffies(CC2_STARTUP_TO_DATA_MS * 2); + ret = wait_for_completion_timeout(&data->complete, timeout); + if (!ret) + return -ETIMEDOUT; + + } else { + msleep(CC2_STARTUP_TO_DATA_MS); + } + + ret = cc2_data_fetch(data->client, type, val); + + return ret; +} + +/* + * A measurement requires enabling the device, waiting for the automatic + * measurement to finish, reading the measurement data and disabling the device + * again. + */ +static int cc2_measurement(struct cc2_data *data, enum hwmon_sensor_types type, + long *val) +{ + int ret; + + ret = cc2_enable(data); + if (ret) + return ret; + + ret = cc2_read_measurement(data, type, val); + + cc2_disable(data); + + return ret; +} + +/* + * In order to check alarm status, the corresponding ALARM_OFF (hysteresis) + * register must be read and a new measurement must be carried out to trigger + * the alarm signals. Given that the device carries out a measurement after + * exiting the command mode, there is no need to force two power-up sequences. + * Instead, a NOM command is sent and the device is disabled after the + * measurement is read. + */ +static int cc2_read_hyst_and_measure(struct cc2_data *data, u8 reg, + long *hyst, long *measurement) +{ + u16 reg_val; + int ret; + + ret = cc2_read_reg(data, reg, ®_val); + if (ret) + goto disable; + + *hyst = cc2_rh_convert(reg_val); + + ret = cc2_command_mode_finish(data); + if (ret) + goto disable; + + ret = cc2_read_measurement(data, hwmon_humidity, measurement); + +disable: + cc2_disable(data); + + return ret; +} + +static umode_t cc2_is_visible(const void *data, enum hwmon_sensor_types type, + u32 attr, int channel) +{ + const struct cc2_data *cc2 = data; + + switch (type) { + case hwmon_humidity: + switch (attr) { + case hwmon_humidity_input: + return 0444; + case hwmon_humidity_min_alarm: + return cc2->rh_alarm.low_alarm_visible ? 0444 : 0; + case hwmon_humidity_max_alarm: + return cc2->rh_alarm.high_alarm_visible ? 0444 : 0; + case hwmon_humidity_min: + case hwmon_humidity_min_hyst: + return cc2->rh_alarm.low_alarm_visible ? 0644 : 0; + case hwmon_humidity_max: + case hwmon_humidity_max_hyst: + return cc2->rh_alarm.high_alarm_visible ? 0644 : 0; + default: + return 0; + } + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + return 0444; + default: + return 0; + } + default: + break; + } + + return 0; +} + +static irqreturn_t cc2_ready_interrupt(int irq, void *data) +{ + struct cc2_data *cc2 = data; + + if (cc2->process_irqs) + complete(&cc2->complete); + + return IRQ_HANDLED; +} + +static irqreturn_t cc2_low_interrupt(int irq, void *data) +{ + struct cc2_data *cc2 = data; + + if (cc2->process_irqs) { + hwmon_notify_event(cc2->hwmon, hwmon_humidity, + hwmon_humidity_min_alarm, CC2_CHAN_HUMIDITY); + cc2->rh_alarm.low_alarm = true; + } + + return IRQ_HANDLED; +} + +static irqreturn_t cc2_high_interrupt(int irq, void *data) +{ + struct cc2_data *cc2 = data; + + if (cc2->process_irqs) { + hwmon_notify_event(cc2->hwmon, hwmon_humidity, + hwmon_humidity_max_alarm, CC2_CHAN_HUMIDITY); + cc2->rh_alarm.high_alarm = true; + } + + return IRQ_HANDLED; +} + +static int cc2_humidity_min_alarm_status(struct cc2_data *data, long *val) +{ + long measurement, min_hyst; + int ret; + + ret = cc2_read_hyst_and_measure(data, CC2_R_ALARM_L_OFF, &min_hyst, + &measurement); + if (ret < 0) + return ret; + + if (data->rh_alarm.low_alarm) { + *val = (measurement < min_hyst) ? 1 : 0; + data->rh_alarm.low_alarm = *val; + } else { + *val = 0; + } + + return 0; +} + +static int cc2_humidity_max_alarm_status(struct cc2_data *data, long *val) +{ + long measurement, max_hyst; + int ret; + + ret = cc2_read_hyst_and_measure(data, CC2_R_ALARM_H_OFF, &max_hyst, + &measurement); + if (ret < 0) + return ret; + + if (data->rh_alarm.high_alarm) { + *val = (measurement > max_hyst) ? 1 : 0; + data->rh_alarm.high_alarm = *val; + } else { + *val = 0; + } + + return 0; +} + +static int cc2_read(struct device *dev, enum hwmon_sensor_types type, u32 attr, + int channel, long *val) +{ + struct cc2_data *data = dev_get_drvdata(dev); + int ret = 0; + + mutex_lock(&data->dev_access_lock); + + switch (type) { + case hwmon_temp: + ret = cc2_measurement(data, type, val); + break; + case hwmon_humidity: + switch (attr) { + case hwmon_humidity_input: + ret = cc2_measurement(data, type, val); + break; + case hwmon_humidity_min: + ret = cc2_get_reg_val(data, CC2_R_ALARM_L_ON, val); + break; + case hwmon_humidity_min_hyst: + ret = cc2_get_reg_val(data, CC2_R_ALARM_L_OFF, val); + break; + case hwmon_humidity_max: + ret = cc2_get_reg_val(data, CC2_R_ALARM_H_ON, val); + break; + case hwmon_humidity_max_hyst: + ret = cc2_get_reg_val(data, CC2_R_ALARM_H_OFF, val); + break; + case hwmon_humidity_min_alarm: + ret = cc2_humidity_min_alarm_status(data, val); + break; + case hwmon_humidity_max_alarm: + ret = cc2_humidity_max_alarm_status(data, val); + break; + default: + ret = -EOPNOTSUPP; + } + break; + default: + ret = -EOPNOTSUPP; + } + + mutex_unlock(&data->dev_access_lock); + + return ret; +} + +static int cc2_write(struct device *dev, enum hwmon_sensor_types type, u32 attr, + int channel, long val) +{ + struct cc2_data *data = dev_get_drvdata(dev); + int ret; + u16 arg; + u8 cmd; + + if (type != hwmon_humidity) + return -EOPNOTSUPP; + + if (val < 0 || val > CC2_RH_MAX) + return -EINVAL; + + mutex_lock(&data->dev_access_lock); + + switch (attr) { + case hwmon_humidity_min: + cmd = CC2_W_ALARM_L_ON; + arg = cc2_rh_to_reg(val); + ret = cc2_write_reg(data, cmd, arg); + break; + + case hwmon_humidity_min_hyst: + cmd = CC2_W_ALARM_L_OFF; + arg = cc2_rh_to_reg(val); + ret = cc2_write_reg(data, cmd, arg); + break; + + case hwmon_humidity_max: + cmd = CC2_W_ALARM_H_ON; + arg = cc2_rh_to_reg(val); + ret = cc2_write_reg(data, cmd, arg); + break; + + case hwmon_humidity_max_hyst: + cmd = CC2_W_ALARM_H_OFF; + arg = cc2_rh_to_reg(val); + ret = cc2_write_reg(data, cmd, arg); + break; + + default: + ret = -EOPNOTSUPP; + break; + } + + mutex_unlock(&data->dev_access_lock); + + return ret; +} + +static int cc2_request_ready_irq(struct cc2_data *data, struct device *dev) +{ + int ret = 0; + + data->irq_ready = fwnode_irq_get_byname(dev_fwnode(dev), "ready"); + if (data->irq_ready > 0) { + init_completion(&data->complete); + ret = devm_request_threaded_irq(dev, data->irq_ready, NULL, + cc2_ready_interrupt, + IRQF_ONESHOT | + IRQF_TRIGGER_RISING, + dev_name(dev), data); + } + + return ret; +} + +static int cc2_request_alarm_irqs(struct cc2_data *data, struct device *dev) +{ + int ret; + + data->irq_low = fwnode_irq_get_byname(dev_fwnode(dev), "low"); + if (data->irq_low > 0) { + ret = devm_request_threaded_irq(dev, data->irq_low, NULL, + cc2_low_interrupt, + IRQF_ONESHOT | + IRQF_TRIGGER_RISING, + dev_name(dev), data); + if (!ret) + data->rh_alarm.low_alarm_visible = true; + } + + data->irq_high = fwnode_irq_get_byname(dev_fwnode(dev), "high"); + if (data->irq_high > 0) { + ret = devm_request_threaded_irq(dev, data->irq_high, NULL, + cc2_high_interrupt, + IRQF_ONESHOT | + IRQF_TRIGGER_RISING, + dev_name(dev), data); + if (!ret) + data->rh_alarm.high_alarm_visible = true; + } + + return ret; +} + +static const struct hwmon_channel_info *cc2_info[] = { + HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), + HWMON_CHANNEL_INFO(humidity, HWMON_H_INPUT | HWMON_H_MIN | HWMON_H_MAX | + HWMON_H_MIN_HYST | HWMON_H_MAX_HYST | + HWMON_H_MIN_ALARM | HWMON_H_MAX_ALARM), + NULL +}; + +static const struct hwmon_ops cc2_hwmon_ops = { + .is_visible = cc2_is_visible, + .read = cc2_read, + .write = cc2_write, +}; + +static const struct hwmon_chip_info cc2_chip_info = { + .ops = &cc2_hwmon_ops, + .info = cc2_info, +}; + +static int cc2_probe(struct i2c_client *client) +{ + struct cc2_data *data; + struct device *dev = &client->dev; + int ret; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) + return -EOPNOTSUPP; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + i2c_set_clientdata(client, data); + + mutex_init(&data->dev_access_lock); + + data->client = client; + + data->regulator = devm_regulator_get_exclusive(dev, "vdd"); + if (IS_ERR(data->regulator)) { + dev_err_probe(dev, PTR_ERR(data->regulator), + "Failed to get regulator\n"); + return PTR_ERR(data->regulator); + } + + ret = cc2_request_ready_irq(data, dev); + if (ret) { + dev_err_probe(dev, ret, "Failed to request ready irq\n"); + return ret; + } + + ret = cc2_request_alarm_irqs(data, dev); + if (ret) { + dev_err_probe(dev, ret, "Failed to request alarm irqs\n"); + goto disable; + } + + data->hwmon = devm_hwmon_device_register_with_info(dev, client->name, + data, &cc2_chip_info, + NULL); + if (IS_ERR(data->hwmon)) { + dev_err_probe(dev, PTR_ERR(data->hwmon), + "Failed to register hwmon device\n"); + ret = PTR_ERR(data->hwmon); + } + +disable: + cc2_disable(data); + + return ret; +} + +static void cc2_remove(struct i2c_client *client) +{ + struct cc2_data *data = i2c_get_clientdata(client); + + cc2_disable(data); +} + +static const struct i2c_device_id cc2_id[] = { + { "cc2d23" }, + { "cc2d23s" }, + { "cc2d25" }, + { "cc2d25s" }, + { "cc2d33" }, + { "cc2d33s" }, + { "cc2d35" }, + { "cc2d35s" }, + { } +}; +MODULE_DEVICE_TABLE(i2c, cc2_id); + +static const struct of_device_id cc2_of_match[] = { + { .compatible = "amphenol,cc2d23" }, + { .compatible = "amphenol,cc2d23s" }, + { .compatible = "amphenol,cc2d25" }, + { .compatible = "amphenol,cc2d25s" }, + { .compatible = "amphenol,cc2d33" }, + { .compatible = "amphenol,cc2d33s" }, + { .compatible = "amphenol,cc2d35" }, + { .compatible = "amphenol,cc2d35s" }, + { }, +}; +MODULE_DEVICE_TABLE(of, cc2_of_match); + +static struct i2c_driver cc2_driver = { + .driver = { + .name = "cc2d23", + .of_match_table = cc2_of_match, + }, + .probe = cc2_probe, + .remove = cc2_remove, + .id_table = cc2_id, +}; +module_i2c_driver(cc2_driver); + +MODULE_AUTHOR("Javier Carrasco "); +MODULE_DESCRIPTION("Amphenol ChipCap 2 humidity and temperature sensor driver"); +MODULE_LICENSE("GPL");