From patchwork Fri Nov 3 08:01:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Yin X-Patchwork-Id: 13444397 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74A9BC4167D for ; Fri, 3 Nov 2023 08:04:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234640AbjKCIE6 (ORCPT ); Fri, 3 Nov 2023 04:04:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38692 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229941AbjKCIE5 (ORCPT ); Fri, 3 Nov 2023 04:04:57 -0400 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DCBABD42; Fri, 3 Nov 2023 01:04:51 -0700 (PDT) Received: by mail-pf1-x431.google.com with SMTP id d2e1a72fcca58-6b5af4662b7so1764223b3a.3; Fri, 03 Nov 2023 01:04:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698998691; x=1699603491; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=V8o7NIVsvFjoN1IBcJ9gHST23hC/srd4GUV+1AFgork=; b=BUZMq2hpWAjDVjRxMnilrZ9EUdJHidAj6QzwqMdPxqcTLiZ8U2WNc7Lz0XSujJX6ZP Nc39h6rliipFGiel285vAYPJTr/adNwlDr35YmXfVUdU7hVgjKOxyVeQ/ZvDh+XrOm8x QZdow8LdtnRwUQxm/orZfDs24MvYI/6VvLqAz8FqZ8SmLqVA622IM8YXmYlEpoeTidYd PqiITFYSutyLw7esICxZL4CC28JIaQlcISZfjQmIQvHJd4HQ4fRUSJmFKLQmq78bfKuw UrYAdO0+ZsU4J3W1Jmc4i25hHnWugvEsvh5kxmvIvh9pYBo6R0OcVh3Unq6rIXtIMxWt Uauw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698998691; x=1699603491; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=V8o7NIVsvFjoN1IBcJ9gHST23hC/srd4GUV+1AFgork=; b=ZdGAHLqMFbm0h7y1h/TxpFKqL3Na1X6p/4oxwppK4CIx8gd2YWtrMd50C1tBKHnCqv gNYlPylZd7hjH/vvYOM6vxQJRZY12WtuLjaZKqZrR2mMaYLTsFx7QT97h7RX7ENEcFXq 23UhO0nAais3a12jjVoK69v80lo7QQNaqrWDiXytMe0D0oLLgxvA1KDVyROKhSjs5qVP kg5sdzKfF06IXw0w7BbR4dF3PFWoQoKyHZ2vPmMqsGlOvqHUDtSVqa5rACy/2Bn/FvZR gkbF+R/M3Q+VQSYCTvwtb1Ou0o4RCG/Ji4+BQyjb4t9scBZTZQ26QkHMZlHK9h/d6Bwn MPjQ== X-Gm-Message-State: AOJu0YwzWD81Hk+j14FgS17L5GGuO1fgDVuexIcM3Fqs1kz0apMrLFxK iryGAS5sJDO+0w7O9J1qwz4= X-Google-Smtp-Source: AGHT+IGHcOsomwU0+lxHyL/U3Etoy6sODvXrPBey27Szl3Sc8WMv3OZCAwZX7IBMT+grKteABJvGkA== X-Received: by 2002:a05:6a20:3941:b0:181:8654:8279 with SMTP id r1-20020a056a20394100b0018186548279mr5059009pzg.47.1698998691363; Fri, 03 Nov 2023 01:04:51 -0700 (PDT) Received: from peter-bmc.dhcpserver.bu9bmc.local (1-34-21-66.hinet-ip.hinet.net. [1.34.21.66]) by smtp.gmail.com with ESMTPSA id l1-20020a17090a72c100b002790ded9c6dsm834378pjk.31.2023.11.03.01.04.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:04:50 -0700 (PDT) From: Peter Yin To: patrick@stwcx.xyz, Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Peter Yin , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v1 1/2] dt-bindings: hwmon: Add mps mp5990 driver bindings Date: Fri, 3 Nov 2023 16:01:26 +0800 Message-Id: <20231103080128.1204218-2-peteryin.openbmc@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231103080128.1204218-1-peteryin.openbmc@gmail.com> References: <20231103080128.1204218-1-peteryin.openbmc@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add a device tree bindings for mp5990 device. Signed-off-by: Peter Yin --- .../devicetree/bindings/hwmon/mps,mp5990.yaml | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml diff --git a/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml new file mode 100644 index 000000000000..7533d69f1922 --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/mps,mp5990.yaml @@ -0,0 +1,43 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/mps,mp5990.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Analog Devices MP5990 HSC Controller + +maintainers: + - Peter Yin + +description: | + Analog Devices MP5990 HSC Controller + + Datasheets: + https://www.monolithicpower.com/en/mp5990.html + +properties: + compatible: + enum: + - mps,mp5990 + + reg: + description: I2C address of slave device. + maxItems: 1 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + power-sensor@20 { + reg = <0x20>; + compatible = "mps,mp5990"; + }; + }; From patchwork Fri Nov 3 08:01:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Yin X-Patchwork-Id: 13444398 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4AB8C4332F for ; Fri, 3 Nov 2023 08:05:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234677AbjKCIFE (ORCPT ); Fri, 3 Nov 2023 04:05:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38720 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234738AbjKCIFC (ORCPT ); Fri, 3 Nov 2023 04:05:02 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BDA131B6; Fri, 3 Nov 2023 01:04:56 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id d9443c01a7336-1cc5fa0e4d5so16472475ad.0; Fri, 03 Nov 2023 01:04:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1698998696; x=1699603496; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=axKwtGrX3CjILSP9XH8F0phpKXXMKLSo8OytbKLjoeo=; b=nRO8RaLPCRooLGVWpbT/3uaZmV88NoaiDi/tKmSMkYfbxUO2juwiZuR++u5qcYdYps pG7QuOzFUlj8cOInmhJz8GdQIOJV75pzH5ljRiQUl4mKNb2H7c5wbVuEMXnntlBPbfq0 speRzhInLEqgoxDca0L7HOUuFpKZ8MReekeombnfbMhzMbmFExvCTkzVa78NUJbSIbKZ wE/GkbHgYrsmk3t+fkoMADIFwxmNk8zca5Q0wMO4rPBUSTedfr7G8ZWRiSE9iMN2PKyK lHxEkZ4OfV30SQlV/Yzs4zokRJTwJZ651Nh2rgoG6b4iZaFb/TOTf2KyadwyRaVdtM1G qnTw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698998696; x=1699603496; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=axKwtGrX3CjILSP9XH8F0phpKXXMKLSo8OytbKLjoeo=; b=X7jaXBvL6MeD37rCf4x40HC4LJquMplHAfywxmRs4So/iiBANtAOOkeI7BaNlaoUun lbox4tdW4eNxn31YRnFlzAAUahclE8bxWjwvO0eYVIg9Ojl8WO5qVcz7i7ygKpd+xMb1 wgJYALB4ucYzkOhZwwM5NY1GuIwyFX4wxvbKIUp768KctefzUfbncBE5g9tl1EbrUgq9 7Phe1xsqYlRnTM9X6p0tVHe1yl4jC28BSzwL5/zR7A9srJrsnFG04YV3C+YnIwJ8iBVW TuBUsXI0fk0ztrubUEzNQxsMUKGge2kHyKNJsfPWFUzpYJaCdJcYomTrMMXIULkCCVyg /sCQ== X-Gm-Message-State: AOJu0Yw/9V3IjPHv6p2Y2Gbao0ePuFwALYWrUGmV3bP2pJbkFw/fYUUL I43M7jPGyrUmIlBfme5gojc= X-Google-Smtp-Source: AGHT+IFM/APK48tWP7y4Wdi3KSHsYdtBIZwoKsNTtil+i8QYKTxOzhyF5qCwrdpW9T5V+VJbGfNxKw== X-Received: by 2002:a17:90a:d497:b0:27f:ecd9:6d0e with SMTP id s23-20020a17090ad49700b0027fecd96d0emr19514519pju.34.1698998696109; Fri, 03 Nov 2023 01:04:56 -0700 (PDT) Received: from peter-bmc.dhcpserver.bu9bmc.local (1-34-21-66.hinet-ip.hinet.net. [1.34.21.66]) by smtp.gmail.com with ESMTPSA id l1-20020a17090a72c100b002790ded9c6dsm834378pjk.31.2023.11.03.01.04.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Nov 2023 01:04:55 -0700 (PDT) From: Peter Yin To: patrick@stwcx.xyz, Jean Delvare , Guenter Roeck , Rob Herring , Krzysztof Kozlowski , Conor Dooley , Jonathan Corbet , Peter Yin , linux-hwmon@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v1 2/2] hwmon: (pmbus) Add support for MPS Multi-phase mp5990 Date: Fri, 3 Nov 2023 16:01:27 +0800 Message-Id: <20231103080128.1204218-3-peteryin.openbmc@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20231103080128.1204218-1-peteryin.openbmc@gmail.com> References: <20231103080128.1204218-1-peteryin.openbmc@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add support for mp5990 device from Monolithic Power Systems, Inc. (MPS) vendor. This is a Hot-Swap Controller. Signed-off-by: Peter Yin --- Documentation/hwmon/index.rst | 1 + Documentation/hwmon/mp5990.rst | 84 +++++++++++++++++++++++++++++++ drivers/hwmon/pmbus/Kconfig | 9 ++++ drivers/hwmon/pmbus/Makefile | 1 + drivers/hwmon/pmbus/mp5990.c | 90 ++++++++++++++++++++++++++++++++++ 5 files changed, 185 insertions(+) create mode 100644 Documentation/hwmon/mp5990.rst create mode 100644 drivers/hwmon/pmbus/mp5990.c diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 042e1cf9501b..8c70e10fc795 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -157,6 +157,7 @@ Hardware Monitoring Kernel Drivers mp2888 mp2975 mp5023 + mp5990 nct6683 nct6775 nct7802 diff --git a/Documentation/hwmon/mp5990.rst b/Documentation/hwmon/mp5990.rst new file mode 100644 index 000000000000..8fc4e388ff7b --- /dev/null +++ b/Documentation/hwmon/mp5990.rst @@ -0,0 +1,84 @@ +.. SPDX-License-Identifier: GPL-2.0 + +Kernel driver mp5990 +==================== + +Supported chips: + + * MPS MP5990 + + Prefix: 'mp5990' + + * Datasheet + + Publicly available at the MPS website : https://www.monolithicpower.com/en/mp5990.html + +Author: + + Peter Yin + +Description +----------- + +This driver implements support for Monolithic Power Systems, Inc. (MPS) +MP5990 Hot-Swap Controller. + +Device complaint with: + +- PMBus rev 1.3 interface. + +Device supports direct format for reading input voltage, output voltage, +output current, input power and temperature. + +The driver exports the following attributes via the 'sysfs' files +for input voltage: + +**in1_input** + +**in1_label** + +**in1_max** + +**in1_max_alarm** + +**in1_min** + +**in1_min_alarm** + +The driver provides the following attributes for output voltage: + +**in2_input** + +**in2_label** + +**in2_alarm** + +The driver provides the following attributes for output current: + +**curr1_input** + +**curr1_label** + +**curr1_alarm** + +**curr1_max** + +The driver provides the following attributes for input power: + +**power1_input** + +**power1_label** + +**power1_alarm** + +The driver provides the following attributes for temperature: + +**temp1_input** + +**temp1_max** + +**temp1_max_alarm** + +**temp1_crit** + +**temp1_crit_alarm** diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig index 270b6336b76d..65a116f7744d 100644 --- a/drivers/hwmon/pmbus/Kconfig +++ b/drivers/hwmon/pmbus/Kconfig @@ -326,6 +326,15 @@ config SENSORS_MP5023 This driver can also be built as a module. If so, the module will be called mp5023. +config SENSORS_MP5990 + tristate "MPS MP5990" + help + If you say yes here you get hardware monitoring support for MPS + MP5990. + + This driver can also be built as a module. If so, the module will + be called mp5990. + config SENSORS_MPQ7932_REGULATOR bool "Regulator support for MPQ7932" depends on SENSORS_MPQ7932 && REGULATOR diff --git a/drivers/hwmon/pmbus/Makefile b/drivers/hwmon/pmbus/Makefile index 84ee960a6c2d..212d9ca0acc9 100644 --- a/drivers/hwmon/pmbus/Makefile +++ b/drivers/hwmon/pmbus/Makefile @@ -35,6 +35,7 @@ obj-$(CONFIG_SENSORS_MAX8688) += max8688.o obj-$(CONFIG_SENSORS_MP2888) += mp2888.o obj-$(CONFIG_SENSORS_MP2975) += mp2975.o obj-$(CONFIG_SENSORS_MP5023) += mp5023.o +obj-$(CONFIG_SENSORS_MP5990) += mp5990.o obj-$(CONFIG_SENSORS_MPQ7932) += mpq7932.o obj-$(CONFIG_SENSORS_PLI1209BC) += pli1209bc.o obj-$(CONFIG_SENSORS_PM6764TR) += pm6764tr.o diff --git a/drivers/hwmon/pmbus/mp5990.c b/drivers/hwmon/pmbus/mp5990.c new file mode 100644 index 000000000000..c3b31af9f750 --- /dev/null +++ b/drivers/hwmon/pmbus/mp5990.c @@ -0,0 +1,90 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * Driver for MPS MP5990 Hot-Swap Controller + */ + +#include +#include +#include +#include +#include "pmbus.h" + +static int mp5990_read_byte_data(struct i2c_client *client, int page, int reg) +{ + switch (reg) { + case PMBUS_VOUT_MODE: + /* + Enforce VOUT direct format, C4h reg BIT9 + default val is not match vout format + */ + return PB_VOUT_MODE_DIRECT; + default: + return -ENODATA; + } +} + +static struct pmbus_driver_info mp5990_info = { + .pages = 1, + .format[PSC_VOLTAGE_IN] = direct, + .format[PSC_VOLTAGE_OUT] = direct, + .format[PSC_CURRENT_OUT] = direct, + .format[PSC_POWER] = direct, + .format[PSC_TEMPERATURE] = direct, + .m[PSC_VOLTAGE_IN] = 32, + .b[PSC_VOLTAGE_IN] = 0, + .R[PSC_VOLTAGE_IN] = 0, + .m[PSC_VOLTAGE_OUT] = 32, + .b[PSC_VOLTAGE_OUT] = 0, + .R[PSC_VOLTAGE_OUT] = 0, + .m[PSC_CURRENT_OUT] = 16, + .b[PSC_CURRENT_OUT] = 0, + .R[PSC_CURRENT_OUT] = 0, + .m[PSC_POWER] = 1, + .b[PSC_POWER] = 0, + .R[PSC_POWER] = 0, + .m[PSC_TEMPERATURE] = 1, + .b[PSC_TEMPERATURE] = 0, + .R[PSC_TEMPERATURE] = 0, + .func[0] = + PMBUS_HAVE_VIN | PMBUS_HAVE_VOUT | PMBUS_HAVE_PIN | + PMBUS_HAVE_TEMP | PMBUS_HAVE_IOUT | + PMBUS_HAVE_STATUS_INPUT | PMBUS_HAVE_STATUS_TEMP, + .read_byte_data = mp5990_read_byte_data, +}; + +static int mp5990_probe(struct i2c_client *client) +{ + int ret; + + ret = i2c_smbus_write_byte_data(client, PMBUS_VOUT_MODE, + PB_VOUT_MODE_DIRECT); + if (ret < 0) + return ret; + return pmbus_do_probe(client, &mp5990_info); +} + +static const struct of_device_id mp5990_of_match[] = { + { .compatible = "mps,mp5990" }, + {} +}; + +static const struct i2c_device_id mp5990_id[] = { + {"mp5990", 0}, + { } +}; +MODULE_DEVICE_TABLE(i2c, mp5990_id); + +static struct i2c_driver mp5990_driver = { + .driver = { + .name = "mp5990", + .of_match_table = of_match_ptr(mp5990_of_match), + }, + .probe = mp5990_probe, + .id_table = mp5990_id, +}; +module_i2c_driver(mp5990_driver); + +MODULE_AUTHOR("Peter Yin "); +MODULE_DESCRIPTION("PMBus driver for MP5990 HSC"); +MODULE_LICENSE("GPL"); +MODULE_IMPORT_NS(PMBUS);