From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902233; cv=pass; d=zohomail.com; s=zohoarc; b=XLS77cq3be0ycD4AU5lE6iQg7ImRPC4RAg2aO77R/4IpreX6pXDDNIrQEurUl1Zh6FtIkdi1SiUDn78vqd3Y3IWxvQRwgr0Nc/gQfUwmOncWL4zX7nhoTv9U9+JXm2TReyRHyHN+Ha8UTYUctECvYZ1aM1RMx+/Z0fys4zeASiM= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902233; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=kYVIUFfhd7F1xKgc8Iym0/HlvpD4oHxvRPRdFOekGUs=; b=iAvIiq4FHYLMI5rWJWYqx2mM71FmAdhhVg1Z0Fi0auFwrCDheuX5QHq5ELYR+vn4U8d76NUUZtqeYmHX1BbE50G67PvW2jelJR1St4MM5gbsjYlwArb9+zBaRLId19p4riHdkmQAnfNDQMauuL1KERFfUvSUMEjwqSYejFgmyEk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692902233255629.7169879343553; Thu, 24 Aug 2023 11:37:13 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAi-0006x1-AI; Thu, 24 Aug 2023 14:35:08 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAg-0006wk-J4 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:06 -0400 Received: from mail-mw2nam12on20617.outbound.protection.outlook.com ([2a01:111:f400:fe5a::617] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAb-0006xh-Bg for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:05 -0400 Received: from MW4PR03CA0301.namprd03.prod.outlook.com (2603:10b6:303:dd::6) by CH2PR12MB4152.namprd12.prod.outlook.com (2603:10b6:610:a7::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Thu, 24 Aug 2023 18:34:54 +0000 Received: from CO1PEPF000044FB.namprd21.prod.outlook.com (2603:10b6:303:dd:cafe::55) by MW4PR03CA0301.outlook.office365.com (2603:10b6:303:dd::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.26 via Frontend Transport; Thu, 24 Aug 2023 18:34:54 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044FB.mail.protection.outlook.com (10.167.241.201) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.2 via Frontend Transport; Thu, 24 Aug 2023 18:34:53 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 13:34:53 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:34:51 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aeynt6ZeQeyDEJz096vPCdcIDUT3zE+hAKBXr8ox81bS4uLgIGQIhrKaiBPm0enqqxv3kTi515wbm1aqKbZLat4oMkwgb+zW1OpgOw/OoqTx0bO0N0Gztdp7zeo5YBc/BfQ0LHiGE/mTtk/+VALxAx4yAdUc/J6mmNPv1CFMs9Z2GJHiIc9Y5Xl9SN8vt+XizcRhMsLKP1ywMS32lWf7JhDHs2bc/MXt6/6GyxjuqYq22tpZqOvxlETQvpNmuob7z1VHM9k634c7hjaURbqWnxC4LYdrmDfNarudsJMgyi7Q7uIWskOiJxSjSmk1KKxklFVBxJ2nyZez/cOh5zL1pg== 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=kYVIUFfhd7F1xKgc8Iym0/HlvpD4oHxvRPRdFOekGUs=; b=WhhCdsqJltghRJDxJaewjN2Dte02F8xRuPeoExgBu2wJpCeWWTy/ddkOWU2ME6lZxgq+/IoamEHvXDxmCgx5Ma0kMskf3e4jpKjk0jPV6VK1EshMzjT4zWxX5sktXYf7q2VTFJDi5D4lVefdgjCE68uKsq8XjJM5wUhLo+6uQCeVTzCOI7JD9zjQ4rnKwBnjqEWYYSkgr+7vRZw8kuiPn4T+fOucpVVwYPT18dd4E5BO/FXWTVvm9Wd+tqVuAieJfM+yY0e5AiSgrOAGr8DLbul3/okwEtopBtOl6DV6nE7ST4NeAwM47NUWa+YU42p2o486wbKSPrFHLyc/vs33sA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=kYVIUFfhd7F1xKgc8Iym0/HlvpD4oHxvRPRdFOekGUs=; b=c4xJlK7cR4wOBwzO2E+t5rKun6egnP49CQlV5DvoK94RYRcOFxWSrnJcxpAADEUcsedUmA4iEO5Wgt0wTGeBd7VLN+pSDQVsogFJVUeOHmiIY3UFETOtIp0aia+faTprKGlKXxyqBYBj46oGJeyzI2TeaNaVRmnr2GKpQHwfJBQ= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB03.amd.com; pr=C From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 1/8] hw/misc: Introduce the Xilinx CFI interface Date: Thu, 24 Aug 2023 20:34:41 +0200 Message-ID: <20230824183448.151738-2-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FB:EE_|CH2PR12MB4152:EE_ X-MS-Office365-Filtering-Correlation-Id: 652b4d25-6bac-4336-35b3-08dba4d0cf37 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Wqc4ecFuHxiiWcYa451GXLLCw+4tM3spy/4F5wHo7GtqBcvSmppJvGwg3bqLIY47aolka34oTvh+vcwFZMxw+xoFdkS3oHkwbFChM6lGBdgcCysvhlAqlSEjSBhP57PdboXqVgamzDJoxps8WJKh3GT2niMg43KXnIKocPwNmdXOvL34eSsv4PWW6AfSgITqwDByho1YudLc7cudwt80Ikebt4q+iPyqSm4UKFpoFdZDrUspnTIpdsEnv0f9Su7DU9gsaKIppW7H0o/o6W55KDVYcmjK1Gd9Q2UPXNafAii83xA8MVSYun2HmLXdWITm2dgEAoXdkTzLRSdJjIHW9n8oSB6iSbselNReXnAtNtJPyKozmSN+rm6FQbx2J62Ky7KD8HcZxiq3jbBlZwfDNLbfaUnpT/2GyfbmjVQ7ehu1uKOrLOhbeYqtM+DAJdH4bLnTkPumM5Zsz3o2TB0mmRQxBGqE5SqgDUnaPk2B3HfckJpFiJ1OgoTEOhGuSRMs8xVN/E+jnyklEyY4VsOj154ZZ/E0SXW4IJUZ+t0PFgAO2lb3CyWsaxcfEDtLJoIYEcWyC9bwg0RMOlKvXFTrHRvHsWGC+RLj2Ij6H2HYuLerwLaR1l++OAZxq6gGOQzGKCjIuUPsaZr6OeeP49Lobu8cU4bfRZiJ4vGq0xM856uwu2iCFZOn/QZ2dydgiF2eTAtgQdl0xqqQK7FX6uEo80BSV3QVleyjn0OZ00XToF4MOKfBk1jROqO3wRLoBIyCUrMkkYUF9M/HznKy+j6zzQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(396003)(136003)(39860400002)(346002)(376002)(186009)(1800799009)(451199024)(82310400011)(36840700001)(40470700004)(46966006)(54906003)(6916009)(316002)(70586007)(70206006)(8676002)(8936002)(4326008)(2616005)(36756003)(41300700001)(1076003)(40460700003)(81166007)(82740400003)(356005)(478600001)(6666004)(5660300002)(40480700001)(2906002)(36860700001)(47076005)(86362001)(336012)(426003)(44832011)(26005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:34:53.8305 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 652b4d25-6bac-4336-35b3-08dba4d0cf37 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FB.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH2PR12MB4152 Received-SPF: softfail client-ip=2a01:111:f400:fe5a::617; envelope-from=francisco.iglesias@amd.com; helo=NAM12-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902234601100003 Content-Type: text/plain; charset="utf-8" Introduce the Xilinx Configuration Frame Interface (CFI) for transmitting CFI data packets between the Xilinx Configuration Frame Unit models (CFU_APB, CFU_FDRO and CFU_SFR), the Xilinx CFRAME controller (CFRAME_REG) and the Xilinx CFRAME broadcast controller (CFRAME_BCAST_REG) models (when emulating bitstream programming and readback). Signed-off-by: Francisco Iglesias Reviewed-by: Sai Pavan Boddu Acked-by: Edgar E. Iglesias --- MAINTAINERS | 6 ++++ hw/misc/meson.build | 1 + hw/misc/xlnx-cfi-if.c | 34 ++++++++++++++++++++ include/hw/misc/xlnx-cfi-if.h | 59 +++++++++++++++++++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 hw/misc/xlnx-cfi-if.c create mode 100644 include/hw/misc/xlnx-cfi-if.h diff --git a/MAINTAINERS b/MAINTAINERS index 6111b6b4d9..e0cd365462 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1034,6 +1034,12 @@ S: Maintained F: hw/ssi/xlnx-versal-ospi.c F: include/hw/ssi/xlnx-versal-ospi.h =20 +Xilinx Versal CFI +M: Francisco Iglesias +S: Maintained +F: hw/misc/xlnx-cfi-if.c +F: include/hw/misc/xlnx-cfi-if.h + STM32F100 M: Alexandre Iooss L: qemu-arm@nongnu.org diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 892f8b91c5..0c562f5e3e 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -97,6 +97,7 @@ specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: file= s('xlnx-versal-crl.c')) system_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( 'xlnx-versal-xramc.c', 'xlnx-versal-pmc-iou-slcr.c', + 'xlnx-cfi-if.c', )) system_ss.add(when: 'CONFIG_STM32F2XX_SYSCFG', if_true: files('stm32f2xx_s= yscfg.c')) system_ss.add(when: 'CONFIG_STM32F4XX_SYSCFG', if_true: files('stm32f4xx_s= yscfg.c')) diff --git a/hw/misc/xlnx-cfi-if.c b/hw/misc/xlnx-cfi-if.c new file mode 100644 index 0000000000..c45f05c4aa --- /dev/null +++ b/hw/misc/xlnx-cfi-if.c @@ -0,0 +1,34 @@ +/* + * Xilinx CFI interface + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * Written by Francisco Iglesias + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#include "qemu/osdep.h" +#include "hw/misc/xlnx-cfi-if.h" + +void xlnx_cfi_transfer_packet(XlnxCfiIf *cfi_if, XlnxCfiPacket *pkt) +{ + XlnxCfiIfClass *xcic =3D XLNX_CFI_IF_GET_CLASS(cfi_if); + + if (xcic->cfi_transfer_packet) { + xcic->cfi_transfer_packet(cfi_if, pkt); + } +} + +static const TypeInfo xlnx_cfi_if_info =3D { + .name =3D TYPE_XLNX_CFI_IF, + .parent =3D TYPE_INTERFACE, + .class_size =3D sizeof(XlnxCfiIfClass), +}; + +static void xlnx_cfi_if_register_types(void) +{ + type_register_static(&xlnx_cfi_if_info); +} + +type_init(xlnx_cfi_if_register_types) + diff --git a/include/hw/misc/xlnx-cfi-if.h b/include/hw/misc/xlnx-cfi-if.h new file mode 100644 index 0000000000..f9bd12292d --- /dev/null +++ b/include/hw/misc/xlnx-cfi-if.h @@ -0,0 +1,59 @@ +/* + * Xilinx CFI interface + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * Written by Francisco Iglesias + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ +#ifndef XLNX_CFI_IF_H +#define XLNX_CFI_IF_H 1 + +#include "qemu/help-texts.h" +#include "hw/hw.h" +#include "qom/object.h" + +#define TYPE_XLNX_CFI_IF "xlnx-cfi-if" +typedef struct XlnxCfiIfClass XlnxCfiIfClass; +DECLARE_CLASS_CHECKERS(XlnxCfiIfClass, XLNX_CFI_IF, TYPE_XLNX_CFI_IF) + +#define XLNX_CFI_IF(obj) \ + INTERFACE_CHECK(XlnxCfiIf, (obj), TYPE_XLNX_CFI_IF) + +typedef enum { + PACKET_TYPE_CFU =3D 0x52, + PACKET_TYPE_CFRAME =3D 0xA1, +} xlnx_cfi_packet_type; + +typedef enum { + CFRAME_FAR =3D 1, + CFRAME_SFR =3D 2, + CFRAME_FDRI =3D 4, + CFRAME_CMD =3D 6, +} xlnx_cfi_reg_addr; + +typedef struct XlnxCfiPacket { + uint8_t reg_addr; + uint32_t data[4]; +} XlnxCfiPacket; + +typedef struct XlnxCfiIf { + Object Parent; +} XlnxCfiIf; + +typedef struct XlnxCfiIfClass { + InterfaceClass parent; + + void (*cfi_transfer_packet)(XlnxCfiIf *cfi_if, XlnxCfiPacket *pkt); +} XlnxCfiIfClass; + +/** + * Transfer a XlnxCfiPacket. + * + * @cfi_if: the object implementing this interface + * @XlnxCfiPacket: a pointer to the XlnxCfiPacket to transfer + */ +void xlnx_cfi_transfer_packet(XlnxCfiIf *cfi_if, XlnxCfiPacket *pkt); + +#endif /* XLNX_CFI_IF_H */ --=20 2.34.1 From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902156; cv=pass; d=zohomail.com; s=zohoarc; b=d2vwHunUzEbi4AcZ7Nqbp/fVYCZnkqVGLWak0AvhQv9rDngy43mqcwFtdCHWTLVquFShCvb9/Dn69YV/bXS7EdvqJRYH/ZIjcUHagAGEwl6iuvckJ03SBngL9dXopehqBsFFbyo4K3j4nq2tLe+iYWwF32cVUQpuyaSuGPnLH0E= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902156; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=e9SHItlAQjSTqN0xrYejzdl651JvBfZEfP1DZ2T+Oyg=; b=K8tdTzhc+O17yo0GRXosvZRqt6w+t8OfUXhJA9po+sxzFmYxwDaz2AqCpCvZCaLALxKWdyeCuBcHfPB/h8pLKjnVzvAKYtVyGHINkTOz1H+dqUdVpZ5uJgcdrnzZEhNOB7nGIYPJM1c+BvsqIkV+URM03fiwy2huEI9PR0yLYiU= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692902156200769.1022104552455; Thu, 24 Aug 2023 11:35:56 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAl-0006y5-Bz; Thu, 24 Aug 2023 14:35:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAi-0006xT-LL for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:08 -0400 Received: from mail-dm6nam10on20603.outbound.protection.outlook.com ([2a01:111:f400:7e88::603] helo=NAM10-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAd-0006yC-ED for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:07 -0400 Received: from MW2PR16CA0031.namprd16.prod.outlook.com (2603:10b6:907::44) by SA0PR12MB4413.namprd12.prod.outlook.com (2603:10b6:806:9e::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 18:34:56 +0000 Received: from CO1PEPF000044FD.namprd21.prod.outlook.com (2603:10b6:907:0:cafe::b5) by MW2PR16CA0031.outlook.office365.com (2603:10b6:907::44) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 18:34:56 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044FD.mail.protection.outlook.com (10.167.241.203) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.2 via Frontend Transport; Thu, 24 Aug 2023 18:34:56 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 13:34:55 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:34:53 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ivnxKX61o4q+pJJw80VApW4uUrlZqipAppxljV+zeSY/haFS0AafT2aXXbDc1ut7Rt1CDJLieOLzViPfHGrzhlnTu+cQB1cDfHJrx5CbxG1ncsWlDJyuh4DrAam4asohpVF1ArRmwyW71lB3MqEMRTQ+fuHGwWH40LigsaZJoO4nCyseGJzVHK6hu6OCSwmjUEmCEwsAjCPOMDSfTa0Ms9TTMRYO9He2UEtTtDhLZzQJd1nORWIhvRwHEkZeGJ0eVhmB+tWnO2+A0rzfkBNuCQg7xyLTuTAUBPnr9emO8sT/kpx8wbzxb6wznaVLtq/dqADo+EgWaK9V/dtpre7ixg== 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=e9SHItlAQjSTqN0xrYejzdl651JvBfZEfP1DZ2T+Oyg=; b=BKX9Kbgr1CVMcFvuMaYHYfaFZG2l7zTaH5y6DxQJT7iBUrvEjiyXc5HfwvJd37bKS43etj8agTzpLjE1q2STVKEDfsJlQ3/HaQXYMrdVbJbQRAQrlVhwjTPEYskljQGj3uYmYRxGWBnxxZ8SxK0nXjxLmOmD4xuux8HuYA0C88ueQjFTG4mLdBBA08nKzTiJmHECeRauKEb8sEOC9NA1z1LTgzuL6efYD+6EJ6gzKFvL8KwdHL3+dN4MRi15K3sUZUrqQz8bVeIMFWJZfOPdfzb5KK+STi4fH3ydOzxfKbGlimtwM44nrx/DHdgpwDhFMEQlkpn2KyHs0AO8BJMmiA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=e9SHItlAQjSTqN0xrYejzdl651JvBfZEfP1DZ2T+Oyg=; b=t2dUIr8sTvk9eYca8TzL3lHVko/5J9C7TK3y0pYb5exUY15mOLfwDDp2TgeWb/L8LRchHMnESC+WPAh7UYFh7v0WD2AOppC4AKsh4wzmTN9geo9dJMsAAsQ+jeWWkk0D4OhaP7P7cVMwMVEfI6D1ZaAx5lFVrRUJQkDEX5Ne+C0= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB03.amd.com; pr=C From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 2/8] hw/misc: Introduce a model of Xilinx Versal's CFU_APB Date: Thu, 24 Aug 2023 20:34:42 +0200 Message-ID: <20230824183448.151738-3-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044FD:EE_|SA0PR12MB4413:EE_ X-MS-Office365-Filtering-Correlation-Id: edd749fb-a2f9-434f-2077-08dba4d0d08c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: z3LmOSiVTIcLp9TEKnqsNnjfXi4aUQDQXbjTxncqz4U/WAAHHEDRfQV5XO9bGjhHGF7gq+8GZ6K2xH9o5lsX3L0mDOU7mDfMUFpNyJPwxa/iXQfVZIQl3MWtoLbSMUcXRIzPDClNxq+URxHKmAPHpF3vywztlOiaF86T6UZQwDgPztYW/fLiI989G++7zWrVfsycj2cF2fhJZo1o7VbiWWmLN0Jvv5RvNIJBPAnquPrxRwKZm1UmuqdmXqJG1TjT3gkgFfXoi5TI9OxSYz68BQL6HkB3g++IAAkLrOGckLdpaNccRkkJsmkIuMnxx66EokCLERzgYxAnQjQRreh9eykl6B7wTnogngs1rnla5iRQpq1hD3xp4pNF+tILtUw1pSMWP1zawzwJNmHd1cT0B2dW2K2dAzHl/x/gKB9uHrnc4pMD8/r7ZhxnHl2Leufh5dSwtaJ7hwybm1hNfxXTz3GiWTwR2pje0NzYkj5Y+cPEo0VJJkxvK8kNbHiQSLJwjginZb/yM7bjH8Gj0slO/8TGChbDRtBeOYHVQFRYL/FTt4gib0Wa5Ppd0j84TrvsFvgT0+tIZWq4NJ2Dmm+B3uwFWWzhmNt591BKO+w45H6b+36oiXVlafBjF0slOqZHj4cGithE42g/sbWDr+QNglmZSpz3ltwYLqopIZgrsrF/Wqk/8gWmzYRDt7fyWJjCFDZ/WKMDMUns+dvuFAybs6jYfIT4sCOz8xc38iUZtmpQ19q+7D8FBQ+vJRfGLCw6PR4zB8rXJL2+e8T3VDaX1uyw76dgBcrm4SPKJeGKQUY= X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(376002)(39860400002)(396003)(136003)(346002)(82310400011)(186009)(1800799009)(451199024)(36840700001)(40470700004)(46966006)(1076003)(40460700003)(2616005)(5660300002)(4326008)(8676002)(8936002)(336012)(47076005)(426003)(36756003)(30864003)(83380400001)(44832011)(36860700001)(26005)(40480700001)(82740400003)(356005)(6666004)(81166007)(70586007)(70206006)(54906003)(6916009)(316002)(478600001)(966005)(41300700001)(2906002)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:34:56.0648 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: edd749fb-a2f9-434f-2077-08dba4d0d08c 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044FD.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4413 Received-SPF: softfail client-ip=2a01:111:f400:7e88::603; envelope-from=francisco.iglesias@amd.com; helo=NAM10-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902157167100005 Content-Type: text/plain; charset="utf-8" Introduce a model of the software programming interface (CFU_APB) of Xilinx Versal's Configuration Frame Unit. Signed-off-by: Francisco Iglesias Reviewed-by: Peter Maydell --- MAINTAINERS | 2 + hw/misc/meson.build | 1 + hw/misc/xlnx-versal-cfu.c | 380 ++++++++++++++++++++++++++++++ include/hw/misc/xlnx-versal-cfu.h | 231 ++++++++++++++++++ 4 files changed, 614 insertions(+) create mode 100644 hw/misc/xlnx-versal-cfu.c create mode 100644 include/hw/misc/xlnx-versal-cfu.h diff --git a/MAINTAINERS b/MAINTAINERS index e0cd365462..847b997d73 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1039,6 +1039,8 @@ M: Francisco Iglesias S: Maintained F: hw/misc/xlnx-cfi-if.c F: include/hw/misc/xlnx-cfi-if.h +F: hw/misc/xlnx-versal-cfu.c +F: include/hw/misc/xlnx-versal-cfu.h =20 STM32F100 M: Alexandre Iooss diff --git a/hw/misc/meson.build b/hw/misc/meson.build index 0c562f5e3e..d95cc3fd87 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -97,6 +97,7 @@ specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: file= s('xlnx-versal-crl.c')) system_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( 'xlnx-versal-xramc.c', 'xlnx-versal-pmc-iou-slcr.c', + 'xlnx-versal-cfu.c', 'xlnx-cfi-if.c', )) system_ss.add(when: 'CONFIG_STM32F2XX_SYSCFG', if_true: files('stm32f2xx_s= yscfg.c')) diff --git a/hw/misc/xlnx-versal-cfu.c b/hw/misc/xlnx-versal-cfu.c new file mode 100644 index 0000000000..b2dc6ab211 --- /dev/null +++ b/hw/misc/xlnx-versal-cfu.c @@ -0,0 +1,380 @@ +/* + * QEMU model of the CFU Configuration Unit. + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * Written by Edgar E. Iglesias , + * Sai Pavan Boddu , + * Francisco Iglesias + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "hw/register.h" +#include "hw/irq.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qemu/units.h" +#include "migration/vmstate.h" +#include "hw/qdev-properties.h" +#include "hw/qdev-properties-system.h" +#include "hw/misc/xlnx-versal-cfu.h" + +#ifndef XLNX_VERSAL_CFU_APB_ERR_DEBUG +#define XLNX_VERSAL_CFU_APB_ERR_DEBUG 0 +#endif + +#define KEYHOLE_STREAM_4K (4 * KiB) +#define KEYHOLE_STREAM_256K (256 * KiB) +#define CFRAME_BROADCAST_ROW 0x1F + +bool update_wfifo(hwaddr addr, uint64_t value, + uint32_t *wfifo, uint32_t *wfifo_ret) +{ + unsigned int idx =3D extract32(addr, 2, 2); + + wfifo[idx] =3D value; + + if (idx =3D=3D 3) { + memcpy(wfifo_ret, wfifo, WFIFO_SZ * sizeof(uint32_t)); + memset(wfifo, 0, WFIFO_SZ * sizeof(uint32_t)); + return true; + } + + return false; +} + +static void cfu_imr_update_irq(XlnxVersalCFUAPB *s) +{ + bool pending =3D s->regs[R_CFU_ISR] & ~s->regs[R_CFU_IMR]; + qemu_set_irq(s->irq_cfu_imr, pending); +} + +static void cfu_isr_postw(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(reg->opaque); + cfu_imr_update_irq(s); +} + +static uint64_t cfu_ier_prew(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(reg->opaque); + uint32_t val =3D val64; + + s->regs[R_CFU_IMR] &=3D ~val; + cfu_imr_update_irq(s); + return 0; +} + +static uint64_t cfu_idr_prew(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(reg->opaque); + uint32_t val =3D val64; + + s->regs[R_CFU_IMR] |=3D val; + cfu_imr_update_irq(s); + return 0; +} + +static uint64_t cfu_itr_prew(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(reg->opaque); + uint32_t val =3D val64; + + s->regs[R_CFU_ISR] |=3D val; + cfu_imr_update_irq(s); + return 0; +} + +static void cfu_fgcr_postw(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(reg->opaque); + uint32_t val =3D (uint32_t)val64; + + /* Do a scan. It always looks good. */ + if (FIELD_EX32(val, CFU_FGCR, SC_HBC_TRIGGER)) { + ARRAY_FIELD_DP32(s->regs, CFU_STATUS, SCAN_CLEAR_PASS, 1); + ARRAY_FIELD_DP32(s->regs, CFU_STATUS, SCAN_CLEAR_DONE, 1); + } +} + +static const RegisterAccessInfo cfu_apb_regs_info[] =3D { + { .name =3D "CFU_ISR", .addr =3D A_CFU_ISR, + .rsvd =3D 0xfffffc00, + .w1c =3D 0x3ff, + .post_write =3D cfu_isr_postw, + },{ .name =3D "CFU_IMR", .addr =3D A_CFU_IMR, + .reset =3D 0x3ff, + .rsvd =3D 0xfffffc00, + .ro =3D 0x3ff, + },{ .name =3D "CFU_IER", .addr =3D A_CFU_IER, + .rsvd =3D 0xfffffc00, + .pre_write =3D cfu_ier_prew, + },{ .name =3D "CFU_IDR", .addr =3D A_CFU_IDR, + .rsvd =3D 0xfffffc00, + .pre_write =3D cfu_idr_prew, + },{ .name =3D "CFU_ITR", .addr =3D A_CFU_ITR, + .rsvd =3D 0xfffffc00, + .pre_write =3D cfu_itr_prew, + },{ .name =3D "CFU_PROTECT", .addr =3D A_CFU_PROTECT, + .reset =3D 0x1, + },{ .name =3D "CFU_FGCR", .addr =3D A_CFU_FGCR, + .rsvd =3D 0xffff8000, + .post_write =3D cfu_fgcr_postw, + },{ .name =3D "CFU_CTL", .addr =3D A_CFU_CTL, + .rsvd =3D 0xffff0000, + },{ .name =3D "CFU_CRAM_RW", .addr =3D A_CFU_CRAM_RW, + .reset =3D 0x401f7d9, + .rsvd =3D 0xf8000000, + },{ .name =3D "CFU_MASK", .addr =3D A_CFU_MASK, + },{ .name =3D "CFU_CRC_EXPECT", .addr =3D A_CFU_CRC_EXPECT, + },{ .name =3D "CFU_CFRAME_LEFT_T0", .addr =3D A_CFU_CFRAME_LEFT_T0, + .rsvd =3D 0xfff00000, + },{ .name =3D "CFU_CFRAME_LEFT_T1", .addr =3D A_CFU_CFRAME_LEFT_T1, + .rsvd =3D 0xfff00000, + },{ .name =3D "CFU_CFRAME_LEFT_T2", .addr =3D A_CFU_CFRAME_LEFT_T2, + .rsvd =3D 0xfff00000, + },{ .name =3D "CFU_ROW_RANGE", .addr =3D A_CFU_ROW_RANGE, + .rsvd =3D 0xffffffc0, + .ro =3D 0x3f, + },{ .name =3D "CFU_STATUS", .addr =3D A_CFU_STATUS, + .rsvd =3D 0x80000000, + .ro =3D 0x7fffffff, + },{ .name =3D "CFU_INTERNAL_STATUS", .addr =3D A_CFU_INTERNAL_STATUS, + .rsvd =3D 0xff800000, + .ro =3D 0x7fffff, + },{ .name =3D "CFU_QWORD_CNT", .addr =3D A_CFU_QWORD_CNT, + .ro =3D 0xffffffff, + },{ .name =3D "CFU_CRC_LIVE", .addr =3D A_CFU_CRC_LIVE, + .ro =3D 0xffffffff, + },{ .name =3D "CFU_PENDING_READ_CNT", .addr =3D A_CFU_PENDING_READ_CN= T, + .rsvd =3D 0xfe000000, + .ro =3D 0x1ffffff, + },{ .name =3D "CFU_FDRI_CNT", .addr =3D A_CFU_FDRI_CNT, + .ro =3D 0xffffffff, + },{ .name =3D "CFU_ECO1", .addr =3D A_CFU_ECO1, + },{ .name =3D "CFU_ECO2", .addr =3D A_CFU_ECO2, + } +}; + +static void cfu_apb_reset(DeviceState *dev) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(dev); + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(s->regs_info); ++i) { + register_reset(&s->regs_info[i]); + } + memset(s->wfifo, 0, WFIFO_SZ * sizeof(uint32_t)); + + s->regs[R_CFU_STATUS] |=3D R_CFU_STATUS_HC_COMPLETE_MASK; + cfu_imr_update_irq(s); +} + +static const MemoryRegionOps cfu_apb_ops =3D { + .read =3D register_read_memory, + .write =3D register_write_memory, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static void cfu_transfer_cfi_packet(XlnxVersalCFUAPB *s, uint8_t row_addr, + XlnxCfiPacket *pkt) +{ + if (row_addr =3D=3D CFRAME_BROADCAST_ROW) { + for (int i =3D 0; i < ARRAY_SIZE(s->cfg.cframe); i++) { + if (s->cfg.cframe[i]) { + xlnx_cfi_transfer_packet(s->cfg.cframe[i], pkt); + } + } + } else { + assert(row_addr < ARRAY_SIZE(s->cfg.cframe)); + + if (s->cfg.cframe[row_addr]) { + xlnx_cfi_transfer_packet(s->cfg.cframe[row_addr], pkt); + } + } +} + +static uint64_t cfu_stream_read(void *opaque, hwaddr addr, unsigned size) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unsupported read from addr=3D%" + HWADDR_PRIx "\n", __func__, addr); + return 0; +} + +static void cfu_stream_write(void *opaque, hwaddr addr, uint64_t value, + unsigned size) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(opaque); + uint32_t wfifo[WFIFO_SZ]; + + if (update_wfifo(addr, value, s->wfifo, wfifo)) { + uint8_t packet_type, row_addr, reg_addr; + + packet_type =3D extract32(wfifo[0], 24, 8); + row_addr =3D extract32(wfifo[0], 16, 5); + reg_addr =3D extract32(wfifo[0], 8, 6); + + /* Compressed bitstreams are not supported yet. */ + if (ARRAY_FIELD_EX32(s->regs, CFU_CTL, DECOMPRESS) =3D=3D 0) { + if (s->regs[R_CFU_FDRI_CNT]) { + XlnxCfiPacket pkt =3D { + .reg_addr =3D CFRAME_FDRI, + .data[0] =3D wfifo[0], + .data[1] =3D wfifo[1], + .data[2] =3D wfifo[2], + .data[3] =3D wfifo[3] + }; + + cfu_transfer_cfi_packet(s, s->fdri_row_addr, &pkt); + + s->regs[R_CFU_FDRI_CNT]--; + + } else if (packet_type =3D=3D PACKET_TYPE_CFU && + reg_addr =3D=3D CFRAME_FDRI) { + + /* Load R_CFU_FDRI_CNT, must be multiple of 25 */ + s->regs[R_CFU_FDRI_CNT] =3D wfifo[1]; + + /* Store target row_addr */ + s->fdri_row_addr =3D row_addr; + + if (wfifo[1] % 25 !=3D 0) { + qemu_log_mask(LOG_GUEST_ERROR, + "CFU FDRI_CNT is not loaded with " + "a multiple of 25 value\n"); + } + + } else if (packet_type =3D=3D PACKET_TYPE_CFRAME) { + XlnxCfiPacket pkt =3D { + .reg_addr =3D reg_addr, + .data[0] =3D wfifo[1], + .data[1] =3D wfifo[2], + .data[2] =3D wfifo[3], + }; + cfu_transfer_cfi_packet(s, row_addr, &pkt); + } + } + } +} + +static const MemoryRegionOps cfu_stream_ops =3D { + .read =3D cfu_stream_read, + .write =3D cfu_stream_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 8, + }, +}; + +static void cfu_apb_init(Object *obj) +{ + XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + RegisterInfoArray *reg_array; + unsigned int i; + char *name; + + memory_region_init(&s->iomem, obj, TYPE_XLNX_VERSAL_CFU_APB, R_MAX * 4= ); + reg_array =3D + register_init_block32(DEVICE(obj), cfu_apb_regs_info, + ARRAY_SIZE(cfu_apb_regs_info), + s->regs_info, s->regs, + &cfu_apb_ops, + XLNX_VERSAL_CFU_APB_ERR_DEBUG, + R_MAX * 4); + memory_region_add_subregion(&s->iomem, + 0x0, + ®_array->mem); + sysbus_init_mmio(sbd, &s->iomem); + for (i =3D 0; i < NUM_STREAM; i++) { + name =3D g_strdup_printf(TYPE_XLNX_VERSAL_CFU_APB "-stream%d", i); + memory_region_init_io(&s->iomem_stream[i], obj, &cfu_stream_ops, s, + name, i =3D=3D 0 ? KEYHOLE_STREAM_4K : + KEYHOLE_STREAM_256K); + sysbus_init_mmio(sbd, &s->iomem_stream[i]); + g_free(name); + } + sysbus_init_irq(sbd, &s->irq_cfu_imr); +} + +static Property cfu_props[] =3D { + DEFINE_PROP_LINK("cframe0", XlnxVersalCFUAPB, cfg.cframe[0], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe1", XlnxVersalCFUAPB, cfg.cframe[1], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe2", XlnxVersalCFUAPB, cfg.cframe[2], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe3", XlnxVersalCFUAPB, cfg.cframe[3], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe4", XlnxVersalCFUAPB, cfg.cframe[4], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe5", XlnxVersalCFUAPB, cfg.cframe[5], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe6", XlnxVersalCFUAPB, cfg.cframe[6], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe7", XlnxVersalCFUAPB, cfg.cframe[7], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe8", XlnxVersalCFUAPB, cfg.cframe[8], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe9", XlnxVersalCFUAPB, cfg.cframe[9], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe10", XlnxVersalCFUAPB, cfg.cframe[10], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe11", XlnxVersalCFUAPB, cfg.cframe[11], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe12", XlnxVersalCFUAPB, cfg.cframe[12], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe13", XlnxVersalCFUAPB, cfg.cframe[13], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe14", XlnxVersalCFUAPB, cfg.cframe[14], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_END_OF_LIST(), +}; + +static const VMStateDescription vmstate_cfu_apb =3D { + .name =3D TYPE_XLNX_VERSAL_CFU_APB, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32_ARRAY(wfifo, XlnxVersalCFUAPB, 4), + VMSTATE_UINT32_ARRAY(regs, XlnxVersalCFUAPB, R_MAX), + VMSTATE_UINT8(fdri_row_addr, XlnxVersalCFUAPB), + VMSTATE_END_OF_LIST(), + } +}; + +static void cfu_apb_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + + dc->reset =3D cfu_apb_reset; + dc->vmsd =3D &vmstate_cfu_apb; + device_class_set_props(dc, cfu_props); +} + +static const TypeInfo cfu_apb_info =3D { + .name =3D TYPE_XLNX_VERSAL_CFU_APB, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(XlnxVersalCFUAPB), + .class_init =3D cfu_apb_class_init, + .instance_init =3D cfu_apb_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_XLNX_CFI_IF }, + { } + } +}; + +static void cfu_apb_register_types(void) +{ + type_register_static(&cfu_apb_info); +} + +type_init(cfu_apb_register_types) diff --git a/include/hw/misc/xlnx-versal-cfu.h b/include/hw/misc/xlnx-versa= l-cfu.h new file mode 100644 index 0000000000..62d10caf27 --- /dev/null +++ b/include/hw/misc/xlnx-versal-cfu.h @@ -0,0 +1,231 @@ +/* + * QEMU model of the CFU Configuration Unit. + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * Written by Francisco Iglesias + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * References: + * [1] Versal ACAP Technical Reference Manual, + * https://www.xilinx.com/support/documentation/architecture-manuals/a= m011-versal-acap-trm.pdf + * + * [2] Versal ACAP Register Reference, + * https://www.xilinx.com/htmldocs/registers/am012/am012-versal-regist= er-reference.html + */ +#ifndef HW_MISC_XLNX_VERSAL_CFU_APB_H +#define HW_MISC_XLNX_VERSAL_CFU_APB_H + +#include "hw/sysbus.h" +#include "hw/register.h" +#include "hw/misc/xlnx-cfi-if.h" + +#define TYPE_XLNX_VERSAL_CFU_APB "xlnx,versal-cfu-apb" +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFUAPB, XLNX_VERSAL_CFU_APB) + +REG32(CFU_ISR, 0x0) + FIELD(CFU_ISR, USR_GTS_EVENT, 9, 1) + FIELD(CFU_ISR, USR_GSR_EVENT, 8, 1) + FIELD(CFU_ISR, SLVERR, 7, 1) + FIELD(CFU_ISR, DECOMP_ERROR, 6, 1) + FIELD(CFU_ISR, BAD_CFI_PACKET, 5, 1) + FIELD(CFU_ISR, AXI_ALIGN_ERROR, 4, 1) + FIELD(CFU_ISR, CFI_ROW_ERROR, 3, 1) + FIELD(CFU_ISR, CRC32_ERROR, 2, 1) + FIELD(CFU_ISR, CRC8_ERROR, 1, 1) + FIELD(CFU_ISR, SEU_ENDOFCALIB, 0, 1) +REG32(CFU_IMR, 0x4) + FIELD(CFU_IMR, USR_GTS_EVENT, 9, 1) + FIELD(CFU_IMR, USR_GSR_EVENT, 8, 1) + FIELD(CFU_IMR, SLVERR, 7, 1) + FIELD(CFU_IMR, DECOMP_ERROR, 6, 1) + FIELD(CFU_IMR, BAD_CFI_PACKET, 5, 1) + FIELD(CFU_IMR, AXI_ALIGN_ERROR, 4, 1) + FIELD(CFU_IMR, CFI_ROW_ERROR, 3, 1) + FIELD(CFU_IMR, CRC32_ERROR, 2, 1) + FIELD(CFU_IMR, CRC8_ERROR, 1, 1) + FIELD(CFU_IMR, SEU_ENDOFCALIB, 0, 1) +REG32(CFU_IER, 0x8) + FIELD(CFU_IER, USR_GTS_EVENT, 9, 1) + FIELD(CFU_IER, USR_GSR_EVENT, 8, 1) + FIELD(CFU_IER, SLVERR, 7, 1) + FIELD(CFU_IER, DECOMP_ERROR, 6, 1) + FIELD(CFU_IER, BAD_CFI_PACKET, 5, 1) + FIELD(CFU_IER, AXI_ALIGN_ERROR, 4, 1) + FIELD(CFU_IER, CFI_ROW_ERROR, 3, 1) + FIELD(CFU_IER, CRC32_ERROR, 2, 1) + FIELD(CFU_IER, CRC8_ERROR, 1, 1) + FIELD(CFU_IER, SEU_ENDOFCALIB, 0, 1) +REG32(CFU_IDR, 0xc) + FIELD(CFU_IDR, USR_GTS_EVENT, 9, 1) + FIELD(CFU_IDR, USR_GSR_EVENT, 8, 1) + FIELD(CFU_IDR, SLVERR, 7, 1) + FIELD(CFU_IDR, DECOMP_ERROR, 6, 1) + FIELD(CFU_IDR, BAD_CFI_PACKET, 5, 1) + FIELD(CFU_IDR, AXI_ALIGN_ERROR, 4, 1) + FIELD(CFU_IDR, CFI_ROW_ERROR, 3, 1) + FIELD(CFU_IDR, CRC32_ERROR, 2, 1) + FIELD(CFU_IDR, CRC8_ERROR, 1, 1) + FIELD(CFU_IDR, SEU_ENDOFCALIB, 0, 1) +REG32(CFU_ITR, 0x10) + FIELD(CFU_ITR, USR_GTS_EVENT, 9, 1) + FIELD(CFU_ITR, USR_GSR_EVENT, 8, 1) + FIELD(CFU_ITR, SLVERR, 7, 1) + FIELD(CFU_ITR, DECOMP_ERROR, 6, 1) + FIELD(CFU_ITR, BAD_CFI_PACKET, 5, 1) + FIELD(CFU_ITR, AXI_ALIGN_ERROR, 4, 1) + FIELD(CFU_ITR, CFI_ROW_ERROR, 3, 1) + FIELD(CFU_ITR, CRC32_ERROR, 2, 1) + FIELD(CFU_ITR, CRC8_ERROR, 1, 1) + FIELD(CFU_ITR, SEU_ENDOFCALIB, 0, 1) +REG32(CFU_PROTECT, 0x14) + FIELD(CFU_PROTECT, ACTIVE, 0, 1) +REG32(CFU_FGCR, 0x18) + FIELD(CFU_FGCR, GCLK_CAL, 14, 1) + FIELD(CFU_FGCR, SC_HBC_TRIGGER, 13, 1) + FIELD(CFU_FGCR, GLOW, 12, 1) + FIELD(CFU_FGCR, GPWRDWN, 11, 1) + FIELD(CFU_FGCR, GCAP, 10, 1) + FIELD(CFU_FGCR, GSCWE, 9, 1) + FIELD(CFU_FGCR, GHIGH_B, 8, 1) + FIELD(CFU_FGCR, GMC_B, 7, 1) + FIELD(CFU_FGCR, GWE, 6, 1) + FIELD(CFU_FGCR, GRESTORE, 5, 1) + FIELD(CFU_FGCR, GTS_CFG_B, 4, 1) + FIELD(CFU_FGCR, GLUTMASK, 3, 1) + FIELD(CFU_FGCR, EN_GLOBS_B, 2, 1) + FIELD(CFU_FGCR, EOS, 1, 1) + FIELD(CFU_FGCR, INIT_COMPLETE, 0, 1) +REG32(CFU_CTL, 0x1c) + FIELD(CFU_CTL, GSR_GSC, 15, 1) + FIELD(CFU_CTL, SLVERR_EN, 14, 1) + FIELD(CFU_CTL, CRC32_RESET, 13, 1) + FIELD(CFU_CTL, AXI_ERROR_EN, 12, 1) + FIELD(CFU_CTL, FLUSH_AXI, 11, 1) + FIELD(CFU_CTL, SSI_PER_SLR_PR, 10, 1) + FIELD(CFU_CTL, GCAP_CLK_EN, 9, 1) + FIELD(CFU_CTL, STATUS_SYNC_DISABLE, 8, 1) + FIELD(CFU_CTL, IGNORE_CFI_ERROR, 7, 1) + FIELD(CFU_CTL, CFRAME_DISABLE, 6, 1) + FIELD(CFU_CTL, QWORD_CNT_RESET, 5, 1) + FIELD(CFU_CTL, CRC8_DISABLE, 4, 1) + FIELD(CFU_CTL, CRC32_CHECK, 3, 1) + FIELD(CFU_CTL, DECOMPRESS, 2, 1) + FIELD(CFU_CTL, SEU_GO, 1, 1) + FIELD(CFU_CTL, CFI_LOCAL_RESET, 0, 1) +REG32(CFU_CRAM_RW, 0x20) + FIELD(CFU_CRAM_RW, RFIFO_AFULL_DEPTH, 18, 9) + FIELD(CFU_CRAM_RW, RD_WAVE_CNT_LEFT, 12, 6) + FIELD(CFU_CRAM_RW, RD_WAVE_CNT, 6, 6) + FIELD(CFU_CRAM_RW, WR_WAVE_CNT, 0, 6) +REG32(CFU_MASK, 0x28) +REG32(CFU_CRC_EXPECT, 0x2c) +REG32(CFU_CFRAME_LEFT_T0, 0x60) + FIELD(CFU_CFRAME_LEFT_T0, NUM, 0, 20) +REG32(CFU_CFRAME_LEFT_T1, 0x64) + FIELD(CFU_CFRAME_LEFT_T1, NUM, 0, 20) +REG32(CFU_CFRAME_LEFT_T2, 0x68) + FIELD(CFU_CFRAME_LEFT_T2, NUM, 0, 20) +REG32(CFU_ROW_RANGE, 0x6c) + FIELD(CFU_ROW_RANGE, HALF_FSR, 5, 1) + FIELD(CFU_ROW_RANGE, NUM, 0, 5) +REG32(CFU_STATUS, 0x100) + FIELD(CFU_STATUS, SEU_WRITE_ERROR, 30, 1) + FIELD(CFU_STATUS, FRCNT_ERROR, 29, 1) + FIELD(CFU_STATUS, RSVD_ERROR, 28, 1) + FIELD(CFU_STATUS, FDRO_ERROR, 27, 1) + FIELD(CFU_STATUS, FDRI_ERROR, 26, 1) + FIELD(CFU_STATUS, FDRI_READ_ERROR, 25, 1) + FIELD(CFU_STATUS, READ_FDRI_ERROR, 24, 1) + FIELD(CFU_STATUS, READ_SFR_ERROR, 23, 1) + FIELD(CFU_STATUS, READ_STREAM_ERROR, 22, 1) + FIELD(CFU_STATUS, UNKNOWN_STREAM_PKT, 21, 1) + FIELD(CFU_STATUS, USR_GTS, 20, 1) + FIELD(CFU_STATUS, USR_GSR, 19, 1) + FIELD(CFU_STATUS, AXI_BAD_WSTRB, 18, 1) + FIELD(CFU_STATUS, AXI_BAD_AR_SIZE, 17, 1) + FIELD(CFU_STATUS, AXI_BAD_AW_SIZE, 16, 1) + FIELD(CFU_STATUS, AXI_BAD_ARADDR, 15, 1) + FIELD(CFU_STATUS, AXI_BAD_AWADDR, 14, 1) + FIELD(CFU_STATUS, SCAN_CLEAR_PASS, 13, 1) + FIELD(CFU_STATUS, HC_SEC_ERROR, 12, 1) + FIELD(CFU_STATUS, GHIGH_B_ISHIGH, 11, 1) + FIELD(CFU_STATUS, GHIGH_B_ISLOW, 10, 1) + FIELD(CFU_STATUS, GMC_B_ISHIGH, 9, 1) + FIELD(CFU_STATUS, GMC_B_ISLOW, 8, 1) + FIELD(CFU_STATUS, GPWRDWN_B_ISHIGH, 7, 1) + FIELD(CFU_STATUS, CFI_SEU_CRC_ERROR, 6, 1) + FIELD(CFU_STATUS, CFI_SEU_ECC_ERROR, 5, 1) + FIELD(CFU_STATUS, CFI_SEU_HEARTBEAT, 4, 1) + FIELD(CFU_STATUS, SCAN_CLEAR_DONE, 3, 1) + FIELD(CFU_STATUS, HC_COMPLETE, 2, 1) + FIELD(CFU_STATUS, CFI_CFRAME_BUSY, 1, 1) + FIELD(CFU_STATUS, CFU_STREAM_BUSY, 0, 1) +REG32(CFU_INTERNAL_STATUS, 0x104) + FIELD(CFU_INTERNAL_STATUS, SSI_EOS, 22, 1) + FIELD(CFU_INTERNAL_STATUS, SSI_GWE, 21, 1) + FIELD(CFU_INTERNAL_STATUS, RFIFO_EMPTY, 20, 1) + FIELD(CFU_INTERNAL_STATUS, RFIFO_FULL, 19, 1) + FIELD(CFU_INTERNAL_STATUS, SEL_SFR, 18, 1) + FIELD(CFU_INTERNAL_STATUS, STREAM_CFRAME, 17, 1) + FIELD(CFU_INTERNAL_STATUS, FDRI_PHASE, 16, 1) + FIELD(CFU_INTERNAL_STATUS, CFI_PIPE_EN, 15, 1) + FIELD(CFU_INTERNAL_STATUS, AWFIFO_DCNT, 10, 5) + FIELD(CFU_INTERNAL_STATUS, WFIFO_DCNT, 5, 5) + FIELD(CFU_INTERNAL_STATUS, REPAIR_BUSY, 4, 1) + FIELD(CFU_INTERNAL_STATUS, TRIMU_BUSY, 3, 1) + FIELD(CFU_INTERNAL_STATUS, TRIMB_BUSY, 2, 1) + FIELD(CFU_INTERNAL_STATUS, HCLEANR_BUSY, 1, 1) + FIELD(CFU_INTERNAL_STATUS, HCLEAN_BUSY, 0, 1) +REG32(CFU_QWORD_CNT, 0x108) +REG32(CFU_CRC_LIVE, 0x10c) +REG32(CFU_PENDING_READ_CNT, 0x110) + FIELD(CFU_PENDING_READ_CNT, NUM, 0, 25) +REG32(CFU_FDRI_CNT, 0x114) +REG32(CFU_ECO1, 0x118) +REG32(CFU_ECO2, 0x11c) + +#define R_MAX (R_CFU_ECO2 + 1) + +#define NUM_STREAM 2 +#define WFIFO_SZ 4 + +struct XlnxVersalCFUAPB { + SysBusDevice parent_obj; + MemoryRegion iomem; + MemoryRegion iomem_stream[NUM_STREAM]; + qemu_irq irq_cfu_imr; + + /* 128-bit wfifo. */ + uint32_t wfifo[WFIFO_SZ]; + + uint32_t regs[R_MAX]; + RegisterInfo regs_info[R_MAX]; + + uint8_t fdri_row_addr; + + struct { + XlnxCfiIf *cframe[15]; + } cfg; +}; + +/** + * This is a helper function for updating a CFI data write fifo, an array = of 4 + * uint32_t and 128 bits of data that are allowed to be written through 4 + * sequential 32 bit accesses. After the last index has been written into = the + * write fifo (wfifo), the data is copied to and returned in a secondary f= ifo + * provided to the function (wfifo_ret), and the write fifo is cleared + * (zeroized). + * + * @addr: the address used when calculating the wfifo array index to update + * @value: the value to write into the wfifo array + * @wfifo: the wfifo to update + * @wfifo_out: will return the wfifo data when all 128 bits have been writ= ten + * + * @return: true if all 128 bits have been updated. + */ +bool update_wfifo(hwaddr addr, uint64_t value, + uint32_t *wfifo, uint32_t *wfifo_ret); + +#endif --=20 2.34.1 From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902171; cv=pass; d=zohomail.com; s=zohoarc; b=V8OzeQ811CKd2lPXTFOO3HQI0UVcffhI9c5ES+wG+Kc9JBG7PMMJJXfG/8XnIIZuG59IqldIQuS2U8g+525A+dY/Wz3cS7ZWo3ARrrT7YzB9AHHY574FdPxTkLc9e7YoNLEQ2S/xaWgn1z98ryiGAflxwaMmia8GbAXO+roXgTI= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902171; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dP9DJgnfmyBqIQPky8kPymTuxPZxwsqnJY/SEnS5AJY=; b=MTgFy08zLVkFiIKk+4nKG5fYBS4fzXQp15Vmyf8F9OezcMqqmMdHgeGVvbaPtc0/0uUJqLiImPTuqqTUQFIoC8Mrdk7N4oO/9GRCfz2sXcd/1QvfRV3xKkAshLS2cUKYrjkuMH6NheOJJe19EotT7HH7p3cLi+xO2PgwPldLNjo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169290217189033.126642525422085; Thu, 24 Aug 2023 11:36:11 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAm-0006yL-A6; Thu, 24 Aug 2023 14:35:12 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAk-0006xt-G2 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:10 -0400 Received: from mail-dm6nam11on2060b.outbound.protection.outlook.com ([2a01:111:f400:7eaa::60b] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAg-00077x-EG for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:10 -0400 Received: from DM6PR18CA0003.namprd18.prod.outlook.com (2603:10b6:5:15b::16) by PH8PR12MB7135.namprd12.prod.outlook.com (2603:10b6:510:22c::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.24; Thu, 24 Aug 2023 18:34:58 +0000 Received: from CO1PEPF000044F8.namprd21.prod.outlook.com (2603:10b6:5:15b:cafe::33) by DM6PR18CA0003.outlook.office365.com (2603:10b6:5:15b::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.26 via Frontend Transport; Thu, 24 Aug 2023 18:34:58 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.2 via Frontend Transport; Thu, 24 Aug 2023 18:34:58 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 13:34:57 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:34:55 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=oVuZzOPdgTlYZUBc4x1KukWz+JAohwLa+N8EpP4RL+x52DxvladigdBOAOzNbLugiESdL5uCIRr+iGjIsMdoM3lpLywe+h3uovbl6/H/lH6o0kDCpekRWSmMPNmmnylELU2juUnN6sTPKuluogzWeE84hNhBX2EMycKJWuS0WiF7HJ/6YrdRagiVK+3HLXwj9i+Z5nsqpQVVk4dI7IEHTGQMZViyzDw/tKap5RQ/hgtOjZB5MIZDwwT2/0F+0bk6AjnQdHQqIkyEWvAt7HStJAOlqyodN7EWLEvFxclFY9g1OZtXvrngCPcBcLrqXTHUd2TRbhZGV/BQVDJ0A7FCRQ== 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=dP9DJgnfmyBqIQPky8kPymTuxPZxwsqnJY/SEnS5AJY=; b=VPg7fswXc0zqHscVlyx5/hF/EvXnu9ZBGU9sU67yEanKXjp0kVgDypK4Q0I8I6gIBTaYbbiB1YxbdjmOsyeJ9JM8InqIYD9/9u+BtvN54NKgxly+0yckkDhj4L00kvZMFLud2fatxGm80NMmy2VvWKgpPglvF6ad36Q0P5FaE8heZzWu647lckGaouYt615weAbPAW0ZESeaKhX9xkIEWtU4BtrGhD5xcT4p2YAzKgN5/H+DmnxVhMeEGOI4feffWp7Pm4uAeevmiBbfFYrvzd/NRWbglqLJaztVdAiTcVH0LvoibADlrp5zrSZxQtMPdjRSaf8D8Byv5/kwpo5qLQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=dP9DJgnfmyBqIQPky8kPymTuxPZxwsqnJY/SEnS5AJY=; b=CPV5OQyqVVu6Bk1vTRJ29QSCElrDvdPzRaBL2ovlWkZWTWsQqDPvHT/F50MGbaVOoIkn1wQD+85sGHVigu2BFMpwptkBCsXflrA4K9a4GMpk9R2OptJpiaW0ONY5BO0Avg8Rln6jAZlD7pb20hy/UU0fS2zfy8OoamDEduDFrno= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB03.amd.com; pr=C From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 3/8] hw/misc/xlnx-versal-cfu: Introduce a model of Xilinx Versal CFU_FDRO Date: Thu, 24 Aug 2023 20:34:43 +0200 Message-ID: <20230824183448.151738-4-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F8:EE_|PH8PR12MB7135:EE_ X-MS-Office365-Filtering-Correlation-Id: 9a82ae49-4876-4ff5-2835-08dba4d0d1cf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S4WmNxZYQN/jwEqjuOESgx1gWre3avY/F7LtNwHapWrpPFRFD/0ES9Kbskhgen47/1CBFAMpqQEnPZjVH0pzJUVAw5zEqctJZQnN0KpJ93LmSyr3olNo5YwMeiNSr1l0t45PrP5ukHCOGWJ7iKVcnoHuFJE2wQA0+LaazNHCYkhfKIylgQ9/oyiiaoqOSZkussyOAtDY1RYpbdQJbIhu6IkLqL0Uy4W2/tG4AACyfel8u/CqgOPTZOATH7F0UmJM1HrQ6aPHc2o22YKsT++8/eXkY1bVg7Wl2JGyTC2aaBHlGwO4/yyJVs0uSxpBYAdFeIvy+MguV8Pd+2zHTXASMD60hPNixHju1j08/XRy6PKbe1J/hZ17KEhjYHD3kfvUwL+8nwGef3iOp8osa+dha3c58ZPAKG5ZqD/D5YhX+8laQ2Z9fQeopCjSD24hvumy9dZjyAgz033r+r7WNqHsoiFUfVq8KuhQFmia5QAnRI2RwaIxWLICIbaIwcJvWaamPCeh33/GH3rI62R3UBqw4two/FnTYDr84vwFw5zlesPaaiNF22OKVCNuoJXxcgQMwA0AHaYRDkcJAconzSY1jW40OR4f4ceokuK+iRuFGxqrJLAOhQPAGS7AAnovhdbXLg5+FNeVWf4oM24bfZCPO++EtVbRFRZi2vC7GhdsfKzUuUU9/9Xi7G+a6yVV0cWFDxLVdW72j7wuctWwnIwePcoUtGlhi2czvKJ9X1If9yHBvqlcDRd4Ou3vNAQWpV6iT8Eoh4XYZFbVKff8WyYMqg== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(39860400002)(136003)(396003)(376002)(346002)(82310400011)(1800799009)(186009)(451199024)(36840700001)(46966006)(40470700004)(336012)(40480700001)(2616005)(6916009)(54906003)(41300700001)(81166007)(70586007)(70206006)(6666004)(40460700003)(82740400003)(316002)(356005)(1076003)(26005)(8676002)(8936002)(5660300002)(36860700001)(4326008)(426003)(47076005)(2906002)(83380400001)(44832011)(86362001)(36756003)(478600001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:34:58.1505 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9a82ae49-4876-4ff5-2835-08dba4d0d1cf 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH8PR12MB7135 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::60b; envelope-from=francisco.iglesias@amd.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902172893100003 Content-Type: text/plain; charset="utf-8" Introduce a model of Xilinx Versal's Configuration Frame Unit's data out port (CFU_FDRO). Signed-off-by: Francisco Iglesias Reviewed-by: Peter Maydell --- hw/misc/xlnx-versal-cfu.c | 96 +++++++++++++++++++++++++++++++ include/hw/misc/xlnx-versal-cfu.h | 12 ++++ 2 files changed, 108 insertions(+) diff --git a/hw/misc/xlnx-versal-cfu.c b/hw/misc/xlnx-versal-cfu.c index b2dc6ab211..255c1bf4b8 100644 --- a/hw/misc/xlnx-versal-cfu.c +++ b/hw/misc/xlnx-versal-cfu.c @@ -264,6 +264,25 @@ static void cfu_stream_write(void *opaque, hwaddr addr= , uint64_t value, } } =20 +static uint64_t cfu_fdro_read(void *opaque, hwaddr addr, unsigned size) +{ + XlnxVersalCFUFDRO *s =3D XLNX_VERSAL_CFU_FDRO(opaque); + uint64_t ret =3D 0; + + if (!fifo32_is_empty(&s->fdro_data)) { + ret =3D fifo32_pop(&s->fdro_data); + } + + return ret; +} + +static void cfu_fdro_write(void *opaque, hwaddr addr, uint64_t value, + unsigned size) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unsupported write from addr=3D%" + HWADDR_PRIx "\n", __func__, addr); +} + static const MemoryRegionOps cfu_stream_ops =3D { .read =3D cfu_stream_read, .write =3D cfu_stream_write, @@ -274,6 +293,16 @@ static const MemoryRegionOps cfu_stream_ops =3D { }, }; =20 +static const MemoryRegionOps cfu_fdro_ops =3D { + .read =3D cfu_fdro_read, + .write =3D cfu_fdro_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + static void cfu_apb_init(Object *obj) { XlnxVersalCFUAPB *s =3D XLNX_VERSAL_CFU_APB(obj); @@ -305,6 +334,39 @@ static void cfu_apb_init(Object *obj) sysbus_init_irq(sbd, &s->irq_cfu_imr); } =20 +static void cfu_fdro_init(Object *obj) +{ + XlnxVersalCFUFDRO *s =3D XLNX_VERSAL_CFU_FDRO(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + memory_region_init_io(&s->iomem_fdro, obj, &cfu_fdro_ops, s, + TYPE_XLNX_VERSAL_CFU_FDRO, KEYHOLE_STREAM_4K); + sysbus_init_mmio(sbd, &s->iomem_fdro); + fifo32_create(&s->fdro_data, 8 * KiB / sizeof(uint32_t)); +} + +static void cfu_fdro_reset_enter(Object *obj, ResetType type) +{ + XlnxVersalCFUFDRO *s =3D XLNX_VERSAL_CFU_FDRO(obj); + + fifo32_reset(&s->fdro_data); +} + +static void cfu_fdro_cfi_transfer_packet(XlnxCfiIf *cfi_if, XlnxCfiPacket = *pkt) +{ + XlnxVersalCFUFDRO *s =3D XLNX_VERSAL_CFU_FDRO(cfi_if); + + if (fifo32_num_free(&s->fdro_data) >=3D ARRAY_SIZE(pkt->data)) { + for (int i =3D 0; i < ARRAY_SIZE(pkt->data); i++) { + fifo32_push(&s->fdro_data, pkt->data[i]); + } + } else { + /* It is a programming error to fill the fifo. */ + qemu_log_mask(LOG_GUEST_ERROR, + "CFU_FDRO: CFI data dropped due to full read fifo\n"= ); + } +} + static Property cfu_props[] =3D { DEFINE_PROP_LINK("cframe0", XlnxVersalCFUAPB, cfg.cframe[0], TYPE_XLNX_CFI_IF, XlnxCfiIf *), @@ -351,6 +413,16 @@ static const VMStateDescription vmstate_cfu_apb =3D { } }; =20 +static const VMStateDescription vmstate_cfu_fdro =3D { + .name =3D TYPE_XLNX_VERSAL_CFU_FDRO, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_FIFO32(fdro_data, XlnxVersalCFUFDRO), + VMSTATE_END_OF_LIST(), + } +}; + static void cfu_apb_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -360,6 +432,17 @@ static void cfu_apb_class_init(ObjectClass *klass, voi= d *data) device_class_set_props(dc, cfu_props); } =20 +static void cfu_fdro_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + XlnxCfiIfClass *xcic =3D XLNX_CFI_IF_CLASS(klass); + + dc->vmsd =3D &vmstate_cfu_fdro; + xcic->cfi_transfer_packet =3D cfu_fdro_cfi_transfer_packet; + rc->phases.enter =3D cfu_fdro_reset_enter; +} + static const TypeInfo cfu_apb_info =3D { .name =3D TYPE_XLNX_VERSAL_CFU_APB, .parent =3D TYPE_SYS_BUS_DEVICE, @@ -372,9 +455,22 @@ static const TypeInfo cfu_apb_info =3D { } }; =20 +static const TypeInfo cfu_fdro_info =3D { + .name =3D TYPE_XLNX_VERSAL_CFU_FDRO, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(XlnxVersalCFUFDRO), + .class_init =3D cfu_fdro_class_init, + .instance_init =3D cfu_fdro_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_XLNX_CFI_IF }, + { } + } +}; + static void cfu_apb_register_types(void) { type_register_static(&cfu_apb_info); + type_register_static(&cfu_fdro_info); } =20 type_init(cfu_apb_register_types) diff --git a/include/hw/misc/xlnx-versal-cfu.h b/include/hw/misc/xlnx-versa= l-cfu.h index 62d10caf27..73e9a21af4 100644 --- a/include/hw/misc/xlnx-versal-cfu.h +++ b/include/hw/misc/xlnx-versal-cfu.h @@ -20,10 +20,14 @@ #include "hw/sysbus.h" #include "hw/register.h" #include "hw/misc/xlnx-cfi-if.h" +#include "qemu/fifo32.h" =20 #define TYPE_XLNX_VERSAL_CFU_APB "xlnx,versal-cfu-apb" OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFUAPB, XLNX_VERSAL_CFU_APB) =20 +#define TYPE_XLNX_VERSAL_CFU_FDRO "xlnx,versal-cfu-fdro" +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFUFDRO, XLNX_VERSAL_CFU_FDRO) + REG32(CFU_ISR, 0x0) FIELD(CFU_ISR, USR_GTS_EVENT, 9, 1) FIELD(CFU_ISR, USR_GSR_EVENT, 8, 1) @@ -210,6 +214,14 @@ struct XlnxVersalCFUAPB { } cfg; }; =20 + +struct XlnxVersalCFUFDRO { + SysBusDevice parent_obj; + MemoryRegion iomem_fdro; + + Fifo32 fdro_data; +}; + /** * This is a helper function for updating a CFI data write fifo, an array = of 4 * uint32_t and 128 bits of data that are allowed to be written through 4 --=20 2.34.1 From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902154; cv=pass; d=zohomail.com; s=zohoarc; b=cbKk7lwiPexSZVzZ/ofyKen4L1TT+2oo4DJbOAgRlbWY4efi/JcxvfJOIW1E6Q6Rdd7uORKk07P4zg0rY4NkNWyAqf4KKg0guXnuRzlVtrNAnjMalOl6LOtjjZkAPrbrWKNOc5Zv4T9awYy9EkFwLqRWCu32ob49gp85iO3Wke4= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902154; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=L3K6zjYWsy6eN46xdaD2mGatwHnrAxG/IEIeslaDOLA=; b=WWrtJCONoFfTL6kfdRYO2YSXlOiw1dcn6Wwr0e7OQ7yno96XycUpnkm8hWG+E5JMwllT3O8KZ2xLoJp537TlmUaueYzdtNjdaGFxx9NSLnkwI6cGdjlE0almreom43wdSabZ0WvdfXb95wMmmWusgIL3wg4PU0bM7pAG1KmcDDk= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 169290215457629.152541936987063; Thu, 24 Aug 2023 11:35:54 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAt-000704-V7; Thu, 24 Aug 2023 14:35:19 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAm-0006yN-Vf for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:14 -0400 Received: from mail-dm6nam11on20622.outbound.protection.outlook.com ([2a01:111:f400:7eaa::622] helo=NAM11-DM6-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAk-0007CG-C0 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:12 -0400 Received: from DM6PR18CA0006.namprd18.prod.outlook.com (2603:10b6:5:15b::19) by CH3PR12MB9284.namprd12.prod.outlook.com (2603:10b6:610:1c7::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 18:35:03 +0000 Received: from CO1PEPF000044F8.namprd21.prod.outlook.com (2603:10b6:5:15b:cafe::d4) by DM6PR18CA0006.outlook.office365.com (2603:10b6:5:15b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 18:35:02 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F8.mail.protection.outlook.com (10.167.241.198) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.2 via Frontend Transport; Thu, 24 Aug 2023 18:35:02 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 13:34:59 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:34:57 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YOmCxkJKyDQSv2DsV2DHS27n4tTpPoTHMlgRf5TwGjUouY28vqfqmC8jPNAOqI2PXDlv6V2fN6U+ToUteA03XuOtOY9zFfCVR5gsAj3rxeju5Rk3Wf4yjM0yLoACSaLyX0eOxSAwIXmIRO+7XAmHy7GV6VnoJQWgMzdcmyFVwciwKm/m0rtgbePSkfVVGdVlNSvdQT5KFf8U6bVNgSTDqgfh50Q4JqDXZIA94U9LQqru2anH78ZzQp16qlIDoBQw8cgbwEKGvdC0mPGEZpCRnr0JYM7ccL5rVmD8+O1nV8S4fS+yyNkdR0EhWyErI0g2Ovoe2Axj6aX/lYOLPztsSg== 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=L3K6zjYWsy6eN46xdaD2mGatwHnrAxG/IEIeslaDOLA=; b=AshsuYmBQvxYU5XwlbR/jmxpXJVzealh7olxdDaIxyLFIIpzmiYR04PDN4Bj+JdGp3rp1ewuf9VA4hxlgqYg5cG90TM4fEKChlVWNEd8NjUEeRRIjk+fumeTr+r21k19GsKoH0GhCMPkfzBysgj4neTi7WIp4kVdFgDWV2BnH25MpnmlGWkpWSO8GKwwcNWxVLlbp2MwmzruFoNRrY4Weh6Bnw65HQNIJMx4iod+AXiVNSeTOgd1awVXL3lbYP6wZdc5+GJE3EOdIXMmBf/hf/6+Rx10y+AH3pYFmeRJuCqU53DwjmKjgIoCUrM7/FGhaJSJWM4olANG65N1APfhow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=L3K6zjYWsy6eN46xdaD2mGatwHnrAxG/IEIeslaDOLA=; b=NgkMGwCjvuV62U6AijqZ1fpWCwSQZ5pTRghV3CMS3laPrfp9rhT1dWkEUMP4Dl/hJ4ZUC9o+19jeHqXW5TcFu5/IDG191RKKcko73lvV9LwnHYEL/N9olvCgnTkGK1apb3GugsbI6/ooEpgPqb+q9yUOai4hX+NYNUQKODu2NI0= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB03.amd.com; pr=C From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 4/8] hw/misc/xlnx-versal-cfu: Introduce a model of Xilinx Versal's CFU_SFR Date: Thu, 24 Aug 2023 20:34:44 +0200 Message-ID: <20230824183448.151738-5-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F8:EE_|CH3PR12MB9284:EE_ X-MS-Office365-Filtering-Correlation-Id: 3d1545dc-870e-424d-2f8a-08dba4d0d480 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: dbf2gP3+SeJf1JnHRunbvRlFD1k3cAtBglgDdTuQVmRwhEN/WyN3SCtdQDGglS66YVZxxX4cQe8CqPV40GL3SbGSM7iEtN/4N1MkmyPJjBZSKEY4wJGaECsTtw4MWv3x7IweyaZN3Snu0KRMtafAMBDjsjSk2NmKj/wzSq/kJwtfkMu238a8/qFpB+dezcvzy60diRMQywOY3bBCFr6nnpCizD4FI4pV2WDnjaLWVYXMvuHxPu50XEv41UDbvtW70sb4XKsOCtLSnwZKWcUUbXAgFGSaQ5/+HcLXXz21XiIvpXlhxCWLjZgPRwn1ZSbAuacGt6mPK3oXkUafk0vNPcG96zJ0TPkxOR1U5Do+ilmNQsc+8fuxZ5h5C6JQp5JYssf2E4PlNHesJNmB45jlCNPLJNJIY5qQl6qw27UZGrde9iI8cliySk4kHQomQJHq8jnXdedQv/JK1ezwSaSgbgcl+LTeBQi5m/aQterxKpE7VOB739VAWWc2/61mAg9mUl0jy1MIaMCQz0Amr3OG4TWEHU/Niy3xLX5Ja1b9Mdznds+EXe5vrHZtFsxuoMYpnIWU3YOh2JtqCE74hf8vgp+57re3QyQHyeH6Y+Mj9anIjr2jNUVUgreiq3zaYpI6OevzzpTstNXiEM6goz2rducj1s2HVdKv7oJETxO1vw+lJ/WSYjvWzewlPbvirVjAwR88VQEnoJOZ0TVwXTJEUXWiy06HkYK3fneHDcpZJbYIQD561VokipBWqXPxf7GsyJRLrs3fOmtjDGRoYxCalw== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(136003)(346002)(376002)(396003)(39860400002)(451199024)(186009)(82310400011)(1800799009)(46966006)(40470700004)(36840700001)(54906003)(70206006)(70586007)(316002)(81166007)(40480700001)(6916009)(478600001)(26005)(36860700001)(44832011)(6666004)(356005)(82740400003)(41300700001)(86362001)(2906002)(8936002)(8676002)(4326008)(40460700003)(1076003)(2616005)(5660300002)(83380400001)(36756003)(336012)(426003)(47076005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:35:02.6661 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3d1545dc-870e-424d-2f8a-08dba4d0d480 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F8.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB9284 Received-SPF: softfail client-ip=2a01:111:f400:7eaa::622; envelope-from=francisco.iglesias@amd.com; helo=NAM11-DM6-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902156167100001 Content-Type: text/plain; charset="utf-8" Introduce a model of Xilinx Versal's Configuration Frame Unit's Single Frame Read port (CFU_SFR). Signed-off-by: Francisco Iglesias Reviewed-by: Peter Maydell --- hw/misc/xlnx-versal-cfu.c | 87 +++++++++++++++++++++++++++++++ include/hw/misc/xlnx-versal-cfu.h | 15 ++++++ 2 files changed, 102 insertions(+) diff --git a/hw/misc/xlnx-versal-cfu.c b/hw/misc/xlnx-versal-cfu.c index 255c1bf4b8..8e588ac1d8 100644 --- a/hw/misc/xlnx-versal-cfu.c +++ b/hw/misc/xlnx-versal-cfu.c @@ -264,6 +264,31 @@ static void cfu_stream_write(void *opaque, hwaddr addr= , uint64_t value, } } =20 +static uint64_t cfu_sfr_read(void *opaque, hwaddr addr, unsigned size) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unsupported read from addr=3D%" + HWADDR_PRIx "\n", __func__, addr); + return 0; +} + +static void cfu_sfr_write(void *opaque, hwaddr addr, uint64_t value, + unsigned size) +{ + XlnxVersalCFUSFR *s =3D XLNX_VERSAL_CFU_SFR(opaque); + uint32_t wfifo[WFIFO_SZ]; + + if (update_wfifo(addr, value, s->wfifo, wfifo)) { + uint8_t row_addr =3D extract32(wfifo[0], 23, 5); + uint32_t frame_addr =3D extract32(wfifo[0], 0, 23); + XlnxCfiPacket pkt =3D { .reg_addr =3D CFRAME_SFR, + .data[0] =3D frame_addr }; + + if (s->cfg.cfu) { + cfu_transfer_cfi_packet(s->cfg.cfu, row_addr, &pkt); + } + } +} + static uint64_t cfu_fdro_read(void *opaque, hwaddr addr, unsigned size) { XlnxVersalCFUFDRO *s =3D XLNX_VERSAL_CFU_FDRO(opaque); @@ -293,6 +318,16 @@ static const MemoryRegionOps cfu_stream_ops =3D { }, }; =20 +static const MemoryRegionOps cfu_sfr_ops =3D { + .read =3D cfu_sfr_read, + .write =3D cfu_sfr_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + static const MemoryRegionOps cfu_fdro_ops =3D { .read =3D cfu_fdro_read, .write =3D cfu_fdro_write, @@ -334,6 +369,23 @@ static void cfu_apb_init(Object *obj) sysbus_init_irq(sbd, &s->irq_cfu_imr); } =20 +static void cfu_sfr_init(Object *obj) +{ + XlnxVersalCFUSFR *s =3D XLNX_VERSAL_CFU_SFR(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + memory_region_init_io(&s->iomem_sfr, obj, &cfu_sfr_ops, s, + TYPE_XLNX_VERSAL_CFU_SFR, KEYHOLE_STREAM_4K); + sysbus_init_mmio(sbd, &s->iomem_sfr); +} + +static void cfu_sfr_reset_enter(Object *obj, ResetType type) +{ + XlnxVersalCFUSFR *s =3D XLNX_VERSAL_CFU_SFR(obj); + + memset(s->wfifo, 0, WFIFO_SZ * sizeof(uint32_t)); +} + static void cfu_fdro_init(Object *obj) { XlnxVersalCFUFDRO *s =3D XLNX_VERSAL_CFU_FDRO(obj); @@ -401,6 +453,12 @@ static Property cfu_props[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static Property cfu_sfr_props[] =3D { + DEFINE_PROP_LINK("cfu", XlnxVersalCFUSFR, cfg.cfu, + TYPE_XLNX_VERSAL_CFU_APB, XlnxVersalCFUAPB *), + DEFINE_PROP_END_OF_LIST(), +}; + static const VMStateDescription vmstate_cfu_apb =3D { .name =3D TYPE_XLNX_VERSAL_CFU_APB, .version_id =3D 1, @@ -423,6 +481,16 @@ static const VMStateDescription vmstate_cfu_fdro =3D { } }; =20 +static const VMStateDescription vmstate_cfu_sfr =3D { + .name =3D TYPE_XLNX_VERSAL_CFU_SFR, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32_ARRAY(wfifo, XlnxVersalCFUSFR, 4), + VMSTATE_END_OF_LIST(), + } +}; + static void cfu_apb_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -443,6 +511,16 @@ static void cfu_fdro_class_init(ObjectClass *klass, vo= id *data) rc->phases.enter =3D cfu_fdro_reset_enter; } =20 +static void cfu_sfr_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + device_class_set_props(dc, cfu_sfr_props); + dc->vmsd =3D &vmstate_cfu_sfr; + rc->phases.enter =3D cfu_sfr_reset_enter; +} + static const TypeInfo cfu_apb_info =3D { .name =3D TYPE_XLNX_VERSAL_CFU_APB, .parent =3D TYPE_SYS_BUS_DEVICE, @@ -467,10 +545,19 @@ static const TypeInfo cfu_fdro_info =3D { } }; =20 +static const TypeInfo cfu_sfr_info =3D { + .name =3D TYPE_XLNX_VERSAL_CFU_SFR, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(XlnxVersalCFUSFR), + .class_init =3D cfu_sfr_class_init, + .instance_init =3D cfu_sfr_init, +}; + static void cfu_apb_register_types(void) { type_register_static(&cfu_apb_info); type_register_static(&cfu_fdro_info); + type_register_static(&cfu_sfr_info); } =20 type_init(cfu_apb_register_types) diff --git a/include/hw/misc/xlnx-versal-cfu.h b/include/hw/misc/xlnx-versa= l-cfu.h index 73e9a21af4..86fb841053 100644 --- a/include/hw/misc/xlnx-versal-cfu.h +++ b/include/hw/misc/xlnx-versal-cfu.h @@ -28,6 +28,9 @@ OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFUAPB, XLNX_VERSAL_= CFU_APB) #define TYPE_XLNX_VERSAL_CFU_FDRO "xlnx,versal-cfu-fdro" OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFUFDRO, XLNX_VERSAL_CFU_FDRO) =20 +#define TYPE_XLNX_VERSAL_CFU_SFR "xlnx,versal-cfu-sfr" +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFUSFR, XLNX_VERSAL_CFU_SFR) + REG32(CFU_ISR, 0x0) FIELD(CFU_ISR, USR_GTS_EVENT, 9, 1) FIELD(CFU_ISR, USR_GSR_EVENT, 8, 1) @@ -222,6 +225,18 @@ struct XlnxVersalCFUFDRO { Fifo32 fdro_data; }; =20 +struct XlnxVersalCFUSFR { + SysBusDevice parent_obj; + MemoryRegion iomem_sfr; + + /* 128-bit wfifo. */ + uint32_t wfifo[WFIFO_SZ]; + + struct { + XlnxVersalCFUAPB *cfu; + } cfg; +}; + /** * This is a helper function for updating a CFI data write fifo, an array = of 4 * uint32_t and 128 bits of data that are allowed to be written through 4 --=20 2.34.1 From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902227; cv=pass; d=zohomail.com; s=zohoarc; b=AlHMYtcrgEces/zDSDYR0qxQAU7XSW67dlW5MDUhGWHRwoz6B+44vhbSKYt/Em/kx994T5j+KPxMdwzfhIn1okm6cdvrnEanFaefP/h/wYz170BnAGS+jmSSwFdNTPx2JmBpuC8zHrzQOXS/bf0KOO+xE+edB/e0Hkon14pPABY= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902227; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=igOqM0iIw/psjUQIfqVUbIfEpwPXmIHr0fGjHwNpqCE=; b=TXj5dj5miy+dIyRbS45I1g4sONoa+oTgwXiDi7RLvLZxUWqT/3ML60TWujgMn8k/mcH8nZ/w1nJEw+77UpvrPpkHKZH8sOPNUlAF+m1lv7JA7OkCvyB5IEL46z8Tl5L8oHSb0UTugchGhNml3cgWOnbvvvSdgPespJHsiaGYtg0= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692902227343697.5910681841199; Thu, 24 Aug 2023 11:37:07 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAv-00070B-QH; Thu, 24 Aug 2023 14:35:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAo-0006yl-Uo for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:15 -0400 Received: from mail-mw2nam10on20626.outbound.protection.outlook.com ([2a01:111:f400:7e89::626] helo=NAM10-MW2-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAj-0007Bx-N2 for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:14 -0400 Received: from CY5PR13CA0045.namprd13.prod.outlook.com (2603:10b6:930:11::17) by CH0PR12MB5028.namprd12.prod.outlook.com (2603:10b6:610:e3::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 18:35:04 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:930:11:cafe::14) by CY5PR13CA0045.outlook.office365.com (2603:10b6:930:11::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Thu, 24 Aug 2023 18:35:04 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Thu, 24 Aug 2023 18:35:03 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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.2507.27; Thu, 24 Aug 2023 13:35:01 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 11:35:01 -0700 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:34:59 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZkVY7sOdagxN38W5hMKVcoYqi5LaIK6lhKZoKckz16IbGmkhXwUAMN5XugnrheNoxLNrS0tDQQD0Ed/EV3FWCP2hna3aWlcpjOxq8yV1OyP68N9siUIkxjEPTU0x48u68ILW+E/XbQA9TLndCKdfz/OnxGyecSwS2ZAZFOuJb7MXskKGCpEhcxQN3Xuoo+pVDCOyKhnRPPX50smq5lyydz/z5wP12vTKlbXvU+EwP02WDytoMJwAJ+Kk2X4GZZr6neOwyksiatEKdrp/LEZcjPS6t8YQqf+hc2rW/FVxufmjrx8agioqYQ1hYskUqZsRczku40Jan3N5r9i4zeKrBg== 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=igOqM0iIw/psjUQIfqVUbIfEpwPXmIHr0fGjHwNpqCE=; b=K+TLQn8gvKwzeJr1SKPUcW+stIlHoil+NwpgCZoxr5ev/LPGVU3399ALuQ1ADXdnS+ZQ4hfCcOJLhqOdcj8JEp0kfKsnYgOBZYTCovWdiPsr6cUJE0OmmUdQCidUiXMrQVUw/G5TGij9VAk/0OsZls7HdqBCHd1FZbqJNm3mYw7GdRWX/EIS4yw8I/btymVSX6xG8UF/OXAAtr3HCpIv5dPtdrCOEk4eZfA73Flo/bJA8w7zBaiUFgaXacMvwRw0ItdLcuJjrt2api3PwGU4pJAx21unzER89i/G34HdJpZHk9hu1dH5l6FXyzHv745uYEyU0y41aBwN5YYyEWugFw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=igOqM0iIw/psjUQIfqVUbIfEpwPXmIHr0fGjHwNpqCE=; b=hiMuf0i/k9AEqddYHVKUHm9ER65LTV+cDGXG7BWsYzNSxy5YClGXtMBVhhduhTw9T3EjMXiVTu5iaVVNr1r567JRvouHe7jwGHCs+LMBchGR1zfCjRGqwWEiC3T7k3b8RyOw5WWCFBwbaHzeN1Zl3Pfq2Isc90o33XitUctVQao= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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 From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 5/8] hw/misc: Introduce a model of Xilinx Versal's CFRAME_REG Date: Thu, 24 Aug 2023 20:34:45 +0200 Message-ID: <20230824183448.151738-6-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE37:EE_|CH0PR12MB5028:EE_ X-MS-Office365-Filtering-Correlation-Id: ecf034b6-600c-479c-e8ac-08dba4d0d545 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lODILlmT76Ijc9MU3qYZUen7geAeNdDXlBZt+ESh6XTse2V/P0YKFYiVy1UfgMJlBWlRVJ+zLCssN0sHI5XcVMuWP72ot6cX1I4GnY4qesIYfyl5zFIm0PeTAIulQq1Wg21nKfot14B2BZqUzBRqSJsC4fHbL0s6w/EnafzMTx8De49aPPL/BNGiowZl3UBevb24RCznsCmz61kORYzTGWKfVuNSSXQxiOjs7q3FSxRs5hrWRFM0qRkzeG8pAFN26XkuYp+Nr5ChFpaNoCRhu2RhTK8M4whrOxK/ESjtzjlLqtWjEbX51HoUd8iyB836lcec5Hs79Kj8ngTEVRQbYO4T5wxcDS6UWvBe2htwU+Yq0sHiWLk5t3y6PwuYD/rpw099h12D5PQ19hhNb7eUZ9Nj2wYp01VdVnVbQK6Uv2TeOukh2uouKVSGrNseJY244OMzSaIYIvHQqLBKEVKdnoGMS312KRsiISVL/IfF7jus+FNgzxa2HeF1SHalp35QO5DT/ixzizBd++JGc/sz4PaBxM3nZ9BHZ3dIOL9on1IF2nKp7rnWidQjnJ8JThSL6X7YY0cfpMI9Z8XrThHqna/MLe6W4hs7trv2Ndz1vRscyg9UuYgkcn+7ORmOiyhoB3afcfTcUnnvv77FRNJpzRUkmUWlHwcJY5+/OBSbGC3xqHq5MCQBFbv4ceLPWBQNJkkubRfYfEIBAxZLci96gXdQsXw+mcwMfzmbp46alZsCu0a0mSzk/POOaprGhUd/FBZTbqVpvLCBFJL0G7bxSRLuXi4NdvBZLKoe8NNCtvU= 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:(13230031)(4636009)(376002)(39860400002)(396003)(136003)(346002)(186009)(1800799009)(82310400011)(451199024)(40470700004)(36840700001)(46966006)(1076003)(40460700003)(2616005)(5660300002)(8936002)(4326008)(8676002)(336012)(426003)(47076005)(36756003)(30864003)(83380400001)(44832011)(36860700001)(26005)(40480700001)(82740400003)(356005)(6666004)(81166007)(70206006)(70586007)(54906003)(6916009)(316002)(478600001)(966005)(41300700001)(2906002)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:35:03.9932 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ecf034b6-600c-479c-e8ac-08dba4d0d545 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH0PR12MB5028 Received-SPF: softfail client-ip=2a01:111:f400:7e89::626; envelope-from=francisco.iglesias@amd.com; helo=NAM10-MW2-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902227676100001 Content-Type: text/plain; charset="utf-8" Introduce a model of Xilinx Versal's Configuration Frame controller (CFRAME_REG). Signed-off-by: Francisco Iglesias --- MAINTAINERS | 2 + hw/misc/meson.build | 1 + hw/misc/xlnx-versal-cframe-reg.c | 685 +++++++++++++++++++++++ include/hw/misc/xlnx-versal-cframe-reg.h | 286 ++++++++++ 4 files changed, 974 insertions(+) create mode 100644 hw/misc/xlnx-versal-cframe-reg.c create mode 100644 include/hw/misc/xlnx-versal-cframe-reg.h diff --git a/MAINTAINERS b/MAINTAINERS index 847b997d73..645374c1d9 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1041,6 +1041,8 @@ F: hw/misc/xlnx-cfi-if.c F: include/hw/misc/xlnx-cfi-if.h F: hw/misc/xlnx-versal-cfu.c F: include/hw/misc/xlnx-versal-cfu.h +F: hw/misc/xlnx-versal-cframe-reg.c +F: include/hw/misc/xlnx-versal-cframe-reg.h =20 STM32F100 M: Alexandre Iooss diff --git a/hw/misc/meson.build b/hw/misc/meson.build index d95cc3fd87..1b425b03bd 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -99,6 +99,7 @@ system_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files( 'xlnx-versal-pmc-iou-slcr.c', 'xlnx-versal-cfu.c', 'xlnx-cfi-if.c', + 'xlnx-versal-cframe-reg.c', )) system_ss.add(when: 'CONFIG_STM32F2XX_SYSCFG', if_true: files('stm32f2xx_s= yscfg.c')) system_ss.add(when: 'CONFIG_STM32F4XX_SYSCFG', if_true: files('stm32f4xx_s= yscfg.c')) diff --git a/hw/misc/xlnx-versal-cframe-reg.c b/hw/misc/xlnx-versal-cframe-= reg.c new file mode 100644 index 0000000000..4c9afb184d --- /dev/null +++ b/hw/misc/xlnx-versal-cframe-reg.c @@ -0,0 +1,685 @@ +/* + * QEMU model of the Configuration Frame Control module + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * Written by Francisco Iglesias + * + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +#include "qemu/osdep.h" +#include "hw/sysbus.h" +#include "hw/register.h" +#include "hw/registerfields.h" +#include "qemu/bitops.h" +#include "qemu/log.h" +#include "qemu/units.h" +#include "qapi/error.h" +#include "hw/qdev-properties.h" +#include "migration/vmstate.h" +#include "hw/irq.h" +#include "hw/misc/xlnx-versal-cframe-reg.h" + +#ifndef XLNX_VERSAL_CFRAME_REG_ERR_DEBUG +#define XLNX_VERSAL_CFRAME_REG_ERR_DEBUG 0 +#endif + +#define KEYHOLE_STREAM_4K (4 * KiB) +#define N_WORDS_128BIT 4 + +#define MAX_BLOCKTYPE 6 +#define MAX_BLOCKTYPE_FRAMES 0xFFFFF + +enum { + CFRAME_CMD_WCFG =3D 1, + CFRAME_CMD_ROWON =3D 2, + CFRAME_CMD_ROWOFF =3D 3, + CFRAME_CMD_RCFG =3D 4, + CFRAME_CMD_DLPARK =3D 5, +}; + +static gint int_cmp(gconstpointer a, gconstpointer b, gpointer user_data) +{ + guint ua =3D GPOINTER_TO_UINT(a); + guint ub =3D GPOINTER_TO_UINT(b); + return (ua > ub) - (ua < ub); +} + +static void cfrm_imr_update_irq(XlnxVersalCFrameReg *s) +{ + bool pending =3D s->regs[R_CFRM_ISR0] & ~s->regs[R_CFRM_IMR0]; + qemu_set_irq(s->irq_cfrm_imr, pending); +} + +static void cfrm_isr_postw(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + cfrm_imr_update_irq(s); +} + +static uint64_t cfrm_ier_prew(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + + s->regs[R_CFRM_IMR0] &=3D ~s->regs[R_CFRM_IER0]; + s->regs[R_CFRM_IER0] =3D 0; + cfrm_imr_update_irq(s); + return 0; +} + +static uint64_t cfrm_idr_prew(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + + s->regs[R_CFRM_IMR0] |=3D s->regs[R_CFRM_IDR0]; + s->regs[R_CFRM_IDR0] =3D 0; + cfrm_imr_update_irq(s); + return 0; +} + +static uint64_t cfrm_itr_prew(RegisterInfo *reg, uint64_t val64) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + + s->regs[R_CFRM_ISR0] |=3D s->regs[R_CFRM_ITR0]; + s->regs[R_CFRM_ITR0] =3D 0; + cfrm_imr_update_irq(s); + return 0; +} + +static void cframe_incr_far(XlnxVersalCFrameReg *s) +{ + uint32_t faddr =3D ARRAY_FIELD_EX32(s->regs, FAR0, FRAME_ADDR); + uint32_t blktype =3D ARRAY_FIELD_EX32(s->regs, FAR0, BLOCKTYPE); + + assert(blktype <=3D MAX_BLOCKTYPE); + + faddr++; + if (faddr > s->cfg.blktype_num_frames[blktype]) { + /* Restart from 0 and increment block type */ + faddr =3D 0; + blktype++; + + assert(blktype <=3D MAX_BLOCKTYPE); + + ARRAY_FIELD_DP32(s->regs, FAR0, BLOCKTYPE, blktype); + } + + ARRAY_FIELD_DP32(s->regs, FAR0, FRAME_ADDR, faddr); +} + +static void cfrm_fdri_post_write(RegisterInfo *reg, uint64_t val) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + + if (s->row_configured && s->rowon && s->wcfg) { + + if (fifo32_num_free(&s->new_f_data) >=3D N_WORDS_128BIT) { + fifo32_push(&s->new_f_data, s->regs[R_FDRI0]); + fifo32_push(&s->new_f_data, s->regs[R_FDRI1]); + fifo32_push(&s->new_f_data, s->regs[R_FDRI2]); + fifo32_push(&s->new_f_data, s->regs[R_FDRI3]); + } + + if (fifo32_is_full(&s->new_f_data)) { + uint32_t addr =3D extract32(s->regs[R_FAR0], 0, 23); + XlnxCFrame *f =3D g_new(XlnxCFrame, 1); + + memcpy(f->data, s->new_f_data.fifo.data, sizeof(f->data)); + + g_tree_replace(s->cframes, GUINT_TO_POINTER(addr), f); + + cframe_incr_far(s); + + fifo32_reset(&s->new_f_data); + } + } +} + +static void cfrm_readout_frames(XlnxVersalCFrameReg *s, uint32_t start_add= r, + uint32_t end_addr) +{ + for (uint32_t addr =3D start_addr; addr < end_addr; addr++) { + XlnxCFrame *f =3D g_tree_lookup(s->cframes, GUINT_TO_POINTER(addr)= ); + + /* Transmit the data if a frame was found */ + if (f) { + for (int i =3D 0; i < FRAME_NUM_WORDS; i +=3D 4) { + XlnxCfiPacket pkt =3D {}; + + pkt.data[0] =3D f->data[i]; + pkt.data[1] =3D f->data[i + 1]; + pkt.data[2] =3D f->data[i + 2]; + pkt.data[3] =3D f->data[i + 3]; + + if (s->cfg.cfu_fdro) { + xlnx_cfi_transfer_packet(s->cfg.cfu_fdro, &pkt); + } + } + } + } +} + +static void cfrm_frcnt_post_write(RegisterInfo *reg, uint64_t val) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + + if (s->row_configured && s->rowon && s->rcfg) { + uint32_t start_addr =3D extract32(s->regs[R_FAR0], 0, 23); + uint32_t end_addr =3D start_addr + s->regs[R_FRCNT0] / FRAME_NUM_Q= WORDS; + + cfrm_readout_frames(s, start_addr, end_addr); + } +} + +static void cfrm_cmd_post_write(RegisterInfo *reg, uint64_t val) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + + if (s->row_configured) { + uint8_t cmd =3D ARRAY_FIELD_EX32(s->regs, CMD0, CMD); + + switch (cmd) { + case CFRAME_CMD_WCFG: + s->wcfg =3D true; + break; + case CFRAME_CMD_ROWON: + s->rowon =3D true; + break; + case CFRAME_CMD_ROWOFF: + s->rowon =3D false; + break; + case CFRAME_CMD_RCFG: + s->rcfg =3D true; + break; + case CFRAME_CMD_DLPARK: + s->wcfg =3D false; + s->rcfg =3D false; + break; + default: + break; + }; + } +} + +static uint64_t cfrm_last_frame_bot_post_read(RegisterInfo *reg, + uint64_t val64) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + uint64_t val =3D 0; + + switch (reg->access->addr) { + case A_LAST_FRAME_BOT0: + val =3D FIELD_DP32(val, LAST_FRAME_BOT0, BLOCKTYPE1_LAST_FRAME_LSB, + s->cfg.blktype_num_frames[1]); + val =3D FIELD_DP32(val, LAST_FRAME_BOT0, BLOCKTYPE0_LAST_FRAME, + s->cfg.blktype_num_frames[0]); + break; + case A_LAST_FRAME_BOT1: + val =3D FIELD_DP32(val, LAST_FRAME_BOT1, BLOCKTYPE3_LAST_FRAME_LSB, + s->cfg.blktype_num_frames[3]); + val =3D FIELD_DP32(val, LAST_FRAME_BOT1, BLOCKTYPE2_LAST_FRAME, + s->cfg.blktype_num_frames[2]); + val =3D FIELD_DP32(val, LAST_FRAME_BOT1, BLOCKTYPE1_LAST_FRAME_MSB, + (s->cfg.blktype_num_frames[1] >> 12)); + break; + case A_LAST_FRAME_BOT2: + val =3D FIELD_DP32(val, LAST_FRAME_BOT2, BLOCKTYPE3_LAST_FRAME_MSB, + (s->cfg.blktype_num_frames[3] >> 4)); + break; + case A_LAST_FRAME_BOT3: + default: + break; + } + + return val; +} + +static uint64_t cfrm_last_frame_top_post_read(RegisterInfo *reg, + uint64_t val64) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + uint64_t val =3D 0; + + switch (reg->access->addr) { + case A_LAST_FRAME_TOP0: + val =3D FIELD_DP32(val, LAST_FRAME_TOP0, BLOCKTYPE5_LAST_FRAME_LSB, + s->cfg.blktype_num_frames[5]); + val =3D FIELD_DP32(val, LAST_FRAME_TOP0, BLOCKTYPE4_LAST_FRAME, + s->cfg.blktype_num_frames[4]); + break; + case A_LAST_FRAME_TOP1: + val =3D FIELD_DP32(val, LAST_FRAME_TOP1, BLOCKTYPE6_LAST_FRAME, + s->cfg.blktype_num_frames[6]); + val =3D FIELD_DP32(val, LAST_FRAME_TOP1, BLOCKTYPE5_LAST_FRAME_MSB, + (s->cfg.blktype_num_frames[5] >> 12)); + break; + case A_LAST_FRAME_TOP2: + case A_LAST_FRAME_BOT3: + default: + break; + } + + return val; +} + +static void cfrm_far_sfr_post_write(RegisterInfo *reg, uint64_t val) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(reg->opaque); + + if (s->row_configured && s->rowon && s->rcfg) { + uint32_t start_addr =3D extract32(s->regs[R_FAR_SFR0], 0, 23); + + /* Readback 1 frame */ + cfrm_readout_frames(s, start_addr, start_addr + 1); + } +} + +static const RegisterAccessInfo cframe_reg_regs_info[] =3D { + { .name =3D "CRC0", .addr =3D A_CRC0, + .rsvd =3D 0x00000000, + },{ .name =3D "CRC1", .addr =3D A_CRC0, + .rsvd =3D 0xffffffff, + },{ .name =3D "CRC2", .addr =3D A_CRC0, + .rsvd =3D 0xffffffff, + },{ .name =3D "CRC3", .addr =3D A_CRC0, + .rsvd =3D 0xffffffff, + },{ .name =3D "FAR0", .addr =3D A_FAR0, + .rsvd =3D 0xfe000000, + },{ .name =3D "FAR1", .addr =3D A_FAR1, + .rsvd =3D 0xffffffff, + },{ .name =3D "FAR2", .addr =3D A_FAR2, + .rsvd =3D 0xffffffff, + },{ .name =3D "FAR3", .addr =3D A_FAR3, + .rsvd =3D 0xffffffff, + },{ .name =3D "FAR_SFR0", .addr =3D A_FAR_SFR0, + .rsvd =3D 0xff800000, + },{ .name =3D "FAR_SFR1", .addr =3D A_FAR_SFR1, + .rsvd =3D 0xffffffff, + },{ .name =3D "FAR_SFR2", .addr =3D A_FAR_SFR2, + .rsvd =3D 0xffffffff, + },{ .name =3D "FAR_SFR3", .addr =3D A_FAR_SFR3, + .rsvd =3D 0xffffffff, + .post_write =3D cfrm_far_sfr_post_write, + },{ .name =3D "FDRI0", .addr =3D A_FDRI0, + },{ .name =3D "FDRI1", .addr =3D A_FDRI1, + },{ .name =3D "FDRI2", .addr =3D A_FDRI2, + },{ .name =3D "FDRI3", .addr =3D A_FDRI3, + .post_write =3D cfrm_fdri_post_write, + },{ .name =3D "FRCNT0", .addr =3D A_FRCNT0, + .rsvd =3D 0x00000000, + },{ .name =3D "FRCNT1", .addr =3D A_FRCNT1, + .rsvd =3D 0xffffffff, + },{ .name =3D "FRCNT2", .addr =3D A_FRCNT2, + .rsvd =3D 0xffffffff, + },{ .name =3D "FRCNT3", .addr =3D A_FRCNT3, + .rsvd =3D 0xffffffff, + .post_write =3D cfrm_frcnt_post_write + },{ .name =3D "CMD0", .addr =3D A_CMD0, + .rsvd =3D 0xffffffe0, + },{ .name =3D "CMD1", .addr =3D A_CMD1, + .rsvd =3D 0xffffffff, + },{ .name =3D "CMD2", .addr =3D A_CMD2, + .rsvd =3D 0xffffffff, + },{ .name =3D "CMD3", .addr =3D A_CMD3, + .rsvd =3D 0xffffffff, + .post_write =3D cfrm_cmd_post_write + },{ .name =3D "CR_MASK0", .addr =3D A_CR_MASK0, + .rsvd =3D 0x00000000, + },{ .name =3D "CR_MASK1", .addr =3D A_CR_MASK1, + .rsvd =3D 0x00000000, + },{ .name =3D "CR_MASK2", .addr =3D A_CR_MASK2, + .rsvd =3D 0x00000000, + },{ .name =3D "CR_MASK3", .addr =3D A_CR_MASK3, + .rsvd =3D 0xffffffff, + },{ .name =3D "CTL0", .addr =3D A_CTL0, + .rsvd =3D 0xfffffff8, + },{ .name =3D "CTL1", .addr =3D A_CTL1, + .rsvd =3D 0xffffffff, + },{ .name =3D "CTL2", .addr =3D A_CTL2, + .rsvd =3D 0xffffffff, + },{ .name =3D "CTL3", .addr =3D A_CTL3, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_ISR0", .addr =3D A_CFRM_ISR0, + .rsvd =3D 0xffc04000, + .w1c =3D 0x3bfff, + },{ .name =3D "CFRM_ISR1", .addr =3D A_CFRM_ISR1, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_ISR2", .addr =3D A_CFRM_ISR2, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_ISR3", .addr =3D A_CFRM_ISR3, + .rsvd =3D 0xffffffff, + .post_write =3D cfrm_isr_postw, + },{ .name =3D "CFRM_IMR0", .addr =3D A_CFRM_IMR0, + .rsvd =3D 0xffc04000, + .ro =3D 0xfffff, + .reset =3D 0x3bfff, + },{ .name =3D "CFRM_IMR1", .addr =3D A_CFRM_IMR1, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_IMR2", .addr =3D A_CFRM_IMR2, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_IMR3", .addr =3D A_CFRM_IMR3, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_IER0", .addr =3D A_CFRM_IER0, + .rsvd =3D 0xffc04000, + },{ .name =3D "CFRM_IER1", .addr =3D A_CFRM_IER1, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_IER2", .addr =3D A_CFRM_IER2, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_IER3", .addr =3D A_CFRM_IER3, + .rsvd =3D 0xffffffff, + .pre_write =3D cfrm_ier_prew, + },{ .name =3D "CFRM_IDR0", .addr =3D A_CFRM_IDR0, + .rsvd =3D 0xffc04000, + },{ .name =3D "CFRM_IDR1", .addr =3D A_CFRM_IDR1, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_IDR2", .addr =3D A_CFRM_IDR2, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_IDR3", .addr =3D A_CFRM_IDR3, + .rsvd =3D 0xffffffff, + .pre_write =3D cfrm_idr_prew, + },{ .name =3D "CFRM_ITR0", .addr =3D A_CFRM_ITR0, + .rsvd =3D 0xffc04000, + },{ .name =3D "CFRM_ITR1", .addr =3D A_CFRM_ITR1, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_ITR2", .addr =3D A_CFRM_ITR2, + .rsvd =3D 0xffffffff, + },{ .name =3D "CFRM_ITR3", .addr =3D A_CFRM_ITR3, + .rsvd =3D 0xffffffff, + .pre_write =3D cfrm_itr_prew, + },{ .name =3D "SEU_SYNDRM00", .addr =3D A_SEU_SYNDRM00, + },{ .name =3D "SEU_SYNDRM01", .addr =3D A_SEU_SYNDRM01, + },{ .name =3D "SEU_SYNDRM02", .addr =3D A_SEU_SYNDRM02, + },{ .name =3D "SEU_SYNDRM03", .addr =3D A_SEU_SYNDRM03, + },{ .name =3D "SEU_SYNDRM10", .addr =3D A_SEU_SYNDRM10, + },{ .name =3D "SEU_SYNDRM11", .addr =3D A_SEU_SYNDRM11, + },{ .name =3D "SEU_SYNDRM12", .addr =3D A_SEU_SYNDRM12, + },{ .name =3D "SEU_SYNDRM13", .addr =3D A_SEU_SYNDRM13, + },{ .name =3D "SEU_SYNDRM20", .addr =3D A_SEU_SYNDRM20, + },{ .name =3D "SEU_SYNDRM21", .addr =3D A_SEU_SYNDRM21, + },{ .name =3D "SEU_SYNDRM22", .addr =3D A_SEU_SYNDRM22, + },{ .name =3D "SEU_SYNDRM23", .addr =3D A_SEU_SYNDRM23, + },{ .name =3D "SEU_SYNDRM30", .addr =3D A_SEU_SYNDRM30, + },{ .name =3D "SEU_SYNDRM31", .addr =3D A_SEU_SYNDRM31, + },{ .name =3D "SEU_SYNDRM32", .addr =3D A_SEU_SYNDRM32, + },{ .name =3D "SEU_SYNDRM33", .addr =3D A_SEU_SYNDRM33, + },{ .name =3D "SEU_VIRTUAL_SYNDRM0", .addr =3D A_SEU_VIRTUAL_SYNDRM0, + },{ .name =3D "SEU_VIRTUAL_SYNDRM1", .addr =3D A_SEU_VIRTUAL_SYNDRM1, + },{ .name =3D "SEU_VIRTUAL_SYNDRM2", .addr =3D A_SEU_VIRTUAL_SYNDRM2, + },{ .name =3D "SEU_VIRTUAL_SYNDRM3", .addr =3D A_SEU_VIRTUAL_SYNDRM3, + },{ .name =3D "SEU_CRC0", .addr =3D A_SEU_CRC0, + },{ .name =3D "SEU_CRC1", .addr =3D A_SEU_CRC1, + },{ .name =3D "SEU_CRC2", .addr =3D A_SEU_CRC2, + },{ .name =3D "SEU_CRC3", .addr =3D A_SEU_CRC3, + },{ .name =3D "CFRAME_FAR_BOT0", .addr =3D A_CFRAME_FAR_BOT0, + },{ .name =3D "CFRAME_FAR_BOT1", .addr =3D A_CFRAME_FAR_BOT1, + },{ .name =3D "CFRAME_FAR_BOT2", .addr =3D A_CFRAME_FAR_BOT2, + },{ .name =3D "CFRAME_FAR_BOT3", .addr =3D A_CFRAME_FAR_BOT3, + },{ .name =3D "CFRAME_FAR_TOP0", .addr =3D A_CFRAME_FAR_TOP0, + },{ .name =3D "CFRAME_FAR_TOP1", .addr =3D A_CFRAME_FAR_TOP1, + },{ .name =3D "CFRAME_FAR_TOP2", .addr =3D A_CFRAME_FAR_TOP2, + },{ .name =3D "CFRAME_FAR_TOP3", .addr =3D A_CFRAME_FAR_TOP3, + },{ .name =3D "LAST_FRAME_BOT0", .addr =3D A_LAST_FRAME_BOT0, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_bot_post_read, + },{ .name =3D "LAST_FRAME_BOT1", .addr =3D A_LAST_FRAME_BOT1, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_bot_post_read, + },{ .name =3D "LAST_FRAME_BOT2", .addr =3D A_LAST_FRAME_BOT2, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_bot_post_read, + },{ .name =3D "LAST_FRAME_BOT3", .addr =3D A_LAST_FRAME_BOT3, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_bot_post_read, + },{ .name =3D "LAST_FRAME_TOP0", .addr =3D A_LAST_FRAME_TOP0, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_top_post_read, + },{ .name =3D "LAST_FRAME_TOP1", .addr =3D A_LAST_FRAME_TOP1, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_top_post_read, + },{ .name =3D "LAST_FRAME_TOP2", .addr =3D A_LAST_FRAME_TOP2, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_top_post_read, + },{ .name =3D "LAST_FRAME_TOP3", .addr =3D A_LAST_FRAME_TOP3, + .ro =3D 0xffffffff, + .post_read =3D cfrm_last_frame_top_post_read, + } +}; + +static void cframe_reg_cfi_transfer_packet(XlnxCfiIf *cfi_if, + XlnxCfiPacket *pkt) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(cfi_if); + uint64_t we =3D MAKE_64BIT_MASK(0, 4 * 8); + + if (!s->row_configured) { + return; + } + + switch (pkt->reg_addr) { + case CFRAME_FAR: + s->regs[R_FAR0] =3D pkt->data[0]; + break; + case CFRAME_SFR: + s->regs[R_FAR_SFR0] =3D pkt->data[0]; + register_write(&s->regs_info[R_FAR_SFR3], 0, + we, object_get_typename(OBJECT(s)), + XLNX_VERSAL_CFRAME_REG_ERR_DEBUG); + break; + case CFRAME_FDRI: + s->regs[R_FDRI0] =3D pkt->data[0]; + s->regs[R_FDRI1] =3D pkt->data[1]; + s->regs[R_FDRI2] =3D pkt->data[2]; + register_write(&s->regs_info[R_FDRI3], pkt->data[3], + we, object_get_typename(OBJECT(s)), + XLNX_VERSAL_CFRAME_REG_ERR_DEBUG); + break; + case CFRAME_CMD: + ARRAY_FIELD_DP32(s->regs, CMD0, CMD, pkt->data[0]); + + register_write(&s->regs_info[R_CMD3], 0, + we, object_get_typename(OBJECT(s)), + XLNX_VERSAL_CFRAME_REG_ERR_DEBUG); + break; + default: + break; + } +} + +static uint64_t cframe_reg_fdri_read(void *opaque, hwaddr addr, unsigned s= ize) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unsupported read from addr=3D%" + HWADDR_PRIx "\n", __func__, addr); + return 0; +} + +static void cframe_reg_fdri_write(void *opaque, hwaddr addr, uint64_t valu= e, + unsigned size) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(opaque); + uint32_t wfifo[WFIFO_SZ]; + + if (update_wfifo(addr, value, s->wfifo, wfifo)) { + uint64_t we =3D MAKE_64BIT_MASK(0, 4 * 8); + + s->regs[R_FDRI0] =3D wfifo[0]; + s->regs[R_FDRI1] =3D wfifo[1]; + s->regs[R_FDRI2] =3D wfifo[2]; + register_write(&s->regs_info[R_FDRI3], wfifo[3], + we, object_get_typename(OBJECT(s)), + XLNX_VERSAL_CFRAME_REG_ERR_DEBUG); + } +} + +static void cframe_reg_reset_enter(Object *obj, ResetType type) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(obj); + unsigned int i; + + for (i =3D 0; i < ARRAY_SIZE(s->regs_info); ++i) { + register_reset(&s->regs_info[i]); + } + memset(s->wfifo, 0, WFIFO_SZ * sizeof(uint32_t)); + fifo32_reset(&s->new_f_data); + + if (g_tree_height(s->cframes)) { + g_tree_destroy(s->cframes); + s->cframes =3D g_tree_new_full((GCompareDataFunc)int_cmp, NULL, + NULL, (GDestroyNotify) g_free); + } +} + +static void cframe_reg_reset_hold(Object *obj) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(obj); + + cfrm_imr_update_irq(s); +} + +static const MemoryRegionOps cframe_reg_ops =3D { + .read =3D register_read_memory, + .write =3D register_write_memory, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static const MemoryRegionOps cframe_reg_fdri_ops =3D { + .read =3D cframe_reg_fdri_read, + .write =3D cframe_reg_fdri_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static void cframe_reg_realize(DeviceState *dev, Error **errp) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(dev); + + for (int i =3D 0; i < ARRAY_SIZE(s->cfg.blktype_num_frames); i++) { + if (s->cfg.blktype_num_frames[i] > MAX_BLOCKTYPE_FRAMES) { + error_setg(errp, + "blktype-frames%d > 0xFFFFF (max frame per block)", + i); + return; + } + if (s->cfg.blktype_num_frames[i]) { + s->row_configured =3D true; + } + } +} + +static void cframe_reg_init(Object *obj) +{ + XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + RegisterInfoArray *reg_array; + + memory_region_init(&s->iomem, obj, TYPE_XLNX_VERSAL_CFRAME_REG, + CFRAME_REG_R_MAX * 4); + reg_array =3D + register_init_block32(DEVICE(obj), cframe_reg_regs_info, + ARRAY_SIZE(cframe_reg_regs_info), + s->regs_info, s->regs, + &cframe_reg_ops, + XLNX_VERSAL_CFRAME_REG_ERR_DEBUG, + CFRAME_REG_R_MAX * 4); + memory_region_add_subregion(&s->iomem, + 0x0, + ®_array->mem); + sysbus_init_mmio(sbd, &s->iomem); + memory_region_init_io(&s->iomem_fdri, obj, &cframe_reg_fdri_ops, s, + TYPE_XLNX_VERSAL_CFRAME_REG "-fdri", + KEYHOLE_STREAM_4K); + sysbus_init_mmio(sbd, &s->iomem_fdri); + sysbus_init_irq(sbd, &s->irq_cfrm_imr); + + s->cframes =3D g_tree_new_full((GCompareDataFunc)int_cmp, NULL, + NULL, (GDestroyNotify) g_free); + fifo32_create(&s->new_f_data, FRAME_NUM_WORDS); +} + +static const VMStateDescription vmstate_cframe =3D { + .name =3D "cframe", + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32_ARRAY(data, XlnxCFrame, FRAME_NUM_WORDS), + VMSTATE_END_OF_LIST() + } +}; + +static const VMStateDescription vmstate_cframe_reg =3D { + .name =3D TYPE_XLNX_VERSAL_CFRAME_REG, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32_ARRAY(wfifo, XlnxVersalCFrameReg, 4), + VMSTATE_UINT32_ARRAY(regs, XlnxVersalCFrameReg, CFRAME_REG_R_MAX), + VMSTATE_BOOL(rowon, XlnxVersalCFrameReg), + VMSTATE_BOOL(wcfg, XlnxVersalCFrameReg), + VMSTATE_BOOL(rcfg, XlnxVersalCFrameReg), + VMSTATE_GTREE_DIRECT_KEY_V(cframes, XlnxVersalCFrameReg, 1, + &vmstate_cframe, XlnxCFrame), + VMSTATE_FIFO32(new_f_data, XlnxVersalCFrameReg), + VMSTATE_END_OF_LIST(), + } +}; + +static Property cframe_regs_props[] =3D { + DEFINE_PROP_LINK("cfu-fdro", XlnxVersalCFrameReg, cfg.cfu_fdro, + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_UINT32("blktype0-frames", XlnxVersalCFrameReg, + cfg.blktype_num_frames[0], 0), + DEFINE_PROP_UINT32("blktype1-frames", XlnxVersalCFrameReg, + cfg.blktype_num_frames[1], 0), + DEFINE_PROP_UINT32("blktype2-frames", XlnxVersalCFrameReg, + cfg.blktype_num_frames[2], 0), + DEFINE_PROP_UINT32("blktype3-frames", XlnxVersalCFrameReg, + cfg.blktype_num_frames[3], 0), + DEFINE_PROP_UINT32("blktype4-frames", XlnxVersalCFrameReg, + cfg.blktype_num_frames[4], 0), + DEFINE_PROP_UINT32("blktype5-frames", XlnxVersalCFrameReg, + cfg.blktype_num_frames[5], 0), + DEFINE_PROP_UINT32("blktype6-frames", XlnxVersalCFrameReg, + cfg.blktype_num_frames[6], 0), + DEFINE_PROP_END_OF_LIST(), +}; + +static void cframe_reg_class_init(ObjectClass *klass, void *data) +{ + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + DeviceClass *dc =3D DEVICE_CLASS(klass); + XlnxCfiIfClass *xcic =3D XLNX_CFI_IF_CLASS(klass); + + dc->vmsd =3D &vmstate_cframe_reg; + dc->realize =3D cframe_reg_realize; + rc->phases.enter =3D cframe_reg_reset_enter; + rc->phases.hold =3D cframe_reg_reset_hold; + device_class_set_props(dc, cframe_regs_props); + xcic->cfi_transfer_packet =3D cframe_reg_cfi_transfer_packet; +} + +static const TypeInfo cframe_reg_info =3D { + .name =3D TYPE_XLNX_VERSAL_CFRAME_REG, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(XlnxVersalCFrameReg), + .class_init =3D cframe_reg_class_init, + .instance_init =3D cframe_reg_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_XLNX_CFI_IF }, + { } + } +}; + +static void cframe_reg_register_types(void) +{ + type_register_static(&cframe_reg_info); +} + +type_init(cframe_reg_register_types) diff --git a/include/hw/misc/xlnx-versal-cframe-reg.h b/include/hw/misc/xln= x-versal-cframe-reg.h new file mode 100644 index 0000000000..f286d973bf --- /dev/null +++ b/include/hw/misc/xlnx-versal-cframe-reg.h @@ -0,0 +1,286 @@ +/* + * QEMU model of the Configuration Frame Control module + * + * Copyright (C) 2023, Advanced Micro Devices, Inc. + * + * Written by Francisco Iglesias + * + * SPDX-License-Identifier: GPL-2.0-or-later + * + * References: + * [1] Versal ACAP Technical Reference Manual, + * https://www.xilinx.com/support/documentation/architecture-manuals/a= m011-versal-acap-trm.pdf + * + * [2] Versal ACAP Register Reference, + * https://www.xilinx.com/htmldocs/registers/am012/am012-versal-regist= er-reference.html + */ +#ifndef HW_MISC_XLNX_VERSAL_CFRAME_REG_H +#define HW_MISC_XLNX_VERSAL_CFRAME_REG_H + +#include "hw/sysbus.h" +#include "hw/register.h" +#include "hw/misc/xlnx-cfi-if.h" +#include "hw/misc/xlnx-versal-cfu.h" +#include "qemu/fifo32.h" + +#define TYPE_XLNX_VERSAL_CFRAME_REG "xlnx,cframe-reg" +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFrameReg, XLNX_VERSAL_CFRAME_REG) + +/* + * The registers in this module are 128 bits wide but it is ok to write + * and read them through 4 sequential 32 bit accesses (address[3:2] =3D 0, + * 1, 2, 3). + */ +REG32(CRC0, 0x0) + FIELD(CRC, CRC, 0, 32) +REG32(CRC1, 0x4) +REG32(CRC2, 0x8) +REG32(CRC3, 0xc) +REG32(FAR0, 0x10) + FIELD(FAR0, SEGMENT, 23, 2) + FIELD(FAR0, BLOCKTYPE, 20, 3) + FIELD(FAR0, FRAME_ADDR, 0, 20) +REG32(FAR1, 0x14) +REG32(FAR2, 0x18) +REG32(FAR3, 0x1c) +REG32(FAR_SFR0, 0x20) + FIELD(FAR_SFR0, BLOCKTYPE, 20, 3) + FIELD(FAR_SFR0, FRAME_ADDR, 0, 20) +REG32(FAR_SFR1, 0x24) +REG32(FAR_SFR2, 0x28) +REG32(FAR_SFR3, 0x2c) +REG32(FDRI0, 0x40) +REG32(FDRI1, 0x44) +REG32(FDRI2, 0x48) +REG32(FDRI3, 0x4c) +REG32(FRCNT0, 0x50) + FIELD(FRCNT0, FRCNT, 0, 32) +REG32(FRCNT1, 0x54) +REG32(FRCNT2, 0x58) +REG32(FRCNT3, 0x5c) +REG32(CMD0, 0x60) + FIELD(CMD0, CMD, 0, 5) +REG32(CMD1, 0x64) +REG32(CMD2, 0x68) +REG32(CMD3, 0x6c) +REG32(CR_MASK0, 0x70) +REG32(CR_MASK1, 0x74) +REG32(CR_MASK2, 0x78) +REG32(CR_MASK3, 0x7c) +REG32(CTL0, 0x80) + FIELD(CTL, PER_FRAME_CRC, 0, 1) +REG32(CTL1, 0x84) +REG32(CTL2, 0x88) +REG32(CTL3, 0x8c) +REG32(CFRM_ISR0, 0x150) + FIELD(CFRM_ISR0, READ_BROADCAST_ERROR, 21, 1) + FIELD(CFRM_ISR0, CMD_MISSING_ERROR, 20, 1) + FIELD(CFRM_ISR0, RW_ROWOFF_ERROR, 19, 1) + FIELD(CFRM_ISR0, READ_REG_ADDR_ERROR, 18, 1) + FIELD(CFRM_ISR0, READ_BLK_TYPE_ERROR, 17, 1) + FIELD(CFRM_ISR0, READ_FRAME_ADDR_ERROR, 16, 1) + FIELD(CFRM_ISR0, WRITE_REG_ADDR_ERROR, 15, 1) + FIELD(CFRM_ISR0, WRITE_BLK_TYPE_ERROR, 13, 1) + FIELD(CFRM_ISR0, WRITE_FRAME_ADDR_ERROR, 12, 1) + FIELD(CFRM_ISR0, MFW_OVERRUN_ERROR, 11, 1) + FIELD(CFRM_ISR0, FAR_FIFO_UNDERFLOW, 10, 1) + FIELD(CFRM_ISR0, FAR_FIFO_OVERFLOW, 9, 1) + FIELD(CFRM_ISR0, PER_FRAME_SEQ_ERROR, 8, 1) + FIELD(CFRM_ISR0, CRC_ERROR, 7, 1) + FIELD(CFRM_ISR0, WRITE_OVERRUN_ERROR, 6, 1) + FIELD(CFRM_ISR0, READ_OVERRUN_ERROR, 5, 1) + FIELD(CFRM_ISR0, CMD_INTERRUPT_ERROR, 4, 1) + FIELD(CFRM_ISR0, WRITE_INTERRUPT_ERROR, 3, 1) + FIELD(CFRM_ISR0, READ_INTERRUPT_ERROR, 2, 1) + FIELD(CFRM_ISR0, SEU_CRC_ERROR, 1, 1) + FIELD(CFRM_ISR0, SEU_ECC_ERROR, 0, 1) +REG32(CFRM_ISR1, 0x154) +REG32(CFRM_ISR2, 0x158) +REG32(CFRM_ISR3, 0x15c) +REG32(CFRM_IMR0, 0x160) + FIELD(CFRM_IMR0, READ_BROADCAST_ERROR, 21, 1) + FIELD(CFRM_IMR0, CMD_MISSING_ERROR, 20, 1) + FIELD(CFRM_IMR0, RW_ROWOFF_ERROR, 19, 1) + FIELD(CFRM_IMR0, READ_REG_ADDR_ERROR, 18, 1) + FIELD(CFRM_IMR0, READ_BLK_TYPE_ERROR, 17, 1) + FIELD(CFRM_IMR0, READ_FRAME_ADDR_ERROR, 16, 1) + FIELD(CFRM_IMR0, WRITE_REG_ADDR_ERROR, 15, 1) + FIELD(CFRM_IMR0, WRITE_BLK_TYPE_ERROR, 13, 1) + FIELD(CFRM_IMR0, WRITE_FRAME_ADDR_ERROR, 12, 1) + FIELD(CFRM_IMR0, MFW_OVERRUN_ERROR, 11, 1) + FIELD(CFRM_IMR0, FAR_FIFO_UNDERFLOW, 10, 1) + FIELD(CFRM_IMR0, FAR_FIFO_OVERFLOW, 9, 1) + FIELD(CFRM_IMR0, PER_FRAME_SEQ_ERROR, 8, 1) + FIELD(CFRM_IMR0, CRC_ERROR, 7, 1) + FIELD(CFRM_IMR0, WRITE_OVERRUN_ERROR, 6, 1) + FIELD(CFRM_IMR0, READ_OVERRUN_ERROR, 5, 1) + FIELD(CFRM_IMR0, CMD_INTERRUPT_ERROR, 4, 1) + FIELD(CFRM_IMR0, WRITE_INTERRUPT_ERROR, 3, 1) + FIELD(CFRM_IMR0, READ_INTERRUPT_ERROR, 2, 1) + FIELD(CFRM_IMR0, SEU_CRC_ERROR, 1, 1) + FIELD(CFRM_IMR0, SEU_ECC_ERROR, 0, 1) +REG32(CFRM_IMR1, 0x164) +REG32(CFRM_IMR2, 0x168) +REG32(CFRM_IMR3, 0x16c) +REG32(CFRM_IER0, 0x170) + FIELD(CFRM_IER0, READ_BROADCAST_ERROR, 21, 1) + FIELD(CFRM_IER0, CMD_MISSING_ERROR, 20, 1) + FIELD(CFRM_IER0, RW_ROWOFF_ERROR, 19, 1) + FIELD(CFRM_IER0, READ_REG_ADDR_ERROR, 18, 1) + FIELD(CFRM_IER0, READ_BLK_TYPE_ERROR, 17, 1) + FIELD(CFRM_IER0, READ_FRAME_ADDR_ERROR, 16, 1) + FIELD(CFRM_IER0, WRITE_REG_ADDR_ERROR, 15, 1) + FIELD(CFRM_IER0, WRITE_BLK_TYPE_ERROR, 13, 1) + FIELD(CFRM_IER0, WRITE_FRAME_ADDR_ERROR, 12, 1) + FIELD(CFRM_IER0, MFW_OVERRUN_ERROR, 11, 1) + FIELD(CFRM_IER0, FAR_FIFO_UNDERFLOW, 10, 1) + FIELD(CFRM_IER0, FAR_FIFO_OVERFLOW, 9, 1) + FIELD(CFRM_IER0, PER_FRAME_SEQ_ERROR, 8, 1) + FIELD(CFRM_IER0, CRC_ERROR, 7, 1) + FIELD(CFRM_IER0, WRITE_OVERRUN_ERROR, 6, 1) + FIELD(CFRM_IER0, READ_OVERRUN_ERROR, 5, 1) + FIELD(CFRM_IER0, CMD_INTERRUPT_ERROR, 4, 1) + FIELD(CFRM_IER0, WRITE_INTERRUPT_ERROR, 3, 1) + FIELD(CFRM_IER0, READ_INTERRUPT_ERROR, 2, 1) + FIELD(CFRM_IER0, SEU_CRC_ERROR, 1, 1) + FIELD(CFRM_IER0, SEU_ECC_ERROR, 0, 1) +REG32(CFRM_IER1, 0x174) +REG32(CFRM_IER2, 0x178) +REG32(CFRM_IER3, 0x17c) +REG32(CFRM_IDR0, 0x180) + FIELD(CFRM_IDR0, READ_BROADCAST_ERROR, 21, 1) + FIELD(CFRM_IDR0, CMD_MISSING_ERROR, 20, 1) + FIELD(CFRM_IDR0, RW_ROWOFF_ERROR, 19, 1) + FIELD(CFRM_IDR0, READ_REG_ADDR_ERROR, 18, 1) + FIELD(CFRM_IDR0, READ_BLK_TYPE_ERROR, 17, 1) + FIELD(CFRM_IDR0, READ_FRAME_ADDR_ERROR, 16, 1) + FIELD(CFRM_IDR0, WRITE_REG_ADDR_ERROR, 15, 1) + FIELD(CFRM_IDR0, WRITE_BLK_TYPE_ERROR, 13, 1) + FIELD(CFRM_IDR0, WRITE_FRAME_ADDR_ERROR, 12, 1) + FIELD(CFRM_IDR0, MFW_OVERRUN_ERROR, 11, 1) + FIELD(CFRM_IDR0, FAR_FIFO_UNDERFLOW, 10, 1) + FIELD(CFRM_IDR0, FAR_FIFO_OVERFLOW, 9, 1) + FIELD(CFRM_IDR0, PER_FRAME_SEQ_ERROR, 8, 1) + FIELD(CFRM_IDR0, CRC_ERROR, 7, 1) + FIELD(CFRM_IDR0, WRITE_OVERRUN_ERROR, 6, 1) + FIELD(CFRM_IDR0, READ_OVERRUN_ERROR, 5, 1) + FIELD(CFRM_IDR0, CMD_INTERRUPT_ERROR, 4, 1) + FIELD(CFRM_IDR0, WRITE_INTERRUPT_ERROR, 3, 1) + FIELD(CFRM_IDR0, READ_INTERRUPT_ERROR, 2, 1) + FIELD(CFRM_IDR0, SEU_CRC_ERROR, 1, 1) + FIELD(CFRM_IDR0, SEU_ECC_ERROR, 0, 1) +REG32(CFRM_IDR1, 0x184) +REG32(CFRM_IDR2, 0x188) +REG32(CFRM_IDR3, 0x18c) +REG32(CFRM_ITR0, 0x190) + FIELD(CFRM_ITR0, READ_BROADCAST_ERROR, 21, 1) + FIELD(CFRM_ITR0, CMD_MISSING_ERROR, 20, 1) + FIELD(CFRM_ITR0, RW_ROWOFF_ERROR, 19, 1) + FIELD(CFRM_ITR0, READ_REG_ADDR_ERROR, 18, 1) + FIELD(CFRM_ITR0, READ_BLK_TYPE_ERROR, 17, 1) + FIELD(CFRM_ITR0, READ_FRAME_ADDR_ERROR, 16, 1) + FIELD(CFRM_ITR0, WRITE_REG_ADDR_ERROR, 15, 1) + FIELD(CFRM_ITR0, WRITE_BLK_TYPE_ERROR, 13, 1) + FIELD(CFRM_ITR0, WRITE_FRAME_ADDR_ERROR, 12, 1) + FIELD(CFRM_ITR0, MFW_OVERRUN_ERROR, 11, 1) + FIELD(CFRM_ITR0, FAR_FIFO_UNDERFLOW, 10, 1) + FIELD(CFRM_ITR0, FAR_FIFO_OVERFLOW, 9, 1) + FIELD(CFRM_ITR0, PER_FRAME_SEQ_ERROR, 8, 1) + FIELD(CFRM_ITR0, CRC_ERROR, 7, 1) + FIELD(CFRM_ITR0, WRITE_OVERRUN_ERROR, 6, 1) + FIELD(CFRM_ITR0, READ_OVERRUN_ERROR, 5, 1) + FIELD(CFRM_ITR0, CMD_INTERRUPT_ERROR, 4, 1) + FIELD(CFRM_ITR0, WRITE_INTERRUPT_ERROR, 3, 1) + FIELD(CFRM_ITR0, READ_INTERRUPT_ERROR, 2, 1) + FIELD(CFRM_ITR0, SEU_CRC_ERROR, 1, 1) + FIELD(CFRM_ITR0, SEU_ECC_ERROR, 0, 1) +REG32(CFRM_ITR1, 0x194) +REG32(CFRM_ITR2, 0x198) +REG32(CFRM_ITR3, 0x19c) +REG32(SEU_SYNDRM00, 0x1a0) +REG32(SEU_SYNDRM01, 0x1a4) +REG32(SEU_SYNDRM02, 0x1a8) +REG32(SEU_SYNDRM03, 0x1ac) +REG32(SEU_SYNDRM10, 0x1b0) +REG32(SEU_SYNDRM11, 0x1b4) +REG32(SEU_SYNDRM12, 0x1b8) +REG32(SEU_SYNDRM13, 0x1bc) +REG32(SEU_SYNDRM20, 0x1c0) +REG32(SEU_SYNDRM21, 0x1c4) +REG32(SEU_SYNDRM22, 0x1c8) +REG32(SEU_SYNDRM23, 0x1cc) +REG32(SEU_SYNDRM30, 0x1d0) +REG32(SEU_SYNDRM31, 0x1d4) +REG32(SEU_SYNDRM32, 0x1d8) +REG32(SEU_SYNDRM33, 0x1dc) +REG32(SEU_VIRTUAL_SYNDRM0, 0x1e0) +REG32(SEU_VIRTUAL_SYNDRM1, 0x1e4) +REG32(SEU_VIRTUAL_SYNDRM2, 0x1e8) +REG32(SEU_VIRTUAL_SYNDRM3, 0x1ec) +REG32(SEU_CRC0, 0x1f0) +REG32(SEU_CRC1, 0x1f4) +REG32(SEU_CRC2, 0x1f8) +REG32(SEU_CRC3, 0x1fc) +REG32(CFRAME_FAR_BOT0, 0x200) +REG32(CFRAME_FAR_BOT1, 0x204) +REG32(CFRAME_FAR_BOT2, 0x208) +REG32(CFRAME_FAR_BOT3, 0x20c) +REG32(CFRAME_FAR_TOP0, 0x210) +REG32(CFRAME_FAR_TOP1, 0x214) +REG32(CFRAME_FAR_TOP2, 0x218) +REG32(CFRAME_FAR_TOP3, 0x21c) +REG32(LAST_FRAME_BOT0, 0x220) + FIELD(LAST_FRAME_BOT0, BLOCKTYPE1_LAST_FRAME_LSB, 20, 12) + FIELD(LAST_FRAME_BOT0, BLOCKTYPE0_LAST_FRAME, 0, 20) +REG32(LAST_FRAME_BOT1, 0x224) + FIELD(LAST_FRAME_BOT1, BLOCKTYPE3_LAST_FRAME_LSB, 28, 4) + FIELD(LAST_FRAME_BOT1, BLOCKTYPE2_LAST_FRAME, 8, 20) + FIELD(LAST_FRAME_BOT1, BLOCKTYPE1_LAST_FRAME_MSB, 0, 8) +REG32(LAST_FRAME_BOT2, 0x228) + FIELD(LAST_FRAME_BOT2, BLOCKTYPE3_LAST_FRAME_MSB, 0, 16) +REG32(LAST_FRAME_BOT3, 0x22c) +REG32(LAST_FRAME_TOP0, 0x230) + FIELD(LAST_FRAME_TOP0, BLOCKTYPE5_LAST_FRAME_LSB, 20, 12) + FIELD(LAST_FRAME_TOP0, BLOCKTYPE4_LAST_FRAME, 0, 20) +REG32(LAST_FRAME_TOP1, 0x234) + FIELD(LAST_FRAME_TOP1, BLOCKTYPE6_LAST_FRAME, 8, 20) + FIELD(LAST_FRAME_TOP1, BLOCKTYPE5_LAST_FRAME_MSB, 0, 8) +REG32(LAST_FRAME_TOP2, 0x238) +REG32(LAST_FRAME_TOP3, 0x23c) + +#define CFRAME_REG_R_MAX (R_LAST_FRAME_TOP3 + 1) + +#define FRAME_NUM_QWORDS 25 +#define FRAME_NUM_WORDS (FRAME_NUM_QWORDS * 4) /* 25 * 128 bits */ + +typedef struct XlnxCFrame { + uint32_t data[FRAME_NUM_WORDS]; +} XlnxCFrame; + +struct XlnxVersalCFrameReg { + SysBusDevice parent_obj; + MemoryRegion iomem; + MemoryRegion iomem_fdri; + qemu_irq irq_cfrm_imr; + + /* 128-bit wfifo. */ + uint32_t wfifo[WFIFO_SZ]; + + uint32_t regs[CFRAME_REG_R_MAX]; + RegisterInfo regs_info[CFRAME_REG_R_MAX]; + + bool rowon; + bool wcfg; + bool rcfg; + + GTree *cframes; + Fifo32 new_f_data; + + struct { + XlnxCfiIf *cfu_fdro; + uint32_t blktype_num_frames[7]; + } cfg; + bool row_configured; +}; + +#endif --=20 2.34.1 From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902193; cv=pass; d=zohomail.com; s=zohoarc; b=buAvHN6h6M0rBTnuQDBy7wJCAmBfL+GYgud8A+D5e1OUEcZOAwJY0Vl8WLnrLv/r0NcOc/LKFjn4MiETVTZHxeT/MIeoYMqNXIdLDoNw1vERi0+HEthzCHe/uVsMdMPBd+IOIe64o497x0LmqIxghVXPqCEvvx56hPfu1m8/7w0= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902193; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=flFS5KYN+WgkgEaGTlNnGjNFWjAc9ImxSRCOjPRlyqU=; b=j98/OcEsdhWOVpD0MbEGMlVk1yRo3xjedRchHLP/6CcDzqhivqMtdRtK9/rtzD1qV8nEwD/zL4/9QHVyII3J22nv50LCL+SdQod1XXp4yKJASzHRnAFNJrd7DcUSAAFOrgB9odnDBTsplY8z92V0+q1F60c9RXIhKLeUw/pUolw= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692902193098236.47448023059064; Thu, 24 Aug 2023 11:36:33 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAy-00072E-0Q; Thu, 24 Aug 2023 14:35:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAv-00070C-0s for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:21 -0400 Received: from mail-bn1nam02on20608.outbound.protection.outlook.com ([2a01:111:f400:7eb2::608] helo=NAM02-BN1-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAs-0007F3-8X for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:20 -0400 Received: from CY5PR13CA0040.namprd13.prod.outlook.com (2603:10b6:930:11::15) by SN7PR12MB6813.namprd12.prod.outlook.com (2603:10b6:806:267::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 18:35:13 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:930:11:cafe::9c) by CY5PR13CA0040.outlook.office365.com (2603:10b6:930:11::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.15 via Frontend Transport; Thu, 24 Aug 2023 18:35:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Thu, 24 Aug 2023 18:35:12 +0000 Received: from SATLEXMB07.amd.com (10.181.41.45) 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.2507.27; Thu, 24 Aug 2023 13:35:03 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB07.amd.com (10.181.41.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 11:35:03 -0700 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:35:01 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LWCmXntg5jzyQkaKhGQVbfZMiFV6G+I9AAiNOvk0hKi5nzSLBkRlf8FV1DYIYwv97LVv3U7TzUCO5uS4wzLvApeM7FXxXYH7j5dMfbajKCGJDiDH3hLUVglboRABp/s0fOw1DyrMVAGfwZr1Rmq8mEkTZwuQmXOcGMIDzuM2OePXdztSP18l7umRV1fuojooMp37fExMIRwK89MKnyUzYOwNKRJ3b8Gkb6b92KmYViWPQZRX+Hl4zYj1oe/9p0SfLj221WSsoNO31S+V10srU7z8lW+n4BMXZMBnTnP6B+3SbsXmbQDxw1bTcms0uKehep8hLX0eOVg0u97czPec1w== 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=flFS5KYN+WgkgEaGTlNnGjNFWjAc9ImxSRCOjPRlyqU=; b=S80Xo1Yq7+7FlgidtQ/RbiacBXsaiv5COPcMaaq0+3maPp/d1PEIziuYH956Zhqde8YZ+BoUQ3hUCZRTBmk0fOQIWu1+H0uKpBWI8S00fILWder+Ue1Xy3ASBo5q6dXppYJt12I/tuqXpYLWi8TuEVdhWTTOREF7TQ//sErUxpJBWzNohZ5E79fFFWNYzglTzCdZ4xp2jLHkTfNqNjDp+fZFW6XUgVbeMhTWshiqiACLY79x4V+LmdV4qpgTHOWDwYPFJO30+YxxYo0PKhGr4oM8IPTdgZsOli7NzCleXruEdbP31Zp49oyeCtQpjldFfrQAiv3Y1Hw8scEMT/2ZeQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=flFS5KYN+WgkgEaGTlNnGjNFWjAc9ImxSRCOjPRlyqU=; b=n7PzMkAnWsY+yc6Etc24V3ZUlaW2MDF3s9zBHJ5/JlchzqaEbkT1FVVlXP/6PGnKa1yaU7hft+AAXbCcvxz81OKpboJjavQezqQkj1BVaxIftoKR1B9nKJP6i7CaJ4clyyCZJcJf5l/KrSb78xZ0oxR7fk58S7Atsssma9oydvY= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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 From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 6/8] hw/misc: Introduce a model of Xilinx Versal's CFRAME_BCAST_REG Date: Thu, 24 Aug 2023 20:34:46 +0200 Message-ID: <20230824183448.151738-7-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE37:EE_|SN7PR12MB6813:EE_ X-MS-Office365-Filtering-Correlation-Id: a9968dac-69f6-4963-b05e-08dba4d0da5b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: QIsck8OapsieFyk9yJvyasfl1b8D/hquiFyY7NncWipe+39z4HyE/ER+96pDb+LXIKl/D5eAj0p/iNhLwostJh1nlapi62lklBiqZCEIoofncTHMjqhZHWf6XwzVgfh72ZR/bNojxQit5na6iERhd4KJV1kGu0FNZcHQqfkSrxu4MjD4H+oZTwzVRxSsq10BHCnpKXjj5XgiDH18wGaAD9cilNSdDsyMp8RTCK29m25kHdCMzGjAZ1JDZlB1w1itygJv9SMFlik7E0lI3DBbtqJqdISOaX0S/5F3TM9qExVRA4CCyHbS8abXt+a1DEpNiQbipey9qrs6nb3OTy1Mizcm1Bm91GnDwZsv3aZrLOxva//vQsMzwRbWpCZf7fQ18YjImnoUdVI7XvMs7+snRCl8EC1rhSwePpezm5bxcD633c6nQuB3UX/EJP7G2lfAYOQm9dbOoRO7GiXZIQ0/lm4ndwWEiTRxTWDAyCWunfTZe7emXrCVY97KOHlaGt3+egHlDBGEhoNa405ARmeUT0teluz8EFE4I6R2nylVLBxNuQZ4W59voHedAYq8v5pO2OJjRLMLx9pHSjLTl5wsRmVc5R8Pjh/LwTaHhIBtUKaYE3LsgjZLezP1MN466pRjjfx3aGpe6MRGGk5JIvQXYBQUq4hPi3Jm3QONrBCSdb0w4VXilxooXjhrMDn8AWKGYWlCIfnH6mpqH0vaE/nk9UGpjKiU5Q7QWkuySHz08AmyuBH/Of/vL9tGPkEiMC8+4rXFArMoC87IboCBMoZL1w== 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:(13230031)(4636009)(39860400002)(376002)(136003)(396003)(346002)(186009)(1800799009)(82310400011)(451199024)(36840700001)(40470700004)(46966006)(54906003)(70206006)(70586007)(316002)(6916009)(81166007)(478600001)(40480700001)(26005)(6666004)(82740400003)(41300700001)(86362001)(2906002)(356005)(4326008)(8676002)(8936002)(83380400001)(2616005)(40460700003)(5660300002)(47076005)(44832011)(1076003)(426003)(336012)(36756003)(36860700001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:35:12.5245 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a9968dac-69f6-4963-b05e-08dba4d0da5b 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN7PR12MB6813 Received-SPF: softfail client-ip=2a01:111:f400:7eb2::608; envelope-from=francisco.iglesias@amd.com; helo=NAM02-BN1-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902194863100001 Content-Type: text/plain; charset="utf-8" Introduce a model of Xilinx Versal's Configuration Frame broadcast controller (CFRAME_BCAST_REG). Signed-off-by: Francisco Iglesias Reviewed-by: Peter Maydell --- hw/misc/xlnx-versal-cframe-reg.c | 161 +++++++++++++++++++++++ include/hw/misc/xlnx-versal-cframe-reg.h | 17 +++ 2 files changed, 178 insertions(+) diff --git a/hw/misc/xlnx-versal-cframe-reg.c b/hw/misc/xlnx-versal-cframe-= reg.c index 4c9afb184d..2ce62c1b2e 100644 --- a/hw/misc/xlnx-versal-cframe-reg.c +++ b/hw/misc/xlnx-versal-cframe-reg.c @@ -557,6 +557,83 @@ static const MemoryRegionOps cframe_reg_fdri_ops =3D { }, }; =20 +static uint64_t cframes_bcast_reg_read(void *opaque, hwaddr addr, unsigned= size) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unsupported read from addr=3D%" + HWADDR_PRIx "\n", __func__, addr); + return 0; +} + +static void cframes_bcast_write(XlnxVersalCFrameBcastReg *s, uint8_t reg_a= ddr, + uint32_t *wfifo) +{ + XlnxCfiPacket pkt =3D { + .reg_addr =3D reg_addr, + .data[0] =3D wfifo[0], + .data[1] =3D wfifo[1], + .data[2] =3D wfifo[2], + .data[3] =3D wfifo[3] + }; + + for (int i =3D 0; i < ARRAY_SIZE(s->cfg.cframe); i++) { + if (s->cfg.cframe[i]) { + xlnx_cfi_transfer_packet(s->cfg.cframe[i], &pkt); + } + } +} + +static void cframes_bcast_reg_write(void *opaque, hwaddr addr, uint64_t va= lue, + unsigned size) +{ + XlnxVersalCFrameBcastReg *s =3D XLNX_VERSAL_CFRAME_BCAST_REG(opaque); + uint32_t wfifo[WFIFO_SZ]; + + if (update_wfifo(addr, value, s->wfifo, wfifo)) { + uint8_t reg_addr =3D extract32(addr, 4, 6); + + cframes_bcast_write(s, reg_addr, wfifo); + } +} + +static uint64_t cframes_bcast_fdri_read(void *opaque, hwaddr addr, + unsigned size) +{ + qemu_log_mask(LOG_GUEST_ERROR, "%s: Unsupported read from addr=3D%" + HWADDR_PRIx "\n", __func__, addr); + return 0; +} + +static void cframes_bcast_fdri_write(void *opaque, hwaddr addr, uint64_t v= alue, + unsigned size) +{ + XlnxVersalCFrameBcastReg *s =3D XLNX_VERSAL_CFRAME_BCAST_REG(opaque); + uint32_t wfifo[WFIFO_SZ]; + + if (update_wfifo(addr, value, s->wfifo, wfifo)) { + cframes_bcast_write(s, CFRAME_FDRI, wfifo); + } +} + +static const MemoryRegionOps cframes_bcast_reg_reg_ops =3D { + .read =3D cframes_bcast_reg_read, + .write =3D cframes_bcast_reg_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + +static const MemoryRegionOps cframes_bcast_reg_fdri_ops =3D { + .read =3D cframes_bcast_fdri_read, + .write =3D cframes_bcast_fdri_write, + .endianness =3D DEVICE_LITTLE_ENDIAN, + .valid =3D { + .min_access_size =3D 4, + .max_access_size =3D 4, + }, +}; + static void cframe_reg_realize(DeviceState *dev, Error **errp) { XlnxVersalCFrameReg *s =3D XLNX_VERSAL_CFRAME_REG(dev); @@ -651,6 +728,71 @@ static Property cframe_regs_props[] =3D { DEFINE_PROP_END_OF_LIST(), }; =20 +static void cframe_bcast_reg_init(Object *obj) +{ + XlnxVersalCFrameBcastReg *s =3D XLNX_VERSAL_CFRAME_BCAST_REG(obj); + SysBusDevice *sbd =3D SYS_BUS_DEVICE(obj); + + memory_region_init_io(&s->iomem_reg, obj, &cframes_bcast_reg_reg_ops, = s, + TYPE_XLNX_VERSAL_CFRAME_BCAST_REG, KEYHOLE_STREA= M_4K); + memory_region_init_io(&s->iomem_fdri, obj, &cframes_bcast_reg_fdri_ops= , s, + TYPE_XLNX_VERSAL_CFRAME_BCAST_REG "-fdri", + KEYHOLE_STREAM_4K); + sysbus_init_mmio(sbd, &s->iomem_reg); + sysbus_init_mmio(sbd, &s->iomem_fdri); +} + +static void cframe_bcast_reg_reset_enter(Object *obj, ResetType type) +{ + XlnxVersalCFrameBcastReg *s =3D XLNX_VERSAL_CFRAME_BCAST_REG(obj); + + memset(s->wfifo, 0, WFIFO_SZ * sizeof(uint32_t)); +} + +static const VMStateDescription vmstate_cframe_bcast_reg =3D { + .name =3D TYPE_XLNX_VERSAL_CFRAME_BCAST_REG, + .version_id =3D 1, + .minimum_version_id =3D 1, + .fields =3D (VMStateField[]) { + VMSTATE_UINT32_ARRAY(wfifo, XlnxVersalCFrameBcastReg, 4), + VMSTATE_END_OF_LIST(), + } +}; + +static Property cframe_bcast_regs_props[] =3D { + DEFINE_PROP_LINK("cframe0", XlnxVersalCFrameBcastReg, cfg.cframe[0], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe1", XlnxVersalCFrameBcastReg, cfg.cframe[1], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe2", XlnxVersalCFrameBcastReg, cfg.cframe[2], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe3", XlnxVersalCFrameBcastReg, cfg.cframe[3], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe4", XlnxVersalCFrameBcastReg, cfg.cframe[4], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe5", XlnxVersalCFrameBcastReg, cfg.cframe[5], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe6", XlnxVersalCFrameBcastReg, cfg.cframe[6], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe7", XlnxVersalCFrameBcastReg, cfg.cframe[7], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe8", XlnxVersalCFrameBcastReg, cfg.cframe[8], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe9", XlnxVersalCFrameBcastReg, cfg.cframe[9], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe10", XlnxVersalCFrameBcastReg, cfg.cframe[10], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe11", XlnxVersalCFrameBcastReg, cfg.cframe[11], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe12", XlnxVersalCFrameBcastReg, cfg.cframe[12], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe13", XlnxVersalCFrameBcastReg, cfg.cframe[13], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_LINK("cframe14", XlnxVersalCFrameBcastReg, cfg.cframe[14], + TYPE_XLNX_CFI_IF, XlnxCfiIf *), + DEFINE_PROP_END_OF_LIST(), +}; + static void cframe_reg_class_init(ObjectClass *klass, void *data) { ResettableClass *rc =3D RESETTABLE_CLASS(klass); @@ -665,6 +807,16 @@ static void cframe_reg_class_init(ObjectClass *klass, = void *data) xcic->cfi_transfer_packet =3D cframe_reg_cfi_transfer_packet; } =20 +static void cframe_bcast_reg_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ResettableClass *rc =3D RESETTABLE_CLASS(klass); + + dc->vmsd =3D &vmstate_cframe_bcast_reg; + device_class_set_props(dc, cframe_bcast_regs_props); + rc->phases.enter =3D cframe_bcast_reg_reset_enter; +} + static const TypeInfo cframe_reg_info =3D { .name =3D TYPE_XLNX_VERSAL_CFRAME_REG, .parent =3D TYPE_SYS_BUS_DEVICE, @@ -677,9 +829,18 @@ static const TypeInfo cframe_reg_info =3D { } }; =20 +static const TypeInfo cframe_bcast_reg_info =3D { + .name =3D TYPE_XLNX_VERSAL_CFRAME_BCAST_REG, + .parent =3D TYPE_SYS_BUS_DEVICE, + .instance_size =3D sizeof(XlnxVersalCFrameBcastReg), + .class_init =3D cframe_bcast_reg_class_init, + .instance_init =3D cframe_bcast_reg_init, +}; + static void cframe_reg_register_types(void) { type_register_static(&cframe_reg_info); + type_register_static(&cframe_bcast_reg_info); } =20 type_init(cframe_reg_register_types) diff --git a/include/hw/misc/xlnx-versal-cframe-reg.h b/include/hw/misc/xln= x-versal-cframe-reg.h index f286d973bf..a14fbd7fe4 100644 --- a/include/hw/misc/xlnx-versal-cframe-reg.h +++ b/include/hw/misc/xlnx-versal-cframe-reg.h @@ -26,6 +26,10 @@ #define TYPE_XLNX_VERSAL_CFRAME_REG "xlnx,cframe-reg" OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFrameReg, XLNX_VERSAL_CFRAME_REG) =20 +#define TYPE_XLNX_VERSAL_CFRAME_BCAST_REG "xlnx.cframe-bcast-reg" +OBJECT_DECLARE_SIMPLE_TYPE(XlnxVersalCFrameBcastReg, + XLNX_VERSAL_CFRAME_BCAST_REG) + /* * The registers in this module are 128 bits wide but it is ok to write * and read them through 4 sequential 32 bit accesses (address[3:2] =3D 0, @@ -283,4 +287,17 @@ struct XlnxVersalCFrameReg { bool row_configured; }; =20 +struct XlnxVersalCFrameBcastReg { + SysBusDevice parent_obj; + MemoryRegion iomem_reg; + MemoryRegion iomem_fdri; + + /* 128-bit wfifo. */ + uint32_t wfifo[WFIFO_SZ]; + + struct { + XlnxCfiIf *cframe[15]; + } cfg; +}; + #endif --=20 2.34.1 From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902239; cv=pass; d=zohomail.com; s=zohoarc; b=SIzRMnd9GMQKBvF44K4jAmkCEM3gUOh3zc9beM/OB9G1E3A+Gbq+ukYaKGbFzUqkrBdk++YdloHqDkYVAs/4cB5VpQYfTXOx0uZP6Xe7ofOfO3GF0tx560sBkOJHtLAmBj46QTwEKmt9/1mIK8XyQr9ZwnsmzXmhJfraTPCOE8Y= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902239; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PQ+lddYVIVTyHUZJvwGaDUPTBiw80FboOA1+/NRIf+w=; b=m+1wcnSvk6uw0pOV8ALn7exmWZGqp+ZTY9kDmQfB+oepqui0MfwYasw5g0p0qzpZShHXzOI+DCpVEDfnbPQrQU7jK8qA3+onw7QfUFg7e0aC0D5HzH9qdwl97tpXkL+S/vVflOx6y4+0kQPcWrKRBJBZdRNTh5Wllt7zAOE5ESo= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692902239191749.5895052513748; Thu, 24 Aug 2023 11:37:19 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAy-00072z-QP; Thu, 24 Aug 2023 14:35:24 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAv-00070E-8X for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:21 -0400 Received: from mail-bn8nam12on2060f.outbound.protection.outlook.com ([2a01:111:f400:fe5b::60f] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAs-0007FB-Gb for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:21 -0400 Received: from CY5PR13CA0052.namprd13.prod.outlook.com (2603:10b6:930:11::34) by BN9PR12MB5322.namprd12.prod.outlook.com (2603:10b6:408:103::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 18:35:14 +0000 Received: from CY4PEPF0000EE37.namprd05.prod.outlook.com (2603:10b6:930:11:cafe::a7) by CY5PR13CA0052.outlook.office365.com (2603:10b6:930:11::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.14 via Frontend Transport; Thu, 24 Aug 2023 18:35:13 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by CY4PEPF0000EE37.mail.protection.outlook.com (10.167.242.43) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6699.15 via Frontend Transport; Thu, 24 Aug 2023 18:35:13 +0000 Received: from SATLEXMB05.amd.com (10.181.40.146) 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.2507.27; Thu, 24 Aug 2023 13:35:05 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB05.amd.com (10.181.40.146) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 13:35:05 -0500 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:35:03 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=VJZPTDMIBfIzfX02Hh2Yy743IRVBKLRkqzO1hpppAk/uF/JwRK+H4VLl9R9BYIF3IsGhThuFjSryn+z6Og7Zmf/GtzKj6nTbcT4hG9YB2ed9GXdlAr25NYNBA/GOtju+fSy7ZXbghEOpD+U15jMC7PcmCzwb6HpB3eH/QcsFBnXTg+adGOv+zhga0laH6XidEtZVOdS96axj6HgalzP52jZ6BB0gbLXVqa/VGjCXzt/Hy89yea92vbCrPEuYDeBYhkgM2CZ86Hpc8OpYtxpcshKPTAtX7/PM6L2q+JvISSr37UELVYZAejcQ4K7yjWMdQLVXY2TphcuWhJS7B94/2A== 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=PQ+lddYVIVTyHUZJvwGaDUPTBiw80FboOA1+/NRIf+w=; b=iYqqZeKx9b8OwRAVLw9+bzGb1dEVz2xCsKFzDkHsgB2za6iJ0Ay4IlRC9si6F3E3FbnON2s2CoXYForZORVSbvDbquIY5UkQbwg9W2NqtFZI0at970w67EKYbVUgNvKzQSJzY3ovMapszFoYvyN95av7MZ2cEHR2Yl75hw6FnQYC9FnHCUPz6Xt+SFhKER4cq7n6r/o/4d5BvSgLX/zCzrVEXH7dXuKthMTM45JFm3/cLAVJSdP1yoKmTvSUpKv1lbCyXoz2idTfT9nCp62Ke48p+PN4SAzqJW82IMxiA5Z2Nd5gzmjdXiBp2CGgZniXL468LvlfJ4GZ0prAbhanJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=PQ+lddYVIVTyHUZJvwGaDUPTBiw80FboOA1+/NRIf+w=; b=Mbwk68xLEH/G6rlPykiGzGahIJ5TYfWbRNIiQtgPd4MEGG1cpUl6oQZlkMiSY54UbmedKQ0xtKhuSBM+CyNHvMFaIq/lYFG/J67fLEYZMKKaDzUTbpz6JSS4IWW06c82qt0as7u1oQXRB5+/4vwN/GyWEJPZHGgMIAi1RKjT2bw= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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 From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 7/8] hw/arm/xlnx-versal: Connect the CFU_APB, CFU_FDRO and CFU_SFR Date: Thu, 24 Aug 2023 20:34:47 +0200 Message-ID: <20230824183448.151738-8-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CY4PEPF0000EE37:EE_|BN9PR12MB5322:EE_ X-MS-Office365-Filtering-Correlation-Id: 128eed48-fd42-4d99-460b-08dba4d0db13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aD7INbRi6WiJtZ9LFUESSPcYF3R77OCxz7na82e1JhWQAAS446x8Kj4ZSRZemrUxQdJeki8BKgkRxA2zvORrC/IjGpiWo2YG9mOmceBYVaekYMKUmoheRsroNbKABwvKfDUYx+vh8rBkfBF6rHQk96lbwhknJhQa41TO9oZSrw5YSRnjClQf+6z3ZD43R1VCyBQmOZE1TRmHVnecR3260DUqt0sA2adwiqf2slGM6vqsl4n1d4XOuqBbqp4sgBucupivH3RF5vwf3toigQCgRhk4i6LaU0RSBONFIw8mj25Q+z6idZIiHJ7Fe33ygQesMS9pTCldSDJhuHo+5I2CrlliZrOzDs6Yono6fDTeS8rBzvwIgmDS8kPYVX6YfnBkn3mCEOT6xLx8d8kRQe78DlU2yox/gZaI4R0DKkQloz8kc8yC4ZEqFlN66MSf4R/6Aiv3GyiKJ0JNH2u9BjfY4rdZe0ICTea1YYCPw66VNkJ9NNIK1NtvtP9FpudtiNjsZPyS1hv5hYs1Dk6AXJDu2kNiMAhd9vrVoINCQAExq54g/ZYPklCVoMiagbgwd+/P5/7QdoJDQKEyBo9/nIgrajwsBA9eb/O/5QMbTXFkgQGsPo83pUrSwdh4YC5g8QKXvhqAf5TpM3iuWNNFEwUev8LHw0mMGn/pNSSUIDXobrtDiua8yoriXftMvedwU2eLkXeE9kh9yYqU+Ki1gsYBP6/C2KtGWBCFPtqYxjpYXKupU832Yl2nlCoqDNwnrUIS/A5cvMU1fCWeQmRBFODc8g== 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:(13230031)(4636009)(346002)(136003)(396003)(39860400002)(376002)(451199024)(82310400011)(186009)(1800799009)(40470700004)(36840700001)(46966006)(54906003)(70206006)(70586007)(316002)(6916009)(478600001)(26005)(36860700001)(44832011)(356005)(6666004)(40480700001)(82740400003)(81166007)(41300700001)(86362001)(2906002)(8936002)(8676002)(4326008)(1076003)(40460700003)(2616005)(5660300002)(36756003)(336012)(47076005)(426003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:35:13.7277 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 128eed48-fd42-4d99-460b-08dba4d0db13 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: CY4PEPF0000EE37.namprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN9PR12MB5322 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::60f; envelope-from=francisco.iglesias@amd.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902240614100003 Content-Type: text/plain; charset="utf-8" Connect the Configuration Frame Unit (CFU_APB, CFU_FDRO and CFU_SFR) to the Versal machine. Signed-off-by: Francisco Iglesias Acked-by: Edgar E. Iglesias Reviewed-by: Peter Maydell --- hw/arm/xlnx-versal.c | 42 ++++++++++++++++++++++++++++++++++++ include/hw/arm/xlnx-versal.h | 16 ++++++++++++++ 2 files changed, 58 insertions(+) diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c index 60bf5fe657..3f4b4b1560 100644 --- a/hw/arm/xlnx-versal.c +++ b/hw/arm/xlnx-versal.c @@ -570,6 +570,47 @@ static void versal_create_ospi(Versal *s, qemu_irq *pi= c) qdev_connect_gpio_out(orgate, 0, pic[VERSAL_OSPI_IRQ]); } =20 +static void versal_create_cfu(Versal *s, qemu_irq *pic) +{ + SysBusDevice *sbd; + + /* CFU FDRO */ + object_initialize_child(OBJECT(s), "cfu-fdro", &s->pmc.cfu_fdro, + TYPE_XLNX_VERSAL_CFU_FDRO); + sbd =3D SYS_BUS_DEVICE(&s->pmc.cfu_fdro); + + sysbus_realize(sbd, &error_fatal); + memory_region_add_subregion(&s->mr_ps, MM_PMC_CFU_FDRO, + sysbus_mmio_get_region(sbd, 0)); + + /* CFU APB */ + object_initialize_child(OBJECT(s), "cfu-apb", &s->pmc.cfu_apb, + TYPE_XLNX_VERSAL_CFU_APB); + sbd =3D SYS_BUS_DEVICE(&s->pmc.cfu_apb); + + sysbus_realize(sbd, &error_fatal); + memory_region_add_subregion(&s->mr_ps, MM_PMC_CFU_APB, + sysbus_mmio_get_region(sbd, 0)); + memory_region_add_subregion(&s->mr_ps, MM_PMC_CFU_STREAM, + sysbus_mmio_get_region(sbd, 1)); + memory_region_add_subregion(&s->mr_ps, MM_PMC_CFU_STREAM_2, + sysbus_mmio_get_region(sbd, 2)); + sysbus_connect_irq(sbd, 0, pic[VERSAL_CFU_IRQ_0]); + + /* CFU SFR */ + object_initialize_child(OBJECT(s), "cfu-sfr", &s->pmc.cfu_sfr, + TYPE_XLNX_VERSAL_CFU_SFR); + + sbd =3D SYS_BUS_DEVICE(&s->pmc.cfu_sfr); + + object_property_set_link(OBJECT(&s->pmc.cfu_sfr), + "cfu", OBJECT(&s->pmc.cfu_apb), &error_abort); + + sysbus_realize(sbd, &error_fatal); + memory_region_add_subregion(&s->mr_ps, MM_PMC_CFU_SFR, + sysbus_mmio_get_region(sbd, 0)); +} + static void versal_create_crl(Versal *s, qemu_irq *pic) { SysBusDevice *sbd; @@ -763,6 +804,7 @@ static void versal_realize(DeviceState *dev, Error **er= rp) versal_create_pmc_iou_slcr(s, pic); versal_create_ospi(s, pic); versal_create_crl(s, pic); + versal_create_cfu(s, pic); versal_map_ddr(s); versal_unimp(s); =20 diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h index 39ee31185c..29b9c60301 100644 --- a/include/hw/arm/xlnx-versal.h +++ b/include/hw/arm/xlnx-versal.h @@ -32,6 +32,7 @@ #include "hw/misc/xlnx-versal-crl.h" #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/net/xlnx-versal-canfd.h" +#include "hw/misc/xlnx-versal-cfu.h" =20 #define TYPE_XLNX_VERSAL "xlnx-versal" OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) @@ -117,6 +118,9 @@ struct Versal { XlnxEFuse efuse; XlnxVersalEFuseCtrl efuse_ctrl; XlnxVersalEFuseCache efuse_cache; + XlnxVersalCFUAPB cfu_apb; + XlnxVersalCFUFDRO cfu_fdro; + XlnxVersalCFUSFR cfu_sfr; =20 OrIRQState apb_irq_orgate; } pmc; @@ -147,6 +151,7 @@ struct Versal { #define VERSAL_GEM1_WAKE_IRQ_0 59 #define VERSAL_ADMA_IRQ_0 60 #define VERSAL_XRAM_IRQ_0 79 +#define VERSAL_CFU_IRQ_0 120 #define VERSAL_PMC_APB_IRQ 121 #define VERSAL_OSPI_IRQ 124 #define VERSAL_SD0_IRQ_0 126 @@ -240,6 +245,17 @@ struct Versal { #define MM_PMC_EFUSE_CACHE 0xf1250000 #define MM_PMC_EFUSE_CACHE_SIZE 0x00C00 =20 +#define MM_PMC_CFU_APB 0xf12b0000 +#define MM_PMC_CFU_APB_SIZE 0x10000 +#define MM_PMC_CFU_STREAM 0xf12c0000 +#define MM_PMC_CFU_STREAM_SIZE 0x1000 +#define MM_PMC_CFU_SFR 0xf12c1000 +#define MM_PMC_CFU_SFR_SIZE 0x1000 +#define MM_PMC_CFU_FDRO 0xf12c2000 +#define MM_PMC_CFU_FDRO_SIZE 0x1000 +#define MM_PMC_CFU_STREAM_2 0xf1f80000 +#define MM_PMC_CFU_STREAM_2_SIZE 0x40000 + #define MM_PMC_CRP 0xf1260000U #define MM_PMC_CRP_SIZE 0x10000 #define MM_PMC_RTC 0xf12a0000 --=20 2.34.1 From nobody Thu Nov 28 08:31:33 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass(p=quarantine dis=none) header.from=amd.com ARC-Seal: i=2; a=rsa-sha256; t=1692902172; cv=pass; d=zohomail.com; s=zohoarc; b=D27fD0qCmMqZZICBYRn7/i0ybp8thbkU14TJ5hndttGjWUCsPVhmDxOCMtN5haMSI8uI3R0FEQ97NQ45s8YInM0rdknedXMGEzPkjEpgUeqg9md7rrlAMENliby024IBpa6pdbJS2kyVpEQGTuFwJkIcWejyiGzUKe6wMJM/4og= ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1692902172; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wG3Tv2m3grnATlhKb6xXipJorZEirfPz5WweItlp1io=; b=ZLmtvvGqJHTSv+MIpXpmIC4NgGo+ujBwwsyOFK0MCNmXKwAp0j59ttaPv9Jfh2GAW4Na26ezWZFdncy2xR+LN1LEXyz2ji+EM0IzqGLyZ73cE0egAJS1SILCsjbkYQddiuXtYNYGmP0/yZukewEIjN3p7oiGTUx3qvZqr/HVtxg= ARC-Authentication-Results: i=2; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; arc=pass (i=1 dmarc=pass fromdomain=amd.com); dmarc=pass header.from= (p=quarantine dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1692902172433682.5199944470301; Thu, 24 Aug 2023 11:36:12 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qZFAq-0006zP-Ao; Thu, 24 Aug 2023 14:35:16 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAp-0006zG-LL for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:15 -0400 Received: from mail-bn8nam12on20628.outbound.protection.outlook.com ([2a01:111:f400:fe5b::628] helo=NAM12-BN8-obe.outbound.protection.outlook.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qZFAm-0007D7-Co for qemu-devel@nongnu.org; Thu, 24 Aug 2023 14:35:15 -0400 Received: from DS7PR03CA0174.namprd03.prod.outlook.com (2603:10b6:5:3b2::29) by DS7PR12MB8347.namprd12.prod.outlook.com (2603:10b6:8:e5::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27; Thu, 24 Aug 2023 18:35:09 +0000 Received: from CO1PEPF000044F9.namprd21.prod.outlook.com (2603:10b6:5:3b2:cafe::f3) by DS7PR03CA0174.outlook.office365.com (2603:10b6:5:3b2::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6699.27 via Frontend Transport; Thu, 24 Aug 2023 18:35:08 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by CO1PEPF000044F9.mail.protection.outlook.com (10.167.241.199) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6745.2 via Frontend Transport; Thu, 24 Aug 2023 18:35:08 +0000 Received: from SATLEXMB08.amd.com (10.181.40.132) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 13:35:07 -0500 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB08.amd.com (10.181.40.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.27; Thu, 24 Aug 2023 11:35:07 -0700 Received: from localhost.localdomain (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2507.27 via Frontend Transport; Thu, 24 Aug 2023 13:35:05 -0500 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=W2yrq53gtCMFchNK/e9JScj4aVDSnm08OCLR7BOaxEonbCvnO1LuBtDeaKRNB1t47d3SmMCZthFTXQsaA6Rl1aY5YRB/F2FaXRygW2vd1CfBXvotQMy9tEkqaRGbUXiI9UqQ57fZHJM57lTNQxXerWsXgykwc5+BUMPxQi5HIGJkcRgqcC47x+XMdE7x1byUufH/CuaKxr0KxEEKxzgDEpUdjjbp1rj5QtV2QzU7U6BAb5Dts9TQdAnFdiYtPtfLEivgSjdaeAYVBWoOsmjqd/pFpvD4M5xNKZBphQc5wVY+/CXi7X2p5L18XXNkZh7Y5kR5ROgH4gIg0EfUM1y9FA== 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=wG3Tv2m3grnATlhKb6xXipJorZEirfPz5WweItlp1io=; b=ajKv8tpgoWs1bWsGIp9wFgYJ64tGmUrHNNPZgkCwX8mWlB4TrSulWnJsD5di7iJL+4+U8FkOjDvB1t61d7906oq/RNTuqLKM1HrkfBbNr8jZlDRdBE24rV/HUZOkpuerJa2CzTFRN14OljkFIWkvsTBCk7N2ADcu60rcYL+3oqtbS4eJuvIsyAZVKKOiNibiBCant/j9jjVVe0R3ovAIJjxwJWS61tsBRaAZHM2qTlSeEjW++IUyEnIfmcdCLx8BfIsnBolPqdmWtr1mDKe8INtMZ62cZvef1j9aBi3DI45eahjY771SuvRKhmb4Xpbec8acLa6Ez+E6Ujf8V+ho1g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=nongnu.org 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=wG3Tv2m3grnATlhKb6xXipJorZEirfPz5WweItlp1io=; b=NXxN1Cptw7G8wdQ+thmseYQf9imUzeo+lJwmeBWwdjoHaDAUqhuy4NCfUZ3V6RGTiT/nf6tP/w45wYgBdav2WhrI/Pb5kYnCw7qGZ0/Bbb1ToGlPYAlPoVEfN0x57wG8eycopMIgU+bblMT2A26zgUf2pWEJXYqmsAM1uMYilWg= 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 (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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=SATLEXMB03.amd.com; pr=C From: Francisco Iglesias To: CC: , , , , , , , Subject: [PATCH v3 8/8] hw/arm/versal: Connect the CFRAME_REG and CFRAME_BCAST_REG Date: Thu, 24 Aug 2023 20:34:48 +0200 Message-ID: <20230824183448.151738-9-francisco.iglesias@amd.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230824183448.151738-1-francisco.iglesias@amd.com> References: <20230824183448.151738-1-francisco.iglesias@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: CO1PEPF000044F9:EE_|DS7PR12MB8347:EE_ X-MS-Office365-Filtering-Correlation-Id: c3f9b5c2-8326-408a-623e-08dba4d0d804 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EzJCjjagkAsOp0z7AMc8AkEWN9ubqTkGwU0FJEYW7DHU4SUEgm7L7W9HOrH825fHzAvPx2f4N18Wl14o69SNrKzYe37e+PJWdUgHKUa4kig/qidIwsOfFAH/fCAFOmbneWMW6q2ymE8Sr26kAWvZF5RO54wESRe3pfEO7D3VQs1SHsSoVPegxsNVGC0y3wV0iqs4qoQeDA7HgKzTqwWLOlD+hlsYErytW8svNi4E9v+sZ3ZNgcQ7Te+5HGaMSOq/Wvt6Ewa87Kf700d0wRfjC33zVZAvjAPjZRYwHd6unqnvkbgsLjtZrVCGkIXyHVIp/YWYawcJ2mm6lLVS5blheN8HWQeNbc9oDNJPsxZHxTje30XnGextnEVyKdQKjpIDuaUG1wk695YVMQrMeHkGZlEtpRTQsbzPR41E927UeB2ikkLHLRPw6mcfF1OPyeqUFzD9q+pIfSLXw1Xb0s/CvexaaZKxZwkXojs1MTa+k/RjAENTkl6/HEnIGBb1yhwPqwJtvMSiVHg5PpAhMGw0hUyv/E8DTuneD65xZdcOEhGd23u0lUSuzATyJ0HjUnghFbwZYTz/IIajbW8dUpdB5E1hmAbamxRQmj2nrzIx77yAPyCvskznNvO5+m4ib7AdRiGe2qchu5d0xhMiVjcC5b4P28SL77lerWhViw5Tblf0zGTx7ED8rzdyOHTYmOUUflLocEhr0HPh36I9htOfe/pX1SR8nolZxY/WiNbqt2jt+5eoa2EH7Nlgf+48z07n5g3UTqg0NeEN5L3KMVn8fQ== X-Forefront-Antispam-Report: CIP:165.204.84.17; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:SATLEXMB03.amd.com; PTR:InfoDomainNonexistent; CAT:NONE; SFS:(13230031)(4636009)(346002)(136003)(396003)(39860400002)(376002)(451199024)(82310400011)(186009)(1800799009)(40470700004)(36840700001)(46966006)(54906003)(70206006)(70586007)(316002)(6916009)(478600001)(26005)(36860700001)(44832011)(356005)(6666004)(40480700001)(82740400003)(81166007)(41300700001)(86362001)(2906002)(8936002)(8676002)(4326008)(1076003)(40460700003)(2616005)(5660300002)(83380400001)(36756003)(336012)(47076005)(426003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Aug 2023 18:35:08.5969 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c3f9b5c2-8326-408a-623e-08dba4d0d804 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: CO1PEPF000044F9.namprd21.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DS7PR12MB8347 Received-SPF: softfail client-ip=2a01:111:f400:fe5b::628; envelope-from=francisco.iglesias@amd.com; helo=NAM12-BN8-obe.outbound.protection.outlook.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @amd.com) X-ZM-MESSAGEID: 1692902174371100006 Content-Type: text/plain; charset="utf-8" Connect the Configuration Frame controller (CFRAME_REG) and the Configuration Frame broadcast controller (CFRAME_BCAST_REG) to the Versal machine. Signed-off-by: Francisco Iglesias Reviewed-by: Peter Maydell --- hw/arm/xlnx-versal.c | 113 ++++++++++++++++++++++++++++++++++- include/hw/arm/xlnx-versal.h | 69 +++++++++++++++++++++ 2 files changed, 181 insertions(+), 1 deletion(-) diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c index 3f4b4b1560..fa556d8764 100644 --- a/hw/arm/xlnx-versal.c +++ b/hw/arm/xlnx-versal.c @@ -27,7 +27,7 @@ #define XLNX_VERSAL_RCPU_TYPE ARM_CPU_TYPE_NAME("cortex-r5f") #define GEM_REVISION 0x40070106 =20 -#define VERSAL_NUM_PMC_APB_IRQS 3 +#define VERSAL_NUM_PMC_APB_IRQS 18 #define NUM_OSPI_IRQ_LINES 3 =20 static void versal_create_apu_cpus(Versal *s) @@ -341,6 +341,7 @@ static void versal_create_pmc_apb_irq_orgate(Versal *s,= qemu_irq *pic) * - RTC * - BBRAM * - PMC SLCR + * - CFRAME regs (input 3 - 17 to the orgate) */ object_initialize_child(OBJECT(s), "pmc-apb-irq-orgate", &s->pmc.apb_irq_orgate, TYPE_OR_IRQ); @@ -573,6 +574,42 @@ static void versal_create_ospi(Versal *s, qemu_irq *pi= c) static void versal_create_cfu(Versal *s, qemu_irq *pic) { SysBusDevice *sbd; + DeviceState *dev; + int i; + const struct { + uint64_t reg_base; + uint64_t fdri_base; + } cframe_addr[] =3D { + { MM_PMC_CFRAME0_REG, MM_PMC_CFRAME0_FDRI }, + { MM_PMC_CFRAME1_REG, MM_PMC_CFRAME1_FDRI }, + { MM_PMC_CFRAME2_REG, MM_PMC_CFRAME2_FDRI }, + { MM_PMC_CFRAME3_REG, MM_PMC_CFRAME3_FDRI }, + { MM_PMC_CFRAME4_REG, MM_PMC_CFRAME4_FDRI }, + { MM_PMC_CFRAME5_REG, MM_PMC_CFRAME5_FDRI }, + { MM_PMC_CFRAME6_REG, MM_PMC_CFRAME6_FDRI }, + { MM_PMC_CFRAME7_REG, MM_PMC_CFRAME7_FDRI }, + { MM_PMC_CFRAME8_REG, MM_PMC_CFRAME8_FDRI }, + { MM_PMC_CFRAME9_REG, MM_PMC_CFRAME9_FDRI }, + { MM_PMC_CFRAME10_REG, MM_PMC_CFRAME10_FDRI }, + { MM_PMC_CFRAME11_REG, MM_PMC_CFRAME11_FDRI }, + { MM_PMC_CFRAME12_REG, MM_PMC_CFRAME12_FDRI }, + { MM_PMC_CFRAME13_REG, MM_PMC_CFRAME13_FDRI }, + { MM_PMC_CFRAME14_REG, MM_PMC_CFRAME14_FDRI }, + }; + const struct { + uint32_t blktype0_frames; + uint32_t blktype1_frames; + uint32_t blktype2_frames; + uint32_t blktype3_frames; + uint32_t blktype4_frames; + uint32_t blktype5_frames; + uint32_t blktype6_frames; + } cframe_cfg[] =3D { + [0] =3D { 34111, 3528, 12800, 11, 5, 1, 1 }, + [1] =3D { 38498, 3841, 15361, 13, 7, 3, 1 }, + [2] =3D { 38498, 3841, 15361, 13, 7, 3, 1 }, + [3] =3D { 38498, 3841, 15361, 13, 7, 3, 1 }, + }; =20 /* CFU FDRO */ object_initialize_child(OBJECT(s), "cfu-fdro", &s->pmc.cfu_fdro, @@ -583,10 +620,84 @@ static void versal_create_cfu(Versal *s, qemu_irq *pi= c) memory_region_add_subregion(&s->mr_ps, MM_PMC_CFU_FDRO, sysbus_mmio_get_region(sbd, 0)); =20 + /* CFRAME REG */ + for (i =3D 0; i < ARRAY_SIZE(s->pmc.cframe); i++) { + g_autofree char *name =3D g_strdup_printf("cframe%d", i); + + object_initialize_child(OBJECT(s), name, &s->pmc.cframe[i], + TYPE_XLNX_VERSAL_CFRAME_REG); + + sbd =3D SYS_BUS_DEVICE(&s->pmc.cframe[i]); + dev =3D DEVICE(&s->pmc.cframe[i]); + + if (i < ARRAY_SIZE(cframe_cfg)) { + object_property_set_int(OBJECT(dev), "blktype0-frames", + cframe_cfg[i].blktype0_frames, + &error_abort); + object_property_set_int(OBJECT(dev), "blktype1-frames", + cframe_cfg[i].blktype1_frames, + &error_abort); + object_property_set_int(OBJECT(dev), "blktype2-frames", + cframe_cfg[i].blktype2_frames, + &error_abort); + object_property_set_int(OBJECT(dev), "blktype3-frames", + cframe_cfg[i].blktype3_frames, + &error_abort); + object_property_set_int(OBJECT(dev), "blktype4-frames", + cframe_cfg[i].blktype4_frames, + &error_abort); + object_property_set_int(OBJECT(dev), "blktype5-frames", + cframe_cfg[i].blktype5_frames, + &error_abort); + object_property_set_int(OBJECT(dev), "blktype6-frames", + cframe_cfg[i].blktype6_frames, + &error_abort); + } + object_property_set_link(OBJECT(dev), "cfu-fdro", + OBJECT(&s->pmc.cfu_fdro), &error_fatal); + + sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); + + memory_region_add_subregion(&s->mr_ps, cframe_addr[i].reg_base, + sysbus_mmio_get_region(sbd, 0)); + memory_region_add_subregion(&s->mr_ps, cframe_addr[i].fdri_base, + sysbus_mmio_get_region(sbd, 1)); + sysbus_connect_irq(sbd, 0, + qdev_get_gpio_in(DEVICE(&s->pmc.apb_irq_orgate), + 3 + i)); + } + + /* CFRAME BCAST */ + object_initialize_child(OBJECT(s), "cframe_bcast", &s->pmc.cframe_bcas= t, + TYPE_XLNX_VERSAL_CFRAME_BCAST_REG); + + sbd =3D SYS_BUS_DEVICE(&s->pmc.cframe_bcast); + dev =3D DEVICE(&s->pmc.cframe_bcast); + + for (i =3D 0; i < ARRAY_SIZE(s->pmc.cframe); i++) { + g_autofree char *propname =3D g_strdup_printf("cframe%d", i); + object_property_set_link(OBJECT(dev), propname, + OBJECT(&s->pmc.cframe[i]), &error_fatal); + } + + sysbus_realize(sbd, &error_fatal); + + memory_region_add_subregion(&s->mr_ps, MM_PMC_CFRAME_BCAST_REG, + sysbus_mmio_get_region(sbd, 0)); + memory_region_add_subregion(&s->mr_ps, MM_PMC_CFRAME_BCAST_FDRI, + sysbus_mmio_get_region(sbd, 1)); + /* CFU APB */ object_initialize_child(OBJECT(s), "cfu-apb", &s->pmc.cfu_apb, TYPE_XLNX_VERSAL_CFU_APB); sbd =3D SYS_BUS_DEVICE(&s->pmc.cfu_apb); + dev =3D DEVICE(&s->pmc.cfu_apb); + + for (i =3D 0; i < ARRAY_SIZE(s->pmc.cframe); i++) { + g_autofree char *propname =3D g_strdup_printf("cframe%d", i); + object_property_set_link(OBJECT(dev), propname, + OBJECT(&s->pmc.cframe[i]), &error_fatal); + } =20 sysbus_realize(sbd, &error_fatal); memory_region_add_subregion(&s->mr_ps, MM_PMC_CFU_APB, diff --git a/include/hw/arm/xlnx-versal.h b/include/hw/arm/xlnx-versal.h index 29b9c60301..7b419f88c2 100644 --- a/include/hw/arm/xlnx-versal.h +++ b/include/hw/arm/xlnx-versal.h @@ -33,6 +33,7 @@ #include "hw/misc/xlnx-versal-pmc-iou-slcr.h" #include "hw/net/xlnx-versal-canfd.h" #include "hw/misc/xlnx-versal-cfu.h" +#include "hw/misc/xlnx-versal-cframe-reg.h" =20 #define TYPE_XLNX_VERSAL "xlnx-versal" OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) @@ -47,6 +48,7 @@ OBJECT_DECLARE_SIMPLE_TYPE(Versal, XLNX_VERSAL) #define XLNX_VERSAL_NR_IRQS 192 #define XLNX_VERSAL_NR_CANFD 2 #define XLNX_VERSAL_CANFD_REF_CLK (24 * 1000 * 1000) +#define XLNX_VERSAL_NR_CFRAME 15 =20 struct Versal { /*< private >*/ @@ -121,6 +123,8 @@ struct Versal { XlnxVersalCFUAPB cfu_apb; XlnxVersalCFUFDRO cfu_fdro; XlnxVersalCFUSFR cfu_sfr; + XlnxVersalCFrameReg cframe[XLNX_VERSAL_NR_CFRAME]; + XlnxVersalCFrameBcastReg cframe_bcast; =20 OrIRQState apb_irq_orgate; } pmc; @@ -256,6 +260,71 @@ struct Versal { #define MM_PMC_CFU_STREAM_2 0xf1f80000 #define MM_PMC_CFU_STREAM_2_SIZE 0x40000 =20 +#define MM_PMC_CFRAME0_REG 0xf12d0000 +#define MM_PMC_CFRAME0_REG_SIZE 0x1000 +#define MM_PMC_CFRAME0_FDRI 0xf12d1000 +#define MM_PMC_CFRAME0_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME1_REG 0xf12d2000 +#define MM_PMC_CFRAME1_REG_SIZE 0x1000 +#define MM_PMC_CFRAME1_FDRI 0xf12d3000 +#define MM_PMC_CFRAME1_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME2_REG 0xf12d4000 +#define MM_PMC_CFRAME2_REG_SIZE 0x1000 +#define MM_PMC_CFRAME2_FDRI 0xf12d5000 +#define MM_PMC_CFRAME2_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME3_REG 0xf12d6000 +#define MM_PMC_CFRAME3_REG_SIZE 0x1000 +#define MM_PMC_CFRAME3_FDRI 0xf12d7000 +#define MM_PMC_CFRAME3_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME4_REG 0xf12d8000 +#define MM_PMC_CFRAME4_REG_SIZE 0x1000 +#define MM_PMC_CFRAME4_FDRI 0xf12d9000 +#define MM_PMC_CFRAME4_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME5_REG 0xf12da000 +#define MM_PMC_CFRAME5_REG_SIZE 0x1000 +#define MM_PMC_CFRAME5_FDRI 0xf12db000 +#define MM_PMC_CFRAME5_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME6_REG 0xf12dc000 +#define MM_PMC_CFRAME6_REG_SIZE 0x1000 +#define MM_PMC_CFRAME6_FDRI 0xf12dd000 +#define MM_PMC_CFRAME6_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME7_REG 0xf12de000 +#define MM_PMC_CFRAME7_REG_SIZE 0x1000 +#define MM_PMC_CFRAME7_FDRI 0xf12df000 +#define MM_PMC_CFRAME7_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME8_REG 0xf12e0000 +#define MM_PMC_CFRAME8_REG_SIZE 0x1000 +#define MM_PMC_CFRAME8_FDRI 0xf12e1000 +#define MM_PMC_CFRAME8_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME9_REG 0xf12e2000 +#define MM_PMC_CFRAME9_REG_SIZE 0x1000 +#define MM_PMC_CFRAME9_FDRI 0xf12e3000 +#define MM_PMC_CFRAME9_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME10_REG 0xf12e4000 +#define MM_PMC_CFRAME10_REG_SIZE 0x1000 +#define MM_PMC_CFRAME10_FDRI 0xf12e5000 +#define MM_PMC_CFRAME10_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME11_REG 0xf12e6000 +#define MM_PMC_CFRAME11_REG_SIZE 0x1000 +#define MM_PMC_CFRAME11_FDRI 0xf12e7000 +#define MM_PMC_CFRAME11_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME12_REG 0xf12e8000 +#define MM_PMC_CFRAME12_REG_SIZE 0x1000 +#define MM_PMC_CFRAME12_FDRI 0xf12e9000 +#define MM_PMC_CFRAME12_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME13_REG 0xf12ea000 +#define MM_PMC_CFRAME13_REG_SIZE 0x1000 +#define MM_PMC_CFRAME13_FDRI 0xf12eb000 +#define MM_PMC_CFRAME13_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME14_REG 0xf12ec000 +#define MM_PMC_CFRAME14_REG_SIZE 0x1000 +#define MM_PMC_CFRAME14_FDRI 0xf12ed000 +#define MM_PMC_CFRAME14_FDRI_SIZE 0x1000 +#define MM_PMC_CFRAME_BCAST_REG 0xf12ee000 +#define MM_PMC_CFRAME_BCAST_REG_SIZE 0x1000 +#define MM_PMC_CFRAME_BCAST_FDRI 0xf12ef000 +#define MM_PMC_CFRAME_BCAST_FDRI_SIZE 0x1000 + #define MM_PMC_CRP 0xf1260000U #define MM_PMC_CRP_SIZE 0x10000 #define MM_PMC_RTC 0xf12a0000 --=20 2.34.1