1 /* 2 * QEMU PowerPC PowerNV XSCOM bus definitions 3 * 4 * Copyright (c) 2016, IBM Corporation. 5 * 6 * This library is free software; you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public 8 * License as published by the Free Software Foundation; either 9 * version 2 of the License, or (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with this library; if not, see <http://www.gnu.org/licenses/>. 18 */ 19 20 #ifndef PPC_PNV_XSCOM_H 21 #define PPC_PNV_XSCOM_H 22 23 #include "qom/object.h" 24 25 typedef struct PnvXScomInterface PnvXScomInterface; 26 27 #define TYPE_PNV_XSCOM_INTERFACE "pnv-xscom-interface" 28 #define PNV_XSCOM_INTERFACE(obj) \ 29 INTERFACE_CHECK(PnvXScomInterface, (obj), TYPE_PNV_XSCOM_INTERFACE) 30 #define PNV_XSCOM_INTERFACE_CLASS(klass) \ 31 OBJECT_CLASS_CHECK(PnvXScomInterfaceClass, (klass), \ 32 TYPE_PNV_XSCOM_INTERFACE) 33 #define PNV_XSCOM_INTERFACE_GET_CLASS(obj) \ 34 OBJECT_GET_CLASS(PnvXScomInterfaceClass, (obj), TYPE_PNV_XSCOM_INTERFACE) 35 36 typedef struct PnvXScomInterfaceClass { 37 InterfaceClass parent; 38 int (*dt_xscom)(PnvXScomInterface *dev, void *fdt, int offset); 39 } PnvXScomInterfaceClass; 40 41 /* 42 * Layout of the XSCOM PCB addresses of EX core 1 (POWER 8) 43 * 44 * GPIO 0x1100xxxx 45 * SCOM 0x1101xxxx 46 * OHA 0x1102xxxx 47 * CLOCK CTL 0x1103xxxx 48 * FIR 0x1104xxxx 49 * THERM 0x1105xxxx 50 * <reserved> 0x1106xxxx 51 * .. 52 * 0x110Exxxx 53 * PCB SLAVE 0x110Fxxxx 54 */ 55 56 #define PNV_XSCOM_EX_CORE_BASE 0x10000000ull 57 58 #define PNV_XSCOM_EX_BASE(core) \ 59 (PNV_XSCOM_EX_CORE_BASE | ((uint64_t)(core) << 24)) 60 #define PNV_XSCOM_EX_SIZE 0x100000 61 62 #define PNV_XSCOM_LPC_BASE 0xb0020 63 #define PNV_XSCOM_LPC_SIZE 0x4 64 65 #define PNV_XSCOM_PSIHB_BASE 0x2010900 66 #define PNV_XSCOM_PSIHB_SIZE 0x20 67 68 #define PNV_XSCOM_OCC_BASE 0x0066000 69 #define PNV_XSCOM_OCC_SIZE 0x6000 70 71 /* 72 * Layout of the XSCOM PCB addresses (POWER 9) 73 */ 74 #define PNV9_XSCOM_EC_BASE(core) \ 75 ((uint64_t)(((core) & 0x1F) + 0x20) << 24) 76 #define PNV9_XSCOM_EC_SIZE 0x100000 77 78 #define PNV9_XSCOM_EQ_BASE(core) \ 79 ((uint64_t)(((core) & 0x1C) + 0x40) << 22) 80 #define PNV9_XSCOM_EQ_SIZE 0x100000 81 82 #define PNV9_XSCOM_OCC_BASE PNV_XSCOM_OCC_BASE 83 #define PNV9_XSCOM_OCC_SIZE 0x8000 84 85 #define PNV9_XSCOM_PSIHB_BASE 0x5012900 86 #define PNV9_XSCOM_PSIHB_SIZE 0x100 87 88 #define PNV9_XSCOM_XIVE_BASE 0x5013000 89 #define PNV9_XSCOM_XIVE_SIZE 0x300 90 91 /* 92 * Layout of the XSCOM PCB addresses (POWER 10) 93 */ 94 #define PNV10_XSCOM_EQ_CHIPLET(core) (0x20 + ((core) >> 2)) 95 #define PNV10_XSCOM_EQ(chiplet) ((chiplet) << 24) 96 #define PNV10_XSCOM_EC(proc) \ 97 ((0x2 << 16) | ((1 << (3 - (proc))) << 12)) 98 99 #define PNV10_XSCOM_EQ_BASE(core) \ 100 ((uint64_t) PNV10_XSCOM_EQ(PNV10_XSCOM_EQ_CHIPLET(core))) 101 #define PNV10_XSCOM_EQ_SIZE 0x100000 102 103 #define PNV10_XSCOM_EC_BASE(core) \ 104 ((uint64_t) PNV10_XSCOM_EQ_BASE(core) | PNV10_XSCOM_EC(core & 0x3)) 105 #define PNV10_XSCOM_EC_SIZE 0x100000 106 107 #define PNV10_XSCOM_PSIHB_BASE 0x3011D00 108 #define PNV10_XSCOM_PSIHB_SIZE 0x100 109 110 extern void pnv_xscom_realize(PnvChip *chip, uint64_t size, Error **errp); 111 extern int pnv_dt_xscom(PnvChip *chip, void *fdt, int offset); 112 113 extern void pnv_xscom_add_subregion(PnvChip *chip, hwaddr offset, 114 MemoryRegion *mr); 115 extern void pnv_xscom_region_init(MemoryRegion *mr, 116 struct Object *owner, 117 const MemoryRegionOps *ops, 118 void *opaque, 119 const char *name, 120 uint64_t size); 121 122 #endif /* PPC_PNV_XSCOM_H */ 123