Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp9517944rwp; Thu, 20 Jul 2023 06:13:08 -0700 (PDT) X-Google-Smtp-Source: APBJJlGCybQXfT/mfCa1v6p0d+sIOs5xMkPnml8TsftU3HKY2yHtb0nX9LTU1Yrw8yOoVNrK3WDs X-Received: by 2002:a05:6870:d10d:b0:1ba:5464:774d with SMTP id e13-20020a056870d10d00b001ba5464774dmr1753285oac.19.1689858788459; Thu, 20 Jul 2023 06:13:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689858788; cv=none; d=google.com; s=arc-20160816; b=YaK/oz1Ddz/yqe0EuByDyHuHhdYK065f/by7ExrOVQn8FWN3C9jFbqsRnj6pGu6uZo pom114DoNJvxjvogiKS8ILFgkHtogU+ojy2lvJ8RoGpmLJwYytykkxosvKZQ8zkmr3qj RxKmrxnmxEUl4YuFgK4UsUsbyGlbimkJlGSndOn6IYrep4gDSSU+IAJDNfizkc0lfFRg X85EGfZQnLXdLitjxnJEwKiZgCKVioFcyGMvyuZxVo0ZE1h2cOKfATwDYyM4Ear2pgS0 6Mfy7QIHYwl58l8tu7qciaKta9aDxB7OxFxsrFbUfsTLAIWnO8Y2JkIyBkTZXlyk3MsT vZqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:dkim-signature:from; bh=QcDTd84f5Syv2zlZDzVZzw50uxA1cKbNqqF+nxsaLiA=; fh=FebaqzejDEeujckHc2Z8223tkM9c+TD44bTmHxhACko=; b=hTTCPg+OHjORPl2KQktLxX+R3Pf8u+0Dmqc5z+gYB7m+9VTqv+C33yeyPmbBdwpRoV B18HZyl9mW2mbGjxFzxAuuUoLSa4kBlC5xvSDgwEPLI8VBqCUvmYJQx4IqWkRrBTJKGn 0MLJe9D/w44O2B1x0VrU/h/r9c91Zz8Nu8BYHG+BZLFv1Lmv/7I6clc7un19cLmv+XJg c3wsjJfzqG0RyZrLawiQhWsLMHcv53hL1SNegQH0gI+p3SE7dOp2Z1RQKVpwHz08nRwL jzB1u7G+NouHfzd7D08gyMmiol7YoSyWA3nWHBIHVCNRMSfoD2X01soSuwbgrFCfPw3Z jTUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@startmail.com header.s=2020-07 header.b=DZMAEosi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=startmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l190-20020a633ec7000000b0055b57fa6d19si834768pga.208.2023.07.20.06.12.54; Thu, 20 Jul 2023 06:13:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@startmail.com header.s=2020-07 header.b=DZMAEosi; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=startmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229838AbjGTMfZ (ORCPT + 99 others); Thu, 20 Jul 2023 08:35:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229613AbjGTMfX (ORCPT ); Thu, 20 Jul 2023 08:35:23 -0400 X-Greylist: delayed 1200 seconds by postgrey-1.37 at lindbergh.monkeyblade.net; Thu, 20 Jul 2023 05:35:22 PDT Received: from mx-out1.startmail.com (mx-out1.startmail.com [145.131.90.139]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 81906F0 for ; Thu, 20 Jul 2023 05:35:22 -0700 (PDT) From: "Marty E. Plummer" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=startmail.com; s=2020-07; t=1689854295; bh=QcDTd84f5Syv2zlZDzVZzw50uxA1cKbNqqF+nxsaLiA=; h=From:To:Subject:Date:Message-ID:Mime-Version: Content-Transfer-Encoding:From:Subject:To:Date:Sender:Content-Type: Content-Transfer-Encoding:Content-Disposition:Mime-Version: Reply-To:In-Reply-To:References:Message-Id:Autocrypt; b=DZMAEosiWQwnb2IXM3Em5+0qiKiSvnyUymUZf3gwfWy9e8w/LFXvQIl8soY2IK5hv yiX+mGQRSLQMpjLQCNCzApOzAKsfKIwC137VCRUzmGrZKyP+8R5r42Lp4O8M1pEbx9 hAk7zA/hd8cMyCaByQO75Q9zfWMzTC9irK4bZGXvA5f7ZAiRcaUz5WL5xpcd0jCyW7 NXH1evjfbSZPjJZCnbOl07Ro6uJOQufv14wBKgmu3LiZQp9BEx6ykvhzMLiVR1OolT pSDLQfy71G9Fi3Do4o6+aTh1Ki1t+/Afo96IIuAW44+wtSJWmNZiPcTjVuMFgcKYD2 UmEoctV/KFpNg== To: linux-kernel@vger.kernel.org, linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org Cc: Jean Delvare , Guenter Roeck , Jonathan Corbet , "Marty E. Plummer" Subject: [PATCH] hwmon: (pmbus) Add driver fpr Infineon IR35201 Date: Thu, 20 Jul 2023 06:58:05 -0500 Message-ID: <20230720115805.1510279-1-hanetzer@startmail.com> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The IR35201 is a dual-loop digital multi-phase buck controller designed for CPU voltage regulation. Signed-off-by: Marty E. Plummer --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/ir35201.rst | 63 +++++++++++++++++++++++ drivers/hwmon/pmbus/Kconfig | 9 ++++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/ir35201.c | 89 +++++++++++++++++++++++++++++++++ 5 files changed, 163 insertions(+) create mode 100644 Documentation/hwmon/ir35201.rst create mode 100644 drivers/hwmon/pmbus/ir35201.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 042e1cf9501b..5b44a268de0d 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -87,6 +87,7 @@ Hardware Monitoring Kernel Drivers ina3221 inspur-ipsps1 intel-m10-bmc-hwmon + ir35201 ir35221 ir38064 ir36021 diff --git a/Documentation/hwmon/ir35201.rst b/Documentation/hwmon/ir35201.rst new file mode 100644 index 000000000000..6ca34d4b02a3 --- /dev/null +++ b/Documentation/hwmon/ir35201.rst @@ -0,0 +1,63 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver ir35201 +===================== + +Supported chips: + + * Infineon IR35201 + + Prefix: ir35201 + Addresses scanned: - + + Datasheet: Publicly available at the Infineon website + https://www.infineon.com/dgdl/Infineon-IR35201MTRPBF-DS-v01_00-EN.pdf?fileId=5546d462576f347501579c95d19772b5 + +Authors: + - Marty E. Plummer + +Description +----------- + +The IR35201 is a dual-loop digital multi-phase buck controller designed for +CPU voltage regulation. + +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 270b6336b76d..7180823b15bb 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -123,6 +123,15 @@ config SENSORS_INSPUR_IPSPS This driver can also be built as a module. If so, the module will be called inspur-ipsps. +config SENSORS_IR35201 + tristate "Infineon IR35201" + help + If you say yes here you get hardware monitoring support for the + Infineon IR35201 controller. + + This driver can also be built as a module. If so, the module will + be called ir35201. + config SENSORS_IR35221 tristate "Infineon IR35221" help diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 84ee960a6c2d..40729dd14e7a 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -15,6 +15,7 @@ obj-$(CONFIG_SENSORS_FSP_3Y) += fsp-3y.o obj-$(CONFIG_SENSORS_IBM_CFFPS) += ibm-cffps.o obj-$(CONFIG_SENSORS_DPS920AB) += dps920ab.o obj-$(CONFIG_SENSORS_INSPUR_IPSPS) += inspur-ipsps.o +obj-$(CONFIG_SENSORS_IR35201) += ir35201.o obj-$(CONFIG_SENSORS_IR35221) += ir35221.o obj-$(CONFIG_SENSORS_IR36021) += ir36021.o obj-$(CONFIG_SENSORS_IR38064) += ir38064.o diff --git a/drivers/hwmon/pmbus/ir35201.c b/drivers/hwmon/pmbus/ir35201.c new file mode 100644 index 000000000000..77f77057175a --- /dev/null +++ b/drivers/hwmon/pmbus/ir35201.c @@ -0,0 +1,89 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Hardware monitoring driver for Infineon IR35201 + */ + +#include +#include +#include +#include +#include +#include "pmbus.h" + +static struct pmbus_driver_info ir35201_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 ir35201_probe(struct i2c_client *client) +{ + 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_block_data(client, PMBUS_MFR_ID, buf); + if (ret < 0) { + dev_err(&client->dev, "Failed to read PMBUS_MFR_ID\n"); + return ret; + } + if (ret != 2 || strncmp(buf, "IR", strlen("IR"))) { + dev_err(&client->dev, "MFR_ID unrecognized\n"); + return -ENODEV; + } + + ret = i2c_smbus_read_block_data(client, PMBUS_MFR_MODEL, buf); + if (ret < 0) { + dev_err(&client->dev, "Failed to read PMBUS_MFR_MODEL\n"); + return ret; + } + if (ret != 1 || buf[0] != 0x50) { + dev_err(&client->dev, "MFR_MODEL unrecognized\n"); + return -ENODEV; + } + + return pmbus_do_probe(client, &ir35201_info); +} + +static const struct i2c_device_id ir35201_id[] = { + { "ir35201", 0}, + {}, +}; +MODULE_DEVICE_TABLE(i2c, ir35201_id); + +static const struct of_device_id __maybe_unused ir35201_of_id[] = { + { .compatible = "infineon,ir35201" }, + {}, +}; +MODULE_DEVICE_TABLE(of, ir35201_of_id); + +static struct i2c_driver ir35201_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "ir35201", + .of_match_table = of_match_ptr(ir35201_of_id), + }, + .probe_new = ir35201_probe, + .id_table = ir35201_id, +}; + +module_i2c_driver(ir35201_driver); + +MODULE_AUTHOR("Marty E. Plummer "); +MODULE_DESCRIPTION("PMBus driver for Infineon IR35201"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(PMBUS); -- 2.41.0