From nobody Sun Jun 28 09:39:22 2026 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 22FDAC433F5 for ; Wed, 9 Feb 2022 08:27:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241276AbiBII13 (ORCPT ); Wed, 9 Feb 2022 03:27:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34284 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241085AbiBII1O (ORCPT ); Wed, 9 Feb 2022 03:27:14 -0500 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2050.outbound.protection.outlook.com [40.107.92.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 860D3C0613CA for ; Wed, 9 Feb 2022 00:27:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gfLBW/6TgWRB7MugzkLCtWVN3P1G6DMmE7k6nCfnCvNGk3GK4MjWH+zBUnpUAeHAAILx0hWCHNkGFCcGd5q9ZPmGMkG5pjktAUVnBDt7/wEONdU88nQU2gJ4THIAn+cufQUkvSAxFw3xQX3vqV0JsqI2L1XEkCBjObMsmiDhI5gOTyJe34oO2nFSo1mBO54CGBeVy3tAjueYoHkYI3mO1R2Mv1hna/dZjJBQdEGNYPSmkij0E9LoRHG7qA99+OPm0xeFbcPuF+I7/Tnz7uYKpa/xv00R2ZnpR7pUy8k9zGv/xWCU8t1Iu7z4ae4Dxro6K9ufvfi65HERr6TkBpv17Q== 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=qjuchD44P/5PkxHuJbQ27b3bs9bb9qfdjlVHF227NLY=; b=i9g3WZ/svilc+TNQtEg9M3TzRvI7Psdp7FvoW3ZUiZb7Galpo3vdFaNHEmMmWe1/3gLdxN+dfTz0KN/ahrdmTUnskhtsYzqnIhz9uJORfR0U2htp/MZPgSk8CGVc1C42YafQsQpLZra9cIcenuxPS9naTy/ZrDMQr71TJL0DtUPkFBdCZRftKc7dLpU9kXmSi7XE7lWNA6/YRnKq82619JH0z9lnz799opgZflBiLqq64C5pb0XlPmL5xcEZRHh3ikMKOxcXvwDSJUSdSlt1MlsZwd1l86vTbMHXvGmCoV24vQsY5kMrKc9WzjO6AR+5WjaUbimnNCcTJ22Qcmo4Vg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qjuchD44P/5PkxHuJbQ27b3bs9bb9qfdjlVHF227NLY=; b=TR8Vy1tM0l1Bcnds58zLsWfoa8sDrkH4gcnTh2jLEASZsHGznsQlRlSPaKlY2Zj/u0AtkEb/5g0rJq+gOlrcVBHIasavZHI2FesL2VLdcngDLJP5H62CRs5x+zh8xeKKqeG+NCzptyZ2achTshIxeTxpYTpUf2VQz2DqLFP9N3I= Received: from BN9PR03CA0321.namprd03.prod.outlook.com (2603:10b6:408:112::26) by SN1PR02MB3775.namprd02.prod.outlook.com (2603:10b6:802:27::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.18; Wed, 9 Feb 2022 08:27:16 +0000 Received: from BN1NAM02FT023.eop-nam02.prod.protection.outlook.com (2603:10b6:408:112:cafe::2b) by BN9PR03CA0321.outlook.office365.com (2603:10b6:408:112::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 08:27:16 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT023.mail.protection.outlook.com (10.13.2.137) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 08:27:15 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 9 Feb 2022 00:27:12 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 9 Feb 2022 00:27:12 -0800 Envelope-to: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, corbet@lwn.net, linux-arm-kernel@lists.infradead.org, arnd@arndb.de Received: from [172.19.2.91] (port=40310 helo=xsjjollys50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nHiJk-0003T0-D9; Wed, 09 Feb 2022 00:27:12 -0800 From: Ronak Jain To: , CC: , , , , , , Ronak Jain Subject: [PATCH v5 1/3] firmware: xilinx: Add support for runtime features Date: Wed, 9 Feb 2022 00:27:07 -0800 Message-ID: <20220209082709.32378-2-ronak.jain@xilinx.com> X-Mailer: git-send-email 2.32.0.93.g670b81a In-Reply-To: <20220209082709.32378-1-ronak.jain@xilinx.com> References: <20220209082709.32378-1-ronak.jain@xilinx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9ab5c01f-d24e-44bf-8a33-08d9eba5faae X-MS-TrafficTypeDiagnostic: SN1PR02MB3775:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:935; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: vRL881/QA04n/W5TSQBUUmwN6877x7J7GOuctoTkDRwayoiioQdlYmXQ0GF6pGz8S5k3rSPQa/bEzkBaIn015D5MThzVAv1sK/xeiMa7uHFD9CVoGxbzGPjAUXjB2f4xU0fIc9tm576F2JzgzB8jPXx+vCJlBr9iNZ3NRIfTP00chkijcU+x/Dd+KWXFNb5yzNi9/4xMC0u9Zh8dbQOJwc4S2xTplqBDTQQVjURIAfcv/Uf2kLmE6HhZpA9BO/TDkY+x32vLWw5rkB7Y9q5dxv5wCmYjfuaP3cEFn1hoinhNTQATh8BLfbzvwqku9IBSa7tcFNrA1E8qxC2Wz89027Kqq/gBjC+HiAU4whsnCOZMegPUJDJxoDrk7gD2fviPnUeqN8PN5reKagz+FG1M9owB42pw5GLcXnGtrUpKRyk2Z98ioK7JCZQXPLXYnav7No2I0cdty+uirBSq1X3pUapYbZj2WZNy3IViEjF1Znd0GbOoioI44JFeH2RWM9v8H0PoVZfLF1nd4bR4IC+7aV4dQUJIse2Bx4NLnsiiqlGS802VeIOyb+/XD+EjCt0Rkesc2ppuXJf3j8MprR7GtgsvNlZkD+/W+1hv8rlmhxcnHSXm8LOBfu/u7Ft161ppXiMEjxJmWhpfyi5a6dY6l/EzVvn+OoNgqEhTe7oGfd/q2gPvHC6UnUJ5HhKZy5kJZWM1VJDeDCMH681IG1s2WA== X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(82310400004)(186003)(4326008)(70586007)(1076003)(6666004)(83380400001)(2616005)(7696005)(44832011)(9786002)(5660300002)(426003)(36756003)(8936002)(54906003)(2906002)(107886003)(8676002)(26005)(70206006)(7636003)(508600001)(110136005)(40460700003)(36860700001)(356005)(316002)(47076005)(336012)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 08:27:15.6103 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9ab5c01f-d24e-44bf-8a33-08d9eba5faae X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT023.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR02MB3775 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for runtime features by using an IOCTL call. The features can be enabled or disabled from the firmware as well as the features can be configured at runtime by querying IOCTL_SET_FEATURE_CONFIG id. Similarly, the user can get the configured values of features by querying IOCTL_GET_FEATURE_CONFIG id. Signed-off-by: Ronak Jain Acked-by: Michal Simek --- Changes in v5: - Resolved merge conflicts Changes in v4: - Update commit message Changes in v3: - Resolved merged conflict Changes in v2: - Resolved merged conflict - Update commit message --- drivers/firmware/xilinx/zynqmp.c | 27 +++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 25 +++++++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zyn= qmp.c index 450c5f6a1cbf..0fa6cae4969d 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -1156,6 +1156,33 @@ int zynqmp_pm_system_shutdown(const u32 type, const = u32 subtype) 0, 0, NULL); } =20 +/** + * zynqmp_pm_set_feature_config - PM call to request IOCTL for feature con= fig + * @id: The config ID of the feature to be configured + * @value: The config value of the feature to be configured + * + * Return: Returns 0 on success or error value on failure. + */ +int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value) +{ + return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_SET_FEATURE_CONFIG, + id, value, NULL); +} + +/** + * zynqmp_pm_get_feature_config - PM call to get value of configured featu= re + * @id: The config id of the feature to be queried + * @payload: Returned value array + * + * Return: Returns 0 on success or error value on failure. + */ +int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, + u32 *payload) +{ + return zynqmp_pm_invoke_fn(PM_IOCTL, 0, IOCTL_GET_FEATURE_CONFIG, + id, 0, payload); +} + /** * struct zynqmp_pm_shutdown_scope - Struct for shutdown scope * @subtype: Shutdown subtype diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/= xlnx-zynqmp.h index 907cb01890cf..cf557fbeb8c7 100644 --- a/include/linux/firmware/xlnx-zynqmp.h +++ b/include/linux/firmware/xlnx-zynqmp.h @@ -143,6 +143,9 @@ enum pm_ioctl_id { IOCTL_OSPI_MUX_SELECT =3D 21, /* Register SGI to ATF */ IOCTL_REGISTER_SGI =3D 25, + /* Runtime feature configuration */ + IOCTL_SET_FEATURE_CONFIG =3D 26, + IOCTL_GET_FEATURE_CONFIG =3D 27, }; =20 enum pm_query_id { @@ -376,6 +379,14 @@ enum ospi_mux_select_type { PM_OSPI_MUX_SEL_LINEAR =3D 1, }; =20 +enum pm_feature_config_id { + PM_FEATURE_INVALID =3D 0, + PM_FEATURE_OVERTEMP_STATUS =3D 1, + PM_FEATURE_OVERTEMP_VALUE =3D 2, + PM_FEATURE_EXTWDT_STATUS =3D 3, + PM_FEATURE_EXTWDT_VALUE =3D 4, +}; + /** * struct zynqmp_pm_query_data - PM query data * @qid: query ID @@ -447,6 +458,8 @@ int zynqmp_pm_load_pdi(const u32 src, const u64 address= ); int zynqmp_pm_register_notifier(const u32 node, const u32 event, const u32 wake, const u32 enable); int zynqmp_pm_feature(const u32 api_id); +int zynqmp_pm_set_feature_config(enum pm_feature_config_id id, u32 value); +int zynqmp_pm_get_feature_config(enum pm_feature_config_id id, u32 *payloa= d); #else static inline int zynqmp_pm_get_api_version(u32 *version) { @@ -689,6 +702,18 @@ static inline int zynqmp_pm_feature(const u32 api_id) { return -ENODEV; } + +static inline int zynqmp_pm_set_feature_config(enum pm_feature_config_id i= d, + u32 value) +{ + return -ENODEV; +} + +static inline int zynqmp_pm_get_feature_config(enum pm_feature_config_id i= d, + u32 *payload) +{ + return -ENODEV; +} #endif =20 #endif /* __FIRMWARE_ZYNQMP_H__ */ --=20 2.32.0.93.g670b81a From nobody Sun Jun 28 09:39:22 2026 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 D4AEAC433F5 for ; Wed, 9 Feb 2022 08:27:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241108AbiBII1P (ORCPT ); Wed, 9 Feb 2022 03:27:15 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34250 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236318AbiBII1M (ORCPT ); Wed, 9 Feb 2022 03:27:12 -0500 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2079.outbound.protection.outlook.com [40.107.223.79]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86A3AC05CB85 for ; Wed, 9 Feb 2022 00:27:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Mq8GQh4y4jc21cKeHAuWeaTFbXlITi9z1GtO6UDhve6b7P29MlGfB7nV7C34edRObL9b1Dv4azsy/BUvxexOLIfUAF9mLechBlQDtjZuiLUaYgUpVOkB6dJYQQs0SyMc7BCNOrCN9m1J/jhzXV7KyXFBySUY501IAAZTsxb+BueIfRmLrDSk0EBy63M/EPRfUufiyY8cjUsMeFtVpxmATVpys1+AyBFSl51hf38hA0oKrog/d1sD2MHfXkFaIkHc6rkSHU2kp9JJh1tOmvPQtAjgh+pnXW87I6REGcL+30y5TdkH+Z/uZTFSnbVafZ94ubsG3PY0r7GvDHRwXHzYQQ== 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=v4xkKo8LcBxnqo2hVPx4Tj8aAmM93UUPnAiSr2pifXo=; b=Vj9bZB6GgZrkJs/UU0/krlVMCG0wPqnoQ9F4ojhGL8wTc3118frho1sf+7GupbX8tcPStJPQ83hAzZLTCV4lJYvbTOaJ+qyasfqtWebOmNE8whkzhHLvtdhuqwRNUKG7EsQwTEgg4KsM41WmAEbZpTUhfauUhly5Kg6q1EvA4MxdvV747SaAFz9SBUtm2tVgTQgZJVdVqeUwMxPSy3KbJTOwU8YHR+HAfqIqcYPneoAfy7gwfyLSVgqn9OCdSblMWzOcW3WN9TvUo+YSIaRTAIzhzqVpUJfeD9ttmeWh6N/6f3iOH6sl+EzMZ3dcfuzOdZHltIuBowYPCc5n/FXo6Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=v4xkKo8LcBxnqo2hVPx4Tj8aAmM93UUPnAiSr2pifXo=; b=iDXF40HgyAm8L6KeZFe/0mSCURp0JhsJ8T8+4BFy9OHXaErM+1qabWl1OKq191fWxcEVfy+hflE2H2fgH6d7jCGbYBEDgDMw4rTHJZMsAXNTEEBiqfmADuB6w5dfzN/mhpaElAzfdS1/14Y+N3sSW2MLVwmlhxzwSTDzbdlrQGE= Received: from BN9PR03CA0899.namprd03.prod.outlook.com (2603:10b6:408:13c::34) by SA0PR02MB7129.namprd02.prod.outlook.com (2603:10b6:806:eb::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12; Wed, 9 Feb 2022 08:27:13 +0000 Received: from BN1NAM02FT035.eop-nam02.prod.protection.outlook.com (2603:10b6:408:13c:cafe::b4) by BN9PR03CA0899.outlook.office365.com (2603:10b6:408:13c::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 08:27:12 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch01.xlnx.xilinx.com; Received: from xsj-pvapexch01.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT035.mail.protection.outlook.com (10.13.2.81) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 08:27:12 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch01.xlnx.xilinx.com (172.19.86.40) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 9 Feb 2022 00:27:12 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 9 Feb 2022 00:27:12 -0800 Envelope-to: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, corbet@lwn.net, linux-arm-kernel@lists.infradead.org, arnd@arndb.de Received: from [172.19.2.91] (port=40310 helo=xsjjollys50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nHiJk-0003T0-E5; Wed, 09 Feb 2022 00:27:12 -0800 From: Ronak Jain To: , CC: , , , , , , Ronak Jain Subject: [PATCH v5 2/3] firmware: zynqmp: Add documentation for runtime feature config Date: Wed, 9 Feb 2022 00:27:08 -0800 Message-ID: <20220209082709.32378-3-ronak.jain@xilinx.com> X-Mailer: git-send-email 2.32.0.93.g670b81a In-Reply-To: <20220209082709.32378-1-ronak.jain@xilinx.com> References: <20220209082709.32378-1-ronak.jain@xilinx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7d2b1bec-1975-43fd-180e-08d9eba5f917 X-MS-TrafficTypeDiagnostic: SA0PR02MB7129:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:1751; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MfU5oq2aAXo7Sb+gg3TqQYPZbhpavPRr1mI/KqbX+RVOCATGoEhqdlgYU8NX35z9ZS/Ex0CLtJpieA96MmaCOKtk37/EJJbPgBEbSpApkEGjgNh/KY49GSrakftvl0i5kwU0F++l9DTIDv07fxwRvP/MWc7rfT6N7Z3X4l9RH1rMZ4R/AIMCgZoCoK8NuiaHq0OGs1doJcEdwpTUvDA0/iwLBaVW1XoFJQvPt6GV4gvBoY0cQXVT0A9GmmwvbAW9oqwAG3QNupvU6m1gRpK+Z9zUo6LimUsNR+nclS95+gXo8cybLXQVifjVcGkFsYcJApLBqXAsrY8gjG+czTz0Q3fdWkf0w5+mdKo9DloDtJt4NAVScyyCD3rDmgkamhRMVwREFG38jmWTxRra48tJbKabW6jhxVZ6dN9vGXklmjlLBrbLMiEBvrhv1dWY8WRtIwYAGisZxXnmxsP4TuAGvs+DffxTGw/nmXw6vIYxc3ZKZum1G0fQwZKHbMM7pmJnAQH7qkBS65icp4EgOjlubPTbsXwl1IwOAGNtsclLB6k2rUJdKkrLRP6Ifiw7uEiNho/tjfCmJJSBqjcn8elZU0kQHEuiHIGKY13D4ppibf7iMqSKiR9dp8vGlXXmE2GiM21zA7IJap6Xk5dI6xtMy8DH4/QucIeCd6d9YfL2B2cGSLi5rnRwwfT1gp68TdWlPyPxmYDAoy0cI/SMLnN0aQ== X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch01.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(70206006)(54906003)(5660300002)(70586007)(6666004)(36860700001)(83380400001)(316002)(7696005)(110136005)(9786002)(508600001)(356005)(8936002)(36756003)(40460700003)(4326008)(107886003)(8676002)(2906002)(1076003)(26005)(2616005)(186003)(336012)(426003)(7636003)(82310400004)(44832011)(47076005)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 08:27:12.9401 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7d2b1bec-1975-43fd-180e-08d9eba5f917 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch01.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT035.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR02MB7129 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add documentation for sysfs entries like feature_config_id and feature_config_value for runtime feature configuration. The support is added for an over temperature and external watchdog features. Signed-off-by: Ronak Jain Acked-by: Michal Simek --- Changes in v5: - Update kernel version for sysfs documentation Changes in v4: - Add separate sysfs entries for runtime feature config - Update commit message Changes in v3: - None Changes in v2: - Update commit message --- .../ABI/stable/sysfs-driver-firmware-zynqmp | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) diff --git a/Documentation/ABI/stable/sysfs-driver-firmware-zynqmp b/Docume= ntation/ABI/stable/sysfs-driver-firmware-zynqmp index f5724bb5b462..c3fec3c835af 100644 --- a/Documentation/ABI/stable/sysfs-driver-firmware-zynqmp +++ b/Documentation/ABI/stable/sysfs-driver-firmware-zynqmp @@ -113,3 +113,144 @@ Description: # echo 0 > /sys/devices/platform/firmware\:zynqmp-firmware/health_st= atus =20 Users: Xilinx + +What: /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_id +Date: Feb 2022 +KernelVersion: 5.18 +Contact: "Ronak Jain" +Description: + This sysfs interface allows user to configure features at + runtime. The user can enable or disable features running at + firmware as well as the user can configure the parameters of + the features at runtime. The supported features are over + temperature and external watchdog. Here, the external watchdog + is completely different than the /dev/watchdog as the external + watchdog is running on the firmware and it is used to monitor + the health of firmware not APU(Linux). Also, the external + watchdog is interfaced outside of the zynqmp soc. + + The supported config ids are for the feature configuration is, + 1. PM_FEATURE_OVERTEMP_STATUS =3D 1, the user can enable or + disable the over temperature feature. + 2. PM_FEATURE_OVERTEMP_VALUE =3D 2, the user can configure the + over temperature limit in Degree Celsius. + 3. PM_FEATURE_EXTWDT_STATUS =3D 3, the user can enable or disable + the external watchdog feature. + 4. PM_FEATURE_EXTWDT_VALUE =3D 4, the user can configure the + external watchdog feature. + + Usage: + + Select over temperature config ID to enable/disable feature + # echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + + Check over temperature config ID is selected or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_id + The expected result is 1. + + Select over temperature config ID to configure OT limit + # echo 2 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + + Check over temperature config ID is selected or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_id + The expected result is 2. + + Select external watchdog config ID to enable/disable feature + # echo 3 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + + Check external watchdog config ID is selected or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_id + The expected result is 3. + + Select external watchdog config ID to configure time interval + # echo 4 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + + Check external watchdog config ID is selected or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_id + The expected result is 4. + +Users: Xilinx + +What: /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_value +Date: Feb 2022 +KernelVersion: 5.18 +Contact: "Ronak Jain" +Description: + This sysfs interface allows to configure features at runtime. + The user can enable or disable features running at firmware. + Also, the user can configure the parameters of the features + at runtime. The supported features are over temperature and + external watchdog. Here, the external watchdog is completely + different than the /dev/watchdog as the external watchdog is + running on the firmware and it is used to monitor the health + of firmware not APU(Linux). Also, the external watchdog is + interfaced outside of the zynqmp soc. + + By default the features are disabled in the firmware. The user + can enable features by querying appropriate config id of the + features. + + The default limit for the over temperature is 90 Degree Celsius. + The default timer interval for the external watchdog is 570ms. + + The supported config ids are for the feature configuration is, + 1. PM_FEATURE_OVERTEMP_STATUS =3D 1, the user can enable or + disable the over temperature feature. + 2. PM_FEATURE_OVERTEMP_VALUE =3D 2, the user can configure the + over temperature limit in Degree Celsius. + 3. PM_FEATURE_EXTWDT_STATUS =3D 3, the user can enable or disable + the external watchdog feature. + 4. PM_FEATURE_EXTWDT_VALUE =3D 4, the user can configure the + external watchdog feature. + + Usage: + + Enable over temperature feature + # echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + # echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_value + + Check whether the over temperature feature is enabled or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_val= ue + The expected result is 1. + + Disable over temperature feature + # echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + # echo 0 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_value + + Check whether the over temperature feature is disabled or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_val= ue + The expected result is 0. + + Configure over temperature limit to 50 Degree Celsius + # echo 2 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + # echo 50 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_conf= ig_value + + Check whether the over temperature limit is configured or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_val= ue + The expected result is 50. + + Enable external watchdog feature + # echo 3 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + # echo 1 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_value + + Check whether the external watchdog feature is enabled or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_val= ue + The expected result is 1. + + Disable external watchdog feature + # echo 3 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + # echo 0 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_value + + Check whether the external watchdog feature is disabled or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_val= ue + The expected result is 0. + + Configure external watchdog timer interval to 500ms + # echo 4 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_confi= g_id + # echo 500 > /sys/devices/platform/firmware\:zynqmp-firmware/feature_con= fig_value + + Check whether the external watchdog timer interval is configured or not + # cat /sys/devices/platform/firmware\:zynqmp-firmware/feature_config_val= ue + The expected result is 500. + +Users: Xilinx --=20 2.32.0.93.g670b81a From nobody Sun Jun 28 09:39:22 2026 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 C664BC433F5 for ; Wed, 9 Feb 2022 08:28:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241239AbiBII2B (ORCPT ); Wed, 9 Feb 2022 03:28:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241387AbiBII1v (ORCPT ); Wed, 9 Feb 2022 03:27:51 -0500 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2073.outbound.protection.outlook.com [40.107.212.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92648C05CBB9 for ; Wed, 9 Feb 2022 00:27:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aozV1DZodN49KUQQTG3sDYu68PWERUBxZf03oI0zT6hpPL4TeQDY32RyCMB6pKMvWKp5T8yy5W2AtFfmOMFdUWDKw7yBhSydJVBnZLsHwWTRX+iz9jr2GFPhObpG4n33gho11ov04P8QS7q/5Z6IUEJePUa3gp+sR8Do3UEnqvL/LecPkP/3K/54HDMd1W/2YEVrZTShm3HI7fqIcDtbtaNCG3XbAE0Qjo3/Ib7t6T1YNjKy93PBDyy+EIQR3ags8NZleehEa5hYIeayVDhMDCuAwUURO/YaPKKM7oyidpw08irPk6vr5j6qb2TrPoL65S+IS7W+865C+nWaou4g6A== 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=4hEHYpCeIzyIxsQ3kFeZpjVqPsBV5OhXACBcFZTt08M=; b=VhCqMavgkQUb4DQe5dE8znKUR/06lqPBhsCLEPjB84Wye4gRmJNjiwvFnFzdEjd6R2XfjeP/JVrm5ZXb5RaU6WRk3EO+OZmDVIWqb7kFmGgrV/bRGNw13bu+6OinTe8XrR8ToHL1kwNsx1Hc+V9h9yHLxVEXpwzWeG8rbaSBpbKvempP+v9bCjJH/O6aD5s3UQJ6Bz/tSdvDF+fHKYgtkSZZKJymUlj5kcv2qa1QXGetAGKUShGdv54eIJpyXjO9doZzoo/gsJbVYgDm+MAD1doCLP1Ba8VnHu4wIC0fh5M59In5PcaWhm4XHWFIVvqBnu8zQ24nZAYJZ59zrquKYA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 149.199.62.198) smtp.rcpttodomain=vger.kernel.org smtp.mailfrom=xilinx.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=xilinx.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector2-xilinx-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=4hEHYpCeIzyIxsQ3kFeZpjVqPsBV5OhXACBcFZTt08M=; b=bLz+HZazjCZ6Ta0i6dybDoSp0GjYepoLkLYuN6QDLNtseaoyp2uqMIkVcutAmvfFFA/2AcazmBATho/OvUwRvxnuDauc8VpQyljmsoRiEdqQxx0xW8tS0NEa+4Skweij/eDuCoara9IYBFM0IvZKu/P87cwVt1U0UY4SYnhJ8Ok= Received: from BN9PR03CA0857.namprd03.prod.outlook.com (2603:10b6:408:13d::22) by DM8PR02MB7973.namprd02.prod.outlook.com (2603:10b6:8:12::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.17; Wed, 9 Feb 2022 08:27:36 +0000 Received: from BN1NAM02FT020.eop-nam02.prod.protection.outlook.com (2603:10b6:408:13d:cafe::b) by BN9PR03CA0857.outlook.office365.com (2603:10b6:408:13d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4951.12 via Frontend Transport; Wed, 9 Feb 2022 08:27:36 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 149.199.62.198) smtp.mailfrom=xilinx.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.62.198 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.62.198; helo=xsj-pvapexch02.xlnx.xilinx.com; Received: from xsj-pvapexch02.xlnx.xilinx.com (149.199.62.198) by BN1NAM02FT020.mail.protection.outlook.com (10.13.2.135) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.4975.11 via Frontend Transport; Wed, 9 Feb 2022 08:27:36 +0000 Received: from xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2176.14; Wed, 9 Feb 2022 00:27:12 -0800 Received: from smtp.xilinx.com (172.19.127.96) by xsj-pvapexch02.xlnx.xilinx.com (172.19.86.41) with Microsoft SMTP Server id 15.1.2176.14 via Frontend Transport; Wed, 9 Feb 2022 00:27:12 -0800 Envelope-to: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, corbet@lwn.net, linux-arm-kernel@lists.infradead.org, arnd@arndb.de Received: from [172.19.2.91] (port=40310 helo=xsjjollys50.xilinx.com) by smtp.xilinx.com with esmtp (Exim 4.90) (envelope-from ) id 1nHiJk-0003T0-Ey; Wed, 09 Feb 2022 00:27:12 -0800 From: Ronak Jain To: , CC: , , , , , , Ronak Jain Subject: [PATCH v5 3/3] firmware: xilinx: Add sysfs support for feature config Date: Wed, 9 Feb 2022 00:27:09 -0800 Message-ID: <20220209082709.32378-4-ronak.jain@xilinx.com> X-Mailer: git-send-email 2.32.0.93.g670b81a In-Reply-To: <20220209082709.32378-1-ronak.jain@xilinx.com> References: <20220209082709.32378-1-ronak.jain@xilinx.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: cf61540a-463e-469e-0b69-08d9eba606e2 X-MS-TrafficTypeDiagnostic: DM8PR02MB7973:EE_ X-Microsoft-Antispam-PRVS: X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply X-MS-Oob-TLC-OOBClassifiers: OLM:2201; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: XX+fgG3WV7Ton9fDavsoJ+yXJueGOxDf4bZ2XztD5T+G5Znwf8Db74MkGVRrHiWovqZ6nK5rXm7bp+Kui+AXhK5lLzphE4hqiU6yIPh8If+PucaCYAI5YWBiwEngFHTENDOxZEIPsp+cXypBDIJAPaHjQBDrsI9V8AgK9sOEKO9kiiZ0NFvNjHWOP42TUt44jfEaJAvgNgu3qX9jbcE8C6iehm8UbapfRSCMNOTOqEqzS2bxaNid0sKUrUFo0J3NAasn51xBjbVN0ngIG66pJJBwetKDWcaKlJcBi2t+jxXfEcNPVI8K7BaDE8pSUl/F4cmbyerwQvCIGLAJt4A9bDr4j7n6ZQA9b7Qhvcmxv8mFRvgsJkQRS8/caUU0nlxz/MEtLSgbzvWTJoD8si1czAUbkwIB9kCUFrV36IybyGvC/5F188gX67/tBMaq0StM6ogqPWea7uqhxDrMBS2fTydR7/ax6ZtoDGyj3e9k8wIBsSrtCk363MIwBAnskeey7zKm4YVquGHEvVxRNSFcXInmxvZKitBoTN3a3SlclAU0TdUM8EXHRxu9Kl0RS485n6ms51s2ckMzQGe4yI1WV5UQxBwQ76hUq9iyB2KDXCIrKZ0bBdrdfNxcXQ0BAHiiuxvz6lO6W9UvIHd3TZ1fifGIiByGmxW4jyrUVsd3pmfN4IwVXKgj3D8C6FApDsYvCpmuuEdvt4NcFLXcGEtTxQ== X-Forefront-Antispam-Report: CIP:149.199.62.198;CTRY:US;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:xsj-pvapexch02.xlnx.xilinx.com;PTR:unknown-62-198.xilinx.com;CAT:NONE;SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(40460700003)(36860700001)(426003)(70586007)(6666004)(7696005)(336012)(9786002)(8936002)(83380400001)(4326008)(8676002)(47076005)(316002)(70206006)(26005)(7636003)(54906003)(110136005)(356005)(82310400004)(36756003)(186003)(2616005)(44832011)(107886003)(508600001)(1076003)(5660300002)(2906002)(102446001);DIR:OUT;SFP:1101; X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Feb 2022 08:27:36.0649 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cf61540a-463e-469e-0b69-08d9eba606e2 X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c;Ip=[149.199.62.198];Helo=[xsj-pvapexch02.xlnx.xilinx.com] X-MS-Exchange-CrossTenant-AuthSource: BN1NAM02FT020.eop-nam02.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR02MB7973 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Add support for sysfs interface for runtime features configuration. The user can configure the features at runtime. First, the user need to select the config id of the supported features and then the user can configure the parameters of the feature based on the config id. Signed-off-by: Ronak Jain Acked-by: Michal Simek --- Changes in v5: - None Changes in v4: - Update commit message Changes in v3: - Added zynqmp_devinfo structure to store device instances - Modified feature_conf_id from atomic variable to u32 - Update commit message - Resolved merge conflicts Changes in v2: - Update commit message --- drivers/firmware/xilinx/zynqmp.c | 93 ++++++++++++++++++++++++++++++++ 1 file changed, 93 insertions(+) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zyn= qmp.c index 0fa6cae4969d..7d8cb2ec6f8e 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -41,6 +41,16 @@ static DEFINE_HASHTABLE(pm_api_features_map, PM_API_FEAT= URE_CHECK_MAX_ORDER); =20 static struct platform_device *em_dev; =20 +/** + * struct zynqmp_devinfo - Structure for Zynqmp device instance + * @dev: Device Pointer + * @feature_conf_id: Feature conf id + */ +struct zynqmp_devinfo { + struct device *dev; + u32 feature_conf_id; +}; + /** * struct pm_api_feature_data - PM API Feature data * @pm_api_id: PM API Id, used as key to index into hashmap @@ -1451,6 +1461,78 @@ static DEVICE_ATTR_RW(pggs1); static DEVICE_ATTR_RW(pggs2); static DEVICE_ATTR_RW(pggs3); =20 +static ssize_t feature_config_id_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + struct zynqmp_devinfo *devinfo =3D dev_get_drvdata(device); + + return sysfs_emit(buf, "%d\n", devinfo->feature_conf_id); +} + +static ssize_t feature_config_id_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t count) +{ + u32 config_id; + int ret; + struct zynqmp_devinfo *devinfo =3D dev_get_drvdata(device); + + if (!buf) + return -EINVAL; + + ret =3D kstrtou32(buf, 10, &config_id); + if (ret) + return ret; + + devinfo->feature_conf_id =3D config_id; + + return count; +} + +static DEVICE_ATTR_RW(feature_config_id); + +static ssize_t feature_config_value_show(struct device *device, + struct device_attribute *attr, + char *buf) +{ + int ret; + u32 ret_payload[PAYLOAD_ARG_CNT]; + struct zynqmp_devinfo *devinfo =3D dev_get_drvdata(device); + + ret =3D zynqmp_pm_get_feature_config(devinfo->feature_conf_id, + ret_payload); + if (ret) + return ret; + + return sysfs_emit(buf, "%d\n", ret_payload[1]); +} + +static ssize_t feature_config_value_store(struct device *device, + struct device_attribute *attr, + const char *buf, size_t count) +{ + u32 value; + int ret; + struct zynqmp_devinfo *devinfo =3D dev_get_drvdata(device); + + if (!buf) + return -EINVAL; + + ret =3D kstrtou32(buf, 10, &value); + if (ret) + return ret; + + ret =3D zynqmp_pm_set_feature_config(devinfo->feature_conf_id, + value); + if (ret) + return ret; + + return count; +} + +static DEVICE_ATTR_RW(feature_config_value); + static struct attribute *zynqmp_firmware_attrs[] =3D { &dev_attr_ggs0.attr, &dev_attr_ggs1.attr, @@ -1462,6 +1544,8 @@ static struct attribute *zynqmp_firmware_attrs[] =3D { &dev_attr_pggs3.attr, &dev_attr_shutdown_scope.attr, &dev_attr_health_status.attr, + &dev_attr_feature_config_id.attr, + &dev_attr_feature_config_value.attr, NULL, }; =20 @@ -1471,6 +1555,7 @@ static int zynqmp_firmware_probe(struct platform_devi= ce *pdev) { struct device *dev =3D &pdev->dev; struct device_node *np; + struct zynqmp_devinfo *devinfo; int ret; =20 np =3D of_find_compatible_node(NULL, NULL, "xlnx,zynqmp"); @@ -1487,6 +1572,14 @@ static int zynqmp_firmware_probe(struct platform_dev= ice *pdev) if (ret) return ret; =20 + devinfo =3D devm_kzalloc(dev, sizeof(*devinfo), GFP_KERNEL); + if (!devinfo) + return -ENOMEM; + + devinfo->dev =3D dev; + + platform_set_drvdata(pdev, devinfo); + /* Check PM API version number */ ret =3D zynqmp_pm_get_api_version(&pm_api_version); if (ret) --=20 2.32.0.93.g670b81a