From patchwork Mon May 20 03:03:19 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 1936876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.a=rsa-sha256 header.s=mail181024 header.b=xhltVXsE; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:40f1:3f00::1; helo=sy.mirrors.kernel.org; envelope-from=linux-pwm+bounces-2182-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org [IPv6:2604:1380:40f1:3f00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VjMpZ0WNTz20PV for ; Mon, 20 May 2024 13:03:50 +1000 (AEST) 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 sy.mirrors.kernel.org (Postfix) with ESMTPS id D2796B21258 for ; Mon, 20 May 2024 03:03:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A9F2AF9C9; Mon, 20 May 2024 03:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="xhltVXsE" X-Original-To: linux-pwm@vger.kernel.org Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 28F0D9475 for ; Mon, 20 May 2024 03:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.36.163.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716174218; cv=none; b=WuL09QoiP4lScnlZUMJ94dyxfSER7rzK+vO0nFhVXw8+RApjn9Rf79p67dh0XD1kHCh2d4kfzNdc8B/RB9njWFPhZEFSriIHY9mGPgEyA5f/chMMZuVE9BVT//Ov22SFIugp6A5pBZJCWACPMT0qLGX6WihTP6daPHJS+tQ+dGs= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716174218; c=relaxed/simple; bh=vYPIVnU/6/vOoV/WNN88mzsJ22V4J/K72IQvoqz+eQw=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=aWsWn3d+vK3qf2nLioRxvPRaKZxzxwLsmitpNBfTY3sKxfQHBt9unZcvrVevrCQtxN9Q9PpEqkbfZRFNveFUPR/Cl76MZAJWZ6tK9t6GFL4q9w5WzJ/diJhI1rop0vh0RmTxatEhMZT1ZGV2a/Q9VKcKcqIw9vpm6OjC9bzss5c= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz; spf=pass smtp.mailfrom=alliedtelesis.co.nz; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b=xhltVXsE; arc=none smtp.client-ip=202.36.163.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alliedtelesis.co.nz Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 913B22C031D; Mon, 20 May 2024 15:03:26 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1716174206; bh=GpDG4VenMkr2tJn/OuFbp9IDJ9KdkQr6+CcyVhSPNIg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=xhltVXsEX8V5z2M6/mwihRQ+sYAWyarBNWQzf597Kuqz1NNOuqQa8BW3FCNLE2qbN hlVkyNbdDD8pQisRu42cisQuPX9G7D4YEnHEyQrSqQ9G0VxGJC0QcsHaYdH8AUZU5V 3yMXmGHB2Jzd7ba2GT6FeqyH3VniVaK87BdlldgrMjxKLJyQtYdlSP2vqt7DbIc+R3 eoQsokVzxOEb7Bp9VdKiqCPml9gZoF5SNYSa+nOdPFf+TUsw1YBbCff5nVQdXEThuX K2bzRM9LJcfKUu2xtlIf+/gNVGeKwuA9KJLeFyPGm/9cTgOrXJ50SX2rlIUTVpx8or 6+UPiIg+myI/w== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 20 May 2024 15:03:26 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 5F24113EE4F; Mon, 20 May 2024 15:03:26 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 5B2E9280420; Mon, 20 May 2024 15:03:26 +1200 (NZST) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, ukleinek@kernel.org Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, Chris Packham Subject: [PATCH v3 1/3] dt-bindings: hwmon: Add adt7475 fan/pwm properties Date: Mon, 20 May 2024 15:03:19 +1200 Message-ID: <20240520030321.3756604-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240520030321.3756604-1-chris.packham@alliedtelesis.co.nz> References: <20240520030321.3756604-1-chris.packham@alliedtelesis.co.nz> Precedence: bulk X-Mailing-List: linux-pwm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.4 cv=F9L0dbhN c=1 sm=1 tr=0 ts=664abd7e a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=TpHVaj0NuXgA:10 a=nd0hpPEdzzsPhCuWCasA:9 a=3ZKOabzyN94A:10 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Add fan child nodes that allow describing the connections for the ADT7475 to the fans it controls. This also allows setting some initial values for the pwm duty cycle and frequency. Signed-off-by: Chris Packham --- Notes: Changes in v3: - Use the pwm provider/consumer bindings Changes in v2: - Document 0 as a valid value (leaves hardware as-is) .../devicetree/bindings/hwmon/adt7475.yaml | 25 ++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/adt7475.yaml b/Documentation/devicetree/bindings/hwmon/adt7475.yaml index 051c976ab711..99bd689ae0cd 100644 --- a/Documentation/devicetree/bindings/hwmon/adt7475.yaml +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -51,6 +51,15 @@ properties: enum: [0, 1] default: 1 + "#pwm-cells": + const: 4 + description: | + Number of cells in a PWM specifier. + - 0: The pwm channel + - 1: The pwm frequency in hertz - 0, 11, 14, 22, 29, 35, 44, 58, 88, 22500 + - 2: PWM flags 0 or PWM_POLARITY_INVERTED + - 3: The default pwm duty cycle - 0-255 + patternProperties: "^adi,bypass-attenuator-in[0-4]$": description: | @@ -81,6 +90,10 @@ patternProperties: - smbalert# - gpio + "^fan-[0-9]+$": + $ref: fan-common.yaml# + unevaluatedProperties: false + required: - compatible - reg @@ -89,11 +102,12 @@ additionalProperties: false examples: - | + #include i2c { #address-cells = <1>; #size-cells = <0>; - hwmon@2e { + pwm: hwmon@2e { compatible = "adi,adt7476"; reg = <0x2e>; adi,bypass-attenuator-in0 = <1>; @@ -101,5 +115,14 @@ examples: adi,pwm-active-state = <1 0 1>; adi,pin10-function = "smbalert#"; adi,pin14-function = "tach4"; + #pwm-cells = <4>; + + fan-0 { + pwms = <&pwm 0 22500 PWM_POLARITY_INVERTED 255>; + }; + + fan-1 { + pwms = <&pwm 2 22500 PWM_POLARITY_INVERTED 255>; + }; }; }; From patchwork Mon May 20 03:03:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 1936878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.a=rsa-sha256 header.s=mail181024 header.b=HI34v6Ch; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=147.75.199.223; helo=ny.mirrors.kernel.org; envelope-from=linux-pwm+bounces-2183-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [147.75.199.223]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VjMpd61qqz20KG for ; Mon, 20 May 2024 13:03:53 +1000 (AEST) 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 E81251C20F4B for ; Mon, 20 May 2024 03:03:51 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E7E15FC1D; Mon, 20 May 2024 03:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="HI34v6Ch" X-Original-To: linux-pwm@vger.kernel.org Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 320F6D2F0 for ; Mon, 20 May 2024 03:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.36.163.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716174218; cv=none; b=XWDYeucXuBXWbWnpqOf5iao1pOhBvRPPCRJXP3lk77YS9TspIozOjCyqczBojp7LQYheJwkl1shtSkvKIhOI1R4lNJCQciqmkBhiunGdLqep3+ZjqfiCcZk3ZmAT6OMVh+NKK9UsqRaU196NvUOqRcdqYaCkstTF7nAVGngxIlg= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716174218; c=relaxed/simple; bh=MBxTA2zQx0pZlq6BZ7RD1+lBsfooOF9aS3XEvy31nVg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=nwxsg6TRnsO/OnkRIORkTzOa23gA+cfxTCG59Tgx3JJb1Q+qCoNgaUE2YTOtsITRU6YBtavYjDNECbOl2suj6+5UmkNvPVmRbQ9Cm2yFsfihXDJgVdfXWJYlvsLqQ/k1S80vWFFCiXkKOMQaiyedhh6RBpfiXKw3QNj+2APfNeY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz; spf=pass smtp.mailfrom=alliedtelesis.co.nz; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b=HI34v6Ch; arc=none smtp.client-ip=202.36.163.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alliedtelesis.co.nz Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id B6FF02C05E6; Mon, 20 May 2024 15:03:26 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1716174206; bh=PP8I/h6TurMIh4d3JTHdZaDPCLL7yfRyKCJAU8JYWEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=HI34v6ChIVhoaIMRiMTYaOTPwgpKJXCm43jt8hL0/yxFQ1vEnCQq0zDOF4+oVCVTK tAvjgTUeodwn4LL1Q8eZ8g0xpgxXRHRNv0F6WSk5dAhSrIp8VihFUGIuuYzOW3dppY CDfTtnGC8YTHfbLb/i3QvvOKADTfGkRw0ePVGOWB0uNYxN8p5hpz4OgQhWJVXCJc6u Gt9acR6bHy+WEhr4hyxg6t6fRlop6VwgM/xBEc3oLlaORsg2GyKNspG6oqMU10ciF6 6eD6iBJNMOG+JE+9EFR4OFXawmFQ8pN6YX1e/HEh1Qpmz5laobLfC2DBRBy6iE3mwL 37IJToC0sth5A== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 20 May 2024 15:03:26 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 625D913EE83; Mon, 20 May 2024 15:03:26 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 5DBCE280CB6; Mon, 20 May 2024 15:03:26 +1200 (NZST) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, ukleinek@kernel.org Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, Chris Packham Subject: [PATCH v3 2/3] dt-bindings: hwmon: adt7475: Deprecate adi,pwm-active-state Date: Mon, 20 May 2024 15:03:20 +1200 Message-ID: <20240520030321.3756604-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240520030321.3756604-1-chris.packham@alliedtelesis.co.nz> References: <20240520030321.3756604-1-chris.packham@alliedtelesis.co.nz> Precedence: bulk X-Mailing-List: linux-pwm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.4 cv=F9L0dbhN c=1 sm=1 tr=0 ts=664abd7e a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=TpHVaj0NuXgA:10 a=A1YWOaG1RMH6ymt1ZYoA:9 a=3ZKOabzyN94A:10 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Now that we have fan child nodes that can specify flags for the PWM outputs we no longer need the adi,pwm-active-state property. Signed-off-by: Chris Packham --- Notes: Changes in v3: - New Documentation/devicetree/bindings/hwmon/adt7475.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/hwmon/adt7475.yaml b/Documentation/devicetree/bindings/hwmon/adt7475.yaml index 99bd689ae0cd..3d4f9266f0e3 100644 --- a/Documentation/devicetree/bindings/hwmon/adt7475.yaml +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -45,6 +45,7 @@ properties: the pwm uses a logic low output for 100% duty cycle. If set to 1 the pwm uses a logic high output for 100% duty cycle. $ref: /schemas/types.yaml#/definitions/uint32-array + deprecated: true minItems: 3 maxItems: 3 items: @@ -112,7 +113,6 @@ examples: reg = <0x2e>; adi,bypass-attenuator-in0 = <1>; adi,bypass-attenuator-in1 = <0>; - adi,pwm-active-state = <1 0 1>; adi,pin10-function = "smbalert#"; adi,pin14-function = "tach4"; #pwm-cells = <4>; From patchwork Mon May 20 03:03:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 1936875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.a=rsa-sha256 header.s=mail181024 header.b=Zaoofn8G; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org (client-ip=2604:1380:45d1:ec00::1; helo=ny.mirrors.kernel.org; envelope-from=linux-pwm+bounces-2181-incoming=patchwork.ozlabs.org@vger.kernel.org; receiver=patchwork.ozlabs.org) Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org [IPv6:2604:1380:45d1:ec00::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VjMpY09Wfz20KG for ; Mon, 20 May 2024 13:03:49 +1000 (AEST) 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 33E8B1C20F9E for ; Mon, 20 May 2024 03:03:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id A1003F505; Mon, 20 May 2024 03:03:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="Zaoofn8G" X-Original-To: linux-pwm@vger.kernel.org Received: from gate2.alliedtelesis.co.nz (gate2.alliedtelesis.co.nz [202.36.163.20]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 35D6DD52E for ; Mon, 20 May 2024 03:03:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=202.36.163.20 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716174218; cv=none; b=PJF+ht09mtW271EuEa4ZT9wP7Jc4p8U9BqavEyoErQ16PQzAlNCysHrWqkBAi4NO7kU89tbOHJZVOnnXqAfI4FxJgreeaqV7JaDLNy3Yf9bKptN1kxViWMT+icK0vdEW7X18XdEjZq6HTUmaA+L6YJQA0SbwmetKXDHh5YhQG7A= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1716174218; c=relaxed/simple; bh=IGj5kRKmq3n+WvTh+8fKpl07otq/0zDRJPWb+zfXshc=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=SxRzZ+NTsauvWUPx2vEZ+d8cXMAMi9N0fuo2VTCU6M9HZZ6dT043C4L0rd8Ctv7aalKXWtzV5PsXyySPI7UpTiW/8Sh3rSF+VnPXSSnsWbVwCIZ9WqKdtEQKKtkdAdzufm650ZRcOpJlmkx1vNGHsd+4tf9FndZ72oMfUh7U3WQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz; spf=pass smtp.mailfrom=alliedtelesis.co.nz; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b=Zaoofn8G; arc=none smtp.client-ip=202.36.163.20 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=alliedtelesis.co.nz Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alliedtelesis.co.nz Received: from svr-chch-seg1.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id C27472C061C; Mon, 20 May 2024 15:03:26 +1200 (NZST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1716174206; bh=b9qzEaQJl1Fq0z1Dc4J4cdeNmSzNgDpWQiImhbo4eN0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Zaoofn8G6Br/cFFjD9ge1Zd/mw0CpDVC4UOctapKzSpw42vpkowtEWD7zzDIc+Srh vVnXewdi2+OPKhwIdvaPzB462kjRXkp3r5Fv+W8/eUgjf+dFyayj/kHO/4r61JNjqN cxmIB7gsDyWZwA+x+TsOu0ZaGz8tqLIpuvgBa5/OWeyH17zHT2YibVh1RgXWaHt8y8 HmyrMYJZsewn4J3IqW++jex50oHyxqKeGPKkh3bCn4RDBbv+QVARF2MlgE053/8ASd 6OvCXsHUE54c5+NRIgEaWuZM+fIBkTdvBLXqIdl/g66hVLBoyinc1RM253Pn0cppq/ 53+TyvOD5Ug4A== Received: from pat.atlnz.lc (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 20 May 2024 15:03:26 +1200 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by pat.atlnz.lc (Postfix) with ESMTP id 67C8913EE4F; Mon, 20 May 2024 15:03:26 +1200 (NZST) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 651FA280C1C; Mon, 20 May 2024 15:03:26 +1200 (NZST) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, ukleinek@kernel.org Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pwm@vger.kernel.org, Chris Packham Subject: [PATCH v3 3/3] hwmon: (adt7475) Add support for configuring initial PWM state Date: Mon, 20 May 2024 15:03:21 +1200 Message-ID: <20240520030321.3756604-4-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.45.1 In-Reply-To: <20240520030321.3756604-1-chris.packham@alliedtelesis.co.nz> References: <20240520030321.3756604-1-chris.packham@alliedtelesis.co.nz> Precedence: bulk X-Mailing-List: linux-pwm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.4 cv=F9L0dbhN c=1 sm=1 tr=0 ts=664abd7e a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=TpHVaj0NuXgA:10 a=p7mM90n0AGoxUC-S2eYA:9 a=3ZKOabzyN94A:10 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat By default the PWM duty cycle in hardware is 100%. On some systems this can cause unwanted fan noise. Add the ability to specify the fan connections and initial state of the PWMs via device properties. Signed-off-by: Chris Packham --- Notes: Changes in v3: - Use the pwm provider/consumer bindings Changes in v2: - Use correct device property string for frequency - Allow -EINVAL and only warn on error - Use a frequency of 0 to indicate that the hardware should be left as-is drivers/hwmon/adt7475.c | 63 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 4224ffb30483..2b8f39c1d76f 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -21,6 +21,8 @@ #include #include +#include + /* Indexes for the sysfs hooks */ #define INPUT 0 @@ -1662,6 +1664,63 @@ static int adt7475_set_pwm_polarity(struct i2c_client *client) return 0; } +static int adt7475_fan_pwm_config(struct i2c_client *client) +{ + struct adt7475_data *data = i2c_get_clientdata(client); + struct fwnode_handle *child; + struct of_phandle_args args = {}; + int ret, pwm, duty, freq, flags; + u8 val; + + device_for_each_child_node(&client->dev, child) { + if (!is_of_node(child)) + continue; + + ret = of_parse_phandle_with_args(to_of_node(child), "pwms", "#pwm-cells", 0, &args); + if (ret) + return ret; + + if (args.args_count != 4) + return -EINVAL; + + pwm = args.args[0]; + freq = find_closest(args.args[1], pwmfreq_table, ARRAY_SIZE(pwmfreq_table)); + flags = args.args[2]; + duty = clamp_val(args.args[3], 0, 0xFF); + + if (pwm >= ADT7475_PWM_COUNT) + return -EINVAL; + + ret = adt7475_read(PWM_CONFIG_REG(pwm)); + if (ret < 0) + return ret; + val = ret; + if (flags & PWM_POLARITY_INVERTED) + val |= BIT(4); + else + val &= ~BIT(4); + + ret = i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(pwm), val); + if (ret) + return ret; + + data->pwm[pwm][0] = duty; + ret = i2c_smbus_write_byte_data(client, PWM_REG(pwm), data->pwm[pwm][0]); + if (ret) + return ret; + + data->range[pwm] = adt7475_read(TEMP_TRANGE_REG(pwm)); + data->range[pwm] &= ~0xf; + data->range[pwm] |= freq; + + ret = i2c_smbus_write_byte_data(client, TEMP_TRANGE_REG(pwm), data->range[pwm]); + if (ret) + return ret; + } + + return 0; +} + static int adt7475_probe(struct i2c_client *client) { enum chips chip; @@ -1778,6 +1837,10 @@ static int adt7475_probe(struct i2c_client *client) if (ret && ret != -EINVAL) dev_warn(&client->dev, "Error configuring pwm polarity\n"); + ret = adt7475_fan_pwm_config(client); + if (ret) + dev_warn(&client->dev, "Error %d configuring fan/pwm\n", ret); + /* Start monitoring */ switch (chip) { case adt7475: