From patchwork Fri Feb 21 04:16:27 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11395533 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 39EEA17F0 for ; Fri, 21 Feb 2020 04:17:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 195EC20722 for ; Fri, 21 Feb 2020 04:17:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="Si4a9Ztq" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729729AbgBUEQr (ORCPT ); Thu, 20 Feb 2020 23:16:47 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:58132 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729632AbgBUEQr (ORCPT ); Thu, 20 Feb 2020 23:16:47 -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 ABC0C886BF; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582258603; bh=mvvz71fd9ax1lJ7OsfFZtFfyACbY6CnOTOhmEvtEqTE=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Si4a9Ztq3hH7cS4ZNR3118mxghrEV/upozAQllv8LVMY7rHHwhB8vy/uLE9KLjDsd BJvL/NzzxYrUZMPlVP+KORQXnojn9RLPbyHe+GGH9YtBK55RbJ303vUqmcpZR4H04c EyB2/1BpCjKuBLtKxmfzt5PjKk378ACBCsrGbGc0pE9pNvID+Rb5sStt9qTQycpp3q lx59WEldjcVJD7lM81P15/jtkSutbq5Ku+6hSrY2VAlsXdz1GCYWXxpPVMnEFG8WXh E0jL5arLO2b6u4MnpvQBESUE8Ou45q1StLPoYWDSIeTf+6fFy2dVqhFoK1yCfEpu39 vGq4RliV+/pBg== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 21 Feb 2020 17:16:44 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id D7FA513EECD; Fri, 21 Feb 2020 17:16:42 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 6A8DB28006D; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, logan.shaw@alliedtelesis.co.nz, Chris Packham Subject: [PATCH v4 1/5] dt-bindings: hwmon: Document adt7475 binding Date: Fri, 21 Feb 2020 17:16:27 +1300 Message-Id: <20200221041631.10960-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200221041631.10960-1-chris.packham@alliedtelesis.co.nz> References: <20200221041631.10960-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 Reviewed-by: Rob Herring --- Notes: Changes in v3: - split conversion to yaml from addition of new properties .../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 Fri Feb 21 04:16:28 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11395539 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 AFD5A159A for ; Fri, 21 Feb 2020 04:17:08 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8FEEA24653 for ; Fri, 21 Feb 2020 04:17:08 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="2YXdz4oF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729665AbgBUEQq (ORCPT ); Thu, 20 Feb 2020 23:16:46 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:58140 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729644AbgBUEQp (ORCPT ); Thu, 20 Feb 2020 23:16:45 -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 E1674891A9; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582258603; bh=1IbgMe7uSVweJ14EZmRPTWbfcngs93L74TZLpxRax5c=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=2YXdz4oFn2Rx6FydDlGzQynCoKZn4jiq2vCjsoR7YBclpDLJdItEDpDTI4wMShrkY AQ7PEiwmRYCjq5KgcNuyGCeIS5nCnazBFbx86l1eVcy7ZeG/hyQ7vU18fbJDX6/VtO 7mjNw3w1JHBSiZCvQGAhfD9EQAvGDJ3DZH/wfEP07pcZ5KNZi3E2J3RA16rwfz5gy9 wyTsMCoUFFeWQpd1IT8mNlYox3FRzDsrY4DlM6avHYrwCOd9E4F5+O2JPfhkIArJdQ jfYkOL+k0MmSCKhLABNoWvt/xgtHbn46zFjsNzhcMzQvCGVFCtkK57I/P8IXPolUXY ngiK/zyIRM1Lg== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 21 Feb 2020 17:16:44 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 01D4513EECD; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 8954E28006D; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, logan.shaw@alliedtelesis.co.nz, Chris Packham Subject: [PATCH v4 2/5] dt-bindings: hwmon: Document adt7475 bypass-attenuator property Date: Fri, 21 Feb 2020 17:16:28 +1300 Message-Id: <20200221041631.10960-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200221041631.10960-1-chris.packham@alliedtelesis.co.nz> References: <20200221041631.10960-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 Reviewed-by: Rob Herring --- Notes: Changes in v4: - use $ref uint32 and enum - add 'adi' vendor prefix Changes in v3: - separated addition of new properties from conversion to yaml .../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..e40612ee075f 100644 --- a/Documentation/devicetree/bindings/hwmon/adt7475.yaml +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -39,6 +39,17 @@ properties: reg: maxItems: 1 +patternProperties: + "^adi,bypass-attenuator-in[0-4]$": + 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. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: [0, 1] + required: - compatible - reg @@ -52,6 +63,8 @@ examples: hwmon@2e { compatible = "adi,adt7476"; reg = <0x2e>; + adi,bypass-attenuator-in0 = <1>; + adi,bypass-attenuator-in1 = <0>; }; }; From patchwork Fri Feb 21 04:16:29 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11395529 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 8E321138D for ; Fri, 21 Feb 2020 04:16:46 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 3BC36207FD for ; Fri, 21 Feb 2020 04:16:46 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="JznCo4/J" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729654AbgBUEQq (ORCPT ); Thu, 20 Feb 2020 23:16:46 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:58144 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729280AbgBUEQp (ORCPT ); Thu, 20 Feb 2020 23:16:45 -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 E27A0891AA; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582258603; bh=uyQ2DBeRxZwKGi/wDcdyCc4BoWSFgZunk5Ddx35iWJI=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=JznCo4/JdMKLdLlPnPztkV4QM8i3v4C9UKH5cecmxx9fRvMXJ0cAIDIThJVvvpd7i YHZcrHKKsV7r8Ga+YO/96oIAk45/AHL7D75yfOgrGPBxmDqVnbYFmzI97fYgwqlYFK gl+WNdw8Z2o/0szrySBVivRj8QCUtbrEAnxny/7bIIw+EJgD5v6zUW+MZ1EzRGWwmd u5znsyCEwqYgAkmyZm95fuVdpOgaZDzehSVw/Dlf6UDDkt09qiC+1KZoeA6GTYI6zP xiCglm2ABeik7fZYMro9slur8T5VGvRGdSgWEI9dKGBYhhN89kXP3FVpXdrokcMPu0 4qcdl9IFyKS+g== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 21 Feb 2020 17:16:44 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 211A613EECD; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id A818728006D; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, logan.shaw@alliedtelesis.co.nz, Chris Packham Subject: [PATCH v4 3/5] dt-bindings: hwmon: Document adt7475 invert-pwm property Date: Fri, 21 Feb 2020 17:16:29 +1300 Message-Id: <20200221041631.10960-4-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200221041631.10960-1-chris.packham@alliedtelesis.co.nz> References: <20200221041631.10960-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 --- Notes: Changes in v4: - use $ref uint32 and enum - add adi vendor prefix Cahnges in v3: - new 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 e40612ee075f..6a358b30586c 100644 --- a/Documentation/devicetree/bindings/hwmon/adt7475.yaml +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -50,6 +50,17 @@ patternProperties: - $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0, 1] + "^adi,invert-pwm[1-3]$": + 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. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32 + - enum: [0, 1] + required: - compatible - reg @@ -65,6 +76,7 @@ examples: reg = <0x2e>; adi,bypass-attenuator-in0 = <1>; adi,bypass-attenuator-in1 = <0>; + adi,invert-pwm1 = <1>; }; }; From patchwork Fri Feb 21 04:16:30 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11395531 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 8CBC1138D for ; Fri, 21 Feb 2020 04:16:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6BDC120722 for ; Fri, 21 Feb 2020 04:16:56 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="Unt39Dbi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729625AbgBUEQz (ORCPT ); Thu, 20 Feb 2020 23:16:55 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:58169 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729699AbgBUEQs (ORCPT ); Thu, 20 Feb 2020 23:16:48 -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 4513A891AC; Fri, 21 Feb 2020 17:16:44 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582258604; bh=JWoAVIXnFFzFVezqCwzPVSnstWKKJ4H9zsN13AoZIc4=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=Unt39DbiIhM8Y30Z+43V2P8Oj85hivyAj2GxRhd6gFw4bfkDKJQh+MvdYC1xmLjrQ EazolKvmU58PX7fJR+GGhUXHwOuy2tDulGlTzB0FKdqwi/NlRCC9NpysiJS3HyldxM 7N8RhzRdylrLVWuYbMtF6CHIRMSiGn8eHVC5E995xpROyG2aA6fx5N5Z/g+WP17y7U 0jMj2IX3A6AIOW9jQO2ZdfmJSTCZEX4Cz2LfjZfl2M7l3cGvKOKPIDVBAzPY5HB5Tv hAolzC6j3xamgbDloyGCy0nrC7lSfsJ2WdPb5bI4TgtROVeh4bbPQFU8iPSIKbkWk3 LsbskQ1jt7OSg== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 21 Feb 2020 17:16:44 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 5D5BC13EECD; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id E53AF28006D; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, logan.shaw@alliedtelesis.co.nz, Chris Packham Subject: [PATCH v4 4/5] hwmon: (adt7475) Add attenuator bypass support Date: Fri, 21 Feb 2020 17:16:30 +1300 Message-Id: <20200221041631.10960-5-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200221041631.10960-1-chris.packham@alliedtelesis.co.nz> References: <20200221041631.10960-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 --- Notes: Changes in v4: - use vendor prefix for new property Changes in v3: - move config2 to struct adt7475_data - set_property_bit() new helper function to set/clear bit based on dt property value. - rename to use load_attenuators() 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..3649b18359dc 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, "adi,bypass-attenuator-in0", + &data->config4, 4); + set_property_bit(client, "adi,bypass-attenuator-in1", + &data->config4, 5); + set_property_bit(client, "adi,bypass-attenuator-in3", + &data->config4, 6); + set_property_bit(client, "adi,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, "adi,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 Fri Feb 21 04:16:31 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 11395535 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 14F48138D for ; Fri, 21 Feb 2020 04:17:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E9194207FD for ; Fri, 21 Feb 2020 04:17:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="jR/pmPxd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729718AbgBUEQr (ORCPT ); Thu, 20 Feb 2020 23:16:47 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:58154 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729615AbgBUEQq (ORCPT ); Thu, 20 Feb 2020 23:16:46 -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 3B4EE891AB; Fri, 21 Feb 2020 17:16:44 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582258604; bh=RwLHepCx03CNEZvF3kbx50mD0JOEcmY6pn/SjTogwSg=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=jR/pmPxdWw38ncgsejH7KkxLbNfeEt8pCw1DgbTuET8+Uuk9YGsOPxykPk2QzYiVu POQZBqWT/DgyTOM2Y+Z9PHov6EuQrUMfPYvgTytH8au24H1ZHiN+EaEzHlc94YuUd5 zjjqeKJOWP5QPRh77uIfl3JvrDmL/5DSBvWC+gC3z0YnQjAz4b0lHtCM85cl3pnvMO LJnokr4OaYK0iTtCU4vEyPRRJz2sH44brrtoYJTsrfwHya9ok+eoElwXaSSbOQ2lMn 6iILQifkIfUMFwxFTrVNONEK9ffKdQDJqL5RNCLDjofcbG7OASI4bk+d0CANs6bDjb ejEKo+Cwb6Obg== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 21 Feb 2020 17:16:44 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 7BFB813EECD; Fri, 21 Feb 2020 17:16:43 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 1001028006D; Fri, 21 Feb 2020 17:16:44 +1300 (NZDT) From: Chris Packham To: jdelvare@suse.com, linux@roeck-us.net, robh+dt@kernel.org, mark.rutland@arm.com Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, logan.shaw@alliedtelesis.co.nz, Chris Packham Subject: [PATCH v4 5/5] hwmon: (adt7475) Add support for inverting pwm output Date: Fri, 21 Feb 2020 17:16:31 +1300 Message-Id: <20200221041631.10960-6-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200221041631.10960-1-chris.packham@alliedtelesis.co.nz> References: <20200221041631.10960-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 --- Notes: Changes in v4: - use vendor prefix for new property Changes in v3: - New drivers/hwmon/adt7475.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index 3649b18359dc..13267181dde6 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 = "adi,invert-pwm1"; + break; + case 1: + prop = "adi,invert-pwm2"; + break; + case 2: + prop = "adi,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: