19e933f4aSBenjamin Herrenschmidt /* 29e933f4aSBenjamin Herrenschmidt * QEMU PowerPC PowerNV various definitions 39e933f4aSBenjamin Herrenschmidt * 49e933f4aSBenjamin Herrenschmidt * Copyright (c) 2014-2016 BenH, IBM Corporation. 59e933f4aSBenjamin Herrenschmidt * 69e933f4aSBenjamin Herrenschmidt * This library is free software; you can redistribute it and/or 79e933f4aSBenjamin Herrenschmidt * modify it under the terms of the GNU Lesser General Public 89e933f4aSBenjamin Herrenschmidt * License as published by the Free Software Foundation; either 99e933f4aSBenjamin Herrenschmidt * version 2 of the License, or (at your option) any later version. 109e933f4aSBenjamin Herrenschmidt * 119e933f4aSBenjamin Herrenschmidt * This library is distributed in the hope that it will be useful, 129e933f4aSBenjamin Herrenschmidt * but WITHOUT ANY WARRANTY; without even the implied warranty of 139e933f4aSBenjamin Herrenschmidt * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 149e933f4aSBenjamin Herrenschmidt * Lesser General Public License for more details. 159e933f4aSBenjamin Herrenschmidt * 169e933f4aSBenjamin Herrenschmidt * You should have received a copy of the GNU Lesser General Public 179e933f4aSBenjamin Herrenschmidt * License along with this library; if not, see <http://www.gnu.org/licenses/>. 189e933f4aSBenjamin Herrenschmidt */ 199e933f4aSBenjamin Herrenschmidt #ifndef _PPC_PNV_H 209e933f4aSBenjamin Herrenschmidt #define _PPC_PNV_H 219e933f4aSBenjamin Herrenschmidt 229e933f4aSBenjamin Herrenschmidt #include "hw/boards.h" 23e997040eSCédric Le Goater #include "hw/sysbus.h" 24eaf87a39SDavid Gibson #include "hw/ipmi/ipmi.h" 25a3980bf5SBenjamin Herrenschmidt #include "hw/ppc/pnv_lpc.h" 2654f59d78SCédric Le Goater #include "hw/ppc/pnv_psi.h" 270722d05aSBenjamin Herrenschmidt #include "hw/ppc/pnv_occ.h" 28e997040eSCédric Le Goater 29e997040eSCédric Le Goater #define TYPE_PNV_CHIP "powernv-chip" 30e997040eSCédric Le Goater #define PNV_CHIP(obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP) 31e997040eSCédric Le Goater #define PNV_CHIP_CLASS(klass) \ 32e997040eSCédric Le Goater OBJECT_CLASS_CHECK(PnvChipClass, (klass), TYPE_PNV_CHIP) 33e997040eSCédric Le Goater #define PNV_CHIP_GET_CLASS(obj) \ 34e997040eSCédric Le Goater OBJECT_GET_CLASS(PnvChipClass, (obj), TYPE_PNV_CHIP) 35e997040eSCédric Le Goater 36e997040eSCédric Le Goater typedef enum PnvChipType { 37e997040eSCédric Le Goater PNV_CHIP_POWER8E, /* AKA Murano (default) */ 38e997040eSCédric Le Goater PNV_CHIP_POWER8, /* AKA Venice */ 39e997040eSCédric Le Goater PNV_CHIP_POWER8NVL, /* AKA Naples */ 40e997040eSCédric Le Goater PNV_CHIP_POWER9, /* AKA Nimbus */ 41e997040eSCédric Le Goater } PnvChipType; 42e997040eSCédric Le Goater 43e997040eSCédric Le Goater typedef struct PnvChip { 44e997040eSCédric Le Goater /*< private >*/ 45e997040eSCédric Le Goater SysBusDevice parent_obj; 46e997040eSCédric Le Goater 47e997040eSCédric Le Goater /*< public >*/ 48e997040eSCédric Le Goater uint32_t chip_id; 49e997040eSCédric Le Goater uint64_t ram_start; 50e997040eSCédric Le Goater uint64_t ram_size; 51397a79e7SCédric Le Goater 52397a79e7SCédric Le Goater uint32_t nr_cores; 53397a79e7SCédric Le Goater uint64_t cores_mask; 54d2fd9612SCédric Le Goater void *cores; 55967b7523SCédric Le Goater 56967b7523SCédric Le Goater hwaddr xscom_base; 57967b7523SCédric Le Goater MemoryRegion xscom_mmio; 58967b7523SCédric Le Goater MemoryRegion xscom; 59967b7523SCédric Le Goater AddressSpace xscom_as; 60bf5615e7SCédric Le Goater MemoryRegion icp_mmio; 61a3980bf5SBenjamin Herrenschmidt 62a3980bf5SBenjamin Herrenschmidt PnvLpcController lpc; 6354f59d78SCédric Le Goater PnvPsi psi; 640722d05aSBenjamin Herrenschmidt PnvOCC occ; 65e997040eSCédric Le Goater } PnvChip; 66e997040eSCédric Le Goater 67e997040eSCédric Le Goater typedef struct PnvChipClass { 68e997040eSCédric Le Goater /*< private >*/ 69e997040eSCédric Le Goater SysBusDeviceClass parent_class; 70e997040eSCédric Le Goater 71e997040eSCédric Le Goater /*< public >*/ 72e997040eSCédric Le Goater const char *cpu_model; 73e997040eSCédric Le Goater PnvChipType chip_type; 74e997040eSCédric Le Goater uint64_t chip_cfam_id; 75397a79e7SCédric Le Goater uint64_t cores_mask; 76631adaffSCédric Le Goater 77967b7523SCédric Le Goater hwaddr xscom_base; 78ad521238SCédric Le Goater hwaddr xscom_core_base; 79967b7523SCédric Le Goater 80631adaffSCédric Le Goater uint32_t (*core_pir)(PnvChip *chip, uint32_t core_id); 81e997040eSCédric Le Goater } PnvChipClass; 82e997040eSCédric Le Goater 83*7fd544d8SIgor Mammedov #define PNV_CHIP_TYPE_SUFFIX "-" TYPE_PNV_CHIP 84*7fd544d8SIgor Mammedov #define PNV_CHIP_TYPE_NAME(cpu_model) cpu_model PNV_CHIP_TYPE_SUFFIX 85*7fd544d8SIgor Mammedov 86*7fd544d8SIgor Mammedov #define TYPE_PNV_CHIP_POWER8E PNV_CHIP_TYPE_NAME("power8e_v2.1") 87e997040eSCédric Le Goater #define PNV_CHIP_POWER8E(obj) \ 88e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8E) 89e997040eSCédric Le Goater 90*7fd544d8SIgor Mammedov #define TYPE_PNV_CHIP_POWER8 PNV_CHIP_TYPE_NAME("power8_v2.0") 91e997040eSCédric Le Goater #define PNV_CHIP_POWER8(obj) \ 92e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8) 93e997040eSCédric Le Goater 94*7fd544d8SIgor Mammedov #define TYPE_PNV_CHIP_POWER8NVL PNV_CHIP_TYPE_NAME("power8nvl_v1.0") 95e997040eSCédric Le Goater #define PNV_CHIP_POWER8NVL(obj) \ 96e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8NVL) 97e997040eSCédric Le Goater 98*7fd544d8SIgor Mammedov #define TYPE_PNV_CHIP_POWER9 PNV_CHIP_TYPE_NAME("power9_v2.0") 99e997040eSCédric Le Goater #define PNV_CHIP_POWER9(obj) \ 100e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER9) 101e997040eSCédric Le Goater 102e997040eSCédric Le Goater /* 1035509db4aSCédric Le Goater * This generates a HW chip id depending on an index, as found on a 1045509db4aSCédric Le Goater * two socket system with dual chip modules : 105e997040eSCédric Le Goater * 106e997040eSCédric Le Goater * 0x0, 0x1, 0x10, 0x11 107e997040eSCédric Le Goater * 108e997040eSCédric Le Goater * 4 chips should be the maximum 1095509db4aSCédric Le Goater * 1105509db4aSCédric Le Goater * TODO: use a machine property to define the chip ids 111e997040eSCédric Le Goater */ 112e997040eSCédric Le Goater #define PNV_CHIP_HWID(i) ((((i) & 0x3e) << 3) | ((i) & 0x1)) 1139e933f4aSBenjamin Herrenschmidt 1145509db4aSCédric Le Goater /* 1155509db4aSCédric Le Goater * Converts back a HW chip id to an index. This is useful to calculate 1165509db4aSCédric Le Goater * the MMIO addresses of some controllers which depend on the chip id. 1175509db4aSCédric Le Goater */ 1185509db4aSCédric Le Goater #define PNV_CHIP_INDEX(chip) \ 1195509db4aSCédric Le Goater (((chip)->chip_id >> 2) * 2 + ((chip)->chip_id & 0x3)) 1205509db4aSCédric Le Goater 1219e933f4aSBenjamin Herrenschmidt #define TYPE_POWERNV_MACHINE MACHINE_TYPE_NAME("powernv") 1229e933f4aSBenjamin Herrenschmidt #define POWERNV_MACHINE(obj) \ 1239e933f4aSBenjamin Herrenschmidt OBJECT_CHECK(PnvMachineState, (obj), TYPE_POWERNV_MACHINE) 1249e933f4aSBenjamin Herrenschmidt 1259e933f4aSBenjamin Herrenschmidt typedef struct PnvMachineState { 1269e933f4aSBenjamin Herrenschmidt /*< private >*/ 1279e933f4aSBenjamin Herrenschmidt MachineState parent_obj; 1289e933f4aSBenjamin Herrenschmidt 1299e933f4aSBenjamin Herrenschmidt uint32_t initrd_base; 1309e933f4aSBenjamin Herrenschmidt long initrd_size; 131e997040eSCédric Le Goater 132e997040eSCédric Le Goater uint32_t num_chips; 133e997040eSCédric Le Goater PnvChip **chips; 1343495b6b6SCédric Le Goater 1353495b6b6SCédric Le Goater ISABus *isa_bus; 13654f59d78SCédric Le Goater uint32_t cpld_irqstate; 137aeaef83dSCédric Le Goater 138aeaef83dSCédric Le Goater IPMIBmc *bmc; 139bce0b691SCédric Le Goater Notifier powerdown_notifier; 1409e933f4aSBenjamin Herrenschmidt } PnvMachineState; 1419e933f4aSBenjamin Herrenschmidt 1429e933f4aSBenjamin Herrenschmidt #define PNV_FDT_ADDR 0x01000000 143d2fd9612SCédric Le Goater #define PNV_TIMEBASE_FREQ 512000000ULL 1449e933f4aSBenjamin Herrenschmidt 145967b7523SCédric Le Goater /* 146aeaef83dSCédric Le Goater * BMC helpers 147aeaef83dSCédric Le Goater */ 148aeaef83dSCédric Le Goater void pnv_bmc_populate_sensors(IPMIBmc *bmc, void *fdt); 149bce0b691SCédric Le Goater void pnv_bmc_powerdown(IPMIBmc *bmc); 150aeaef83dSCédric Le Goater 151aeaef83dSCédric Le Goater /* 152967b7523SCédric Le Goater * POWER8 MMIO base addresses 153967b7523SCédric Le Goater */ 154967b7523SCédric Le Goater #define PNV_XSCOM_SIZE 0x800000000ull 155967b7523SCédric Le Goater #define PNV_XSCOM_BASE(chip) \ 156967b7523SCédric Le Goater (chip->xscom_base + ((uint64_t)(chip)->chip_id) * PNV_XSCOM_SIZE) 157967b7523SCédric Le Goater 158bf5615e7SCédric Le Goater /* 159bf5615e7SCédric Le Goater * XSCOM 0x20109CA defines the ICP BAR: 160bf5615e7SCédric Le Goater * 161bf5615e7SCédric Le Goater * 0:29 : bits 14 to 43 of address to define 1 MB region. 162bf5615e7SCédric Le Goater * 30 : 1 to enable ICP to receive loads/stores against its BAR region 163bf5615e7SCédric Le Goater * 31:63 : Constant 0 164bf5615e7SCédric Le Goater * 165bf5615e7SCédric Le Goater * Usually defined as : 166bf5615e7SCédric Le Goater * 167bf5615e7SCédric Le Goater * 0xffffe00200000000 -> 0x0003ffff80000000 168bf5615e7SCédric Le Goater * 0xffffe00600000000 -> 0x0003ffff80100000 169bf5615e7SCédric Le Goater * 0xffffe02200000000 -> 0x0003ffff80800000 170bf5615e7SCédric Le Goater * 0xffffe02600000000 -> 0x0003ffff80900000 171bf5615e7SCédric Le Goater */ 172bf5615e7SCédric Le Goater #define PNV_ICP_SIZE 0x0000000000100000ull 173bf5615e7SCédric Le Goater #define PNV_ICP_BASE(chip) \ 174bf5615e7SCédric Le Goater (0x0003ffff80000000ull + (uint64_t) PNV_CHIP_INDEX(chip) * PNV_ICP_SIZE) 175bf5615e7SCédric Le Goater 17654f59d78SCédric Le Goater 17754f59d78SCédric Le Goater #define PNV_PSIHB_SIZE 0x0000000000100000ull 17854f59d78SCédric Le Goater #define PNV_PSIHB_BASE(chip) \ 17954f59d78SCédric Le Goater (0x0003fffe80000000ull + (uint64_t)PNV_CHIP_INDEX(chip) * PNV_PSIHB_SIZE) 18054f59d78SCédric Le Goater 18154f59d78SCédric Le Goater #define PNV_PSIHB_FSP_SIZE 0x0000000100000000ull 18254f59d78SCédric Le Goater #define PNV_PSIHB_FSP_BASE(chip) \ 18354f59d78SCédric Le Goater (0x0003ffe000000000ull + (uint64_t)PNV_CHIP_INDEX(chip) * \ 18454f59d78SCédric Le Goater PNV_PSIHB_FSP_SIZE) 18554f59d78SCédric Le Goater 1869e933f4aSBenjamin Herrenschmidt #endif /* _PPC_PNV_H */ 187