From patchwork Tue Feb 27 00:56:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ban Feng X-Patchwork-Id: 206987 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2421486dyb; Mon, 26 Feb 2024 16:58:14 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWfKEpEfMk4Ht8o/bHfohAriSlmAWA+s7gPj3aOaDrn3Ysuj1z4RE22brzBYWNlWBEe3z/G65WAzOPzUnR4LJ7Y3GQymg== X-Google-Smtp-Source: AGHT+IHh8F+Oy/FtpsRd9FVXv2nW85asWZoWOM3RvzUc92sYeeYt6qF6gGpgL3MugpJhtOPP1Md6 X-Received: by 2002:a17:906:260d:b0:a3e:5cb9:8a4f with SMTP id h13-20020a170906260d00b00a3e5cb98a4fmr6265159ejc.58.1708995494364; Mon, 26 Feb 2024 16:58:14 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708995494; cv=pass; d=google.com; s=arc-20160816; b=WtWpcFT//svUHHadLjzAhDdNQwZexud94cr7EJd8jjwQZUN2tHKzhdX8HpbJ6si+At Xk63guV/p+5pa79pSnDIrZAPQfVj0rtBAFm6qQDKal9acMzu7S59DVzge+rkQcbOSJJg Xib8cev2bb+im68MLlxZfaSZ5yPM41ytxNvyGlA8ZI0x//UQDMOd362SS4tFOa9sLlyX 0qnZlAvxSIRQWuinvLOonbpA/4TgV6QRsU5K218mmYV7ROgV7xOEn3SwfHRl92jAlp9I Gd6MsXosINq6gLbGH1VEdkkAKmu6HehRDUCN2FZQsawOyMm1Ns8qH3TO0zaUlhcwiWBe eDNQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=Tla499i31FteRARO4yRBYIXYdMACpp2W1rRXAXvCyxw=; fh=fYiihK7cjM7V1nuwxK4GjpChh/H9LlxgihWNhAKxvhE=; b=XxwNKaxizT3hrd9l6orYbdJ50dZiU+nujrEnxRqnyjyttlF3l49HVE7iqbIfCvxd6M ZFl1ji3dEotiKilbzHt5rFMsBI3B3/2D+B97q7oOLIu7TD5+4F84GtvKuOFkBjQcoIVF o6baUz/6jFQT/HSVhcdbxdOp2wSpoItWxcqmDHKBgXsrKs0KD1kUP3pW5aUDaAsQeK9N r+yPkiT+ewWWqkxqtPFy25RKtBtvH+BVTNW+KC3S0UJoCblGbVAyxFc3J/B0wPBlpCHi i4xKErrC4nYBw1a5z7K7H1cjCIAVH708eDiXKIQhYjPguwPXMCktJMMOsSIMZE3eIvcT Gxng==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kgc535m5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82492-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82492-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id oq2-20020a170906cc8200b00a438d35b117si220812ejb.521.2024.02.26.16.58.14 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:58:14 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82492-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=kgc535m5; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82492-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82492-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 48CE71F23C9C for ; Tue, 27 Feb 2024 00:57:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id EAC1B1FBB; Tue, 27 Feb 2024 00:57:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kgc535m5" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (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 7695F4A29; Tue, 27 Feb 2024 00:57:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708995425; cv=none; b=H0i4sjiHu91Rf2dlsRiJwapFG6FINzUsLyxC54N/vGhgHX+PT8yFKSXKWwnpBwblTdpCmHr8shbVSgaiYn67UjeyGwQNErLfmiKg+LlRt7bIcUig1dSbdpdOtLwsKwwXTHl/ZP+2CVo9mAKW8IsR4ULipqUO6+e5Mo3j7nsdaQs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708995425; c=relaxed/simple; bh=xt+P52CkE2QqdybtNxMmcXYypfUOZZ7DvOIFDhA5jR0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=FbR/6B3KpqCotlpfagPu1PK7WP/W7fYpYZ/qlYRa1Gb+VbzF8W49zP7IAZHpmPF1TsRGjwo9UX5Reo/eoshiuda55CddFf6ex5OcnPvn4xoXsdCnWut59+cNnz/z9I7K2XTWNsvTuS30MsakgaLDgVIhQinAUbQG7n+4YxWUuFg= 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=kgc535m5; arc=none smtp.client-ip=209.85.214.170 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 Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1dcafff3c50so8916835ad.0; Mon, 26 Feb 2024 16:57:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708995423; x=1709600223; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Tla499i31FteRARO4yRBYIXYdMACpp2W1rRXAXvCyxw=; b=kgc535m5t/1QB6ntVhEjGrz40jGndEmcSqVgGKs6S42P4nDJfjWJgA+SNGaWwOo5+O 8Dcy8BLBCnloVVys9bZMJ5H0qIBOjYu351xFJv4wpQlyOUfIRu+oUqQqq6dPXNdL6J97 XICzyxpTIMxReZHYb3J/0wqmKSmdh3t9MlS82WvQGDhr2DdRtI1pxVi0arF8A4c972gh jmUe2SqPM5YNSWia0dDL6SHDzlE2efPjIRsWP8T2vrZk6QrU/2+/Hn7x+blOwj+lgoWI UqrP8QqP1/x4hrdKvGtd6UZwdR/8NZcKZoFMKpIbYLnsrZ19WUIPSKZPLrPZPZk5KqrJ vxlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708995423; x=1709600223; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Tla499i31FteRARO4yRBYIXYdMACpp2W1rRXAXvCyxw=; b=Mq1jptoPpjq2U019fJdyju8aROaFOclW/jQB/rPdvxx+yhNdovr2exACiPF6RqfDBy Vd7vVIBgumGuEDiiOeY7Xvr/m387bTfRuHV+e8I6ZEW40P08wIalFE09tG+DToUJaWll WlNXMFJQWWNsDNGV7BdGn0otRCyojWCOHUUYsmxjwM/Oq3nFglOOvdOseftD1Rx/zXFc p75d2vBzEI0R2DRYPeOFrGTko3MUBf2F/3t2JO51cAYxSLRefJnjFpozn5Nbb994DdeV hRjzjka+qijKka+xnuZ/wIdQSOHdiEPL1lmNhYTj/I7ttfixL/f9nwU0DqqZceRvwwyI s9Iw== X-Forwarded-Encrypted: i=1; AJvYcCUTSNPNw/S5eklcMGvpQRyjcUdNivkBneEIcfHihog7xBtSKZKhrkfUngSt8bgtFo4LPc3DkTC3k+C4swo2S+0qWYy+1CVf2hGxGOEWHMfackBTqtD6gqXt8Di1psxl4Zrg0iCKmOXPkLpd8Ol8Q+JAqAnHvbrIOEUvWA03e+/ZmyeC+g== X-Gm-Message-State: AOJu0Yzv4fXurRP2a+LOo6L3/YIYJOeHszmdHoimLIgXpfopyiDprDk+ i6C6iYWWjtfybzhBPKzJGx0xWTx70q9BZhWcsAOv0iICWmV6iXoM X-Received: by 2002:a17:902:bf49:b0:1db:f371:dc90 with SMTP id u9-20020a170902bf4900b001dbf371dc90mr8777057pls.20.1708995422708; Mon, 26 Feb 2024 16:57:02 -0800 (PST) Received: from hcdev-d520mt2.. (60-250-192-107.hinet-ip.hinet.net. [60.250.192.107]) by smtp.gmail.com with ESMTPSA id t12-20020a170902e84c00b001db3361bc1dsm289253plg.102.2024.02.26.16.56.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:57:02 -0800 (PST) From: baneric926@gmail.com X-Google-Original-From: kcfeng0@nuvoton.com To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, corbet@lwn.net Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, openbmc@lists.ozlabs.org, kwliu@nuvoton.com, kcfeng0@nuvoton.com, DELPHINE_CHIU@wiwynn.com, Bonnie_Lo@wiwynn.com, naresh.solanki@9elements.com, billy_tsai@aspeedtech.com, Rob Herring Subject: [PATCH v4 1/3] dt-bindings: hwmon: fan: Add fan binding to schema Date: Tue, 27 Feb 2024 08:56:04 +0800 Message-Id: <20240227005606.1107203-2-kcfeng0@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227005606.1107203-1-kcfeng0@nuvoton.com> References: <20240227005606.1107203-1-kcfeng0@nuvoton.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792011659376677012 X-GMAIL-MSGID: 1792011659376677012 From: Naresh Solanki Add common fan properties bindings to a schema. Bindings for fan controllers can reference the common schema for the fan child nodes: patternProperties: "^fan@[0-2]": type: object $ref: fan-common.yaml# unevaluatedProperties: false Reviewed-by: Rob Herring Signed-off-by: Naresh Solanki Signed-off-by: Billy Tsai Signed-off-by: Ban Feng --- .../devicetree/bindings/hwmon/fan-common.yaml | 78 +++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/fan-common.yaml diff --git a/Documentation/devicetree/bindings/hwmon/fan-common.yaml b/Documentation/devicetree/bindings/hwmon/fan-common.yaml new file mode 100644 index 000000000000..15c591c74545 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/fan-common.yaml @@ -0,0 +1,78 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/fan-common.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Common Fan Properties + +maintainers: + - Naresh Solanki + - Billy Tsai + +properties: + max-rpm: + description: + Max RPM supported by fan. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 100000 + + min-rpm: + description: + Min RPM supported by fan. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 1000 + + pulses-per-revolution: + description: + The number of pulse from fan sensor per revolution. + $ref: /schemas/types.yaml#/definitions/uint32 + maximum: 4 + + tach-div: + description: + Divisor for the tach sampling clock, which determines the sensitivity of the tach pin. + $ref: /schemas/types.yaml#/definitions/uint32 + + target-rpm: + description: + The default desired fan speed in RPM. + $ref: /schemas/types.yaml#/definitions/uint32 + + fan-driving-mode: + description: + Select the driving mode of the fan.(DC, PWM and so on) + $ref: /schemas/types.yaml#/definitions/string + enum: [ dc, pwm ] + + pwms: + description: + PWM provider. + maxItems: 1 + + "#cooling-cells": + const: 2 + + cooling-levels: + description: + The control value which correspond to thermal cooling states. + $ref: /schemas/types.yaml#/definitions/uint32-array + + tach-ch: + description: + The tach channel used for the fan. + $ref: /schemas/types.yaml#/definitions/uint8-array + + label: + description: + Optional fan label + + fan-supply: + description: + Power supply for fan. + + reg: + maxItems: 1 + +additionalProperties: true + From patchwork Tue Feb 27 00:56:06 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ban Feng X-Patchwork-Id: 206986 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp2421433dyb; Mon, 26 Feb 2024 16:58:04 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVo54IcRzMi025+0BlSFwct2LyB+7X4BuEWJ3/IrWBmkj/dbvpH4XqpSV2Yi6m/3+LNWx4xloYKn9fNQoHVju6T1fTz/Q== X-Google-Smtp-Source: AGHT+IHbSbC3t/09XHsMF6vfl/+n2sK2LrTwjwte2QpwQ2FW+g+Hcg4mNghVpAUWERTJcJ2MZWSQ X-Received: by 2002:a67:e8d1:0:b0:470:5b57:6943 with SMTP id y17-20020a67e8d1000000b004705b576943mr4394086vsn.31.1708995484199; Mon, 26 Feb 2024 16:58:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708995484; cv=pass; d=google.com; s=arc-20160816; b=Zlrug6bfbeYuxGaXytmXXpdyUbuaNbCitSpot9XbU7MkA9NwszogqCIYKmymLrpFTE AySVQAJBsEzOucQq5HbRGHq0GBHwc+oUrpAAAmz/t5LMV2KEfIdn16HFTop6Hy26OwQN hK8NpZaOyU4fulo6MRj7XwrgRypLGFPCgWb2zXP98EaCcCPtbeYSKoKV9b3xXF/KFWNW 9P5N9tlBTeuGr5QBqDDbp+jRsmCyfL6iUZOe/FOMgDiPAjAOiaqLl9dkH2N5/fpLbNMl qFbluE4STZYgaLcNKx2qkJe9pyExclgEBYc7InkD/QpNhLogOC02AOgHLhtw8H9iA40L zc9g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=viN62ftpMyo6GvVXoLPS/9Wzyg9rdjzqSvpHHxSrBzg=; fh=lYTn3p6dTZATbhJp9cWevn6+xVAMhhdd/1czF1ly5yg=; b=mZgVFVXBfCwbRP4X+DNsG4EgyCVs5Ypysl0hYJpudXSQldlbiXnrqhUMZiwrICyBtZ qA6+cavFMXTSptvQQiLcN/C300hKrHggXVjP2iutLajnTp9J2Y5tMHaqaSJbhfXZzv1j 7u6bA8bs05jDIq84SubCqNrx1/PQacSCciH8NdncMTtcj4ODwWcD9NoxOJHnGafBB4s8 Elw/hZbtLrFZWaqIwdcvyWBrbQAOKeIDw7VUVmqtBjevRSHrb07EVFediMQYgoRuQmkD qDVWu00EraS6cRH5sCxkLbJsI4Ouww6p7B5T1LZiyosnAqHN7ziotgMjtZT2aqF+GDiY hDdw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="kEH1Z/W5"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82494-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82494-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id d4-20020a37c404000000b00787a6ab41casi6070872qki.505.2024.02.26.16.58.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:58:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82494-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b="kEH1Z/W5"; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-82494-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82494-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E298D1C2243D for ; Tue, 27 Feb 2024 00:58:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 163D5EAD4; Tue, 27 Feb 2024 00:57:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kEH1Z/W5" Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com [209.85.214.169]) (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 76D1FE56E; Tue, 27 Feb 2024 00:57:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708995432; cv=none; b=raO3Ur6rpPEmDnH0uhfsPWlpwg6rItYIgJ81I+aUMDkGAGeqSyZGk9QA3eeI/z9YYJxXvEK2kKE8OwFG0UWuJPfmJR1/8QgE2enrjkKhtLVaW4piCHaAve9B+gggpBBDngeY+mgaX8M2rPw13IviP96MhDNK9hRSB+iE9jPk/yo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708995432; c=relaxed/simple; bh=q42sbE6Dgv0fa/KUnOLjHsR9dWLx8Zv2Vgm6ZMUdMow=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=dHtj7Spk8m0C4q+sJJVR5cNCaZmIU31NHsIvo/b1cXFTiMIvEkPRbChwbD+K1FmSGK+BFUy1UArPFUZRGwCGqCTBy7YbvTYoM5APTHG8FJF8OMfb3pUYAFwUVPD3SlV9qy45nrrHn2z+cgCBHVVgcIt8pK/wejE7AGqRTn1VHgY= 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=kEH1Z/W5; arc=none smtp.client-ip=209.85.214.169 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 Received: by mail-pl1-f169.google.com with SMTP id d9443c01a7336-1dca3951ad9so14238285ad.3; Mon, 26 Feb 2024 16:57:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1708995429; x=1709600229; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=viN62ftpMyo6GvVXoLPS/9Wzyg9rdjzqSvpHHxSrBzg=; b=kEH1Z/W5cX44Aem96DW+prwv0jDrdg7YVo9QXi0rPufB2aZt0fsaYucuPuWrG/yj47 +BlTX+Urwt3JZJmKXzJNl/JotsQGCUuPQaFJPDm3Sg4gD8GlUF9leUtz0WXO9OgiIvt4 QpNaar+SnFdeROiVb5c5e0/VaaiaTTHLixLLe8fR8xMaU/txTSrGdBIpEV5nQxOZnzps vrPxya6SQFnHa3TnpsVROwpjftlwAAACG7Zez9VH9+tQr7KOG7acG/8m9+7jdjW2w3+G jUUpm9UV594wlccGsiPEvme/zQv2DJTKQRpvy3vUHQNcwx59sTI+bJRq+Jhekit7UclM oiCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708995429; x=1709600229; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=viN62ftpMyo6GvVXoLPS/9Wzyg9rdjzqSvpHHxSrBzg=; b=wEpbf/PBwHVgT/MtFZBqbWDd3kFPyfRt48EMevUPpDXENA8BDyhjioaGdZnzHGkYiX Y+zyEfFfK+blhzPSfAX+K8uHBysFeAJc1cPGkoAUQSaJ9333qcu2I9tpQaHVWYnM6EyO YpwSUvqmIBY7rWjqvFUjS2ZBUX2XVCWsvP3pwydE8uOuNcp/lhAS7SNd+52XR/JlMnus yD8TgQvgDQKieXJpsmsp5Mk4wtY1nxsTvOGX02ZD8igSJ/pBUtm/9e15wp1q5rapQQZ1 9r6CmMobBDmNOixjAkps3MjSluf1sXWwkwvEzLlt1iaHtdTfON/oeyJk0fg6Dka5HMpu v8Aw== X-Forwarded-Encrypted: i=1; AJvYcCX1pDfFv9t1QA43f8CNzfzGUkOzyHbYJxAeu7Lwsp7O4GlwMfS3aHXbFRQhWJQb/ZyGhjiQGNePZ6qwn64T5YoaJ9u4WJV3gtjkSGaF0t33mjeiU/rF/zD9pCMMy6XqxhV9sjK870H573GMiAkaFwJ35Nl7D2H3EIpujC9+NaCEE0DEtQ== X-Gm-Message-State: AOJu0Yw3+jW2s7cdy1iOtGpJOv9OqsOeV1728Rk5OkebtGxN116TQkg1 tdbuL6u8FREA9F75699DfuSBGD2Ep5YCO773uiLIYuBEUGC2K+oY X-Received: by 2002:a17:902:8303:b0:1db:e243:6d64 with SMTP id bd3-20020a170902830300b001dbe2436d64mr8652636plb.69.1708995428675; Mon, 26 Feb 2024 16:57:08 -0800 (PST) Received: from hcdev-d520mt2.. (60-250-192-107.hinet-ip.hinet.net. [60.250.192.107]) by smtp.gmail.com with ESMTPSA id t12-20020a170902e84c00b001db3361bc1dsm289253plg.102.2024.02.26.16.57.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 26 Feb 2024 16:57:08 -0800 (PST) From: baneric926@gmail.com X-Google-Original-From: kcfeng0@nuvoton.com To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, corbet@lwn.net Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, openbmc@lists.ozlabs.org, kwliu@nuvoton.com, kcfeng0@nuvoton.com, DELPHINE_CHIU@wiwynn.com, Bonnie_Lo@wiwynn.com, naresh.solanki@9elements.com, billy_tsai@aspeedtech.com Subject: [PATCH v4 3/3] hwmon: Driver for Nuvoton NCT7363Y Date: Tue, 27 Feb 2024 08:56:06 +0800 Message-Id: <20240227005606.1107203-4-kcfeng0@nuvoton.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240227005606.1107203-1-kcfeng0@nuvoton.com> References: <20240227005606.1107203-1-kcfeng0@nuvoton.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1792011601563106412 X-GMAIL-MSGID: 1792011648890368328 From: Ban Feng NCT7363Y is an I2C based hardware monitoring chip from Nuvoton. Signed-off-by: Ban Feng --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/nct7363.rst | 33 +++ MAINTAINERS | 2 + drivers/hwmon/Kconfig | 11 + drivers/hwmon/Makefile | 1 + drivers/hwmon/nct7363.c | 412 ++++++++++++++++++++++++++++++++ 6 files changed, 460 insertions(+) create mode 100644 Documentation/hwmon/nct7363.rst create mode 100644 drivers/hwmon/nct7363.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index c7ed1f73ac06..302f954b45be 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -165,6 +165,7 @@ Hardware Monitoring Kernel Drivers mp5990 nct6683 nct6775 + nct7363 nct7802 nct7904 npcm750-pwm-fan diff --git a/Documentation/hwmon/nct7363.rst b/Documentation/hwmon/nct7363.rst new file mode 100644 index 000000000000..89699c95aa4b --- /dev/null +++ b/Documentation/hwmon/nct7363.rst @@ -0,0 +1,33 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver nct7363 +===================== + +Supported chip: + + * Nuvoton NCT7363Y + + Prefix: nct7363 + + Addresses: I2C 0x20, 0x21, 0x22, 0x23 + +Author: Ban Feng + + +Description +----------- + +The NCT7363Y is a Fan controller which provides up to 16 independent +FAN input monitors, and up to 16 independent PWM output with SMBus interface. + + +Sysfs entries +------------- + +Currently, the driver supports the following features: + +======================= ======================================================= +fanX_input provide current fan rotation value in RPM + +pwmX get or set PWM fan control value. +======================= ======================================================= diff --git a/MAINTAINERS b/MAINTAINERS index 7b1efefed7c4..7ca66b713e30 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -15089,6 +15089,8 @@ M: Ban Feng L: linux-hwmon@vger.kernel.org S: Maintained F: Documentation/devicetree/bindings/hwmon/nuvoton,nct7363.yaml +F: Documentation/hwmon/nct7363.rst +F: drivers/hwmon/nct7363.c NETDEVSIM M: Jakub Kicinski diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index a608264da87d..a297b5409b04 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1616,6 +1616,17 @@ config SENSORS_NCT6775_I2C This driver can also be built as a module. If so, the module will be called nct6775-i2c. +config SENSORS_NCT7363 + tristate "Nuvoton NCT7363Y" + depends on I2C + select REGMAP_I2C + help + If you say yes here you get support for the Nuvoton NCT7363Y, + hardware monitoring chip. + + This driver can also be built as a module. If so, the module + will be called nct7363. + config SENSORS_NCT7802 tristate "Nuvoton NCT7802Y" depends on I2C diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 47be39af5c03..d5e7531204df 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -167,6 +167,7 @@ obj-$(CONFIG_SENSORS_NCT6775_CORE) += nct6775-core.o nct6775-objs := nct6775-platform.o obj-$(CONFIG_SENSORS_NCT6775) += nct6775.o obj-$(CONFIG_SENSORS_NCT6775_I2C) += nct6775-i2c.o +obj-$(CONFIG_SENSORS_NCT7363) += nct7363.o obj-$(CONFIG_SENSORS_NCT7802) += nct7802.o obj-$(CONFIG_SENSORS_NCT7904) += nct7904.o obj-$(CONFIG_SENSORS_NPCM7XX) += npcm750-pwm-fan.o diff --git a/drivers/hwmon/nct7363.c b/drivers/hwmon/nct7363.c new file mode 100644 index 000000000000..c79d3ca4f111 --- /dev/null +++ b/drivers/hwmon/nct7363.c @@ -0,0 +1,412 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Copyright (c) 2023 Nuvoton Technology corporation. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define NCT7363_REG_GPIO_0_3 0x20 +#define NCT7363_REG_GPIO_4_7 0x21 +#define NCT7363_REG_GPIO_10_13 0x22 +#define NCT7363_REG_GPIO_14_17 0x23 +#define NCT7363_REG_PWMEN_0_7 0x38 +#define NCT7363_REG_PWMEN_8_15 0x39 +#define NCT7363_REG_FANINEN_0_7 0x41 +#define NCT7363_REG_FANINEN_8_15 0x42 +#define NCT7363_REG_FANINX_HVAL(x) (0x48 + ((x) * 2)) +#define NCT7363_REG_FANINX_LVAL(x) (0x49 + ((x) * 2)) +#define NCT7363_REG_FSCPXDUTY(x) (0x90 + ((x) * 2)) + +#define PWM_SEL(x) (BIT(0) << (((x) % 4) * 2)) +#define FANIN_SEL(x) (BIT(1) << (((x) % 4) * 2)) + +#define NCT7363_FANINX_LVAL_MASK GENMASK(4, 0) +#define NCT7363_FANIN_MASK GENMASK(12, 0) + +#define NCT7363_PWM_COUNT 16 + +static inline unsigned long FAN_FROM_REG(u16 val) +{ + /* In case fan is stopped or divide by 0 */ + if (val == NCT7363_FANIN_MASK || val == 0) + return 0; + + return (1350000UL / val); +} + +static const struct of_device_id nct7363_of_match[] = { + { .compatible = "nuvoton,nct7363" }, + { }, +}; +MODULE_DEVICE_TABLE(of, nct7363_of_match); + +struct nct7363_data { + struct regmap *regmap; + struct mutex lock; /* protect register access */ + + u16 fanin_mask; + u16 pwm_mask; +}; + +static int nct7363_read_fan(struct device *dev, u32 attr, int channel, + long *val) +{ + struct nct7363_data *data = dev_get_drvdata(dev); + unsigned int hi, lo; + u16 cnt, rpm; + int ret = 0; + + switch (attr) { + case hwmon_fan_input: + /* + * High-byte register should be read first to latch + * synchronous low-byte value + */ + ret = regmap_read(data->regmap, + NCT7363_REG_FANINX_HVAL(channel), &hi); + if (ret) + return ret; + + ret = regmap_read(data->regmap, + NCT7363_REG_FANINX_LVAL(channel), &lo); + if (ret) + return ret; + + cnt = (hi << 5) | (lo & NCT7363_FANINX_LVAL_MASK); + rpm = FAN_FROM_REG(cnt); + *val = (long)rpm; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_fan_is_visible(const void *_data, u32 attr, int channel) +{ + const struct nct7363_data *data = _data; + + switch (attr) { + case hwmon_fan_input: + if (data->fanin_mask & BIT(channel)) + return 0444; + break; + default: + break; + } + + return 0; +} + +static int nct7363_read_pwm(struct device *dev, u32 attr, int channel, + long *val) +{ + struct nct7363_data *data = dev_get_drvdata(dev); + unsigned int regval; + u16 ret; + + switch (attr) { + case hwmon_pwm_input: + ret = regmap_read(data->regmap, + NCT7363_REG_FSCPXDUTY(channel), ®val); + if (ret) + return ret; + + *val = (long)regval; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int nct7363_write_pwm(struct device *dev, u32 attr, int channel, + long val) +{ + struct nct7363_data *data = dev_get_drvdata(dev); + int ret; + + switch (attr) { + case hwmon_pwm_input: + if (val < 0 || val > 255) + return -EINVAL; + + mutex_lock(&data->lock); + ret = regmap_write(data->regmap, + NCT7363_REG_FSCPXDUTY(channel), val); + mutex_unlock(&data->lock); + + return ret; + + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_pwm_is_visible(const void *_data, u32 attr, int channel) +{ + const struct nct7363_data *data = _data; + + switch (attr) { + case hwmon_pwm_input: + if (data->pwm_mask & BIT(channel)) + return 0644; + break; + default: + break; + } + + return 0; +} + +static int nct7363_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + switch (type) { + case hwmon_fan: + return nct7363_read_fan(dev, attr, channel, val); + case hwmon_pwm: + return nct7363_read_pwm(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static int nct7363_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) +{ + switch (type) { + case hwmon_pwm: + return nct7363_write_pwm(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static umode_t nct7363_is_visible(const void *data, + enum hwmon_sensor_types type, + u32 attr, int channel) +{ + switch (type) { + case hwmon_fan: + return nct7363_fan_is_visible(data, attr, channel); + case hwmon_pwm: + return nct7363_pwm_is_visible(data, attr, channel); + default: + return 0; + } +} + +static const struct hwmon_channel_info *nct7363_info[] = { + HWMON_CHANNEL_INFO(fan, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT, + HWMON_F_INPUT), + HWMON_CHANNEL_INFO(pwm, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT, + HWMON_PWM_INPUT), + NULL +}; + +static const struct hwmon_ops nct7363_hwmon_ops = { + .is_visible = nct7363_is_visible, + .read = nct7363_read, + .write = nct7363_write, +}; + +static const struct hwmon_chip_info nct7363_chip_info = { + .ops = &nct7363_hwmon_ops, + .info = nct7363_info, +}; + +static int nct7363_init_chip(struct nct7363_data *data) +{ + u8 i, gpio0_3 = 0, gpio4_7 = 0, gpio10_13 = 0, gpio14_17 = 0; + int ret; + + for (i = 0; i < NCT7363_PWM_COUNT; i++) { + if (i < 4) { + if (data->pwm_mask & BIT(i)) + gpio0_3 |= PWM_SEL(i); + if (data->fanin_mask & BIT(i)) + gpio10_13 |= FANIN_SEL(i); + } else if (i < 8) { + if (data->pwm_mask & BIT(i)) + gpio4_7 |= PWM_SEL(i); + if (data->fanin_mask & BIT(i)) + gpio14_17 |= FANIN_SEL(i); + } else if (i < 12) { + if (data->pwm_mask & BIT(i)) + gpio10_13 |= PWM_SEL(i); + if (data->fanin_mask & BIT(i)) + gpio0_3 |= FANIN_SEL(i); + } else { + if (data->pwm_mask & BIT(i)) + gpio14_17 |= PWM_SEL(i); + if (data->fanin_mask & BIT(i)) + gpio4_7 |= FANIN_SEL(i); + } + } + + /* Pin Function Configuration */ + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_0_3, gpio0_3); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_4_7, gpio4_7); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_10_13, gpio10_13); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_GPIO_14_17, gpio14_17); + if (ret < 0) + return ret; + + /* PWM and FANIN Monitoring Enable */ + ret = regmap_write(data->regmap, NCT7363_REG_PWMEN_0_7, + data->pwm_mask & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_PWMEN_8_15, + (data->pwm_mask >> 8) & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_FANINEN_0_7, + data->fanin_mask & 0xff); + if (ret < 0) + return ret; + ret = regmap_write(data->regmap, NCT7363_REG_FANINEN_8_15, + (data->fanin_mask >> 8) & 0xff); + if (ret < 0) + return ret; + + return 0; +} + +static int nct7363_present_pwm_fanin(struct device *dev, + struct device_node *child, + struct nct7363_data *data) +{ + struct of_phandle_args args; + int ret, fanin_cnt; + u8 *fanin_ch; + u8 ch, index; + + ret = of_parse_phandle_with_args(child, "pwms", "#pwm-cells", + 0, &args); + if (ret) + return ret; + + data->pwm_mask |= BIT(args.args[0]); + + fanin_cnt = of_property_count_u8_elems(child, "tach-ch"); + if (fanin_cnt < 1) + return -EINVAL; + + fanin_ch = devm_kcalloc(dev, fanin_cnt, sizeof(*fanin_ch), GFP_KERNEL); + if (!fanin_ch) + return -ENOMEM; + + ret = of_property_read_u8_array(child, "tach-ch", fanin_ch, fanin_cnt); + if (ret) + return ret; + + for (ch = 0; ch < fanin_cnt; ch++) { + index = fanin_ch[ch]; + data->fanin_mask |= BIT(index); + } + + return 0; +} + +static const struct regmap_config nct7363_regmap_config = { + .reg_bits = 8, + .val_bits = 8, +}; + +static int nct7363_probe(struct i2c_client *client) +{ + struct device *dev = &client->dev; + struct device_node *child; + struct nct7363_data *data; + struct device *hwmon_dev; + int ret; + + data = devm_kzalloc(dev, sizeof(*data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->regmap = devm_regmap_init_i2c(client, &nct7363_regmap_config); + if (IS_ERR(data->regmap)) + return PTR_ERR(data->regmap); + + mutex_init(&data->lock); + + for_each_child_of_node(dev->of_node, child) { + ret = nct7363_present_pwm_fanin(dev, child, data); + if (ret) { + of_node_put(child); + return ret; + } + } + + /* Initialize the chip */ + ret = nct7363_init_chip(data); + if (ret) + return ret; + + hwmon_dev = + devm_hwmon_device_register_with_info(dev, client->name, data, + &nct7363_chip_info, NULL); + return PTR_ERR_OR_ZERO(hwmon_dev); +} + +static struct i2c_driver nct7363_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "nct7363", + .of_match_table = nct7363_of_match, + }, + .probe = nct7363_probe, +}; + +module_i2c_driver(nct7363_driver); + +MODULE_AUTHOR("CW Ho "); +MODULE_AUTHOR("Ban Feng "); +MODULE_DESCRIPTION("NCT7363 Hardware Monitoring Driver"); +MODULE_LICENSE("GPL");