xref: /qemu/include/hw/ppc/pnv_psi.h (revision 30b5707c269cac1ad80b72f777e52c8e08b2ff19)
154f59d78SCédric Le Goater /*
254f59d78SCédric Le Goater  * QEMU PowerPC PowerNV Processor Service Interface (PSI) model
354f59d78SCédric Le Goater  *
454f59d78SCédric Le Goater  * Copyright (c) 2015-2017, IBM Corporation.
554f59d78SCédric Le Goater  *
654f59d78SCédric Le Goater  * This library is free software; you can redistribute it and/or
754f59d78SCédric Le Goater  * modify it under the terms of the GNU Lesser General Public
854f59d78SCédric Le Goater  * License as published by the Free Software Foundation; either
954f59d78SCédric Le Goater  * version 2 of the License, or (at your option) any later version.
1054f59d78SCédric Le Goater  *
1154f59d78SCédric Le Goater  * This library is distributed in the hope that it will be useful,
1254f59d78SCédric Le Goater  * but WITHOUT ANY WARRANTY; without even the implied warranty of
1354f59d78SCédric Le Goater  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
1454f59d78SCédric Le Goater  * Lesser General Public License for more details.
1554f59d78SCédric Le Goater  *
1654f59d78SCédric Le Goater  * You should have received a copy of the GNU Lesser General Public
1754f59d78SCédric Le Goater  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
1854f59d78SCédric Le Goater  */
19a8b991b5SMarkus Armbruster 
20a8b991b5SMarkus Armbruster #ifndef PPC_PNV_PSI_H
21a8b991b5SMarkus Armbruster #define PPC_PNV_PSI_H
2254f59d78SCédric Le Goater 
2354f59d78SCédric Le Goater #include "hw/sysbus.h"
2454f59d78SCédric Le Goater #include "hw/ppc/xics.h"
25c38536bcSCédric Le Goater #include "hw/ppc/xive.h"
26db1015e9SEduardo Habkost #include "qom/object.h"
2754f59d78SCédric Le Goater 
2854f59d78SCédric Le Goater #define TYPE_PNV_PSI "pnv-psi"
29c821774aSEduardo Habkost OBJECT_DECLARE_TYPE(PnvPsi, PnvPsiClass,
30*30b5707cSEduardo Habkost                     PNV_PSI)
3154f59d78SCédric Le Goater 
3254f59d78SCédric Le Goater #define PSIHB_XSCOM_MAX         0x20
3354f59d78SCédric Le Goater 
34db1015e9SEduardo Habkost struct PnvPsi {
352f35254aSMarkus Armbruster     DeviceState parent;
3654f59d78SCédric Le Goater 
3754f59d78SCédric Le Goater     MemoryRegion regs_mr;
3854f59d78SCédric Le Goater     uint64_t bar;
3954f59d78SCédric Le Goater 
4054f59d78SCédric Le Goater     /* FSP region not supported */
4154f59d78SCédric Le Goater     /* MemoryRegion fsp_mr; */
4254f59d78SCédric Le Goater     uint64_t fsp_bar;
4354f59d78SCédric Le Goater 
4454f59d78SCédric Le Goater     /* Interrupt generation */
45f8df9003SCédric Le Goater     qemu_irq *qirqs;
4654f59d78SCédric Le Goater 
4754f59d78SCédric Le Goater     /* Registers */
4854f59d78SCédric Le Goater     uint64_t regs[PSIHB_XSCOM_MAX];
4954f59d78SCédric Le Goater 
5054f59d78SCédric Le Goater     MemoryRegion xscom_regs;
51db1015e9SEduardo Habkost };
5254f59d78SCédric Le Goater 
53ae856055SCédric Le Goater #define TYPE_PNV8_PSI TYPE_PNV_PSI "-POWER8"
54db1015e9SEduardo Habkost typedef struct Pnv8Psi Pnv8Psi;
558110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(Pnv8Psi, PNV8_PSI,
568110fa1dSEduardo Habkost                          TYPE_PNV8_PSI)
57ae856055SCédric Le Goater 
58db1015e9SEduardo Habkost struct Pnv8Psi {
59ae856055SCédric Le Goater     PnvPsi   parent;
60ae856055SCédric Le Goater 
61ae856055SCédric Le Goater     ICSState ics;
62db1015e9SEduardo Habkost };
63ae856055SCédric Le Goater 
64c38536bcSCédric Le Goater #define TYPE_PNV9_PSI TYPE_PNV_PSI "-POWER9"
65db1015e9SEduardo Habkost typedef struct Pnv9Psi Pnv9Psi;
668110fa1dSEduardo Habkost DECLARE_INSTANCE_CHECKER(Pnv9Psi, PNV9_PSI,
678110fa1dSEduardo Habkost                          TYPE_PNV9_PSI)
68c38536bcSCédric Le Goater 
69db1015e9SEduardo Habkost struct Pnv9Psi {
70c38536bcSCédric Le Goater     PnvPsi   parent;
71c38536bcSCédric Le Goater 
72c38536bcSCédric Le Goater     XiveSource source;
73db1015e9SEduardo Habkost };
74c38536bcSCédric Le Goater 
758b50ce85SCédric Le Goater #define TYPE_PNV10_PSI TYPE_PNV_PSI "-POWER10"
768b50ce85SCédric Le Goater 
77ae856055SCédric Le Goater 
78db1015e9SEduardo Habkost struct PnvPsiClass {
79ae856055SCédric Le Goater     SysBusDeviceClass parent_class;
80ae856055SCédric Le Goater 
81ae856055SCédric Le Goater     uint32_t xscom_pcba;
82ae856055SCédric Le Goater     uint32_t xscom_size;
83ae856055SCédric Le Goater     uint64_t bar_mask;
8441c4ef70SGreg Kurz     const char *compat;
8541c4ef70SGreg Kurz     int compat_size;
86ae856055SCédric Le Goater 
87ae856055SCédric Le Goater     void (*irq_set)(PnvPsi *psi, int, bool state);
88db1015e9SEduardo Habkost };
89ae856055SCédric Le Goater 
9054f59d78SCédric Le Goater /* The PSI and FSP interrupts are muxed on the same IRQ number */
9154f59d78SCédric Le Goater typedef enum PnvPsiIrq {
9254f59d78SCédric Le Goater     PSIHB_IRQ_PSI, /* internal use only */
9354f59d78SCédric Le Goater     PSIHB_IRQ_FSP, /* internal use only */
9454f59d78SCédric Le Goater     PSIHB_IRQ_OCC,
9554f59d78SCédric Le Goater     PSIHB_IRQ_FSI,
9654f59d78SCédric Le Goater     PSIHB_IRQ_LPC_I2C,
9754f59d78SCédric Le Goater     PSIHB_IRQ_LOCAL_ERR,
9854f59d78SCédric Le Goater     PSIHB_IRQ_EXTERNAL,
9954f59d78SCédric Le Goater } PnvPsiIrq;
10054f59d78SCédric Le Goater 
10154f59d78SCédric Le Goater #define PSI_NUM_INTERRUPTS 6
10254f59d78SCédric Le Goater 
103ae856055SCédric Le Goater void pnv_psi_irq_set(PnvPsi *psi, int irq, bool state);
10454f59d78SCédric Le Goater 
105c38536bcSCédric Le Goater /* P9 PSI Interrupts */
106c38536bcSCédric Le Goater #define PSIHB9_IRQ_PSI          0
107c38536bcSCédric Le Goater #define PSIHB9_IRQ_OCC          1
108c38536bcSCédric Le Goater #define PSIHB9_IRQ_FSI          2
109c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPCHC        3
110c38536bcSCédric Le Goater #define PSIHB9_IRQ_LOCAL_ERR    4
111c38536bcSCédric Le Goater #define PSIHB9_IRQ_GLOBAL_ERR   5
112c38536bcSCédric Le Goater #define PSIHB9_IRQ_TPM          6
113c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ0    7
114c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ1    8
115c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ2    9
116c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ3    10
117c38536bcSCédric Le Goater #define PSIHB9_IRQ_SBE_I2C      11
118c38536bcSCédric Le Goater #define PSIHB9_IRQ_DIO          12
119c38536bcSCédric Le Goater #define PSIHB9_IRQ_PSU          13
120c38536bcSCédric Le Goater #define PSIHB9_NUM_IRQS         14
121c38536bcSCédric Le Goater 
122c38536bcSCédric Le Goater void pnv_psi_pic_print_info(Pnv9Psi *psi, Monitor *mon);
123c38536bcSCédric Le Goater 
124a8b991b5SMarkus Armbruster #endif /* PPC_PNV_PSI_H */
125