From patchwork Sun May 26 18:45:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13674344 Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.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 CE6A21FA5; Sun, 26 May 2024 18:45:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.169 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716749138; cv=none; b=IPJ4M4vPPbMtc0jGsdbnh/LDdg/Dm4pRC1v64XQVkrVwc2Q1ENatcQkPMboRP0XCJqrM2t83MTjhkIwWfyzpC8OH/vCFudMAyhHn4+xdyai8ZWtDkZYgo0zn2Wr3JHDfDdSBnHzdy6XpEf5zW1Dl+R6d76P6TKMpgs8uIPCFcLg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716749138; c=relaxed/simple; bh=kBxqKZt3yNiBobYLsd+AE4sKuvGrJdLiY2b+Bt+0qno=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=bkadFg7/213RerL1ceQWdcb00RnRzjX5HvdBtlSj5tL0xiDx0SiYKpMMOYAYc2UKqbzLIxiXVlhk1/HKlycB8v6JwNbA4MPee3GZBbnCshkn0+pKopHHuX1djtWr1rJAvh3cjfW7LkQ3yQ25kuKMFSWO5UBcADdVNy0Z2QyFvEU= 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=OfgLfjod; arc=none smtp.client-ip=209.85.208.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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OfgLfjod" Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e95a1f9c53so31491101fa.0; Sun, 26 May 2024 11:45:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716749135; x=1717353935; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=miLZb61bb6eHKVsGFJqgSUKqREuKVQ85VCQ63BLN4t4=; b=OfgLfjod2vU9NMat+fTqXCOPcJsT0fTMlMP+7GLbkBWkQVhSkH5XJuzj2ZPJmUdfDy 7+wB5MIbO66zEe5bMROt35ox6jSX/holij+z1KNL3VHDYZjRnMKX4MeaR6tPxhl3fMxQ 0lYmfZ7t1nuidxj55Zn3lUseLTLEHDzjfwvDoiRnvkFkljzERcO+9UuBi1QRMD2W/9rw JoaseO251qrENwQO5LXEayrDhs+bbib6GJ4IcLrf3SxNSOfTdF/ArHobBIGiDfqeOAjr Xe7Ll7EmbIS2Y0deThbDEMz506QdXCRywdSc2vhI6NG5ED/V0pS5QHX68edp0DDmiz6t TTgg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716749135; x=1717353935; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=miLZb61bb6eHKVsGFJqgSUKqREuKVQ85VCQ63BLN4t4=; b=Ksc++e5yn2I73lISYf5NlE8uMjQQrmSizA6TV5Sb3j3fJ7FJl+4rZsAr6JwY6ql8ei sFfio8WG0MW66JrVoxKzxnEQ1xF2EcmrUrOHyussLhYPsFlxewNJjpRUskEIz49oI3oJ 6lIfNg1uxt47ErFP6VTZtfrCcxC121RsPm6qqKJ0OhMMiPHINX7P7uKU23KuAw6+bGNv ygliATAhHzUXX9xeoEYy0LVilJuvMAupSpMjXeEfcc1lBVtug3n61M2dLCt+GZFUQUPM JNNBxO+lEBCfEIFiOUHTyi8ZqfgLE1ASyBb5YIVV6knhdhS7s9CRiHrHExWRZwY3G2xu cloA== X-Forwarded-Encrypted: i=1; AJvYcCUW1egqPbbemvRNRMN3R1lSbfAB1drcHJdpIEcSisQ9Cco8vG5Dj2CpO5JFZTpwAVG4JZq+rVmIAsl2gU5w9YB7RH2kY4ASGBQ5gLSWwuCViOneGwXgc+3UTLI0XPxOF8T4PNPzr7Cnf6vDsBJyJnLYHI5vFKkb2+vVS4d8e1Xwbvu9dJNZ X-Gm-Message-State: AOJu0Yx2N67vpY/i5UEPwHjflbC9TnHlZyzTSh9LEi9ZE6UVsttN6XPQ R8eJHVe5YwyZ0kVxGq/rDrcF/Xiaa7XaQ0rEUbyA/mbgkjnnqQz8 X-Google-Smtp-Source: AGHT+IHSCfugX/hh3BML+J946B+KyEq7nhGjevAknvFRJgmvi01bsdZjuw2ImLGRO7NGEScNBD0o/g== X-Received: by 2002:a2e:b70a:0:b0:2e1:adc4:47f6 with SMTP id 38308e7fff4ca-2e95b0945d4mr45205081fa.6.1716749134608; Sun, 26 May 2024 11:45:34 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-421089cc504sm84960075e9.40.2024.05.26.11.45.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 11:45:34 -0700 (PDT) From: Christian Marangi To: Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Marangi , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 1/3] dt-bindings: hwmon: g762: Convert to yaml schema Date: Sun, 26 May 2024 20:45:23 +0200 Message-ID: <20240526184526.21010-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Convert g762 Documentation to yaml schema. Since it supports various device, change the name to g76x and add the vendor prefix. Signed-off-by: Christian Marangi --- .../devicetree/bindings/hwmon/g762.txt | 47 ----------- .../devicetree/bindings/hwmon/gmt,g76x.yaml | 83 +++++++++++++++++++ 2 files changed, 83 insertions(+), 47 deletions(-) delete mode 100644 Documentation/devicetree/bindings/hwmon/g762.txt create mode 100644 Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml diff --git a/Documentation/devicetree/bindings/hwmon/g762.txt b/Documentation/devicetree/bindings/hwmon/g762.txt deleted file mode 100644 index 6d154c4923de..000000000000 --- a/Documentation/devicetree/bindings/hwmon/g762.txt +++ /dev/null @@ -1,47 +0,0 @@ -GMT G762/G763 PWM Fan controller - -Required node properties: - - - "compatible": must be either "gmt,g762" or "gmt,g763" - - "reg": I2C bus address of the device - - "clocks": a fixed clock providing input clock frequency - on CLK pin of the chip. - -Optional properties: - - - "fan_startv": fan startup voltage. Accepted values are 0, 1, 2 and 3. - The higher the more. - - - "pwm_polarity": pwm polarity. Accepted values are 0 (positive duty) - and 1 (negative duty). - - - "fan_gear_mode": fan gear mode. Supported values are 0, 1 and 2. - -If an optional property is not set in .dts file, then current value is kept -unmodified (e.g. u-boot installed value). - -Additional information on operational parameters for the device is available -in Documentation/hwmon/g762.rst. A detailed datasheet for the device is available -at http://natisbad.org/NAS/refs/GMT_EDS-762_763-080710-0.2.pdf. - -Example g762 node: - - clocks { - #address-cells = <1>; - #size-cells = <0>; - - g762_clk: fixedclk { - compatible = "fixed-clock"; - #clock-cells = <0>; - clock-frequency = <8192>; - } - } - - g762: g762@3e { - compatible = "gmt,g762"; - reg = <0x3e>; - clocks = <&g762_clk> - fan_gear_mode = <0>; /* chip default */ - fan_startv = <1>; /* chip default */ - pwm_polarity = <0>; /* chip default */ - }; diff --git a/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml b/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml new file mode 100644 index 000000000000..bfefe49f54bf --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml @@ -0,0 +1,83 @@ +# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/gmt,g76x.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: GMT G762/G763 PWM Fan controller + +maintainers: + - Christian Marangi + +description: | + GMT G762/G763 PWM Fan controller. + + If an optional property is not set in DT, then current value is kept + unmodified (e.g. bootloader installed value). + + Additional information on operational parameters for the device is available + in Documentation/hwmon/g762.rst. A detailed datasheet for the device is available + at http://natisbad.org/NAS/refs/GMT_EDS-762_763-080710-0.2.pdf. + +properties: + compatible: + enum: + - gmt,g762 + - gmt,g763 + + reg: + maxItems: 1 + + clocks: + description: a fixed clock providing input clock frequency on CLK + pin of the chip. + maxItems: 1 + + fan_startv: + description: Fan startup voltage step + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2, 3] + + pwm_polarity: + description: PWM polarity (psotivie or negative duty) + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1] + + fan_gear_mode: + description: FAN gear mode. Configure High speed fan setting factor + $ref: /schemas/types.yaml#/definitions/uint32 + enum: [0, 1, 2] + +required: + - compatible + - reg + - clocks + +additionalProperties: false + +examples: + - | + clocks { + #address-cells = <1>; + #size-cells = <0>; + + g762_clk: fixedclk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-frequency = <8192>; + }; + }; + + i2c { + #address-cells = <1>; + #size-cells = <0>; + + g762@3e { + compatible = "gmt,g762"; + reg = <0x3e>; + clocks = <&g762_clk>; + fan_gear_mode = <0>; + fan_startv = <1>; + pwm_polarity = <0>; + }; + }; From patchwork Sun May 26 18:45:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13674345 Received: from mail-wr1-f43.google.com (mail-wr1-f43.google.com [209.85.221.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 6BE4C1A2C21; Sun, 26 May 2024 18:45:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716749139; cv=none; b=B8G1RBv3OGhXA3r5HpOjWsl6Rszmpw5rdlyx98fRDc14r/zszETALqUqZu5ScfCxTj1mjBTdMNC8ZMXv7lB0XpezkpIidCfEzYUpr7tcWp4JLrPZmPEpCSdwnGw9aRmBiOGAZ0iCU1w+bCNKKM/+svKPlUeddQua7Z2DW5Psj5w= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716749139; c=relaxed/simple; bh=Jn/oennutCbKq+bpfLRWSfWybsFguqTo2dXI8ycdh5k=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=n4keTb8m7aJoolkIaR1G2yy3CUEuIDJtJwePW7BPJyjQ/KhgxoIEdZxXD67Xd8+8U/tKkl2olTxQtDlnPUOC4GRsItqEBlokD8sS8PX/JEkdw90sDn05gIOZ7jkFrjIwYphCAEeCeLwkiuxS6+P2Qb8n9RAzB5HJZQpf3u3PweA= 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=nMSi52wv; arc=none smtp.client-ip=209.85.221.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="nMSi52wv" Received: by mail-wr1-f43.google.com with SMTP id ffacd0b85a97d-35507fc2600so2413858f8f.0; Sun, 26 May 2024 11:45:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716749136; x=1717353936; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nnzxDfpe0iPVXlvwWkWqHb0XuymYzvTbT0c38MGaPZY=; b=nMSi52wvw42VdsJ7+9DGOHH8iXdnVvCvw6pGiRJz6o9aXhnJan43ub1Jrvhp+pBpWW NmFwdQlXjpcpyKqftbtLBq/oRP9aIwHmrFqvsesZr2iJPS8sGZWHC8ahpsM9IlDsrn5m dHwqFP58D0BjUkq883gvv1jxewbV90PljzT2zmNOnnJ4C6nc9dC6qACGY2D/dJx81pWs +fC446Nrgvp726X2ZFp7oZBha9Hmy9TwyY4QjFamtu30D6nqZL0yVyhJ2q4tS5bTLiCP p1z1nKEgZm+aSJEioQtoZB/2RPu/AfVmbFjxjMtzTmAS6kuN5oFzljFDGrwfeH1vTF0l xO4A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716749136; x=1717353936; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nnzxDfpe0iPVXlvwWkWqHb0XuymYzvTbT0c38MGaPZY=; b=wUOuv68SHcn49c7HTTPTZQr8wu6GaynYMWXUPBfKLgzjdmP7ro/Vq8v+K0vxshLd+c NntJyAY2Zi86mHAjae9LE0UfVvbkxVrVkWR7KH3gzgrNepsF2L9aQF01lJjJLV0QXLz6 xX82fgILHMuINN31/k9LhNwPKQySE1mHusk3iEHNCGkU7DU2t5lcKlp1Oh84CeN89Vro dvMZDb31WWqt4PeaF6KTXXZqUnq1AHc1+pqbicuod+kvftLsYNyhTvtYXGoPAvAMGVME 9ootv8Js/6RAFl5JuY7Q/AOlbMobt+/3jfj/Uod/frznUKJO81t5zacHYgG2+KJrOOgG wqzQ== X-Forwarded-Encrypted: i=1; AJvYcCXnRqWsUYwIRtZpqLlAW8IJRfswMF0gsXlUouS+sCmg9VDvVVd4S2lXWC0szLE5Hf9J1oHJMII8BBgW5/wXZI3hGQWd7AMICzryUsWGbwEDMaljxTKwY+cJKW7b0Z5wihmuyVgPcuO++HkE1kSva5iUPZt+8DNMAG+cOQeV5sDDYNojFdwR X-Gm-Message-State: AOJu0Yw9KOUsIMMzdU+lEtfORnu0c6unFpThnGkfRN2sT7M3BflreHxN l1uV8frRNikLvG0fvQgDxqp5kyamO8r0S65caB9gOXWq7ThAVUA0 X-Google-Smtp-Source: AGHT+IElfipAR8N2uKG3K9Zf0InJRVbqv0ms/tbTMdGV5hx1RHXSHuNWaAq9BPK+MX56S6kekTfWsw== X-Received: by 2002:a5d:64ec:0:b0:358:a66:160 with SMTP id ffacd0b85a97d-3580a66021dmr2333078f8f.38.1716749135462; Sun, 26 May 2024 11:45:35 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-421089cc504sm84960075e9.40.2024.05.26.11.45.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 11:45:35 -0700 (PDT) From: Christian Marangi To: Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Marangi , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 2/3] dt-bindings: hwmon: g76x: Add support for g761 Date: Sun, 26 May 2024 20:45:24 +0200 Message-ID: <20240526184526.21010-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240526184526.21010-1-ansuelsmth@gmail.com> References: <20240526184526.21010-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for g761 PWM Fan controller. This is an exact copy of g763 with the difference that it does also support an internal clock oscillator. With clocks property not defined, the internal clock oscillator is used. Signed-off-by: Christian Marangi Reviewed-by: Conor Dooley --- Changes v2: - Drop internal-clock property .../devicetree/bindings/hwmon/gmt,g76x.yaml | 29 +++++++++++++++++-- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml b/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml index bfefe49f54bf..6dadd24efca2 100644 --- a/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml +++ b/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml @@ -4,13 +4,17 @@ $id: http://devicetree.org/schemas/hwmon/gmt,g76x.yaml# $schema: http://devicetree.org/meta-schemas/core.yaml# -title: GMT G762/G763 PWM Fan controller +title: GMT G761/G762/G763 PWM Fan controller maintainers: - Christian Marangi description: | - GMT G762/G763 PWM Fan controller. + GMT G761/G762/G763 PWM Fan controller. + + G761 supports an internal-clock hence the clocks property is optional. + If not defined, internal-clock will be used. (31KHz is the clock of + the internal crystal oscillator) If an optional property is not set in DT, then current value is kept unmodified (e.g. bootloader installed value). @@ -22,6 +26,7 @@ description: | properties: compatible: enum: + - gmt,g761 - gmt,g762 - gmt,g763 @@ -51,7 +56,17 @@ properties: required: - compatible - reg - - clocks + +if: + properties: + compatible: + contains: + enum: + - gmt,g762 + - gmt,g763 +then: + required: + - clocks additionalProperties: false @@ -80,4 +95,12 @@ examples: fan_startv = <1>; pwm_polarity = <0>; }; + + g761@1e { + compatible = "gmt,g761"; + reg = <0x1e>; + fan_gear_mode = <0>; + fan_startv = <1>; + pwm_polarity = <0>; + }; }; From patchwork Sun May 26 18:45:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13674346 Received: from mail-lj1-f181.google.com (mail-lj1-f181.google.com [209.85.208.181]) (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 B2EE11DA5F; Sun, 26 May 2024 18:45:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716749140; cv=none; b=YKHySNcHW9LBCecFKtXn0mxYkVAocmwNsV8xbZLUa6YpAVGcJpr6cu79DJ5T2c4wOcK4D4HOu/0J0Yu6QwkZkOW1lAg3yHt+4pfQsnlSsBJ8RRp9rnuKQvVpiGkte+Y1UgO10Q5TOFi5tHvxgoSHBprE0yeWjpVtBCOR8RnMlGg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716749140; c=relaxed/simple; bh=DYn2aSysUxjoJXWq3Kj3csOOiFlPojw8oWHmMl9rv6w=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SpZaI4TVbNtKbV2Mf1JEg8xQqaTcwbdhxva6162Pnpu8ix7RavwfL7CxdEHd8BBIP2/iotnRJBI1tsNwdFfcBp+j2dkMp4W4Gr4SFKLn4ygi/a/TYpfP/pWImK3MHaujeNW/LMRZF2rzZnJgI3mUxw7fdvDyqHyUCEL7GejH6o4= 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=gV4j0RmS; arc=none smtp.client-ip=209.85.208.181 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="gV4j0RmS" Received: by mail-lj1-f181.google.com with SMTP id 38308e7fff4ca-2e73359b8fbso81870081fa.2; Sun, 26 May 2024 11:45:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716749137; x=1717353937; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=K5IL9WVaL+MRAvoehS1X61pU+AcxiSLj6714R/XAATo=; b=gV4j0RmS4M2R2vQdAtIfzWJxMMYTnzBFEzKJKRllk8nuiDIXVfCvug6sNyqhDYj5Kz tciCJP6UxTvmOS8QluI5qBFBFF8GMviO9HmGovCa8TfteBIdtn9P6EcA6SFRqd01RUDO NOWfto6EgaeBB3zAjbjK7hMaQnSAoetwtYn4dRwO75n3NIUh7dfdu/oEDn9s3vgP6y4b eN4cdDHWwhQGSvyj2vnZCpPLg6C7yz3UchRoFUdh0eDB6fhWXKKCT1X9MJGH3ovcxoNe nuqDH0nnWwlLcmyiFrHsnDT1vwp6JBv+zN1aMrd7dgNyrec/9dWluKGqnL76yzhsjykP r+sA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716749137; x=1717353937; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=K5IL9WVaL+MRAvoehS1X61pU+AcxiSLj6714R/XAATo=; b=hgvXCFgleU6cycBL5zfFLHalZnqN1SkabFNH7gzQU2PhMfwcMv1alz973zbmCfJ846 ldRp796r5aYohVvt/3IFWWGcadFYtxgQ4yiE8Yl+Z99RHEzqfuG5VKXRjoMh+TstdrBP 9ZyL45qWFxOTBzKsuSIrGh8wtIRz3Jvs5ySsCEhd+gNaC/r+4SEaN1f5vNyto+xezRDD ONhqK6XqJb50hbjBiCNyVt5Rm/zf/qVwAdYXDleJIp94ZyRPipg1AH5lXkDu1uvaLU4J dwFVc6MzSFourtCwtHVs2cHshrmech8wb9raeT8JWCjiLg9EB3DlLeleTBo3hmrfrSSb 4tOA== X-Forwarded-Encrypted: i=1; AJvYcCXn3bUF4qTmIdS2iUVHpNcXcgSaToiP0hevWDOdBrFxgPOKf3uZ7q8+gO1T2Vto8U7RdMFFosdyEWsAlZMIDh4CFYXA/bOuMk1vsL+Aj4Pia++/X1bFAHEnZOrT5jcC90fsJIu/lmOzsrspRdplBWK4FcH75KKWOEawPu2Sh9USWvpM5pHz X-Gm-Message-State: AOJu0YyMVTFCCyC8YU1fiN696OZmWry5ZFjeNJufi2QTN2OrgSi2sYIr ePMJCqP0YwAkrllGQVqCZEzsQUSui/llPP56FEG5AEMVi8YoxTaM X-Google-Smtp-Source: AGHT+IFeY+DPFBdoClSgAlOqZo+Z5AKnX0cbUgFQyPiSnm2Mh4+flIRnbeMwzJIJb8B/uipjI9owZQ== X-Received: by 2002:a2e:9f0a:0:b0:2da:a3ff:5254 with SMTP id 38308e7fff4ca-2e95b042cd4mr65305581fa.1.1716749136562; Sun, 26 May 2024 11:45:36 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id 5b1f17b1804b1-421089cc504sm84960075e9.40.2024.05.26.11.45.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 26 May 2024 11:45:36 -0700 (PDT) From: Christian Marangi To: Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Christian Marangi , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v2 3/3] hwmon: g672: add support for g761 Date: Sun, 26 May 2024 20:45:25 +0200 Message-ID: <20240526184526.21010-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240526184526.21010-1-ansuelsmth@gmail.com> References: <20240526184526.21010-1-ansuelsmth@gmail.com> Precedence: bulk X-Mailing-List: linux-hwmon@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Add support for g761 PWM Fan Controller. The g761 is a copy of the g763 with the only difference of supporting and internal clock. The internal clock is used if no clocks property is defined in device node and in such case the required bit is enabled and clock handling is skipped. The internal clock oscillator runs at 31KHz. Signed-off-by: Christian Marangi --- Changes v2: - Rework handling of internal clock drivers/hwmon/g762.c | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c index af1228708e25..a00cf3245eec 100644 --- a/drivers/hwmon/g762.c +++ b/drivers/hwmon/g762.c @@ -69,6 +69,7 @@ enum g762_regs { #define G762_REG_FAN_CMD1_PWM_POLARITY 0x02 /* PWM polarity */ #define G762_REG_FAN_CMD1_PULSE_PER_REV 0x01 /* pulse per fan revolution */ +#define G761_REG_FAN_CMD2_FAN_CLOCK 0x20 /* choose internal clock*/ #define G762_REG_FAN_CMD2_GEAR_MODE_1 0x08 /* fan gear mode */ #define G762_REG_FAN_CMD2_GEAR_MODE_0 0x04 #define G762_REG_FAN_CMD2_FAN_STARTV_1 0x02 /* fan startup voltage */ @@ -115,6 +116,7 @@ enum g762_regs { struct g762_data { struct i2c_client *client; + bool internal_clock; struct clk *clk; /* update mutex */ @@ -566,6 +568,7 @@ static int do_set_fan_startv(struct device *dev, unsigned long val) #ifdef CONFIG_OF static const struct of_device_id g762_dt_match[] = { + { .compatible = "gmt,g761" }, { .compatible = "gmt,g762" }, { .compatible = "gmt,g763" }, { }, @@ -597,6 +600,21 @@ static int g762_of_clock_enable(struct i2c_client *client) if (!client->dev.of_node) return 0; + data = i2c_get_clientdata(client); + + /* + * Skip CLK detection and handling if we use internal clock. + * This is only valid for g761. + */ + data->internal_clock = of_device_is_compatible(client->dev.of_node, + "gmt,g761") && + !of_property_present(client->dev.of_node, + "clocks"); + if (data->internal_clock) { + do_set_clk_freq(&client->dev, 32768); + return 0; + } + clk = of_clk_get(client->dev.of_node, 0); if (IS_ERR(clk)) { dev_err(&client->dev, "failed to get clock\n"); @@ -616,7 +634,6 @@ static int g762_of_clock_enable(struct i2c_client *client) goto clk_unprep; } - data = i2c_get_clientdata(client); data->clk = clk; ret = devm_add_action(&client->dev, g762_of_clock_disable, data); @@ -1025,16 +1042,26 @@ ATTRIBUTE_GROUPS(g762); static inline int g762_fan_init(struct device *dev) { struct g762_data *data = g762_update_client(dev); + int ret; if (IS_ERR(data)) return PTR_ERR(data); + /* internal_clock can only be set with compatible g761 */ + if (data->internal_clock) + data->fan_cmd2 |= G761_REG_FAN_CMD2_FAN_CLOCK; + data->fan_cmd1 |= G762_REG_FAN_CMD1_DET_FAN_FAIL; data->fan_cmd1 |= G762_REG_FAN_CMD1_DET_FAN_OOC; data->valid = false; - return i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD1, - data->fan_cmd1); + ret = i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD1, + data->fan_cmd1); + if (ret) + return ret; + + return i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD2, + data->fan_cmd2); } static int g762_probe(struct i2c_client *client)