From patchwork Fri Jun 25 13:25:42 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: 12345067 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 98434C2B9F4 for ; Fri, 25 Jun 2021 13:26:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C34F61962 for ; Fri, 25 Jun 2021 13:26:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231618AbhFYN21 (ORCPT ); Fri, 25 Jun 2021 09:28:27 -0400 Received: from mail-dm6nam10on2069.outbound.protection.outlook.com ([40.107.93.69]:16416 "EHLO NAM10-DM6-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231617AbhFYN20 (ORCPT ); Fri, 25 Jun 2021 09:28:26 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=EeGK/q2z6jJgSRYDAi6WmHCuaitp5vjko5cwkpqmIFiPMY5vhjF3RGSDvJbG1H4xHRJtLW/mDOF0CuBjeEHduHmAnooVEdVVA+1wbbRS0iN0V2lkNjkuoQ8ljtucpJaM7AzxCkWDrve6yLefRs4RQfEXqiSZX/MYJ9D0AWRS4Xdi6M0qRew9e2huqUYdU9DLI4B34O7zd319wVopmPKIqIiyaM8LdVIOu1HpOlnD4HKwkCgvaXSMSwh35NPbTvKWOP0tPapOdDPghlObnTB8FeuIFD8dOCVj2dMZrx4QJqYQkXXK16KJJD1ZbiAFKeJYJaZUM/+LAP0NuNnjW1V7KQ== 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=ZtORC8AYLiFwXNcPWCbm0211Kdna1m30tK23kf8njF0=; b=Gm/plh2B8g3iRUIDKhdc7jWym3KRp90aijj1OVcsZi+A3fHzWBkzarKAbgK6QoJ4Iir/RUMw1T1fq6eM0DklempsPHWxJ8HsEhnzeaZ3aDLYg77BhMfsS+Ppf6EItSdj1trEU6tllGrj/R8mDbY/p+KeTexY9EvT33AM1AZRLm2R+8laZ5Q86RyI/VVAtmzNZzugCp/R5HpGZDnepRDqckemze2oTAZE0s0aTcjmDtOCymmdjkV5mWY4Dp0/TG7LLFMscV7PA0J0TOirMZd7hMEUl7EIpwzOtIU9c4UVc28H0/rcyza4RhnXhofhm/TiRjWA9URkyASA4jPvaUCYEg== 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=ZtORC8AYLiFwXNcPWCbm0211Kdna1m30tK23kf8njF0=; b=JDKCgWaPpsi75EN6+uebuzqKdk/v6H3IfdzUJg98r+dM/MH+eFIqEgOe84f8dFLEg8SUB9In0AJNXI3dMPftDxLFMawlhQbOPNDt0Wn/cRWpcMttr3vqeWEYs+J7Ki3B4abp11v/HvLEu+RjfDWSH1IxDlSAiVNIAVTOgwbIU/Q= 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 BL1PR12MB5032.namprd12.prod.outlook.com (2603:10b6:208:30a::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20; Fri, 25 Jun 2021 13:26:04 +0000 Received: from BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::1514:9ec7:76dd:568c]) by BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::1514:9ec7:76dd:568c%7]) with mapi id 15.20.4264.021; Fri, 25 Jun 2021 13:26:04 +0000 From: Naveen Krishna Chatradhi To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, Akshay Gupta , Naveen Krishna Chatradhi Subject: [PATCH 1/3] hwmon: sbrmi: Add support for sbrmi power module Date: Fri, 25 Jun 2021 18:55:42 +0530 Message-Id: <20210625132544.18094-1-nchatrad@amd.com> X-Mailer: git-send-email 2.17.1 X-Originating-IP: [165.204.156.251] X-ClientProxiedBy: MA1PR01CA0171.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::17) 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 MA1PR01CA0171.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20 via Frontend Transport; Fri, 25 Jun 2021 13:26:02 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 21cde9cb-92ea-422d-6b1e-08d937dcc804 X-MS-TrafficTypeDiagnostic: BL1PR12MB5032: 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: B7/QoJeC9lBCQ51LvN1BTKdwx8OijYNIQfMPf+XxwkyTl++lgOn7TAQk9hcKH0K/W+Pj1i8i7DJ7UpTvie4qdfQscWNHlVBL6OxYb+x4xf2xHeyNvkq4V+9pEDCh/mNmofnXfhGfk1hCBstNeSwyFIrPV4Yt5xrTYKcd3g2Zhk5CgVC06eZgGk2I7F3NxoEcsFNg9ZJEHawSj4CxpvWA+HjoAE5VLhMQiGvGMgzcNemLo50HTGf3uR51Yvbg6WNbWVZd8A1ZLKygXqjLC0plqUSOnv9ZxQoMQPnoCmiDseRl5GeN6HUlYIqlrpB8MqzwzVE7JlhFdba1wSSVkJ/bWF7DTa2mAQbJbkJrOKT0np1jFIv8GVpYbiPVuIxQlCd0KnyiBm/c9eA1eU35Kgw/fb7xeMRcwLxk5xjBa68u9e4bnUA0qtI8/pyoGOyqm5/MzEkrbPiainH+Q/gI1TLqii1ysfjdUeUZcBgybAJlj2LhQ5IzMG+9C+jxUv4SG8TXny6sPlxJ9Oz6GNV9uGR4OGkbTIQA/rdAeVsVcQeI5/PA4/+/gUQptUZbnDC/jlvsaRgkLP+THMlAzEQZsb5JRXWNPdBumLm2jVcPLG03rKdyHXqruWevC4FVTdcL8Jf5xOU8Auuzrhd2BGr1Kvzxb4Dc+PcIhpKYGLGT9boLsmNk21DsAY8ndswxGgUmAmUGCsHce8LN6/2FRrGbsYm/nQ== 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)(376002)(346002)(39860400002)(366004)(396003)(38350700002)(38100700002)(186003)(16526019)(7696005)(956004)(54906003)(6666004)(2616005)(30864003)(1076003)(52116002)(2906002)(6916009)(316002)(26005)(5660300002)(83380400001)(478600001)(36756003)(8936002)(66946007)(66476007)(66556008)(6486002)(8676002)(4326008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Oxi307V4vhmNK65HBckn+ndTaA733UY4wAtt91Ox65nXWrKuTuuF5n9dyDHdg8taSiq3RAgMbGfozEeuifvGvjB0ehE9Npx0eXkp4cf8cnC3AM+ktlLdbhvI7uBCQ8FUDzfOdq2sR/wbzwTFUjcDJnJPDswOStz+DpcKWlhbrGHtxKQzuzKDE5xSLw/RBlP1tlW1ge445fBhcxeRc4dToxQwpSuUOTeiHkjthQK0kJKoQG7tVw8OTlxzDog6XdrH+ZX5ASdpA0qIoUZL88J6hIGrZYt54iaJf2PJy3EL8ePgf8EjpLZ4DvTMXgT9kKaTz9SsVO1QuOfW3t1sKzjwKsJebasniW5om1fimaajpcFc5ixVOdUhwd+Cf6hHKRfYyk0JfDPSJWqGctT4WrbIyhF05zkyqe8pY8lVND4Yt/lkqMGbAlCtVf/MfHBTDhul5n/dLx4F78YLssVcHtlde/WSGERHvxVXAnb4QAsYZtK8/RY5k9UtIHNET4H8b0corMYv8ZeMmqtLX4iE1BZL7RMj1LuaRlelAezBqpz34MlK80r1WU3LT8LT0O+hsK55J8Dha7ruHTuMagZzSQt4QcY+surmZGotwAfFPkurqpCU13XPxDtPKVK4jKwbyOTiL5QdUTmUQyO8AGmxh+QtckwboD43us2Y93jwzAyC0NobNX6p5uBYZlayfErm+Fm0f5VdptVPHr6GComYYU/7jSRfNHYuzeFaAdIgY696FGAhPA+UHJPprhXz+v0xag7F47Sb1GrXRfOv6QuamBlx3uIkFFqNCI9no1dDccXfQVfxAxdBDkubmMBz4LTpHW10BBLBEwAqorw9InMbQzMiP4RPlAyhdEaFapKuN5F+Qagmm6MSCpZu/3nk18cRB11ByIBPdWfYYccxNT46jiOTFFFeEWOsMX3FiVQ1iTlNqduGQcbo2cMKVT8BgCgDHiFRt6wvps148d96ds0n8sR6hZ6afOv/lhwl2wEnWfIaqjPt+dicW0HNpbVWSjREUdMFY03WmkX2Vl7i4+fhtzkR6BU41MUZ84Mj7PtMs4YwjFx0ABrGYfLkIgvmbaxeBJr2pOc/by+WXKhscc62WSCLWmhup+XPraCcOzPdrI7YfF5fLEnzzqY9YEuAz5QDaN+JT8REzEBvQwBmx1jiCR+LeSzzzD7aO+7tkWfq2/1k3w6O8otIApTs5gGnHZ7XsU9x71qgzdXvRnZdWrQMpGbucxSjO7ojIa0HcXcWjkSRnUVszKsTuIZaGwduS6zPReQdFyHSO+fbUCDUvYFKPWwY9nn9wqtVXNW1NVZ1Drwy5qIddjB4m++mbTSgb+OWWGRm X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 21cde9cb-92ea-422d-6b1e-08d937dcc804 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5286.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2021 13:26:04.0479 (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: uJkhiJ1gDCBaweZsvxSrSR106WpUYchGY54LNy3yMKWKz5LbhtTpy9w/8NdOclRF97FDk99V44MUL53UxrzNlg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5032 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 Remote Management Interface (SB-Remote Management Interface (SB-RMI) which provides Soft Mailbox messages to report 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 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. Signed-off-by: Akshay Gupta Signed-off-by: Naveen Krishna Chatradhi --- drivers/hwmon/Kconfig | 10 ++ drivers/hwmon/Makefile | 1 + drivers/hwmon/sbrmi.c | 394 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 405 insertions(+) create mode 100644 drivers/hwmon/sbrmi.c diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 87624902ea80..d1813ea8382c 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..c35829513459 --- /dev/null +++ b/drivers/hwmon/sbrmi.c @@ -0,0 +1,394 @@ +// 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 +#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; +}; + +/* Mailbox message data format */ +union mailbox_word { + u8 bytes[4]; + u32 value; +}; + +struct sbrmi_mailbox_msg { + u8 cmd; + bool read; + union mailbox_word data_in; + union mailbox_word data_out; +}; + +static int print_mailbox_error(struct sbrmi_data *data) +{ + int status; + + /* Mailbox error code will be written by Firmware in + * SBRMI::OutBndMsg_inst7 (SBRMI_x37) + */ + status = i2c_smbus_read_byte_data(data->client, SBRMI_OUTBNDMSG7); + if (status < 0) { + pr_err("SMBUS translation failed\n"); + return status; + } + + switch (status) { + case 0x0: /* Success */ + break; + case 0x1: + pr_err("Mailbox message command is aborted\n"); + break; + case 0x2: + pr_err("Unknown mailbox message\n"); + break; + case 0x3: + pr_err("Invalid core is specified in mailbox message parameters\n"); + break; + default: + pr_err("Unknown Error\n"); + } + + return status; +} + +static int sbrmi_enable_alert(struct sbrmi_data *data) +{ + 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(data->client, SBRMI_CTRL); + if (ctrl < 0) + return ctrl; + + if (ctrl & 0x10) { + ctrl &= ~0x10; + return i2c_smbus_write_byte_data(data->client, + SBRMI_CTRL, ctrl); + } + + return 0; +} + +static int rmi_mailbox_xfer(struct sbrmi_data *data, + struct sbrmi_mailbox_msg *msg) +{ + union mailbox_word output, input; + int i, err = 0, retry = 10; + int sw_status; + + mutex_lock(&data->lock); + + err = sbrmi_enable_alert(data); + if (err < 0) + goto exit_unlock; + + /* Indicate firmware a command is to be serviced */ + err = i2c_smbus_write_byte_data(data->client, + SBRMI_INBNDMSG7, START_CMD); + if (err < 0) + goto exit_unlock; + + /* Write the command to SBRMI::InBndMsg_inst0 */ + err = i2c_smbus_write_byte_data(data->client, + SBRMI_INBNDMSG0, msg->cmd); + if (err < 0) + goto exit_mod; + + /* + * 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) + */ + input = msg->data_in; + for (i = 0; i < 3; i++) { + err = i2c_smbus_write_byte_data(data->client, + (SBRMI_INBNDMSG1 + i), + input.bytes[i]); + if (err < 0) + goto exit_mod; + } + + /* + * Write 0x01 to SBRMI::SoftwareInterrupt to notify firmware to + * perform the requested read or write command + */ + err = i2c_smbus_write_byte_data(data->client, + SBRMI_SW_INTERRUPT, TRIGGER_MAILBOX); + if (err < 0) + goto exit_mod; + + /* + * 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) { + err = sw_status; + goto exit_mod; + } + if (sw_status & SW_ALERT_MASK) + break; + usleep_range(50, 100); + } while (retry--); + + if (retry < 0) { + pr_err("Firmware fail to indicate command colmpletion\n"); + err = -1; + goto exit_mod; + } + + /* + * 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++) { + output.bytes[i] = i2c_smbus_read_byte_data(data->client, + (SBRMI_OUTBNDMSG1 + i)); + if (output.bytes[i] < 0) { + err = output.bytes[i]; + goto exit_mod; + } + } + } + msg->data_out = output; + + /* + * BMC must write 1'b1 to SBRMI::Status[SwAlertSts] to clear the + * ALERT to initiator + */ + err = i2c_smbus_write_byte_data(data->client, SBRMI_STATUS, + (sw_status | SW_ALERT_MASK)); + +exit_mod: + if (err < 0) + pr_err("SMBUS translation failed\n"); + else + err = print_mailbox_error(data); +exit_unlock: + mutex_unlock(&data->lock); + return err; +} + +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.value * 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.value = 0; + msg.read = true; + rmi_mailbox_xfer(data, &msg); + + val = clamp_val(val, SBRMI_PWR_MIN, msg.data_out.value); + + msg.cmd = SBRMI_WRITE_PKG_PWR_LIMIT; + msg.data_in.value = 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; + + if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) { + dev_err(&client->dev, "adapter does not support true I2C\n"); + return -ENODEV; + } + + 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 Fri Jun 25 13:25:43 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: 12345069 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 09A82C2B9F4 for ; Fri, 25 Jun 2021 13:26:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E6FFD61628 for ; Fri, 25 Jun 2021 13:26:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231617AbhFYN2b (ORCPT ); Fri, 25 Jun 2021 09:28:31 -0400 Received: from mail-bn7nam10on2055.outbound.protection.outlook.com ([40.107.92.55]:10336 "EHLO NAM10-BN7-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231708AbhFYN2a (ORCPT ); Fri, 25 Jun 2021 09:28:30 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SUxFtDeJsWIh8UZtpJU7bs7WTDN7iyHama5shDIKEuifaDtplLGfU7O+Zs4ryxIoM4MZXJzqUBrnIkePTW3C4+rSrzWrwy+TqR1y7zrq/3fBlVuspf0hXS+PbbOuWWlbH3aHMz1iXlnWMBKYzH0Mg0cefi7OhFRY1ImlpK6KkX8LzvwVTX99z1AkknHcFBif2ELjdnAwTggUP6z31PrfDwxuumMxRNkNneVeAfJ065kO9RkJaKv+3gwxP6H9qR6rK0h94pvSUthNbmTU5yz7pGrrLkx2SM0UaBgLaIZvJTi+HmG8FShbVcIlEq4DACRv/ZVvYk+TAZnGsfr7ADRYxg== 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=LR1nLqNNzxt6CPpxphGQkw04PuVRroGHthGbtDtcET8=; b=oFLnN+S9ueNSUEg00bDe2sRizw9zUZp7D8qojfKoC3iPgIZGRIzFR7x/Oms8lmzZIK6Qsc5gz/uf5tk4mONPTBAKvERpswgnD5IZwOUOfvrTDQR1o3FNDcsAra0qTLgXu52NIm7w7RkUwiN0b66cQRVdvUB5EvFNQAjPRNjyDbB8hVUob7ZTNsk0iqz6VEiaNdtgNlRjzdUspW5WmTtaFN10DBigOY/MdtCp2Og1s1Om2D9JVdDLy7KZ2GANTjEYdzUKzQPA+Blgdqppc95mQW8fYyqa3e5wBMIatR1u7XvJQBBNr0MVaAGnnfZfjPBLv3bCt0ti33OocfplIJFR+Q== 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=LR1nLqNNzxt6CPpxphGQkw04PuVRroGHthGbtDtcET8=; b=draCeQdPeidaE/pnXjwtrmm6KhVRbQOgbJrKo+ETuqHo9azUwGvFzqP6cg21uHkHZyzcBq19vzd3gXJxDACkuOK/ZGtq/QFCkMQzndK2hNRWq4O6WBNBjJyAhSFrPDNMWZw783ebjjym8XSMzs1R7buwssQUsRu5pQ3B6snFkQE= 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 BL1PR12MB5255.namprd12.prod.outlook.com (2603:10b6:208:315::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Fri, 25 Jun 2021 13:26:08 +0000 Received: from BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::1514:9ec7:76dd:568c]) by BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::1514:9ec7:76dd:568c%7]) with mapi id 15.20.4264.021; Fri, 25 Jun 2021 13:26:08 +0000 From: Naveen Krishna Chatradhi To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, Akshay Gupta , Naveen Krishna Chatradhi Subject: [PATCH 2/3] hwmon: sbrmi: Add Documentation Date: Fri, 25 Jun 2021 18:55:43 +0530 Message-Id: <20210625132544.18094-2-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-Originating-IP: [165.204.156.251] X-ClientProxiedBy: MA1PR01CA0171.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::17) 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 MA1PR01CA0171.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20 via Frontend Transport; Fri, 25 Jun 2021 13:26:06 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1a2ddcec-380a-45bb-e1a8-08d937dccad0 X-MS-TrafficTypeDiagnostic: BL1PR12MB5255: 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: ih0CuTZEwEPOiKTpMFBOJJOW+EUjHrRNCHSKzbkhFj9auW2KDH0jAi0B4iwc8SZPHYw4kPcy7PNSRxuuo7xZjssbC/OW21g/Y0fwpdLnod5g9YDjq+oV2Xs/f1BHqLaVnC3f2bKpfddeiqtFOBgjmgph2szQzdZJGaFx7By5716WCFQroAzkYMxA97IaPEXoadtb3hRZxwuzDpHCpJ1H47XryUEgyZ3HduwINrN77/YHSNcct+cN1DIzDMXtRX2+2D5IZitGI+tBOXPibBNPSUifmsfpnd48GdzYTQkJXNKx/ev6kOZculagy1Jt/PJKxLgcUjT3rQKWoqkn8GIjJbHUW3r3YYdo/y1/uWbkwrgFQSMLGr1JcGiPaStJk42KPr6SLXVTXSg9qbpe5BE+mamthfWHcysS2RrV/6ngB/6kfGNhPODE0gqiztlGGDCAUDC9QU/L5O6V8VNQ6v5npt04vS7wozH6RfzisFNQeCbZ9mjCrYuqYq7uB+qUlTU0ayFL1k3ADOj8yMIo0J3wvJ5TB0ynPHJbz1ZvKWjExb2/8wXaUwvPNJRhUf2un5YKxIs37IQgRSMPMAdHolh4+Wzim0kMy7GzbkA3K/ZPzsYnIKhWcLDN8CM/WlFkSaYx7Lvez/JM68b9N8i/LqU5YvI04fDSDH9TKJC2nlkUha6/9u7kbDGd3U677l0HIv7pPJthRpfs1afYXlkhOD13oLLW6+SgPEXkc2PwHXJSJ44uyNWq6VEzBC9R70uQ2faE5M9dJLOgsZWbD+LlPGniAPSUYXzh3vJQtSFowY2YFMiYvCGYPrtlY6DbpVkhtXq0+vFZmFDrm6e4py2qdWjYpA== 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)(366004)(346002)(396003)(376002)(136003)(39860400002)(1076003)(8676002)(36756003)(54906003)(2616005)(6916009)(956004)(8936002)(4326008)(2906002)(38100700002)(38350700002)(26005)(186003)(7696005)(83380400001)(6666004)(966005)(66946007)(5660300002)(16526019)(66476007)(478600001)(316002)(6486002)(52116002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: mTN+DR65of9BrEoZGkODCIPo9pJVWEBNtUCKK+eV9+M75oSCZzNL/BcTm+xlxur0c7q2z6IrWuCOJqKq6XDSCDGMwe4M+HgF+rDG0Uo9y/q9kfjqnXL7qx78z1UlmSVxYnw8MKxW7fiYXziekKJ7le0WqSXPr3Nm5rmBAvaFFjNcWSxLNyLNzAUkYRh4yJM4kqivkas/JLDxAH3AsFyvaf7cWLrUGVhkD6lhcERPLipIsepWE/ewpD4C+FVGhiI6So99NV9FHbhYXURwAMidHO4/Cmxxw3m63AC3kj8C7mfm9frmqTLu1pY/vIQe0fIdS4zmJPkqpCHI5A4cszCuFFhiB2+gOxBfxESB5f+NWAY7J4a6/GZzrctZD22D5ve0X9QhRtPj2DAN8EZPg9mCCzUrfqCF2VpzaESwKziNpr5Imd0Gx7UnyJXD6gxZeVr4+At+OcELjYc3YM+UKPAcbpVMhRFK/ufHLLRblCkbe8tooe1bPHRXqsW/ovCf1h30bTf0wuLZ7I+F1jq9ez3mDPo11Z4blI7nD0kCC7B9zzJ+Uo9XvYTL12POMBcHYkxm3X7jMydhC4Us2vdULcoDYxZv+loc0HmLfgHU01HdabgUhAuL80SwOV174X4ihM3JfVwAQDL99dPGz51Ci2BnCqVnEqXeb1oEuZXSQxz6Ym3EoOG1knsI7D5NXi0aXjV+vg+LPLKl7MBrF0vDMAk1Bk1/hgzEBfn1QETjRGn35ODRovmFlPH0K4Aiv17G4JYJP7KeGMXTEwEflZJDOhE/Aq9P1Nk8eywboq2bOfcYixG7AGxGoE3/aKO8Tm91UUFYwwu49QlxW3KesgqF2m1EtR27rPKbNwqfi1y3qBre5AJUZJCy913oFAbyRSZ9MFr8N/AeydcQ/HbbhmyNXt8iSUwJf2UGJDiupDgSdnjKkp5mke/dr7zoTwrIwfdDobJkRRb6LU2qIZL1BLY451Hr/S8HqAPrGCCErUu0zGv6tKVWBZTrL2ffQwm4wM716st6lMUE0Fwuvy0X5IxxuNuwa/vXbtvu3GZXVkcBOkgB9ESGaAaSTiqWlYRrU+Fezn83WDn4ETJP7BH3J99LpJ5sFiEJnobisjfNKHjQNqlJ+N+nCqT5Fo8ndQHVtggfijPTaZm2SuBgcTeKw6dh80KRpzgCP3MaA1g92eE44/vQXJYlw0rKa7Fg+Bl6FtpKBflLcQzMWHp7R2I+a5afl5gUAIkA8m5pM/MXR0Ve8NZ681CjdoQv794z23VLqnehWwwurKmS/7vfYjbROht1rSU1LmvdouiKcmHc/IzUARdXcL2E98W7Pr+3+ncqs+1s+Ynk X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1a2ddcec-380a-45bb-e1a8-08d937dccad0 X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5286.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2021 13:26:08.6517 (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: U3vCTT2b3Z26J0ntCmwPMBTlQQvlUiEgy1aISugBXGdAkoELD5PjqX+04TkpsuN7OeB0D1oyub4Wyus+WGja7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5255 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 --- 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..db50393167bb --- /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 +================ ===== ======================================================== +power#_input RO Current Power consumed +power#_cap RW Power limit can be set between 0 and power#_cap_max +power#_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 Fri Jun 25 13:25:44 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: 12345071 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 E762DC2B9F4 for ; Fri, 25 Jun 2021 13:26:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D06BF61962 for ; Fri, 25 Jun 2021 13:26:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231708AbhFYN2g (ORCPT ); Fri, 25 Jun 2021 09:28:36 -0400 Received: from mail-mw2nam12on2069.outbound.protection.outlook.com ([40.107.244.69]:52897 "EHLO NAM12-MW2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S231668AbhFYN2f (ORCPT ); Fri, 25 Jun 2021 09:28:35 -0400 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fA5X4mKmLvEb7utffFdEq99n1szt3Qr6aThfdQx+vi8XXZUc2nh7QrfoclMTHfczbKwtvtkDKMEk43QXlvOjY0x9O5fJrlnuxwdxRL97CnxUZc64l2RYZG+Y3K8u2Igq+KmwIWtkpvI8ntqrrwGmuRwhs+16E8wnE20kTOm2hBUB4WHi4ZC06jlUSPtjQo9l7aNECTrg4bXC6SK+Kd415L1wIGIC/jINVtg7OfjXcE+KKWzT+kgueAoF5fQiz18n/RqA2SiIqLCc+hhPQAwDxzwC5LW6oI0AjMj2LPLf28P7eQnA8vwSoGyaqyWIxx4aCl5avKIUN6x/0qb995wm+Q== 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=dFoyZhPBenXNdPYqomVPZULFX4pYwTjfeMOg9yezwrE=; b=aR33PmIdetsyW3NYPmJm1FsEnVrgiRPf2mCb5+vI6GolWBlRx5Nv/zQDP9w/9pNYFkiEMCt7aoQzi1EgxK5SBSIihMF5F38cfgbnFmHYHh8NNnoEJWDzsuvov6G/6BWtKtrZ8dF59MbNl3c5+5ElCrhgGf6z6PJM24hvX9SmxCWphVG3BLu/+2MFT+A0InAKoGx/OMipcZIg/hZdi3Z56Eu90wb1VDipfysr7lblZq56eqV1jW3H1HpSw+b2Wgd/MCvO2m6ggzgDNMKmxNixaWBMZMWpqrkWLmymhvnWwdOOxTP9ymrhNkmjZ29/KdsMsicGQ//8Lb/XPMC9SzuoMA== 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=dFoyZhPBenXNdPYqomVPZULFX4pYwTjfeMOg9yezwrE=; b=xY0vtSMg11g9gmElhTPtEH4dkr9z5JWAoVQjQaDXAP3wRKViffkAJPc6MHqPtNO1J2EHMbxZA+oFVbfJKi65N4nTnAKNmyuobYUcGPb/bDNbSE0uwaX1lL4HO31hXYxL5zzh+c8EnZusFbVM48EzSZLBUfXJWqS3cOP/wE062AA= 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 BL1PR12MB5255.namprd12.prod.outlook.com (2603:10b6:208:315::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.18; Fri, 25 Jun 2021 13:26:13 +0000 Received: from BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::1514:9ec7:76dd:568c]) by BL1PR12MB5286.namprd12.prod.outlook.com ([fe80::1514:9ec7:76dd:568c%7]) with mapi id 15.20.4264.021; Fri, 25 Jun 2021 13:26:13 +0000 From: Naveen Krishna Chatradhi To: linux-hwmon@vger.kernel.org Cc: linux@roeck-us.net, Akshay Gupta , Naveen Krishna Chatradhi Subject: [PATCH 3/3] dt-bindings: sbrmi: Add SB-RMI hwmon driver bindings Date: Fri, 25 Jun 2021 18:55:44 +0530 Message-Id: <20210625132544.18094-3-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-Originating-IP: [165.204.156.251] X-ClientProxiedBy: MA1PR01CA0171.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::17) 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 MA1PR01CA0171.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a01:d::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4264.20 via Frontend Transport; Fri, 25 Jun 2021 13:26:11 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7ccb2e43-4a56-4328-35bc-08d937dccdba X-MS-TrafficTypeDiagnostic: BL1PR12MB5255: 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: BsNNQypyuStPAEQjAgjbF7V4EFrznZMAoaEkTVpYfabTpzH9CPXH43OPZIrh+qwe1bZIhgThQq+1roEuyQuwzPK0ZTiTYJfGOQv2Ouq6aW1GGAmBxTOuWLySuZf2bmNCk3PhpeJmYozHw6vawweIRdCQUAQ5+4Ij4ZjADMpMdiPY1lNDz3eqj9jf2MRvRPkiFLeUVk9QLQEW8GsoFAEHrWPvbjoo4NPKgqxDRNGR3NRqU7CJ3shPJPi2HjE/jARXhVxPm04Wk4/KdBBqlsSoF9JYNhxBhLVwIIfbOp6u7T9Vi7uRXoQhkL7uGf0lqL3BzTl4aaPbROKuBY1Pw57gdwPFGogHPWvHUfwJT45+SY5ZwpX+HU1gDAe/jOxGr2H8KHo/2ZvkitoeXgiLUg4zsJlYlyK/mxskOZE18wsbcKuK0hQ1KqZU6vu9t2l7B5LkDjn321wcF3Pmi1syz7p3kvlpFYOZzPjo5xKnO0PN6rWQ5uBh6i7rkyNc+GZoTwVYI8GsTMDFrYu1cdGstuWMrQeAdDkgy/l3oaFJrZ/9hqRqFSinzRxyF3wmjZ9vEDlwpxz437SkviLJifrMsbBl+bgwYK8gNaz9MmIMtU36wj1IXmWk0wu72To7uCz3R2rITOvg9blaY4Hi4oTE449hyktkAD/XpzGtYS2Xqe6TSEs1ejSWS7c2FbFWJMLOnDZ8YUbG4FwH6TvIQLzCqDoICW1HEl/yubckxN32L2jGYLYeOIWFCm1ri8oH9vfDiNNG6rdQlnLfw9pRfB5HLriSdqpWtKm7z66TY7yQ3AJYcdNbY0QOTNhBTT6APClMQjVQ 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)(366004)(346002)(396003)(376002)(136003)(39860400002)(1076003)(8676002)(36756003)(54906003)(2616005)(6916009)(956004)(8936002)(4326008)(2906002)(38100700002)(38350700002)(26005)(186003)(7696005)(83380400001)(6666004)(966005)(66946007)(5660300002)(16526019)(66476007)(478600001)(316002)(6486002)(52116002)(66556008);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tIBlfLnNtZBb1gSpJ+1eM3de5A086wyRqlxQ7G6oxyIoJE2iCNzaFo0dmcKICyMFlA9tcJMt5KJ0+9NLq9P+V93EB5C6iv6s962D9nT5R13NhkJYuXheFm7v9z1hKKD+etSvyeB5IYVVyZaFC53GmP59N2AP8AMHb01i7+BrloSVOPsRYk6vbl5lsnRo9fhquGq+q74B14lmWeriURN535Nk8iebKc5S6wX9GlGtp6b2roEpTanQX0z4nwNB32AEpVuG+0LW1SVNa6bz14jcSplgDTFCTkJSLIzzN9pi0+5VJL00lfjC9+l1PSciSmJHaFJI96kkO8oEyrem86iz+mdhGVa40H2friUBi1jirXiP97EcO/yUhsFuCUfFmVtvg0n2ub6ydXX2I6j/Ww1QyyLpB87h2lKmGpfUxByiGeq6KOwoTrsls0myEvnc+oc3hSrTlJMXLXu0cw2ULgEmDkt3T7KO7BDVQ3KERZtryAayqLNj9jE/Mx91oOyepPiZ62tA9+hAHQ60SY5O69HTHieBq/GepfSB5nyh8+xXmtWm+TJpWPn1tBpif9PZh4wEAKG71FDLDEMMIXEjiv4APi/T5jwcU37WY1CVTXvAiQMd7CwipITqZ4FjEmZrUPQ9Utl+ZjM/+dBnsUFt2R45ZKA0dgN31/vTJsjjozUrGY8CIL5Ed2B4Kpzu5ShcBd4kUaCkbOViTxAaZxMx+T2oCmCElgLHhnwsh8X3DtRv5bHXJWrVTxZuIuVOEoI9kWwAPPGcUb9emQn/qchZAelE3wqNGmlfoPLE9fRuN+AuCtSzp/z52RjqWdPu6BaZopMhszfgNMe8coctECxevShoHWZmTPeTv71SLSn/7HwPDSf3x5VwpxJCvPckFWKdx/xS5HY04MDYO3vRcJ2tDACWocAJ1mJ17Uq3M4gCk+5vixvnmcgSLic6p5x3N9bLf5uqwqgOXnXp+8EJMKXwjEuYW4SHXbFNHQCz1A2tnoKtFei6YcjjrI+j5XgaIl9mCbUh3xgCuAqSgSayEUw+2+Fq6k1TOFPMeHYCY78VmJaZD/wyY+h12ECQO18+oAPZN6l7OZNYRAouAT5jGalgNoFwInhs2NkqPNkjEO0ugSraKvzOp+oyDdXcTukStxxb2OI16/JwQVfHYp57qhuabTMMmre7GdeHna/Bd+IYVSSulxc4v4w3SLGHem5wKPEph8QUxChpDVn177whiLgqYj7FTBxugoFvAXCKQA0eYsjfH3yZ49whR7RbozvtIBYinU8owoUkjzPdA+eiwWv2FSkBJWTAH4g/DC7G5KZLu51gXOJi37amkAMKPpTLXFASSsOO X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7ccb2e43-4a56-4328-35bc-08d937dccdba X-MS-Exchange-CrossTenant-AuthSource: BL1PR12MB5286.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Jun 2021 13:26:13.5223 (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: kBZyCZTlpUupren/PqEOz2Xgf0TwZIo9U1gV+pkFjj/I6HtKwHauLNmIsyAyIcJKVFGeswieDt7kztOIyrlR0w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL1PR12MB5255 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 --- .../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>; + }; + }; +...