From patchwork Thu Nov 8 22:56:06 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 10675085 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9E6E15A6 for ; Thu, 8 Nov 2018 22:56:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AAE7D2E636 for ; Thu, 8 Nov 2018 22:56:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9F3AA2E771; Thu, 8 Nov 2018 22:56:33 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 41F232E636 for ; Thu, 8 Nov 2018 22:56:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727266AbeKIIeB (ORCPT ); Fri, 9 Nov 2018 03:34:01 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:44356 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727231AbeKIIeB (ORCPT ); Fri, 9 Nov 2018 03:34:01 -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 D57CA8365D; Fri, 9 Nov 2018 11:56:11 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1541717771; bh=6MFMVJsYOxXnV8yXRYe6WaU0lNWyciNyE5lThyg4Tyo=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=oQ32LbAvLa6LaGBQ7VjOzOzMEmId6HC8sP+iMUJ8X+o05JrBkCuK0LEZ0tIjWACJz uzBjgs7Q3NhF8ICP199burvP3S0DjvNcaomnNEc29gGPRHGRcQtUszValVRlAYihge UD+umfVczlIqmF5PsXWZn3B63Q9i1wD6m+T+JInaX11BLmXfTWkN6K3sN8YGp89Pnq XVrnisVj3HHwoS9sRzx/K/98fGmIILtC945pPZE2322cbeqct3dbZkJMVfQvGflCxi 33abwDSYaIpgpcEMjwwLqd6ipE5Uz7y9BwwxQ2/hHNBL1IJbDJqPurto1sy9ehwhMT wL+dJldQFDYTQ== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 09 Nov 2018 11:56:12 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id BAE4E13EEA1; Fri, 9 Nov 2018 11:56:16 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 975911E0968; Fri, 9 Nov 2018 11:56:11 +1300 (NZDT) From: Chris Packham To: linux@roeck-us.net, robh+dt@kernel.org, jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham , Mark Rutland Subject: [PATCH v2 1/2] dt-bindings: hwmon: add binding documentation for adt7475 Date: Fri, 9 Nov 2018 11:56:06 +1300 Message-Id: <20181108225607.7521-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108225607.7521-1-chris.packham@alliedtelesis.co.nz> References: <20181108225607.7521-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 X-Virus-Scanned: ClamAV using ClamSMTP With the addition of the invert-pwm property the adt7475 needs its own binding documentation rather being captured under trivial-devices.txt. Signed-off-by: Chris Packham --- Changes in v2: - use pwm-polarity attiribute to indicate normal or inverted polarity. .../devicetree/bindings/hwmon/adt7475.txt | 24 +++++++++++++++++++ .../devicetree/bindings/trivial-devices.txt | 4 ---- 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 Documentation/devicetree/bindings/hwmon/adt7475.txt diff --git a/Documentation/devicetree/bindings/hwmon/adt7475.txt b/Documentation/devicetree/bindings/hwmon/adt7475.txt new file mode 100644 index 000000000000..d9212b5e9036 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/adt7475.txt @@ -0,0 +1,24 @@ +*ADT7475 hwmon sensor. + +Required properties: +- compatible: One of + "adi,adt7473" + "adi,adt7475" + "adi,adt7476" + "adi,adt7490" + +- reg: I2C address + +optional properties: + +- pwm-polarity: This configures the polarity of the PWM. 0 + (PWM_POLARITY_NORMAL) uses logic high for 100% duty cycle. 1 + (PWM_POLARITY_INVERSED) uses logic low for 100% duty cycle. + +Example: + +hwmon@2e { + compatible = ; + reg = <0x2e>; + pwm-polarity = <1>; +}; diff --git a/Documentation/devicetree/bindings/trivial-devices.txt b/Documentation/devicetree/bindings/trivial-devices.txt index 69c934aec13b..4f29100d6bbf 100644 --- a/Documentation/devicetree/bindings/trivial-devices.txt +++ b/Documentation/devicetree/bindings/trivial-devices.txt @@ -14,10 +14,6 @@ ad,ad7414 SMBus/I2C Digital Temperature Sensor in 6-Pin SOT with SMBus Alert an ad,adm9240 ADM9240: Complete System Hardware Monitor for uProcessor-Based Systems 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 +/-1C TDM Extended Temp Range I.C adi,adxl345 Three-Axis Digital Accelerometer adi,adxl346 Three-Axis Digital Accelerometer (backward-compatibility value "adi,adxl345" must be listed too) ams,iaq-core AMS iAQ-Core VOC Sensor From patchwork Thu Nov 8 22:56:07 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 10675083 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D84101709 for ; Thu, 8 Nov 2018 22:56:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA5612E636 for ; Thu, 8 Nov 2018 22:56:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BE83B2E771; Thu, 8 Nov 2018 22:56:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6ACB92E636 for ; Thu, 8 Nov 2018 22:56:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727451AbeKIIeB (ORCPT ); Fri, 9 Nov 2018 03:34:01 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:44366 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727223AbeKIIeA (ORCPT ); Fri, 9 Nov 2018 03:34:00 -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 15C418781F; Fri, 9 Nov 2018 11:56:12 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1541717772; bh=3icy1bdjKwYRadB8YMcxkqJOJV9nsuQSkD1bLtX/uaU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=T15MGFWgexb46ZCQ5U00ob0LLlvCSFx41c4Mti6Xazmyo5Q5/W+58kqzGnzfDQQZL mquBH2WHdqLzDTqv24ZY7EImSBjGi8dlTooruKjaaFnviY947oLB8q2z2aYSK34KT4 uNMWq/zt0vehloCTsiKaeWGtdRdtjJPjLjJ4T/WJVnhA/WWFvXgxk3E4Zaah3QjJtl Qtob8qR5OUJcbYqHrT2+ulWvjzvLPW+St+DXxdlLdZWdBv2TjNh4gW17M8/gRozdX+ 3TnSzpU+zZqb2MjE2N8Stl4aJ9GHC1H1/NCXSJLMO85ChLYdWlcLglL1p/yqETvbpN YHIbZnOjyL99w== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7,5,8,10121) id ; Fri, 09 Nov 2018 11:56:12 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.30]) by smtp (Postfix) with ESMTP id 0132013EEA1; Fri, 9 Nov 2018 11:56:17 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id B17331E0968; Fri, 9 Nov 2018 11:56:11 +1300 (NZDT) From: Chris Packham To: linux@roeck-us.net, robh+dt@kernel.org, jdelvare@suse.com Cc: linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham Subject: [PATCH v2 2/2] hwmon: (adt7475): add support for inverting the pwm output Date: Fri, 9 Nov 2018 11:56:07 +1300 Message-Id: <20181108225607.7521-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181108225607.7521-1-chris.packham@alliedtelesis.co.nz> References: <20181108225607.7521-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 X-Virus-Scanned: ClamAV using ClamSMTP Add a "invert-pwm" device-tree property to allow hardware designs to use inverted logic on the PWM output. We intentionally 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 --- Changes in v2: - use "pwm-polarity" and support setting both logic high and logic low drivers/hwmon/adt7475.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/drivers/hwmon/adt7475.c b/drivers/hwmon/adt7475.c index f4c7516eb989..ce2c7d6493c0 100644 --- a/drivers/hwmon/adt7475.c +++ b/drivers/hwmon/adt7475.c @@ -23,6 +23,7 @@ #include #include #include +#include /* Indexes for the sysfs hooks */ @@ -1536,6 +1537,23 @@ static int adt7475_update_limits(struct i2c_client *client) return 0; } +static int adt7475_set_pwm_polarity(struct i2c_client *client, int index, + enum pwm_polarity pol) +{ + int ret; + + ret = adt7475_read(PWM_CONFIG_REG(index)); + if (ret < 0) + return ret; + + if (pol == PWM_POLARITY_INVERSED) + ret |= BIT(4); + else + ret &= ~BIT(4); + + return i2c_smbus_write_byte_data(client, PWM_CONFIG_REG(index), ret); +} + static int adt7475_probe(struct i2c_client *client, const struct i2c_device_id *id) { @@ -1638,6 +1656,16 @@ static int adt7475_probe(struct i2c_client *client, for (i = 0; i < ADT7475_PWM_COUNT; i++) adt7475_read_pwm(client, i); + if (client->dev.of_node) { + enum pwm_polarity polarity; + + ret = of_property_read_u32(client->dev.of_node, "pwm-polarity", + &polarity); + if (!ret) + for (i = 0; i < ADT7475_PWM_COUNT; i++) + adt7475_set_pwm_polarity(client, i, polarity); + } + /* Start monitoring */ switch (chip) { case adt7475: