From patchwork Wed Jul 7 15:58:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 12363001 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,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham 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 EBE53C07E95 for ; Wed, 7 Jul 2021 15:59:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CFB2961C33 for ; Wed, 7 Jul 2021 15:59:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231933AbhGGQCV (ORCPT ); Wed, 7 Jul 2021 12:02:21 -0400 Received: from mail-dm6nam11on2051.outbound.protection.outlook.com ([40.107.223.51]:31808 "EHLO NAM11-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231931AbhGGQCV (ORCPT ); Wed, 7 Jul 2021 12:02:21 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZdEsh3VTNLDi9auOS8cwV3I3E6ooYsZmOFcvleQqK71pumcm3tqDo7SQR2YxXMFzQKH0ktptcQ25ki39Yifc+sC+plJ72E9LsnrI59asUWjNfbcu3Abv3eL8AOFz4Fcl0hnMPK1+JAZaCVb5yEoHSucv+uRZJx47t58jG2zGdA4+uT0bpdaluoEXo1FZPHsETRfZOFj6b3cIVw4Ew+lSALBBBFrVIeOBktOzwrqjLBTgLm3HlTlOQumtMXfx5fo+vx+nnj7K/3ctWSWBaEjmePex5yLIObLLrLn/v+eXTQitWAH1RSdVgYZtMdA8X6ugCo+trdegO2RHl+TFitrIsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xm6vC9TnwTvK68OlEeFtve1HsrgP9qaokSs0o9MO3XI=; b=d4rIOhWqKvhWD7bLkqbH7d3VY3/MdLv3Z91SAjPL0Tx0cRmlfsDKyiUrcLQanajgQo8x2qDTVpsUq1rsMrnmrMxR5htZkoSt1q+FJMAREg0hZmJdQOl0G56t0u8K/BsG55KOK//9n8TTokAQLcHRR07hZBryVK9OH8tLkbnbYYJPDZDSc2XTp6AF3QYaHCsUis2SA3YjFW5T7VcJKRqtKGJZrCPy45ZrDwqeecVz5rB5YbMdzIOQ7rIxc1MhG2ZN134cb4H8zuUzvzAq5G5cqmyKTU9g+vlGdpoV4exzOsXi1qylUsjmdw0+a7fw+t18S4nb6acuOtQ1DOHmY2ZmHQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Xm6vC9TnwTvK68OlEeFtve1HsrgP9qaokSs0o9MO3XI=; b=hQgv8V44mH7K3wLWm++yr+WfLDy9zwkzuIVHl4/VXG6x8PJATi5jRdEhUMIv1t0XnrtwVtlrILGIsMuDFbXIs5UrAFQ+VqlzyYjnW8D+5Q7Nlp7FUBwj0UVhk8U7DPyfHDud/Mz/hgwBHzE+EaoMPH2NSgNkcqUkQASxiEfcIrM= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BL1PR12MB5286.namprd12.prod.outlook.com (2603:10b6:208:31d::6) by BL1PR12MB5270.namprd12.prod.outlook.com (2603:10b6:208:31e::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21; Wed, 7 Jul 2021 15:59:39 +0000 Received: from BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::8ce:4339:7e20:7022]) by BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::8ce:4339:7e20:7022%7]) with mapi id 15.20.4308.020; Wed, 7 Jul 2021 15:59:39 +0000 From: Naveen Krishna Chatradhi To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, Akshay Gupta , Naveen Krishna Chatradhi Subject: [PATCH v2 1/3] hwmon: sbrmi: Add support for sbrmi power module Date: Wed, 7 Jul 2021 21:28:57 +0530 Message-Id: <20210707155859.86240-1-nchatrad@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210625132544.18094-1-nchatrad@amd.com> References: <20210625132544.18094-1-nchatrad@amd.com> X-ClientProxiedBy: MA1PR01CA0139.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::33) To BL1PR12MB5286.namprd12.prod.outlook.com (2603:10b6:208:31d::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from milan-ETHANOL-X.amd.com (165.204.156.251) by MA1PR01CA0139.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 15:59:37 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: abde3098-871c-4e89-6685-08d94160397c X-MS-TrafficTypeDiagnostic: BL1PR12MB5270: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qgclKQt6+iA3EpBIFuvmg+dhNT7S9ovg9kctDRouZZc7dIlP31n6z3GR6Dq5aGXVANEAE/bAtytepP3zeyq6HmbXrtFeiD3NY/mHxyvzlnADh2bmZ2G8aKOBS7ISsN3GXZSGzb9U28G0LvUfuXSjZuimZeNudxOymrvus+j7uO9NiQFaP04btH36K0OZ1sXGPl4NIXDmPAAahwibCVQftfteB3nDV5JZBja9VmcMyGcgIXYNRKcYc+4TXb7vSm88E2QMnhAO5gL/FrVFaa3qYjibLyLheBX+AJpKtrHsbhGcCnmbCrlNP0E74DCjUE6oatoBiZ1U0IBxHzV9kTFPWz+abwxGtpY8BY9sf7z42dt3ORyvKZ7jaKOZhhF4S+4QyUMwY/4I+1JN95bC6vwJ6POfMbSwfIMm7XilH2wtqvmYklq7ZZ1HvillcN5sRMs5GOe1sYdIfXYUYD/xM91a6sPsXEYTk5v2CeXrnqmLdG5B/Zn5B4a3bSVlqZHiW8ywcghgKehpdRR8ylZpAmGIuWAnRnhUeyF/0wOcXPUmPp87/B6m1os98S8b9hEr6BxPgZCuSG5kxZ4vQqqvxhpMXMa9eLDHGWWVsv4UEmRR3q4UX1mMS6eGVDbWRNxgv3YP9O87f03nlxHyiWK/uLpiQje/Ban/McxmkKLGbTu2q/LRd3fxIFgolan7sLhaM76rb4ZYlPaSSLq+hYUpBDMmFQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5286.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(346002)(39860400002)(376002)(396003)(366004)(136003)(6486002)(4326008)(38350700002)(66946007)(2616005)(30864003)(66476007)(54906003)(956004)(66556008)(478600001)(38100700002)(8676002)(8936002)(52116002)(7696005)(316002)(6666004)(36756003)(26005)(6916009)(186003)(5660300002)(83380400001)(2906002)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: MU5jMKxannmLNOwjWm892Z8RXlQXIVIoLq0SSr1zWKKNjoQ0XRB/J5diIebHlr2Gnvkdk6Yljz8Qv9LkIn4QQE2Fy+K82FjfCBq+nsZeFhcjsnRD/hSgp2ai/UD36T3qG0BGMirHuIz4ETa2aqt22DVF4m+zxIn873fEWoBjxu9I8qjo86bj+nXtEnd1itWVyEe2L5P0ofBdE+KZ0iKJh76KWfhta/52pPT4tq1FETXABMMnRoS2LSQEVyt7H9OTfMLwZUH9O2AakOwjyAnSok7MchhHxo7VRoidM6Hjpi3znhVMqmtUKPAT5P1zR7Vq19X1TXI02loiY+Y4VeL/4WZatSMYj0iMWtj12KSnaHRCroaGmC0bXX+JXGK9PUdQheF8G2VNijOui42IUJscanhfYeofrE+doJ2NhD/ygLdKemYzMVrYH+NrVVqtasPYX2oC4wzDitKdwq2XxGTyUUtpsycViCJD36ZOecgJ2ozVVBsipHrafY2M6b38389Ftwy1JdZLLB02twQO1Y/iQxMp2gKSzQtCWyKHF0BqBDt6ifSZAXVj4W3xAwShz45hV+sqMqLt0d4rHdrKPFR7H7KUZwBySeIm0AY7ecPfyWUhBs4N2OxOyLa3CfuB2fD4+gYHXxfqwo6SGnVbkRYGLi6eJbJMdTcCnviR0dUyQR68rQeN0rahJBtrz0tNn9+hKaoXydjVY5g4FP/o21zabqmkK2BVTDel4G1o7hSZqc5dQANI+4UX78QtUugpYAxbfYEoQU67EhGFkE113/CWt6TpHjnNf1WtQufeCZ3/D334INRhhDUJAvubK9oCoYtNgAoN4T4OMU42OY8M1P7fF/JpTEKeDSqOa3vUYheR1Rl6JPZz9jFaGrx+lCKZY8IkBJGUVLj573xmHW+rVARs2kyRgvgthR6svFTS2dyNk4MsC2T9hhBS2xXvI+2Gp9dJPLUnhF8RCQZpFVCp5om23sHW9dem5ayJ5YFpKc+eMYHUR5cVlJZN/k5lX9YxR/DhDeUdrq1VwkaSpfUr4pM1fQ4sDQEoj2FO2LX0hwWKRWYrxe5GYridD1E92qK4gTxcIi3OELVvrek59RBOJNn/iVCOsbDXmS7Dr1LYMnfBZ5BI0Rff3T8AdRncM6f39hcKw8keP6Dja787TwWviuWxaWmOMqqyMKlgazf5FvohrazK2oVIePpWIRQ5xOvIMMmF/tsoG3+6aJmsoqRoe17TaWcHApQGzQLg3Tih3YqcWpWAF0648jD5VQgWgU9Th3iLmFrlHoDtLbtSKSdiyXQzb50K7PCpyJlSh6B59HvqEBUJuJ1qUMva3diBXbZyYvj4 X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: abde3098-871c-4e89-6685-08d94160397c X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5286.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 15:59:38.9015 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 08+1TEx4Y9LbLJoP+G4HcFSlisRcyDfsNCQxlxpm8kFR9YvwG4QuSFSQJE/n31lYlg9407ycmIAMwzLdVzPizw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5270 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Akshay Gupta On AMD platforms the Out-of-band access is provided by Advanced Platform Management Link (APML), APML is a SMBus v2.0 compatible 2-wire processor client interface. APML is also referred as the sideband interface (SBI). APML is used to communicate with the Side-Band Remote Management Interface (SB-RMI) which provides Soft Mailbox messages to manage power consumption and power limits of the CPU socket. - This module add support to read power consumption, power limit & max power limit and write power limit. - To instantiate this driver on a Board Management Controller (BMC) connected to an AMD CPU with SB-RMI support, the i2c bus number would be the bus connected from the BMC to the CPU. Signed-off-by: Akshay Gupta Signed-off-by: Naveen Krishna Chatradhi --- Changes since v1: 1. remove header file and move in alphabetical order 2. make all comments multiline 3. remove the pr_err, needed for debugging only 4. fix #define tab issue 5. uninitailize err, - correct spelling & remove extra () - remove extra i2c functionality check 6. reduce call to data->client 7. remove usage of union drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/sbrmi.c | 341 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 352 insertions(+) create mode 100644 drivers/hwmon/sbrmi.c diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 87624902ea80..f489972a6309 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -1551,6 +1551,16 @@ config SENSORS_SBTSI This driver can also be built as a module. If so, the module will be called sbtsi_temp. +config SENSORS_SBRMI + tristate "Emulated SB-RMI sensor" + depends on I2C + help + If you say yes here you get support for emulated RMI + sensors on AMD SoCs with APML interface connected to a BMC device. + + This driver can also be built as a module. If so, the module will + be called sbrmi. + config SENSORS_SHT15 tristate "Sensiron humidity and temperature sensors. SHT15 and compat." depends on GPIOLIB || COMPILE_TEST diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 59e78bc212cf..8031acf58936 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -164,6 +164,7 @@ obj-$(CONFIG_SENSORS_PWM_FAN) += pwm-fan.o obj-$(CONFIG_SENSORS_RASPBERRYPI_HWMON) += raspberrypi-hwmon.o obj-$(CONFIG_SENSORS_S3C) += s3c-hwmon.o obj-$(CONFIG_SENSORS_SBTSI) += sbtsi_temp.o +obj-$(CONFIG_SENSORS_SBRMI) += sbrmi.o obj-$(CONFIG_SENSORS_SCH56XX_COMMON)+= sch56xx-common.o obj-$(CONFIG_SENSORS_SCH5627) += sch5627.o obj-$(CONFIG_SENSORS_SCH5636) += sch5636.o diff --git a/drivers/hwmon/sbrmi.c b/drivers/hwmon/sbrmi.c new file mode 100644 index 000000000000..10622b1f23f2 --- /dev/null +++ b/drivers/hwmon/sbrmi.c @@ -0,0 +1,341 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* + * sbrmi.c - hwmon driver for a SB-RMI mailbox + * compliant AMD SoC device. + * + * Copyright (C) 2020-2021 Advanced Micro Devices, Inc. + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* Do not allow setting negative power limit */ +#define SBRMI_PWR_MIN 0 +/* Mask for Status Register bit[1] */ +#define SW_ALERT_MASK 0x2 + +/* Software Interrupt for triggering */ +#define START_CMD 0x80 +#define TRIGGER_MAILBOX 0x01 + +/* + * SB-RMI supports soft mailbox service request to MP1 (power management + * firmware) through SBRMI inbound/outbound message registers. + * SB-RMI message IDs + */ +enum sbrmi_msg_id { + SBRMI_READ_PKG_PWR_CONSUMPTION = 0x1, + SBRMI_WRITE_PKG_PWR_LIMIT, + SBRMI_READ_PKG_PWR_LIMIT, + SBRMI_READ_PKG_MAX_PWR_LIMIT, +}; + +/* SB-RMI registers */ +enum sbrmi_reg { + SBRMI_CTRL = 0x01, + SBRMI_STATUS, + SBRMI_OUTBNDMSG0 = 0x30, + SBRMI_OUTBNDMSG1, + SBRMI_OUTBNDMSG2, + SBRMI_OUTBNDMSG3, + SBRMI_OUTBNDMSG4, + SBRMI_OUTBNDMSG5, + SBRMI_OUTBNDMSG6, + SBRMI_OUTBNDMSG7, + SBRMI_INBNDMSG0, + SBRMI_INBNDMSG1, + SBRMI_INBNDMSG2, + SBRMI_INBNDMSG3, + SBRMI_INBNDMSG4, + SBRMI_INBNDMSG5, + SBRMI_INBNDMSG6, + SBRMI_INBNDMSG7, + SBRMI_SW_INTERRUPT, +}; + +/* Each client has this additional data */ +struct sbrmi_data { + struct i2c_client *client; + struct mutex lock; +}; + +struct sbrmi_mailbox_msg { + u8 cmd; + bool read; + u32 data_in; + u32 data_out; +}; + +static int sbrmi_enable_alert(struct i2c_client *client) +{ + int ctrl; + + /* + * Enable the SB-RMI Software alert status + * by writing 0 to bit 4 of Control register(0x1) + */ + ctrl = i2c_smbus_read_byte_data(client, SBRMI_CTRL); + if (ctrl < 0) + return ctrl; + + if (ctrl & 0x10) { + ctrl &= ~0x10; + return i2c_smbus_write_byte_data(client, + SBRMI_CTRL, ctrl); + } + + return 0; +} + +static int rmi_mailbox_xfer(struct sbrmi_data *data, + struct sbrmi_mailbox_msg *msg) +{ + int i, ret, retry = 10; + int sw_status; + u8 byte; + + mutex_lock(&data->lock); + + ret = sbrmi_enable_alert(data->client); + if (ret < 0) + goto exit_unlock; + + /* Indicate firmware a command is to be serviced */ + ret = i2c_smbus_write_byte_data(data->client, + SBRMI_INBNDMSG7, START_CMD); + if (ret < 0) + goto exit_unlock; + + /* Write the command to SBRMI::InBndMsg_inst0 */ + ret = i2c_smbus_write_byte_data(data->client, + SBRMI_INBNDMSG0, msg->cmd); + if (ret < 0) + goto exit_unlock; + + /* + * For both read and write the initiator (BMC) writes + * Command Data In[31:0] to SBRMI::InBndMsg_inst[4:1] + * SBRMI_x3C(MSB):SBRMI_x39(LSB) + */ + for (i = 0; i < 4; i++) { + byte = (msg->data_in >> i * 8) & 0xff; + ret = i2c_smbus_write_byte_data(data->client, + SBRMI_INBNDMSG1 + i, byte); + if (ret < 0) + goto exit_unlock; + } + + /* + * Write 0x01 to SBRMI::SoftwareInterrupt to notify firmware to + * perform the requested read or write command + */ + ret = i2c_smbus_write_byte_data(data->client, + SBRMI_SW_INTERRUPT, TRIGGER_MAILBOX); + if (ret < 0) + goto exit_unlock; + + /* + * Firmware will write SBRMI::Status[SwAlertSts]=1 to generate + * an ALERT (if enabled) to initiator (BMC) to indicate completion + * of the requested command + */ + do { + sw_status = i2c_smbus_read_byte_data(data->client, + SBRMI_STATUS); + if (sw_status < 0) { + ret = sw_status; + goto exit_unlock; + } + if (sw_status & SW_ALERT_MASK) + break; + usleep_range(50, 100); + } while (retry--); + + if (retry < 0) { + pr_err("Firmware fail to indicate command completion\n"); + ret = -1; + goto exit_unlock; + } + + /* + * For a read operation, the initiator (BMC) reads the firmware + * response Command Data Out[31:0] from SBRMI::OutBndMsg_inst[4:1] + * {SBRMI_x34(MSB):SBRMI_x31(LSB)}. + */ + if (msg->read) { + for (i = 0; i < 4; i++) { + ret = i2c_smbus_read_byte_data(data->client, + SBRMI_OUTBNDMSG1 + i); + if (ret < 0) + goto exit_unlock; + msg->data_out |= (ret & 0xff) << i * 8; + } + } + + /* + * BMC must write 1'b1 to SBRMI::Status[SwAlertSts] to clear the + * ALERT to initiator + */ + ret = i2c_smbus_write_byte_data(data->client, SBRMI_STATUS, + sw_status | SW_ALERT_MASK); + +exit_unlock: + if (ret < 0) + pr_err("SMBUS translation failed\n"); + + mutex_unlock(&data->lock); + return ret; +} + +static int sbrmi_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + struct sbrmi_data *data = dev_get_drvdata(dev); + struct sbrmi_mailbox_msg msg = { 0 }; + int ret; + + if (type != hwmon_power) + return -EINVAL; + + msg.read = true; + switch (attr) { + case hwmon_power_input: + msg.cmd = SBRMI_READ_PKG_PWR_CONSUMPTION; + ret = rmi_mailbox_xfer(data, &msg); + break; + case hwmon_power_cap: + msg.cmd = SBRMI_READ_PKG_PWR_LIMIT; + ret = rmi_mailbox_xfer(data, &msg); + break; + case hwmon_power_cap_max: + msg.cmd = SBRMI_READ_PKG_MAX_PWR_LIMIT; + ret = rmi_mailbox_xfer(data, &msg); + break; + default: + return -EINVAL; + } + /* hwmon power attributes are in microWatt */ + *val = (long)msg.data_out * 1000; + return ret; +} + +static int sbrmi_write(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long val) +{ + struct sbrmi_data *data = dev_get_drvdata(dev); + struct sbrmi_mailbox_msg msg = { 0 }; + + if (type != hwmon_power && attr != hwmon_power_cap) + return -EINVAL; + /* + * hwmon power attributes are in microWatt + * mailbox read/write is in mWatt + */ + val /= 1000; + + msg.cmd = SBRMI_READ_PKG_MAX_PWR_LIMIT; + msg.data_in = 0; + msg.read = true; + rmi_mailbox_xfer(data, &msg); + + val = clamp_val(val, SBRMI_PWR_MIN, msg.data_out); + + msg.cmd = SBRMI_WRITE_PKG_PWR_LIMIT; + msg.data_in = val; + msg.read = false; + + return rmi_mailbox_xfer(data, &msg); +} + +static umode_t sbrmi_is_visible(const void *data, + enum hwmon_sensor_types type, + u32 attr, int channel) +{ + switch (type) { + case hwmon_power: + switch (attr) { + case hwmon_power_input: + case hwmon_power_cap_max: + return 0444; + case hwmon_power_cap: + return 0644; + } + break; + default: + break; + } + return 0; +} + +static const struct hwmon_channel_info *sbrmi_info[] = { + HWMON_CHANNEL_INFO(power, + HWMON_P_INPUT | HWMON_P_CAP | HWMON_P_CAP_MAX), + NULL +}; + +static const struct hwmon_ops sbrmi_hwmon_ops = { + .is_visible = sbrmi_is_visible, + .read = sbrmi_read, + .write = sbrmi_write, +}; + +static const struct hwmon_chip_info sbrmi_chip_info = { + .ops = &sbrmi_hwmon_ops, + .info = sbrmi_info, +}; + +static int sbrmi_probe(struct i2c_client *client, + const struct i2c_device_id *id) +{ + struct device *dev = &client->dev; + struct device *hwmon_dev; + struct sbrmi_data *data; + + data = devm_kzalloc(dev, sizeof(struct sbrmi_data), GFP_KERNEL); + if (!data) + return -ENOMEM; + + data->client = client; + mutex_init(&data->lock); + + hwmon_dev = devm_hwmon_device_register_with_info(dev, client->name, data, + &sbrmi_chip_info, NULL); + + return PTR_ERR_OR_ZERO(hwmon_dev); +} + +static const struct i2c_device_id sbrmi_id[] = { + {"sbrmi", 0}, + {} +}; +MODULE_DEVICE_TABLE(i2c, sbrmi_id); + +static const struct of_device_id __maybe_unused sbrmi_of_match[] = { + { + .compatible = "amd,sbrmi", + }, + { }, +}; +MODULE_DEVICE_TABLE(of, sbrmi_of_match); + +static struct i2c_driver sbrmi_driver = { + .class = I2C_CLASS_HWMON, + .driver = { + .name = "sbrmi", + .of_match_table = of_match_ptr(sbrmi_of_match), + }, + .probe = sbrmi_probe, + .id_table = sbrmi_id, +}; + +module_i2c_driver(sbrmi_driver); + +MODULE_AUTHOR("Akshay Gupta "); +MODULE_DESCRIPTION("Hwmon driver for AMD SB-RMI emulated sensor"); +MODULE_LICENSE("GPL"); From patchwork Wed Jul 7 15:58:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 12363003 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,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham 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 2B92EC07E95 for ; Wed, 7 Jul 2021 15:59:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EAC461C33 for ; Wed, 7 Jul 2021 15:59:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232069AbhGGQCb (ORCPT ); Wed, 7 Jul 2021 12:02:31 -0400 Received: from mail-dm6nam10on2063.outbound.protection.outlook.com ([40.107.93.63]:27936 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231685AbhGGQCb (ORCPT ); Wed, 7 Jul 2021 12:02:31 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XYKAPg2YQhUo008WJbk6/YlNF8P7zuQ3G1arkx1GOI3Ng7c08EuEpUT/o2lM8ECNQQcz+7fW1qdl0RgTEE7ep3R2CiX1Z5Kdr3bs1L3gK9wTCVRHuullNnqLhSzPtRVLOdbZCRXsEJvnANkAzzaIda7nAlzUiO2Qq15qrwxHv2eOH2dF4ATjXIae5cT1hXm/Ml3BPStXWzijI4v4ixiT0HDElmryLW1U0tPum3SV+a8LkjxCqezBoMovC8GKYDBFik3h08vTTBFigGYagB8mq5jM1HeiNZYi+MpG7DPftcoEnGlzaUlnhNeEGJH/4JiAx4+5c5lAVY4kY2gEikACrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SID3vOKI6Gz1SoYemi/CdbCph+me+3Id5iZGr2o2UMM=; b=ks2rh2wV263tDzbqXnxo75s2PXcJkfhS8PHnQ9fbKKWEkgSq1UKnvLRh0KFQvtKVkjGdCOOQYvGPwkaF294kb1QYL80sI0kUPEoWCMugFdLEc55l8HA+eKO9ehRAmOdVPrqJl6fQhJcv4juvKXNWWOt4Lg5cTwHD5EtsVzotA9F030iQNLiTO35ZY6fG+e3CcbwWY5Sa4stwh6FbFcHKEy0mPlhSJFznOhnoTexF+W4NmXDsfmnSua9VGy4nJigXZyDxT1rTIO2PlpYEPkbPOT7nQpECiShpqYjeXdMZ9Da8gxanC3GgBFmSf1wQpUv4ZXUE5zck7sWdepBW32CHng== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SID3vOKI6Gz1SoYemi/CdbCph+me+3Id5iZGr2o2UMM=; b=f82yiFMHFrQUijaMQSmoRCvNjvkBKgQSbWztDFhur0xjee5G4Mkr0jV0icwfm+GkswDri1Kb4EYBYr7+AOYaawQrg2LmuBufSB7TWoToOm8bxWcnvIvoXPewPgoJVuF3uRnB22DVW+AESgVC4Iik1t9SzSndBqARh7YekOTpPr8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BL1PR12MB5286.namprd12.prod.outlook.com (2603:10b6:208:31d::6) by BL1PR12MB5333.namprd12.prod.outlook.com (2603:10b6:208:31f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.31; Wed, 7 Jul 2021 15:59:48 +0000 Received: from BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::8ce:4339:7e20:7022]) by BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::8ce:4339:7e20:7022%7]) with mapi id 15.20.4308.020; Wed, 7 Jul 2021 15:59:48 +0000 From: Naveen Krishna Chatradhi To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, Akshay Gupta , Naveen Krishna Chatradhi Subject: [PATCH v2 2/3] hwmon: sbrmi: Add Documentation Date: Wed, 7 Jul 2021 21:28:58 +0530 Message-Id: <20210707155859.86240-2-nchatrad@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707155859.86240-1-nchatrad@amd.com> References: <20210625132544.18094-1-nchatrad@amd.com> <20210707155859.86240-1-nchatrad@amd.com> X-ClientProxiedBy: MA1PR01CA0139.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::33) To BL1PR12MB5286.namprd12.prod.outlook.com (2603:10b6:208:31d::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from milan-ETHANOL-X.amd.com (165.204.156.251) by MA1PR01CA0139.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 15:59:47 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c161a3fd-5e97-46ef-632e-08d941603f71 X-MS-TrafficTypeDiagnostic: BL1PR12MB5333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:9508; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 5tDaGhBtcMX9PwuIcoCZvR6+XXlYPXFR+47nRkUEgoinsbQDZEWwKlJrVtxPTiTfDVII1r+IRQ4tpvODsotTYDreGPPvgW1l2idzPWvc83ROXfO1QzpPGRoRJ/zvIAdBGKuGOPWuJt+4rY2MgpXB7r+oEcVS4/ewNQElIIPAh+Fxp4zPQIemE8DWJM2g5RBSuJLURF5URr+O6SdTytq07lRf7IBADq67cIvwz1numjBV+clW8g7u0CKdv01TF/fqSlIKyzvSZY4UwFVhHVVBozB8CrrtgQFVR1nW3w8RhEfpwYLfn4ULxH8eLi5TkVJmR9FjQ9XQWPCuwntInkZcz8qT94yr3wmDdZQ+W1RTQM4sUSVTVZ6jj7TbRShArYYUlTNKgmUJGY9REm3dsrUlINJsUhE+CwRACMI1yoI54The63M0HSIm9VY9WwhohQa698FDFKWreyrLCGxYN0vDh8FxkgJBhCzT7YRN5T2a+QaJtBd0YaTwdkx2dUdfizPEpw2hDqJyUMixdIhq71dBtPo66XQ4cZQHoAyVw88aOLl16Qh2yyG2/jn1cQgn7+sbfAJo8iqDssPrjSQ26Fixz4Vfp9W0JSwRO/gER62TC+S10iiKnhYU6PLSwBWymCvgjkaeieK1J6G3wTClZsb1+U6lCl3MVjDJ0vQIDwDMlvSIJsizIUfjt6g0CtqwP8Waa7zCM8hqPqCgA9BCz+Ooi5h0zqKQZQIfCRTztM7X3U20S2RHbYoKXrEpjqlF11mX/Ra7u6aRvJhlH1NX0BfSusce+jyNtlc4Tv/UPovCPHI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5286.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(39860400002)(376002)(366004)(346002)(83380400001)(36756003)(54906003)(38100700002)(8936002)(956004)(38350700002)(2616005)(66476007)(186003)(6486002)(7696005)(4326008)(6916009)(6666004)(5660300002)(66946007)(316002)(478600001)(66556008)(26005)(2906002)(52116002)(8676002)(1076003)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: WkozESuhFk5ysun81ZA4DKoR5VByncvVrLLwOeKvyLZOpmlvfLOJGzNdvLEj8cF30i6R5hk5LPbFVkV7mADUYKOfiF9RBI4dojl/e6o0UDA/s7br6apZOqRP8ALJB+ibKDqs7rd2mrNJggJgOtnvz2sAW99ZQOXm3+Z3CIoAHbdQFFXuRfDn/6UR1+RktCs7P3qqMclXC+H36WN3emtwlWfmcjxP0UFryyHDgPo9a1Ktb8vx+HGu4EuphXnUMQiTTGdjk+qZ+K+fYXqo/dP4R52HMvjbcwzSGZWezvG3GZXATzPappBQ9lhhlh/gouklE910S3V7ZVakR4hemagJs3Ua19z3IYl1kl7xaTTaviRaZwRsUTdv4sFuHgpsBKO20bRPayapvWxEOd9hiGK2rIBoAYBx9zW4KmpgTIgGTvj+VOZyd7GzbGU45/aqgWJi/gJqh6zoOoPbpB/sWYd3rqRGrDPrJ0sBArCAjS8nW4JUPlLaQSpbNE9zOTw8vmFeoddjFGuI+phH0Hgy9FyNcREUygP97AaW7jLnaBpq41EMujktmtVUIQTf3wLJIWHdZR03tSJWbO0nGvwK0NFVOJu9APBoWjeKLvHK34qHn7bjbiuxVfqtd4MHS2Gou+nRJgNVnl4lYokQbjmGNb+Z46piAKgykBtvUboO7/iui/eV83rFGkoJkRAWdfZ1g+B03VFnZLzuLDUflRPPdlXI5NCUPEdTFWhNb7gFgl+irkgQC7rDMDrqdcn1U9od73goh2+dFhpb95ormUH4WrEKOOvRQFCg1+V+vRCy8ufUYAmDCXyNpnRCT35BlGTbC54cUwXQu6Nf5c3qMhL4mwYmLPx7R+jF928Qz6NTE5WFIHESVPzeFShpd61T06fSAC0N3EcuI02RRwnyzVy4GPcF8bOdy6ZZb1jc0tYdSpmxRHXNh86nKQG9VqeJt9hk8qSMyKF12CoH+y/Tt6wK+5Q9sBaDGSKsmJC0UNIBYnGP2HYV1//oPNUqzA0fvfO9tNo8BIpy2XqP2WCYzMo6d/tiwqAwZSYiUY2MCfyOEuugavz2Xd7qk/Zv/bC9Pn6771pTxZqRwZVFc327j2E2S3ETY+Svjr0DsBbW/gdKOAZN7x2Qo95q2fRAKeVu54sBq2/Y6pzJi4qgCgYNGKUIqpc+Ot06zEBV4N4jCLk49ss42/3ZPnjVGNsR1mFz6H0jGKrebA7kqRrsnTeESvc99tM1bBWZqPVF2SK8517s4S7kj/9locYSvhYg9jlPEChjNxsdesGCacS6me4bQAd9fmltBSOxPfI9OTuuW3RIlq2EOOB1qigm9O8wM3QzasrpQanl X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: c161a3fd-5e97-46ef-632e-08d941603f71 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5286.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 15:59:48.8340 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: PiR+l3Ck73/TxJPn9VveSdqmu5plcNI4bl2xnu2UvuULEZaA5fIOqKRziCx4M38A+TRUw1/6exG6UITn1q2psg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5333 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Akshay Gupta - Add documentation for sbrmi module Signed-off-by: Akshay Gupta Signed-off-by: Naveen Krishna Chatradhi --- Changes since v1: - correct power# to power1 Documentation/hwmon/index.rst | 1 + Documentation/hwmon/sbrmi.rst | 79 +++++++++++++++++++++++++++++++++++ 2 files changed, 80 insertions(+) create mode 100644 Documentation/hwmon/sbrmi.rst diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 9ed60fa84cbe..5cd4798fe193 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -158,6 +158,7 @@ Hardware Monitoring Kernel Drivers q54sj108a2 raspberrypi-hwmon sbtsi_temp + sbrmi sch5627 sch5636 scpi-hwmon diff --git a/Documentation/hwmon/sbrmi.rst b/Documentation/hwmon/sbrmi.rst new file mode 100644 index 000000000000..296049e13ac9 --- /dev/null +++ b/Documentation/hwmon/sbrmi.rst @@ -0,0 +1,79 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver sbrmi +=================== + +Supported hardware: + + * Sideband Remote Management Interface (SB-RMI) compliant AMD SoC + device connected to the BMC via the APML. + + Prefix: 'sbrmi' + + Addresses scanned: This driver doesn't support address scanning. + + To instantiate this driver on an AMD CPU with SB-RMI + support, the i2c bus number would be the bus connected from the board + management controller (BMC) to the CPU. + The SMBus address is really 7 bits. Some vendors and the SMBus + specification show the address as 8 bits, left justified with the R/W + bit as a write (0) making bit 0. Some vendors use only the 7 bits + to describe the address. + As mentioned in AMD's APML specification, The SB-RMI address is + normally 78h(0111 100W) or 3Ch(011 1100) for socket 0 and 70h(0111 000W) + or 38h(011 1000) for socket 1, but it could vary based on hardware + address select pins. + + Datasheet: The SB-RMI interface and protocol along with the Advanced + Platform Management Link (APML) Specification is available + as part of the open source SoC register reference at: + + https://www.amd.com/en/support/tech-docs?keyword=55898 + +Author: Akshay Gupta + +Description +----------- + +The APML provides a way to communicate with the SB Remote Management interface +(SB-RMI) module from the external SMBus master that can be used to report socket +power on AMD platforms using mailbox command and resembles a typical 8-pin remote +power sensor's I2C interface to BMC. + +This driver implements current power with power cap and power cap max. + +sysfs-Interface +--------------- +Power sensors can be queried and set via the standard ``hwmon`` interface +on ``sysfs``, under the directory ``/sys/class/hwmon/hwmonX`` for some value +of ``X`` (search for the ``X`` such that ``/sys/class/hwmon/hwmonX/name`` has +content ``sbrmi``) + +================ ===== ======================================================== +Name Perm Description +================ ===== ======================================================== +power1_input RO Current Power consumed +power1_cap RW Power limit can be set between 0 and power1_cap_max +power1_cap_max RO Maximum powerlimit calculated and reported by the SMU FW +================ ===== ======================================================== + +The following example show how the 'Power' attribute from the i2c-addresses +can be monitored using the userspace utilities like ``sensors`` binary:: + + # sensors + sbrmi-i2c-1-38 + Adapter: bcm2835 I2C adapter + power1: 61.00 W (cap = 225.00 W) + + sbrmi-i2c-1-3c + Adapter: bcm2835 I2C adapter + power1: 28.39 W (cap = 224.77 W) + # + +Also, Below shows how get and set the values from sysfs entries individually:: + # cat /sys/class/hwmon/hwmon1/power1_cap_max + 225000000 + + # echo 180000000 > /sys/class/hwmon/hwmon1/power1_cap + # cat /sys/class/hwmon/hwmon1/power1_cap + 180000000 From patchwork Wed Jul 7 15:58:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Naveen Krishna Chatradhi X-Patchwork-Id: 12363005 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,MSGID_FROM_MTA_HEADER,SPF_HELO_NONE, SPF_PASS,USER_AGENT_GIT autolearn=ham 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 8AAA7C07E95 for ; Wed, 7 Jul 2021 15:59:58 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7388061C6C for ; Wed, 7 Jul 2021 15:59:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232070AbhGGQCi (ORCPT ); Wed, 7 Jul 2021 12:02:38 -0400 Received: from mail-dm6nam10on2089.outbound.protection.outlook.com ([40.107.93.89]:6176 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231915AbhGGQCh (ORCPT ); Wed, 7 Jul 2021 12:02:37 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iq/JvP2cz6DWxiRIFoX92mTQCS2G0yWQ9JH0cpDEU88uSry29o6aT/r5m3p9K3THpViMutHoQVoAycWUOvBrV4UVJ/LeIA3ZKuahbC4qpo++HK5fFuzWv2sjqZWVltFmKNcRc+tXmVUsE8auMH5sg2u764rLs0zCOpNRBDHDBoli+tYf/HMBSEilxaC+XEuWv5Rwt9VXwN3FgGcSwjZCJyBRJ4GP2QcTXvu5E80WqwIRFcj7IBXMYtNhA7SXYMQuj8sxRP0Abj61CwRhaBARrGvkRFM8OvW2KfrLzyUdOggBg1II+CqtoqgNn1oTa5zN8vIjl1GVjm6AZQeI1shgUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wN0xp14tJkYZ19asBQJsG8iwflpUSRdmPrFjX5q5kAk=; b=auvHcuPKj/0TuUkRF1Futf3PRMIpctF9ETw4SONOs5XdLw3DwB2M/MKlw7ISNtV2uNvgRd3oStOruMk/sxXUpjs+pF/5WJqMQ6xAcT0m7EwOHck/YcXMPU8QcxMzrQ9N4FvElLtj/gzLIb6mAWw4nx3nhtpf1mypABmbefvj1l/X/W/Hn9Or4AKgrxP33ns+C42sOUpUQae7+chpzpEEiC1ly3EoD2H4q894sLSKrmh6To3CP3RefQ6relo6gpI71fjuEpwsXVdwFd6KsTP4vPfZ3tNhyQWAuyG2oziRUHKjPzzLdb1ERA8vHBOZzLQPZGFHSc9WK8hqtho0rXB3hg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=amd.com; dmarc=pass action=none header.from=amd.com; dkim=pass header.d=amd.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wN0xp14tJkYZ19asBQJsG8iwflpUSRdmPrFjX5q5kAk=; b=0r9uba906V5WBKDht8OqN5/1/ytQv5QZpTtPUkm62Kcn7pu1LPRLGN/ZRRa46nQyrPTgsRIN7sk/lXYdVk1IyWcYArHTbEbvGKZCyt1Sr/D5YQN36u2xk4SlyPKLkJ4IXF/iqIl9YkdB2odA4WQXN5x0usdIkhP+z8QNFFVWvhc= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=amd.com; Received: from BL1PR12MB5286.namprd12.prod.outlook.com (2603:10b6:208:31d::6) by BL1PR12MB5333.namprd12.prod.outlook.com (2603:10b6:208:31f::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.31; Wed, 7 Jul 2021 15:59:56 +0000 Received: from BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::8ce:4339:7e20:7022]) by BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::8ce:4339:7e20:7022%7]) with mapi id 15.20.4308.020; Wed, 7 Jul 2021 15:59:56 +0000 From: Naveen Krishna Chatradhi To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, Akshay Gupta , Naveen Krishna Chatradhi Subject: [PATCH v2 3/3] dt-bindings: sbrmi: Add SB-RMI hwmon driver bindings Date: Wed, 7 Jul 2021 21:28:59 +0530 Message-Id: <20210707155859.86240-3-nchatrad@amd.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210707155859.86240-1-nchatrad@amd.com> References: <20210625132544.18094-1-nchatrad@amd.com> <20210707155859.86240-1-nchatrad@amd.com> X-ClientProxiedBy: MA1PR01CA0139.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::33) To BL1PR12MB5286.namprd12.prod.outlook.com (2603:10b6:208:31d::6) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from milan-ETHANOL-X.amd.com (165.204.156.251) by MA1PR01CA0139.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:35::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.21 via Frontend Transport; Wed, 7 Jul 2021 15:59:54 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a37b2ec3-d4b4-49c7-d59f-08d9416043db X-MS-TrafficTypeDiagnostic: BL1PR12MB5333: X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6EeSwGhEZwtAkAccPOqJEOTZlG9wRYfCH/QG6UND9sZX5Dc08XR7cqxxIlf88zmAClj4M31vhleePNDjNm7TobcRK053EJOP8/GMr+M5yeGYagVIvSNjz41w/w03iO+0pF4xV0/jtfq6xMvHZ+j1qEWnWzvfT4DVg3S6Jo9ALkarIPz4GM0rwD+9e86bveq1gecs9Lvx5lX+BlxbwFdik+rQJnp2YgrFvpw7s1CIKGMQ7O169N+/1NJlSxu/F835mSHGd9l3KkkdlgdtYm1//28iB50Ie+VBnrt1UI75iEfZZKmv22HSFED9LNVWELF/oQ5izrpTjnYsTl8RZSv/3po0J4ljxQckkVA2YGWg3hVGODb999rUJ6BIERbvEcFaXGSL5jI/j4Duc2ml0QRUrarOOVL+xE/9o8Z7Wp+zabpkIQ7GJ41svskktFOQIbfAb1zg64gU1iz/e1trTTNXLvhRpVWW2SOY8YbtOADPrJxz2H9Dy5ZdxbEX4ZhMPM+3zLSwVZaAtLa1y39pKKGyn2M8ZH7f045jVuPVFQcQkb4lV4pmimzWfBg+ydDnhgR3DCAhKT5mO9XyxkeiCjFugFl5aOBAej20uIawg+HmE5zM23P6zgbXGgzTVmeOK5QIJy1L8Kry0AaWfkhDzMlB1kd5cZ4C2HyBO7ZszdvY0TBrqumy9HRcB82Ggmas42EyuE0xo5p6x7RGUsCYXQkAXBQEWQeIe2Cj7GQDVur0vReEuo2IwzrXEeVVLOL+HxyDXYLZozM3dzKywhm5De9Afw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:BL1PR12MB5286.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(136003)(396003)(39860400002)(376002)(366004)(346002)(83380400001)(36756003)(54906003)(38100700002)(8936002)(956004)(38350700002)(2616005)(66476007)(186003)(6486002)(7696005)(4326008)(6916009)(5660300002)(66946007)(316002)(478600001)(66556008)(26005)(2906002)(52116002)(8676002)(1076003)(966005);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ke2lA67TWB0Jf/2bp1deRyV2ROfB4rJv2ejy5IF8RQm3vC/fWcpizIETsvCT1Jfqw4rTVS8p5HwCnBZgAc3B6ti/q5Mj1eXWZ+HNgpuCljkGxWOjsxTEiAea6dLgjC/Sa9uL9r6UigkWb8inDixUkw6c4rYDS95Q2j/FUEjJmcAjIPh57Pzx26g0EkEZwhcYGa1e6U6j8wHX4Qqwu23j1QYAvHT208F36OqdEsF6P9IjOp4UJSm3pGjL/2V7mDikB8sHo20gWF6B9Z7GnaRzSxPhM26TXdEEzuurRH18Zzff3qP2+rgg9YdDtFdFfG8/fBwTLfS14M/l7tXYyfRcNwwmZIyCGNS7/rJuiGUDjFjYIS28y/s8Z7XFCKa/PJYCfrMbvbEAP8YlUAnq21UI2wjk52xEyo5MJlch5hkCKqz6P8olbOgqCw5V1rkksjLoRGt+cSpV1EJVFmbW4+psLqOVTJN0414Riqmlu9DokV7r4ACTtpYenbc0Q/2wfOOKeijEoV1NdCuRGfJYzKMqb8N5BWGDGMToQCtyC0kngU0FFkQkKQJC9llKEmst31eDBRN30hsA1Obr93LiEi55zQpA4M73Yzf4M1AWWTmZbRUPYyLh1Z3urSEzT6muWuQO22wZEs5XrzC/vFYmstP1x7vQ9jS3cV2g1G97iMD4DWjSHPUIqsCLKX4J4Gl6j+0JHDFMzTzHPp/gPaheAWG06mXg2RNiQA3eT9oq/Uv7C2Xf5JEE32TLgsswQnV0quBJs3x88qvv/LRqgG3VuFQkPpX7AolX0JtusrN2hMu9GWwWTdhMqX6oo7v532CV09aHLJEJH+iSXE4oZBfyhJQ3QS66ATJdbFli/t1MFrnrtoaiCVIM5QnH45NKwVDYbocxPly05qJnccZz2tv6wCsJnfJjcnijDMY0CNlDFMUDtrKHEgmqOP99y0ZDjYA61XffdV89B5qitG+WtmoUxa3zvn/ou7z7y2vDM+eCm7T9ZmzKbzWthBFyon/7VlDmxPypZa9Ge97uNd+xkd/goWu+Sjxne4Vvti/qQkzwYCND/9POd1Hvxnn3qr5A9Msdg4PW8geKwy3LcW7S+wkFquYaTwsd1DouIOS8RqCrV0Z0EUXku3CI8tcFJgGvuwHIBjI7FXkjImOMYUNAzj+H2g+QkDr3T2ffal0/L4aILM836NO81dAHd5jfMffhNqKDV6/3L2V1RMkaC7ljHfta06Hs8lGOKvhlOQCClzp9GxqPk/NCORHq6/DHM5y1KTwo3sRoP5oDtsUulZ578G6tMfxjEEwGlHMKSYIRzEqvUbfKtHyPKT93mN7AUdAX3Yl2/fiZ X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: a37b2ec3-d4b4-49c7-d59f-08d9416043db X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5286.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Jul 2021 15:59:56.2395 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WvNLpfV69u0QDhJaeXCK47Q0vALh6hjVO+thMkdPbwaiEcdwOdQe2gVmDVKmROGAvRXc9qcJDrTtQvFcNlsSMg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5333 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org From: Akshay Gupta - Document device tree bindings for AMD SB-RMI emulated service. Signed-off-by: Akshay Gupta Signed-off-by: Naveen Krishna Chatradhi --- Changes since v1: None .../devicetree/bindings/hwmon/amd,sbrmi.yaml | 53 +++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Documentation/devicetree/bindings/hwmon/amd,sbrmi.yaml diff --git a/Documentation/devicetree/bindings/hwmon/amd,sbrmi.yaml b/Documentation/devicetree/bindings/hwmon/amd,sbrmi.yaml new file mode 100644 index 000000000000..7598b083979c --- /dev/null +++ b/Documentation/devicetree/bindings/hwmon/amd,sbrmi.yaml @@ -0,0 +1,53 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/hwmon/amd,sbrmi.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: > + Sideband Remote Management Interface (SB-RMI) compliant + AMD SoC power device. + +maintainers: + - Akshay Gupta + +description: | + SB Remote Management Interface (SB-RMI) is an SMBus compatible + interface that reports AMD SoC's Power (normalized Power) using, + Mailbox Service Request and resembles a typical 8-pin remote power + sensor's I2C interface to BMC. The power attributes in hwmon + reports power in microwatts. + +properties: + compatible: + enum: + - amd,sbrmi + + reg: + maxItems: 1 + description: | + I2C bus address of the device as specified in Section SBI SMBus Address + of the SoC register reference. The SB-RMI address is normally 78h for + socket 0 and 70h for socket 1, but it could vary based on hardware + address select pins. + \[open source SoC register reference\] + https://www.amd.com/en/support/tech-docs?keyword=55898 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c0 { + #address-cells = <1>; + #size-cells = <0>; + + sbrmi@3c { + compatible = "amd,sbrmi"; + reg = <0x3c>; + }; + }; +...