From patchwork Sat May 25 10:29:10 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13673942 Received: from mail-wr1-f48.google.com (mail-wr1-f48.google.com [209.85.221.48]) (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 3DDD12BB0A; Sat, 25 May 2024 10:29:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.48 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716632966; cv=none; b=KRVEiutZlfX/159gnSJ4EINytpD8t9L6Zq9jL+scLX8UQb8qAR6AxA4gWMZ8MM1jbvooClRxOcN+mrtFQCtGhiHIGTyHTtpH2yZLSfuUUMKiF4D7a4DaGDTbgxZB27GcI+8XWyS79iEFtFizI5zdCZOKNW90UhXySes/mcHXbZU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716632966; c=relaxed/simple; bh=kBxqKZt3yNiBobYLsd+AE4sKuvGrJdLiY2b+Bt+0qno=; h=From:To:Subject:Date:Message-ID:MIME-Version; b=KgM4R0KzgZBrDOJavWNdDDKFtr0At8wnMz4FfbVHrP0xb3tWD2k7v0zbYCZzL/yyNZLpwfy2GPBRHK+p5uohZr9fdFNL8/kAvYuU9cgO7j4mhrsOpJrxk/FKzJMQbK0xOo+qGRAomlp509S/uj8jpTu7s06F5EyDri2aNM1YhSQ= 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=H+KPAZI7; arc=none smtp.client-ip=209.85.221.48 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="H+KPAZI7" Received: by mail-wr1-f48.google.com with SMTP id ffacd0b85a97d-351d309bbecso6866885f8f.2; Sat, 25 May 2024 03:29:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716632963; x=1717237763; 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=H+KPAZI7ip822Jr+4PsnRAdtTVHfwbNM5ahPkSm73HvghqcVhAaUN5hbTfiQ/kLdq+ gKS28yi2yqFFB8FMiGR4a/vnW6DgtLOolKCBPjubU8TXAPMo9d76qchZytw7cyVJmAAA cD1mhGQ2UplxT5HIUp5OQlfnv1QsQLKd5lTWRcL7WSO3FHYv3xuWPmaQuwbSu2Z93Rk+ g7yx9s4brEUdwkmX+GhfI3e6O/YTviytQJLhwCsLIs5bD1qLs/zuoOwgCN2iZKXG9P8A kF+TbAmAiVS8JfZOGx3I8dgnsZQwi4vjVTtmaGWABxRfDc/8/WFxD86lWNXdQJK6KP05 ZMCQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716632963; x=1717237763; 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=DYq/bQdhvCg6EoH+EIiX9/lz/NZiInVae3rUz+cyGAHug+YvTYeF0Xz143BXYvvFbk brIY7cKbqV/rCkZZBLMyHz4mXO4fXnTfNFCUUQxPnSH+pdm1Tg76O7HYWJWLdRdsA8wU MWxOwECFHo8+u1b5W4ZMoAvJ1U6XMpw5/SpN+v08v2Rd0bD1N9/hApFePRKVUAcuqRM6 Ay/gzy3S8rb+6mFwZwhjiNZUeakjTFKPsXMacdk3lrAMSNsuWczkeMaiYdDacNqmaTYF KuSzGP7IyL2eaR9laUA+sSMa3Fy0evFOqjePoXPayWtidRVEO23KZM3xxrSMMRZYwlFv yThw== X-Forwarded-Encrypted: i=1; AJvYcCXdx9VHfxGhzifBjU2YAwoi5FHpyIFhhLxQHywZDler3hkSS/z8U+6nNMxr2AP5zijvwGp4meX0IcCmEp574Swtev9ttToRxF8k9nbzlTVTs2ILLelIv7UPwvMHc88XZvOaBSdR9GDCkRkejx206V+xFP7ERpDXN/jS7m/aCiN9FVrFWUgL X-Gm-Message-State: AOJu0YzKf/RtVEUJW4NalKNM7eVNiBIygwTyC7pIDt8KIY6nG9ruQZNz pHwBwR0WZLYPf+iIe2A6iv683NwvK00Un3j/0inKqvcXro5IgXSr X-Google-Smtp-Source: AGHT+IFw6LxuhUxXMFjkGKrzwVqjOrq7IxQYbP/w/ZEtUm/8Af6yDC71Wcic05SYGXlh8ur6o0seXg== X-Received: by 2002:adf:cd8a:0:b0:354:f9b4:e9b1 with SMTP id ffacd0b85a97d-3552f4fe99amr3850617f8f.27.1716632963208; Sat, 25 May 2024 03:29:23 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3557a1c918csm3674651f8f.77.2024.05.25.03.29.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 03:29:22 -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 1/3] dt-bindings: hwmon: g762: Convert to yaml schema Date: Sat, 25 May 2024 12:29:10 +0200 Message-ID: <20240525102914.22634-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 Sat May 25 10:29:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13673943 Received: from mail-wr1-f45.google.com (mail-wr1-f45.google.com [209.85.221.45]) (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 00FD22BB16; Sat, 25 May 2024 10:29:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.221.45 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716632967; cv=none; b=asDpLdeSV1pYuiS0BV8kDI3jzquZmyy8tKSLC763dTOd3RuwmzO0uFvtHz1rYs9lCDGKSqxbx+iAOvz5UV9lozoDIxqqXD+aBDHwTosXCSIMlS6rfwwjd0fxhejl34C5Bqq++sMqVbOEiPmE0O7XNuIemj/5ZQ3N8OuwC3f4SdU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716632967; c=relaxed/simple; bh=N3cigQASH5aPySn58ICfGRQpR7Ju7/mbMWtr5LCOwNs=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=ZY1m7hwtCn8WE9NE2X4Qm6lP31T5zQtg5J4U1dhEFxArZIIaBVRAe5mK3R5hj0jrd7iR0qQ/AreJWYMmLZDifYptS/dNzh2UnRFCuFsYtblF7RAoQcI64cZyM4GHH6jAh8VzFyFbi9OTfOQ11NTWkkjyZ+UMJJiQhiY1eAC6LSk= 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=dVbIbMSi; arc=none smtp.client-ip=209.85.221.45 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="dVbIbMSi" Received: by mail-wr1-f45.google.com with SMTP id ffacd0b85a97d-354faf5f1b4so2474026f8f.1; Sat, 25 May 2024 03:29:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716632964; x=1717237764; 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=CMH0rKAImsJvaTI5337Dr7Uinr6zejv64aYJwOTfOMY=; b=dVbIbMSiWd42j1FvyhRLPTlETeNiQMsnJqvi5wrGcTe6m2ivpGYYMwEU3Da88nz6ag 65R8DmwN8rx0s411spTrqO14H59zx1C9R5Uukl5VEDPbY7g+fsWbM+04FVBu41ZN16D4 OpiWWXnWHDHSc5yoSqG38u8d1JCmbZfCEHa0oy7/Wqc2GeFkrfKzyw8dxDIi4dkgAT1a 404HMij0MUwJ017HnuBlyjBOuNIkJlgbNAjaP2XglFCfapaGLJQ4cu4VGxwmjrVkhAc1 o5qVXoXjh3jpiYwpnL5fyAL4vytkWnxvExjxH6uvFoHbU/+d0H+l4Ya1lMqZQ41XrNMo jjZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716632964; x=1717237764; 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=CMH0rKAImsJvaTI5337Dr7Uinr6zejv64aYJwOTfOMY=; b=jI2chDrERmNt4CPjslzd+GHzR2APouq3dAOtE5JMwZsB7t55iTktDSZQDocoTfyW/D 4x1paNqNw1LmPrALh4WRFvURFrLfktcIcQbdVQDNEVI/nl9HSW4T2ImLcpf5mqzwcqqy kVJ5VdS1Qp6XeGCM7PVfdemyiAq/or/PWuhtM0WttQ7yp2WK8ESiPdKK4Pjr7Y5sIDto ElVYXOfzNRuxOhUhT7PymwVwlBo2RfFhhnmxh+iwYwvxm/dCVF7kafQjGscrEHo7sQmm u0tNHEHz8FlozqDsD1qb5rgyMZLA/HQdJX2l0xVaKjD3woEeNsCprJLHEVvNIM7htD5E HcZA== X-Forwarded-Encrypted: i=1; AJvYcCU9ho+5DMPtgiR/GkrdWHP33tdsBEAoFN7FhHpqR+Zz+zhMPg7krajYlf/qetGc+YpNB1QVYG/6r6C6+DXaWabaoHjcv9+DaLv2vavC98WksH6UvauS73Pcf9phbgC4jn/LgbBVNcyfJevOvL0VMsfU9rAwWPzgZOjx+yGGlPHBgA0s6ayM X-Gm-Message-State: AOJu0YwqCXKUNmpesQVoBzhBGlpwlyloYAdTRiCTW55Z4QZr34uXvkLb R6DWJIwTfIu/6SxpyWvw5oKffOZP7tHrFFsuxOs7jHFtS7UI9PL1 X-Google-Smtp-Source: AGHT+IET61yBdk7r+/rRJjoLtnHqhtah5niSswc0UxbR4Pp0Kw/VqXbz4bHX2k/A4SE4LTq0buN3Xw== X-Received: by 2002:a05:6000:bd2:b0:354:fd10:d217 with SMTP id ffacd0b85a97d-3552fe17d69mr3986636f8f.63.1716632964280; Sat, 25 May 2024 03:29:24 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3557a1c918csm3674651f8f.77.2024.05.25.03.29.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 03:29:23 -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 2/3] dt-bindings: hwmon: g76x: Add support for g761 Date: Sat, 25 May 2024 12:29:11 +0200 Message-ID: <20240525102914.22634-2-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240525102914.22634-1-ansuelsmth@gmail.com> References: <20240525102914.22634-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 oscillators. Add required logic to support this additional feature with the property gmt,internal-clock and reject invalid schema that define both internal-clock property and external clocks. Signed-off-by: Christian Marangi --- .../devicetree/bindings/hwmon/gmt,g76x.yaml | 43 +++++++++++++++++-- 1 file changed, 40 insertions(+), 3 deletions(-) diff --git a/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml b/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml index bfefe49f54bf..d6e80392d045 100644 --- a/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml +++ b/Documentation/devicetree/bindings/hwmon/gmt,g76x.yaml @@ -4,13 +4,13 @@ $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. If an optional property is not set in DT, then current value is kept unmodified (e.g. bootloader installed value). @@ -22,6 +22,7 @@ description: | properties: compatible: enum: + - gmt,g761 - gmt,g762 - gmt,g763 @@ -48,10 +49,37 @@ properties: $ref: /schemas/types.yaml#/definitions/uint32 enum: [0, 1, 2] + gmt,internal-clock: + description: Use the Internal clock instead of externally attached one + via the CLK pin. + type: boolean + required: - compatible - reg - - clocks + +allOf: + - if: + properties: + compatible: + contains: + enum: + - gmt,g762 + - gmt,g763 + then: + properties: + gmt,internal-clock: false + + required: + - clocks + + - if: + required: + - gmt,internal-clock + + then: + properties: + clocks: false additionalProperties: false @@ -80,4 +108,13 @@ examples: fan_startv = <1>; pwm_polarity = <0>; }; + + g761@1e { + compatible = "gmt,g761"; + reg = <0x1e>; + gmt,internal-clock; + fan_gear_mode = <0>; + fan_startv = <1>; + pwm_polarity = <0>; + }; }; From patchwork Sat May 25 10:29:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 13673944 Received: from mail-lj1-f176.google.com (mail-lj1-f176.google.com [209.85.208.176]) (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 44EAF2C1B8; Sat, 25 May 2024 10:29:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.176 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716632968; cv=none; b=Vc0sFRegKaSsVzjXATi5YcN30gpCz6rE0vFcEVHzx+vxc+3L+HUP1f8PG3ZFmWlKYRA+MZxWmrhiaVPyIBYOxm3KxTWlsgT+mdbGtRjg8XPB4BIt2A3cbg9hKpBI9G8MRBCZS7aArKM81lXRwIviJscayjoDtXKUCqCftbRxF9Y= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716632968; c=relaxed/simple; bh=6OojyHEHyztqo2TUt1lhXyVgSsQ0TBRoUiEL7+DxBTU=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=FcBZOXnXYlw1tD9CLmr7Dct8ojuM87YDyFZWpNnKJvA42Xa6rV4i8ciEe4KDRLRp4Fwd0pv+PuHQfHXFNJc3ck2CmmZNAn7haDoCkCnW8I4QPIGcJh2t+YAbiC5YMcRUX0gO5LG+pbN+0tXTdCMSL6qJ1LfzCOqA0t30dFF40YU= 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=USbCDJ+/; arc=none smtp.client-ip=209.85.208.176 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="USbCDJ+/" Received: by mail-lj1-f176.google.com with SMTP id 38308e7fff4ca-2e95a1f9c53so20686391fa.0; Sat, 25 May 2024 03:29:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716632965; x=1717237765; 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=5GaCh38jQb1O6dHYQUFwk+JyFUXEH9RZyCvXnxsDzbE=; b=USbCDJ+/hE39Mc55BxD6AKLSwX800hquXHyiFtjtl5rRenevZK6f2SOEgowsDvzMv9 cgC+zd+UQtK2WNpnZS68NSJnMBimXcS71STdSoAHhLrXDyW38J9F74iKyhsjsJ5UvQJN ATFJ7VgAmVqmuu4AimMMuGAipFut0lGHxFSFMrG7eiLGsFjN0Xbjlzhulye/cMqMUjl9 LKun2U+FY6Ougq5OgLrS+Ub2lCnjOb1TiMU4Hfo6lFaHG+klpgtxeQ5sIr6gKxcuBdSm 3zEolFNRQ3QQZzWc1p0JFWM1yx5CNuAhScMJ+Pf4D8hhIGLd7ws/psSxsSjJahpDLvAJ Ogtg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716632965; x=1717237765; 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=5GaCh38jQb1O6dHYQUFwk+JyFUXEH9RZyCvXnxsDzbE=; b=oLhvC3SYKZ0/9HgRm5sQPu+GG8cW3FWnV4isoFZhBmyZd5woVMLDTAMm5syYKYA4Fc r5vzAQiSxzlLS+8KnNovJJ1s6MxQJdDB0xt0Wef25MXsRrUbEKUsf7tSlG9rmmB48od+ qYur+qzelct5xVb+drxSPrIaegDua74QBOINvP5jmIgehFJt/SG9t7MpofOoNHkZmbko LPtGarFY7D1A6Qmji0GQUfEALY4iJTL+s4eAzOWZb0Kkt4UzWqt/uigvBhGJFlgcqO3F OARowg623c8nRp7/6UwbZiTuWYsYndklBX4t7ycKi4gxxwLviVpDLuPhzTjz6ZVJTdSS 4+qQ== X-Forwarded-Encrypted: i=1; AJvYcCViXg1ZhM5+Nd4SompA/EiMJ5M+V54BANll1EL9Borouox6LBcj3CDl9eU19N/HDPfgov1c2J55w3L0czHjqaLHbJaFfDD0K2cl0VC367ksKRtmWpAaFzuNxJzGWbYS+xFC1nCvY1OgY0LJqSfy7KH7tD5SeNXAxBHdFjTUrdfFXPEPCfZd X-Gm-Message-State: AOJu0YxFvi6Q583jgau4gOiBnBArZVq7FzeEBJzwXLv1Ct5FQ0g7RCzr TEfZaPQEkIExnDEFmDumOYsOcy417E/pQ8vmceuHI5OZSbLwDBGr X-Google-Smtp-Source: AGHT+IGMLzoCtvXN3m/fC+vUzmwyk+kFSoszTXTjtj7MW+NybH+4NmTDB2f1Knzfzc8OQwrwz5QaUw== X-Received: by 2002:a2e:998b:0:b0:2e1:18d:5b4f with SMTP id 38308e7fff4ca-2e95b2823e1mr28804791fa.42.1716632965244; Sat, 25 May 2024 03:29:25 -0700 (PDT) Received: from localhost.localdomain (93-34-90-105.ip49.fastwebnet.it. [93.34.90.105]) by smtp.googlemail.com with ESMTPSA id ffacd0b85a97d-3557a1c918csm3674651f8f.77.2024.05.25.03.29.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 25 May 2024 03:29:24 -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 3/3] hwmon: g672: add support for g761 Date: Sat, 25 May 2024 12:29:12 +0200 Message-ID: <20240525102914.22634-3-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240525102914.22634-1-ansuelsmth@gmail.com> References: <20240525102914.22634-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. This can be configured with the gmt,internal-clock property and in such case clock handling is skipped. Signed-off-by: Christian Marangi --- drivers/hwmon/g762.c | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/g762.c b/drivers/hwmon/g762.c index af1228708e25..1629a3141c11 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,16 @@ 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 */ + data->internal_clock = of_property_read_bool(client->dev.of_node, + "gmt,internal-clock"); + 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 +629,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); @@ -1029,12 +1041,17 @@ static inline int g762_fan_init(struct device *dev) if (IS_ERR(data)) return PTR_ERR(data); + 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); + return (i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD1, + data->fan_cmd1) | + i2c_smbus_write_byte_data(data->client, G762_REG_FAN_CMD2, + data->fan_cmd2)); } static int g762_probe(struct i2c_client *client)