From patchwork Sun Feb 28 23:07:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 12108509 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 4667AC433E9 for ; Sun, 28 Feb 2021 23:16:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A86561490 for ; Sun, 28 Feb 2021 23:16:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbhB1XQz (ORCPT ); Sun, 28 Feb 2021 18:16:55 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:35316 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230167AbhB1XQy (ORCPT ); Sun, 28 Feb 2021 18:16:54 -0500 X-Greylist: delayed 534 seconds by postgrey-1.27 at vger.kernel.org; Sun, 28 Feb 2021 18:16:53 EST Received: from svr-chch-seg1.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 5F647891AE; Mon, 1 Mar 2021 12:07:17 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1614553637; bh=3iqu4i+0F5Xxhcc2Ga9I95uLneeEovMUx3QEp5LgNnw=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=LVHKihKHNXRWO48Jkvw95KEStuaq4Po5LAkRuWyW3H1J1ltjCmSDW0huNjUN3/v9R t0PI1H1EpvR8bBLAjhf6sqvY1cnMj2GPlC7kYxxnvehzu46uvjpVSCXwxoWZUCOCa0 Emz9Vc6Dkj5ohNcj3mfjaaicZEvsseMIHDgk+kXD3ebx1lqzwlJ1scUdFQ1UzFkPly fDS8JvACcbR6Fg5R8hND/elEBRHPU9W/VVx6jf2uDX2BFT4gRogvW7dMQ3izmgcKIO INaozsyTf1ko3Nv7/QL5Legm1pq7YNKrslcpOqOQo9X9J/rih307t6GHfNIBEsDPyN 7hIXX3ucpWgzA== Received: from smtp (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 01 Mar 2021 12:07:17 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id A209E13EF08; Mon, 1 Mar 2021 12:07:27 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 38BFD283985; Mon, 1 Mar 2021 12:07:17 +1300 (NZDT) From: Chris Packham To: robh+dt@kernel.org, jdelvare@suse.com, linux@roeck-us.net Cc: devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham , Jiri Kosina Subject: [PATCH 1/2] dt-bindings: trivial-devices: Add infineon,ir36021 Date: Mon, 1 Mar 2021 12:07:13 +1300 Message-Id: <20210228230714.26578-2-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210228230714.26578-1-chris.packham@alliedtelesis.co.nz> References: <20210228230714.26578-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=C7uXNjH+ c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=dESyimp9J3IA:10 a=jfe4B9wozX6hrU8P5YcA:9 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add infineon,ir36021 to trivial-devices.yaml. Signed-off-by: Chris Packham --- Documentation/devicetree/bindings/trivial-devices.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/trivial-devices.yaml b/Documentation/devicetree/bindings/trivial-devices.yaml index a327130d1faa..19bc4c301f5b 100644 --- a/Documentation/devicetree/bindings/trivial-devices.yaml +++ b/Documentation/devicetree/bindings/trivial-devices.yaml @@ -102,6 +102,8 @@ properties: - mps,mp2975 # G751: Digital Temperature Sensor and Thermal Watchdog with Two-Wire Interface - gmt,g751 + # Infineon IR36021 digital POL buck controller + - infineon,ir36021 # Infineon IR38064 Voltage Regulator - infineon,ir38064 # Infineon SLB9635 (Soft-) I2C TPM (old protocol, max 100khz) From patchwork Sun Feb 28 23:07:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Chris Packham X-Patchwork-Id: 12108507 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=-18.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, 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 B77D6C433E0 for ; Sun, 28 Feb 2021 23:16:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8A35261490 for ; Sun, 28 Feb 2021 23:16:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230461AbhB1XQz (ORCPT ); Sun, 28 Feb 2021 18:16:55 -0500 Received: from gate2.alliedtelesis.co.nz ([202.36.163.20]:35318 "EHLO gate2.alliedtelesis.co.nz" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230371AbhB1XQy (ORCPT ); Sun, 28 Feb 2021 18:16:54 -0500 Received: from svr-chch-seg1.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 1D670891AF; Mon, 1 Mar 2021 12:07:18 +1300 (NZDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alliedtelesis.co.nz; s=mail181024; t=1614553638; bh=mTm99MPkc+6dS7pISgrAnkJH72py1xCk7Vkk6ktc3EU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=a9j2RyeJrnhMOjj5G1DP57GC2bonpTQBEI9sm0XmDXY6GO1zpmtq2ITdw9r90Vzf/ SOnqvVtPLcFU2j8I66E6I0TQ4J24csYrFWerFgOuchBn9hQrhBS7MdZ+jHAF3ZRYrW EMqBWWsteDw0Pv4UyAhcZj12l8x7leMPqfIqCUryFL87/e5g0/pLlywlI0hhEP5RGb nCC//Q1e8JrrS+r2dTvuEoR8lBC1a3gC9t3VSo6W4Wf2+qBs2Lqm7+BsecJRGAy3A/ o4S6nAuo9EvCdJaz8lFO14d7tdbRDkZyyedqOjheweVYnrEPOlfOARIfBHqa3rlKIA kH0rK6Q0LcsVA== Received: from smtp (Not Verified[10.32.16.33]) by svr-chch-seg1.atlnz.lc with Trustwave SEG (v8,2,6,11305) id ; Mon, 01 Mar 2021 12:07:17 +1300 Received: from chrisp-dl.ws.atlnz.lc (chrisp-dl.ws.atlnz.lc [10.33.22.20]) by smtp (Postfix) with ESMTP id 0165113EF08; Mon, 1 Mar 2021 12:07:28 +1300 (NZDT) Received: by chrisp-dl.ws.atlnz.lc (Postfix, from userid 1030) id 8D7DF283985; Mon, 1 Mar 2021 12:07:17 +1300 (NZDT) From: Chris Packham To: robh+dt@kernel.org, jdelvare@suse.com, linux@roeck-us.net Cc: devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-kernel@vger.kernel.org, Chris Packham , Jonathan Corbet , linux-doc@vger.kernel.org Subject: [PATCH 2/2] hwmon: (pmbus): Add driver for Infineon IR36021 Date: Mon, 1 Mar 2021 12:07:14 +1300 Message-Id: <20210228230714.26578-3-chris.packham@alliedtelesis.co.nz> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210228230714.26578-1-chris.packham@alliedtelesis.co.nz> References: <20210228230714.26578-1-chris.packham@alliedtelesis.co.nz> MIME-Version: 1.0 X-SEG-SpamProfiler-Analysis: v=2.3 cv=C7uXNjH+ c=1 sm=1 tr=0 a=KLBiSEs5mFS1a/PbTCJxuA==:117 a=IkcTkHD0fZMA:10 a=dESyimp9J3IA:10 a=bUQKSiCPAAAA:8 a=eFSOPmDLR39FoRlrkAYA:9 a=QEXdDO2ut3YA:10 a=-fHZXUhsFbuwFN3fwQAr:22 X-SEG-SpamProfiler-Score: 0 x-atlnz-ls: pat Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org The IR36021 is a dual‐loop digital multi‐phase buck controller. Signed-off-by: Chris Packham --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/ir36021.rst | 62 +++++++++++++++++++++++++ drivers/hwmon/pmbus/Kconfig | 9 ++++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/ir36021.c | 81 +++++++++++++++++++++++++++++++++ 5 files changed, 154 insertions(+) create mode 100644 Documentation/hwmon/ir36021.rst create mode 100644 drivers/hwmon/pmbus/ir36021.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 8d5a2df1ecb6..b34894403c2b 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -77,6 +77,7 @@ Hardware Monitoring Kernel Drivers intel-m10-bmc-hwmon ir35221 ir38064 + ir36021 isl68137 it87 jc42 diff --git a/Documentation/hwmon/ir36021.rst b/Documentation/hwmon/ir36021.rst new file mode 100644 index 000000000000..36ef8d518b81 --- /dev/null +++ b/Documentation/hwmon/ir36021.rst @@ -0,0 +1,62 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver ir36021 +===================== + +Supported chips: + + * Infineon IR36021 + + Prefix: ir36021 + Addresses scanned: - + + Datasheet: Publicly available at the Infineon website + https://www.infineon.com/dgdl/ir36021.pdf?fileId=5546d462533600a4015355d0aa2d1775 + +Authors: + - Chris Packham + +Description +----------- + +The IR36021 is a dual‐loop digital multi‐phase buck controller designed for +point of load applications. + +Usage Notes +----------- + +This driver does not probe for PMBus devices. You will have to instantiate +devices explicitly. + +Sysfs attributes +---------------- + +======================= =========================== +curr1_label "iin" +curr1_input Measured input current +curr1_alarm Input fault alarm + +curr2_label "iout1" +curr2_input Measured output current +curr2_alarm Output over-current alarm + +in1_label "vin" +in1_input Measured input voltage +in1_alarm Input under-voltage alarm + +in2_label "vout1" +in2_input Measured output voltage +in2_alarm Output over-voltage alarm + +power1_label "pin" +power1_input Measured input power +power1_alarm Input under-voltage alarm + +power2_label "pout1" +power2_input Measured output power + +temp1_input Measured temperature +temp1_alarm Temperature alarm + +temp2_input Measured other loop temperature +temp2_alarm Temperature alarm diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 32d2fc850621..ee8c27b3b83d 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -84,6 +84,15 @@ config SENSORS_IR35221 This driver can also be built as a module. If so, the module will be called ir35221. +config SENSORS_IR36021 + tristate "Infineon IR36021" + help + If you say yes here you get hardware monitoring support for Infineon + IR36021. + + This driver can also be built as a module. If so, the module will + be called ir36021. + config SENSORS_IR38064 tristate "Infineon IR38064" help diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 6a4ba0fdc1db..685a6bc2b15f 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -11,6 +11,7 @@ obj-$(CONFIG_SENSORS_BEL_PFE) += bel-pfe.o obj-$(CONFIG_SENSORS_IBM_CFFPS) += ibm-cffps.o obj-$(CONFIG_SENSORS_INSPUR_IPSPS) += inspur-ipsps.o obj-$(CONFIG_SENSORS_IR35221) += ir35221.o +obj-$(CONFIG_SENSORS_IR36021) += ir36021.o obj-$(CONFIG_SENSORS_IR38064) += ir38064.o obj-$(CONFIG_SENSORS_IRPS5401) += irps5401.o obj-$(CONFIG_SENSORS_ISL68137) += isl68137.o diff --git a/drivers/hwmon/pmbus/ir36021.c b/drivers/hwmon/pmbus/ir36021.c new file mode 100644 index 000000000000..99b5c7311afd --- /dev/null +++ b/drivers/hwmon/pmbus/ir36021.c @@ -0,0 +1,81 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Hardware monitoring driver for Infineon IR36021 + * + * Copyright (c) 2021 Allied Telesis + */ +#include +#include +#include +#include +#include +#include "pmbus.h" + +static struct pmbus_driver_info ir36021_info = { + .pages = 1, + .format[PSC_VOLTAGE_IN] = linear, + .format[PSC_VOLTAGE_OUT] = linear, + .format[PSC_CURRENT_IN] = linear, + .format[PSC_CURRENT_OUT] = linear, + .format[PSC_POWER] = linear, + .format[PSC_TEMPERATURE] = linear, + .func[0] = PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT + | PMBUS_HAVE_IIN | PMBUS_HAVE_IOUT + | PMBUS_HAVE_PIN | PMBUS_HAVE_POUT + | PMBUS_HAVE_TEMP | PMBUS_HAVE_TEMP2 + | PMBUS_HAVE_STATUS_TEMP, +}; + +static int ir36021_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + u8 buf[I2C_SMBUS_BLOCK_MAX]; + int ret; + + if (!i2c_check_functionality(client->adapter, + I2C_FUNC_SMBUS_READ_BYTE_DATA + | I2C_FUNC_SMBUS_READ_WORD_DATA + | I2C_FUNC_SMBUS_READ_BLOCK_DATA)) + return -ENODEV; + + ret = i2c_smbus_read_i2c_block_data(client, PMBUS_MFR_MODEL, 2, buf); + if (ret < 0) { + dev_err(&client->dev, "Failed to read PMBUS_MFR_MODEL\n"); + return ret; + } + if (ret != 2 || !(buf[0] == 0x01 || buf[1] == 0x2d)) { + dev_err(&client->dev, "MFR_MODEL unrecognised\n"); + return -ENODEV; + } + + return pmbus_do_probe(client, id, &ir36021_info); +} + +static const struct i2c_device_id ir36021_id[] = { + { "ir36021", 0 }, + {}, +}; +MODULE_DEVICE_TABLE(i2c, ir36021_id); + +static const struct of_device_id __maybe_unused ir36021_of_id[] = { + { .compatible = "infineon,ir36021" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ir36021_of_id); + +static struct i2c_driver ir36021_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "ir36021", + .of_match_table = of_match_ptr(ir36021_of_id), + }, + .probe = ir36021_probe, + .remove = pmbus_do_remove, + .id_table = ir36021_id, +}; + +module_i2c_driver(ir36021_driver); + +MODULE_AUTHOR("Chris Packham "); +MODULE_DESCRIPTION("PMBus driver for Infineon IR36021"); +MODULE_LICENSE("GPL");