@@ -20,7 +20,7 @@
#include <device.h>
static struct proc_chip *chips[MAX_CHIPS];
-bool is_mambo_chip;
+enum proc_chip_quirks proc_chip_quirks;
uint32_t pir_to_chip_id(uint32_t pir)
{
@@ -68,8 +68,16 @@ void init_chips(void)
struct dt_node *xn;
/* Detect mambo chip */
- if (dt_find_by_path(dt_root, "/mambo"))
- is_mambo_chip = true;
+ if (dt_find_by_path(dt_root, "/mambo")) {
+ proc_chip_quirks |= QUIRK_NO_CHIPTOD | QUIRK_MAMBO_CALLOUTS
+ | QUIRK_NO_F000F | QUIRK_NO_PBA | QUIRK_NO_OCC_IRQ
+ | QUIRK_DISABLE_NAP;
+ prlog(PR_NOTICE, "CHIP: Detected Mambo simulator\n");
+ }
+ if (dt_node_is_compatible(dt_root, "qemu,powernv")) {
+ proc_chip_quirks |= QUIRK_NO_CHIPTOD | QUIRK_NO_PBA | QUIRK_NO_OCC_IRQ;
+ prlog(PR_NOTICE, "CHIP: Detected Qemu simulator\n");
+ }
/* We walk the chips based on xscom nodes in the tree */
dt_for_each_compatible(dt_root, xn, "ibm,xscom") {
@@ -559,7 +559,7 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu)
* to access chips via that path early on.
*/
init_chips();
- if (is_mambo_chip)
+ if (chip_quirk(QUIRK_MAMBO_CALLOUTS))
enable_mambo_console();
xscom_init();
mfsi_init();
@@ -628,7 +628,7 @@ void __noreturn main_cpu_entry(const void *fdt, u32 master_cpu)
* value (so they appear to go backward at this point), and synchronize
* all core timebases to the global ChipTOD network
*/
- chiptod_init(master_cpu);
+ chiptod_init();
/* Initialize i2c */
p8_i2c_init();
@@ -770,8 +770,8 @@ void chiptod_init(void)
struct cpu_thread *cpu0, *cpu;
bool sres;
- /* Mambo doesn't simulate the chiptod */
- if (is_mambo_chip)
+ /* Mambo and qemu doesn't simulate the chiptod */
+ if (chip_quirk(QUIRK_NO_CHIPTOD))
return;
op_display(OP_LOG, OP_MOD_CHIPTOD, 0);
@@ -111,7 +111,7 @@ void homer_init(void)
{
struct proc_chip *chip;
- if (proc_gen != proc_gen_p8 || is_mambo_chip)
+ if (proc_gen != proc_gen_p8 || chip_quirk(QUIRK_NO_PBA))
return;
/*
@@ -536,8 +536,8 @@ static struct fsp_client fsp_occ_client = {
void occ_send_dummy_interrupt(void)
{
- /* Mambo chip and P7 don't do this */
- if (is_mambo_chip || proc_gen != proc_gen_p8)
+ /* Emulators and P7 doesn't do this */
+ if (proc_gen != proc_gen_p8 || chip_quirk(QUIRK_NO_OCC_IRQ))
return;
xscom_writeme(OCB_OCI_OCCMISC_OR,
OCB_OCI_OCIMISC_IRQ |
@@ -525,7 +525,7 @@ static void add_cpu_idle_state_properties(void)
/* Mambo currently misbehaves in nap mode vs. timebase, so let's
* disable idle states
*/
- if (is_mambo_chip)
+ if (chip_quirk(QUIRK_DISABLE_NAP))
return;
/*
@@ -441,7 +441,7 @@ static void xscom_init_chip_info(struct proc_chip *chip)
/* Mambo chip model lacks the f000f register, just make
* something up (Murano DD2.1)
*/
- if (is_mambo_chip)
+ if (chip_quirk(QUIRK_NO_F000F))
val = 0x221EF04980000000;
else
rc = xscom_read(chip->id, 0xf000f, &val);
@@ -89,6 +89,21 @@ enum proc_chip_type {
PROC_CHIP_P8_VENICE,
};
+/* Simulator quirks */
+enum proc_chip_quirks {
+ QUIRK_NO_CHIPTOD = 0x00000001,
+ QUIRK_MAMBO_CALLOUTS = 0x00000002,
+ QUIRK_NO_F000F = 0x00000004,
+ QUIRK_NO_PBA = 0x00000008,
+ QUIRK_NO_OCC_IRQ = 0x00000010,
+ QUIRK_DISABLE_NAP = 0x00000020,
+} proc_chip_quirks;
+
+static inline bool chip_quirk(unsigned int q)
+{
+ return !!(proc_chip_quirks & q);
+}
+
#define MAX_CHIPS (1 << 6) /* 6-bit chip ID */
/*
@@ -139,9 +154,6 @@ struct proc_chip {
struct list_head i2cms;
};
-/* Mambo simplified chip model lacks some features, handle it here */
-extern bool is_mambo_chip;
-
extern uint32_t pir_to_chip_id(uint32_t pir);
extern uint32_t pir_to_core_id(uint32_t pir);
extern uint32_t pir_to_thread_id(uint32_t pir);
And add some basic qemu quirks Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org> --- core/chip.c | 14 +++++++++++--- core/init.c | 4 ++-- hw/chiptod.c | 4 ++-- hw/homer.c | 2 +- hw/occ.c | 4 ++-- hw/slw.c | 2 +- hw/xscom.c | 2 +- include/chip.h | 18 +++++++++++++++--- 8 files changed, 35 insertions(+), 15 deletions(-)