2 * QEMU PowerPC N1 chiplet model
4 * Copyright (c) 2023, IBM Corporation.
6 * SPDX-License-Identifier: GPL-2.0-or-later
9 #include "qemu/osdep.h"
11 #include "hw/qdev-properties.h"
12 #include "hw/ppc/pnv.h"
13 #include "hw/ppc/pnv_xscom.h"
14 #include "hw/ppc/pnv_n1_chiplet.h"
15 #include "hw/ppc/pnv_nest_pervasive.h"
18 * The n1 chiplet contains chiplet control unit,
19 * PowerBus/RaceTrack/Bridge logic, nest Memory Management Unit(nMMU)
22 * In this model Nest1 chiplet control registers are modelled via common
23 * nest pervasive model and few PowerBus racetrack registers are modelled.
26 #define PB_SCOM_EQ0_HP_MODE2_CURR 0xe
27 #define PB_SCOM_ES3_MODE 0x8a
29 static uint64_t pnv_n1_chiplet_pb_scom_eq_read(void *opaque
, hwaddr addr
,
32 PnvN1Chiplet
*n1_chiplet
= PNV_N1_CHIPLET(opaque
);
33 uint32_t reg
= addr
>> 3;
37 case PB_SCOM_EQ0_HP_MODE2_CURR
:
38 val
= n1_chiplet
->eq
[0].hp_mode2_curr
;
41 qemu_log_mask(LOG_UNIMP
, "%s: Invalid xscom read at 0x%" PRIx32
"\n",
47 static void pnv_n1_chiplet_pb_scom_eq_write(void *opaque
, hwaddr addr
,
48 uint64_t val
, unsigned size
)
50 PnvN1Chiplet
*n1_chiplet
= PNV_N1_CHIPLET(opaque
);
51 uint32_t reg
= addr
>> 3;
54 case PB_SCOM_EQ0_HP_MODE2_CURR
:
55 n1_chiplet
->eq
[0].hp_mode2_curr
= val
;
58 qemu_log_mask(LOG_UNIMP
, "%s: Invalid xscom write at 0x%" PRIx32
"\n",
63 static const MemoryRegionOps pnv_n1_chiplet_pb_scom_eq_ops
= {
64 .read
= pnv_n1_chiplet_pb_scom_eq_read
,
65 .write
= pnv_n1_chiplet_pb_scom_eq_write
,
66 .valid
.min_access_size
= 8,
67 .valid
.max_access_size
= 8,
68 .impl
.min_access_size
= 8,
69 .impl
.max_access_size
= 8,
70 .endianness
= DEVICE_BIG_ENDIAN
,
73 static uint64_t pnv_n1_chiplet_pb_scom_es_read(void *opaque
, hwaddr addr
,
76 PnvN1Chiplet
*n1_chiplet
= PNV_N1_CHIPLET(opaque
);
77 uint32_t reg
= addr
>> 3;
81 case PB_SCOM_ES3_MODE
:
82 val
= n1_chiplet
->es
[3].mode
;
85 qemu_log_mask(LOG_UNIMP
, "%s: Invalid xscom read at 0x%" PRIx32
"\n",
91 static void pnv_n1_chiplet_pb_scom_es_write(void *opaque
, hwaddr addr
,
92 uint64_t val
, unsigned size
)
94 PnvN1Chiplet
*n1_chiplet
= PNV_N1_CHIPLET(opaque
);
95 uint32_t reg
= addr
>> 3;
98 case PB_SCOM_ES3_MODE
:
99 n1_chiplet
->es
[3].mode
= val
;
102 qemu_log_mask(LOG_UNIMP
, "%s: Invalid xscom write at 0x%" PRIx32
"\n",
107 static const MemoryRegionOps pnv_n1_chiplet_pb_scom_es_ops
= {
108 .read
= pnv_n1_chiplet_pb_scom_es_read
,
109 .write
= pnv_n1_chiplet_pb_scom_es_write
,
110 .valid
.min_access_size
= 8,
111 .valid
.max_access_size
= 8,
112 .impl
.min_access_size
= 8,
113 .impl
.max_access_size
= 8,
114 .endianness
= DEVICE_BIG_ENDIAN
,
117 static void pnv_n1_chiplet_realize(DeviceState
*dev
, Error
**errp
)
119 PnvN1Chiplet
*n1_chiplet
= PNV_N1_CHIPLET(dev
);
121 /* Realize nest pervasive common chiplet model */
122 if (!qdev_realize(DEVICE(&n1_chiplet
->nest_pervasive
), NULL
, errp
)) {
126 /* Nest1 chiplet power bus EQ xscom region */
127 pnv_xscom_region_init(&n1_chiplet
->xscom_pb_eq_mr
, OBJECT(n1_chiplet
),
128 &pnv_n1_chiplet_pb_scom_eq_ops
, n1_chiplet
,
129 "xscom-n1-chiplet-pb-scom-eq",
130 PNV10_XSCOM_N1_PB_SCOM_EQ_SIZE
);
132 /* Nest1 chiplet power bus ES xscom region */
133 pnv_xscom_region_init(&n1_chiplet
->xscom_pb_es_mr
, OBJECT(n1_chiplet
),
134 &pnv_n1_chiplet_pb_scom_es_ops
, n1_chiplet
,
135 "xscom-n1-chiplet-pb-scom-es",
136 PNV10_XSCOM_N1_PB_SCOM_ES_SIZE
);
139 static void pnv_n1_chiplet_class_init(ObjectClass
*klass
, void *data
)
141 DeviceClass
*dc
= DEVICE_CLASS(klass
);
143 dc
->desc
= "PowerNV n1 chiplet";
144 dc
->realize
= pnv_n1_chiplet_realize
;
147 static void pnv_n1_chiplet_instance_init(Object
*obj
)
149 PnvN1Chiplet
*n1_chiplet
= PNV_N1_CHIPLET(obj
);
151 object_initialize_child(OBJECT(n1_chiplet
), "nest-pervasive-common",
152 &n1_chiplet
->nest_pervasive
,
153 TYPE_PNV_NEST_CHIPLET_PERVASIVE
);
156 static const TypeInfo pnv_n1_chiplet_info
= {
157 .name
= TYPE_PNV_N1_CHIPLET
,
158 .parent
= TYPE_DEVICE
,
159 .instance_init
= pnv_n1_chiplet_instance_init
,
160 .instance_size
= sizeof(PnvN1Chiplet
),
161 .class_init
= pnv_n1_chiplet_class_init
,
162 .interfaces
= (InterfaceInfo
[]) {
163 { TYPE_PNV_XSCOM_INTERFACE
},
168 static void pnv_n1_chiplet_register_types(void)
170 type_register_static(&pnv_n1_chiplet_info
);
173 type_init(pnv_n1_chiplet_register_types
);