xref: /openbmc/qemu/include/hw/misc/xlnx-cfi-if.h (revision 05caa062)
1 /*
2  * Xilinx CFI interface
3  *
4  * Copyright (C) 2023, Advanced Micro Devices, Inc.
5  *
6  * Written by Francisco Iglesias <francisco.iglesias@amd.com>
7  *
8  * SPDX-License-Identifier: GPL-2.0-or-later
9  */
10 #ifndef XLNX_CFI_IF_H
11 #define XLNX_CFI_IF_H 1
12 
13 #include "qemu/help-texts.h"
14 #include "qom/object.h"
15 
16 #define TYPE_XLNX_CFI_IF "xlnx-cfi-if"
17 typedef struct XlnxCfiIfClass XlnxCfiIfClass;
18 DECLARE_CLASS_CHECKERS(XlnxCfiIfClass, XLNX_CFI_IF, TYPE_XLNX_CFI_IF)
19 
20 #define XLNX_CFI_IF(obj) \
21      INTERFACE_CHECK(XlnxCfiIf, (obj), TYPE_XLNX_CFI_IF)
22 
23 typedef enum {
24     PACKET_TYPE_CFU = 0x52,
25     PACKET_TYPE_CFRAME = 0xA1,
26 } xlnx_cfi_packet_type;
27 
28 typedef enum {
29     CFRAME_FAR = 1,
30     CFRAME_SFR = 2,
31     CFRAME_FDRI = 4,
32     CFRAME_CMD = 6,
33 } xlnx_cfi_reg_addr;
34 
35 typedef struct XlnxCfiPacket {
36     uint8_t reg_addr;
37     uint32_t data[4];
38 } XlnxCfiPacket;
39 
40 typedef struct XlnxCfiIf {
41     Object Parent;
42 } XlnxCfiIf;
43 
44 typedef struct XlnxCfiIfClass {
45     InterfaceClass parent;
46 
47     void (*cfi_transfer_packet)(XlnxCfiIf *cfi_if, XlnxCfiPacket *pkt);
48 } XlnxCfiIfClass;
49 
50 /**
51  * Transfer a XlnxCfiPacket.
52  *
53  * @cfi_if: the object implementing this interface
54  * @XlnxCfiPacket: a pointer to the XlnxCfiPacket to transfer
55  */
56 void xlnx_cfi_transfer_packet(XlnxCfiIf *cfi_if, XlnxCfiPacket *pkt);
57 
58 #endif /* XLNX_CFI_IF_H */
59