From patchwork Thu Oct 13 09:05:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Manne, Nava kishore" X-Patchwork-Id: 1984 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp169361wrs; Thu, 13 Oct 2022 02:14:47 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4ShLHVZ8FS/JZXCYEi5okOArQp6sIm/xVy+mllqn/6MOhOvQzI3XUKq/MwJ2uurab7yG2C X-Received: by 2002:a17:906:9b86:b0:73d:72cf:72af with SMTP id dd6-20020a1709069b8600b0073d72cf72afmr25534096ejc.440.1665652486973; Thu, 13 Oct 2022 02:14:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665652486; cv=pass; d=google.com; s=arc-20160816; b=nton6LlCng0lD4bzeI8gjKw/qIEYpB3nlIiJIvAbWZVFSBeQqcnTTOsAMltRx6W5Si Mqd9okav82fccKKeJd0n4eJnfrNaqFokf7fuZBIcfzV3t+uQBf9rcs6ETGzQKZR0oH18 fb6RhNCaTkd5cjRN101u17KnBFusxnVzZhdlWqcTJ0lJxdKps6+cJyP2DttgbQKvPn9r DCVNmN/vh0xN1NW5EQUHCdvp3SsKYT7/t1EL2wIotvRwydbii/39wpZ299YSqKirF3Kd 19A8SKN4I1E21Y/eXjPBggZz71+65g6bAy3oM/j+isT8Nv5jlei5aIZd+i2QJbvLlsho 7FUQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=jVw7E3maP+kFvQ1taOQSCAScBaVZu28hMZB7lpaSxn8=; b=k6qjjERXvYzLiHnxpEwZeFKHJEIo7DUHL1V3Xi+d6eO2to8UVanwYXF+kXIy6pFj3U y0zWed9FAjj1LBu4QEbqgnBts9QN7D5XgQtIZ/I18ONZBv3K3OWhE/KePQQBM/L2Otkc MV56+zZJcmuvhV8lGJ7bj5Vprz3LxlyopsNbPwP3poikplde6hFa8KNlBdupbCs9FrmP Y+RBZ/ll/9vX6Sp+brEuzqOFi+T2OOStp9KEOWgUOkNEjL5TUD6C1p7I3sLoyksnc8NV Xr0i96jmWcPM8N7AXGBsWUZrFPKTbybf5Xbq0gk4/PfQ6pTZMvHblP9A4vHcDiSdiwpl dx7Q== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Gzt0nxvO; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id b16-20020a170906039000b00773e2e6f605si17005335eja.930.2022.10.13.02.14.18; Thu, 13 Oct 2022 02:14:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=Gzt0nxvO; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229879AbiJMJGS (ORCPT + 99 others); Thu, 13 Oct 2022 05:06:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229727AbiJMJGQ (ORCPT ); Thu, 13 Oct 2022 05:06:16 -0400 Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2053.outbound.protection.outlook.com [40.107.244.53]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 814E54B992; Thu, 13 Oct 2022 02:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=AwU2MJLhmXssIUaAx/J0y9Dtw31+pak5uvlvE4slt9oWdoD6+E5J+8P4hTKuRDoJaUuU2bgiiteIuRNofmven5pXN1L9eZGA7JurZ1fTMqPALzrOCpZvHmvzOrga6EsAJv12buHsE2TqOXX4KDKLAANwvrnUoetbG7xC82TgJSXrnPi8xGpdwcoaHZixNJ/zl1fJ7CaB5O1meObFNuqiKjhnQLTn58cA/cBLVHkaV1bPlJHBUZtNv9xA5r38SrSDeMi7FD47PHBFAB3j7KL3ZgiCpbuCxOeOPxFi2/k2l8KN5RYZQUMkbVNvWq+zfy/Hl3jG0kzRNOtsvjM7omeDvQ== 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=jVw7E3maP+kFvQ1taOQSCAScBaVZu28hMZB7lpaSxn8=; b=kSeWVxha/xfAjYjEHvxNPgo9GAU0zS7gs3Q0aPcvV5c55vXr/l4TFXD8GZqfH40t1SqfEotWsFNa7msNHsYMYtLBz9/6FOIi0+lH3ExsAw1t+cplqitlfcaTWU5TN96COTNTbIIxEkFlRXkAUKYFUnAtfTNPCu0tkhc7nfzjxTRXY+b4S5zVHqtl7P6mJregcijzKeZ8Vgq4h+WIvXLGGc7lKRVncbD1aZWcwVL5hhF7T8OcvCaLNqFCDxp2Anx1agFyUjaiK6MKCeitEl29NHVPJTcWyger7eB02K3h3WEJDc4uvZ4xdrBDT6Tmje2/3tWbnSSHTYYlQcjP0ZEksg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xilinx.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jVw7E3maP+kFvQ1taOQSCAScBaVZu28hMZB7lpaSxn8=; b=Gzt0nxvOJJqhvObPwai5YXc8xu9spHu82z7AAgLnJBWDnVc01C9GACovc/wIOyUgQcGBh13BsyJkexpK/9fOuKBSkb18m616iMn9d4enruoVprJBs/Z3yua+L2UouvfQsmHgW/KtXLfhpUKoF2ykiCpSPuREs/szPuii7Pgeovw= Received: from MW4P223CA0020.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::25) by BL0PR12MB5010.namprd12.prod.outlook.com (2603:10b6:208:17c::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.21; Thu, 13 Oct 2022 09:06:11 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::8a) by MW4P223CA0020.outlook.office365.com (2603:10b6:303:80::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5723.26 via Frontend Transport; Thu, 13 Oct 2022 09:06:10 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Thu, 13 Oct 2022 09:06:10 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 13 Oct 2022 04:06:08 -0500 From: Nava kishore Manne To: , , , , , , , , , , , , , , , , Subject: [PATCH v3 1/2] firmware: xilinx: Add pm api function for PL config reg readback Date: Thu, 13 Oct 2022 14:35:55 +0530 Message-ID: <20221013090556.741357-2-nava.kishore.manne@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221013090556.741357-1-nava.kishore.manne@amd.com> References: <20221013090556.741357-1-nava.kishore.manne@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT013:EE_|BL0PR12MB5010:EE_ X-MS-Office365-Filtering-Correlation-Id: cddd7bda-aba9-4e28-09bf-08daacfa2bf3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: X3t4ohiLTYeZB4ztoQ89JKv1o4+mWWVfEWWTT+8X3kQwzr17/FH//kE0TSBpXvW/zEaCPsEI3vdr4Ju3Yv+i1RYecxCHKDqUBWXqnmLlVQ1ftPHPB5zy8YrFzpTBZPW39EIybP1jK0VYjMEqGN5dxuukw0koLs9i83p8cLoAVYSnm7Cbmuiagv9OY0eI0uGjF39B/KdHDnSsXoGaLFTR0uQnIVElVG8J2Iml3ZzDRSj8V5OCKLgHy2NRmKOoRvdcUOOLx+Y949rt0XdR5HFnF+zSaK0Z+V/AfMu4lloUs5O7d+4fC8pBMl3HYjtXICGGN0zhdA4hfmycaOJM4xEguofWhhtpeY+PhmLgVd65H0uGPNNzEiYKhFYF1orHr99VAxSJjnstV7fulFp7n8XYMsMxvoJalekslq+aSaFOIPBhvOWZCHqXDs2v0ZhyG/RydaIj9V97ch3rXrNeBlzsOfJXKvFBNyBEP8eJP70surMz78/BIC02MKvuT0UFFKOIlG5/bBkvxS2Ui7fs4EiAe/1wHHeHxJvTLko4Oo3HrWsUwhkV/jx13zWPownA2Q6M8S4KRee+QIu2n+Pebz1juKFNVBvyqYEF2/zmVEHDmBs8R350qTNkM30OTq03mNp6Da892IF+Zszy3ntWxr8aqIxfoU3MITFRN8q+xo7JVuWQ+m+Jrr/nEaSPxabQNcRkMJU1ZvAk76qzbUQjGdAHBJvkC580h9ZB1XMXGIP+Y/iIWUeUYOZmZeDEJQG3xAwV5toEUdPF20zLHK9JGOtpr6xn8R/jJhyFJJqqSn10s1CYX2i0fAmSd0bos402hK06bJULL5TO/4g88WzoqXc+AAs+/ZW5kydnj86Bd1QI1DIY2EeLkQ4jRD3poTZX4jlQ X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(376002)(39860400002)(396003)(346002)(136003)(451199015)(40470700004)(46966006)(36840700001)(86362001)(6666004)(426003)(40480700001)(5660300002)(921005)(82310400005)(356005)(83380400001)(70206006)(70586007)(8676002)(47076005)(81166007)(316002)(2906002)(41300700001)(110136005)(336012)(36756003)(26005)(36860700001)(186003)(16526019)(1076003)(2616005)(82740400003)(8936002)(103116003)(478600001)(40460700003)(83996005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 09:06:10.3464 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: cddd7bda-aba9-4e28-09bf-08daacfa2bf3 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5010 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746563222326729047?= X-GMAIL-MSGID: =?utf-8?q?1746563222326729047?= Adds PM API for performing Programmable Logic(PL) configuration register readback. It provides an interface to the firmware(pmufw) to readback the FPGA configuration register. Signed-off-by: Nava kishore Manne --- hanges for v2: - None. Changes for v3: - Updated API and config reg read-back handling logic - Updated the commit msg to align with the changes. drivers/firmware/xilinx/zynqmp.c | 35 ++++++++++++++++++++++++++++ include/linux/firmware/xlnx-zynqmp.h | 11 +++++++++ 2 files changed, 46 insertions(+) diff --git a/drivers/firmware/xilinx/zynqmp.c b/drivers/firmware/xilinx/zynqmp.c index d1f652802181..045a113434c2 100644 --- a/drivers/firmware/xilinx/zynqmp.c +++ b/drivers/firmware/xilinx/zynqmp.c @@ -941,6 +941,41 @@ int zynqmp_pm_fpga_get_status(u32 *value) } EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_status); +/** + * zynqmp_pm_fpga_get_config_status - Get the FPGA configuration status. + * @value: Buffer to store FPGA configuration status. + * + * This function provides access to the pmufw to get the FPGA configuration + * status + * + * Return: Returns status, either success or error+reason + */ +int zynqmp_pm_fpga_get_config_status(u32 *value) +{ + u32 ret_payload[PAYLOAD_ARG_CNT]; + u32 buf, phys_lower_addr, phys_upper_addr, addr; + int ret; + + if (!value) + return -EINVAL; + + addr = (u64)&buf; + + phys_lower_addr = lower_32_bits(addr); + phys_upper_addr = upper_32_bits(addr); + + ret = zynqmp_pm_invoke_fn(PM_FPGA_READ, + XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET, + phys_lower_addr, phys_upper_addr, + XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG, + ret_payload); + + *value = ret_payload[1]; + + return ret; +} +EXPORT_SYMBOL_GPL(zynqmp_pm_fpga_get_config_status); + /** * zynqmp_pm_pinctrl_request - Request Pin from firmware * @pin: Pin number to request diff --git a/include/linux/firmware/xlnx-zynqmp.h b/include/linux/firmware/xlnx-zynqmp.h index 9f50dacbf7d6..34b0a9171293 100644 --- a/include/linux/firmware/xlnx-zynqmp.h +++ b/include/linux/firmware/xlnx-zynqmp.h @@ -70,6 +70,10 @@ #define XILINX_ZYNQMP_PM_FPGA_FULL 0x0U #define XILINX_ZYNQMP_PM_FPGA_PARTIAL BIT(0) +/* FPGA Status Reg */ +#define XILINX_ZYNQMP_PM_FPGA_CONFIG_STAT_OFFSET 7U +#define XILINX_ZYNQMP_PM_FPGA_READ_CONFIG_REG 0U + /* * Node IDs for the Error Events. */ @@ -117,6 +121,7 @@ enum pm_api_id { PM_CLOCK_GETRATE = 42, PM_CLOCK_SETPARENT = 43, PM_CLOCK_GETPARENT = 44, + PM_FPGA_READ = 46, PM_SECURE_AES = 47, PM_FEATURE_CHECK = 63, }; @@ -475,6 +480,7 @@ int zynqmp_pm_is_function_supported(const u32 api_id, const u32 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 *payload); int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset); +int zynqmp_pm_fpga_get_config_status(u32 *value); #else static inline int zynqmp_pm_get_api_version(u32 *version) { @@ -745,6 +751,11 @@ static inline int zynqmp_pm_register_sgi(u32 sgi_num, u32 reset) { return -ENODEV; } + +int zynqmp_pm_fpga_get_config_status(u32 *value) +{ + return -ENODEV; +} #endif #endif /* __FIRMWARE_ZYNQMP_H__ */ From patchwork Thu Oct 13 09:05:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Manne, Nava kishore" X-Patchwork-Id: 1985 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp169498wrs; Thu, 13 Oct 2022 02:15:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7DNyLqzUL1W4jR++37z+Nt1mrWfO6a7qPlOETvx3pL7/sQ0Dw16bpJtT/X+wVnkXyMHORK X-Received: by 2002:a17:906:ee8e:b0:730:4a24:f311 with SMTP id wt14-20020a170906ee8e00b007304a24f311mr26256239ejb.420.1665652510259; Thu, 13 Oct 2022 02:15:10 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1665652510; cv=pass; d=google.com; s=arc-20160816; b=dovVXZ+mwMkbyDJpk3mljyM6g8v4EIHiKNqpwNBJQ/zEItdGgaD90DJ2YRzgHRbyDd r+ZSRTpuHJd+57o3DRAv6IsMX5I2myqc79sOJpKNDogfoHcFFz40E1SA78iLXd6oHApZ pzK1ZaixojEQxiLYTnt7NIsMvn11D26ppWTJsOzcrZPmoN/luqsLq/BJMKnzL4PYF2QM d6VIjrz5rJ2JjfoTTwEadOFtchJXXS1dHoRyAC4Nz6spz8kLAyi7ksbMQ1Z+hXjFhZpR 3nlfbKss8bT91v3OD9oeUO+rXrqIm1PILbj6OJAyqRH04hBhkxauduCdNKRy+NpgjTQP dzVQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=gQHK3WlFdqHBGva3mKYYADCx9HNGT9ok7aYbfwSG/Go=; b=XYHg0nZ6mwGFPjcLG6xbExi5TwDmwS+HMH8/kfl5NchEkkWSJtDwAPUzzmQQbLXQlx iiq6yJ/vcgBfD1ftgTaUbFsw+oV8n+DQJS+6YjMbECcBpS4vLwbIOSDOCzPvPWs87gRt 5QS8Vlxxop4p9xbBFVvbxeu5bgX/g0/zaGyuanyAQlR8GyRPtH+6nt7YdNIbBtfe6mi2 1aHVQ/lmfZBYDYpaGEA4nVSkm+Wl38keU0TQH/uruHf1bilQFxlNog6hQRS8f87kJl/U /i6JPV5njpvdVxBrH22GYWOkASMlQoKFaubVBgzMmZA0+MgMV7lhfShe3pr2LJyLN83o Ocpg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=RMnGi2o0; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h22-20020a056402281600b0045808c3aac6si22648198ede.36.2022.10.13.02.14.44; Thu, 13 Oct 2022 02:15:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=RMnGi2o0; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229925AbiJMJG3 (ORCPT + 99 others); Thu, 13 Oct 2022 05:06:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229891AbiJMJGV (ORCPT ); Thu, 13 Oct 2022 05:06:21 -0400 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1anam02on2089.outbound.protection.outlook.com [40.107.96.89]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D25FC122BE0; Thu, 13 Oct 2022 02:06:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=b2IPx7EfyqVDFshximdP1Jmc32yUDo4//yjfEvJdPAnsDgn9pSugByubioUCaF19JXGgP6gcK4qmfsR8Tyu5XUICvxOeUYyDJh5ssnbDYg/QRCL50JfAxjMwAGRrHPWNuszwcbDSgz6XP+8zA2ue8Vndes4itqb2LOmB7spzpqaZHU+FG/v7loc0kCq8nDQCb6/UVocj1Ig+gT088bEUIQ3Ux5+oiy9diQr6wuzkGp58PgrcXLDuDD5xQ7PkNWZ5+3eBHykHm2AIMISa0FoYYOUjHoOmiAzt0lhErtazFna5PyL85OBGp+JseXnnIPBftiCYu/9zh3ocU+x62xV48Q== 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=gQHK3WlFdqHBGva3mKYYADCx9HNGT9ok7aYbfwSG/Go=; b=HlXUklA9t31PkN9xU4FvTrjniBsBz0C3nKuRi4zTPHBy2qVSNdMhBgSwdt8G+C/qw9fNNWfCuLP6Ni/a+mydaKL/mfNNf/IWrG6T8TTMoBfSgH7GTFtRVMeishokmfuTC0McqVGGnVkO2VZJGO6+xkQagxMxeekGiSLn4h7vpVpIAb1apr5Y1HJmNB7JIu2uY4WrCycZTUjU/AOosie4GV8HJ/2VFdoVU5YKA5D8zBfWR5Pi6EDT+h8KMSFWeRYeGBPoXkaq7XkT+/wnE4Os3G8gEsumA5LO+qaA+lvwTulvjhqYnnjqx9OjR2r4vec3RrX2GUI1VgF2tKtOVXgYgg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=xilinx.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=gQHK3WlFdqHBGva3mKYYADCx9HNGT9ok7aYbfwSG/Go=; b=RMnGi2o0lTqkxg1MS5KVg0h96Ugi+oCueMr198/FKuRSjtOjr5de2c8XmwZlrB4hXVMlDXTogeS2JYCdEi075B6YEmcvFOdiRmmjfFgmr0odBKkdiDlkymZQqxz6Uzl6oixGwPeOF4kFj3p0SYbkyPdIWSozEtBzF+5juvtRy8o= Received: from MW4P223CA0018.NAMP223.PROD.OUTLOOK.COM (2603:10b6:303:80::23) by DM4PR12MB5168.namprd12.prod.outlook.com (2603:10b6:5:397::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.21; Thu, 13 Oct 2022 09:06:13 +0000 Received: from CO1NAM11FT013.eop-nam11.prod.protection.outlook.com (2603:10b6:303:80:cafe::da) by MW4P223CA0018.outlook.office365.com (2603:10b6:303:80::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5709.22 via Frontend Transport; Thu, 13 Oct 2022 09:06:13 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by CO1NAM11FT013.mail.protection.outlook.com (10.13.174.227) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.5723.20 via Frontend Transport; Thu, 13 Oct 2022 09:06:13 +0000 Received: from localhost (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.28; Thu, 13 Oct 2022 04:06:11 -0500 From: Nava kishore Manne To: , , , , , , , , , , , , , , , , Subject: [PATCH v3 2/2] fpga: zynqmp-fpga: Adds status interface Date: Thu, 13 Oct 2022 14:35:56 +0530 Message-ID: <20221013090556.741357-3-nava.kishore.manne@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20221013090556.741357-1-nava.kishore.manne@amd.com> References: <20221013090556.741357-1-nava.kishore.manne@amd.com> MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1NAM11FT013:EE_|DM4PR12MB5168:EE_ X-MS-Office365-Filtering-Correlation-Id: d7f05b45-a3c6-4750-8831-08daacfa2dc1 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: hNGQmDfdaAGCdsbSOuPUAN967C48AZp+wNGvQwJwFPCnWvkZXy5CdeESvXTNKSRQUy5+6bagi08xWXTUxLWNQuHKaw5sklVYur/txi+GKe4N9LcOX+44pzAqx93+pUP2qzCds0beFKTuo6BLYNd8u67nkSqKgH23OG/c9iFttGCrJH7njN8dMWiuf6BkOiHaX1GWe7sB5lDwfjMZy07m5k0yw402/oQuvI3+Kr+o2lXnA8BZ6Dz4ItktUJWJ1AlS1hvqtCS3KKRXDL6p1S2UybowBnPNnD3KMKnvNOCQ4iAk6c60kItivp703nFQzUNLaWxpgZL/NdGIDn190Dp9gwaYbFdgjyLQYffnZtJPY5KXhjV6eHyIEuGLvEWnnacNDYDMEK7QuemLF7xHiz8awLFO24+CSj2auI/6nPcXQ7pKK41Dj4aG1G+yCUmg9D6d0yqIXEwp0lyflASAKZ4zuJ/2068UfFiN+Xy2AqQoPTjBN3RCVIPrxtStwoTh50mtxw/r8l6d2ajShu4XddB7swB9jQJmgbSYpWbFNGACmzMTl0hfIM8mU3R/SotWZzS7pGtsbzqgtMIWFe/mm97/VhuPmBF8C2VV9llOiQwPtuXT888CdlBGFd7/9R/wEvvFE8Pmec655n75F/CRWtkXCdVHlMeY+5uU1HrhEcv6zOYUWZAdb/ss3nDOmgJ14QCUKCSIR15wQufpR9JCNJvfNY9jvTYyz/sBUKt2SqKBAiHaymYQGD+qRfz4wvvgsu1M8Hw6d1p7xzeloTwDBBca1OgVjAlQo5v45CvxyoOtNp6VqhfsbiRhFQxcrmbSQT3pP5ZjYZmbJKX8zLKyXiRFZujw+mGO+KH3abdPdlQU0yy6YDtH1EjitL8j0aHRY0NL X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230022)(4636009)(346002)(136003)(39860400002)(396003)(376002)(451199015)(36840700001)(40470700004)(46966006)(82740400003)(110136005)(478600001)(82310400005)(16526019)(103116003)(40480700001)(2906002)(356005)(186003)(26005)(2616005)(81166007)(1076003)(336012)(83380400001)(6666004)(70206006)(86362001)(426003)(47076005)(70586007)(316002)(5660300002)(8936002)(8676002)(40460700003)(41300700001)(36756003)(36860700001)(921005)(83996005)(2101003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2022 09:06:13.4243 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d7f05b45-a3c6-4750-8831-08daacfa2dc1 X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1NAM11FT013.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5168 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1746563246879506180?= X-GMAIL-MSGID: =?utf-8?q?1746563246879506180?= Adds status interface for zynqmp-fpga, It's a read only interface which allows the user to get the Programmable Logic(PL) configuration status. Usage: To read the Programmable Logic(PL) configuration status cat /sys/class/fpga_manager//device/status Signed-off-by: Nava kishore Manne --- Changes for v2: - Updated status messages handling logic as suggested by Xu Yilun. Changes for v3: - Updated status interface handling logic (Restrict the status interface to the device-specific instead of handled by the core) as suggested by Xu Yilun. drivers/fpga/zynqmp-fpga.c | 87 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) diff --git a/drivers/fpga/zynqmp-fpga.c b/drivers/fpga/zynqmp-fpga.c index c60f20949c47..4e0295486c36 100644 --- a/drivers/fpga/zynqmp-fpga.c +++ b/drivers/fpga/zynqmp-fpga.c @@ -15,6 +15,37 @@ /* Constant Definitions */ #define IXR_FPGA_DONE_MASK BIT(3) +/* Error Register */ +#define IXR_FPGA_ERR_CRC_ERR BIT(0) +#define IXR_FPGA_ERR_SECURITY_ERR BIT(16) + +/* Signal Status Register */ +#define IXR_FPGA_END_OF_STARTUP BIT(4) +#define IXR_FPGA_GST_CFG_B BIT(5) +#define IXR_FPGA_INIT_B_INTERNAL BIT(11) +#define IXR_FPGA_DONE_INTERNAL_SIGNAL BIT(13) + +/* FPGA error status. */ +enum { + ZYNQMP_FPGA_STATUS_CRC_ERR, + ZYNQMP_FPGA_STATUS_SECURITY_ERR, + ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR, + ZYNQMP_FPGA_STATUS_SIGNAL_ERR, + ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR, + ZYNQMP_FPGA_STATUS_EOS_ERR, + ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR, +}; + +static const char * const zynqmp_fpga_error_statuses[] = { + [ZYNQMP_FPGA_STATUS_CRC_ERR] = "reconfig CRC error", + [ZYNQMP_FPGA_STATUS_SECURITY_ERR] = "reconfig security error", + [ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR] = "Device Initialization error", + [ZYNQMP_FPGA_STATUS_SIGNAL_ERR] = "Device internal signal error", + [ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR] = "All I/Os are placed in High-Z state", + [ZYNQMP_FPGA_STATUS_EOS_ERR] = "Device sequence error", + [ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR] = "firmware request error", +}; + /** * struct zynqmp_fpga_priv - Private data structure * @dev: Device data structure @@ -77,6 +108,54 @@ static enum fpga_mgr_states zynqmp_fpga_ops_state(struct fpga_manager *mgr) return FPGA_MGR_STATE_UNKNOWN; } +static ssize_t status_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + unsigned long status = 0; + ssize_t len = 0; + u32 reg_val; + int ret; + u8 i; + + ret = zynqmp_pm_fpga_get_config_status(®_val); + if (!ret) { + if (reg_val & IXR_FPGA_ERR_CRC_ERR) + status |= ZYNQMP_FPGA_STATUS_CRC_ERR; + if (reg_val & IXR_FPGA_ERR_SECURITY_ERR) + status |= ZYNQMP_FPGA_STATUS_SECURITY_ERR; + if (!(reg_val & IXR_FPGA_INIT_B_INTERNAL)) + status |= ZYNQMP_FPGA_STATUS_DEVICE_INIT_ERR; + if (!(reg_val & IXR_FPGA_DONE_INTERNAL_SIGNAL)) + status |= ZYNQMP_FPGA_STATUS_SIGNAL_ERR; + if (!(reg_val & IXR_FPGA_GST_CFG_B)) + status |= ZYNQMP_FPGA_STATUS_HIGH_Z_STATE_ERR; + if (!(reg_val & IXR_FPGA_END_OF_STARTUP)) + status |= ZYNQMP_FPGA_STATUS_EOS_ERR; + } else { + status = ZYNQMP_FPGA_MGR_STATUS_FIRMWARE_REQ_ERR; + } + + for_each_set_bit(i, &status, ARRAY_SIZE(zynqmp_fpga_error_statuses)) + len += sysfs_emit_at(buf, len, "%s ", + zynqmp_fpga_error_statuses[i]); + + if (len) + buf[len - 1] = '\n'; + + return len; +} + +static DEVICE_ATTR_RO(status); + +static struct attribute *zynqmp_fpga_device_attrs[] = { + &dev_attr_status.attr, + NULL, +}; + +static const struct attribute_group zynqmp_fpga_attr_group = { + .attrs = zynqmp_fpga_device_attrs, +}; + static const struct fpga_manager_ops zynqmp_fpga_ops = { .state = zynqmp_fpga_ops_state, .write_init = zynqmp_fpga_ops_write_init, @@ -88,6 +167,7 @@ static int zynqmp_fpga_probe(struct platform_device *pdev) struct device *dev = &pdev->dev; struct zynqmp_fpga_priv *priv; struct fpga_manager *mgr; + int ret; priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); if (!priv) @@ -95,6 +175,13 @@ static int zynqmp_fpga_probe(struct platform_device *pdev) priv->dev = dev; + /* Add the device attributes */ + ret = sysfs_create_group(&dev->kobj, &zynqmp_fpga_attr_group); + if (ret) { + dev_err(dev, "Error creating sysfs files\n"); + return ret; + } + mgr = devm_fpga_mgr_register(dev, "Xilinx ZynqMP FPGA Manager", &zynqmp_fpga_ops, priv); return PTR_ERR_OR_ZERO(mgr);