ppc/pnv: add a OCC model for POWER9
[qemu/ar7.git] / include / hw / ppc / pnv.h
blob39888f9d52c10ce1760145d3a38262ec3f37f4d4
1 /*
2 * QEMU PowerPC PowerNV various definitions
4 * Copyright (c) 2014-2016 BenH, IBM Corporation.
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #ifndef _PPC_PNV_H
20 #define _PPC_PNV_H
22 #include "hw/boards.h"
23 #include "hw/sysbus.h"
24 #include "hw/ipmi/ipmi.h"
25 #include "hw/ppc/pnv_lpc.h"
26 #include "hw/ppc/pnv_psi.h"
27 #include "hw/ppc/pnv_occ.h"
28 #include "hw/ppc/pnv_xive.h"
30 #define TYPE_PNV_CHIP "pnv-chip"
31 #define PNV_CHIP(obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP)
32 #define PNV_CHIP_CLASS(klass) \
33 OBJECT_CLASS_CHECK(PnvChipClass, (klass), TYPE_PNV_CHIP)
34 #define PNV_CHIP_GET_CLASS(obj) \
35 OBJECT_GET_CLASS(PnvChipClass, (obj), TYPE_PNV_CHIP)
37 typedef enum PnvChipType {
38 PNV_CHIP_POWER8E, /* AKA Murano (default) */
39 PNV_CHIP_POWER8, /* AKA Venice */
40 PNV_CHIP_POWER8NVL, /* AKA Naples */
41 PNV_CHIP_POWER9, /* AKA Nimbus */
42 } PnvChipType;
44 typedef struct PnvChip {
45 /*< private >*/
46 SysBusDevice parent_obj;
48 /*< public >*/
49 uint32_t chip_id;
50 uint64_t ram_start;
51 uint64_t ram_size;
53 uint32_t nr_cores;
54 uint64_t cores_mask;
55 void *cores;
57 hwaddr xscom_base;
58 MemoryRegion xscom_mmio;
59 MemoryRegion xscom;
60 AddressSpace xscom_as;
62 gchar *dt_isa_nodename;
63 } PnvChip;
65 #define TYPE_PNV8_CHIP "pnv8-chip"
66 #define PNV8_CHIP(obj) OBJECT_CHECK(Pnv8Chip, (obj), TYPE_PNV8_CHIP)
68 typedef struct Pnv8Chip {
69 /*< private >*/
70 PnvChip parent_obj;
72 /*< public >*/
73 MemoryRegion icp_mmio;
75 PnvLpcController lpc;
76 Pnv8Psi psi;
77 PnvOCC occ;
78 } Pnv8Chip;
80 #define TYPE_PNV9_CHIP "pnv9-chip"
81 #define PNV9_CHIP(obj) OBJECT_CHECK(Pnv9Chip, (obj), TYPE_PNV9_CHIP)
83 typedef struct Pnv9Chip {
84 /*< private >*/
85 PnvChip parent_obj;
87 /*< public >*/
88 PnvXive xive;
89 Pnv9Psi psi;
90 PnvLpcController lpc;
91 PnvOCC occ;
92 } Pnv9Chip;
94 typedef struct PnvChipClass {
95 /*< private >*/
96 SysBusDeviceClass parent_class;
98 /*< public >*/
99 PnvChipType chip_type;
100 uint64_t chip_cfam_id;
101 uint64_t cores_mask;
103 hwaddr xscom_base;
105 DeviceRealize parent_realize;
107 uint32_t (*core_pir)(PnvChip *chip, uint32_t core_id);
108 void (*intc_create)(PnvChip *chip, PowerPCCPU *cpu, Error **errp);
109 ISABus *(*isa_create)(PnvChip *chip, Error **errp);
110 void (*dt_populate)(PnvChip *chip, void *fdt);
111 void (*pic_print_info)(PnvChip *chip, Monitor *mon);
112 } PnvChipClass;
114 #define PNV_CHIP_TYPE_SUFFIX "-" TYPE_PNV_CHIP
115 #define PNV_CHIP_TYPE_NAME(cpu_model) cpu_model PNV_CHIP_TYPE_SUFFIX
117 #define TYPE_PNV_CHIP_POWER8E PNV_CHIP_TYPE_NAME("power8e_v2.1")
118 #define PNV_CHIP_POWER8E(obj) \
119 OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8E)
121 #define TYPE_PNV_CHIP_POWER8 PNV_CHIP_TYPE_NAME("power8_v2.0")
122 #define PNV_CHIP_POWER8(obj) \
123 OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8)
125 #define TYPE_PNV_CHIP_POWER8NVL PNV_CHIP_TYPE_NAME("power8nvl_v1.0")
126 #define PNV_CHIP_POWER8NVL(obj) \
127 OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8NVL)
129 #define TYPE_PNV_CHIP_POWER9 PNV_CHIP_TYPE_NAME("power9_v2.0")
130 #define PNV_CHIP_POWER9(obj) \
131 OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER9)
134 * This generates a HW chip id depending on an index, as found on a
135 * two socket system with dual chip modules :
137 * 0x0, 0x1, 0x10, 0x11
139 * 4 chips should be the maximum
141 * TODO: use a machine property to define the chip ids
143 #define PNV_CHIP_HWID(i) ((((i) & 0x3e) << 3) | ((i) & 0x1))
146 * Converts back a HW chip id to an index. This is useful to calculate
147 * the MMIO addresses of some controllers which depend on the chip id.
149 #define PNV_CHIP_INDEX(chip) \
150 (((chip)->chip_id >> 2) * 2 + ((chip)->chip_id & 0x3))
152 #define TYPE_PNV_MACHINE MACHINE_TYPE_NAME("powernv")
153 #define PNV_MACHINE(obj) \
154 OBJECT_CHECK(PnvMachineState, (obj), TYPE_PNV_MACHINE)
156 typedef struct PnvMachineState {
157 /*< private >*/
158 MachineState parent_obj;
160 uint32_t initrd_base;
161 long initrd_size;
163 uint32_t num_chips;
164 PnvChip **chips;
166 ISABus *isa_bus;
167 uint32_t cpld_irqstate;
169 IPMIBmc *bmc;
170 Notifier powerdown_notifier;
171 } PnvMachineState;
173 static inline bool pnv_chip_is_power9(const PnvChip *chip)
175 return PNV_CHIP_GET_CLASS(chip)->chip_type == PNV_CHIP_POWER9;
178 static inline bool pnv_is_power9(PnvMachineState *pnv)
180 return pnv_chip_is_power9(pnv->chips[0]);
183 #define PNV_FDT_ADDR 0x01000000
184 #define PNV_TIMEBASE_FREQ 512000000ULL
187 * BMC helpers
189 void pnv_dt_bmc_sensors(IPMIBmc *bmc, void *fdt);
190 void pnv_bmc_powerdown(IPMIBmc *bmc);
193 * POWER8 MMIO base addresses
195 #define PNV_XSCOM_SIZE 0x800000000ull
196 #define PNV_XSCOM_BASE(chip) \
197 (chip->xscom_base + ((uint64_t)(chip)->chip_id) * PNV_XSCOM_SIZE)
200 * XSCOM 0x20109CA defines the ICP BAR:
202 * 0:29 : bits 14 to 43 of address to define 1 MB region.
203 * 30 : 1 to enable ICP to receive loads/stores against its BAR region
204 * 31:63 : Constant 0
206 * Usually defined as :
208 * 0xffffe00200000000 -> 0x0003ffff80000000
209 * 0xffffe00600000000 -> 0x0003ffff80100000
210 * 0xffffe02200000000 -> 0x0003ffff80800000
211 * 0xffffe02600000000 -> 0x0003ffff80900000
213 #define PNV_ICP_SIZE 0x0000000000100000ull
214 #define PNV_ICP_BASE(chip) \
215 (0x0003ffff80000000ull + (uint64_t) PNV_CHIP_INDEX(chip) * PNV_ICP_SIZE)
218 #define PNV_PSIHB_SIZE 0x0000000000100000ull
219 #define PNV_PSIHB_BASE(chip) \
220 (0x0003fffe80000000ull + (uint64_t)PNV_CHIP_INDEX(chip) * PNV_PSIHB_SIZE)
222 #define PNV_PSIHB_FSP_SIZE 0x0000000100000000ull
223 #define PNV_PSIHB_FSP_BASE(chip) \
224 (0x0003ffe000000000ull + (uint64_t)PNV_CHIP_INDEX(chip) * \
225 PNV_PSIHB_FSP_SIZE)
228 * POWER9 MMIO base addresses
230 #define PNV9_CHIP_BASE(chip, base) \
231 ((base) + ((uint64_t) (chip)->chip_id << 42))
233 #define PNV9_XIVE_VC_SIZE 0x0000008000000000ull
234 #define PNV9_XIVE_VC_BASE(chip) PNV9_CHIP_BASE(chip, 0x0006010000000000ull)
236 #define PNV9_XIVE_PC_SIZE 0x0000001000000000ull
237 #define PNV9_XIVE_PC_BASE(chip) PNV9_CHIP_BASE(chip, 0x0006018000000000ull)
239 #define PNV9_LPCM_SIZE 0x0000000100000000ull
240 #define PNV9_LPCM_BASE(chip) PNV9_CHIP_BASE(chip, 0x0006030000000000ull)
242 #define PNV9_PSIHB_SIZE 0x0000000000100000ull
243 #define PNV9_PSIHB_BASE(chip) PNV9_CHIP_BASE(chip, 0x0006030203000000ull)
245 #define PNV9_XIVE_IC_SIZE 0x0000000000080000ull
246 #define PNV9_XIVE_IC_BASE(chip) PNV9_CHIP_BASE(chip, 0x0006030203100000ull)
248 #define PNV9_XIVE_TM_SIZE 0x0000000000040000ull
249 #define PNV9_XIVE_TM_BASE(chip) PNV9_CHIP_BASE(chip, 0x0006030203180000ull)
251 #define PNV9_PSIHB_ESB_SIZE 0x0000000000010000ull
252 #define PNV9_PSIHB_ESB_BASE(chip) PNV9_CHIP_BASE(chip, 0x00060302031c0000ull)
254 #endif /* _PPC_PNV_H */