From patchwork Thu Feb 27 08:46:38 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 204145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F337FC11D3D for ; Thu, 27 Feb 2020 08:47:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id C185F24688 for ; Thu, 27 Feb 2020 08:47:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="eaQuzMKC" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728693AbgB0IrB (ORCPT ); Thu, 27 Feb 2020 03:47:01 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:40259 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728593AbgB0Iqy (ORCPT ); Thu, 27 Feb 2020 03:46:54 -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 EFD37891AB; Thu, 27 Feb 2020 21:46:51 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582793211; bh=G1BjMK8LeDwh1xL68jE7KXxSK4WXConFO3EIX8pVad0=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=eaQuzMKC8lA6T6Ml4eeRwEv1WJu1fChfvsHvodvM3sp8OBCjkw89ZQLvb0CJqGUP8 kvptYTKwn0U78v0xJIiVHqbCw4U5zixFB1Iugs9cJwkzvjNhWFyzUAaZKzIABS/HGB K4LEMsvLX2Q0DjGk3etM1zGNZZlZgkuhlnBxQegehB9sN4eHTVV49dTy2PKUwlGur7 8/abxU63FEB+Mv4cW+TLfY6XeaMlDIuABBE0kPKKlT+4H79qRDijFQowRZ5rKEJgQJ iDshQNz2f8nhvn6FZPhNT0yhhQHuZP4vRnIvVhNLZYymJDn73JQKxuOUERQuDQF8wh /Lhu2wghOtVvA== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 27 Feb 2020 21:46:51 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id F085513EECD; Thu, 27 Feb 2020 21:46:50 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id B68BE280072; Thu, 27 Feb 2020 21:46:51 +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 v5 1/5] dt-bindings: hwmon: Document adt7475 binding Date: Thu, 27 Feb 2020 21:46:38 +1300 Message-Id: <20200227084642.7057-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227084642.7057-1-chris.packham@alliedtelesis.co.nz> References: <20200227084642.7057-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 v5: - add review from Rob Changes in v4: - None 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 Thu Feb 27 08:46:40 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 204143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DA159C4BA06 for ; Thu, 27 Feb 2020 08:47:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AA2142469E for ; Thu, 27 Feb 2020 08:47:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="CjbJo2R2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbgB0IrN (ORCPT ); Thu, 27 Feb 2020 03:47:13 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:40271 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728630AbgB0Iqy (ORCPT ); Thu, 27 Feb 2020 03:46:54 -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 2D16A891AD; Thu, 27 Feb 2020 21:46:52 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582793212; bh=EVlEwiS/TFFN1q66aMSFRrpHv5REOLeczvMuwQi/uGU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=CjbJo2R2MQonW8SHlpPrWcGrqNEX21yj5DWeIK1/xIJPI4Ya6juJoMDc+VzGgj4fn 8H/pN32ifgz69atfxNnkxKcu3NkikGMsEV6aEf7wkaYdLUdQPkPLYIPYod6iLYfVJF 50ElomjbzXUYZpOQ2b3l82yrSTwOxKwUu5R9Qb5F8OSIa0FjTtXPpB8+SKymPSdv8d TVEOzUdmemh9pEfU42HsUJDqZdcAChfNgQw1lIIKDIHGFN4ZCupwFIJsaZtGCB1ypz m9NXc34Wj+dLi0wouBZaRppFTNOPh9pHnj5LdiGr0qkmLyie5JACws8L1+DPS62OVk Xw6Vduc+4v8lQ== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 27 Feb 2020 21:46:51 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 3F63313EECD; Thu, 27 Feb 2020 21:46:51 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 0581F280072; Thu, 27 Feb 2020 21:46:52 +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 v5 3/5] dt-bindings: hwmon: Document adt7475 pwm-active-state property Date: Thu, 27 Feb 2020 21:46:40 +1300 Message-Id: <20200227084642.7057-4-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227084642.7057-1-chris.packham@alliedtelesis.co.nz> References: <20200227084642.7057-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add binding information for the adi,pwm-active-state property. Signed-off-by: Chris Packham --- Notes: Changes in v5: - change to adi,pwm-active-state - uint32 array Changes in v4: - use $ref uint32 and enum - add adi vendor prefix Cahnges in v3: - new .../devicetree/bindings/hwmon/adt7475.yaml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/Documentation/devicetree/bindings/hwmon/adt7475.yaml b/Documentation/devicetree/bindings/hwmon/adt7475.yaml index e40612ee075f..76985034ea73 100644 --- a/Documentation/devicetree/bindings/hwmon/adt7475.yaml +++ b/Documentation/devicetree/bindings/hwmon/adt7475.yaml @@ -50,6 +50,19 @@ patternProperties: - $ref: /schemas/types.yaml#/definitions/uint32 - enum: [0, 1] + "^adi,pwm-active-state$": + description: | + Integer array, represents the active state of the pwm outputs If set to 0 + 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. + allOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - minItems: 3 + maxItems: 3 + items: + enum: [0, 1] + default: 1 + required: - compatible - reg @@ -65,6 +78,7 @@ examples: reg = <0x2e>; adi,bypass-attenuator-in0 = <1>; adi,bypass-attenuator-in1 = <0>; + adi,pwm-active-state = <1 0 1>; }; }; From patchwork Thu Feb 27 08:46:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 204144 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.9 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D9949C4BA3C for ; Thu, 27 Feb 2020 08:47:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id AF7E424688 for ; Thu, 27 Feb 2020 08:47:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=alliedtelesis.co.nz header.i=@alliedtelesis.co.nz header.b="ZX0+bbtZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728599AbgB0IrG (ORCPT ); Thu, 27 Feb 2020 03:47:06 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:40276 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728584AbgB0Iqy (ORCPT ); Thu, 27 Feb 2020 03:46:54 -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 7966B891AF; Thu, 27 Feb 2020 21:46:52 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1582793212; bh=gAeymK9rchxCX6TVwrgC2CafflPqeAExrMOJHuXCK3g=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=ZX0+bbtZF+xBIecdwhvbZoOoUqR1MMKjLocPEyOIS2NE9mrhAyakEZa4/vQUOxY1r jNKSzYhTibAUlxpqn7yLukVLzhfFrbA/ljjj83vegT7iLRWRIPKGX070Zft9XzJ22d R2r7N9iAaay6YmO9CExvrKkf1fsqYnCumBiO+mzTM3V81dbRXJGl7jqCnpMbIhSfLw bfKx52Fkfv5LboALwXJKIOZfEOYoeCpmxAg4CejdH5aB4vmy8xPv2i1FKwc1ISPJWf 8Yd6ndxOOx03j0AAlID4+wtpdLXLFSSWavIR5uaKT1kk4BFKm6XnLPZWf486yN5kFE Wrdb8+uRDATVw== Received: from smtp (Not Verified[10.32.16.33]) by mmarshal3.atlnz.lc with Trustwave SEG (v7, 5, 8, 10121) id ; Thu, 27 Feb 2020 21:46:51 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 60EF413EECD; Thu, 27 Feb 2020 21:46:51 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 2708C280072; Thu, 27 Feb 2020 21:46:52 +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 v5 4/5] hwmon: (adt7475) Add attenuator bypass support Date: Thu, 27 Feb 2020 21:46:41 +1300 Message-Id: <20200227084642.7057-5-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200227084642.7057-1-chris.packham@alliedtelesis.co.nz> References: <20200227084642.7057-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 x-atlnz-ls: pat Sender: devicetree-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: devicetree@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 v5: - None 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) |