From patchwork Mon Mar 21 08:13:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786963 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 A8147C433EF for ; Mon, 21 Mar 2022 08:14:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345124AbiCUIQL (ORCPT ); Mon, 21 Mar 2022 04:16:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233809AbiCUIQF (ORCPT ); Mon, 21 Mar 2022 04:16:05 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2102.outbound.protection.outlook.com [40.107.92.102]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9671C4F9E0; Mon, 21 Mar 2022 01:14:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aKa6+BKh9VRPP0g4wCwOrjXWNV4mFZhBlPrPuwhrm03EICSG0Z7dINYYSd1czq15+mVPYpmGiPnONT+w/87ebYz6f89tAW8EqVaWp7LFWabB1CBwCHAEbtEg2qbImTbra7nR4XwLjwb27A0lgtAfpEBYvuKxPIiPhDK7xEHuYS7TYjbPTR04o4TJWJ551vbY2tANgO3GXFeACXcneB0JFcyJj9uwiw6ux/Ov+THQMQ7MyFrF/lSIy+5wLEcS0xssWwUwtoUZwM538jmPuy93VfdHDX1O11CwgV94XHOpm5ydlg4vptItKqGcQjuop+b2zxHyPyFEg4gJyzG5JKaKnA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=0HbID+FckdOZ85t6zD8zvgqjzzXrxoGBCmrC6dmG3to=; b=hLBsEy/nmZ2QVDxpFNrXdo2WvpcqghakDz/9BHOv39INuyXCW0IegTUqRxh1l2MpkHPTfmKsIu3OmSKpZPE7mFlGQ/0JsYmYh/tCEi/mTkPiQ/zShL6a4ErBAjo71RIvaEzcF5vjsmJaRgBDs1o7kp1pN+c0e16rlzR6U1t8qKEPKLjnBUDHSbXG+U/YvIcE7EfOpSHwiq826yQPAP1z1IGIfyauoQCt9DitwcmUfif14TEIh++pFGOPyQ5doVqbo2yXrsA6KMCkelX4orJMSWGqxLILcEx9o/a7q5MJaUnZAteQVdSlufIBrzdKbyE3yx4zLx7h/OMnJVRK1DsArg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0HbID+FckdOZ85t6zD8zvgqjzzXrxoGBCmrC6dmG3to=; b=vuw9nYOmbySs20xpnUIhRWdxLXM7KLO0t+JTM0eRSKrjmwI8IVfgY/GVg+zGOx3yqPLs7HGTKKePjXDEObAOr5ENkVr+FnvLhn4PLKUEdSa0GZNIjACu4feGC/jToe0N55A4y5cUJI7gPHf82B7oOnf3+fCECsJKiZUD5CS99DE= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by BN6PR01MB2738.prod.exchangelabs.com (2603:10b6:404:ce::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Mon, 21 Mar 2022 08:14:38 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:14:38 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 1/9] hwmon: smpro: Add Ampere's Altra smpro-hwmon driver Date: Mon, 21 Mar 2022 15:13:47 +0700 Message-Id: <20220321081355.6802-2-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fe65f9e3-8c46-4ed6-c0a7-08da0b12d766 X-MS-TrafficTypeDiagnostic: BN6PR01MB2738:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: wd39Q96oEdvDuh3LhZOnLjNMxpZfJ5EMMK5B2ECZBNtUSzZwtTdzZ3CBxHPTPQ/vW3FQcNoZO8ibWlrIZkzN592Rc8aRMe3gHgJ9K/RJvnCV9E9EL9jdFu4nU1RHR3PY3IPrud/8IrEcXbh24ZuBMtzXGLqOZTcphJCgazJrjK3FM+rFWj5nsAKd5i3omZdvshWcIFIGR/2fRG523qyfG4uBZT6jDSKKAYfug0MpZqJr/9UqTvSBE1u5t39wnS2VA+FJnRlwqbMZ95BOWmRdxEerd2U9RZg8QCrMxJqqAFFcnuv1JREhFfpKUZVd/GUF5zB6hq0SCnvXzAS1Anw+ytzgfr1IACxTr0IkF94jPpvoo2Bo7BR38zjkW6OI4y+0zhuwIatgFJsXHUJc1P7OTx3Sc+1GiicpEKk5eZXW/hcFRJSIZRnoQvhHvoaMl8+9LLY3VEzKz+S2AwaJ1DLq8XcGPPY3E+DfBj1CKiMGupiPOAQLATrewthOu0MpqqBjYTlmpdCbWPZx1u2JpualIjMaw9KJ7KGd8fP7JEA7sT4b8v47Yx/BevjgZk9L4MS4tb/uQXQibxWvszwJJehuGp+2KeGjCIOAcfbHSIhKAAnZldIdGB/PPyD50muNFCkfY51fGNZ0GjuZj7mi6cE7hS+8x1ev+1tmjSr1OKW5NyMS3inXmrXo1mloLcW/ljoh+8YmH4ZcTxFse6M7qumX4LM7P1ff4MOxig1n3pQR78Y= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38100700002)(66476007)(66556008)(6512007)(66946007)(7416002)(30864003)(107886003)(186003)(1076003)(86362001)(38350700002)(4326008)(5660300002)(8676002)(26005)(316002)(52116002)(110136005)(921005)(54906003)(2616005)(2906002)(508600001)(8936002)(6486002)(6506007)(6666004)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KoM2k/ZTQaENy7pTYlXuxoUyI/3Okp5p8BWmeKe8bTpt1Ji4DszoenY1d+CfshAu1yKOzLrXTanLed1R87eib5vAFuIym+/myx6HGwNmejT9wtMvlqLAWej6zAHgtA9NHqRrWWykzFcy2VDPC2PYz9DRJWBzykzDiWMXgykEvnph6S/o5q12ICCrYDmuaeDLkEjQVye+k7UA8Hfn3zddr3QsVMOr46a66VvXH1ysSVTMw7c1UnWq3k/1BFzojd6vi6hoOcKW5oCkJSo+1p9ZjXqdBaaFc3Qv9csQhgMjWPM2EVMoyGKbPbeq1q4q1g3YLOE10UdaLFjcQ7nONCXO0X0IyHePX2HWCDCcThVL/D1YaZFI9rrio5/T4YT/33CeNPqlhkVV1Db3nBVczjBXRCjNVpbUwRG52EJjYKmyveN+aPxLUUBHJyiuNS1Lye7E2H7qZa6dZV9FtU6diPIZ6CwkAl3u7Grd9NGs4EVhidnB4+8RoSMUo9RbMJh2LjeFM+RfWuZgnwtC7F2giIT8MTtT/MdHoNnVuhFHVIjuE9tztBW3KaQRDtlgPaOg8h+3nzYY6BDxOxI2hZv82FqWEuMDMOi6gXqGyM6nRrMygNMn2WNH5xyJQ/rJA4J8XkwTpGtnv8v6WJ2ebka8XM7OHq7v/4hf28vTweS8jcTnuSCZKBb5xEUIAlJGZ9rj9mjfJlMT1Ts3CH9XvtWiG9IG6m+Hb/T8+uJ50UfH7bQxy9DqqKB0XWv7wCOxxKxtQSk6Cmzzk99j0v8x2CgvySZLrjQHjnyL7cRCyznz7Aq0Fe2a14VtB6j0rDE/qWDLNXqiqyfrSWaDGVaVjANGJqHo+hg4bImyMP6wITV0kOaID6lX+C1oRkIF89ErP5fm92TAKdvyEhtTPNpR857ayDLJS6k2aXPiPc7KVFBQyTduCgK0vskdyTIOwVakHMRGrKVcJpm3tyNEn4Px2l2GwrBewNqDnhBE7huB6Dc/iMpbg7UW1furIh2FAGvNzt00t/2lnsorCm1QtmZGKjqgf93egk3PcceMPBRZl9ZXkIYGeUrSVTTwEQMh3PzTRZZUmOBVkU/zXEUQW4oD7Dd3DStGiNHxIocKqVdv07zK+h5qKLEHGDDX3OUEexPYSXAxUkJN+tyLMissTQTIEb4hrSbP8ZvYKkULmbe4Ulc2dlkVlQPY4DzpaVVkBU2wQhIa7jxSkk+jZsRKyZx4eFGdSkjGguHNqDv7AP2ao7m0RAH4GUjJ+eGIJiJ7C7cCPB0UWdc72RT5DFJ7vSJq+Itpd9/4erYKP0902ZDNawwhHI0vONBG2ekAnBMnV2McXONnd2eSwnmgctzHCMLrtwkCwO2fJl5czbNhtDVymknBfeHmjVgIGfENXfmx9MJOZlPoFWwxEJkrLjFjm4nwRtg6TvqCEkbJXAG+PKZGlxN+log/U94BtyGd0QVaV80nuB+32ufjLlOZz6H0j+3LNvuhjLlmyIondAq1W8Ut1KorPLGGJpY= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe65f9e3-8c46-4ed6-c0a7-08da0b12d766 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:14:38.1248 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Q+Rjh6CpOVXxBJo1YhrY+jZS1ogAveilZDIJlykdD78YEOL2p4dZDX12bWDIrNtAvnx/AyKY299kOWw2PszI+GSIW33PzieUcgqzJlEva8M= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR01MB2738 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This commit adds support for Ampere SMpro hwmon driver. This driver supports accessing various CPU sensors provided by the SMpro co-processor including temperature, power, voltages, and current. Signed-off-by: Quan Nguyen Reviewed-by: Guenter Roeck --- Changes in v7: + Update GPL version [Quan] Changes in v6: + None Changes in v5: + Drop ManufacturerID checking when probe as it was checked during smpro-mfd probing [Quan] + Drop the use of register offset [Quan] + Removed the use of compatible string as it is instantiated by smpro-mfd driver [Quan] + Thanks Guenter for the Reviewed-by in last version, but it was not added because there's some changes in this version. Really appreciate if you could help again, thank you. Changes in v4: + Returned regmap_read() error code [Guenter] Changes in v3: + Handled negative temperature value [Guenter] + Returned -ENODEV if Manufacturer ID is wrong [Guenter] + Refactored smpro_read_string() and smpro_temp_read() [Guenter] + Removed smpro_write() function [Guenter] + Added minor refactor changes [Quan] Changes in v2: + Removed "virtual" sensors [Guenter] + Reported SOC_TDP as "Socket TDP" using max attributes [Guenter] + Corrected return error code when host is turn off [Guenter] + Reported MEM HOT Threshold for all DIMMs as temp*_crit [Guenter] + Removed license info as SPDX-License-Identifier existed [Guenter] + Added is_visible() support [Guenter] + Used HWMON_CHANNEL_INFO() macro and LABEL attributes [Guenter] + Made is_valid_id() return boolean [Guenter] + Returned -EPROBE_DEFER when smpro reg inaccessible [Guenter] + Removed unnecessary error message when dev register fail [Guenter] + Removed Socket TDP sensor [Quan] + Included sensor type and channel in labels [Quan] + Refactorized code to fix checkpatch.pl --strict complaint [Quan] drivers/hwmon/Kconfig | 8 + drivers/hwmon/Makefile | 1 + drivers/hwmon/smpro-hwmon.c | 463 ++++++++++++++++++++++++++++++++++++ 3 files changed, 472 insertions(+) create mode 100644 drivers/hwmon/smpro-hwmon.c diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig index 68a8a27ab3b7..d85d81dc7c13 100644 --- a/drivers/hwmon/Kconfig +++ b/drivers/hwmon/Kconfig @@ -67,6 +67,14 @@ config SENSORS_ABITUGURU3 This driver can also be built as a module. If so, the module will be called abituguru3. +config SENSORS_SMPRO + tristate "Ampere's Altra SMpro hardware monitoring driver" + depends on MFD_SMPRO + help + If you say yes here you get support for the thermal, voltage, + current and power sensors of Ampere's Altra processor family SoC + with SMpro co-processor. + config SENSORS_AD7314 tristate "Analog Devices AD7314 and compatibles" depends on SPI diff --git a/drivers/hwmon/Makefile b/drivers/hwmon/Makefile index 8a03289e2aa4..00e0b187675b 100644 --- a/drivers/hwmon/Makefile +++ b/drivers/hwmon/Makefile @@ -182,6 +182,7 @@ obj-$(CONFIG_SENSORS_SHT4x) += sht4x.o obj-$(CONFIG_SENSORS_SHTC1) += shtc1.o obj-$(CONFIG_SENSORS_SIS5595) += sis5595.o obj-$(CONFIG_SENSORS_SMM665) += smm665.o +obj-$(CONFIG_SENSORS_SMPRO) += smpro-hwmon.o obj-$(CONFIG_SENSORS_SMSC47B397)+= smsc47b397.o obj-$(CONFIG_SENSORS_SMSC47M1) += smsc47m1.o obj-$(CONFIG_SENSORS_SMSC47M192)+= smsc47m192.o diff --git a/drivers/hwmon/smpro-hwmon.c b/drivers/hwmon/smpro-hwmon.c new file mode 100644 index 000000000000..b2bf84971fe8 --- /dev/null +++ b/drivers/hwmon/smpro-hwmon.c @@ -0,0 +1,463 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Ampere Computing SoC's SMPro Hardware Monitoring Driver + * + * Copyright (c) 2022, Ampere Computing LLC + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/* Logical Power Sensor Registers */ +#define SOC_TEMP 0x10 +#define SOC_VRD_TEMP 0x11 +#define DIMM_VRD_TEMP 0x12 +#define CORE_VRD_TEMP 0x13 +#define CH0_DIMM_TEMP 0x14 +#define CH1_DIMM_TEMP 0x15 +#define CH2_DIMM_TEMP 0x16 +#define CH3_DIMM_TEMP 0x17 +#define CH4_DIMM_TEMP 0x18 +#define CH5_DIMM_TEMP 0x19 +#define CH6_DIMM_TEMP 0x1A +#define CH7_DIMM_TEMP 0x1B +#define RCA_VRD_TEMP 0x1C + +#define CORE_VRD_PWR 0x20 +#define SOC_PWR 0x21 +#define DIMM_VRD1_PWR 0x22 +#define DIMM_VRD2_PWR 0x23 +#define CORE_VRD_PWR_MW 0x26 +#define SOC_PWR_MW 0x27 +#define DIMM_VRD1_PWR_MW 0x28 +#define DIMM_VRD2_PWR_MW 0x29 +#define RCA_VRD_PWR 0x2A +#define RCA_VRD_PWR_MW 0x2B + +#define MEM_HOT_THRESHOLD 0x32 +#define SOC_VR_HOT_THRESHOLD 0x33 +#define CORE_VRD_VOLT 0x34 +#define SOC_VRD_VOLT 0x35 +#define DIMM_VRD1_VOLT 0x36 +#define DIMM_VRD2_VOLT 0x37 +#define RCA_VRD_VOLT 0x38 + +#define CORE_VRD_CURR 0x39 +#define SOC_VRD_CURR 0x3A +#define DIMM_VRD1_CURR 0x3B +#define DIMM_VRD2_CURR 0x3C +#define RCA_VRD_CURR 0x3D + +struct smpro_hwmon { + struct regmap *regmap; +}; + +struct smpro_sensor { + const u8 reg; + const u8 reg_ext; + const char *label; +}; + +static const struct smpro_sensor temperature[] = { + { + .reg = SOC_TEMP, + .label = "temp1 SoC" + }, + { + .reg = SOC_VRD_TEMP, + .reg_ext = SOC_VR_HOT_THRESHOLD, + .label = "temp2 SoC VRD" + }, + { + .reg = DIMM_VRD_TEMP, + .label = "temp3 DIMM VRD" + }, + { + .reg = CORE_VRD_TEMP, + .label = "temp4 CORE VRD" + }, + { + .reg = CH0_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp5 CH0 DIMM" + }, + { + .reg = CH1_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp6 CH1 DIMM" + }, + { + .reg = CH2_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp7 CH2 DIMM" + }, + { + .reg = CH3_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp8 CH3 DIMM" + }, + { + .reg = CH4_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp9 CH4 DIMM" + }, + { + .reg = CH5_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp10 CH5 DIMM" + }, + { + .reg = CH6_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp11 CH6 DIMM" + }, + { + .reg = CH7_DIMM_TEMP, + .reg_ext = MEM_HOT_THRESHOLD, + .label = "temp12 CH7 DIMM" + }, + { + .reg = RCA_VRD_TEMP, + .label = "temp13 RCA VRD" + }, +}; + +static const struct smpro_sensor voltage[] = { + { + .reg = CORE_VRD_VOLT, + .label = "vout0 CORE VRD" + }, + { + .reg = SOC_VRD_VOLT, + .label = "vout1 SoC VRD" + }, + { + .reg = DIMM_VRD1_VOLT, + .label = "vout2 DIMM VRD1" + }, + { + .reg = DIMM_VRD2_VOLT, + .label = "vout3 DIMM VRD2" + }, + { + .reg = RCA_VRD_VOLT, + .label = "vout4 RCA VRD" + }, +}; + +static const struct smpro_sensor curr_sensor[] = { + { + .reg = CORE_VRD_CURR, + .label = "iout1 CORE VRD" + }, + { + .reg = SOC_VRD_CURR, + .label = "iout2 SoC VRD" + }, + { + .reg = DIMM_VRD1_CURR, + .label = "iout3 DIMM VRD1" + }, + { + .reg = DIMM_VRD2_CURR, + .label = "iout4 DIMM VRD2" + }, + { + .reg = RCA_VRD_CURR, + .label = "iout5 RCA VRD" + }, +}; + +static const struct smpro_sensor power[] = { + { + .reg = CORE_VRD_PWR, + .reg_ext = CORE_VRD_PWR_MW, + .label = "power1 CORE VRD" + }, + { + .reg = SOC_PWR, + .reg_ext = SOC_PWR_MW, + .label = "power2 SoC" + }, + { + .reg = DIMM_VRD1_PWR, + .reg_ext = DIMM_VRD1_PWR_MW, + .label = "power3 DIMM VRD1" + }, + { + .reg = DIMM_VRD2_PWR, + .reg_ext = DIMM_VRD2_PWR_MW, + .label = "power4 DIMM VRD2" + }, + { + .reg = RCA_VRD_PWR, + .reg_ext = RCA_VRD_PWR_MW, + .label = "power5 RCA VRD" + }, +}; + +static int smpro_read_temp(struct device *dev, u32 attr, int channel, long *val) +{ + struct smpro_hwmon *hwmon = dev_get_drvdata(dev); + unsigned int value; + int ret; + + switch (attr) { + case hwmon_temp_input: + ret = regmap_read(hwmon->regmap, temperature[channel].reg, &value); + if (ret) + return ret; + break; + case hwmon_temp_crit: + ret = regmap_read(hwmon->regmap, temperature[channel].reg_ext, &value); + if (ret) + return ret; + break; + default: + return -EOPNOTSUPP; + } + + *val = sign_extend32(value, 8) * 1000; + return 0; +} + +static int smpro_read_in(struct device *dev, u32 attr, int channel, long *val) +{ + struct smpro_hwmon *hwmon = dev_get_drvdata(dev); + unsigned int value; + int ret; + + switch (attr) { + case hwmon_in_input: + ret = regmap_read(hwmon->regmap, voltage[channel].reg, &value); + if (ret < 0) + return ret; + /* 15-bit value in 1mV */ + *val = value & 0x7fff; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int smpro_read_curr(struct device *dev, u32 attr, int channel, long *val) +{ + struct smpro_hwmon *hwmon = dev_get_drvdata(dev); + unsigned int value; + int ret; + + switch (attr) { + case hwmon_curr_input: + ret = regmap_read(hwmon->regmap, curr_sensor[channel].reg, &value); + if (ret < 0) + return ret; + /* Scale reported by the hardware is 1mA */ + *val = value & 0x7fff; + return 0; + default: + return -EOPNOTSUPP; + } +} + +static int smpro_read_power(struct device *dev, u32 attr, int channel, long *val_pwr) +{ + struct smpro_hwmon *hwmon = dev_get_drvdata(dev); + unsigned int val = 0, val_mw = 0; + int ret; + + switch (attr) { + case hwmon_power_input: + ret = regmap_read(hwmon->regmap, power[channel].reg, &val); + if (ret) + return ret; + + ret = regmap_read(hwmon->regmap, power[channel].reg_ext, &val_mw); + if (ret) + return ret; + + *val_pwr = val * 1000000 + val_mw * 1000; + return 0; + + default: + return -EOPNOTSUPP; + } +} + +static int smpro_read(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, long *val) +{ + switch (type) { + case hwmon_temp: + return smpro_read_temp(dev, attr, channel, val); + case hwmon_in: + return smpro_read_in(dev, attr, channel, val); + case hwmon_power: + return smpro_read_power(dev, attr, channel, val); + case hwmon_curr: + return smpro_read_curr(dev, attr, channel, val); + default: + return -EOPNOTSUPP; + } +} + +static int smpro_read_string(struct device *dev, enum hwmon_sensor_types type, + u32 attr, int channel, const char **str) +{ + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_label: + *str = temperature[channel].label; + return 0; + default: + break; + } + break; + + case hwmon_in: + switch (attr) { + case hwmon_in_label: + *str = voltage[channel].label; + return 0; + default: + break; + } + break; + + case hwmon_curr: + switch (attr) { + case hwmon_curr_label: + *str = curr_sensor[channel].label; + return 0; + default: + break; + } + break; + + case hwmon_power: + switch (attr) { + case hwmon_power_label: + *str = power[channel].label; + return 0; + default: + break; + } + break; + default: + break; + } + + return -EOPNOTSUPP; +} + +static umode_t smpro_is_visible(const void *data, enum hwmon_sensor_types type, + u32 attr, int channel) +{ + const struct smpro_hwmon *hwmon = data; + unsigned int value; + int ret; + + switch (type) { + case hwmon_temp: + switch (attr) { + case hwmon_temp_input: + case hwmon_temp_label: + case hwmon_temp_crit: + ret = regmap_read(hwmon->regmap, temperature[channel].reg, &value); + if (ret || value == 0xFFFF) + return 0; + break; + } + default: + break; + } + + return 0444; +} + +static const struct hwmon_channel_info *smpro_info[] = { + HWMON_CHANNEL_INFO(temp, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL | HWMON_T_CRIT, + HWMON_T_INPUT | HWMON_T_LABEL), + HWMON_CHANNEL_INFO(in, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL, + HWMON_I_INPUT | HWMON_I_LABEL), + HWMON_CHANNEL_INFO(power, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL, + HWMON_P_INPUT | HWMON_P_LABEL), + HWMON_CHANNEL_INFO(curr, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL, + HWMON_C_INPUT | HWMON_C_LABEL), + NULL +}; + +static const struct hwmon_ops smpro_hwmon_ops = { + .is_visible = smpro_is_visible, + .read = smpro_read, + .read_string = smpro_read_string, +}; + +static const struct hwmon_chip_info smpro_chip_info = { + .ops = &smpro_hwmon_ops, + .info = smpro_info, +}; + +static int smpro_hwmon_probe(struct platform_device *pdev) +{ + struct smpro_hwmon *hwmon; + struct device *hwmon_dev; + + hwmon = devm_kzalloc(&pdev->dev, sizeof(struct smpro_hwmon), GFP_KERNEL); + if (!hwmon) + return -ENOMEM; + + hwmon->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!hwmon->regmap) + return -ENODEV; + + hwmon_dev = devm_hwmon_device_register_with_info(&pdev->dev, "smpro_hwmon", + hwmon, &smpro_chip_info, NULL); + + return PTR_ERR_OR_ZERO(hwmon_dev); +} + +static struct platform_driver smpro_hwmon_driver = { + .probe = smpro_hwmon_probe, + .driver = { + .name = "smpro-hwmon", + }, +}; + +module_platform_driver(smpro_hwmon_driver); + +MODULE_AUTHOR("Thu Nguyen "); +MODULE_AUTHOR("Quan Nguyen "); +MODULE_DESCRIPTION("Ampere Altra SMPro hwmon driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Mar 21 08:13:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786964 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 9371AC43217 for ; Mon, 21 Mar 2022 08:14:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240082AbiCUIQN (ORCPT ); Mon, 21 Mar 2022 04:16:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44678 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345122AbiCUIQL (ORCPT ); Mon, 21 Mar 2022 04:16:11 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2100.outbound.protection.outlook.com [40.107.92.100]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D1AAF60AA0; Mon, 21 Mar 2022 01:14:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TMCW3H8peFyqavGFWw7hUGsBx6o16eebmQRnkb5JcD0hhD2cCWmbma7TWGuZejMczNXavFG2Z6YFtFOy5HMUWC/RIHuf1l249i8qgT3ddNmdYI0C2ea8ssjmI2kt5ygt+m9skf/eXCX5G6cqB86PYmDgdLFJbHJa/WOoi/jq5j5TsU0JUOOyC38q5YMGcJu2n0mv8V6s7r/GL2jhanJ1ZNkK0awraZCyaVnS/JbOL7jUCzm7RUTyLtlJYLn1RXNctY4CnTA6e7l4i1gflgxhGKyFrBDQ0WNBKxxMj/Akv5SsCtFCl5nzqNx6d41yAu7TW99Si6y/xhseTWdRyeEELA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=molUBPO8hhlFg1mSUCLrPNUknyDfngmXbbSHMXz13wo=; b=AAd5RtUG5r+eTXj+kDCQJUxtiRz2IWMvgfVvvxR6KeSL+1warT92vNUiwJgyuMzptUnaTNt758uqjlj85KSwBHqA4h/WRWC0ADi6kt82tWTQzGpqoinoJwqdZPzToxxXETT7YT3JTAUMGR3ZlxJb1G31ORqkIfl1wYX4KUdUjSYIGyOa6I1v/vyqMwRQD5tXY+RS2X1ecSoe7gdvEZEUz5PwNVpInmQ2qvI3Jd7B6Gv6xvcXiwnO/C6cSp0qkDwzMA45XuwKzPdfaVS8MwJoDQoFYO7sZtvGlyqikeqlVDeuC4kovgx2ObnZHIONvMWI7SHIgKCgPMf0i+1/4Zy3aA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=molUBPO8hhlFg1mSUCLrPNUknyDfngmXbbSHMXz13wo=; b=gVHHlYSay786PO0WFEg00zTqUytSXEgUsraAyQnIaI7Ib3YX+aHpZY9F4B+Ib7lAFhVqvp/OHWZJ+o1U2yx7a2fMBwOc9IHRZMdRMi8hz+mhLAN3at8WEVMo0TxJBOVmum9NgJsGwFyDpDIB5SuyfiLUPG7SgdsO30Z9yB0hlq8= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by BN6PR01MB2738.prod.exchangelabs.com (2603:10b6:404:ce::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Mon, 21 Mar 2022 08:14:43 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:14:43 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 2/9] docs: hwmon: (smpro-hwmon) Add documentation Date: Mon, 21 Mar 2022 15:13:48 +0700 Message-Id: <20220321081355.6802-3-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9b185918-72ad-4120-9e84-08da0b12dab0 X-MS-TrafficTypeDiagnostic: BN6PR01MB2738:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: pXyg9XU4EZyNw61Tg/XBMHQdUxzzt0gq4zrvwi0Sf+TXSeOkl7ialNcmvPCvP2HdhZbl5WeHKqEz/V26+uOJ2FhmApNnWEddAEgGkDW9NJ3uMysg5daGV1fTy3QVxdD1bdr0cC6WJxUL/FhQ0cAgZYQG6vuf3X4+7XiVHTEf7+np01rskBr1Gx+d1rjoLe/rO2FZVZ079KuNOCrZAKuequ4w45KuN9EMOavxow78Zl5/SJ9KT26016VIg+QO32P9bVS8C7gYa7ODLcxWTxPFwG5YZgiLWtsWQUGuF2e9728Dd1SYO4yIiY52+kofuLL2NhEJtm3dCGhWeVnW71mCE0mR99XC18MJUyME7aFNGlxbDtZu4w9zFL58w0boqeF3gNtg9nEXd5F1mSyWy6tqoszPs1nM0Z1WtPFh9L5IO2D6urqP/yd/hnaxVdd+GccXk1joafpC/41vPqgz5OpeDGKY6Q/wtRuQi+EYb+89muY9UY6crgAFLTlszoBL9Nw5DjQkZ/52jhWl4SISIe+3/YC41sCjEEFCDLl+U1x98JHNwdV46QNSs4d+Kdi1RnACwQQ202YBVHsiAbmwXyzurIloo5oSgYM5atfy4S3jU+Ui3d1PTHEB2B3zMQ7j2B6NWeBx6hvFLCaga1UnZBn8Pfq8Zye8oMlfxAtgnUUMQaenBMRvzrR8ooI4Xi1/ojD/lKPSSXBQNDY7UfJBZ52wcdB2tPi85ZCcus9J0COM4sQ= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38100700002)(66476007)(66556008)(6512007)(66946007)(7416002)(107886003)(186003)(1076003)(86362001)(38350700002)(4326008)(5660300002)(8676002)(26005)(316002)(52116002)(110136005)(921005)(54906003)(2616005)(2906002)(508600001)(8936002)(6486002)(6506007)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tQ80XCb/330diS8nkRlyl8Oof6frapfep23OVNCivdWzH8uHn6tEYRST7Jy+igIIKi3KYtUMHz+61wCj2z8SyNOwBfWYA9UOFre7f7aAcLrNkLDV7oYCpifaXYKdUllW3Wom5YQO3SISkHU+AczaZNEHPdsLNNW6fzdssw0tIQm4XVcsrjP8u0DMcLZUSrGnl1y/s7J/S3oCvSVjvY/rUXbVeQB3JM4xGBeRK2MgrUqSAfQ1WAwqnI7aHVL9KvOaLvCVYExMMLIMkFwtAKPvKz5lRRBkE1/ToOAlt2riesxSYxg4CCCa92dAgRCMez15lcgiRP5VglesCOBRsIUA/k6RhvjkJZv3U8tB5y5NCp005W31yJrQZkbkrjsdH0Y19jnrldFsa946CzNi7noL/w6BIKq7fafXVKqzy2EbrLOiUmU08btp43n/AiPbu+gHkFMy9egdXeD2jrsn6lgVFvJ0G5NehsgCS0EsO/zfJ+GHDdQ2kFsV5VguYnb747O5weK1vmQKvdg5SYgRNzkGfeZlFE6eniH+BRxyhSEYnIyoVeFRd5b7tUSctoTJpX1VoBII4wDUINUopseMZA1VHggpJ7rYhzXBE/vU8OhcAOIToxFXelLAYIKVt+fj3LfqVsdzyDH3WETOz5VvUF3Dn5KiIIsX05yyc3iGYIihpqyofwobDs5p6rCpqW755v9Q+6IDopqw/ZCZpyucuhiAvn6kpAqqMdfswyNRfI7aXD3M3xYerLHeIpno4yc1Dj6jttifkt1Ts4ACevefsrvQBROYFOjxdEvXbCoIcZtacX9w5aghrcy/Bou807wiqHGJef8hUlHN7G3a8c+XOXdmXgzvCFUccxjTSNTVSWyilTMwgdRlHxm2KjuPU3XBmjyZ0DD2XyABSjNWIlKZAXFoJlo3ju6fqiqwv2DBcK84qmjy57cV4LqVXfTDkH63peT6dzx8Cn/zNhpw9eeIZzzI9oaL+Rj3XZVsBJRC6Zy8bQWoR/vAhwHMKlbRXJrrgrIZuoXGcEc6h8xGtzlvdMp2QAws92fHKkAApwblzTxIJqn1YUD6DdV/NcygGoIbNee9dT8tkqLrvoI0XCnXMuZYLyE9X9qmWwfEuAn3SIapVhVs9i9Sf82fh6bSBE2rrIfHTM1W9Ar4cdomagVCFn6yS46H+2USx3rJ5Kqley0VhEpyw6P8k/UijtNssJXElvr4BP3i/z/ElZt87q8hv2qL3rpCN+BcQ1xRA58CNsx0NKc7KI9wDfbLV6zlPavlOGhK60AA1uUcsGXawOxlC9hXrdUOuqEjNFwyZv1yg5unXLxVI/dlfQ4kFrYmn4NosIBSAMEbYXH5nDoROFS7ydZQqRnAffrpGBxVlNnybVcxonehPQhLQtSbttHrCP8hHPi0TG/cE0IQzyZMqejhyfvwiXTn4iczwu/VviDA3mi48T9HEDZdFwOHCzaFsG/1yxAC//cq4kDj4T8HxMq9X/Kt2FxNB4Y27BrPOP5NzXZ+TRo= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9b185918-72ad-4120-9e84-08da0b12dab0 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:14:43.6420 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: qkHmDltipSR3dBmk3R4ITW4BWOBfXAiJRYkLu8FjW48yy5eDBaLGfOI1Nuv9rlXJWIUkuz8b6J/w2K9pW6opP5Z8QcsFE9Y3wMsDTv10P/o= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR01MB2738 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add documentation for the Ampere(R)'s Altra(R) SMpro hwmon driver. Signed-off-by: Thu Nguyen Signed-off-by: Quan Nguyen Reviewed-by: Guenter Roeck --- Changes in v7: + None Changes in v6: + None Changes in v5: + None Changes in v4: + None Changes in v3: + None Changes in v2: + Removed "virtual" sensors [Guenter] + Fixed typo "mili" to "milli", "nanoWatt" to "microWatt" [Guenter] + Reported SOC_TDP as "Socket TDP" using max attributes [Guenter] + Clarified "highest" meaning in documentation [Guenter] + Reported MEM HOT Threshold for all DIMMs as temp*_crit [Guenter] + Removed Socket TDP sensor [Quan] + Included sensor type and channel in labels [Quan] Documentation/hwmon/index.rst | 1 + Documentation/hwmon/smpro-hwmon.rst | 101 ++++++++++++++++++++++++++++ 2 files changed, 102 insertions(+) create mode 100644 Documentation/hwmon/smpro-hwmon.rst diff --git a/Documentation/hwmon/index.rst b/Documentation/hwmon/index.rst index 863b76289159..833dd38c93a6 100644 --- a/Documentation/hwmon/index.rst +++ b/Documentation/hwmon/index.rst @@ -184,6 +184,7 @@ Hardware Monitoring Kernel Drivers sis5595 sl28cpld smm665 + smpro-hwmon smsc47b397 smsc47m192 smsc47m1 diff --git a/Documentation/hwmon/smpro-hwmon.rst b/Documentation/hwmon/smpro-hwmon.rst new file mode 100644 index 000000000000..f978b1370e16 --- /dev/null +++ b/Documentation/hwmon/smpro-hwmon.rst @@ -0,0 +1,101 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver Ampere(R)'s Altra(R) SMpro hwmon +============================================== + +Supported chips: + + * Ampere(R) Altra(R) + + Prefix: 'smpro' + + Reference: Altra SoC BMC Interface Specification + +Author: Thu Nguyen + +Description +----------- +This driver supports hardware monitoring for Ampere(R) Altra(R) SoC's based on the +SMpro co-processor (SMpro). +The following sensor types are supported by the driver: + + * temperature + * voltage + * current + * power + +The SMpro interface provides the registers to query the various sensors and +their values which are then exported to userspace by this driver. + +Usage Notes +----------- + +SMpro hwmon driver creates at least two sysfs files for each sensor. + +* File ``_label`` reports the sensor label. +* File ``_input`` returns the sensor value. + +The sysfs files are allocated in the SMpro root fs folder. +There is one root folder for each SMpro instance. + +When the SoC is turned off, the driver will fail to read registers +and return -ENXIO. + +Sysfs entries +------------- + +The following sysfs files are supported: + +* Ampere(R) Altra(R): + +============ ============= ====== =============================================== +Name Unit Perm Description +temp1_input milli Celsius RO SoC temperature +temp2_input milli Celsius RO Max temperature reported among SoC VRDs +temp2_crit milli Celsius RO SoC VRD HOT Threshold temperature +temp3_input milli Celsius RO Max temperature reported among DIMM VRDs +temp4_input milli Celsius RO Max temperature reported among Core VRDs +temp5_input milli Celsius RO Temperature of DIMM0 on CH0 +temp5_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp6_input milli Celsius RO Temperature of DIMM0 on CH1 +temp6_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp7_input milli Celsius RO Temperature of DIMM0 on CH2 +temp7_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp8_input milli Celsius RO Temperature of DIMM0 on CH3 +temp8_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp9_input milli Celsius RO Temperature of DIMM0 on CH4 +temp9_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp10_input milli Celsius RO Temperature of DIMM0 on CH5 +temp10_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp11_input milli Celsius RO Temperature of DIMM0 on CH6 +temp11_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp12_input milli Celsius RO Temperature of DIMM0 on CH7 +temp12_crit milli Celsius RO MEM HOT Threshold for all DIMMs +temp13_input milli Celsius RO Max temperature reported among RCA VRDs +in0_input milli Volts RO Core voltage +in1_input milli Volts RO SoC voltage +in2_input milli Volts RO DIMM VRD1 voltage +in3_input milli Volts RO DIMM VRD2 voltage +in4_input milli Volts RO RCA VRD voltage +cur1_input milli Amperes RO Core VRD current +cur2_input milli Amperes RO SoC VRD current +cur3_input milli Amperes RO DIMM VRD1 current +cur4_input milli Amperes RO DIMM VRD2 current +cur5_input milli Amperes RO RCA VRD current +power1_input micro Watts RO Core VRD power +power2_input micro Watts RO SoC VRD power +power3_input micro Watts RO DIMM VRD1 power +power4_input micro Watts RO DIMM VRD2 power +power5_input micro Watts RO RCA VRD power +============ ============= ====== =============================================== + +Example:: + + # cat in0_input + 830 + # cat temp1_input + 37000 + # cat curr1_input + 9000 + # cat power5_input + 19500000 From patchwork Mon Mar 21 08:13:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786965 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 77696C433F5 for ; Mon, 21 Mar 2022 08:15:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345147AbiCUIQ0 (ORCPT ); Mon, 21 Mar 2022 04:16:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45824 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345145AbiCUIQY (ORCPT ); Mon, 21 Mar 2022 04:16:24 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2091.outbound.protection.outlook.com [40.107.92.91]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C71DC60A9B; Mon, 21 Mar 2022 01:14:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PT9vVRcJsp+D+QmgslY83O1fZY30K5iQxcwDEcOKCOA/pheZGm8MMDj8FXiRQ/O2LA4hTSg3mtxKrm3ZMWqJmlF280VFA1BlYg1esLV5TUTMP+KFPuMXb/igzy/hnDYLg0ZDXeZ/NMNwqY7AISVaVJJ1W4P7w6HhfJO8SM9IGfQvQkeKBN1A3iTzABDcDZW5hAsxv8oSegKIv0LeKWlK1XFKf21/+DpHRIeO4oyjgZwArG9TIUGjgZiJZbJDCVcWn5xjciMc/H7qXcHSXy8609A7diwcM5k4sunnz88u55hSWEj9DrMkvyihCSyJ1UaGViZkfAFCjwdaKImIM52i+g== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=rcYYNWgHsrE/Z8uZsrktWl10lcxxHkqVI8oR5ESOmsE=; b=Pn1C35dUncdrTQ7q/N2whW3qbMw7S0T5RyDMBejenZSZVN94EFt0gZZpsS58r+8qIKNglMBMhVdgMC4fd/niseXAoRKwMX8F6Qw7Gz6U2xYkajreQRGZ9FollByjgvF2QHwUfZbrPC6GiTu7w3t0b9lPNrvDsdNZIQ3T637TVsSb5nCzbOtkkUpCz5vIfmN76CYc8n5/5KCVtqym47n6jAecJJbhPVoD3EORYrvbWf0JTji0f+evPIUox/qW4T5syWQ+FxzpJYACMQOMGm6IswmZp4uisnrAth/wTdyPwdebahsCWN6z7C5hraa7/7f+J+j4lYj7SrDEznDbXHOYCQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=rcYYNWgHsrE/Z8uZsrktWl10lcxxHkqVI8oR5ESOmsE=; b=l4DkPXy2+QsxJjDtzASTq/DvFFdG9d5nhJdgUg2a/KFOX2a8eSQa+37qN8h+9hhsvhNEHRpfbiCjYt25YqSnLL/TgwhWL1HknBwYtuj+hCjyW3NmLSrpAqOwYycPOyXO4EZJpiMqKsSyoGHYGjnW+hT18VoxotMDGv//HHhzsg0= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by BN6PR01MB2738.prod.exchangelabs.com (2603:10b6:404:ce::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Mon, 21 Mar 2022 08:14:49 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:14:49 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 3/9] misc: smpro-errmon: Add Ampere's SMpro error monitor driver Date: Mon, 21 Mar 2022 15:13:49 +0700 Message-Id: <20220321081355.6802-4-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 20658a0e-7d5f-40af-38a1-08da0b12ddf8 X-MS-TrafficTypeDiagnostic: BN6PR01MB2738:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lyayk42mPDvJcpqarXKUcoAYTgoTOdbf4Qj+4CEq91TR30J0yw3NadKd7kzreF6QHxjRycpYHL8xCA/0DeCeIrfSDxdsCkGeQ8ZL7rZIgCo6bg51AdFpWD+jKZEREMS6+/hYeGMyo/2puf3c+hRk0Yv5W5EHIoU15jWCbNUrFzoIqdgLBbKzZXBWSqAGrvfkr25x8JlgRcsvuUpigDNsG2T6f1i15UvpNbNEbG30eg/fGGXsEKcJGJhhzN31zzgfBAUz0slktGBvdukQ6DwkIW3PMhsufSwF4Cb9EdO2aiF4HSFrsi7qvrkF54K0z1rpNqd20y71d3bReVXpDEj4JIBR/ItcFnBDEBFu8eYBUPL7QIw4+tzd0+ML8E3K4HY2dsug3WW3dyzxLMglt+SBBZau8wINPPYMCO5ltD5UC5gUTZlZWgMNHmeWL0/GQ3yCfWXrov3BziCnOW13W0Anh9sc+TciaBDS4+/hWQA+ZWgOZ9R11L9VafYD7q5pDj7F0nirts/7g1wHKGnf8t1bwuJOJGhepNdk7dtjS1BFhpDJ2YTgy2gpT7hp2nQ7yhzFzVGyG1iimmUN4vYGuWFlAmmoXr1y0w01KDm2mbXMZcRuqFazA89z2zBii1ZhPbGkEyapxSfVYISD/fEg4KxgZccL+easIyYGmYa/7nmDwsrxtnO+urVkTmZYTUkqWDkxC5baN6QSCMv4U8V4aiG+iXwzL2ko7z99Pebc10FObY8= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38100700002)(66476007)(66556008)(6512007)(66946007)(7416002)(30864003)(107886003)(186003)(1076003)(86362001)(38350700002)(4326008)(5660300002)(8676002)(26005)(316002)(52116002)(110136005)(921005)(54906003)(2616005)(2906002)(508600001)(8936002)(6486002)(6506007)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 0ytNQ8u1g/XfJdRr/0nk0YEIQfSgrdUIAOYj61u7QV6N+WspOTUC9YdYHXo8J9GmisAYKv0G5au2t2WLkf81GpXyi+OxQaHSsIKZ8wVVkbJMs8Gqj/aU/H0X6UH2zn+YjsKEqNzSgx5MffjAzz7253WnEtb2JYfq7hazeuas4nt/O3w1pVWOTMMmBMDs3Yyne5zV8UXbw8/moC4bhtnBx0LqOm+wKI8xaL0Gg/O79Mka2XdyzxqzcPjPxQG2e/6ynY5mdxZoNMSG5rJ6yi6NSuqODlOcBHXdHyJVvs3MwU8AVHM84QlVXkTOredfSCz2O5gR1HrzPquITAcXGWorZ9u7i0kQnXHjqdd3MTGuI/vecq+LBX5n3d17wEV5Dj6FSsuXKVV7AsfQULUalj/qgNk5kynklumURXaDt2l416VODi2+MPHF2a+L6TF3e7eLY1j9sTvQNTsh5IBnPUsaJjaSJ5ealyhAuZ0BLPaGapDRuiG7X8WeWlAg20N19nFgIdJEcnwGbXQuP8l3S5PmDgUrBp4sxW/xDPJ7DdLUHt5jcMoAVHJbWOrTt9kSSjWxgT7QZ0lBWCb0paTiP3bWDH6ZobI8giTuaoVmfxEqI957yii3/EipfPhozx5onDxbZ23Kgvszj0KOK9wBps7JJuocmsdlA2/Lxhki/3r5jJumCTuVvP3ae1jAF2EXhUXVde0hdEDGh0yY7zRgah0UG60Qw51bgJyqMrXdY6Np+b/tu0PfXHu3Cx1NSlbpyUrekdoSdoCV2lZp7bE1txRZtN8IQgdiLv9lBgJcg/NiYGWACQSrzY1FqX531XesH7b8nHdj5jxqCIUH0upVO+ktUmbFUK3KgRQLZmE/sfnRMwKOuHCDCW8L7gyOsoxQNsuKgkRSaIHSkzCIbRUjTLlK5caaO4rWQdKQQnEY5JxU60x6OdCAkq7NrAI5+V25VPeVJLvYeDBjHvuaAbv1GiFeAnGqZqklljyRGl4SxRE/x5maWNd+bXktADtuPIQGATRrba9zhSXbRinhmQzRt+RiQDZRS8KxFB3WgVEAmKzaaORFuUhYIXHthA4oZYvgT0tVgx3XUfmsfFkJRAC7mAfD5cFeqEZh/5Coiq07nkphoQOAjeeyqzeLSu/vKoQRlodDEYFMZrrBjpDjbA9oDC01MzGvHkO3fDDFAVb4ZKK1ZYYK9xWsWRGZJ9cPySqTHUHutyMcAzQV2iLx2bJDdDKa0eZooJNNMr71/mNsodkmGLGnD4su5EidZ+7wKFxvyWcraTRBFRJ3hxMrplidySizmynyC1HIJFfklHEIyX4fxj0QCTKpandtFW6twEzHS56BV58BduWUGmLTQRDjm+cDLIzM0+ln6ECnLLadJjH8I5Lsdtzd6zbAsGOktezuFlsYhyeXwU/PLkuF586e2AIe6AJxKwHjUE939sNo1k2kd5vvnIfHwxIYe1pkF2XtVOhRb89upJaUSYxfhrJ5mtqC0OYFfOP6q2aw040SBgnji1Q= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 20658a0e-7d5f-40af-38a1-08da0b12ddf8 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:14:49.0832 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 7RM50jgX+H6aOcs29lLfDhALaUhcLoKeMvzrrDoGisOsaI1k01bDytwItRfBDoQXTPj0SSxyCCZb/rwgj/0tqm18vU7KY9w8AZNWFCcZyIY= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR01MB2738 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This commit adds Ampere's SMpro error monitor driver for monitoring and reporting RAS-related errors as reported by SMpro co-processor found on Ampere's Altra processor family. Signed-off-by: Quan Nguyen Reported-by: kernel test robot --- Changes in v7: + Remove regmap_acquire/release_lock(), read_i2c_block_data() [Quan] + Use regmap_noinc_read() instead of errmon_read_block() [Quan] + Validate number of errors before read [Quan] + Fix wrong return type of *_show() function [kernel test robot] + Adjust patch order to avoid dependence with smpro-mfd [Lee Jones] + Use pointer instead of stack memory [Quan] Changes in v6: + First introduced in v6 [Quan] drivers/misc/Kconfig | 7 + drivers/misc/Makefile | 1 + drivers/misc/smpro-errmon.c | 517 ++++++++++++++++++++++++++++++++++++ 3 files changed, 525 insertions(+) create mode 100644 drivers/misc/smpro-errmon.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index a2b26426efba..4e1a0b451f3d 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -176,6 +176,13 @@ config SGI_XP this feature will allow for direct communication between SSIs based on a network adapter and DMA messaging. +config SMPRO_ERRMON + tristate "Ampere Computing SMPro error monitor driver" + depends on MFD_SMPRO || COMPILE_TEST + help + If you say yes here you get support for error monitor function + provides by Ampere Computing's SoC with SMpro processor. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535 diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 70e800e9127f..483308a6e113 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -23,6 +23,7 @@ obj-$(CONFIG_ENCLOSURE_SERVICES) += enclosure.o obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ +obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.o diff --git a/drivers/misc/smpro-errmon.c b/drivers/misc/smpro-errmon.c new file mode 100644 index 000000000000..50970a48d5df --- /dev/null +++ b/drivers/misc/smpro-errmon.c @@ -0,0 +1,517 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Ampere Computing SoC's SMpro Error Monitoring Driver + * + * Copyright (c) 2022, Ampere Computing LLC + * + */ + +#include +#include +#include +#include +#include + +/* GPI RAS Error Registers */ +#define GPI_RAS_ERR 0x7E + +/* Core and L2C Error Registers */ +#define CORE_CE_ERR_CNT 0x80 +#define CORE_CE_ERR_LEN 0x81 +#define CORE_CE_ERR_DATA 0x82 +#define CORE_UE_ERR_CNT 0x83 +#define CORE_UE_ERR_LEN 0x84 +#define CORE_UE_ERR_DATA 0x85 + +/* Memory Error Registers */ +#define MEM_CE_ERR_CNT 0x90 +#define MEM_CE_ERR_LEN 0x91 +#define MEM_CE_ERR_DATA 0x92 +#define MEM_UE_ERR_CNT 0x93 +#define MEM_UE_ERR_LEN 0x94 +#define MEM_UE_ERR_DATA 0x95 + +/* RAS Error/Warning Registers */ +#define ERR_SMPRO_TYPE 0xA0 +#define ERR_PMPRO_TYPE 0xA1 +#define ERR_SMPRO_INFO_LO 0xA2 +#define ERR_SMPRO_INFO_HI 0xA3 +#define ERR_SMPRO_DATA_LO 0xA4 +#define ERR_SMPRO_DATA_HI 0xA5 +#define WARN_SMPRO_INFO_LO 0xAA +#define WARN_SMPRO_INFO_HI 0xAB +#define ERR_PMPRO_INFO_LO 0xA6 +#define ERR_PMPRO_INFO_HI 0xA7 +#define ERR_PMPRO_DATA_LO 0xA8 +#define ERR_PMPRO_DATA_HI 0xA9 +#define WARN_PMPRO_INFO_LO 0xAC +#define WARN_PMPRO_INFO_HI 0xAD + +/* PCIE Error Registers */ +#define PCIE_CE_ERR_CNT 0xC0 +#define PCIE_CE_ERR_LEN 0xC1 +#define PCIE_CE_ERR_DATA 0xC2 +#define PCIE_UE_ERR_CNT 0xC3 +#define PCIE_UE_ERR_LEN 0xC4 +#define PCIE_UE_ERR_DATA 0xC5 + +/* Other Error Registers */ +#define OTHER_CE_ERR_CNT 0xD0 +#define OTHER_CE_ERR_LEN 0xD1 +#define OTHER_CE_ERR_DATA 0xD2 +#define OTHER_UE_ERR_CNT 0xD8 +#define OTHER_UE_ERR_LEN 0xD9 +#define OTHER_UE_ERR_DATA 0xDA + +/* Event Data Registers */ +#define VRD_WARN_FAULT_EVENT_DATA 0x78 +#define VRD_HOT_EVENT_DATA 0x79 +#define DIMM_HOT_EVENT_DATA 0x7A +#define DIMM_2X_REFRESH_EVENT_DATA 0x96 + +#define MAX_READ_BLOCK_LENGTH 48 +#define NUM_I2C_MESSAGES 2 +#define MAX_MSG_LEN 128 + +#define RAS_SMPRO_ERRS 0 +#define RAS_PMPRO_ERRS 1 + +enum RAS_48BYTES_ERR_TYPES { + CORE_CE_ERRS, + CORE_UE_ERRS, + MEM_CE_ERRS, + MEM_UE_ERRS, + PCIE_CE_ERRS, + PCIE_UE_ERRS, + OTHER_CE_ERRS, + OTHER_UE_ERRS, + NUM_48BYTES_ERR_TYPE, +}; + +struct smpro_error_hdr { + u8 err_count; /* Number of the RAS errors */ + u8 err_len; /* Number of data bytes */ + u8 err_data; /* Start of 48-byte data */ + u8 max_err_cnt; /* Max num of errors */ +}; + +/* + * Included Address of registers to get Count, Length of data and Data + * of the 48 bytes error data + */ +static struct smpro_error_hdr smpro_error_table[NUM_48BYTES_ERR_TYPE] = { + {CORE_CE_ERR_CNT, CORE_CE_ERR_LEN, CORE_CE_ERR_DATA, 32}, + {CORE_UE_ERR_CNT, CORE_UE_ERR_LEN, CORE_UE_ERR_DATA, 32}, + {MEM_CE_ERR_CNT, MEM_CE_ERR_LEN, MEM_CE_ERR_DATA, 16}, + {MEM_UE_ERR_CNT, MEM_UE_ERR_LEN, MEM_UE_ERR_DATA, 16}, + {PCIE_CE_ERR_CNT, PCIE_CE_ERR_LEN, PCIE_CE_ERR_DATA, 96}, + {PCIE_UE_ERR_CNT, PCIE_UE_ERR_LEN, PCIE_UE_ERR_DATA, 96}, + {OTHER_CE_ERR_CNT, OTHER_CE_ERR_LEN, OTHER_CE_ERR_DATA, 8}, + {OTHER_UE_ERR_CNT, OTHER_UE_ERR_LEN, OTHER_UE_ERR_DATA, 8}, +}; + +/* + * List of SCP registers which are used to get + * one type of RAS Internal errors. + */ +struct smpro_int_error_hdr { + u8 err_type; + u8 err_info_low; + u8 err_info_high; + u8 err_data_high; + u8 err_data_low; + u8 warn_info_low; + u8 warn_info_high; +}; + +static struct smpro_int_error_hdr list_smpro_int_error_hdr[2] = { + { + ERR_SMPRO_TYPE, + ERR_SMPRO_INFO_LO, ERR_SMPRO_INFO_HI, + ERR_SMPRO_DATA_LO, ERR_SMPRO_DATA_HI, + WARN_SMPRO_INFO_LO, WARN_SMPRO_INFO_HI + }, + { + ERR_PMPRO_TYPE, + ERR_PMPRO_INFO_LO, ERR_PMPRO_INFO_HI, + ERR_PMPRO_DATA_LO, ERR_PMPRO_DATA_HI, + WARN_PMPRO_INFO_LO, WARN_PMPRO_INFO_HI + }, +}; + +struct smpro_errmon { + struct regmap *regmap; +}; + +enum EVENT_TYPES { + VRD_WARN_FAULT_EVENTS, + VRD_HOT_EVENTS, + DIMM_HOT_EVENTS, + NUM_EVENTS_TYPE, +}; + +/* Included Address of event source and data registers */ +static u8 smpro_event_table[NUM_EVENTS_TYPE] = { + VRD_WARN_FAULT_EVENT_DATA, + VRD_HOT_EVENT_DATA, + DIMM_HOT_EVENT_DATA, +}; + +static ssize_t smpro_event_data_read(struct device *dev, + struct device_attribute *da, char *buf, + int channel) +{ + struct smpro_errmon *errmon = dev_get_drvdata(dev); + unsigned char msg[MAX_MSG_LEN] = {'\0'}; + s32 event_data; + int ret; + + *buf = 0; + if (channel >= NUM_EVENTS_TYPE) + goto done; + + ret = regmap_read(errmon->regmap, smpro_event_table[channel], &event_data); + if (ret) + goto done; + + ret = scnprintf(msg, MAX_MSG_LEN, "%02x %04x\n", channel, event_data); + strncat(buf, msg, ret); + /* Clear event after read */ + if (event_data != 0) + regmap_write(errmon->regmap, smpro_event_table[channel], event_data); +done: + return strlen(buf); +} + +static ssize_t smpro_error_data_read(struct device *dev, struct device_attribute *da, + char *buf, int channel) +{ + struct smpro_errmon *errmon = dev_get_drvdata(dev); + unsigned char err_data[MAX_READ_BLOCK_LENGTH]; + unsigned char msg[MAX_MSG_LEN] = {'\0'}; + struct smpro_error_hdr *err_info; + s32 err_count, err_length; + int ret, len, i; + + *buf = 0; + if (channel >= NUM_48BYTES_ERR_TYPE) + goto done; + + err_info = &smpro_error_table[channel]; + + ret = regmap_read(errmon->regmap, err_info->err_count, &err_count); + /* Error count is the low byte */ + err_count &= 0xff; + if (ret || err_count > err_info->max_err_cnt) + goto done; + + /* Bit 8 indentifies the overflow status of one error type */ + if (err_count & BIT(8)) { + len = scnprintf(msg, MAX_MSG_LEN, + "%02x %02x %04x %08x %016llx %016llx %016llx %016llx %016llx\n", + 0xFF, 0xFF, 0, 0, 0LL, 0LL, 0LL, 0LL, 0LL); + strncat(buf, msg, len); + } + + for (i = 0; i < err_count; i++) { + ret = regmap_read(errmon->regmap, err_info->err_len, &err_length); + if (ret || err_length <= 0) + break; + + if (err_length > MAX_READ_BLOCK_LENGTH) + err_length = MAX_READ_BLOCK_LENGTH; + + memset(err_data, 0x00, MAX_READ_BLOCK_LENGTH); + ret = regmap_noinc_read(errmon->regmap, err_info->err_data, err_data, err_length); + if (ret < 0) + break; + + /* + * The output of Core/Memory/PCIe/Others UE/CE errors follows below format: + * \ + * + * Where: + * + Error Type: The hardwares cause the errors. (1 byte) + * + SubType: Sub type of error in the specified hardware error. (1 byte) + * + Instance: Combination of the socket, channel, + * slot cause the error. (2 bytes) + * + Error Status: Encode of error status. (4 bytes) + * + Error Address: The address in device causes the errors. (8 bytes) + * + Error Misc 0/1/2/3: Addition info about the errors. (8 bytes for each) + * Reference Altra SOC BMC Interface specification. + */ + len = scnprintf(msg, MAX_MSG_LEN, + "%02x %02x %04x %08x %016llx %016llx %016llx %016llx %016llx\n", + err_data[0], err_data[1], *(u16 *)&err_data[2], + *(u32 *)&err_data[4], *(u64 *)&err_data[8], + *(u64 *)&err_data[16], *(u64 *)&err_data[24], + *(u64 *)&err_data[32], *(u64 *)&err_data[40]); + + /* go to next error */ + ret = regmap_write(errmon->regmap, err_info->err_count, 0x100); + if (ret) + break; + + /* add error message to buffer */ + strncat(buf, msg, len); + } +done: + return strlen(buf); +} + +static s32 smpro_internal_err_get_info(struct regmap *regmap, u8 addr, u8 addr1, + u8 addr2, u8 addr3, u8 subtype, char *buf) +{ + unsigned int ret_hi, ret_lo, data_lo, data_hi; + int ret; + + ret = regmap_read(regmap, addr, &ret_lo); + if (ret) + return ret; + + ret = regmap_read(regmap, addr1, &ret_hi); + if (ret) + return ret; + + if (addr2 != 0xff) { + ret = regmap_read(regmap, addr2, &data_lo); + if (ret) + return ret; + ret = regmap_read(regmap, addr3, &data_hi); + if (ret) + return ret; + } + /* + * Output format: + * + * Where: + * + errType: SCP Error Type (3 bits) + * 1: Warning + * 2: Error + * 4: Error with data + * + image: SCP Image Code (8 bits) + * + dir: Direction (1 bit) + * 0: Enter + * 1: Exit + * + location: SCP Module Location Code (8 bits) + * + errorCode: SCP Error Code (16 bits) + * + data : Extensive data (32 bits) + * All bits are 0 when errType is warning or error. + */ + return scnprintf(buf, MAX_MSG_LEN, "%01x %02x %01x %02x %04x %04x%04x\n", + subtype, (ret_hi & 0xf000) >> 12, (ret_hi & 0x0800) >> 11, + ret_hi & 0xff, ret_lo, data_hi, data_lo); +} + +static ssize_t smpro_internal_err_read(struct device *dev, struct device_attribute *da, + char *buf, int channel) +{ + struct smpro_errmon *errmon = dev_get_drvdata(dev); + struct smpro_int_error_hdr *err_info; + unsigned char msg[MAX_MSG_LEN] = {'\0'}; + unsigned int err_type; + unsigned int value; + int ret = 0; + + *buf = 0; + /* read error status */ + ret = regmap_read(errmon->regmap, GPI_RAS_ERR, &value); + if (ret) + goto done; + + if (!((channel == RAS_SMPRO_ERRS && (value & BIT(0))) || + (channel == RAS_PMPRO_ERRS && (value & BIT(1))))) + goto done; + + err_info = &list_smpro_int_error_hdr[channel]; + ret = regmap_read(errmon->regmap, err_info->err_type, &err_type); + if (ret) + goto done; + + /* Warning type */ + if (err_type & BIT(0)) { + ret = smpro_internal_err_get_info(errmon->regmap, err_info->warn_info_low, + err_info->warn_info_high, 0xff, 0xff, 1, msg); + if (ret < 0) + goto done; + + strncat(buf, msg, ret); + } + + /* Error with data type */ + if (err_type & BIT(2)) { + ret = smpro_internal_err_get_info(errmon->regmap, + err_info->err_info_low, + err_info->err_info_high, + err_info->err_data_low, + err_info->err_data_high, 4, msg); + if (ret < 0) + goto done; + + strncat(buf, msg, ret); + } + /* Error type */ + else if (err_type & BIT(1)) { + ret = smpro_internal_err_get_info(errmon->regmap, + err_info->err_info_low, + err_info->err_info_high, + 0xff, 0xff, 2, msg); + if (ret < 0) + goto done; + + strncat(buf, msg, ret); + } + + /* clear the read errors */ + regmap_write(errmon->regmap, err_info->err_type, err_type); + +done: + return strlen(buf); +} + +static ssize_t errors_core_ce_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, CORE_CE_ERRS); +} +static DEVICE_ATTR_RO(errors_core_ce); + +static ssize_t errors_core_ue_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, CORE_UE_ERRS); +} +static DEVICE_ATTR_RO(errors_core_ue); + +static ssize_t errors_mem_ce_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, MEM_CE_ERRS); +} +static DEVICE_ATTR_RO(errors_mem_ce); + +static ssize_t errors_mem_ue_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, MEM_UE_ERRS); +} +static DEVICE_ATTR_RO(errors_mem_ue); + +static ssize_t errors_pcie_ce_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, PCIE_CE_ERRS); +} +static DEVICE_ATTR_RO(errors_pcie_ce); + +static ssize_t errors_pcie_ue_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, PCIE_UE_ERRS); +} +static DEVICE_ATTR_RO(errors_pcie_ue); + +static ssize_t errors_other_ce_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, OTHER_CE_ERRS); +} +static DEVICE_ATTR_RO(errors_other_ce); + +static ssize_t errors_other_ue_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_error_data_read(dev, da, buf, OTHER_UE_ERRS); +} +static DEVICE_ATTR_RO(errors_other_ue); + +static ssize_t errors_smpro_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_internal_err_read(dev, da, buf, RAS_SMPRO_ERRS); +} +static DEVICE_ATTR_RO(errors_smpro); + +static ssize_t errors_pmpro_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_internal_err_read(dev, da, buf, RAS_PMPRO_ERRS); +} +static DEVICE_ATTR_RO(errors_pmpro); + +static ssize_t event_vrd_warn_fault_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_event_data_read(dev, da, buf, VRD_WARN_FAULT_EVENTS); +} +static DEVICE_ATTR_RO(event_vrd_warn_fault); + +static ssize_t event_vrd_hot_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_event_data_read(dev, da, buf, VRD_HOT_EVENTS); +} +static DEVICE_ATTR_RO(event_vrd_hot); + +static ssize_t event_dimm_hot_show(struct device *dev, struct device_attribute *da, char *buf) +{ + return smpro_event_data_read(dev, da, buf, DIMM_HOT_EVENTS); +} +static DEVICE_ATTR_RO(event_dimm_hot); + +static struct attribute *smpro_errmon_attrs[] = { + &dev_attr_errors_core_ce.attr, + &dev_attr_errors_core_ue.attr, + &dev_attr_errors_mem_ce.attr, + &dev_attr_errors_mem_ue.attr, + &dev_attr_errors_pcie_ce.attr, + &dev_attr_errors_pcie_ue.attr, + &dev_attr_errors_other_ce.attr, + &dev_attr_errors_other_ue.attr, + &dev_attr_errors_smpro.attr, + &dev_attr_errors_pmpro.attr, + &dev_attr_event_vrd_warn_fault.attr, + &dev_attr_event_vrd_hot.attr, + &dev_attr_event_dimm_hot.attr, + NULL +}; + +static const struct attribute_group smpro_errmon_attr_group = { + .attrs = smpro_errmon_attrs +}; + +static int smpro_errmon_probe(struct platform_device *pdev) +{ + struct smpro_errmon *errmon; + int ret; + + errmon = devm_kzalloc(&pdev->dev, sizeof(struct smpro_errmon), GFP_KERNEL); + if (!errmon) + return -ENOMEM; + + platform_set_drvdata(pdev, errmon); + + errmon->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!errmon->regmap) + return -ENODEV; + + ret = sysfs_create_group(&pdev->dev.kobj, &smpro_errmon_attr_group); + if (ret) + dev_err(&pdev->dev, "SMPro errmon sysfs registration failed\n"); + + return 0; +} + +static int smpro_errmon_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &smpro_errmon_attr_group); + pr_info("SMPro errmon sysfs entries removed"); + + return 0; +} + +static struct platform_driver smpro_errmon_driver = { + .probe = smpro_errmon_probe, + .remove = smpro_errmon_remove, + .driver = { + .name = "smpro-errmon", + }, +}; + +module_platform_driver(smpro_errmon_driver); + +MODULE_AUTHOR("Tung Nguyen "); +MODULE_AUTHOR("Thinh Pham "); +MODULE_AUTHOR("Hoang Nguyen "); +MODULE_AUTHOR("Thu Nguyen "); +MODULE_AUTHOR("Quan Nguyen "); +MODULE_DESCRIPTION("Ampere Altra SMpro driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Mar 21 08:13:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786966 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 06B6DC433FE for ; Mon, 21 Mar 2022 08:15:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240852AbiCUIQ2 (ORCPT ); Mon, 21 Mar 2022 04:16:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45778 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345158AbiCUIQZ (ORCPT ); Mon, 21 Mar 2022 04:16:25 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2121.outbound.protection.outlook.com [40.107.92.121]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12F3111CF70; Mon, 21 Mar 2022 01:14:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ceAvIJqLZV5zrL9IlVw1hfvlN8shW40jS7onu2P/hvLMghigEkLnP9djGLeKuwI6UlIvt0PIH+tB2ySXtuInaK33p1RGanILW8p253LoNLSGceGyGktwo4CHpcfgbU5eJx2MI3MyYvtmKWYFtFjwBRPi58WuwZSsocm80JObCjg6IAkypkPO3zt1A9iHvoyJMYyq1+m6muMbpqsoU2LvB7kmrUzGy+N68wnFoeLLq4YuYG6/iFplw52hhQhMbgX/vnkbHWbPoDOJclMTLQI/iY9b0VdOG+TemLZbtexDFfF/yfCWQqZczOUJ9wv8XSLO89sdMrZvYXeZ+XGer07d7w== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nAw9+4c3MzMPzOt4/wXifFK9WLiGJlKNXVjANFrOWl0=; b=IFz+JSANp3N20bQMrDDv92smG45SnNvxX1r4zQQxu03NDSiDPXV9L+LccN4nfn1+294FLO63nRPljeMMoBsU+wDMV8u/MdpZ0wGWT3H3MBPp24KWhDxC5XjwJj2Me5T8mIxKvAeCNLP03NgCMZkd4q92Jg1WoJWpexHesvZPR8t31bIXmAfmTXugO++zjL5BpIdTWiVUdCJEfCsOLb0wYVvbYpviG26YNyW4RELKFCpj1kxiqwHRpr/XW5Ftc8+eOTJXrNLVuVTsMbgxH15QRft1/s5zXf/4tex0h/vfH5li5gqD6I3ni07Q9T7kzLeXOf4TY/0Cw4WzH6ItLIG+pw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nAw9+4c3MzMPzOt4/wXifFK9WLiGJlKNXVjANFrOWl0=; b=vmIHL9JB/B5nVdxl+Qn1QhfOJUzmIrp768PAhrtnVLSzKvXkCPhPGpY03wKvEuHKJIQJFjBAhE8f5rdBuhh1OmBFs4rUtjRmrCmVGmRwXL3LJUF96+oaNPnOw7RkNnAWGibvO+cURg7xq62KgAXmsYOrXZdjE38Zdk/AjQo2b2w= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by BN6PR01MB2738.prod.exchangelabs.com (2603:10b6:404:ce::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Mon, 21 Mar 2022 08:14:54 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:14:54 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 4/9] docs: misc-devices: (smpro-errmon) Add documentation Date: Mon, 21 Mar 2022 15:13:50 +0700 Message-Id: <20220321081355.6802-5-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: aa89d775-2557-4b14-93f6-08da0b12e138 X-MS-TrafficTypeDiagnostic: BN6PR01MB2738:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: trc2GXABXiBI6judzF4eNXwXfD+Lx5uZWfYVjEJkYyRO7HJFy6hWIFeuk9RN0+vlMvVGGDgoCacafDM3/N5bLo5VGzau8JlF70bll2jtUSwJaA9isvLCSvwtT5VBqRugR53TLoUIq2thrTifwK1aXUILFQs984hHqLgdqL0QA9QCNllf632XWoHzqs3+mGw4bK7gLWlxQp93W/JfXNeEoMAw7Ds9/s9xHxbYQS0qmozQP/DHH+m0hDE/X2yQQyJTUvdopuVkR8YtXip7cnesyp5dHCx8Ceq4dhSN29WpC5JPmfWRih4ogw5Ik3VBE3xd5/As0IF3aQt09HD4+IRmNJn73x04NSWdEv3GjrJCUXvFKl+pUgE6L3mKXrLX+OwXeDzSyzUCgnlzd97qnts7Pb81YSCTK5BDZQOMn5ZhC1QQ6b3FBbJdu20zqHkPKidwbs6FzyFqDvPg7Qi72e4umvo9XZmRosaJuC/TB3FgmbRchuzRT+Ch52F/z00eVviTmCcZRXnm2pz/BKBVBRV6NsuuVRqHl4C7xJkjbhCCdb7qyjY/2OyO8Bt8ZyVfl60FZhKF1+yrvDIVZ4RqDV0gHyNwPL3AjNIOa3hzcYKi7Ywi8ZWgO2bEmc1OFXaeHJmly0dm/TyC6iHkys2I9BYW+r9nZNbNQwixmKAyrvpzu0t725q/SqUh4/0Rnsyh3rGBu0HzqivpHKt7G4BXAJa/15KJEBDg99kq0N/qo22Pffo= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38100700002)(66476007)(66556008)(6512007)(66946007)(7416002)(107886003)(186003)(1076003)(86362001)(38350700002)(4326008)(5660300002)(8676002)(26005)(316002)(52116002)(110136005)(921005)(54906003)(2616005)(2906002)(508600001)(8936002)(6486002)(6506007)(6666004)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: VGrlRWSPhOkC4GxZK+GKdndivTU9aI3FlIepDQqGyqvCzXcJKrzO1D8fq/p0m+VS2xiAtXS4bodFyk/sh1F7ROBsyZlPcaFhy5TPq/Lg+ftUsH63ZrTrQLXax88SvDX1JXun9VsOWJm7uQnIwnulUMIjlizl1wCFjMQ6kGyzMOSPA8MmvM1gZPMvkFYiiP/gDnu3mYlZQBmrJmqvPEEq0RHS/mvjOEUoWFk6a47TISiC9tVy2iiF2/3ajMLNbx70WJLLzXqDVHbyGqEg1BXzCZkkZeOuFFom6TQ52CtBsofSi74uc5SF3bSXRAnOQJunNLGVAxKkwJ/jVAetNG0axqw1sjzAVkVQvCUkP6IH6HSS83Ji8Z3hAQDy1lcGRow28Z+gUEyJT3/0fd+j5EvDWe86yk9fijcEEgM6/gnO37u/It1/LFo1wx1wgWcrLsKonQSk/zfbqP3FbEz+key/LMA7bsJnOfH7YycCz9iu3jPLxbgzcmHErvIL4mxkjE8yuSEo5w3+FrLOWQ4grZ3kyyLCl5iT1mBaItpPQHFWR1OaENBcyoJej66+JnOB+rwTnogurk+8YLGL3Qa3POMK5uwPFk5K/nIBuxsm+o3f/eOamvCnDaQpFM7WYlopGUAwSyQPjRFJ+ns6g4eUf1ThlhDfGzE3mUlQSeo3JMPT4doW7hFmWEFj+N5hGU/dn0lWV0Ds1VWWZtNHKW76bLyXBEl5Jx8BANrdxmX0NCy0cAh7385BVycFfJLIStmBpytLSUmLwOZYCAf+39kc4khj90c23yn78rwWk1GzN+7rIybdeABUBdEgObTDtU7wi6O2ArYqaqD9M1RioTm86nv7VnZj3gBDCern6NOcc6mnJrdgqN+6HkbZK+s7lUqq9MCFA1m/s/oZ8z6XPpZmV7SvWLfU6Jnk9hqfWWfVQDpbEDyzFwbHs/iNHt+9ycZeQYaf0kmOZ54ILLeyVk0tNNWvHDUqpBkq7DJOi/7ldDzlHULYEP88seGyRbu/ReV3jkueBD3zM03PxwPRu82Xjc+TGTNNNiiVu9OvkrM/YtQlTBX8MTr3ILIUD4wULwtycdESw8lSSMiQt3gl5O+sYEH67f9hDTB2TUIFBsp0S2TvE7NlWby8XKbHXZYt51RXnr5SlhciU/g0JkmizvLObAXhAWzk/g8iLEH/nociyjYfrHSMy2ypkS7+kg7a12BUVQYJj8nj6N2OIf5m7YnWDZ2kzG4Henp+sWcfCeyhJ0sCm86jY4KjN+EJPUMICKSy92i4sF94pqZNZTUJGgfUOs189IhbgUXhhCgsGcvXCU5LWUibzYvAXAHPnSk5ueYndjn0qKr+DejUiooEW9Phj8MNjvk4yCkUKVrQ5ZXceOS53Txb4dKpRpOIKi6S1FzVR2iAEJrjV/2iUkCPrTCA276Gpvmq2G28Mr9iDBLzhTmhNONNJvU4Vg5leTj9XiNabLkhCGobKNiOCNWrNG9+lI2+eEPdky5tGbPKnmi1WqsJqsI= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa89d775-2557-4b14-93f6-08da0b12e138 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:14:54.5838 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: WTX2I7wNKUmyMPsqrGyjsX0demmwkTDniZaD0A+BYmfWDrwec55xb2KgbybmV2X+yw2FUJRgebQWKi9cBo1XLq3HlD2HqW5+tQc/kz6N9W4= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR01MB2738 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adds documentation for Ampere(R)'s Altra(R) SMpro errmon driver. Signed-off-by: Thu Nguyen Signed-off-by: Quan Nguyen --- Changes in v7: + None Changes in v6: + First introduced in v6 [Quan] Documentation/misc-devices/index.rst | 1 + Documentation/misc-devices/smpro-errmon.rst | 206 ++++++++++++++++++++ 2 files changed, 207 insertions(+) create mode 100644 Documentation/misc-devices/smpro-errmon.rst diff --git a/Documentation/misc-devices/index.rst b/Documentation/misc-devices/index.rst index 30ac58f81901..7a6a6263cbab 100644 --- a/Documentation/misc-devices/index.rst +++ b/Documentation/misc-devices/index.rst @@ -26,6 +26,7 @@ fit into other categories. lis3lv02d max6875 pci-endpoint-test + smpro-errmon spear-pcie-gadget uacce xilinx_sdfec diff --git a/Documentation/misc-devices/smpro-errmon.rst b/Documentation/misc-devices/smpro-errmon.rst new file mode 100644 index 000000000000..e05d19412c07 --- /dev/null +++ b/Documentation/misc-devices/smpro-errmon.rst @@ -0,0 +1,206 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver Ampere(R)'s Altra(R) SMpro errmon +=============================================== + +Supported chips: + + * Ampere(R) Altra(R) + + Prefix: 'smpro' + + Preference: Altra SoC BMC Interface Specification + +Author: Thu Nguyen + +Description +----------- + +This driver supports hardware monitoring for Ampere(R) Altra(R) SoC's based on the +SMpro co-processor (SMpro). +The following SoC alert/event types are supported by the errmon driver: + +* Core CE/UE errors +* Memory CE/UE errors +* PCIe CE/UE errors +* Other CE/UE errors +* Internal SMpro/PMpro errors +* VRD hot +* VRD warn/fault +* DIMM Hot +* DIMM 2x refresh rate + +The SMpro interface provides the registers to query the status of the SoC alerts/events +and their data and export to userspace by this driver. + +Usage Notes +----------- + +SMpro errmon driver creates the sysfs files for each host alert/event type. +Example: ``errors_core_ce`` to get Core CE error type. + +To get a host alert/event type, the user will read the corresponding sysfs file. + +* If the alert/event is absented, the sysfs file returns empty. +* If the alerts/events are presented, the existing alerts/events will be reported as the error lines. + +The format of the error lines is defended on the alert/event type. + +1) Type 1 for Core/Memory/PCIe/Other CE/UE alert types:: + + + + Where: + * Error Type: The hardwares cause the errors in format of two hex characters. + * SubType: Sub type of error in the specified hardware error in format of two hex characters. + * Instance: Combination of the socket, channel, slot cause the error in format of four hex characters. + * Error Status: Encode of error status in format of eight hex characters. + * Error Address: The address in device causes the errors in format of sixteen hex characters. + * Error Misc 0/1/2/3: Addition info about the errors. Each field is in format of sixteen hex characters. + + Example: + # cat errors_other_ce + 0a 02 0000 000030e4 0000000000000080 0000020000000000 0000000000000000 0000000000000000 0000000000000000 + 0a 01 0000 000030e4 0000000000000080 0000020000000000 0000000000000000 0000000000000000 0000000000000000 + + The size of the alert buffer for this error type is 8 alerts. + When the buffer is overflowed, the errmon driver will be added the overflowed alert line to sysfs output. + + ff ff 0000 00000000 0000000000000080 0000000000000000 0000000000000000 0000000000000000 0000000000000000 + +Below table defines the value of Error types, Sub Types, Sub component and instance: + + ============ ========== ========= =============== ================ + Error Group Error Type Sub type Sub component Instance + CPM 0 0 Snoop-Logic CPM # + CPM 0 2 Armv8 Core 1 CPM # + MCU 1 1 ERR1 MCU # | SLOT << 11 + MCU 1 2 ERR2 MCU # | SLOT << 11 + MCU 1 3 ERR3 MCU # + MCU 1 4 ERR4 MCU # + MCU 1 5 ERR5 MCU # + MCU 1 6 ERR6 MCU # + MCU 1 7 Link Error MCU # + Mesh 2 0 Cross Point X | (Y << 5) | NS <<11 + Mesh 2 1 Home Node(IO) X | (Y << 5) | NS <<11 + Mesh 2 2 Home Node(Mem) X | (Y << 5) | NS <<11 | device<<12 + Mesh 2 4 CCIX Node X | (Y << 5) | NS <<11 + 2P Link 3 0 N/A Altra 2P Link # + GIC 5 0 ERR0 0 + GIC 5 1 ERR1 0 + GIC 5 2 ERR2 0 + GIC 5 3 ERR3 0 + GIC 5 4 ERR4 0 + GIC 5 5 ERR5 0 + GIC 5 6 ERR6 0 + GIC 5 7 ERR7 0 + GIC 5 8 ERR8 0 + GIC 5 9 ERR9 0 + GIC 5 10 ERR10 0 + GIC 5 11 ERR11 0 + GIC 5 12 ERR12 0 + GIC 5 13-21 ERR13 RC# + 1 + SMMU 6 TCU 100 RC # + SMMU 6 TBU0 0 RC # + SMMU 6 TBU1 1 RC # + SMMU 6 TBU2 2 RC # + SMMU 6 TBU3 3 RC # + SMMU 6 TBU4 4 RC # + SMMU 6 TBU5 5 RC # + SMMU 6 TBU6 6 RC # + SMMU 6 TBU7 7 RC # + SMMU 6 TBU8 8 RC # + SMMU 6 TBU9 9 RC # + PCIe AER 7 Root 0 RC # + PCIe AER 7 Device 1 RC # + PCIe RC 8 RCA HB 0 RC # + PCIe RC 8 RCB HB 1 RC # + PCIe RC 8 RASDP 8 RC # + OCM 9 ERR0 0 0 + OCM 9 ERR1 1 0 + OCM 9 ERR2 2 0 + SMpro 10 ERR0 0 0 + SMpro 10 ERR1 1 0 + SMpro 10 MPA_ERR 2 0 + PMpro 11 ERR0 0 0 + PMpro 11 ERR1 1 0 + PMpro 11 MPA_ERR 2 0 + ============= ========== ========= =============== ================ + + +2) Type 2 for the Internal SMpro/PMpro alert types:: + + + + Where: + * Error Type: SMpro/PMpro Error types in format of two hex characters. + + 1: Warning + + 2: Error + + 4: Error with data + * Error SubType: SMpro/PMpro Image Code in format of two hex characters. + * Direction: Direction in format of two hex characters. + + 0: Enter + + 1: Exit + * Error Location: SMpro/PMpro Module Location code in format of two hex characters. + * Error Code: SMpro/PMpro Error code in format of four hex characters. + * Error Data: Extensive datae in format of eight hex characters. + All bits are 0 when Error Type is warning or error. + + Example: + # cat errors_smpro + 01 04 01 08 0035 00000000 + +3) Type 3 for the VRD hot, VRD /warn/fault, DIMM Hot, DIMM 2x refresh rate event:: + + [Event Data] + + Where: + * Event Type: event type in format of two hex characters. + * Event SubType: event sub type in format of two hex characters. + * Direction: Direction in format of two hex characters. + + 0: Asserted + + 1: De-asserted + * Event Location: The index of component cause the alert in format of two hex characters. + * Event Data: Extensive data if have in format of four hex characters. + + Example: + #cat event_vr_hot + 00 02 00 00 -> /* DIMM VRD hot event is asserted at channel 0 */ + 00 02 01 00 -> /* DIMM VRD hot event is de-asserted at channel 0 */ + 00 01 00 03 -> /* Core VRD hot event is asserted at channel 3 */ + 00 00 00 00 -> /* SoC VRD hot event is asserted */ + 00 00 00 00 -> /* SoC VRD hot event is de-asserted */ + 00 02 00 06 -> /* DIMM VRD hot event is de-asserted at channel 6 */ + +Sysfs entries +------------- + +The following sysfs files are supported: + +* Ampere(R) Altra(R): + +Alert Types: + + ================= =============== =========================================================== ======= + Alert Type Sysfs name Description Format + Core CE Errors errors_core_ce Triggered by CPU when Core has an CE error 1 + Core UE Errors errors_core_ue Triggered by CPU when Core has an UE error 1 + Memory CE Errors errors_mem_ce Triggered by CPU when Memory has an CE error 1 + Memory UE Errors errors_mem_ue Triggered by CPU when Memory has an UE error 1 + PCIe CE Errors errors_pcie_ce Triggered by CPU when any PCIe controller has any CE error 1 + PCIe UE Errors errors_pcie_ue Triggered by CPU when any PCIe controller has any UE error 1 + Other CE Errors errors_other_ce Triggered by CPU when any Others CE error 1 + Other UE Errors errors_other_ue Triggered by CPU when any Others UE error 1 + SMpro Errors errors_smpro Triggered by CPU when system have SMpro error 2 + PMpro Errors errors_pmpro Triggered by CPU when system have PMpro error 2 + ================= =============== =========================================================== ======= + +Event Type: + + ============================ ========================== =========== ======================== + Event Type Sysfs name Event Type Sub Type + VRD HOT event_vrd_hot 0 0: SoC, 1: Core, 2: DIMM + VR Warn/Fault event_vrd_warn_fault 1 0: SoC, 1: Core, 2: DIMM + DIMM Hot event_dimm_hot 2 NA (Default 0) + DIMM 2x refresh rate status event_dimm_2x_refresh 3 NA (Default 0) + ============================ ========================== =========== ======================== From patchwork Mon Mar 21 08:13:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786967 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 291CBC433FE for ; Mon, 21 Mar 2022 08:15:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345165AbiCUIQc (ORCPT ); Mon, 21 Mar 2022 04:16:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345161AbiCUIQ3 (ORCPT ); Mon, 21 Mar 2022 04:16:29 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2107.outbound.protection.outlook.com [40.107.92.107]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2630160A9B; Mon, 21 Mar 2022 01:15:02 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=n/sxgHUtMo8IoOIQf7MzFS0RdGdTX012rS7Vk5iFDDmT2QgOwXTvodhtWMCF0b6Tsp8EO1PoSjF2PqaPDD4YfZ9Tlwg7uP+uOeNz2h7MVxY5HuI6fuPwWc3kRE27ps1L0x3UGO8zM1hcjYe671BD2gU2N+bC7AfU/ySmIKvEry+1YFsNTcuqrCJohI7zwutzx4w1nnYZW5k4+/wEHwAJTLtY0oBb+qmqzfd3J0mNhtA+HNeRl34r+4nmv56MEzB2jetw8RsrfeLeZKwAEW1CiTd0OXW/v2UtcEaS5FY8a9PfCSoPoDF9x0oL4/QjX/zn3q3xPZE9p2ng/DF2ZJ7kAA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6gz2V2hUboZee0NoS7N5UB0JFSqluoRrgP3NksaIA48=; b=MyzLbxfN606+b1yfrnjrXvzHT9bKDsDVOiTbO3GoeV+KYD2qHDGeteMg29SlXadz/ziEx9lDZWEVlcs8xmA6Ft3zF5TtThPCd2P6K9iinKvtxbE2ce24wkuPNNnvlsU7LSvy8Lmw1DtPLktlKSLDRCyIPf/8B5J1tPnyevqrS+O9qQ8JiIqYWTQxLERdyQqzBpHicH1A3vtt3xQoSeGvQR0UETTX0wtPWD3EcFHLRBJREeeF5A/2oEvf7EFYv2Wwa06MqYwy1PrOjtKPJ6M4fNwwykudNl2m2quNWKdP2HsBaKKezqwXXQP7k/rUlKUr2aNJk+2eb2g1yc5crXdv3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6gz2V2hUboZee0NoS7N5UB0JFSqluoRrgP3NksaIA48=; b=HpTwtRCSCTkKF8HUICvH55gkFx/J4W1TEZyNR0uEJqrLLs120S+n1K5pfr/XeaaSmr7g2ZstrTU4ofBgaT8y8Ko7sOiP7VlGN1IDjBG+UawQH5IISFWCT9Dvz4/2jkPWaaVWdAbakDhySRqzsAVtwEpyB0QKSWSauyOXK/Ogrvg= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by BN6PR01MB2738.prod.exchangelabs.com (2603:10b6:404:ce::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.14; Mon, 21 Mar 2022 08:15:00 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:15:00 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 5/9] misc: smpro-misc: Add Ampere's Altra SMpro misc driver Date: Mon, 21 Mar 2022 15:13:51 +0700 Message-Id: <20220321081355.6802-6-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 148c7f75-288b-406b-3f7e-08da0b12e480 X-MS-TrafficTypeDiagnostic: BN6PR01MB2738:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xdEvNxsCgPChJH0X6CZmcZ9QjeemnQKygaFnCBur+LJ2ekcJjwOhuWjoVfO/kz5/kARfdQyXkD1luGJvvVwl28aMqSw+wb09jVSfrojS28yIksrwhlD7mutxxDWPKS+MhfzpxDWbQdBYXPbeWNbdJNg926sk4WFWSEulAsFjzgCU1kY7C8HG/XtKg9e8qGx82BzARdP3J4Lw1CxrGb0N6JfeS5F/hB11SAF0LZBQgMxl4Q48zAlsydyQ8eNlZPiwbdGVTeiiJzcBHQoRaGZJxw2aM4sJxoc8d03Ph1e1SrGph5fJrnu8CkIdqwDD0ZbI/JjvLNxOuyJw3VuyVK4/FQONHFoz2m1wC7hnT+3ocESvbZAx8OwESXrS7m8rZTzRY2VUu1Z2jCn45jJNZ6WpuLnmgpDonGzYFQVJdYKspqvYDQ/IT9Eah/ao3DoLW2WLJX6W4FNfKkGVpnWVBwGoGcYJVTsbpYefWrCES+rK8Y3WlqWS+6AXFyf4DN00Pku3HgT68NQQEmRkmTTaMu/P32FNL/ZIoZBmO2AJTl994DiyHWZdk2yyi0rfzMcyAO30FlOigRWCoO46ES/RdvxV3Y6/yx1Md8S/w79EPGv8rA3B6IJDAD/E01OtxyFn6WLFO1Vq65pE7WvNXojHpvfcC/SmFWXeNuaoBzW9nkf4nsfWKQ4p8EVJg3rQz68xBYCsDQbvA4MA4OqSiZXhS9kntANb2aXbveJ3EhJNpIHkVm4= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(38100700002)(66476007)(66556008)(6512007)(66946007)(7416002)(107886003)(186003)(1076003)(86362001)(38350700002)(4326008)(5660300002)(8676002)(26005)(316002)(52116002)(110136005)(921005)(54906003)(2616005)(2906002)(508600001)(8936002)(6486002)(6506007)(6666004)(83380400001);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yWVkfcMKFR4UHRZ+Muvv5IZDnrx+faIUKccxRaisJcIRK1yj+Jin16eCbUzBeFi1TvzZYV18BQZBXlwjlO8GKMtdOXWZsEglDYh2p0jcKrev9jgVfrH/vDu2zgM239bIJaRACGtLvCVjLe2pOQqSLiGj24xqTPh9KXE1WhprTG5AA2otKBoC3kO1/2PsoxHvxNKVzHjlsVtOCw8GWB1Sy6HIM3tWBg5O3FA00Yy7rpQMlqu7y5/s5dF7hwE8mxzxeu5ixO0z/zMqQeyOE8aWYjIqkhi8JS165MybXGP8sY7vx57nFQC63FGujfxrvBK0DECEKGtREp3FfTSAY8Ecprsi3jDmCUVnzOQrQRaxlE7KcqKCFHrL8sZDtBHH2zEEO8RmnYqb4jR7YtPrpsRPMRDGNhqRQhN6sZht9m1f4C/6nEk+wgbDBI4JGfcZW2K8iufYs52vFxE+Ts2X34fQYfj9HKdL2LCYWDztwkWKSw46fb2JfueUEO/YLGoduLV7R9LVSKjVfUGeDGaJ8hsoKaapePA/CUCrnsr/kJNkSIsUtVLWYgtLygXRofXLb98znEFzWtL76eerHNqEe1uOlr2VCTJy7TvvUGL8nPCcX58gXbsiFEq0aWPKEC2jIoziqKIBl7rBWj0E/1JjRUul18Y6E+fCP3PdKeZHw/KuDaDDiWgP2p7kV4cDXu7TWOjZ2pj00ysQXAbR0FxCF2lBI1fVEZBr9BYliOFh2Og68SuPtZ8YM4FsmwFAhUrlhEzdommIV62L2GtQieyDZzK3XrK7Vr4dRz3b3rALvOoNLabBDvDNHSbT0Z6QjG8VEB4WbTWFMi7qUutlDao3cZWNodd/84pyRLR0OYSV5rfReCRg3iRnfl5Z79Fjhn8r+k2VsNyZ5CMvXDZgBaP3iZBKxTl2HICtyGGQRrOcJUylCvnNeJEgTSnDD+5tFJNKTk4kGAtFrWxVw2yZLFayrHlyNECDU7PfH6Myf+yHhCthivBjLFdiYQIRqr+OIF5OowA5It+bYh7q2GmCNb08aamVhL19cpL8dnkAF2sBT+h+PPEk25VrxCJiGwMjmXk5OjD7m+R2ljKMDFwDfyD5shZTNCpTZ3iYk6fAZWEWsxQoF2CRtM2eJgUcnHLeCYH+FkuVbJWYOWYlTVg9FtLHHYIMivBYAtexpUqJzhcQiUv7Bm5qzJmuTRPBPZSf9/g1pcxFJWngp/xH1d8mSbCfT66VAF+X8g0cZMyEhkF1FIUFdUpW7fqnlxUYeeA4M1y2n4J46te9+z+6EdAhlqW+ndAZICFrtk61l2ZAo8Piy+giQjmCvJO57rSi9CAlqVk6PUhzvvb0mPGAdSjlhSaVoPEqAr8iqfnq9J1QiSv7UK15Q4AWb0W86WbQAB6vs1jDRtYbuWyBRGq/ObO0EINPPXAeyDrGIJJHkt5lTDu7n554WZ2h97uMXGlLz1GVmJyNq1usVGtwEZJJwfi7i3YkjLyiPQ2Oa+Eqxfgv4eHgyRybpWw= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 148c7f75-288b-406b-3f7e-08da0b12e480 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:15:00.0397 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UnIj6Cj9AiL31QMFUgI+3RwmeAa8Qr+2HyvoacNEP7cU9Y+0ww9FhUf7SRx0VQEl2PZ2+7ohyu0XvaEEucfom1xZmanPdtE63jHfzDZnWTo= X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR01MB2738 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org This commit adds driver support for accessing various information reported by Ampere's SMpro co-processor such as Boot Progress and other miscellaneous data. Signed-off-by: Quan Nguyen --- Changes in v7: + Fix wrong return type of *_show/store() functions [kernel robot test] + Adjust patch order to remove dependence with smpro-mfd [Lee Jones] Changes in v6: + First introduced in v6 [Quan] drivers/misc/Kconfig | 7 ++ drivers/misc/Makefile | 1 + drivers/misc/smpro-misc.c | 177 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 185 insertions(+) create mode 100644 drivers/misc/smpro-misc.c diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig index 4e1a0b451f3d..f1371d6584e8 100644 --- a/drivers/misc/Kconfig +++ b/drivers/misc/Kconfig @@ -183,6 +183,13 @@ config SMPRO_ERRMON If you say yes here you get support for error monitor function provides by Ampere Computing's SoC with SMpro processor. +config SMPRO_MISC + tristate "Ampere Computing SMPro miscellaneous driver" + depends on MFD_SMPRO || COMPILE_TEST + help + If you say yes here you get support for the miscellaleous function + provides by Ampere Computing's SoC with SMpro processor. + config CS5535_MFGPT tristate "CS5535/CS5536 Geode Multi-Function General Purpose Timer (MFGPT) support" depends on MFD_CS5535 diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile index 483308a6e113..e61e462924d0 100644 --- a/drivers/misc/Makefile +++ b/drivers/misc/Makefile @@ -24,6 +24,7 @@ obj-$(CONFIG_KGDB_TESTS) += kgdbts.o obj-$(CONFIG_SGI_XP) += sgi-xp/ obj-$(CONFIG_SGI_GRU) += sgi-gru/ obj-$(CONFIG_SMPRO_ERRMON) += smpro-errmon.o +obj-$(CONFIG_SMPRO_MISC) += smpro-misc.o obj-$(CONFIG_CS5535_MFGPT) += cs5535-mfgpt.o obj-$(CONFIG_GEHC_ACHC) += gehc-achc.o obj-$(CONFIG_HP_ILO) += hpilo.o diff --git a/drivers/misc/smpro-misc.c b/drivers/misc/smpro-misc.c new file mode 100644 index 000000000000..fadaa66a699e --- /dev/null +++ b/drivers/misc/smpro-misc.c @@ -0,0 +1,177 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * Ampere Computing SoC's SMpro Misc Driver + * + * Copyright (c) 2022, Ampere Computing LLC + */ +#include +#include +#include +#include + +/* Boot Stage/Progress Registers */ +#define BOOTSTAGE_SELECT 0xB0 +#define BOOTSTAGE_STATUS_LO 0xB1 +#define BOOTSTAGE_CUR_STAGE 0xB2 +#define BOOTSTAGE_STATUS_HI 0xB3 + +/* SOC State Registers */ +#define SOC_POWER_LIMIT 0xE5 + +/* Boot stages */ +enum { + BOOTSTAGE_SMPRO = 0, + BOOTSTAGE_PMPRO, + BOOTSTAGE_ATF_BL1, + BOOTSTAGE_DDR_INIT, + BOOTSTAGE_DDR_INIT_PROGRESS, + BOOTSTAGE_ATF_BL2, + BOOTSTAGE_ATF_BL31, + BOOTSTAGE_ATF_BL32, + BOOTSTAGE_UEFI, + BOOTSTAGE_OS, + BOOTSTAGE_MAX +}; + +struct smpro_misc { + struct regmap *regmap; +}; + +static ssize_t boot_progress_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct smpro_misc *misc = dev_get_drvdata(dev); + u32 boot_progress; + u8 current_stage; + u8 boot_status; + u8 boot_stage; + u32 select; + u32 reg_lo; + u32 reg; + int ret; + + /* Read current boot stage */ + ret = regmap_read(misc->regmap, BOOTSTAGE_CUR_STAGE, ®); + if (ret) + return ret; + + current_stage = reg & 0xff; + + /* Read the boot progress */ + ret = regmap_read(misc->regmap, BOOTSTAGE_SELECT, &select); + if (ret) + return ret; + + boot_stage = (select >> 8) & 0xff; + boot_status = select & 0xff; + + if (boot_stage > current_stage) + return -EINVAL; + + ret = regmap_read(misc->regmap, BOOTSTAGE_STATUS_LO, ®_lo); + if (!ret) + ret = regmap_read(misc->regmap, BOOTSTAGE_STATUS_HI, ®); + if (ret) + return ret; + + boot_progress = swab16(reg) << 16 | swab16(reg_lo); + + /* Tell firmware to provide next boot stage next time */ + if (boot_stage < current_stage) { + ret = regmap_write(misc->regmap, BOOTSTAGE_SELECT, ((select & 0xff00) | 0x1)); + if (ret) + return ret; + } + + return snprintf(buf, PAGE_SIZE, "0x%02x 0x%02x 0x%08x\n", + boot_stage, boot_status, boot_progress); +} + +static DEVICE_ATTR_RO(boot_progress); + +static ssize_t soc_power_limit_show(struct device *dev, struct device_attribute *da, char *buf) +{ + struct smpro_misc *misc = dev_get_drvdata(dev); + unsigned int value; + int ret; + + ret = regmap_read(misc->regmap, SOC_POWER_LIMIT, &value); + if (ret) + return ret; + + return snprintf(buf, PAGE_SIZE, "%d\n", value); +} + +static ssize_t soc_power_limit_store(struct device *dev, struct device_attribute *da, + const char *buf, size_t count) +{ + struct smpro_misc *misc = dev_get_drvdata(dev); + unsigned long val; + s32 ret; + + ret = kstrtoul(buf, 0, &val); + if (ret) + return ret; + + ret = regmap_write(misc->regmap, SOC_POWER_LIMIT, (unsigned int)val); + if (ret) + return -EPROTO; + + return count; +} + +static DEVICE_ATTR_RW(soc_power_limit); + +static struct attribute *smpro_misc_attrs[] = { + &dev_attr_boot_progress.attr, + &dev_attr_soc_power_limit.attr, + NULL +}; + +static const struct attribute_group smpro_misc_attr_group = { + .attrs = smpro_misc_attrs +}; + +static int smpro_misc_probe(struct platform_device *pdev) +{ + struct smpro_misc *misc; + int ret; + + misc = devm_kzalloc(&pdev->dev, sizeof(struct smpro_misc), GFP_KERNEL); + if (!misc) + return -ENOMEM; + + platform_set_drvdata(pdev, misc); + + misc->regmap = dev_get_regmap(pdev->dev.parent, NULL); + if (!misc->regmap) + return -ENODEV; + + ret = sysfs_create_group(&pdev->dev.kobj, &smpro_misc_attr_group); + if (ret) + dev_err(&pdev->dev, "SMPro misc sysfs registration failed\n"); + + return 0; +} + +static int smpro_misc_remove(struct platform_device *pdev) +{ + sysfs_remove_group(&pdev->dev.kobj, &smpro_misc_attr_group); + pr_info("SMPro misc sysfs entries removed"); + + return 0; +} + +static struct platform_driver smpro_misc_driver = { + .probe = smpro_misc_probe, + .remove = smpro_misc_remove, + .driver = { + .name = "smpro-misc", + }, +}; + +module_platform_driver(smpro_misc_driver); + +MODULE_AUTHOR("Tung Nguyen "); +MODULE_AUTHOR("Quan Nguyen "); +MODULE_DESCRIPTION("Ampere Altra SMpro Misc driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Mar 21 08:13:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786968 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 005ABC433EF for ; Mon, 21 Mar 2022 08:15:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345172AbiCUIRJ (ORCPT ); Mon, 21 Mar 2022 04:17:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49044 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345173AbiCUIRF (ORCPT ); Mon, 21 Mar 2022 04:17:05 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2135.outbound.protection.outlook.com [40.107.243.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 810D811CF5E; Mon, 21 Mar 2022 01:15:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hFvGLHWRpVVqF9OeGVC3oKWIjg3BevRr9GlLtE2yMahKlBr6HF20T1arIT75cxv1LpAFUJqn7munxeEuLDe6Aewth6dZq58ulluocB9Om+BgF3dGafRe3Jzg9coC+oOpqvd5NNvM53QFKXG95evNrrzCsva+CEqwdCTpciihwYTnJiuH40wtSkRI4kjjj6Q5avwRaSYVdfvbQrWD04eYkEdW9tXyF/rR5vtgnn9GSL21GfgJ/lccsYuSAIvwl1aC1gBYMuUcQ+2OMWIDlBlTmS1V/ooRThd93q+xTxinqM8QgNNooiAuSFy85a3G27oqicjh2/DbTpGaiCn+lNQtNQ== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=csaRjnDj6HboMRHyCeYJrUPteA+rHFghsIsEsIE11C0=; b=QKst31H/J30ldXEcHxMJ1ZbNW1kkAEBovJQg9uqbKTUA/CIbzLoPX1W6EX+owgxjmV+wd+p/JbGct/7kr8ngKyjnOBd0gTHG3959z/ITnxim2tFT23+UtaT4fuHGXnck/xCJg6t4FVT//u0F9eFMYxf5MBVPFeyImyC1J4ccjvR9hAd0s9Hzys5KruMmulLbIUPw0JYhI11yS+UtLPu0OQrpZJw11bJZtd81vbDViLgJQu0DFQerjGh4TvUhX7ihb7k9r51qwsDQMBS/1ouaCbLH8i8C1AwCM4o8dA+ll7PNRYWDH95zANXM9Oc9QBfRZUEo5lgC2XiCmbeHiv/Zkg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=csaRjnDj6HboMRHyCeYJrUPteA+rHFghsIsEsIE11C0=; b=l9qdEpSzLvu5BlsWjlwBJq9enPA8/4MprIajr1/VaG3Am02pzhxjbF/jv7vnqIckghiWITZ9cMLKDiUlhJrjlD05l/rONPKqqUYTi2qFLU/bguBql6vwlDT26BREqo9k2jD1ZZqLcHv6mdKw/uZrDmnqo8WrR5sMxhKscjqUVG4= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by SN6PR01MB4112.prod.exchangelabs.com (2603:10b6:805:a6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.21; Mon, 21 Mar 2022 08:15:05 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:15:05 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 6/9] docs: misc-devices: (smpro-misc) Add documentation Date: Mon, 21 Mar 2022 15:13:52 +0700 Message-Id: <20220321081355.6802-7-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4e515fd9-fddf-497f-2cd5-08da0b12e7be X-MS-TrafficTypeDiagnostic: SN6PR01MB4112:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2tjtr7eA7oIeUb45iFzP4QuztMwgGf4eDvl8vQJ0pPz8TOEbI9pa+ag0Q5/xXnv1Bc4JpAI0zlqgFKzcigE7Rup+SHiJs+8hO/GQ/pCpm3g1+N8AISZGBG0wW/xlc41lakcvJi0/lIy0QGeTWsjB52c53bFDqN3fUqryUY3/CQzJi41T3M+34RySmf7sqW1se8B4vtuIXlNPmhM8vEQ6MMKGHn/ctmnP0O5OxS1gcKg+3sd8hjiKUP8v5HlqgnLDiSoP09o6qEnoUcE8M9KuL0Gv8WrnYW0coghS/TmP4X5ZMCV1wrUiEDcMMPkp8IkW1SSnPHHWnDuCHb2aHKXfgDPdXXLhieWW4j2smTLO6+eWncC//z3X14Ikl6vbU52gmWbA2SifR60u/LQOTroV5DntO/dzm8HzDiD0rli7iWsXEeVuCeiieqURifdyzjWXNQEEyURuH1L0YvomPmC6wLv1AiqbJajO1RxkezRIRWkcf7jgL5Zqn7ZUJnET77N2QX7Ub/wnJMBbjmIC33MQYA2KUhbO5OeAgxGePdU4b/ZFG8zie7KdjaqY/O/8Bt9D5lKBLOPg/OtX0XBn+NVkCwrrQOlrkuFrAmEDciZqwfZT1vTxm0YqjV23axTBdxKkg4alRnuJ4hDhyjbrZVpW+38jM/E2QBl4068caBx41X1W0+ebWgd/QmfFbq7c9q6OvPKmtnimqk+GHmhakrwVcXsgkH0a2bW8iEF9EJ8K4S0= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(5660300002)(508600001)(2616005)(26005)(107886003)(86362001)(8936002)(186003)(2906002)(1076003)(52116002)(7416002)(6666004)(6512007)(6506007)(921005)(38350700002)(38100700002)(110136005)(83380400001)(8676002)(66946007)(316002)(4326008)(66556008)(66476007)(6486002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 7Dlsd4/rdhfSNzuNDFRkgOxAL0Ng25G+WN+5/RBKvC3BN0ONPdaXZrcadMDCJccFC1h1dHxTVdE4vgYdKVsF95yJJabqZsJB5RapAvVWKqvtMMHrJhP2FNC74gcf1gTw6X6Ou4DoPmBtXyfhe0P6eEYvs091P+MnRlgKDzT9ncWHyUErqEpHKQC23knseFr03Ln7f8npe0VVpOP0qBy6piZtz2DCZZmSOPuxt91iqCTOTIoU0xywQu6Xg4cjWUhhxx0CIHNB/SNqEllOsiklGDVtHw/CeaWbIaeT6APllS0pPw+JnP7/X/BbZeeUwNaOq7yYlWU8vejhmKc7t6tSiMoyTrOLNxrqkHywYteDoI7Tw+NpXoceFh2y1+YuuYM3/TQpjGnwQQ1c6d6B4daxLNsuwg0TLIP89Ik+CysP0l1gm5IK/PsIS8eDI1lMmkQNpcyNo2JTSuPq/cy0kXnav27a6+YD0hLjI1RiM0+lkJS+vAPG0MWVTop0EGvqtJyr+vZKysQIv/P9BO5XRRogGCqblCw9gnuW/h4PEO0I7cw5+QPBovP7Sd+sUk27zCJpn6kjY4tlsXh+ANjjSkqcHxS/ML0L0SLO4yn2UV1mbkTLxyAJIyuP5jnfaQTAUUH13Jw3HuKHzg2RRRha0hIiNsPgHgnFSre5n/DZJW+eAO2C4AaA4lJOVuCvYr6QIW6umrTAqqfHh+U7DDlaDg/ZTHs+3DUsAzeeGRY4fwp1+m/xZhxhWQoqLRMS8iCyqX7vsNR+UlcyY8PMmYxJEOMXaIuk840dZiNNDF0glFepim53kPx4aYcwW5GrM/tj+wrLZB9sWIp7zMnvwfWPZqKsu43YrCNOghh+sXpHk4YbkzU2CSC98M15ba8PBLwC43gbYsIa2THuxTVsVkyvhRggEaWkqM6zk6uw9JEhc6fo1pLkoiiWA5zA3Kf737/gdT6p1aLBFNiNfu7LWPOdtkC9u0F0qGykhGVK9OJ54Om0e5uIZCMjPQVHFQjdkITjuflIClcxV75okq3smSXn8YdxjRkz6sWFpTo6nHlee0BhkDMElz2ZYjbsb0rQ5nj1QOP2+WbBMdotjt/aO2kvUQ5P9tmMN4Wo3lfoaKGNjSL4DuphBR+VY9ERnoNFX38j3qFHBu9z3cMGvblQu0VOpEWjfpt3dS+jsWO+WZuwQoGH9GY5Nz+q1fcl8JuoNtF1fpRciMisQlkm1/YtOAOgqfM5DsNmgDCUvtrpkDDOzdsoTpdy1BRQxSWXETZ1141bGzrWugZ682lO45Jv86Fz9OoiOMutBVm4MxMIcaifNM3VVK4IgDLmiuyLogDuGDy0BrAOvichp37qP0SzfmMKNt8qChxe7G9pfTBJ/S81qmlHLOL8a2EE5F5AZK7Eu8jvv5BdAQbsr9n1IxezzMRipmjG/9COk9tM6PmkXIe6+WWLgdUY1ozOWPg0IreSo7ap2aDmQZtPoU6Z86jFgajrRLPetCrYxwabaxiCLDIkez5tHeU= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4e515fd9-fddf-497f-2cd5-08da0b12e7be X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:15:05.6037 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: hv6+V7VKB37fFKW4twudarI5E6tReI45W+d8E6vToyvGXPIu1aZz4gatq3seLbsKAaXV+QSGXB/Bq59O6UziaKWhbX0ZpLhUh2LupKzvD04= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR01MB4112 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adds documentation for the Ampere(R)'s Altra(R) SMpro misc driver. Signed-off-by: Thu Nguyen Signed-off-by: Quan Nguyen --- Changes in v7: + None Changes in v6: + First introduced in v6 [Quan] Documentation/misc-devices/index.rst | 1 + Documentation/misc-devices/smpro-misc.rst | 82 +++++++++++++++++++++++ 2 files changed, 83 insertions(+) create mode 100644 Documentation/misc-devices/smpro-misc.rst diff --git a/Documentation/misc-devices/index.rst b/Documentation/misc-devices/index.rst index 7a6a6263cbab..284568eca747 100644 --- a/Documentation/misc-devices/index.rst +++ b/Documentation/misc-devices/index.rst @@ -27,6 +27,7 @@ fit into other categories. max6875 pci-endpoint-test smpro-errmon + smpro-misc spear-pcie-gadget uacce xilinx_sdfec diff --git a/Documentation/misc-devices/smpro-misc.rst b/Documentation/misc-devices/smpro-misc.rst new file mode 100644 index 000000000000..7c856eb1a7f3 --- /dev/null +++ b/Documentation/misc-devices/smpro-misc.rst @@ -0,0 +1,82 @@ +.. SPDX-License-Identifier: GPL-2.0-or-later + +Kernel driver Ampere(R) Altra(R) SMpro miscellaneous +==================================================== + +Supported chips: + + * Ampere(R) Altra(R) + + Prefix: 'smpro' + + Reference: Altra SoC BMC Interface Specification + +Author: Thu Nguyen + +Description +----------- + +This driver support the monitoring and configuration of various miscellaneous +data provided by Ampere(R) Altra(R) SMpro processor. +At this time, these include: + + * Reading Boot Progress information + * Configuring SoC Power Limit + +Sysfs entries +------------- + +1) Boot progress + +SMpro misc driver creates the sysfs files ``boot_progress``. +The format of ``boot_progress`` file is as below:: + + + +Where: + +* Boot stage:: + + 0: SMpro firmware booting. + 1: PMpro firmware booting. + 2: ATF BL1 firmware booting. + 3: DDR initialization. + 4: DDR training report status. + 5: ATF BL2 firmware booting. + 6: ATF BL31 firmware booting. + 7: ATF BL32 firmware booting. + 8: UEFI firmware booting. + 9: OS booting. + +* Boot status:: + + 0: Not started. + 1: Started. + 2: Complete without error. + 3: Failure. + +* boot progress: 32 bits boot progress code + +The sysfs ``boot_progress`` only reports the boot state when the host is booting. +If the host is already booted, it returns latest state. + +Example:: + + #cat boot_progress + 0x01 0x02 0x808454A8 + +2) SoC Power Limit + +SMpro misc driver creates the sysfs file ``soc_power_limit`` to get/set the SoC Power Limit. + +Reading this sysfs return the current setting of SoC Power Limit (W) in decimal string. +Writing the desired value in decimal string to set the SoC Power Limit in Watt (W). +The range of SoC Power Limit is 90-500(W) and will be ignored if out of range. + +Example:: + + #cat soc_power_limit + 90 + #echo 95 > soc_power_limit + #cat soc_power_limit + 95 From patchwork Mon Mar 21 08:13:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786969 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 CCFB2C433F5 for ; Mon, 21 Mar 2022 08:16:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345199AbiCUIRZ (ORCPT ); Mon, 21 Mar 2022 04:17:25 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345193AbiCUIRI (ORCPT ); Mon, 21 Mar 2022 04:17:08 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2135.outbound.protection.outlook.com [40.107.243.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C3DBE1207E6; Mon, 21 Mar 2022 01:15:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jb8S+KqNQ1tFSUNbPvWaVtvwj4HdStgm9t0yz13VckDUufURgGizySFpA/AoVfETC/sZVh0BaZ0i1sXTHr2Md4JAVOKTjRoeAYWggphUHlqakl5h55ITiL8aGd1y5U7aaLfTi69aFBGzBtS+NdLXEeucdOnS6bySDB4WxxBCKDfLF22tCj0gs+b3dbGmmnH7NdaPIfjCPSKhpLWPruQFaendIroygnPo7RTVnhhrCws+FQ3OKQ5yJN60lz9xq26BE6/wFDP0K4j7A9x4g9XM7XgmYUa+mCLBMO7YIKZCvyN7nv72ql+Gx3pfR6/jS0iJvBrAEHO5MwT5euJpqq+Fxg== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=LRZKxQMlvGxYqJe7hFmCrVdwbvnVoMNuYxi76qf524A=; b=G388+wvsiSVbPSTRhjjruCMQ9A6etaEYPvujbPjRK0DaToMtYVU/9QNn24Y5cdBo6gY/HNNhEDFhj12Gzh1mDVUXZLNl5w0W35xuKhVR7oY5/xIl9jHp97z6KRR5w7RiHQONJn661hPQBqxUUKox4l8A8SvsKUpyRpqTyKN2Ifyjh0fo0S2gcQgiT5l0vhSBqGJnVVagn0hmtjxYabLqe5iSHE/eam5PJS1PX8AiikqShUDfuHvIRy/ZEQeR8nrUPiOkpATXFCYmGI0bvVvgTZ6erEDWEI4IARqpo748Wr0XPKH5d9jMu5ixOqqkiSkdaPLhOssJHs+4cdKgePfSiw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=LRZKxQMlvGxYqJe7hFmCrVdwbvnVoMNuYxi76qf524A=; b=auK5RvKv4HDa1KBLSVaQUrm268LriURbnscz0BkahA0/6X4rYcNfFe9huPkzMnrt/ynPH200hXAK5w2LUL4ydCAIsz5Qh9TbguQElQkAOfJMDyxPw4DQQ9mWFNUVD0G1pC1pujCOcRqaf8WsdjMIOfaGbrM9NaeKKt0H5s+AfAY= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by SN6PR01MB4112.prod.exchangelabs.com (2603:10b6:805:a6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.21; Mon, 21 Mar 2022 08:15:11 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:15:11 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 7/9] dt-bindings: mfd: Add bindings for Ampere Altra SMPro MFD driver Date: Mon, 21 Mar 2022 15:13:53 +0700 Message-Id: <20220321081355.6802-8-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 04e1a142-5fbc-4ed4-eef7-08da0b12eb13 X-MS-TrafficTypeDiagnostic: SN6PR01MB4112:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Zbz9S4F90MjNQIVlEsQ0PgzOwgtGC3OanWWNF7gfNCt46dxuS+yn/oloUIbZIRhJDSVyc5hQct948VuyNYbbKiWxz6Z8bG0MA+Iq6nR28Sh3MzwGXV1okEiuKUDYglnH/iOnhOKR1bKjK1J/5eywNVrSIsHSwq8cQLGXJHpGVHiq+WSWVGWaCGRiZYY7DhhffunQYlipNovzPAarxABuCL724TDt8s0xwqAidmpcd4UG0Vs1XZK4fybZVJtYp3b7n1tx98mOOIOGwtM8iAaZXOhwJU12vGGGDBTC2sIG08SKHgre4zL8kgQMc/iHV19QYHfS7wQH/OdlZ1kQnj7GnHD4OO2h+6+IWS4F9icfgZfXdIBL3t4pFNdXT9RfoFECez+meefJ5b1qFe6E4wUtENXvjZiEOG6MsTXwPVWJ6aXW0ynr3IKxCvEppe/c64TKeQ4QNg0x2ndR2zzyvSrB9php1GhjO93bpwo1YqqAVpzXEA5FfpDQy/TXbMoCf9clyzDNv1L6tHkngSW37a4rfVwHwzKOF4ZUTGWMVt6XT0Yd28qbQ5vKUS+9sWUCCm85Fqlqj+4BtNXhK7gxA1nA91MxcnJ/X3HE1N/6mqYmfYzXCe3vdGLuID4pxH7UgNdC14FlWcVnEcqlsju4Ddw44/z//krJX0X3S2vCHgMnNxU/AZV139lEcNrbIcw7GedZqv3hjJ/Uuj9/eTA0zg18J3ZWhE4jE9AhEaNEbB5QyCDl5XLuC0rtFeZo2ddmf6qmserI4D0vk+K0Yez7pgLHj5aytBsSWqTPNEhQFRBrkzGQqkxQs0NiPooUiYDPdLo1K/89rIntaQ8WhRIp8T0YCLjP8m7qUUzLrPnCDUdraCU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(5660300002)(508600001)(966005)(2616005)(26005)(107886003)(86362001)(8936002)(186003)(2906002)(1076003)(52116002)(7416002)(6666004)(6512007)(6506007)(921005)(38350700002)(38100700002)(110136005)(83380400001)(8676002)(66946007)(316002)(4326008)(66556008)(66476007)(6486002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jsZDriuzFkmEfFx/TD18MTJ9Wo4z30OQroS2//BR5l8G6FaIjbdZ57FMXS/yyROb5wtbyTmdCC3zTEYA2VQWhevRdrYVYQKA1M6jJqIyE6LtQf79ExuwOULElqQ9eFa1uulErP0k1coqLbdtSz2U0YBFQ8J6lOoQf4RiqFEP/L/HMcBmabyknNdKpE1enEZFn793oO0GY6u/W9aU/SkhMs01BK5gjODljVBKNUxAdPyNfpsVNq9vsaunIF1uYuJMh+RyLSkpsKzPbVuHLA7ISF7jWknkv87sCqvpUBOF/zC+KiSoVd2iSGx0Pg3eBlvIKlB6IppskNo+J8wetin6EnTvLXkvXsN9Q9zBgg54M2UrP81SWEGumaTKTK4CqbUplvzcp85W6lNb1TbRNFBzExjY7XsRP0uc2X7fCKNowk8diwXRLw2+apXKEuPj03P5ZOoZ7e8Vfk2fRDpJrtueWg5+cesKmXBhu2mYPU0YqxwaDjK1PSH/BhFTZPavzI8d3L/iXIqI+CtlXUqkZMqhPE8N1Iv/ionw7XRAsMHefRxVERDH4OTD576m/SUpuBB0QoMT89xteAIRe3cxyNkJQ0Dyx3TrR0NLaQJfuMhB+oMRECdtRA1R3RQw8xXYsufMEfVc32+MLYCaYXr/AYjj2RHhHv0bar+HzXWsZd79bCydW5dZ75/K9B4mA7zfvbgbB5o++dSu28pYJ3cQIeRx2uiy9XfvZwtvBYH0/BDBqrsLNicW4pR25PqthIb7O9eZI7t2wVBBxskjuTZuDxvMqOQBtyChPlocvHXEbJ1NeVutdtiIb/iNkcnXRpeYcOOmQ7UywBawL0CKTM6jX4vgZV5sEYtkUWSzs7htixSJRwyZjafQzGhguGzORy4+xqpXydlvzb9P8o/GLRwbCY78BoIgON8MRsZBMg84lueOOhlifvvrse+xNQE/M09WToDastxsNF2FBBnSQM5L8LhmqH+qziOkXz5fz1mhzXW1805NvvyyGRe0j4UjVyqN/Zs3c4+5qAzsnrfb4+eo/PTpwLOwSS0/TP5oSOAd0q/gcbiIh7XbYmtaKOWFql45JS98xGW6EnunqRQJ+RvYNmQUKoS62CMKCE8/tScemnq3uCe1rGkBdF4ughmmCjQ0FUErz/0PAaw0LWm1bXgi+1i8tSBkkO+PQz3CYyJ5w/xSKd1GnVOpTR25YrauJr0blWi/Qw+5uUCLSdHMhv26h23hWdVdHTdfDqu9qA82J01qwwBHFvzmBQVilBKJ3CpmOMCqVg59/EESVqCFdG4n8B4++Bab9GdR+/JWzBZytLYFNvpY0yksk+zLVqJ1RiWMobHhUxh6Lo/7BworDueKMGFX6/VUEWxFEqDuFpBAgDPLSv9a8C5OIpm8WWgS4WWZsc5L7RHdLpveiC2AOk1YiimJbQMQbVXOlaQ1Fn/JMb6a6UyszUBrq2/5kBzOLbaJ9hKLpUlfXBC9k98wxXo1v6J7sIGwzdwLS7OsRhch3rlWBOw= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 04e1a142-5fbc-4ed4-eef7-08da0b12eb13 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:15:11.0598 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: sVUZOg8lvYtCofeOQLOGF3h8u/ho2r5NGr382LPDXrAak03dCpe3rXhteKKzq1SVxKsJ5uJ5WljFP06lpSZanQhu7he3RhOF5NhVGaPqAWk= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR01MB4112 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adds device tree bindings for SMPro MFD driver found on the Mt.Jade hardware reference platform with Ampere's Altra Processor family. The SMpro co-processor on Ampere Altra processor family is to monitor and report various data included hwmon-related info, RAS errors, and other miscellaneous information. Signed-off-by: Quan Nguyen Reviewed-by: Rob Herring --- Changes in v7: + None Changes in v6: + None .../devicetree/bindings/mfd/ampere,smpro.yaml | 48 +++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Documentation/devicetree/bindings/mfd/ampere,smpro.yaml diff --git a/Documentation/devicetree/bindings/mfd/ampere,smpro.yaml b/Documentation/devicetree/bindings/mfd/ampere,smpro.yaml new file mode 100644 index 000000000000..c29d975c1bc3 --- /dev/null +++ b/Documentation/devicetree/bindings/mfd/ampere,smpro.yaml @@ -0,0 +1,48 @@ +# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) +%YAML 1.2 +--- +$id: http://devicetree.org/schemas/mfd/ampere,smpro.yaml# +$schema: http://devicetree.org/meta-schemas/core.yaml# + +title: Ampere Altra SMPro firmware driver + +maintainers: + - Quan Nguyen + +description: | + Ampere Altra SMPro firmware may contain different blocks like hardware + monitoring, error monitoring and other miscellaneous features. + +properties: + compatible: + enum: + - ampere,smpro + + reg: + description: + I2C device address. + maxItems: 1 + + "#address-cells": + const: 1 + + "#size-cells": + const: 0 + +required: + - compatible + - reg + +additionalProperties: false + +examples: + - | + i2c { + #address-cells = <1>; + #size-cells = <0>; + + smpro@4f { + compatible = "ampere,smpro"; + reg = <0x4f>; + }; + }; From patchwork Mon Mar 21 08:13:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786970 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 69317C433FE for ; Mon, 21 Mar 2022 08:16:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345261AbiCUIR3 (ORCPT ); Mon, 21 Mar 2022 04:17:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49456 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345137AbiCUIRK (ORCPT ); Mon, 21 Mar 2022 04:17:10 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2135.outbound.protection.outlook.com [40.107.243.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B1C2124C27; Mon, 21 Mar 2022 01:15:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=X3MhvcYlx0AjQR6XLY98dKrwtEessm/+AU2tt3DAIzo+kU0qTHuE4SOOIOJ7IB4Manw/aHHxslO1Q5uZxsENiNxAXrn9ZzY/SO13zjSIcMuUNAx+8zysqQ4vnsLmh3S0hsiAcY4Tsbv1yUugFBqmU2BU06Rl6etjvjE6I3IwDR3b6AzxXdx8eWHlFaUHRJQjPRJKDPJg5YykbUZgRUI1MW0yVlBHHen9xhRNxt4qKOSZ5fMnwVDPz2yrnf2dbGEmruhqCEFf89MovRlgPjL+g6OyNpXGRQj3AaeyHQkY4Qrqa7RvRM0Kjzkfl/gMsgBNGKHVMgxPgjIaitr8ODVvBA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=OshPEopB8FSyJnfwFFbLIEYDXIs4H3Fqz+gFId+1zw0=; b=GydAOD30/DfPjuKkdPLSQya+c5DAAQSct9zPBQBfFHxZd6wBkuuwqd6XSjFlqIBP72VPiz72DVr0UDkxo7tQVkmawzo6jbJmThvgUy3TxYTawd2bKGUa2Ku8LzqAov6rYDG8gmx2aaz1sEcwyVyiNoMHe/rtCyM3MAij+vy12eFfBUvqyld1bOw+r9ZZfgE7a5pv/KG7TNyybtgb2lalFmLBQi64aUCnZoIdMU1jUCcNNUNmjs0i9pyFtEE2bVq2HZqeoqGJJjkwDWYpmmP1WDCswg149hBi4FYkUenIugJvJ3aoNCH69icaZVNNdix9z945emtLX4shLYXhJbP1Yw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=OshPEopB8FSyJnfwFFbLIEYDXIs4H3Fqz+gFId+1zw0=; b=Rx9oAP4ti/weys5q4JKvVM8yaHY4V46w1RbqFlFCCBzC4lnprOZNLOuAnJqyDOW36dBY/DcXc/BiTFg759H6QOxtZowxF7dRBcfMfySXaMxgL8hinWSimeOL5QvoemhyrLfIpDsfjF6TIWm6UKahUF1ycLBCH0DQQQt8swzd/vo= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by SN6PR01MB4112.prod.exchangelabs.com (2603:10b6:805:a6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.21; Mon, 21 Mar 2022 08:15:16 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:15:16 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 8/9] mfd: smpro-mfd: Adds Ampere's Altra SMpro MFD driver Date: Mon, 21 Mar 2022 15:13:54 +0700 Message-Id: <20220321081355.6802-9-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf88c586-c653-4bab-1733-08da0b12ee74 X-MS-TrafficTypeDiagnostic: SN6PR01MB4112:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: +gvV2GxYwoO/J1q+GjY4zd6hXZ/nQuNQsRpyfgXoqx3JoLYJ9LdO5T9XfvyvB47LmORfKVwCRkJzOm82G4NWfpwqV11YpbAzO+QJirFgTzhDzboa1P+1BqlNNQIiBCVCr6t0ozFjdV1cPzM7SyoSJe/TAWCxm9Qsqh9wAqAuKESr0v9cMRtXQG2Ak14IEFJfwGK3DoEadxe5RJ1zsdXqe5MNwotsnl+ZkfxOv6vJrHL709VqevXZpc0GuRvHF2OqXI2UV9U18KEJgaLQBAjOU8hNFfFC1w/6lOQVKXG73bmpSuW3AQNv5XhPBcc+ZyAKrjQ9VR+XXKrTXWJ/MscuCIL2/uCLUdtOuT++HL6amWB/p0nSVKgpf3qZotxKC/ZfEsTs8KATAJlv64nWhic7AsYTPjVx3kWNgJqdyxcvVJBXJ+9OerhVUSZjtIxcmuo7l8OBzC0gwOricRh75CfuCBEH5C2+cgKT/aNGl6cVtubEhDngy3zIDOrOO3MMZfwxYU02ZpcHhFvuLQyqyNFOWFWO7tMcSXgk94hikaUwn/Cv0yJgVeLGLUm/mIXskwO9h5t8xAgTACE9cZkE3Es46d//q1xCm9q+j8hdT+p8loHcFpaiAuR45cyGxOVRCljSU5xhTtsz1qtLxq/dtMwousjXWdL0b5930HFtPpVWg8tweXT5MzW5oIKCLrVhTvyVrgM8YQOwU9zXGoGubbzcKFDz5qoafrgFkbcyBqT0JMI= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(5660300002)(508600001)(2616005)(26005)(107886003)(86362001)(8936002)(186003)(2906002)(1076003)(52116002)(7416002)(6666004)(6512007)(6506007)(921005)(38350700002)(38100700002)(110136005)(83380400001)(8676002)(66946007)(316002)(4326008)(66556008)(66476007)(6486002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: kAOmrhP++4vS3QITzXc3cKgQ0LTAnyPGepFY551JwP6G0mA+ryFME6w+1qalvDkB5cuuCLgyPx8JfKgAP1csu3yjffEeXQSkKm/FzcgtP+fNONJHHG8j/EAZlA19Cwfg5BU8eV2VM2cWogiBy5je5hK/D33XA87b9T8p9x3ZXUpau282O5Tt4bv0p2bz/6MmMoEbGraPW9kbOpf3hFEWUTEAqw4UsN91FI9VPX9ZUcFssCNBZhxrDsGYcVLMBFoIZT4d5ZortRGoYEgVz6QnKLTYlZll/wysrbH/BYmFzvplroGfkFe+yWL6wwR0xTwkkbwCvHx/SmW0MLhC3aNx4DqzY/MyOXZqVJerTJYB3z3tOM8em0cFb/pz2VI5P7te1A+MgPsb4WnlqJH8PJwOxIuDDv7PT2GHcEG/GgqUBhfFu7nlnFaXLjnozS56sq47nDIUmEcw7O1P9/5eA7ZwD7xgZCOUnVPaZs6hij0Wc3e/Js5d08NWCDtrR5wOllw5dgsVYC9GvABvpHyIAWAW0GpAPXLTHzYF7skjJTg0Q1u2i3dJEDWukY8WlzsfRKULgkdxusjy0JjEJetZ/KgHibpaqaOOlOedq7Hh9Vux2G7tNEFoadHQO4xFpPAYuH/zsBcjZl3f1rVRPQjS26uzHT7yIMzsaNj2mutz2MTLUd0Z8RK2xHI3tw6epTC4j1CBXDayGKHPamZNJms2mLy3xl+kIVeEtdP3U1p3deHLsBIXneDSsQ2XTBJ6+hkyKVpo1VnH0kNxQ1PU1+AXQu8ls6vSpnPV2aDATHt3eRH29KtG8CNgojG/3VzPbyOzTuBtnmQG5wq6FuTVUdrFRc+y9a9JkmyI+XB9UfiHmfm80HiokaFgMYTvtSWFwuLFQYQDYW5PFqhOdljlZQEAaBqIltlwku7aNUFLTRd8KlpGD9RU8smqJaxVIsjYiaATpBVLjOV5AfO20MWqMAmR+4PMGL3c3QGlS5VPhKlIuXMM+ffi2tcBv5dYewE4eJfvegZiqtc1dNdSx3qxgZRPQsSWM7mKOu8CyXrdMyWlHOjtk0UNIEppTHnU/Dm88mm9ju1CGyJuh3KC6IMGqXbTcBuw/rPVxFS8rcASXC1VRlkcbOQqqVfhigiFTzWo7p0GewmttdbiHLRZ7PCei/wYKT2xsBPVh8NHHpryiur7ZSbXMiAcqn+KbWmD9ZhlOn47vv3d/b4CzTDmJqmWg5eH5EDvoeFKoz5YGIskD5PLvGcldShtJgaGp9z0IrdAZ5L006bIQ9XVpYEEeAb5oFE+ne0PkqWr0+lt2NMW25mXc4fu7jOxvD11mRAn0Pb03fDT1sIGSHxZR3NnM2J5RHwXxcgQ6fsvi7t1h7IUKc2ihyctIvCGv0xrpTrkZbOI0GJ2eZLlq1XbWwsjJuEWeTw5T2o/RirnHJYhKbZ1LqCdG7EE+kEfOk6T/Tx/NAHJSDKieH5ukUG3vNjUxyXakR7icmYOnzmLmj+OMI/QaFjW2d3lHI8= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: cf88c586-c653-4bab-1733-08da0b12ee74 X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:15:16.7072 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1881ETrCbRz7KbyZY1X48FiuiL3l/DvmGptoYwo2ufPgF9oFpINlQysxnGJt4kMekJdVxxztvtCivBooSYchQG5IFA4gBTR7co6w+d6Mkzs= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR01MB4112 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Adds Multi-function devices driver for SMpro co-processor found on the Mt.Jade hardware reference platform with Ampere's Altra processor family. Signed-off-by: Quan Nguyen Reported-by: kernel test robot --- Changes in v7: + Smpro-mfd now significant changes in compare with simple-mfd-i2c driver, remove the copyright note about simple-mfd-i2c [Quan] + Install bus->read/write() to handle multiple types of bus access. [Quan] + Update license to MODULE_LICENSE("GPL") [Quan] + Add others minor refactor the code [Quan] Changes in v6: + Update license part to reflect that this driver is clone from simple-mfd-i2c driver [Quan] Changes in v5: + Dropped the use of simple-mfd-i2c driver [Quan] + Introduced drivers/mfd/smpro-mfd.c driver to instantiate sub-devices. This is to avoid DT nodes without resource issue [Quan] + Revised commit message [Quan] Changes in v4: + Add "depends on I2C" to fix build issue found by kernel test robot [Guenter] Changes in v3: + None Changes in v2: + Used 'struct of_device_id's .data attribute [Lee Jones] drivers/mfd/Kconfig | 12 ++++ drivers/mfd/Makefile | 1 + drivers/mfd/smpro-mfd.c | 134 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 147 insertions(+) create mode 100644 drivers/mfd/smpro-mfd.c diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig index 3b59456f5545..383d0e6cfb91 100644 --- a/drivers/mfd/Kconfig +++ b/drivers/mfd/Kconfig @@ -77,6 +77,18 @@ config MFD_AS3711 help Support for the AS3711 PMIC from AMS +config MFD_SMPRO + tristate "Ampere Computing MFD SMpro core driver" + depends on I2C + select MFD_CORE + select REGMAP_I2C + help + Say yes here to enable SMpro driver support for Ampere's Altra + processor family. + + Ampere's Altra SMpro exposes an I2C regmap interface that can + be accessed by child devices. + config MFD_AS3722 tristate "ams AS3722 Power Management IC" select MFD_CORE diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile index 858cacf659d6..36f8981cc4fd 100644 --- a/drivers/mfd/Makefile +++ b/drivers/mfd/Makefile @@ -266,6 +266,7 @@ obj-$(CONFIG_MFD_QCOM_PM8008) += qcom-pm8008.o obj-$(CONFIG_SGI_MFD_IOC3) += ioc3.o obj-$(CONFIG_MFD_SIMPLE_MFD_I2C) += simple-mfd-i2c.o +obj-$(CONFIG_MFD_SMPRO) += smpro-mfd.o obj-$(CONFIG_MFD_INTEL_M10_BMC) += intel-m10-bmc.o obj-$(CONFIG_MFD_ATC260X) += atc260x-core.o diff --git a/drivers/mfd/smpro-mfd.c b/drivers/mfd/smpro-mfd.c new file mode 100644 index 000000000000..485c4f89ebd9 --- /dev/null +++ b/drivers/mfd/smpro-mfd.c @@ -0,0 +1,134 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * Ampere Altra Family SMPro MFD - I2C + * + * Copyright (c) 2022, Ampere Computing LLC + * Author: Quan Nguyen + */ + +#include +#include +#include +#include +#include +#include + +/* Identification Registers */ +#define MANUFACTURER_ID_REG 0x02 +#define AMPERE_MANUFACTURER_ID 0xCD3A + +static int smpro_mfd_write(void *context, const void *data, size_t count) +{ + struct device *dev = context; + struct i2c_client *i2c = to_i2c_client(dev); + int ret; + + ret = i2c_master_send(i2c, data, count); + if (ret == count) + return 0; + else if (ret < 0) + return ret; + else + return -EIO; +} + +static int smpro_mfd_read(void *context, const void *reg, size_t reg_size, + void *val, size_t val_size) +{ + struct device *dev = context; + struct i2c_client *i2c = to_i2c_client(dev); + struct i2c_msg xfer[2]; + unsigned char buf[2]; + int ret; + + xfer[0].addr = i2c->addr; + xfer[0].flags = 0; + + buf[0] = *(u8 *)reg; + buf[1] = val_size; + xfer[0].len = 2; + xfer[0].buf = buf; + + xfer[1].addr = i2c->addr; + xfer[1].flags = I2C_M_RD; + xfer[1].len = val_size; + xfer[1].buf = val; + + ret = i2c_transfer(i2c->adapter, xfer, 2); + if (ret == 2) + return 0; + else if (ret < 0) + return ret; + else + return -EIO; +} + +static const struct regmap_bus smpro_regmap_bus = { + .read = smpro_mfd_read, + .write = smpro_mfd_write, + .val_format_endian_default = REGMAP_ENDIAN_BIG, +}; + +static bool smpro_mfd_readable_noinc_reg(struct device *dev, unsigned int reg) +{ + return (reg == 0x82 || reg == 0x85 || reg == 0x92 || reg == 0x95 || + reg == 0xC2 || reg == 0xC5 || reg == 0xD2 || reg == 0xDA); +} + +static const struct regmap_config smpro_regmap_config = { + .reg_bits = 8, + .val_bits = 16, + .readable_noinc_reg = smpro_mfd_readable_noinc_reg, +}; + +static const struct mfd_cell smpro_devs[] = { + MFD_CELL_NAME("smpro-hwmon"), + MFD_CELL_NAME("smpro-errmon"), + MFD_CELL_NAME("smpro-misc"), +}; + +static int smpro_mfd_probe(struct i2c_client *i2c) +{ + const struct regmap_config *config; + struct regmap *regmap; + unsigned int val; + int ret; + + config = device_get_match_data(&i2c->dev); + if (!config) + config = &smpro_regmap_config; + + regmap = devm_regmap_init(&i2c->dev, &smpro_regmap_bus, &i2c->dev, config); + if (IS_ERR(regmap)) + return PTR_ERR(regmap); + + /* Check for valid ID */ + ret = regmap_read(regmap, MANUFACTURER_ID_REG, &val); + if (ret) + return ret; + + if (val != AMPERE_MANUFACTURER_ID) + return -ENODEV; + + return devm_mfd_add_devices(&i2c->dev, PLATFORM_DEVID_AUTO, + smpro_devs, ARRAY_SIZE(smpro_devs), NULL, 0, NULL); +} + +static const struct of_device_id smpro_mfd_of_match[] = { + { .compatible = "ampere,smpro", .data = &smpro_regmap_config }, + {} +}; +MODULE_DEVICE_TABLE(of, smpro_mfd_of_match); + +static struct i2c_driver smpro_mfd_driver = { + .probe_new = smpro_mfd_probe, + .driver = { + .name = "smpro-mfd-i2c", + .of_match_table = smpro_mfd_of_match, + }, +}; +module_i2c_driver(smpro_mfd_driver); + +MODULE_AUTHOR("Quan Nguyen "); +MODULE_DESCRIPTION("SMPRO MFD - I2C driver"); +MODULE_LICENSE("GPL"); From patchwork Mon Mar 21 08:13:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Quan Nguyen X-Patchwork-Id: 12786971 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 A4EADC4332F for ; Mon, 21 Mar 2022 08:16:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345241AbiCUIRd (ORCPT ); Mon, 21 Mar 2022 04:17:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45820 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345242AbiCUIRR (ORCPT ); Mon, 21 Mar 2022 04:17:17 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2135.outbound.protection.outlook.com [40.107.243.135]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 066651275C8; Mon, 21 Mar 2022 01:15:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HBs/ZnEATian3MBiAvTlMJF+7majuHxEQRV1mcrm82cu4dM/lZZOKSQ4uylPbrQxfWgOaBb31dVIobYA1zgNJIB0RsVLeOUHeEgnAIB51PGB9CSd6kNjj+ANKaYd3161q6+KqM2VMaofQ/OOiE50PrTMLxvf0AubG1svITgiDX7ctbQLOcMyVuu9BL/HWQzXYDQ6luGkbCJNuttqeLdmxXVIuugY7zkPsMjbYm1n849Fl3v7XL0WdherrDdlRtlmzxl4flCV/rC4aEfUBwNHY3xI4jr5totLPwpcAghc9jZtleJgB2xwzlbX0Xpqr6i6ENM44P+PawTm37YUqBE7DA== 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-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iu13vFrkC87x+NN1X6/znM9HXjNvlrldOjzhCFignEs=; b=DUalB4O7lLZEriTLeJzAyQLKIaXPrjhZuTy1XIjw50vCc6/uSqHlSVZiBRFs1rbEMEvkUr01Yu0XJAlghSWGhwegRZGnyVuInfUUVyy1RUFbLF9jJtzmi2oPkKbcwby0f867QK2cTJ0fis319CJ0DGjSe8/Ia2xUA3MTZeKmXllv9rUqymHz/tDaEGrAzsJL0Xp6jH5G4COmxlcKmHp3cQp6CN4oKEID6saZ+ezz24mNPpMzstwWqtbrPYwrSs3Yok9r21w45rq8oPkY/Z3qzpPRhg4bEwZljzeO3Pn71Thnho9VB+rjwfOi6p93Bjh4xGTzpf6dJ1hEgVqci9ePkw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=os.amperecomputing.com; dmarc=pass action=none header.from=os.amperecomputing.com; dkim=pass header.d=os.amperecomputing.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=os.amperecomputing.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iu13vFrkC87x+NN1X6/znM9HXjNvlrldOjzhCFignEs=; b=TrdtCXFJgD4y22fbLMJmtVAYcV0RG1RRnrlx31SrRbwMNxLfHhqxMB6g9h4oHgDoHUXKrFqxH3JMzFBartYlTNoe/V+QzCfHGGUzE6X8QOu/To0LU6RXdYHNgMBG4Tbdg2nvamNEmQ6M3p6wRfWLNQgrk7S2m++mD9hJpY49jHI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=os.amperecomputing.com; Received: from SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) by SN6PR01MB4112.prod.exchangelabs.com (2603:10b6:805:a6::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5081.21; Mon, 21 Mar 2022 08:15:22 +0000 Received: from SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6]) by SJ0PR01MB7282.prod.exchangelabs.com ([fe80::cd24:39ed:7042:46d6%8]) with mapi id 15.20.5081.022; Mon, 21 Mar 2022 08:15:22 +0000 From: Quan Nguyen To: Lee Jones , Rob Herring , Krzysztof Kozlowski , Jean Delvare , Guenter Roeck , Jonathan Corbet , Derek Kiernan , Dragan Cvetic , Arnd Bergmann , Greg Kroah-Hartman , Quan Nguyen , Thu Nguyen , Gustavo Pimentel , linux-kernel@vger.kernel.org (open list), devicetree@vger.kernel.org (open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS), linux-hwmon@vger.kernel.org (open list:HARDWARE MONITORING), linux-doc@vger.kernel.org (open list:DOCUMENTATION), OpenBMC Maillist Cc: Open Source Submission , Phong Vo , "Thang Q . Nguyen" Subject: [PATCH v7 9/9] docs: ABI: testing: Document the Ampere Altra Family's SMpro sysfs interfaces Date: Mon, 21 Mar 2022 15:13:55 +0700 Message-Id: <20220321081355.6802-10-quan@os.amperecomputing.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220321081355.6802-1-quan@os.amperecomputing.com> References: <20220321081355.6802-1-quan@os.amperecomputing.com> X-ClientProxiedBy: SGXP274CA0010.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:b8::22) To SJ0PR01MB7282.prod.exchangelabs.com (2603:10b6:a03:3f2::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4bf2a670-5212-4739-cd94-08da0b12f1aa X-MS-TrafficTypeDiagnostic: SN6PR01MB4112:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: iXLm5MQmFoS6MyX2TeBuR6ObBMxshL1VYAdmC5JJGWgb1KX3Z2ELiWLGie/4nXmsHqovl98ULq8KjZMNtQiXOru6SXzYYlcqnyFJcTkEB0nn6iSnH/hCI1HkSdQ0zjBoDXTcNZrr3+fTFsHgEbA4pqM+lPPRwOoi8h+dE/p06+Ei12MmqA5e4/fhmWmdRb3vDyvPBxww/PklJ5D5+yPTjCpr9BsKXMYd9lWUkOj0SdK5Q7Dh3ZpZMAkUYv5g8evQG0CaUEaTDCCTUwK4dbdBpZWFUHYC5sb4Mg3Fr+lX4AzTrkGIoPUiZPFOgLv/brxvT+sumaSFEMTNW+yzpmrj+mDyaU/AxHVXnNPpXSHh3WgAIJTnkR0Qv92jdtnLlucLdgNOF7eebW1XdZ9tXAAJ2xwJsavz66qbCPxRCtiQ4zc/yAXfugumoVTTrwAIUTT6iNfkQfY26xvY8FBG77Zzb9loUemBO+7G8tFm1yPx40Ghn+GyjLP0QtQaGY8PCTiI2Gqa7AewYbuFgRCSUKzQi0SfO1Z6zQn3OGmrmHDag30KLJdU/tvqIanNEJkY8PYye+Km4kkJNOg5UaTY6VfJ4RW0jwGlhlgQrL0sQyKsKuWhT20Fwfo1kgKbPqMYJ59C+sAmLKGcH2lp4F4CnfOnr2TzdnP/df3gALYCcLrbdNLR0dBkrOgXg8aCWuLawmtMzn+ajjsO9CbRyypvOdDwduKE4M6xoxGpQnSwC4dlQsU= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:SJ0PR01MB7282.prod.exchangelabs.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(5660300002)(508600001)(2616005)(26005)(107886003)(86362001)(8936002)(186003)(2906002)(1076003)(52116002)(7416002)(6666004)(6512007)(6506007)(921005)(38350700002)(38100700002)(110136005)(83380400001)(8676002)(66946007)(316002)(4326008)(66556008)(66476007)(6486002)(54906003);DIR:OUT;SFP:1102; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: zDaaV07E2TxYzh0FdJCZ82jzLATA+PvQNkYizfg9nz0Y31Stu090hZTV1J4Sh5POVW0c79hjKHgKGEi/YbqCOxn26Mj6fOYq8frSaONTyUrULRJJMJvPMozCQUA2wcoFnXv6n7f2nIK/r1GsHd9q8GduAUgo/kme36INvWriqxsJNA8D7/ax0YBZflXnd+8NusNizA2dKf2ZuwDN1Xkx0S6RNl3wIUzT1dctoRnHgwEBi37ulnudUBkUV+lgADPuf3HkROFZ6cXvM8/1oO1bvUAfzCeC6K1g4lkCGko8xn7kfktnUM4csTY1hnAoSxZ0OJGyyKAPd4H4n9TwO7/J5ofkUkuqZRbH1rD+YWWCMA0+d3FrAzMAYje9mDn7Z+SP+oLP3vrfsWJtAKkGeKl/5hqEza3o2Nz3ojMHD9YxMfZ5COLQkI8MdxmmyIeb8XkmCrPYqYLrzNwwZqAS5P1iXRlYiOkkkW+blUCnKyXvSj5gYssIOXSzXsAtlQhrMPsHO3MvqmO8heZUI5Hp0EoL4nKk3QEILziG3wFUDSZPN3xO5dspFXOFSC7vKb7SVEhqER7f9U13qh/W1x0NhKaKedkZtD1o4Io6WRwAIu6VuQrQzGm5xqE3+lycoZkbtgY6OqdUr8SB78Wb6kIxU6XOXBkACsoGdSuqRO4uo8ReP+NmhRT3RQ+OxaKeDWqLZmgsLXri4J9RN7u7BS/uxQD3UCHQmHvW9EYjgffvQz+NuYnSpRnypwhyPrTGBHmudUtw8Jsys8GyprAjXA3palBtQb1XvSnFw1q8jFmZRNxARkliikj1fyqli6ksupNGkruReaqqy3nFIBGF/1pSOv29fvYXDZEk8b2s1H/BcTu7dJ6fxIzT1xE3aaLioSRTXY/EPc7HeI3qxou8cGRBjnw08tPwih0XEuIoMz1O7ZOLR8309S/PTisVWpli7GE3U/eqBxWwAVbO0e3BhSyd9adK5xm+pNpodrrjnbSDD6e/aWGQBIoyeXEMivgvoygGpYOVtu/4YUKIGEGMdo7DoJrKk738gTDGeqyQP+LktVAYqb/mrt03XkQUL2eR0Uhs0JYSijBDxBSc7EG4dkZWSsXquCJTKm9+bCY6lkrL/siZxzU0ppUx898NqGn5MeRN5sbBTrdBc6TWsSZTptShCIwVtNgQIj+zxp5OIeslDnnA/3jOE2P1XHekyfZIaggP9gJH/KKBRE4Kps3TZ8B1x7HUrjPNVrgKPCbPMeVmWkHeyoq58wGO9tJBIzZvASUzhWcof1FzHGVmaHog4X+dyoMtGjr86FPza4OcprPY2MmyTmPKC6F1A9Zga7ju4JnxiGXhAffmYC4bsBlIOGMFBNvDMlvQAonlf/kAy1m0I0gAtrFnQ4bgaXm//kCMrE7GvLEKPiv13LzmtiRPanH5leOPC1ZFtIYw3TP9Rty3KkI8y7liGH7KDL2KnVKmyU1uHUIPBTauSWUpsK/8ng7AgQdP5yZMw7nvq4BMWPOG8/wtXDE= X-OriginatorOrg: os.amperecomputing.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4bf2a670-5212-4739-cd94-08da0b12f1aa X-MS-Exchange-CrossTenant-AuthSource: SJ0PR01MB7282.prod.exchangelabs.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 21 Mar 2022 08:15:22.1134 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 3bc2b170-fd94-476d-b0ce-4229bdc904a7 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1uPOPuoLjDECTEOzfMRyYlYi0l+ifyA+kg4mUP3kOcJiIdHf7F6FtlIBddcoipemcWmgeNQXntxRdgjOGnyS46pXmChvMlBjpeSBV7CEF60= X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN6PR01MB4112 Precedence: bulk List-ID: X-Mailing-List: linux-hwmon@vger.kernel.org Add documentation for the Ampere(R)'s Altra(R) SMpro sysfs interfaces Signed-off-by: Quan Nguyen --- Changes in v7: + First introduce in v7 [Greg] .../sysfs-bus-platform-devices-ampere-smpro | 133 ++++++++++++++++++ 1 file changed, 133 insertions(+) create mode 100644 Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro diff --git a/Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro b/Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro new file mode 100644 index 000000000000..9bfd8d6d0f71 --- /dev/null +++ b/Documentation/ABI/testing/sysfs-bus-platform-devices-ampere-smpro @@ -0,0 +1,133 @@ +What: /sys/bus/platform/devices/smpro-errmon.*/errors_[core|mem|pcie|other]_[ce|ue] +KernelVersion: 5.14 +Contact: quan@os.amperecomputing.com +Description: + (RO) Contains the 48-byte Ampere (Vendor-Specific) Error Record, see [1] + printed in hex format as below: + + AA BB CCCC DDDDDDDD DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD \ + DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD DDDDDDDDDDDDDDDD + Where: + AA : Error Type + BB : Subtype + CCCC : Instance + DDD...DDD: Similar to the Arm RAS standard error record + + See [1] below for the format details. + + The detail of each sysfs entries is as below: + +-------------+---------------------------------------------------------+ + | Error | Sysfs entry | + +-------------+---------------------------------------------------------+ + | Core's CE | /sys/bus/platform/devices/smpro-errmon.*/errors_core_ce | + | Core's UE | /sys/bus/platform/devices/smpro-errmon.*/errors_core_ue | + | Memory's CE | /sys/bus/platform/devices/smpro-errmon.*/errors_mem_ce | + | Memory's UE | /sys/bus/platform/devices/smpro-errmon.*/errors_mem_ue | + | PCIe's CE | /sys/bus/platform/devices/smpro-errmon.*/errors_pcie_ce | + | PCIe's UE | /sys/bus/platform/devices/smpro-errmon.*/errors_pcie_ue | + | Other's CE | /sys/bus/platform/devices/smpro-errmon.*/errors_other_ce| + | Other's UE | /sys/bus/platform/devices/smpro-errmon.*/errors_other_ue| + +-------------+---------------------------------------------------------+ + UE: Uncorrect-able Error + CE: Correct-able Error + + [1] Section 3.3 Ampere (Vendor-Specific) Error Record Formats, + Altra Family RAS Supplement. + + +What: /sys/bus/platform/devices/smpro-errmon.*/errors_[smpro|pmpro] +KernelVersion: 5.14 +Contact: quan@os.amperecomputing.com +Description: + (RO) Contains the internal firmware error record printed as hex format + as below: + + A BB C DD EEEE FFFFFFFF + Where: + A : Firmware Error Type + 1: Warning + 2: Error + 4: Error with data + BB : Firmware Image Code (8-bit value) + C : Direction: + 0: Enter + 1: Exit + DD : Location, firmware module location code (8-bit value) + EEEE : Error Code, firmware Error Code (16-bit value) + FFFFFFFF: Extensive data (32-bit value) + + Example: + root@mtjade:~# cat /sys/bus/platform/devices/smpro-errmon.1.auto/errors_smpro + 1 09 0 08 000a 00000000 + + The detail of each sysfs entries is as below: + +-------------+-------------------------------------------------------+ + | Error | Sysfs entry | + +-------------+-------------------------------------------------------+ + | SMpro error | /sys/bus/platform/devices/smpro-errmon.*/errors_smpro | + | PMpro error | /sys/bus/platform/devices/smpro-errmon.*/errors_pmpro | + +-------------+-------------------------------------------------------+ + See more details in section 5.10 RAS Internal Error Register Definitions, + Altra Family Soc BMC Interface Specification. + + +What: /sys/bus/platform/devices/smpro-errmon.*/event_[vrd_warn_fault|vrd_hot|dimm_hot] +KernelVersion: 5.14 +Contact: quan@os.amperecomputing.com +Description: + (RO) Contains the detail information in case of VRD/DIMM warning/hot events + in hex format as below: + + AA BBBB + Where: + AA : The event channel + 00: VRD Warning Fault + 01: VRD Hot + 02: DIMM host + BBBB: The event detail information data + + See more details in section 5.7 GPI Status Registers, + Altra Family Soc BMC Interface Specification. + + +What: /sys/bus/platform/devices/smpro-misc.*/boot_progress +KernelVersion: 5.14 +Contact: quan@os.amperecomputing.com +Description: + (RO) Contains the boot stages information in hex as format below: + + AA BB CCCCCCCC + Where: + AA : The boot stages + 00: SMpro firmware booting + 01: PMpro firmware booting + 02: ATF BL1 firmware booting + 03: DDR initialization + 04: DDR training report status + 05: ATF BL2 firmware booting + 06: ATF BL31 firmware booting + 07: ATF BL32 firmware booting + 08: UEFI firmware booting + 09: OS booting + BB : Boot status + 00: Not started + 01: Started + 02: Completed without error + 03: Failed. + CCCCCCCC: Boot status information defined for each boot stages + + See more details in section 5.11 Boot Stage Register Definitions, + and section 6. Processor Boot Progress Codes, Altra Family Soc BMC + Interface Specification. + + +What: /sys/bus/platform/devices/smpro-misc*/soc_power_limit +KernelVersion: 5.14 +Contact: quan@os.amperecomputing.com +Description: + (RW) Contains the desired SoC power limit in Watt. + Writes to this sysfs set the desired SoC power limit (W). + Reads from this register return the current SoC power limit (W). + The value ranges: + Minimum: 120 W + Maximum: Socket TDP power