diff mbox series

[v1,1/8] hw/misc: Introduce the Xilinx CFI interface

Message ID 20230710140249.56324-2-francisco.iglesias@amd.com (mailing list archive)
State New, archived
Headers show
Series Xilinx Versal CFI support | expand

Commit Message

Francisco Iglesias July 10, 2023, 2:02 p.m. UTC
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 <francisco.iglesias@amd.com>
---
 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

Comments

Sai Pavan Boddu July 12, 2023, 5:37 a.m. UTC | #1
Hi

Looks good.
Reviewed-by: sai.pavan.boddu@amd.com

Regards,
Sai Pavan

>-----Original Message-----
>From: Francisco Iglesias <francisco.iglesias@amd.com>
>Sent: Monday, July 10, 2023 7:33 PM
>To: qemu-devel@nongnu.org
>Cc: frasse.iglesias@gmail.com; alistair@alistair23.me;
>edgar.iglesias@gmail.com; peter.maydell@linaro.org; Konrad, Frederic
><Frederic.Konrad@amd.com>; Boddu, Sai Pavan
><sai.pavan.boddu@amd.com>; Ho, Tong <tong.ho@amd.com>; Garhwal,
>Vikram <vikram.garhwal@amd.com>
>Subject: [PATCH v1 1/8] hw/misc: Introduce the Xilinx CFI interface
>
>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 <francisco.iglesias@amd.com>
>---
> 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 1817cfc62f..3ba115bb9b 100644
>--- a/MAINTAINERS
>+++ b/MAINTAINERS
>@@ -1036,6 +1036,12 @@ S: Maintained
> F: hw/ssi/xlnx-versal-ospi.c
> F: include/hw/ssi/xlnx-versal-ospi.h
>
>+Xilinx Versal CFI
>+M: Francisco Iglesias <francisco.iglesias@amd.com>
>+S: Maintained
>+F: hw/misc/xlnx-cfi-if.c
>+F: include/hw/misc/xlnx-cfi-if.h
>+
> STM32F100
> M: Alexandre Iooss <erdnaxe@crans.org>
> L: qemu-arm@nongnu.org
>diff --git a/hw/misc/meson.build b/hw/misc/meson.build index
>05877f61cc..9971b1e4db 100644
>--- a/hw/misc/meson.build
>+++ b/hw/misc/meson.build
>@@ -96,6 +96,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')) 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 <francisco.iglesias@amd.com>
>+ *
>+ * 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/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 <francisco.iglesias@amd.com>
>+ *
>+ * 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 */
>--
>2.34.1
diff mbox series

Patch

diff --git a/MAINTAINERS b/MAINTAINERS
index 1817cfc62f..3ba115bb9b 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -1036,6 +1036,12 @@  S: Maintained
 F: hw/ssi/xlnx-versal-ospi.c
 F: include/hw/ssi/xlnx-versal-ospi.h
 
+Xilinx Versal CFI
+M: Francisco Iglesias <francisco.iglesias@amd.com>
+S: Maintained
+F: hw/misc/xlnx-cfi-if.c
+F: include/hw/misc/xlnx-cfi-if.h
+
 STM32F100
 M: Alexandre Iooss <erdnaxe@crans.org>
 L: qemu-arm@nongnu.org
diff --git a/hw/misc/meson.build b/hw/misc/meson.build
index 05877f61cc..9971b1e4db 100644
--- a/hw/misc/meson.build
+++ b/hw/misc/meson.build
@@ -96,6 +96,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'))
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 <francisco.iglesias@amd.com>
+ *
+ * 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/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 <francisco.iglesias@amd.com>
+ *
+ * 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 */