xref: /openbmc/qemu/include/hw/ppc/pnv_xscom.h (revision 1ceda19c)
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
9f70c5966SChetan Pant  * version 2.1 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 
2314f11a20SMarkus Armbruster #include "exec/memory.h"
2414f11a20SMarkus Armbruster #include "hw/ppc/pnv.h"
25967b7523SCédric Le Goater 
2690cce00cSGreg Kurz typedef struct PnvXScomInterface PnvXScomInterface;
27967b7523SCédric Le Goater 
28967b7523SCédric Le Goater #define TYPE_PNV_XSCOM_INTERFACE "pnv-xscom-interface"
29967b7523SCédric Le Goater #define PNV_XSCOM_INTERFACE(obj) \
3090cce00cSGreg Kurz     INTERFACE_CHECK(PnvXScomInterface, (obj), TYPE_PNV_XSCOM_INTERFACE)
31db1015e9SEduardo Habkost typedef struct PnvXScomInterfaceClass PnvXScomInterfaceClass;
328110fa1dSEduardo Habkost DECLARE_CLASS_CHECKERS(PnvXScomInterfaceClass, PNV_XSCOM_INTERFACE,
33967b7523SCédric Le Goater                        TYPE_PNV_XSCOM_INTERFACE)
34967b7523SCédric Le Goater 
35db1015e9SEduardo Habkost struct PnvXScomInterfaceClass {
36967b7523SCédric Le Goater     InterfaceClass parent;
37b168a138SCédric Le Goater     int (*dt_xscom)(PnvXScomInterface *dev, void *fdt, int offset);
38db1015e9SEduardo Habkost };
39967b7523SCédric Le Goater 
4024ece072SCédric Le Goater /*
41ad521238SCédric Le Goater  * Layout of the XSCOM PCB addresses of EX core 1 (POWER 8)
4224ece072SCédric Le Goater  *
4324ece072SCédric Le Goater  *   GPIO        0x1100xxxx
4424ece072SCédric Le Goater  *   SCOM        0x1101xxxx
4524ece072SCédric Le Goater  *   OHA         0x1102xxxx
4624ece072SCédric Le Goater  *   CLOCK CTL   0x1103xxxx
4724ece072SCédric Le Goater  *   FIR         0x1104xxxx
4824ece072SCédric Le Goater  *   THERM       0x1105xxxx
4924ece072SCédric Le Goater  *   <reserved>  0x1106xxxx
5024ece072SCédric Le Goater  *               ..
5124ece072SCédric Le Goater  *               0x110Exxxx
5224ece072SCédric Le Goater  *   PCB SLAVE   0x110Fxxxx
5324ece072SCédric Le Goater  */
5424ece072SCédric Le Goater 
55c035851aSCédric Le Goater #define PNV_XSCOM_EX_CORE_BASE    0x10000000ull
56c035851aSCédric Le Goater 
57c035851aSCédric Le Goater #define PNV_XSCOM_EX_BASE(core) \
58c035851aSCédric Le Goater     (PNV_XSCOM_EX_CORE_BASE | ((uint64_t)(core) << 24))
59c035851aSCédric Le Goater #define PNV_XSCOM_EX_SIZE         0x100000
60c035851aSCédric Le Goater 
61a3980bf5SBenjamin Herrenschmidt #define PNV_XSCOM_LPC_BASE        0xb0020
62a3980bf5SBenjamin Herrenschmidt #define PNV_XSCOM_LPC_SIZE        0x4
63a3980bf5SBenjamin Herrenschmidt 
6454f59d78SCédric Le Goater #define PNV_XSCOM_PSIHB_BASE      0x2010900
6554f59d78SCédric Le Goater #define PNV_XSCOM_PSIHB_SIZE      0x20
6654f59d78SCédric Le Goater 
670722d05aSBenjamin Herrenschmidt #define PNV_XSCOM_OCC_BASE        0x0066000
680722d05aSBenjamin Herrenschmidt #define PNV_XSCOM_OCC_SIZE        0x6000
690722d05aSBenjamin Herrenschmidt 
708f092316SCédric Le Goater #define PNV_XSCOM_PBA_BASE        0x2013f00
718f092316SCédric Le Goater #define PNV_XSCOM_PBA_SIZE        0x40
728f092316SCédric Le Goater 
739ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_NEST_BASE  0x2012000
749ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_NEST_SIZE  0x46
759ae1329eSCédric Le Goater 
769ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_PCI_BASE   0x9012000
779ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_PCI_SIZE   0x15
789ae1329eSCédric Le Goater 
799ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_SPCI_BASE  0x9013c00
809ae1329eSCédric Le Goater #define PNV_XSCOM_PBCQ_SPCI_SIZE  0x5
819ae1329eSCédric Le Goater 
822b548a42SCédric Le Goater /*
832b548a42SCédric Le Goater  * Layout of the XSCOM PCB addresses (POWER 9)
842b548a42SCédric Le Goater  */
855dad902cSCédric Le Goater #define PNV9_XSCOM_EC_BASE(core) \
865dad902cSCédric Le Goater     ((uint64_t)(((core) & 0x1F) + 0x20) << 24)
875dad902cSCédric Le Goater #define PNV9_XSCOM_EC_SIZE        0x100000
885dad902cSCédric Le Goater 
895dad902cSCédric Le Goater #define PNV9_XSCOM_EQ_BASE(core) \
905dad902cSCédric Le Goater     ((uint64_t)(((core) & 0x1C) + 0x40) << 22)
915dad902cSCédric Le Goater #define PNV9_XSCOM_EQ_SIZE        0x100000
925dad902cSCédric Le Goater 
93263b81eeSCédric Le Goater #define PNV9_XSCOM_I2CM_BASE      0xa0000
94263b81eeSCédric Le Goater #define PNV9_XSCOM_I2CM_SIZE      0x1000
95263b81eeSCédric Le Goater 
966598a70dSCédric Le Goater #define PNV9_XSCOM_OCC_BASE       PNV_XSCOM_OCC_BASE
976598a70dSCédric Le Goater #define PNV9_XSCOM_OCC_SIZE       0x8000
986598a70dSCédric Le Goater 
990bf4d77eSNicholas Piggin #define PNV9_XSCOM_SBE_CTRL_BASE  0x00050008
1000bf4d77eSNicholas Piggin #define PNV9_XSCOM_SBE_CTRL_SIZE  0x1
1010bf4d77eSNicholas Piggin 
1020bf4d77eSNicholas Piggin #define PNV9_XSCOM_SBE_MBOX_BASE  0x000D0050
1030bf4d77eSNicholas Piggin #define PNV9_XSCOM_SBE_MBOX_SIZE  0x16
1040bf4d77eSNicholas Piggin 
1058f092316SCédric Le Goater #define PNV9_XSCOM_PBA_BASE       0x5012b00
1068f092316SCédric Le Goater #define PNV9_XSCOM_PBA_SIZE       0x40
1078f092316SCédric Le Goater 
108c38536bcSCédric Le Goater #define PNV9_XSCOM_PSIHB_BASE     0x5012900
109c38536bcSCédric Le Goater #define PNV9_XSCOM_PSIHB_SIZE     0x100
110c38536bcSCédric Le Goater 
1112dfa91a2SCédric Le Goater #define PNV9_XSCOM_XIVE_BASE      0x5013000
1122dfa91a2SCédric Le Goater #define PNV9_XSCOM_XIVE_SIZE      0x300
1132dfa91a2SCédric Le Goater 
1144f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_NEST_BASE  0x4010c00
1154f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_NEST_SIZE  0x100
1164f9924c4SBenjamin Herrenschmidt 
1174f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_BASE   0xd010800
1184f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_SIZE   0x200
1194f9924c4SBenjamin Herrenschmidt 
1204f9924c4SBenjamin Herrenschmidt /* XSCOM PCI "pass-through" window to PHB SCOM */
1214f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_STK0   0x100
1224f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_STK1   0x140
1234f9924c4SBenjamin Herrenschmidt #define PNV9_XSCOM_PEC_PCI_STK2   0x180
1244f9924c4SBenjamin Herrenschmidt 
1252b548a42SCédric Le Goater /*
1262b548a42SCédric Le Goater  * Layout of the XSCOM PCB addresses (POWER 10)
1272b548a42SCédric Le Goater  */
1282b548a42SCédric Le Goater #define PNV10_XSCOM_EQ_CHIPLET(core)  (0x20 + ((core) >> 2))
1292b548a42SCédric Le Goater #define PNV10_XSCOM_EQ(chiplet)       ((chiplet) << 24)
1302b548a42SCédric Le Goater #define PNV10_XSCOM_EC(proc)                    \
1312b548a42SCédric Le Goater     ((0x2 << 16) | ((1 << (3 - (proc))) << 12))
1322b548a42SCédric Le Goater 
133bdb97596SJoel Stanley #define PNV10_XSCOM_QME(chiplet) \
134bdb97596SJoel Stanley         (PNV10_XSCOM_EQ(chiplet) | (0xE << 16))
135bdb97596SJoel Stanley 
136bdb97596SJoel Stanley /*
137bdb97596SJoel Stanley  * Make the region larger by 0x1000 (instead of starting at an offset) so the
138bdb97596SJoel Stanley  * modelled addresses start from 0
139bdb97596SJoel Stanley  */
140bdb97596SJoel Stanley #define PNV10_XSCOM_QME_BASE(core)     \
141bdb97596SJoel Stanley     ((uint64_t) PNV10_XSCOM_QME(PNV10_XSCOM_EQ_CHIPLET(core)))
142bdb97596SJoel Stanley #define PNV10_XSCOM_QME_SIZE        (0x8000 + 0x1000)
143bdb97596SJoel Stanley 
1442b548a42SCédric Le Goater #define PNV10_XSCOM_EQ_BASE(core)     \
1452b548a42SCédric Le Goater     ((uint64_t) PNV10_XSCOM_EQ(PNV10_XSCOM_EQ_CHIPLET(core)))
146a1d64b9eSJoel Stanley #define PNV10_XSCOM_EQ_SIZE        0x20000
1472b548a42SCédric Le Goater 
1482b548a42SCédric Le Goater #define PNV10_XSCOM_EC_BASE(core) \
1492b548a42SCédric Le Goater     ((uint64_t) PNV10_XSCOM_EQ_BASE(core) | PNV10_XSCOM_EC(core & 0x3))
150aa2addf9SNicholas Piggin #define PNV10_XSCOM_EC_SIZE        0x1000
1512b548a42SCédric Le Goater 
1528b50ce85SCédric Le Goater #define PNV10_XSCOM_PSIHB_BASE     0x3011D00
1538b50ce85SCédric Le Goater #define PNV10_XSCOM_PSIHB_SIZE     0x100
1548b50ce85SCédric Le Goater 
155*1ceda19cSGlenn Miles #define PNV10_XSCOM_I2CM_BASE      PNV9_XSCOM_I2CM_BASE
156*1ceda19cSGlenn Miles #define PNV10_XSCOM_I2CM_SIZE      PNV9_XSCOM_I2CM_SIZE
157*1ceda19cSGlenn Miles 
1588bf682a3SCédric Le Goater #define PNV10_XSCOM_OCC_BASE       PNV9_XSCOM_OCC_BASE
1598bf682a3SCédric Le Goater #define PNV10_XSCOM_OCC_SIZE       PNV9_XSCOM_OCC_SIZE
1608bf682a3SCédric Le Goater 
1610bf4d77eSNicholas Piggin #define PNV10_XSCOM_SBE_CTRL_BASE  PNV9_XSCOM_SBE_CTRL_BASE
1620bf4d77eSNicholas Piggin #define PNV10_XSCOM_SBE_CTRL_SIZE  PNV9_XSCOM_SBE_CTRL_SIZE
1630bf4d77eSNicholas Piggin 
1640bf4d77eSNicholas Piggin #define PNV10_XSCOM_SBE_MBOX_BASE  PNV9_XSCOM_SBE_MBOX_BASE
1650bf4d77eSNicholas Piggin #define PNV10_XSCOM_SBE_MBOX_SIZE  PNV9_XSCOM_SBE_MBOX_SIZE
1660bf4d77eSNicholas Piggin 
16792499676SCédric Le Goater #define PNV10_XSCOM_PBA_BASE       0x01010CDA
16892499676SCédric Le Goater #define PNV10_XSCOM_PBA_SIZE       0x40
16992499676SCédric Le Goater 
170da71b7e3SCédric Le Goater #define PNV10_XSCOM_XIVE2_BASE     0x2010800
171da71b7e3SCédric Le Goater #define PNV10_XSCOM_XIVE2_SIZE     0x400
172da71b7e3SCédric Le Goater 
173623575e1SCédric Le Goater #define PNV10_XSCOM_PEC_NEST_BASE  0x3011800 /* index goes downwards ... */
174623575e1SCédric Le Goater #define PNV10_XSCOM_PEC_NEST_SIZE  0x100
175623575e1SCédric Le Goater 
176623575e1SCédric Le Goater #define PNV10_XSCOM_PEC_PCI_BASE   0x8010800 /* index goes upwards ... */
177623575e1SCédric Le Goater #define PNV10_XSCOM_PEC_PCI_SIZE   0x200
178623575e1SCédric Le Goater 
179326f7acbSPhilippe Mathieu-Daudé void pnv_xscom_init(PnvChip *chip, uint64_t size, hwaddr addr);
1803f5b45caSGreg Kurz int pnv_dt_xscom(PnvChip *chip, void *fdt, int root_offset,
181c396c58aSGreg Kurz                  uint64_t xscom_base, uint64_t xscom_size,
182c396c58aSGreg Kurz                  const char *compat, int compat_size);
183967b7523SCédric Le Goater 
184aeb7a330SGreg Kurz void pnv_xscom_add_subregion(PnvChip *chip, hwaddr offset,
185967b7523SCédric Le Goater                              MemoryRegion *mr);
186aeb7a330SGreg Kurz void pnv_xscom_region_init(MemoryRegion *mr,
187d32335e8SPhilippe Mathieu-Daudé                            Object *owner,
188967b7523SCédric Le Goater                            const MemoryRegionOps *ops,
189967b7523SCédric Le Goater                            void *opaque,
190967b7523SCédric Le Goater                            const char *name,
191967b7523SCédric Le Goater                            uint64_t size);
192967b7523SCédric Le Goater 
193a8b991b5SMarkus Armbruster #endif /* PPC_PNV_XSCOM_H */
194