14f9924c4SBenjamin Herrenschmidt /* 24f9924c4SBenjamin Herrenschmidt * QEMU PowerPC PowerNV (POWER9) PHB4 model 34f9924c4SBenjamin Herrenschmidt * 44f9924c4SBenjamin Herrenschmidt * Copyright (c) 2018-2020, IBM Corporation. 54f9924c4SBenjamin Herrenschmidt * 64f9924c4SBenjamin Herrenschmidt * This code is licensed under the GPL version 2 or later. See the 74f9924c4SBenjamin Herrenschmidt * COPYING file in the top-level directory. 84f9924c4SBenjamin Herrenschmidt */ 94f9924c4SBenjamin Herrenschmidt #include "qemu/osdep.h" 104f9924c4SBenjamin Herrenschmidt #include "qapi/error.h" 114f9924c4SBenjamin Herrenschmidt #include "qemu/log.h" 124f9924c4SBenjamin Herrenschmidt #include "target/ppc/cpu.h" 134f9924c4SBenjamin Herrenschmidt #include "hw/ppc/fdt.h" 144f9924c4SBenjamin Herrenschmidt #include "hw/pci-host/pnv_phb4_regs.h" 154f9924c4SBenjamin Herrenschmidt #include "hw/pci-host/pnv_phb4.h" 164f9924c4SBenjamin Herrenschmidt #include "hw/ppc/pnv_xscom.h" 174f9924c4SBenjamin Herrenschmidt #include "hw/pci/pci_bridge.h" 184f9924c4SBenjamin Herrenschmidt #include "hw/pci/pci_bus.h" 194f9924c4SBenjamin Herrenschmidt #include "hw/ppc/pnv.h" 20*2c6fe2e2SMarkus Armbruster #include "hw/ppc/pnv_chip.h" 214f9924c4SBenjamin Herrenschmidt #include "hw/qdev-properties.h" 225bc67b05SDaniel Henrique Barboza #include "sysemu/sysemu.h" 234f9924c4SBenjamin Herrenschmidt 244f9924c4SBenjamin Herrenschmidt #include <libfdt.h> 254f9924c4SBenjamin Herrenschmidt 264f9924c4SBenjamin Herrenschmidt #define phb_pec_error(pec, fmt, ...) \ 274f9924c4SBenjamin Herrenschmidt qemu_log_mask(LOG_GUEST_ERROR, "phb4_pec[%d:%d]: " fmt "\n", \ 284f9924c4SBenjamin Herrenschmidt (pec)->chip_id, (pec)->index, ## __VA_ARGS__) 294f9924c4SBenjamin Herrenschmidt 304f9924c4SBenjamin Herrenschmidt 314f9924c4SBenjamin Herrenschmidt static uint64_t pnv_pec_nest_xscom_read(void *opaque, hwaddr addr, 324f9924c4SBenjamin Herrenschmidt unsigned size) 334f9924c4SBenjamin Herrenschmidt { 344f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(opaque); 354f9924c4SBenjamin Herrenschmidt uint32_t reg = addr >> 3; 364f9924c4SBenjamin Herrenschmidt 374f9924c4SBenjamin Herrenschmidt /* TODO: add list of allowed registers and error out if not */ 384f9924c4SBenjamin Herrenschmidt return pec->nest_regs[reg]; 394f9924c4SBenjamin Herrenschmidt } 404f9924c4SBenjamin Herrenschmidt 414f9924c4SBenjamin Herrenschmidt static void pnv_pec_nest_xscom_write(void *opaque, hwaddr addr, 424f9924c4SBenjamin Herrenschmidt uint64_t val, unsigned size) 434f9924c4SBenjamin Herrenschmidt { 444f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(opaque); 454f9924c4SBenjamin Herrenschmidt uint32_t reg = addr >> 3; 464f9924c4SBenjamin Herrenschmidt 474f9924c4SBenjamin Herrenschmidt switch (reg) { 484f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_HW_CONFIG: 494f9924c4SBenjamin Herrenschmidt case PEC_NEST_DROP_PRIO_CTRL: 504f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_ERR_INJECT: 514f9924c4SBenjamin Herrenschmidt case PEC_NEST_PCI_NEST_CLK_TRACE_CTL: 524f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_PMON_CTRL: 534f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_PBUS_ADDR_EXT: 544f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_PRED_VEC_TIMEOUT: 554f9924c4SBenjamin Herrenschmidt case PEC_NEST_CAPP_CTRL: 564f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_READ_STK_OVR: 574f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_WRITE_STK_OVR: 584f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_STORE_STK_OVR: 594f9924c4SBenjamin Herrenschmidt case PEC_NEST_PBCQ_RETRY_BKOFF_CTRL: 604f9924c4SBenjamin Herrenschmidt pec->nest_regs[reg] = val; 614f9924c4SBenjamin Herrenschmidt break; 624f9924c4SBenjamin Herrenschmidt default: 634f9924c4SBenjamin Herrenschmidt phb_pec_error(pec, "%s @0x%"HWADDR_PRIx"=%"PRIx64"\n", __func__, 644f9924c4SBenjamin Herrenschmidt addr, val); 654f9924c4SBenjamin Herrenschmidt } 664f9924c4SBenjamin Herrenschmidt } 674f9924c4SBenjamin Herrenschmidt 684f9924c4SBenjamin Herrenschmidt static const MemoryRegionOps pnv_pec_nest_xscom_ops = { 694f9924c4SBenjamin Herrenschmidt .read = pnv_pec_nest_xscom_read, 704f9924c4SBenjamin Herrenschmidt .write = pnv_pec_nest_xscom_write, 714f9924c4SBenjamin Herrenschmidt .valid.min_access_size = 8, 724f9924c4SBenjamin Herrenschmidt .valid.max_access_size = 8, 734f9924c4SBenjamin Herrenschmidt .impl.min_access_size = 8, 744f9924c4SBenjamin Herrenschmidt .impl.max_access_size = 8, 754f9924c4SBenjamin Herrenschmidt .endianness = DEVICE_BIG_ENDIAN, 764f9924c4SBenjamin Herrenschmidt }; 774f9924c4SBenjamin Herrenschmidt 784f9924c4SBenjamin Herrenschmidt static uint64_t pnv_pec_pci_xscom_read(void *opaque, hwaddr addr, 794f9924c4SBenjamin Herrenschmidt unsigned size) 804f9924c4SBenjamin Herrenschmidt { 814f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(opaque); 824f9924c4SBenjamin Herrenschmidt uint32_t reg = addr >> 3; 834f9924c4SBenjamin Herrenschmidt 844f9924c4SBenjamin Herrenschmidt /* TODO: add list of allowed registers and error out if not */ 854f9924c4SBenjamin Herrenschmidt return pec->pci_regs[reg]; 864f9924c4SBenjamin Herrenschmidt } 874f9924c4SBenjamin Herrenschmidt 884f9924c4SBenjamin Herrenschmidt static void pnv_pec_pci_xscom_write(void *opaque, hwaddr addr, 894f9924c4SBenjamin Herrenschmidt uint64_t val, unsigned size) 904f9924c4SBenjamin Herrenschmidt { 914f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(opaque); 924f9924c4SBenjamin Herrenschmidt uint32_t reg = addr >> 3; 934f9924c4SBenjamin Herrenschmidt 944f9924c4SBenjamin Herrenschmidt switch (reg) { 954f9924c4SBenjamin Herrenschmidt case PEC_PCI_PBAIB_HW_CONFIG: 964f9924c4SBenjamin Herrenschmidt case PEC_PCI_PBAIB_READ_STK_OVR: 974f9924c4SBenjamin Herrenschmidt pec->pci_regs[reg] = val; 984f9924c4SBenjamin Herrenschmidt break; 994f9924c4SBenjamin Herrenschmidt default: 1004f9924c4SBenjamin Herrenschmidt phb_pec_error(pec, "%s @0x%"HWADDR_PRIx"=%"PRIx64"\n", __func__, 1014f9924c4SBenjamin Herrenschmidt addr, val); 1024f9924c4SBenjamin Herrenschmidt } 1034f9924c4SBenjamin Herrenschmidt } 1044f9924c4SBenjamin Herrenschmidt 1054f9924c4SBenjamin Herrenschmidt static const MemoryRegionOps pnv_pec_pci_xscom_ops = { 1064f9924c4SBenjamin Herrenschmidt .read = pnv_pec_pci_xscom_read, 1074f9924c4SBenjamin Herrenschmidt .write = pnv_pec_pci_xscom_write, 1084f9924c4SBenjamin Herrenschmidt .valid.min_access_size = 8, 1094f9924c4SBenjamin Herrenschmidt .valid.max_access_size = 8, 1104f9924c4SBenjamin Herrenschmidt .impl.min_access_size = 8, 1114f9924c4SBenjamin Herrenschmidt .impl.max_access_size = 8, 1124f9924c4SBenjamin Herrenschmidt .endianness = DEVICE_BIG_ENDIAN, 1134f9924c4SBenjamin Herrenschmidt }; 1144f9924c4SBenjamin Herrenschmidt 1153f4c369eSDaniel Henrique Barboza static void pnv_pec_default_phb_realize(PnvPhb4PecState *pec, 116a479f0dcSDaniel Henrique Barboza int stack_no, 117a479f0dcSDaniel Henrique Barboza Error **errp) 118a479f0dcSDaniel Henrique Barboza { 119210aacb3SDaniel Henrique Barboza PnvPHB *phb = PNV_PHB(qdev_new(TYPE_PNV_PHB)); 120a479f0dcSDaniel Henrique Barboza int phb_id = pnv_phb4_pec_get_phb_id(pec, stack_no); 121a479f0dcSDaniel Henrique Barboza 1229c10d86fSCédric Le Goater object_property_add_child(OBJECT(pec), "phb[*]", OBJECT(phb)); 1233f4c369eSDaniel Henrique Barboza object_property_set_link(OBJECT(phb), "pec", OBJECT(pec), 124a479f0dcSDaniel Henrique Barboza &error_abort); 1253f4c369eSDaniel Henrique Barboza object_property_set_int(OBJECT(phb), "chip-id", pec->chip_id, 126a479f0dcSDaniel Henrique Barboza &error_fatal); 1273f4c369eSDaniel Henrique Barboza object_property_set_int(OBJECT(phb), "index", phb_id, 128a479f0dcSDaniel Henrique Barboza &error_fatal); 129a479f0dcSDaniel Henrique Barboza 1303f4c369eSDaniel Henrique Barboza if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) { 131a479f0dcSDaniel Henrique Barboza return; 132a479f0dcSDaniel Henrique Barboza } 133a479f0dcSDaniel Henrique Barboza } 134a479f0dcSDaniel Henrique Barboza 1354f9924c4SBenjamin Herrenschmidt static void pnv_pec_realize(DeviceState *dev, Error **errp) 1364f9924c4SBenjamin Herrenschmidt { 1374f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(dev); 138cf0ee695SCédric Le Goater PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); 1394f9924c4SBenjamin Herrenschmidt char name[64]; 1404f9924c4SBenjamin Herrenschmidt int i; 1414f9924c4SBenjamin Herrenschmidt 1426f43d255SCédric Le Goater if (pec->index >= PNV_CHIP_GET_CLASS(pec->chip)->num_pecs) { 1436f43d255SCédric Le Goater error_setg(errp, "invalid PEC index: %d", pec->index); 1446f43d255SCédric Le Goater return; 1456f43d255SCédric Le Goater } 1466f43d255SCédric Le Goater 1473f4c369eSDaniel Henrique Barboza pec->num_phbs = pecc->num_phbs[pec->index]; 148cf0ee695SCédric Le Goater 1493f4c369eSDaniel Henrique Barboza /* Create PHBs if running with defaults */ 150d786be3fSDaniel Henrique Barboza if (defaults_enabled()) { 1513f4c369eSDaniel Henrique Barboza for (i = 0; i < pec->num_phbs; i++) { 1523f4c369eSDaniel Henrique Barboza pnv_pec_default_phb_realize(pec, i, errp); 153a479f0dcSDaniel Henrique Barboza } 154d786be3fSDaniel Henrique Barboza } 1554f9924c4SBenjamin Herrenschmidt 1564f9924c4SBenjamin Herrenschmidt /* Initialize the XSCOM regions for the PEC registers */ 1574f9924c4SBenjamin Herrenschmidt snprintf(name, sizeof(name), "xscom-pec-%d.%d-nest", pec->chip_id, 1584f9924c4SBenjamin Herrenschmidt pec->index); 1594f9924c4SBenjamin Herrenschmidt pnv_xscom_region_init(&pec->nest_regs_mr, OBJECT(dev), 1604f9924c4SBenjamin Herrenschmidt &pnv_pec_nest_xscom_ops, pec, name, 1614f9924c4SBenjamin Herrenschmidt PHB4_PEC_NEST_REGS_COUNT); 1624f9924c4SBenjamin Herrenschmidt 1634f9924c4SBenjamin Herrenschmidt snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci", pec->chip_id, 1644f9924c4SBenjamin Herrenschmidt pec->index); 1654f9924c4SBenjamin Herrenschmidt pnv_xscom_region_init(&pec->pci_regs_mr, OBJECT(dev), 1664f9924c4SBenjamin Herrenschmidt &pnv_pec_pci_xscom_ops, pec, name, 1674f9924c4SBenjamin Herrenschmidt PHB4_PEC_PCI_REGS_COUNT); 1684f9924c4SBenjamin Herrenschmidt } 1694f9924c4SBenjamin Herrenschmidt 1704f9924c4SBenjamin Herrenschmidt static int pnv_pec_dt_xscom(PnvXScomInterface *dev, void *fdt, 1714f9924c4SBenjamin Herrenschmidt int xscom_offset) 1724f9924c4SBenjamin Herrenschmidt { 1734f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(dev); 1744f9924c4SBenjamin Herrenschmidt PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(dev); 1754f9924c4SBenjamin Herrenschmidt uint32_t nbase = pecc->xscom_nest_base(pec); 1764f9924c4SBenjamin Herrenschmidt uint32_t pbase = pecc->xscom_pci_base(pec); 1774f9924c4SBenjamin Herrenschmidt int offset, i; 1784f9924c4SBenjamin Herrenschmidt char *name; 1794f9924c4SBenjamin Herrenschmidt uint32_t reg[] = { 1804f9924c4SBenjamin Herrenschmidt cpu_to_be32(nbase), 1814f9924c4SBenjamin Herrenschmidt cpu_to_be32(pecc->xscom_nest_size), 1824f9924c4SBenjamin Herrenschmidt cpu_to_be32(pbase), 1834f9924c4SBenjamin Herrenschmidt cpu_to_be32(pecc->xscom_pci_size), 1844f9924c4SBenjamin Herrenschmidt }; 1854f9924c4SBenjamin Herrenschmidt 1864f9924c4SBenjamin Herrenschmidt name = g_strdup_printf("pbcq@%x", nbase); 1874f9924c4SBenjamin Herrenschmidt offset = fdt_add_subnode(fdt, xscom_offset, name); 1884f9924c4SBenjamin Herrenschmidt _FDT(offset); 1894f9924c4SBenjamin Herrenschmidt g_free(name); 1904f9924c4SBenjamin Herrenschmidt 1914f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop(fdt, offset, "reg", reg, sizeof(reg)))); 1924f9924c4SBenjamin Herrenschmidt 1934f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, offset, "ibm,pec-index", pec->index))); 1944f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, offset, "#address-cells", 1))); 1954f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, offset, "#size-cells", 0))); 1964f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop(fdt, offset, "compatible", pecc->compat, 1974f9924c4SBenjamin Herrenschmidt pecc->compat_size))); 1984f9924c4SBenjamin Herrenschmidt 1993f4c369eSDaniel Henrique Barboza for (i = 0; i < pec->num_phbs; i++) { 200d22b0c94SDaniel Henrique Barboza int phb_id = pnv_phb4_pec_get_phb_id(pec, i); 2014f9924c4SBenjamin Herrenschmidt int stk_offset; 2024f9924c4SBenjamin Herrenschmidt 2034f9924c4SBenjamin Herrenschmidt name = g_strdup_printf("stack@%x", i); 2044f9924c4SBenjamin Herrenschmidt stk_offset = fdt_add_subnode(fdt, offset, name); 2054f9924c4SBenjamin Herrenschmidt _FDT(stk_offset); 2064f9924c4SBenjamin Herrenschmidt g_free(name); 2074f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop(fdt, stk_offset, "compatible", pecc->stk_compat, 2084f9924c4SBenjamin Herrenschmidt pecc->stk_compat_size))); 2094f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, stk_offset, "reg", i))); 210d22b0c94SDaniel Henrique Barboza _FDT((fdt_setprop_cell(fdt, stk_offset, "ibm,phb-index", phb_id))); 2114f9924c4SBenjamin Herrenschmidt } 2124f9924c4SBenjamin Herrenschmidt 2134f9924c4SBenjamin Herrenschmidt return 0; 2144f9924c4SBenjamin Herrenschmidt } 2154f9924c4SBenjamin Herrenschmidt 2164f9924c4SBenjamin Herrenschmidt static Property pnv_pec_properties[] = { 2174f9924c4SBenjamin Herrenschmidt DEFINE_PROP_UINT32("index", PnvPhb4PecState, index, 0), 2184f9924c4SBenjamin Herrenschmidt DEFINE_PROP_UINT32("chip-id", PnvPhb4PecState, chip_id, 0), 2196f43d255SCédric Le Goater DEFINE_PROP_LINK("chip", PnvPhb4PecState, chip, TYPE_PNV_CHIP, 2206f43d255SCédric Le Goater PnvChip *), 2214f9924c4SBenjamin Herrenschmidt DEFINE_PROP_END_OF_LIST(), 2224f9924c4SBenjamin Herrenschmidt }; 2234f9924c4SBenjamin Herrenschmidt 2244f9924c4SBenjamin Herrenschmidt static uint32_t pnv_pec_xscom_pci_base(PnvPhb4PecState *pec) 2254f9924c4SBenjamin Herrenschmidt { 2264f9924c4SBenjamin Herrenschmidt return PNV9_XSCOM_PEC_PCI_BASE + 0x1000000 * pec->index; 2274f9924c4SBenjamin Herrenschmidt } 2284f9924c4SBenjamin Herrenschmidt 2294f9924c4SBenjamin Herrenschmidt static uint32_t pnv_pec_xscom_nest_base(PnvPhb4PecState *pec) 2304f9924c4SBenjamin Herrenschmidt { 2314f9924c4SBenjamin Herrenschmidt return PNV9_XSCOM_PEC_NEST_BASE + 0x400 * pec->index; 2324f9924c4SBenjamin Herrenschmidt } 2334f9924c4SBenjamin Herrenschmidt 234cf0ee695SCédric Le Goater /* 2353f4c369eSDaniel Henrique Barboza * PEC0 -> 1 phb 2363f4c369eSDaniel Henrique Barboza * PEC1 -> 2 phb 2373f4c369eSDaniel Henrique Barboza * PEC2 -> 3 phbs 238cf0ee695SCédric Le Goater */ 2393f4c369eSDaniel Henrique Barboza static const uint32_t pnv_pec_num_phbs[] = { 1, 2, 3 }; 240cf0ee695SCédric Le Goater 2414f9924c4SBenjamin Herrenschmidt static void pnv_pec_class_init(ObjectClass *klass, void *data) 2424f9924c4SBenjamin Herrenschmidt { 2434f9924c4SBenjamin Herrenschmidt DeviceClass *dc = DEVICE_CLASS(klass); 2444f9924c4SBenjamin Herrenschmidt PnvXScomInterfaceClass *xdc = PNV_XSCOM_INTERFACE_CLASS(klass); 2454f9924c4SBenjamin Herrenschmidt PnvPhb4PecClass *pecc = PNV_PHB4_PEC_CLASS(klass); 2464f9924c4SBenjamin Herrenschmidt static const char compat[] = "ibm,power9-pbcq"; 2474f9924c4SBenjamin Herrenschmidt static const char stk_compat[] = "ibm,power9-phb-stack"; 2484f9924c4SBenjamin Herrenschmidt 2494f9924c4SBenjamin Herrenschmidt xdc->dt_xscom = pnv_pec_dt_xscom; 2504f9924c4SBenjamin Herrenschmidt 2514f9924c4SBenjamin Herrenschmidt dc->realize = pnv_pec_realize; 2524f9924c4SBenjamin Herrenschmidt device_class_set_props(dc, pnv_pec_properties); 25323a782ebSCédric Le Goater dc->user_creatable = false; 2544f9924c4SBenjamin Herrenschmidt 2554f9924c4SBenjamin Herrenschmidt pecc->xscom_nest_base = pnv_pec_xscom_nest_base; 2564f9924c4SBenjamin Herrenschmidt pecc->xscom_pci_base = pnv_pec_xscom_pci_base; 2574f9924c4SBenjamin Herrenschmidt pecc->xscom_nest_size = PNV9_XSCOM_PEC_NEST_SIZE; 2584f9924c4SBenjamin Herrenschmidt pecc->xscom_pci_size = PNV9_XSCOM_PEC_PCI_SIZE; 2594f9924c4SBenjamin Herrenschmidt pecc->compat = compat; 2604f9924c4SBenjamin Herrenschmidt pecc->compat_size = sizeof(compat); 2614f9924c4SBenjamin Herrenschmidt pecc->stk_compat = stk_compat; 2624f9924c4SBenjamin Herrenschmidt pecc->stk_compat_size = sizeof(stk_compat); 26312060cbdSCédric Le Goater pecc->version = PNV_PHB4_VERSION; 264d3df1f64SFrederic Barrat pecc->phb_type = TYPE_PNV_PHB4; 2653f4c369eSDaniel Henrique Barboza pecc->num_phbs = pnv_pec_num_phbs; 2664f9924c4SBenjamin Herrenschmidt } 2674f9924c4SBenjamin Herrenschmidt 2684f9924c4SBenjamin Herrenschmidt static const TypeInfo pnv_pec_type_info = { 2694f9924c4SBenjamin Herrenschmidt .name = TYPE_PNV_PHB4_PEC, 2704f9924c4SBenjamin Herrenschmidt .parent = TYPE_DEVICE, 2714f9924c4SBenjamin Herrenschmidt .instance_size = sizeof(PnvPhb4PecState), 2724f9924c4SBenjamin Herrenschmidt .class_init = pnv_pec_class_init, 2734f9924c4SBenjamin Herrenschmidt .class_size = sizeof(PnvPhb4PecClass), 2744f9924c4SBenjamin Herrenschmidt .interfaces = (InterfaceInfo[]) { 2754f9924c4SBenjamin Herrenschmidt { TYPE_PNV_XSCOM_INTERFACE }, 2764f9924c4SBenjamin Herrenschmidt { } 2774f9924c4SBenjamin Herrenschmidt } 2784f9924c4SBenjamin Herrenschmidt }; 2794f9924c4SBenjamin Herrenschmidt 280623575e1SCédric Le Goater /* 281623575e1SCédric Le Goater * POWER10 definitions 282623575e1SCédric Le Goater */ 283623575e1SCédric Le Goater 284623575e1SCédric Le Goater static uint32_t pnv_phb5_pec_xscom_pci_base(PnvPhb4PecState *pec) 285623575e1SCédric Le Goater { 286623575e1SCédric Le Goater return PNV10_XSCOM_PEC_PCI_BASE + 0x1000000 * pec->index; 287623575e1SCédric Le Goater } 288623575e1SCédric Le Goater 289623575e1SCédric Le Goater static uint32_t pnv_phb5_pec_xscom_nest_base(PnvPhb4PecState *pec) 290623575e1SCédric Le Goater { 291623575e1SCédric Le Goater /* index goes down ... */ 292623575e1SCédric Le Goater return PNV10_XSCOM_PEC_NEST_BASE - 0x1000000 * pec->index; 293623575e1SCédric Le Goater } 294623575e1SCédric Le Goater 295623575e1SCédric Le Goater /* 296623575e1SCédric Le Goater * PEC0 -> 3 stacks 297623575e1SCédric Le Goater * PEC1 -> 3 stacks 298623575e1SCédric Le Goater */ 299623575e1SCédric Le Goater static const uint32_t pnv_phb5_pec_num_stacks[] = { 3, 3 }; 300623575e1SCédric Le Goater 301623575e1SCédric Le Goater static void pnv_phb5_pec_class_init(ObjectClass *klass, void *data) 302623575e1SCédric Le Goater { 303623575e1SCédric Le Goater PnvPhb4PecClass *pecc = PNV_PHB4_PEC_CLASS(klass); 304623575e1SCédric Le Goater static const char compat[] = "ibm,power10-pbcq"; 305623575e1SCédric Le Goater static const char stk_compat[] = "ibm,power10-phb-stack"; 306623575e1SCédric Le Goater 307623575e1SCédric Le Goater pecc->xscom_nest_base = pnv_phb5_pec_xscom_nest_base; 308623575e1SCédric Le Goater pecc->xscom_pci_base = pnv_phb5_pec_xscom_pci_base; 309623575e1SCédric Le Goater pecc->xscom_nest_size = PNV10_XSCOM_PEC_NEST_SIZE; 310623575e1SCédric Le Goater pecc->xscom_pci_size = PNV10_XSCOM_PEC_PCI_SIZE; 311623575e1SCédric Le Goater pecc->compat = compat; 312623575e1SCédric Le Goater pecc->compat_size = sizeof(compat); 313623575e1SCédric Le Goater pecc->stk_compat = stk_compat; 314623575e1SCédric Le Goater pecc->stk_compat_size = sizeof(stk_compat); 315623575e1SCédric Le Goater pecc->version = PNV_PHB5_VERSION; 316d3df1f64SFrederic Barrat pecc->phb_type = TYPE_PNV_PHB5; 317623575e1SCédric Le Goater pecc->num_phbs = pnv_phb5_pec_num_stacks; 318623575e1SCédric Le Goater } 319623575e1SCédric Le Goater 320623575e1SCédric Le Goater static const TypeInfo pnv_phb5_pec_type_info = { 321623575e1SCédric Le Goater .name = TYPE_PNV_PHB5_PEC, 322623575e1SCédric Le Goater .parent = TYPE_PNV_PHB4_PEC, 323623575e1SCédric Le Goater .instance_size = sizeof(PnvPhb4PecState), 324623575e1SCédric Le Goater .class_init = pnv_phb5_pec_class_init, 325623575e1SCédric Le Goater .class_size = sizeof(PnvPhb4PecClass), 326623575e1SCédric Le Goater .interfaces = (InterfaceInfo[]) { 327623575e1SCédric Le Goater { TYPE_PNV_XSCOM_INTERFACE }, 328623575e1SCédric Le Goater { } 329623575e1SCédric Le Goater } 330623575e1SCédric Le Goater }; 331623575e1SCédric Le Goater 3324f9924c4SBenjamin Herrenschmidt static void pnv_pec_register_types(void) 3334f9924c4SBenjamin Herrenschmidt { 3344f9924c4SBenjamin Herrenschmidt type_register_static(&pnv_pec_type_info); 335623575e1SCédric Le Goater type_register_static(&pnv_phb5_pec_type_info); 3364f9924c4SBenjamin Herrenschmidt } 3374f9924c4SBenjamin Herrenschmidt 3384f9924c4SBenjamin Herrenschmidt type_init(pnv_pec_register_types); 339