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" 24a3980bf5SBenjamin Herrenschmidt #include "hw/ppc/pnv_lpc.h" 25e997040eSCédric Le Goater 26e997040eSCédric Le Goater #define TYPE_PNV_CHIP "powernv-chip" 27e997040eSCédric Le Goater #define PNV_CHIP(obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP) 28e997040eSCédric Le Goater #define PNV_CHIP_CLASS(klass) \ 29e997040eSCédric Le Goater OBJECT_CLASS_CHECK(PnvChipClass, (klass), TYPE_PNV_CHIP) 30e997040eSCédric Le Goater #define PNV_CHIP_GET_CLASS(obj) \ 31e997040eSCédric Le Goater OBJECT_GET_CLASS(PnvChipClass, (obj), TYPE_PNV_CHIP) 32e997040eSCédric Le Goater 33e997040eSCédric Le Goater typedef enum PnvChipType { 34e997040eSCédric Le Goater PNV_CHIP_POWER8E, /* AKA Murano (default) */ 35e997040eSCédric Le Goater PNV_CHIP_POWER8, /* AKA Venice */ 36e997040eSCédric Le Goater PNV_CHIP_POWER8NVL, /* AKA Naples */ 37e997040eSCédric Le Goater PNV_CHIP_POWER9, /* AKA Nimbus */ 38e997040eSCédric Le Goater } PnvChipType; 39e997040eSCédric Le Goater 40e997040eSCédric Le Goater typedef struct PnvChip { 41e997040eSCédric Le Goater /*< private >*/ 42e997040eSCédric Le Goater SysBusDevice parent_obj; 43e997040eSCédric Le Goater 44e997040eSCédric Le Goater /*< public >*/ 45e997040eSCédric Le Goater uint32_t chip_id; 46e997040eSCédric Le Goater uint64_t ram_start; 47e997040eSCédric Le Goater uint64_t ram_size; 48397a79e7SCédric Le Goater 49397a79e7SCédric Le Goater uint32_t nr_cores; 50397a79e7SCédric Le Goater uint64_t cores_mask; 51d2fd9612SCédric Le Goater void *cores; 52967b7523SCédric Le Goater 53967b7523SCédric Le Goater hwaddr xscom_base; 54967b7523SCédric Le Goater MemoryRegion xscom_mmio; 55967b7523SCédric Le Goater MemoryRegion xscom; 56967b7523SCédric Le Goater AddressSpace xscom_as; 57*bf5615e7SCédric Le Goater MemoryRegion icp_mmio; 58a3980bf5SBenjamin Herrenschmidt 59a3980bf5SBenjamin Herrenschmidt PnvLpcController lpc; 60e997040eSCédric Le Goater } PnvChip; 61e997040eSCédric Le Goater 62e997040eSCédric Le Goater typedef struct PnvChipClass { 63e997040eSCédric Le Goater /*< private >*/ 64e997040eSCédric Le Goater SysBusDeviceClass parent_class; 65e997040eSCédric Le Goater 66e997040eSCédric Le Goater /*< public >*/ 67e997040eSCédric Le Goater const char *cpu_model; 68e997040eSCédric Le Goater PnvChipType chip_type; 69e997040eSCédric Le Goater uint64_t chip_cfam_id; 70397a79e7SCédric Le Goater uint64_t cores_mask; 71631adaffSCédric Le Goater 72967b7523SCédric Le Goater hwaddr xscom_base; 73ad521238SCédric Le Goater hwaddr xscom_core_base; 74967b7523SCédric Le Goater 75631adaffSCédric Le Goater uint32_t (*core_pir)(PnvChip *chip, uint32_t core_id); 76e997040eSCédric Le Goater } PnvChipClass; 77e997040eSCédric Le Goater 78e997040eSCédric Le Goater #define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-POWER8E" 79e997040eSCédric Le Goater #define PNV_CHIP_POWER8E(obj) \ 80e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8E) 81e997040eSCédric Le Goater 82e997040eSCédric Le Goater #define TYPE_PNV_CHIP_POWER8 TYPE_PNV_CHIP "-POWER8" 83e997040eSCédric Le Goater #define PNV_CHIP_POWER8(obj) \ 84e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8) 85e997040eSCédric Le Goater 86e997040eSCédric Le Goater #define TYPE_PNV_CHIP_POWER8NVL TYPE_PNV_CHIP "-POWER8NVL" 87e997040eSCédric Le Goater #define PNV_CHIP_POWER8NVL(obj) \ 88e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8NVL) 89e997040eSCédric Le Goater 90e997040eSCédric Le Goater #define TYPE_PNV_CHIP_POWER9 TYPE_PNV_CHIP "-POWER9" 91e997040eSCédric Le Goater #define PNV_CHIP_POWER9(obj) \ 92e997040eSCédric Le Goater OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER9) 93e997040eSCédric Le Goater 94e997040eSCédric Le Goater /* 955509db4aSCédric Le Goater * This generates a HW chip id depending on an index, as found on a 965509db4aSCédric Le Goater * two socket system with dual chip modules : 97e997040eSCédric Le Goater * 98e997040eSCédric Le Goater * 0x0, 0x1, 0x10, 0x11 99e997040eSCédric Le Goater * 100e997040eSCédric Le Goater * 4 chips should be the maximum 1015509db4aSCédric Le Goater * 1025509db4aSCédric Le Goater * TODO: use a machine property to define the chip ids 103e997040eSCédric Le Goater */ 104e997040eSCédric Le Goater #define PNV_CHIP_HWID(i) ((((i) & 0x3e) << 3) | ((i) & 0x1)) 1059e933f4aSBenjamin Herrenschmidt 1065509db4aSCédric Le Goater /* 1075509db4aSCédric Le Goater * Converts back a HW chip id to an index. This is useful to calculate 1085509db4aSCédric Le Goater * the MMIO addresses of some controllers which depend on the chip id. 1095509db4aSCédric Le Goater */ 1105509db4aSCédric Le Goater #define PNV_CHIP_INDEX(chip) \ 1115509db4aSCédric Le Goater (((chip)->chip_id >> 2) * 2 + ((chip)->chip_id & 0x3)) 1125509db4aSCédric Le Goater 1139e933f4aSBenjamin Herrenschmidt #define TYPE_POWERNV_MACHINE MACHINE_TYPE_NAME("powernv") 1149e933f4aSBenjamin Herrenschmidt #define POWERNV_MACHINE(obj) \ 1159e933f4aSBenjamin Herrenschmidt OBJECT_CHECK(PnvMachineState, (obj), TYPE_POWERNV_MACHINE) 1169e933f4aSBenjamin Herrenschmidt 1179e933f4aSBenjamin Herrenschmidt typedef struct PnvMachineState { 1189e933f4aSBenjamin Herrenschmidt /*< private >*/ 1199e933f4aSBenjamin Herrenschmidt MachineState parent_obj; 1209e933f4aSBenjamin Herrenschmidt 1219e933f4aSBenjamin Herrenschmidt uint32_t initrd_base; 1229e933f4aSBenjamin Herrenschmidt long initrd_size; 123e997040eSCédric Le Goater 124e997040eSCédric Le Goater uint32_t num_chips; 125e997040eSCédric Le Goater PnvChip **chips; 1263495b6b6SCédric Le Goater 1273495b6b6SCédric Le Goater ISABus *isa_bus; 1289e933f4aSBenjamin Herrenschmidt } PnvMachineState; 1299e933f4aSBenjamin Herrenschmidt 1309e933f4aSBenjamin Herrenschmidt #define PNV_FDT_ADDR 0x01000000 131d2fd9612SCédric Le Goater #define PNV_TIMEBASE_FREQ 512000000ULL 1329e933f4aSBenjamin Herrenschmidt 133967b7523SCédric Le Goater /* 134967b7523SCédric Le Goater * POWER8 MMIO base addresses 135967b7523SCédric Le Goater */ 136967b7523SCédric Le Goater #define PNV_XSCOM_SIZE 0x800000000ull 137967b7523SCédric Le Goater #define PNV_XSCOM_BASE(chip) \ 138967b7523SCédric Le Goater (chip->xscom_base + ((uint64_t)(chip)->chip_id) * PNV_XSCOM_SIZE) 139967b7523SCédric Le Goater 140*bf5615e7SCédric Le Goater /* 141*bf5615e7SCédric Le Goater * XSCOM 0x20109CA defines the ICP BAR: 142*bf5615e7SCédric Le Goater * 143*bf5615e7SCédric Le Goater * 0:29 : bits 14 to 43 of address to define 1 MB region. 144*bf5615e7SCédric Le Goater * 30 : 1 to enable ICP to receive loads/stores against its BAR region 145*bf5615e7SCédric Le Goater * 31:63 : Constant 0 146*bf5615e7SCédric Le Goater * 147*bf5615e7SCédric Le Goater * Usually defined as : 148*bf5615e7SCédric Le Goater * 149*bf5615e7SCédric Le Goater * 0xffffe00200000000 -> 0x0003ffff80000000 150*bf5615e7SCédric Le Goater * 0xffffe00600000000 -> 0x0003ffff80100000 151*bf5615e7SCédric Le Goater * 0xffffe02200000000 -> 0x0003ffff80800000 152*bf5615e7SCédric Le Goater * 0xffffe02600000000 -> 0x0003ffff80900000 153*bf5615e7SCédric Le Goater */ 154*bf5615e7SCédric Le Goater #define PNV_ICP_SIZE 0x0000000000100000ull 155*bf5615e7SCédric Le Goater #define PNV_ICP_BASE(chip) \ 156*bf5615e7SCédric Le Goater (0x0003ffff80000000ull + (uint64_t) PNV_CHIP_INDEX(chip) * PNV_ICP_SIZE) 157*bf5615e7SCédric Le Goater 1589e933f4aSBenjamin Herrenschmidt #endif /* _PPC_PNV_H */ 159