This is in preparation for allowing OpenBIOS to detect the difference between CUDA/PMU hardware and build the device tree accordingly.
Signed-off-by: Mark Cave-Ayland mark.cave-ayland@ilande.co.uk --- arch/ppc/qemu/init.c | 19 +++++++++++++++++++ include/arch/common/fw_cfg.h | 1 + include/drivers/drivers.h | 10 ++++++++++ 3 files changed, 30 insertions(+)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c index 06fd08d..eba93c9 100644 --- a/arch/ppc/qemu/init.c +++ b/arch/ppc/qemu/init.c @@ -92,6 +92,25 @@ int is_newworld(void) (machine_id == ARCH_MAC99_U3); }
+#define CORE99_VIA_CONFIG_CUDA 0x0 +#define CORE99_VIA_CONFIG_PMU 0x1 +#define CORE99_VIA_CONFIG_PMU_ADB 0x2 + +int has_pmu(void) +{ + uint32_t via_config = fw_cfg_read_i32(FW_CFG_PPC_VIACONFIG); + + return (via_config != CORE99_VIA_CONFIG_CUDA); +} + +int has_adb(void) +{ + uint32_t via_config = fw_cfg_read_i32(FW_CFG_PPC_VIACONFIG); + + return (via_config == CORE99_VIA_CONFIG_CUDA || + via_config == CORE99_VIA_CONFIG_PMU_ADB); +} + static const pci_arch_t known_arch[] = { [ARCH_PREP] = { .name = "PREP", diff --git a/include/arch/common/fw_cfg.h b/include/arch/common/fw_cfg.h index cd2183a..8460ad4 100644 --- a/include/arch/common/fw_cfg.h +++ b/include/arch/common/fw_cfg.h @@ -47,6 +47,7 @@ #define FW_CFG_PPC_NVRAM_ADDR (FW_CFG_ARCH_LOCAL + 0x08) #define FW_CFG_PPC_BUSFREQ (FW_CFG_ARCH_LOCAL + 0x09) #define FW_CFG_PPC_NVRAM_FLAT (FW_CFG_ARCH_LOCAL + 0x0a) +#define FW_CFG_PPC_VIACONFIG (FW_CFG_ARCH_LOCAL + 0x0b)
#define FW_CFG_INVALID 0xffff
diff --git a/include/drivers/drivers.h b/include/drivers/drivers.h index 38efcc8..117429e 100644 --- a/include/drivers/drivers.h +++ b/include/drivers/drivers.h @@ -23,6 +23,8 @@ int ob_pci_init(void); extern int is_apple(void); extern int is_oldworld(void); extern int is_newworld(void); +extern int has_pmu(void); +extern int has_adb(void); #else static inline int is_apple(void) { @@ -36,6 +38,14 @@ static inline int is_newworld(void) { return 0; } +static inline int has_pmu(void) +{ + return 0; +} +static inline int has_adb(void) +{ + return 0; +} #endif #define AAPL(_cmd) do { if (is_apple()) _cmd; } while(0) #define OLDWORLD(_cmd) do { if (is_oldworld()) _cmd; } while(0)