xref: /qemu/include/hw/ppc/pnv_psi.h (revision db1015e92e04835c9eb50c29625fe566d1202dbd)
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"
26*db1015e9SEduardo Habkost #include "qom/object.h"
2754f59d78SCédric Le Goater 
2854f59d78SCédric Le Goater #define TYPE_PNV_PSI "pnv-psi"
29*db1015e9SEduardo Habkost typedef struct PnvPsi PnvPsi;
30*db1015e9SEduardo Habkost typedef struct PnvPsiClass PnvPsiClass;
3154f59d78SCédric Le Goater #define PNV_PSI(obj) \
3254f59d78SCédric Le Goater      OBJECT_CHECK(PnvPsi, (obj), TYPE_PNV_PSI)
3354f59d78SCédric Le Goater 
3454f59d78SCédric Le Goater #define PSIHB_XSCOM_MAX         0x20
3554f59d78SCédric Le Goater 
36*db1015e9SEduardo Habkost struct PnvPsi {
372f35254aSMarkus Armbruster     DeviceState parent;
3854f59d78SCédric Le Goater 
3954f59d78SCédric Le Goater     MemoryRegion regs_mr;
4054f59d78SCédric Le Goater     uint64_t bar;
4154f59d78SCédric Le Goater 
4254f59d78SCédric Le Goater     /* FSP region not supported */
4354f59d78SCédric Le Goater     /* MemoryRegion fsp_mr; */
4454f59d78SCédric Le Goater     uint64_t fsp_bar;
4554f59d78SCédric Le Goater 
4654f59d78SCédric Le Goater     /* Interrupt generation */
47f8df9003SCédric Le Goater     qemu_irq *qirqs;
4854f59d78SCédric Le Goater 
4954f59d78SCédric Le Goater     /* Registers */
5054f59d78SCédric Le Goater     uint64_t regs[PSIHB_XSCOM_MAX];
5154f59d78SCédric Le Goater 
5254f59d78SCédric Le Goater     MemoryRegion xscom_regs;
53*db1015e9SEduardo Habkost };
5454f59d78SCédric Le Goater 
55ae856055SCédric Le Goater #define TYPE_PNV8_PSI TYPE_PNV_PSI "-POWER8"
56*db1015e9SEduardo Habkost typedef struct Pnv8Psi Pnv8Psi;
57ae856055SCédric Le Goater #define PNV8_PSI(obj) \
58ae856055SCédric Le Goater     OBJECT_CHECK(Pnv8Psi, (obj), TYPE_PNV8_PSI)
59ae856055SCédric Le Goater 
60*db1015e9SEduardo Habkost struct Pnv8Psi {
61ae856055SCédric Le Goater     PnvPsi   parent;
62ae856055SCédric Le Goater 
63ae856055SCédric Le Goater     ICSState ics;
64*db1015e9SEduardo Habkost };
65ae856055SCédric Le Goater 
66c38536bcSCédric Le Goater #define TYPE_PNV9_PSI TYPE_PNV_PSI "-POWER9"
67*db1015e9SEduardo Habkost typedef struct Pnv9Psi Pnv9Psi;
68c38536bcSCédric Le Goater #define PNV9_PSI(obj) \
69c38536bcSCédric Le Goater     OBJECT_CHECK(Pnv9Psi, (obj), TYPE_PNV9_PSI)
70c38536bcSCédric Le Goater 
71*db1015e9SEduardo Habkost struct Pnv9Psi {
72c38536bcSCédric Le Goater     PnvPsi   parent;
73c38536bcSCédric Le Goater 
74c38536bcSCédric Le Goater     XiveSource source;
75*db1015e9SEduardo Habkost };
76c38536bcSCédric Le Goater 
778b50ce85SCédric Le Goater #define TYPE_PNV10_PSI TYPE_PNV_PSI "-POWER10"
788b50ce85SCédric Le Goater 
79ae856055SCédric Le Goater #define PNV_PSI_CLASS(klass) \
80ae856055SCédric Le Goater      OBJECT_CLASS_CHECK(PnvPsiClass, (klass), TYPE_PNV_PSI)
81ae856055SCédric Le Goater #define PNV_PSI_GET_CLASS(obj) \
82ae856055SCédric Le Goater      OBJECT_GET_CLASS(PnvPsiClass, (obj), TYPE_PNV_PSI)
83ae856055SCédric Le Goater 
84*db1015e9SEduardo Habkost struct PnvPsiClass {
85ae856055SCédric Le Goater     SysBusDeviceClass parent_class;
86ae856055SCédric Le Goater 
87ae856055SCédric Le Goater     uint32_t xscom_pcba;
88ae856055SCédric Le Goater     uint32_t xscom_size;
89ae856055SCédric Le Goater     uint64_t bar_mask;
9041c4ef70SGreg Kurz     const char *compat;
9141c4ef70SGreg Kurz     int compat_size;
92ae856055SCédric Le Goater 
93ae856055SCédric Le Goater     void (*irq_set)(PnvPsi *psi, int, bool state);
94*db1015e9SEduardo Habkost };
95ae856055SCédric Le Goater 
9654f59d78SCédric Le Goater /* The PSI and FSP interrupts are muxed on the same IRQ number */
9754f59d78SCédric Le Goater typedef enum PnvPsiIrq {
9854f59d78SCédric Le Goater     PSIHB_IRQ_PSI, /* internal use only */
9954f59d78SCédric Le Goater     PSIHB_IRQ_FSP, /* internal use only */
10054f59d78SCédric Le Goater     PSIHB_IRQ_OCC,
10154f59d78SCédric Le Goater     PSIHB_IRQ_FSI,
10254f59d78SCédric Le Goater     PSIHB_IRQ_LPC_I2C,
10354f59d78SCédric Le Goater     PSIHB_IRQ_LOCAL_ERR,
10454f59d78SCédric Le Goater     PSIHB_IRQ_EXTERNAL,
10554f59d78SCédric Le Goater } PnvPsiIrq;
10654f59d78SCédric Le Goater 
10754f59d78SCédric Le Goater #define PSI_NUM_INTERRUPTS 6
10854f59d78SCédric Le Goater 
109ae856055SCédric Le Goater void pnv_psi_irq_set(PnvPsi *psi, int irq, bool state);
11054f59d78SCédric Le Goater 
111c38536bcSCédric Le Goater /* P9 PSI Interrupts */
112c38536bcSCédric Le Goater #define PSIHB9_IRQ_PSI          0
113c38536bcSCédric Le Goater #define PSIHB9_IRQ_OCC          1
114c38536bcSCédric Le Goater #define PSIHB9_IRQ_FSI          2
115c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPCHC        3
116c38536bcSCédric Le Goater #define PSIHB9_IRQ_LOCAL_ERR    4
117c38536bcSCédric Le Goater #define PSIHB9_IRQ_GLOBAL_ERR   5
118c38536bcSCédric Le Goater #define PSIHB9_IRQ_TPM          6
119c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ0    7
120c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ1    8
121c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ2    9
122c38536bcSCédric Le Goater #define PSIHB9_IRQ_LPC_SIRQ3    10
123c38536bcSCédric Le Goater #define PSIHB9_IRQ_SBE_I2C      11
124c38536bcSCédric Le Goater #define PSIHB9_IRQ_DIO          12
125c38536bcSCédric Le Goater #define PSIHB9_IRQ_PSU          13
126c38536bcSCédric Le Goater #define PSIHB9_NUM_IRQS         14
127c38536bcSCédric Le Goater 
128c38536bcSCédric Le Goater void pnv_psi_pic_print_info(Pnv9Psi *psi, Monitor *mon);
129c38536bcSCédric Le Goater 
130a8b991b5SMarkus Armbruster #endif /* PPC_PNV_PSI_H */
131