xref: /openbmc/qemu/include/hw/ppc/pnv_xscom.h (revision db1015e9)
1967b7523SCédric Le Goater /*
2967b7523SCédric Le Goater  * QEMU PowerPC PowerNV XSCOM bus definitions
3967b7523SCédric Le Goater  *
4967b7523SCédric Le Goater  * Copyright (c) 2016, IBM Corporation.
5967b7523SCédric Le Goater  *
6967b7523SCédric Le Goater  * This library is free software; you can redistribute it and/or
7967b7523SCédric Le Goater  * modify it under the terms of the GNU Lesser General Public
8967b7523SCédric Le Goater  * License as published by the Free Software Foundation; either
9967b7523SCédric Le Goater  * version 2 of the License, or (at your option) any later version.
10967b7523SCédric Le Goater  *
11967b7523SCédric Le Goater  * This library is distributed in the hope that it will be useful,
12967b7523SCédric Le Goater  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13967b7523SCédric Le Goater  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14967b7523SCédric Le Goater  * Lesser General Public License for more details.
15967b7523SCédric Le Goater  *
16967b7523SCédric Le Goater  * You should have received a copy of the GNU Lesser General Public
17967b7523SCédric Le Goater  * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18967b7523SCédric Le Goater  */
19a8b991b5SMarkus Armbruster 
20a8b991b5SMarkus Armbruster #ifndef PPC_PNV_XSCOM_H
21a8b991b5SMarkus Armbruster #define PPC_PNV_XSCOM_H
22967b7523SCédric Le Goater 
23967b7523SCédric Le Goater #include "qom/object.h"
24967b7523SCédric Le Goater 
2590cce00cSGreg Kurz typedef struct PnvXScomInterface PnvXScomInterface;
26967b7523SCédric Le Goater 
27967b7523SCédric Le Goater #define TYPE_PNV_XSCOM_INTERFACE "pnv-xscom-interface"
28967b7523SCédric Le Goater #define PNV_XSCOM_INTERFACE(obj) \
2990cce00cSGreg Kurz     INTERFACE_CHECK(PnvXScomInterface, (obj), TYPE_PNV_XSCOM_INTERFACE)
30*db1015e9SEduardo Habkost typedef struct PnvXScomInterfaceClass PnvXScomInterfaceClass;
31967b7523SCédric Le Goater #define PNV_XSCOM_INTERFACE_CLASS(klass)                \
32967b7523SCédric Le Goater     OBJECT_CLASS_CHECK(PnvXScomInterfaceClass, (klass), \
33967b7523SCédric Le Goater                        TYPE_PNV_XSCOM_INTERFACE)
34967b7523SCédric Le Goater #define PNV_XSCOM_INTERFACE_GET_CLASS(obj) \
35967b7523SCédric Le Goater      OBJECT_GET_CLASS(PnvXScomInterfaceClass, (obj), TYPE_PNV_XSCOM_INTERFACE)
36967b7523SCédric Le Goater 
37*db1015e9SEduardo Habkost struct PnvXScomInterfaceClass {
38967b7523SCédric Le Goater     InterfaceClass parent;
39b168a138SCédric Le Goater     int (*dt_xscom)(PnvXScomInterface *dev, void *fdt, int offset);
40*db1015e9SEduardo Habkost };
41967b7523SCédric Le Goater 
4224ece072SCédric Le Goater /*
43ad521238SCédric Le Goater  * Layout of the XSCOM PCB addresses of EX core 1 (POWER 8)
4424ece072SCédric Le Goater  *
4524ece072SCédric Le Goater  *   GPIO        0x1100xxxx
4624ece072SCédric Le Goater  *   SCOM        0x1101xxxx
4724ece072SCédric Le Goater  *   OHA         0x1102xxxx
4824ece072SCédric Le Goater  *   CLOCK CTL   0x1103xxxx
4924ece072SCédric Le Goater  *   FIR         0x1104xxxx
5024ece072SCédric Le Goater  *   THERM       0x1105xxxx
5124ece072SCédric Le Goater  *   <reserved>  0x1106xxxx
5224ece072SCédric Le Goater  *               ..
5324ece072SCédric Le Goater  *               0x110Exxxx
5424ece072SCédric Le Goater  *   PCB SLAVE   0x110Fxxxx
5524ece072SCédric Le Goater  */
5624ece072SCédric Le Goater 
57c035851aSCédric Le Goater #define PNV_XSCOM_EX_CORE_BASE    0x10000000ull
58c035851aSCédric Le Goater 
59c035851aSCédric Le Goater #define PNV_XSCOM_EX_BASE(core) \
60c035851aSCédric Le Goater     (PNV_XSCOM_EX_CORE_BASE | ((uint64_t)(core) << 24))
61c035851aSCédric Le Goater #define PNV_XSCOM_EX_SIZE         0x100000
62c035851aSCédric Le Goater 
63a3980bf5SBenjamin Herrenschmidt #define PNV_XSCOM_LPC_BASE        0xb0020
64a3980bf5SBenjamin Herrenschmidt #define PNV_XSCOM_LPC_SIZE        0x4
65a3980bf5SBenjamin Herrenschmidt 
6654f59d78SCédric Le Goater #define PNV_XSCOM_PSIHB_BASE      0x2010900
6754f59d78SCédric Le Goater #define PNV_XSCOM_PSIHB_SIZE      0x20
6854f59d78SCédric Le Goater 
690722d05aSBenjamin Herrenschmidt #define PNV_XSCOM_OCC_BASE        0x0066000
700722d05aSBenjamin Herrenschmidt #define PNV_XSCOM_OCC_SIZE        0x6000
710722d05aSBenjamin Herrenschmidt 
728f092316SCédric Le Goater #define PNV_XSCOM_PBA_BASE        0x2013f00
738f092316SCédric Le Goater #define PNV_XSCOM_PBA_SIZE        0x40
748f092316SCédric Le Goater 
759ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_NEST_BASE  0x2012000
769ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_NEST_SIZE  0x46
779ae1329eSCédric Le Goater 
789ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_PCI_BASE   0x9012000
799ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_PCI_SIZE   0x15
809ae1329eSCédric Le Goater 
819ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_SPCI_BASE  0x9013c00
829ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_SPCI_SIZE  0x5
839ae1329eSCédric Le Goater 
842b548a42SCédric Le Goater /*
852b548a42SCédric Le Goater  * Layout of the XSCOM PCB addresses (POWER 9)
862b548a42SCédric Le Goater  */
875dad902cSCédric Le Goater #define PNV9_XSCOM_EC_BASE(core) \
885dad902cSCédric Le Goater     ((uint64_t)(((core) & 0x1F) + 0x20) << 24)
895dad902cSCédric Le Goater #define PNV9_XSCOM_EC_SIZE        0x100000
905dad902cSCédric Le Goater 
915dad902cSCédric Le Goater #define PNV9_XSCOM_EQ_BASE(core) \
925dad902cSCédric Le Goater     ((uint64_t)(((core) & 0x1C) + 0x40) << 22)
935dad902cSCédric Le Goater #define PNV9_XSCOM_EQ_SIZE        0x100000
945dad902cSCédric Le Goater 
956598a70dSCédric Le Goater #define PNV9_XSCOM_OCC_BASE       PNV_XSCOM_OCC_BASE
966598a70dSCédric Le Goater #define PNV9_XSCOM_OCC_SIZE       0x8000
976598a70dSCédric Le Goater 
988f092316SCédric Le Goater #define PNV9_XSCOM_PBA_BASE       0x5012b00
998f092316SCédric Le Goater #define PNV9_XSCOM_PBA_SIZE       0x40
1008f092316SCédric Le Goater 
101c38536bcSCédric Le Goater #define PNV9_XSCOM_PSIHB_BASE     0x5012900
102c38536bcSCédric Le Goater #define PNV9_XSCOM_PSIHB_SIZE     0x100
103c38536bcSCédric Le Goater 
1042dfa91a2SCédric Le Goater #define PNV9_XSCOM_XIVE_BASE      0x5013000
1052dfa91a2SCédric Le Goater #define PNV9_XSCOM_XIVE_SIZE      0x300
1062dfa91a2SCédric Le Goater 
1074f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_NEST_BASE  0x4010c00
1084f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_NEST_SIZE  0x100
1094f9924c4SBenjamin Herrenschmidt 
1104f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_BASE   0xd010800
1114f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_SIZE   0x200
1124f9924c4SBenjamin Herrenschmidt 
1134f9924c4SBenjamin Herrenschmidt /* XSCOM PCI "pass-through" window to PHB SCOM */
1144f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_STK0   0x100
1154f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_STK1   0x140
1164f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_STK2   0x180
1174f9924c4SBenjamin Herrenschmidt 
1182b548a42SCédric Le Goater /*
1192b548a42SCédric Le Goater  * Layout of the XSCOM PCB addresses (POWER 10)
1202b548a42SCédric Le Goater  */
1212b548a42SCédric Le Goater #define PNV10_XSCOM_EQ_CHIPLET(core)  (0x20 + ((core) >> 2))
1222b548a42SCédric Le Goater #define PNV10_XSCOM_EQ(chiplet)       ((chiplet) << 24)
1232b548a42SCédric Le Goater #define PNV10_XSCOM_EC(proc)                    \
1242b548a42SCédric Le Goater     ((0x2 << 16) | ((1 << (3 - (proc))) << 12))
1252b548a42SCédric Le Goater 
1262b548a42SCédric Le Goater #define PNV10_XSCOM_EQ_BASE(core)     \
1272b548a42SCédric Le Goater     ((uint64_t) PNV10_XSCOM_EQ(PNV10_XSCOM_EQ_CHIPLET(core)))
1282b548a42SCédric Le Goater #define PNV10_XSCOM_EQ_SIZE        0x100000
1292b548a42SCédric Le Goater 
1302b548a42SCédric Le Goater #define PNV10_XSCOM_EC_BASE(core) \
1312b548a42SCédric Le Goater     ((uint64_t) PNV10_XSCOM_EQ_BASE(core) | PNV10_XSCOM_EC(core & 0x3))
1322b548a42SCédric Le Goater #define PNV10_XSCOM_EC_SIZE        0x100000
1332b548a42SCédric Le Goater 
1348b50ce85SCédric Le Goater #define PNV10_XSCOM_PSIHB_BASE     0x3011D00
1358b50ce85SCédric Le Goater #define PNV10_XSCOM_PSIHB_SIZE     0x100
1368b50ce85SCédric Le Goater 
137aeb7a330SGreg Kurz void pnv_xscom_realize(PnvChip *chip, uint64_t size, Error **errp);
1383f5b45caSGreg Kurz int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset,
139c396c58aSGreg Kurz                  uint64_t xscom_base, uint64_t xscom_size,
140c396c58aSGreg Kurz                  const char *compat, int compat_size);
141967b7523SCédric Le Goater 
142aeb7a330SGreg Kurz void pnv_xscom_add_subregion(PnvChip *chip, hwaddr offset,
143967b7523SCédric Le Goater                              MemoryRegion *mr);
144aeb7a330SGreg Kurz void pnv_xscom_region_init(MemoryRegion *mr,
145967b7523SCédric Le Goater                            struct Object *owner,
146967b7523SCédric Le Goater                            const MemoryRegionOps *ops,
147967b7523SCédric Le Goater                            void *opaque,
148967b7523SCédric Le Goater                            const char *name,
149967b7523SCédric Le Goater                            uint64_t size);
150967b7523SCédric Le Goater 
151a8b991b5SMarkus Armbruster #endif /* PPC_PNV_XSCOM_H */
152