xref: /qemu/include/hw/ppc/pnv.h (revision e997040e3f02f6d1c6ab76e569f3593f5e3670fe)
1 /*
2  * QEMU PowerPC PowerNV various definitions
3  *
4  * Copyright (c) 2014-2016 BenH, 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 #ifndef _PPC_PNV_H
20 #define _PPC_PNV_H
21 
22 #include "hw/boards.h"
23 #include "hw/sysbus.h"
24 
25 #define TYPE_PNV_CHIP "powernv-chip"
26 #define PNV_CHIP(obj) OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP)
27 #define PNV_CHIP_CLASS(klass) \
28      OBJECT_CLASS_CHECK(PnvChipClass, (klass), TYPE_PNV_CHIP)
29 #define PNV_CHIP_GET_CLASS(obj) \
30      OBJECT_GET_CLASS(PnvChipClass, (obj), TYPE_PNV_CHIP)
31 
32 typedef enum PnvChipType {
33     PNV_CHIP_POWER8E,     /* AKA Murano (default) */
34     PNV_CHIP_POWER8,      /* AKA Venice */
35     PNV_CHIP_POWER8NVL,   /* AKA Naples */
36     PNV_CHIP_POWER9,      /* AKA Nimbus */
37 } PnvChipType;
38 
39 typedef struct PnvChip {
40     /*< private >*/
41     SysBusDevice parent_obj;
42 
43     /*< public >*/
44     uint32_t     chip_id;
45     uint64_t     ram_start;
46     uint64_t     ram_size;
47 } PnvChip;
48 
49 typedef struct PnvChipClass {
50     /*< private >*/
51     SysBusDeviceClass parent_class;
52 
53     /*< public >*/
54     const char *cpu_model;
55     PnvChipType  chip_type;
56     uint64_t     chip_cfam_id;
57 } PnvChipClass;
58 
59 #define TYPE_PNV_CHIP_POWER8E TYPE_PNV_CHIP "-POWER8E"
60 #define PNV_CHIP_POWER8E(obj) \
61     OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8E)
62 
63 #define TYPE_PNV_CHIP_POWER8 TYPE_PNV_CHIP "-POWER8"
64 #define PNV_CHIP_POWER8(obj) \
65     OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8)
66 
67 #define TYPE_PNV_CHIP_POWER8NVL TYPE_PNV_CHIP "-POWER8NVL"
68 #define PNV_CHIP_POWER8NVL(obj) \
69     OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER8NVL)
70 
71 #define TYPE_PNV_CHIP_POWER9 TYPE_PNV_CHIP "-POWER9"
72 #define PNV_CHIP_POWER9(obj) \
73     OBJECT_CHECK(PnvChip, (obj), TYPE_PNV_CHIP_POWER9)
74 
75 /*
76  * This generates a HW chip id depending on an index:
77  *
78  *    0x0, 0x1, 0x10, 0x11
79  *
80  * 4 chips should be the maximum
81  */
82 #define PNV_CHIP_HWID(i) ((((i) & 0x3e) << 3) | ((i) & 0x1))
83 
84 #define TYPE_POWERNV_MACHINE       MACHINE_TYPE_NAME("powernv")
85 #define POWERNV_MACHINE(obj) \
86     OBJECT_CHECK(PnvMachineState, (obj), TYPE_POWERNV_MACHINE)
87 
88 typedef struct PnvMachineState {
89     /*< private >*/
90     MachineState parent_obj;
91 
92     uint32_t     initrd_base;
93     long         initrd_size;
94 
95     uint32_t     num_chips;
96     PnvChip      **chips;
97 } PnvMachineState;
98 
99 #define PNV_FDT_ADDR          0x01000000
100 
101 #endif /* _PPC_PNV_H */
102