From patchwork Mon Feb 17 23:46:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11387709 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A78E9138D for ; Mon, 17 Feb 2020 23:47:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7CF3C20836 for ; Mon, 17 Feb 2020 23:47:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="R39e78dJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726166AbgBQXrL (ORCPT ); Mon, 17 Feb 2020 18:47:11 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48786 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726097AbgBQXrF (ORCPT ); Mon, 17 Feb 2020 18:47:05 -0500 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 3C9AE886BF; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1581983220; bh=LCdEDn9KJ4fwe8poCq2FY9dzyr8T+/O5ezxx8nHK8bk=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=R39e78dJootCQTeSVSI1wDXS/baejRZdPkqj17MC5gc505Fp7INNxb62OLUo3bNQQ MzWJ/dhAgeer545B+cyLS5BDpCo3gY2DkUZ69CHzYTb8q9GWTqx3jdqXR9HYDrJ15Q v1jvAwXgDEj9Ei5LNuVBpik2u9JBLXUjez6PKEa9yWCuQU1YmMWdmt2NohkYe+wx0d VLEctjnOfOqR8khXdbVybKMVX8Q1vvtCEyvx+KzRCs7BnLtFO6S+kyzTRt9VrZh0dI 1Qy++8crwWT8vEVjM2msz0l3JzZu4w0lQaoA6Qmu8Vnsk3vktThhtqrdklc23QPLfd q1PwuNNf90Qfw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Tue, 18 Feb 2020 12:46:59 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 85E8713EED4; Tue, 18 Feb 2020 12:46:59 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 01FA428006C; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: logan.shaw@alliedtelesis.co.nz, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH 1/5] dt-bindings: hwmon: Document adt7475 binding Date: Tue, 18 Feb 2020 12:46:53 +1300 Message-Id: <20200217234657.9413-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> References: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Logan Shaw Add binding for adi,adt7475 and variants. Remove from trivial-devices. Signed-off-by: Logan Shaw Signed-off-by: Chris Packham --- .../devicetree/bindings/hwmon/adt7475.yaml | 57 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.yaml | 8 --- 2 files changed, 57 insertions(+), 8 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/adt7475.yaml diff --git a/Documentation/devicetree/bindings/hwmon/adt7475.yaml b/Documentation/devicetree/bindings/hwmon/adt7475.yaml new file mode 100644 index 000000000000..2252499ea201 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -0,0 +1,57 @@ +# SPDX-License-Identifier: (GPL-2.0 OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/adt7475.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: ADT7475 hwmon sensor + +maintainers: + - Jean Delvare + +description: | + The ADT7473, ADT7475, ADT7476, and ADT7490 are thermal monitors and multiple + PWN fan controllers. + + They support monitoring and controlling up to four fans (the ADT7490 can only + control up to three). They support reading a single on chip temperature + sensor and two off chip temperature sensors (the ADT7490 additionally + supports measuring up to three current external temperature sensors with + series resistance cancellation (SRC)). + + Datasheets: + https://www.onsemi.com/pub/Collateral/ADT7473-D.PDF + https://www.onsemi.com/pub/Collateral/ADT7475-D.PDF + https://www.onsemi.com/pub/Collateral/ADT7476-D.PDF + https://www.onsemi.com/pub/Collateral/ADT7490-D.PDF + + Description taken from onsemiconductors specification sheets, with minor + rephrasing. + +properties: + compatible: + enum: + - adi,adt7473 + - adi,adt7475 + - adi,adt7476 + - adi,adt7490 + + reg: + maxItems: 1 + +required: + - compatible + - reg + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + hwmon@2e { + compatible = "adi,adt7476"; + reg = <0x2e>; + }; + }; + diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index 978de7d37c66..57173ec41c30 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -34,14 +34,6 @@ properties: - adi,adt7461 # +/-1C TDM Extended Temp Range I.C - adt7461 - # +/-1C TDM Extended Temp Range I.C - - adi,adt7473 - # +/-1C TDM Extended Temp Range I.C - - adi,adt7475 - # +/-1C TDM Extended Temp Range I.C - - adi,adt7476 - # +/-1C TDM Extended Temp Range I.C - - adi,adt7490 # Three-Axis Digital Accelerometer - adi,adxl345 # Three-Axis Digital Accelerometer (backward-compatibility value "adi,adxl345" must be listed too) From patchwork Mon Feb 17 23:46:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11387719 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3500F17E8 for ; Mon, 17 Feb 2020 23:47:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 159652072C for ; Mon, 17 Feb 2020 23:47:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="DEEc8jKR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726267AbgBQXrE (ORCPT ); Mon, 17 Feb 2020 18:47:04 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48793 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726155AbgBQXrD (ORCPT ); Mon, 17 Feb 2020 18:47:03 -0500 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 681C3891A9; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1581983220; bh=lIKEtIoXS2FCD30rLdTZz7ER2jiWy8CL5ADzRqw2N9Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=DEEc8jKRKxzXG/g+Vo8jWELD/gqdXXkQ5boV1iHyUd9DKRIGXP3ywKHH/AKCGQqdf zAZWEZyVUumHPzu9N6gyLrU4n+nxOHjWsKJh67f1zEcQLsZywGpLb1vTUvqh17Kspm fo66LXjXR74v9ipM3vD3sYAvquC2lfGj/V7Or3UEYoZxexqUGQ6qaIRw6DHOODWe3h NogAfSjGkjbHMsDb5TnWMEqLiVSOqdGdP2A8DrfnIT+G46LweTdnd+4hoqKvWxOm2s 1OSwOX5oKXy1IHM4bEHpYaE6NlEVRuJwTp+BBc2YZA3vcLsh08VG0j4kuRxN4eitfJ eg9AkPR3c9vFQ== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Tue, 18 Feb 2020 12:46:59 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id A90A913EED4; Tue, 18 Feb 2020 12:46:59 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 253E928006C; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: logan.shaw@alliedtelesis.co.nz, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH 2/5] dt-bindings: hwmon: Document adt7475 bypass-attenuator property Date: Tue, 18 Feb 2020 12:46:54 +1300 Message-Id: <20200217234657.9413-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> References: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Logan Shaw Add documentation for the bypass-attenuator-in[0-4] property. Signed-off-by: Logan Shaw Signed-off-by: Chris Packham --- .../devicetree/bindings/hwmon/adt7475.yaml | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/adt7475.yaml b/Documentation/devicetree/bindings/hwmon/adt7475.yaml index 2252499ea201..61da90c82649 100644 --- a/Documentation/devicetree/bindings/hwmon/adt7475.yaml +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -39,6 +39,17 @@ properties: reg: maxItems: 1 +patternProperties: + "^bypass-attenuator-in[0-4]$": + maxItems: 1 + minimum: 0 + maximum: 1 + description: | + Configures bypassing the individual voltage input attenuator. If + set to 1 the attenuator is bypassed if set to 0 the attenuator is + not bypassed. If the property is absent then the attenuator + retains it's configuration from the bios/bootloader. + required: - compatible - reg @@ -52,6 +63,8 @@ examples: hwmon@2e { compatible = "adi,adt7476"; reg = <0x2e>; + bypass-attenuator-in0 = <1>; + bypass-attenuator-in1 = <0>; }; }; From patchwork Mon Feb 17 23:46:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11387717 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0C05F1580 for ; Mon, 17 Feb 2020 23:47:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E138E2072C for ; Mon, 17 Feb 2020 23:47:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="diM4mqD6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726281AbgBQXrE (ORCPT ); Mon, 17 Feb 2020 18:47:04 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48797 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725987AbgBQXrD (ORCPT ); Mon, 17 Feb 2020 18:47:03 -0500 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id 6EEBF891AA; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1581983220; bh=1a/51WDLn9XkdpMM9d1aDZunsHAxv048R7hDlfT3FEc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=diM4mqD6s1TuhntWRO9wJmnVRCDRUpti2kBmaE8UQ0XjxJ4lcGEHhfQ7x8uWyDpTs cpgSNlhWR69TYY+Y+2PM5pHkJLq+maXIge/t3Nctrh4c6SyrN5SfSxKwzeD2Db/Fl1 YN/XD6iFbWgFFHZn34z0HNQfRHSw/YxGtZ4ULHU/SfK+YKDQAvNC7ViugGMfENsMFT Dh2EJF69VbwiOrHXhL74KrJOyGwtmeJU55XlJ2YVq1eNC9EoH0r2imEyCLg2ZYYYBj D5E6rT16ULfUVE7/YzM4RWHOjno7yLlpkfUzCfEMd3M5bOKNV5Uu0UouOC2kWn0u9I 8FvxMcDLStoXA== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Tue, 18 Feb 2020 12:46:59 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id CAF9E13EED4; Tue, 18 Feb 2020 12:46:59 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 4745D28006C; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: logan.shaw@alliedtelesis.co.nz, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH 3/5] dt-bindings: hwmon: Document adt7475 invert-pwm property Date: Tue, 18 Feb 2020 12:46:55 +1300 Message-Id: <20200217234657.9413-4-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> References: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add binding information for the invert-pwm property. Signed-off-by: Chris Packham --- Documentation/devicetree/bindings/hwmon/adt7475.yaml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/adt7475.yaml b/Documentation/devicetree/bindings/hwmon/adt7475.yaml index 61da90c82649..c11c9a3d9a64 100644 --- a/Documentation/devicetree/bindings/hwmon/adt7475.yaml +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -50,6 +50,17 @@ patternProperties: not bypassed. If the property is absent then the attenuator retains it's configuration from the bios/bootloader. + "^invert-pwm[1-3]$": + maxItems: 1 + minimum: 0 + maximum: 1 + description: | + Configures the pwm output to use inverted logic. If set to 1 + the pwm uses a logic low output for 100% duty cycle. If set + to 0 the pwm uses a logic high output for 100% duty cycle. + If the property is absent the pwm retains it's configuration + from the bios/bootloader. + required: - compatible - reg @@ -65,6 +76,7 @@ examples: reg = <0x2e>; bypass-attenuator-in0 = <1>; bypass-attenuator-in1 = <0>; + invert-pwm1 = <1>; }; }; From patchwork Mon Feb 17 23:46:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11387715 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85C08138D for ; Mon, 17 Feb 2020 23:47:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 667E4207FD for ; Mon, 17 Feb 2020 23:47:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="VrgopT2S" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726140AbgBQXrW (ORCPT ); Mon, 17 Feb 2020 18:47:22 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48807 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726212AbgBQXrE (ORCPT ); Mon, 17 Feb 2020 18:47:04 -0500 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id B5564891AB; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1581983220; bh=cMwWq/fB5TqLaO7gJKiv9RZZ9K3gkV2WtovJnrZdpXU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=VrgopT2S8vUgdhN/m2G1B3sDNdHrEA3jqzsldNwSZx0TM3sbjuq7drEPUWKUGX2uI z6Tbyv/5/uvpg9FHHy2uA0RIdjnQjBMWSRE2fL/tA7mcTQ8Zd85H5rarhMB0NUHLLI Ak/RzTeizRr/f1cA3bM8dNn/VbMAsvZ9b6ivehWpFtYuOhj6uRR65EOiPAy+UWncup m9ZshVDCNXzwHGmxfr8hfqkIY2GJyxnkDtR38FVfU7H7rla7V52ooBlBvqYTenaDqf WJI+u9Z1/Strwn8AFxVFje/AAK39xJGD8ljnnhqcd1QPgaf0wvs1Phc4lHO5mW1OjO k2K4ID+QWgU6Q== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Tue, 18 Feb 2020 12:47:00 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id EE01513EED4; Tue, 18 Feb 2020 12:46:59 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 6A15F28006C; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: logan.shaw@alliedtelesis.co.nz, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH 4/5] hwmon: (adt7475) Add attenuator bypass support Date: Tue, 18 Feb 2020 12:46:56 +1300 Message-Id: <20200217234657.9413-5-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> References: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Logan Shaw Added support for reading DTS properties to set attenuators on device probe for the ADT7473, ADT7475, ADT7476, and ADT7490. Signed-off-by: Logan Shaw Signed-off-by: Chris Packham --- drivers/hwmon/adt7475.c | 61 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 58 insertions(+), 3 deletions(-) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 01c2eeb02aa9..4a62d633a2f5 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -19,6 +19,7 @@ #include #include #include +#include #include /* Indexes for the sysfs hooks */ @@ -193,6 +194,7 @@ struct adt7475_data { unsigned long measure_updated; bool valid; + u8 config2; u8 config4; u8 config5; u8 has_voltage; @@ -1458,6 +1460,55 @@ static int adt7475_update_limits(struct i2c_client *client) return 0; } +static int set_property_bit(const struct i2c_client *client, char *property, + u8 *config, u8 bit_index) +{ + u32 prop_value = 0; + int ret = of_property_read_u32(client->dev.of_node, property, + &prop_value); + + if (!ret) { + if (prop_value) + *config |= (1 << bit_index); + else + *config &= ~(1 << bit_index); + } + + return ret; +} + +static int load_attenuators(const struct i2c_client *client, int chip, + struct adt7475_data *data) +{ + int ret; + + if (chip == adt7476 || chip == adt7490) { + set_property_bit(client, "bypass-attenuator-in0", + &data->config4, 4); + set_property_bit(client, "bypass-attenuator-in1", + &data->config4, 5); + set_property_bit(client, "bypass-attenuator-in3", + &data->config4, 6); + set_property_bit(client, "bypass-attenuator-in4", + &data->config4, 7); + + ret = i2c_smbus_write_byte_data(client, REG_CONFIG4, + data->config4); + if (ret < 0) + return ret; + } else if (chip == adt7473 || chip == adt7475) { + set_property_bit(client, "bypass-attenuator-in1", + &data->config2, 5); + + ret = i2c_smbus_write_byte_data(client, REG_CONFIG2, + data->config2); + if (ret < 0) + return ret; + } + + return 0; +} + static int adt7475_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1472,7 +1523,7 @@ static int adt7475_probe(struct i2c_client *client, struct adt7475_data *data; struct device *hwmon_dev; int i, ret = 0, revision, group_num = 0; - u8 config2, config3; + u8 config3; data = devm_kzalloc(&client->dev, sizeof(*data), GFP_KERNEL); if (data == NULL) @@ -1546,8 +1597,12 @@ static int adt7475_probe(struct i2c_client *client, } /* Voltage attenuators can be bypassed, globally or individually */ - config2 = adt7475_read(REG_CONFIG2); - if (config2 & CONFIG2_ATTN) { + data->config2 = adt7475_read(REG_CONFIG2); + ret = load_attenuators(client, chip, data); + if (ret) + dev_err(&client->dev, "Error configuring attenuator bypass\n"); + + if (data->config2 & CONFIG2_ATTN) { data->bypass_attn = (0x3 << 3) | 0x3; } else { data->bypass_attn = ((data->config4 & CONFIG4_ATTN_IN10) >> 4) | From patchwork Mon Feb 17 23:46:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11387711 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C3CB41580 for ; Mon, 17 Feb 2020 23:47:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id A46402072C for ; Mon, 17 Feb 2020 23:47:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="fMOLdjrZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726353AbgBQXrF (ORCPT ); Mon, 17 Feb 2020 18:47:05 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:48823 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbgBQXrF (ORCPT ); Mon, 17 Feb 2020 18:47:05 -0500 Received: from mmarshal3.atlnz.lc (mmarshal3.atlnz.lc [10.32.18.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by gate2.alliedtelesis.co.nz (Postfix) with ESMTPS id BD63B891AC; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1581983220; bh=Qcs5L20LNgbbFFaZG63R6OuduRgEp8/3wC+dSc2nhA8=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=fMOLdjrZw+oVl9UKJeFT48MXGyeHCAqKxbztTP5CFC0s096+7Wu0CY/Th7eTVWQW0 CZmZuIsoZLJttuo/WQwjyZByPuRr3YHvMiy34AICWibyaqLphhw145r1uagjM1f3MD zYlAo43t7sKDXG8NS2txEYdMZZiJS43ENPtScUTo3aOoCZWpas8u9XX+uVXIWIfusj fH50s0/ksLS8JVEaJPCoItf3p/xi2BZz9wdILrMOVNhBNLvVhtx7tbZo5cOVygo1jT EoH4VwEwHHePhSAidLjQDLFcBgaVdbt8lOVmxRy6/t29K4StZvDNO3gKJhB1/hOAZJ PDZ/pv5cuqXkw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Tue, 18 Feb 2020 12:47:00 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 1CA5613EED4; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 8B6BF28006C; Tue, 18 Feb 2020 12:47:00 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: logan.shaw@alliedtelesis.co.nz, linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH 5/5] hwmon: (adt7475) Add support for inverting pwm output Date: Tue, 18 Feb 2020 12:46:57 +1300 Message-Id: <20200217234657.9413-6-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> References: <20200217234657.9413-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: linux-hwmon-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add a "invert-pwm" device-tree property to allow hardware designs to use inverted logic on the PWM output. Preserve the invert PWM output bit if the property is not found to allow for bootloaders/bios which may have configured this earlier. Signed-off-by: Chris Packham --- drivers/hwmon/adt7475.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 4a62d633a2f5..dccb1c78a57d 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -1509,6 +1509,41 @@ static int load_attenuators(const struct i2c_client *client, int chip, return 0; } +static int adt7475_set_pwm_polarity(struct i2c_client *client) +{ + char *prop; + int ret, i; + u8 val; + + for (i = 0; i < ADT7475_PWM_COUNT; i++) { + ret = adt7475_read(PWM_CONFIG_REG(i)); + if (ret < 0) + return ret; + val = ret; + switch (i) { + case 0: + prop = "invert-pwm1"; + break; + case 1: + prop = "invert-pwm2"; + break; + case 2: + prop = "invert-pwm3"; + break; + } + + ret = set_property_bit(client, prop, &val, 4); + if (ret) + continue; + + ret = i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(i), val); + if (ret) + return ret; + } + + return 0; +} + static int adt7475_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1617,6 +1652,10 @@ static int adt7475_probe(struct i2c_client *client, for (i = 0; i < ADT7475_PWM_COUNT; i++) adt7475_read_pwm(client, i); + ret = adt7475_set_pwm_polarity(client); + if (ret) + dev_err(&client->dev, "Error configuring pwm polarity"); + /* Start monitoring */ switch (chip) { case adt7475: