Merge tag 'migration-20240311-pull-request' of https://gitlab.com/peterx/qemu into...
[qemu/armbru.git] / tests / qtest / pnv-xscom.h
blob6f62941744a61b1f1a89e417fd3953812d18bc65
1 /*
2 * PowerNV XSCOM Bus
4 * Copyright (c) 2024, IBM Corporation.
6 * SPDX-License-Identifier: GPL-2.0-or-later
7 */
9 #ifndef PNV_XSCOM_H
10 #define PNV_XSCOM_H
12 #define SMT 4 /* some tests will break if less than 4 */
14 typedef enum PnvChipType {
15 PNV_CHIP_POWER8E, /* AKA Murano (default) */
16 PNV_CHIP_POWER8, /* AKA Venice */
17 PNV_CHIP_POWER8NVL, /* AKA Naples */
18 PNV_CHIP_POWER9, /* AKA Nimbus */
19 PNV_CHIP_POWER10,
20 } PnvChipType;
22 typedef struct PnvChip {
23 PnvChipType chip_type;
24 const char *cpu_model;
25 uint64_t xscom_base;
26 uint64_t cfam_id;
27 uint32_t first_core;
28 uint32_t num_i2c;
29 } PnvChip;
31 static const PnvChip pnv_chips[] = {
33 .chip_type = PNV_CHIP_POWER8,
34 .cpu_model = "POWER8",
35 .xscom_base = 0x0003fc0000000000ull,
36 .cfam_id = 0x220ea04980000000ull,
37 .first_core = 0x1,
38 .num_i2c = 0,
39 }, {
40 .chip_type = PNV_CHIP_POWER8NVL,
41 .cpu_model = "POWER8NVL",
42 .xscom_base = 0x0003fc0000000000ull,
43 .cfam_id = 0x120d304980000000ull,
44 .first_core = 0x1,
45 .num_i2c = 0,
48 .chip_type = PNV_CHIP_POWER9,
49 .cpu_model = "POWER9",
50 .xscom_base = 0x000603fc00000000ull,
51 .cfam_id = 0x220d104900008000ull,
52 .first_core = 0x0,
53 .num_i2c = 4,
56 .chip_type = PNV_CHIP_POWER10,
57 .cpu_model = "POWER10",
58 .xscom_base = 0x000603fc00000000ull,
59 .cfam_id = 0x120da04900008000ull,
60 .first_core = 0x0,
61 .num_i2c = 4,
65 static inline uint64_t pnv_xscom_addr(const PnvChip *chip, uint32_t pcba)
67 uint64_t addr = chip->xscom_base;
69 if (chip->chip_type == PNV_CHIP_POWER10) {
70 addr |= ((uint64_t) pcba << 3);
71 } else if (chip->chip_type == PNV_CHIP_POWER9) {
72 addr |= ((uint64_t) pcba << 3);
73 } else {
74 addr |= (((uint64_t) pcba << 4) & ~0xffull) |
75 (((uint64_t) pcba << 3) & 0x78);
77 return addr;
80 #endif /* PNV_XSCOM_H */