From patchwork Fri Sep 8 17:05:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 720842 Delivered-To: patch@linaro.org Received: by 2002:adf:eec5:0:b0:31d:da82:a3b4 with SMTP id a5csp884220wrp; Fri, 8 Sep 2023 10:08:24 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEuJsdgCn9E1t/041RcW3EyfLHsPFF6KrMnOIoLYMrKqsQ3sQlD/U8rBnqV3VTkLNwPu86M X-Received: by 2002:a0c:a789:0:b0:637:10b1:b2c6 with SMTP id v9-20020a0ca789000000b0063710b1b2c6mr2395808qva.44.1694192904592; Fri, 08 Sep 2023 10:08:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1694192904; cv=none; d=google.com; s=arc-20160816; b=AhZ+rqI/sAD7zPUbX1M/nhmaxUFAevI4gD8bKStsO5nFMxJsED8IQ6Q4YpeQZHgmSv sVjRR4XvHjxCkPstuIzNBsmoTzkPLLLnnuaRHXkchFCpytUH1Y7OOcxdpL4tJxZAqU/G 7SKn/AxZPA9FYROnn7eTkMH+WVkE9SHQ0JJi4neyt2JqyjZ2T+JWkDRSh05zNvBqjzhb aL+yHjWeIUBNEYYV3bJxsgMMYycho2If+1GS8ebmFwKAM2I3Cnl+60NhMX1y2+LTd6G+ ULfDtDT8Ho7YVUw1it4maXnnfo8oNgHHpWEteONCsGRbRWHJABYdgbqtqXmpxrj6kOAh AUgg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=SgO+kR/KocImJn/Mxs6WaAtmexrHy0cJRdZfhaYRW4w=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=bF2Ih94UsJ4I2woakT8PZzRYYQqscD0iwgqMxe9ulqLbUPK3U5t7naHSK/wwpRxbLK hykT6eah7w2/8Y6DIoksOosC50eot0UC5SmInAuKCI1Jzef+tpk3OS8iSbLUYRNyxt0+ KyFm+ci5WEE68eF/hsZPbjPYG1VnQDk/w8iMyfY8JTHSVmtyjBDjLCIAEOQO7qbvZEoj Pr1KI5NJSed5wksYm5+hOW95QxEJ8DF7kO1+rqWv12iHmozz6YCuG1tEcnquO/2BzNrn Y9hhtbjT12SvWdhcif50q4KRvvEm4rQcqguYjDU5TgLYLlRu2OREitz/JbEc9bB6iwC+ rB8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GfhTmL4i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h3-20020a0cf403000000b0064df3c750b2si1310400qvl.335.2023.09.08.10.08.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Fri, 08 Sep 2023 10:08:24 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=GfhTmL4i; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qeevx-00059Z-DL; Fri, 08 Sep 2023 13:06:17 -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 1qeevv-000549-M6 for qemu-devel@nongnu.org; Fri, 08 Sep 2023 13:06:15 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qeevn-000181-KT for qemu-devel@nongnu.org; Fri, 08 Sep 2023 13:06:15 -0400 Received: by mail-wm1-x329.google.com with SMTP id 5b1f17b1804b1-401d10e3e54so24376795e9.2 for ; Fri, 08 Sep 2023 10:06:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1694192765; x=1694797565; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=SgO+kR/KocImJn/Mxs6WaAtmexrHy0cJRdZfhaYRW4w=; b=GfhTmL4iXOxfnG7ZD5V8HMlsEobAZhm+22OXga7fR3E+lwKomg9jwavuI6+8B4TxNf rgMTm5Ro97EAth+Cc48G174Vbwvy8/Z+6l8CipLk92KNcY9kOxlkCQdBgfY66T7izpRz 4HMtFrHzKCj6loT4DziI9yI0GQCHnBEXF7FxnrO2QUn7Bq5+mhYOa4sJ6QhL+HFGO/5w +rCHZqVUajij+nVh3Qc16TdfFUNRXp+CWnwk/MLWEg1X65wSc1cp2cSdLYnePN3nu+gk X8PNNHiIWT5UnpjyNI3N+F8DcMyRY0O3eCvD6Dw3tlXI+/utOLQ6JbCH/BFW39wHZAIo K0kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1694192765; x=1694797565; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SgO+kR/KocImJn/Mxs6WaAtmexrHy0cJRdZfhaYRW4w=; b=bVXp853potSusRtSBYMITNMbM5wkxOCXlTaZa2JlR1A8KsrRfgE6n+JQLkreRffIvk RkKfRuGKyAMhxGGaORW4XWZ9bCAcPhRjQYqp0kVWUnqHVOtfdEIeUSfCrS7+J+mehLJe swJeJ2Gj9wvaVhbN9OJZRFPf60bqdY13mszGj6shJ75B//ZuBafjBr9RwEmDLPC8d2aj aRPTkZniYaKdfTeLcc6qmRWtq+v0NmHdIBSrXeFYQ9bwylp+d2WxjpUqze/IMsYeyuY2 HMVPzU/oe3f+ApwC12f2EZAm0vLSuY5b7ZVRdMPQIQcbxf6SDY0mDlHWGyfCPCqNmwXY pMIA== X-Gm-Message-State: AOJu0YyAX/eZXhyd0G/d+yKPfK7Scgg2DlTYKuThJqmsms6dVbrtxPrI KT7Nqibl0ieOL9m2ebvVhdsyoKblYR/mfXTQdZg= X-Received: by 2002:a7b:c386:0:b0:402:ea96:c09a with SMTP id s6-20020a7bc386000000b00402ea96c09amr2705754wmj.16.1694192765531; Fri, 08 Sep 2023 10:06:05 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id d21-20020a1c7315000000b00400268671c6sm2427152wmb.13.2023.09.08.10.06.05 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Sep 2023 10:06:05 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/26] hw/misc: Introduce the Xilinx CFI interface Date: Fri, 8 Sep 2023 18:05:42 +0100 Message-Id: <20230908170557.773048-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230908170557.773048-1-peter.maydell@linaro.org> References: <20230908170557.773048-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::329; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x329.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Francisco Iglesias 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 Message-id: 20230831165701.2016397-2-francisco.iglesias@amd.com Signed-off-by: Peter Maydell --- MAINTAINERS | 6 ++++ include/hw/misc/xlnx-cfi-if.h | 59 +++++++++++++++++++++++++++++++++++ hw/misc/xlnx-cfi-if.c | 34 ++++++++++++++++++++ hw/misc/meson.build | 1 + 4 files changed, 100 insertions(+) create mode 100644 include/hw/misc/xlnx-cfi-if.h create mode 100644 hw/misc/xlnx-cfi-if.c diff --git a/MAINTAINERS b/MAINTAINERS index b471973e1e1..4b9512eda93 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1026,6 +1026,12 @@ S: Maintained F: hw/ssi/xlnx-versal-ospi.c F: include/hw/ssi/xlnx-versal-ospi.h +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/include/hw/misc/xlnx-cfi-if.h b/include/hw/misc/xlnx-cfi-if.h new file mode 100644 index 00000000000..f9bd12292d4 --- /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 = 0x52, + PACKET_TYPE_CFRAME = 0xA1, +} xlnx_cfi_packet_type; + +typedef enum { + CFRAME_FAR = 1, + CFRAME_SFR = 2, + CFRAME_FDRI = 4, + CFRAME_CMD = 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 */ diff --git a/hw/misc/xlnx-cfi-if.c b/hw/misc/xlnx-cfi-if.c new file mode 100644 index 00000000000..c45f05c4aac --- /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 = 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 = { + .name = TYPE_XLNX_CFI_IF, + .parent = TYPE_INTERFACE, + .class_size = 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/hw/misc/meson.build b/hw/misc/meson.build index d9a370c1de2..593c7591fc8 100644 --- a/hw/misc/meson.build +++ b/hw/misc/meson.build @@ -98,6 +98,7 @@ specific_ss.add(when: 'CONFIG_XLNX_VERSAL', if_true: files('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_syscfg.c')) system_ss.add(when: 'CONFIG_STM32F4XX_SYSCFG', if_true: files('stm32f4xx_syscfg.c'))