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-common.h" 124f9924c4SBenjamin Herrenschmidt #include "qemu/log.h" 134f9924c4SBenjamin Herrenschmidt #include "target/ppc/cpu.h" 144f9924c4SBenjamin Herrenschmidt #include "hw/ppc/fdt.h" 154f9924c4SBenjamin Herrenschmidt #include "hw/pci-host/pnv_phb4_regs.h" 164f9924c4SBenjamin Herrenschmidt #include "hw/pci-host/pnv_phb4.h" 174f9924c4SBenjamin Herrenschmidt #include "hw/ppc/pnv_xscom.h" 184f9924c4SBenjamin Herrenschmidt #include "hw/pci/pci_bridge.h" 194f9924c4SBenjamin Herrenschmidt #include "hw/pci/pci_bus.h" 204f9924c4SBenjamin Herrenschmidt #include "hw/ppc/pnv.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 115*3f4c369eSDaniel 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 { 119*3f4c369eSDaniel Henrique Barboza PnvPHB4 *phb = PNV_PHB4(qdev_new(TYPE_PNV_PHB4)); 120a479f0dcSDaniel Henrique Barboza PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); 121a479f0dcSDaniel Henrique Barboza int phb_id = pnv_phb4_pec_get_phb_id(pec, stack_no); 122a479f0dcSDaniel Henrique Barboza 123*3f4c369eSDaniel Henrique Barboza object_property_set_link(OBJECT(phb), "pec", OBJECT(pec), 124a479f0dcSDaniel Henrique Barboza &error_abort); 125*3f4c369eSDaniel Henrique Barboza object_property_set_int(OBJECT(phb), "chip-id", pec->chip_id, 126a479f0dcSDaniel Henrique Barboza &error_fatal); 127*3f4c369eSDaniel Henrique Barboza object_property_set_int(OBJECT(phb), "index", phb_id, 128a479f0dcSDaniel Henrique Barboza &error_fatal); 129*3f4c369eSDaniel Henrique Barboza object_property_set_int(OBJECT(phb), "version", pecc->version, 130a479f0dcSDaniel Henrique Barboza &error_fatal); 131a479f0dcSDaniel Henrique Barboza 132*3f4c369eSDaniel Henrique Barboza if (!sysbus_realize(SYS_BUS_DEVICE(phb), errp)) { 133a479f0dcSDaniel Henrique Barboza return; 134a479f0dcSDaniel Henrique Barboza } 135a479f0dcSDaniel Henrique Barboza } 136a479f0dcSDaniel Henrique Barboza 1374f9924c4SBenjamin Herrenschmidt static void pnv_pec_realize(DeviceState *dev, Error **errp) 1384f9924c4SBenjamin Herrenschmidt { 1394f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(dev); 140cf0ee695SCédric Le Goater PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(pec); 1414f9924c4SBenjamin Herrenschmidt char name[64]; 1424f9924c4SBenjamin Herrenschmidt int i; 1434f9924c4SBenjamin Herrenschmidt 1446f43d255SCédric Le Goater if (pec->index >= PNV_CHIP_GET_CLASS(pec->chip)->num_pecs) { 1456f43d255SCédric Le Goater error_setg(errp, "invalid PEC index: %d", pec->index); 1466f43d255SCédric Le Goater return; 1476f43d255SCédric Le Goater } 1486f43d255SCédric Le Goater 149*3f4c369eSDaniel Henrique Barboza pec->num_phbs = pecc->num_phbs[pec->index]; 150cf0ee695SCédric Le Goater 151*3f4c369eSDaniel Henrique Barboza /* Create PHBs if running with defaults */ 152a479f0dcSDaniel Henrique Barboza if (defaults_enabled()) { 153*3f4c369eSDaniel Henrique Barboza for (i = 0; i < pec->num_phbs; i++) { 154*3f4c369eSDaniel Henrique Barboza pnv_pec_default_phb_realize(pec, i, errp); 155a479f0dcSDaniel Henrique Barboza } 156efa05595SMarkus Armbruster } 1574f9924c4SBenjamin Herrenschmidt 1584f9924c4SBenjamin Herrenschmidt /* Initialize the XSCOM regions for the PEC registers */ 1594f9924c4SBenjamin Herrenschmidt snprintf(name, sizeof(name), "xscom-pec-%d.%d-nest", pec->chip_id, 1604f9924c4SBenjamin Herrenschmidt pec->index); 1614f9924c4SBenjamin Herrenschmidt pnv_xscom_region_init(&pec->nest_regs_mr, OBJECT(dev), 1624f9924c4SBenjamin Herrenschmidt &pnv_pec_nest_xscom_ops, pec, name, 1634f9924c4SBenjamin Herrenschmidt PHB4_PEC_NEST_REGS_COUNT); 1644f9924c4SBenjamin Herrenschmidt 1654f9924c4SBenjamin Herrenschmidt snprintf(name, sizeof(name), "xscom-pec-%d.%d-pci", pec->chip_id, 1664f9924c4SBenjamin Herrenschmidt pec->index); 1674f9924c4SBenjamin Herrenschmidt pnv_xscom_region_init(&pec->pci_regs_mr, OBJECT(dev), 1684f9924c4SBenjamin Herrenschmidt &pnv_pec_pci_xscom_ops, pec, name, 1694f9924c4SBenjamin Herrenschmidt PHB4_PEC_PCI_REGS_COUNT); 1704f9924c4SBenjamin Herrenschmidt } 1714f9924c4SBenjamin Herrenschmidt 1724f9924c4SBenjamin Herrenschmidt static int pnv_pec_dt_xscom(PnvXScomInterface *dev, void *fdt, 1734f9924c4SBenjamin Herrenschmidt int xscom_offset) 1744f9924c4SBenjamin Herrenschmidt { 1754f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *pec = PNV_PHB4_PEC(dev); 1764f9924c4SBenjamin Herrenschmidt PnvPhb4PecClass *pecc = PNV_PHB4_PEC_GET_CLASS(dev); 1774f9924c4SBenjamin Herrenschmidt uint32_t nbase = pecc->xscom_nest_base(pec); 1784f9924c4SBenjamin Herrenschmidt uint32_t pbase = pecc->xscom_pci_base(pec); 1794f9924c4SBenjamin Herrenschmidt int offset, i; 1804f9924c4SBenjamin Herrenschmidt char *name; 1814f9924c4SBenjamin Herrenschmidt uint32_t reg[] = { 1824f9924c4SBenjamin Herrenschmidt cpu_to_be32(nbase), 1834f9924c4SBenjamin Herrenschmidt cpu_to_be32(pecc->xscom_nest_size), 1844f9924c4SBenjamin Herrenschmidt cpu_to_be32(pbase), 1854f9924c4SBenjamin Herrenschmidt cpu_to_be32(pecc->xscom_pci_size), 1864f9924c4SBenjamin Herrenschmidt }; 1874f9924c4SBenjamin Herrenschmidt 1884f9924c4SBenjamin Herrenschmidt name = g_strdup_printf("pbcq@%x", nbase); 1894f9924c4SBenjamin Herrenschmidt offset = fdt_add_subnode(fdt, xscom_offset, name); 1904f9924c4SBenjamin Herrenschmidt _FDT(offset); 1914f9924c4SBenjamin Herrenschmidt g_free(name); 1924f9924c4SBenjamin Herrenschmidt 1934f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop(fdt, offset, "reg", reg, sizeof(reg)))); 1944f9924c4SBenjamin Herrenschmidt 1954f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, offset, "ibm,pec-index", pec->index))); 1964f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, offset, "#address-cells", 1))); 1974f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, offset, "#size-cells", 0))); 1984f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop(fdt, offset, "compatible", pecc->compat, 1994f9924c4SBenjamin Herrenschmidt pecc->compat_size))); 2004f9924c4SBenjamin Herrenschmidt 201*3f4c369eSDaniel Henrique Barboza for (i = 0; i < pec->num_phbs; i++) { 202d22b0c94SDaniel Henrique Barboza int phb_id = pnv_phb4_pec_get_phb_id(pec, i); 2034f9924c4SBenjamin Herrenschmidt int stk_offset; 2044f9924c4SBenjamin Herrenschmidt 2054f9924c4SBenjamin Herrenschmidt name = g_strdup_printf("stack@%x", i); 2064f9924c4SBenjamin Herrenschmidt stk_offset = fdt_add_subnode(fdt, offset, name); 2074f9924c4SBenjamin Herrenschmidt _FDT(stk_offset); 2084f9924c4SBenjamin Herrenschmidt g_free(name); 2094f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop(fdt, stk_offset, "compatible", pecc->stk_compat, 2104f9924c4SBenjamin Herrenschmidt pecc->stk_compat_size))); 2114f9924c4SBenjamin Herrenschmidt _FDT((fdt_setprop_cell(fdt, stk_offset, "reg", i))); 212d22b0c94SDaniel Henrique Barboza _FDT((fdt_setprop_cell(fdt, stk_offset, "ibm,phb-index", phb_id))); 2134f9924c4SBenjamin Herrenschmidt } 2144f9924c4SBenjamin Herrenschmidt 2154f9924c4SBenjamin Herrenschmidt return 0; 2164f9924c4SBenjamin Herrenschmidt } 2174f9924c4SBenjamin Herrenschmidt 2184f9924c4SBenjamin Herrenschmidt static Property pnv_pec_properties[] = { 2194f9924c4SBenjamin Herrenschmidt DEFINE_PROP_UINT32("index", PnvPhb4PecState, index, 0), 2204f9924c4SBenjamin Herrenschmidt DEFINE_PROP_UINT32("chip-id", PnvPhb4PecState, chip_id, 0), 2216f43d255SCédric Le Goater DEFINE_PROP_LINK("chip", PnvPhb4PecState, chip, TYPE_PNV_CHIP, 2226f43d255SCédric Le Goater PnvChip *), 2234f9924c4SBenjamin Herrenschmidt DEFINE_PROP_END_OF_LIST(), 2244f9924c4SBenjamin Herrenschmidt }; 2254f9924c4SBenjamin Herrenschmidt 2264f9924c4SBenjamin Herrenschmidt static uint32_t pnv_pec_xscom_pci_base(PnvPhb4PecState *pec) 2274f9924c4SBenjamin Herrenschmidt { 2284f9924c4SBenjamin Herrenschmidt return PNV9_XSCOM_PEC_PCI_BASE + 0x1000000 * pec->index; 2294f9924c4SBenjamin Herrenschmidt } 2304f9924c4SBenjamin Herrenschmidt 2314f9924c4SBenjamin Herrenschmidt static uint32_t pnv_pec_xscom_nest_base(PnvPhb4PecState *pec) 2324f9924c4SBenjamin Herrenschmidt { 2334f9924c4SBenjamin Herrenschmidt return PNV9_XSCOM_PEC_NEST_BASE + 0x400 * pec->index; 2344f9924c4SBenjamin Herrenschmidt } 2354f9924c4SBenjamin Herrenschmidt 236cf0ee695SCédric Le Goater /* 237*3f4c369eSDaniel Henrique Barboza * PEC0 -> 1 phb 238*3f4c369eSDaniel Henrique Barboza * PEC1 -> 2 phb 239*3f4c369eSDaniel Henrique Barboza * PEC2 -> 3 phbs 240cf0ee695SCédric Le Goater */ 241*3f4c369eSDaniel Henrique Barboza static const uint32_t pnv_pec_num_phbs[] = { 1, 2, 3 }; 242cf0ee695SCédric Le Goater 2434f9924c4SBenjamin Herrenschmidt static void pnv_pec_class_init(ObjectClass *klass, void *data) 2444f9924c4SBenjamin Herrenschmidt { 2454f9924c4SBenjamin Herrenschmidt DeviceClass *dc = DEVICE_CLASS(klass); 2464f9924c4SBenjamin Herrenschmidt PnvXScomInterfaceClass *xdc = PNV_XSCOM_INTERFACE_CLASS(klass); 2474f9924c4SBenjamin Herrenschmidt PnvPhb4PecClass *pecc = PNV_PHB4_PEC_CLASS(klass); 2484f9924c4SBenjamin Herrenschmidt static const char compat[] = "ibm,power9-pbcq"; 2494f9924c4SBenjamin Herrenschmidt static const char stk_compat[] = "ibm,power9-phb-stack"; 2504f9924c4SBenjamin Herrenschmidt 2514f9924c4SBenjamin Herrenschmidt xdc->dt_xscom = pnv_pec_dt_xscom; 2524f9924c4SBenjamin Herrenschmidt 2534f9924c4SBenjamin Herrenschmidt dc->realize = pnv_pec_realize; 2544f9924c4SBenjamin Herrenschmidt device_class_set_props(dc, pnv_pec_properties); 25523a782ebSCédric Le Goater dc->user_creatable = false; 2564f9924c4SBenjamin Herrenschmidt 2574f9924c4SBenjamin Herrenschmidt pecc->xscom_nest_base = pnv_pec_xscom_nest_base; 2584f9924c4SBenjamin Herrenschmidt pecc->xscom_pci_base = pnv_pec_xscom_pci_base; 2594f9924c4SBenjamin Herrenschmidt pecc->xscom_nest_size = PNV9_XSCOM_PEC_NEST_SIZE; 2604f9924c4SBenjamin Herrenschmidt pecc->xscom_pci_size = PNV9_XSCOM_PEC_PCI_SIZE; 2614f9924c4SBenjamin Herrenschmidt pecc->compat = compat; 2624f9924c4SBenjamin Herrenschmidt pecc->compat_size = sizeof(compat); 2634f9924c4SBenjamin Herrenschmidt pecc->stk_compat = stk_compat; 2644f9924c4SBenjamin Herrenschmidt pecc->stk_compat_size = sizeof(stk_compat); 26512060cbdSCédric Le Goater pecc->version = PNV_PHB4_VERSION; 266*3f4c369eSDaniel Henrique Barboza pecc->num_phbs = pnv_pec_num_phbs; 2674f9924c4SBenjamin Herrenschmidt } 2684f9924c4SBenjamin Herrenschmidt 2694f9924c4SBenjamin Herrenschmidt static const TypeInfo pnv_pec_type_info = { 2704f9924c4SBenjamin Herrenschmidt .name = TYPE_PNV_PHB4_PEC, 2714f9924c4SBenjamin Herrenschmidt .parent = TYPE_DEVICE, 2724f9924c4SBenjamin Herrenschmidt .instance_size = sizeof(PnvPhb4PecState), 2734f9924c4SBenjamin Herrenschmidt .class_init = pnv_pec_class_init, 2744f9924c4SBenjamin Herrenschmidt .class_size = sizeof(PnvPhb4PecClass), 2754f9924c4SBenjamin Herrenschmidt .interfaces = (InterfaceInfo[]) { 2764f9924c4SBenjamin Herrenschmidt { TYPE_PNV_XSCOM_INTERFACE }, 2774f9924c4SBenjamin Herrenschmidt { } 2784f9924c4SBenjamin Herrenschmidt } 2794f9924c4SBenjamin Herrenschmidt }; 2804f9924c4SBenjamin Herrenschmidt 2815bc67b05SDaniel Henrique Barboza static void pnv_pec_stk_realize(DeviceState *dev, Error **errp) 2825bc67b05SDaniel Henrique Barboza { 2835bc67b05SDaniel Henrique Barboza } 2845bc67b05SDaniel Henrique Barboza 2854f9924c4SBenjamin Herrenschmidt static Property pnv_pec_stk_properties[] = { 2864f9924c4SBenjamin Herrenschmidt DEFINE_PROP_LINK("pec", PnvPhb4PecStack, pec, TYPE_PNV_PHB4_PEC, 2874f9924c4SBenjamin Herrenschmidt PnvPhb4PecState *), 2884f9924c4SBenjamin Herrenschmidt DEFINE_PROP_END_OF_LIST(), 2894f9924c4SBenjamin Herrenschmidt }; 2904f9924c4SBenjamin Herrenschmidt 2914f9924c4SBenjamin Herrenschmidt static void pnv_pec_stk_class_init(ObjectClass *klass, void *data) 2924f9924c4SBenjamin Herrenschmidt { 2934f9924c4SBenjamin Herrenschmidt DeviceClass *dc = DEVICE_CLASS(klass); 2944f9924c4SBenjamin Herrenschmidt 2954f9924c4SBenjamin Herrenschmidt device_class_set_props(dc, pnv_pec_stk_properties); 2964f9924c4SBenjamin Herrenschmidt dc->realize = pnv_pec_stk_realize; 29723a782ebSCédric Le Goater dc->user_creatable = false; 2984f9924c4SBenjamin Herrenschmidt 2994f9924c4SBenjamin Herrenschmidt /* TODO: reset regs ? */ 3004f9924c4SBenjamin Herrenschmidt } 3014f9924c4SBenjamin Herrenschmidt 3024f9924c4SBenjamin Herrenschmidt static const TypeInfo pnv_pec_stk_type_info = { 3034f9924c4SBenjamin Herrenschmidt .name = TYPE_PNV_PHB4_PEC_STACK, 3044f9924c4SBenjamin Herrenschmidt .parent = TYPE_DEVICE, 3054f9924c4SBenjamin Herrenschmidt .instance_size = sizeof(PnvPhb4PecStack), 3064f9924c4SBenjamin Herrenschmidt .class_init = pnv_pec_stk_class_init, 3074f9924c4SBenjamin Herrenschmidt .interfaces = (InterfaceInfo[]) { 3084f9924c4SBenjamin Herrenschmidt { TYPE_PNV_XSCOM_INTERFACE }, 3094f9924c4SBenjamin Herrenschmidt { } 3104f9924c4SBenjamin Herrenschmidt } 3114f9924c4SBenjamin Herrenschmidt }; 3124f9924c4SBenjamin Herrenschmidt 3134f9924c4SBenjamin Herrenschmidt static void pnv_pec_register_types(void) 3144f9924c4SBenjamin Herrenschmidt { 3154f9924c4SBenjamin Herrenschmidt type_register_static(&pnv_pec_type_info); 3164f9924c4SBenjamin Herrenschmidt type_register_static(&pnv_pec_stk_type_info); 3174f9924c4SBenjamin Herrenschmidt } 3184f9924c4SBenjamin Herrenschmidt 3194f9924c4SBenjamin Herrenschmidt type_init(pnv_pec_register_types); 320