| 1 | /* |
| 2 | * QEMU PowerPC PowerNV (POWER10) PHB5 PEC model |
| 3 | * |
| 4 | * Copyright (c) 2018-2026, IBM Corporation. |
| 5 | * |
| 6 | * SPDX-License-Identifier: GPL-2.0-or-later |
| 7 | */ |
| 8 | |
| 9 | #include "qemu/osdep.h" |
| 10 | #include "hw/pci-host/pnv_phb4.h" |
| 11 | #include "hw/ppc/pnv_xscom.h" |
| 12 | |
| 13 | #define XPEC_PCI_CPLT_OFFSET 0x1000000ULL |
| 14 | |
| 15 | /* |
| 16 | * POWER10 definitions |
| 17 | */ |
| 18 | static uint32_t pnv_phb5_pec_xscom_cplt_base(PnvPhb4PecState *pec) |
| 19 | { |
| 20 | return PNV10_XSCOM_PEC_NEST_CPLT_BASE + XPEC_PCI_CPLT_OFFSET * pec->index; |
| 21 | } |
| 22 | |
| 23 | static uint32_t pnv_phb5_pec_xscom_pci_base(PnvPhb4PecState *pec) |
| 24 | { |
| 25 | return PNV10_XSCOM_PEC_PCI_BASE + 0x1000000 * pec->index; |
| 26 | } |
| 27 | |
| 28 | static uint32_t pnv_phb5_pec_xscom_nest_base(PnvPhb4PecState *pec) |
| 29 | { |
| 30 | /* index goes down ... */ |
| 31 | return PNV10_XSCOM_PEC_NEST_BASE - 0x1000000 * pec->index; |
| 32 | } |
| 33 | |
| 34 | /* |
| 35 | * PEC0 -> 3 stacks |
| 36 | * PEC1 -> 3 stacks |
| 37 | */ |
| 38 | static const uint32_t pnv_phb5_pec_num_stacks[] = { 3, 3 }; |
| 39 | |
| 40 | static void pnv_phb5_pec_class_init(ObjectClass *klass, const void *data) |
| 41 | { |
| 42 | PnvPhb4PecClass *pecc = PNV_PHB4_PEC_CLASS(klass); |
| 43 | static const char compat[] = "ibm,power10-pbcq"; |
| 44 | static const char stk_compat[] = "ibm,power10-phb-stack"; |
| 45 | |
| 46 | pecc->xscom_cplt_base = pnv_phb5_pec_xscom_cplt_base; |
| 47 | pecc->xscom_nest_base = pnv_phb5_pec_xscom_nest_base; |
| 48 | pecc->xscom_pci_base = pnv_phb5_pec_xscom_pci_base; |
| 49 | pecc->xscom_nest_size = PNV10_XSCOM_PEC_NEST_SIZE; |
| 50 | pecc->xscom_pci_size = PNV10_XSCOM_PEC_PCI_SIZE; |
| 51 | pecc->compat = compat; |
| 52 | pecc->compat_size = sizeof(compat); |
| 53 | pecc->stk_compat = stk_compat; |
| 54 | pecc->stk_compat_size = sizeof(stk_compat); |
| 55 | pecc->version = PNV_PHB5_VERSION; |
| 56 | pecc->phb_type = TYPE_PNV_PHB5; |
| 57 | pecc->num_phbs = pnv_phb5_pec_num_stacks; |
| 58 | } |
| 59 | |
| 60 | static const TypeInfo pnv_phb5_pec_type_info = { |
| 61 | .name = TYPE_PNV_PHB5_PEC, |
| 62 | .parent = TYPE_PNV_PHB4_PEC, |
| 63 | .instance_size = sizeof(PnvPhb4PecState), |
| 64 | .class_init = pnv_phb5_pec_class_init, |
| 65 | .class_size = sizeof(PnvPhb4PecClass), |
| 66 | .interfaces = (const InterfaceInfo[]) { |
| 67 | { TYPE_PNV_XSCOM_INTERFACE }, |
| 68 | { } |
| 69 | } |
| 70 | }; |
| 71 | |
| 72 | static void pnv_phb5_pec_register_types(void) |
| 73 | { |
| 74 | type_register_static(&pnv_phb5_pec_type_info); |
| 75 | } |
| 76 | |
| 77 | type_init(pnv_phb5_pec_register_types); |