mac_newworld: add via machine option to control mac99 VIA/ADB configuration

This option allows the VIA configuration to be controlled between 3
different possible setups: cuda, pmu-adb and pmu with USB rather than ADB
keyboard/mouse.

For the moment we don't do anything with the configuration except to pass
it to the macio device (the via-cuda parent) and also to the firmware via
the fw_cfg interface so that it can present the correct device tree.

The default is cuda which is the current default and so will have no
change in behaviour.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
Signed-off-by: David Gibson <david@gibson.dropbear.id.au>
This commit is contained in:
Mark Cave-Ayland 2018-06-12 17:43:57 +01:00 committed by David Gibson
parent 06fe3a5bf1
commit f1114c17ee
5 changed files with 78 additions and 7 deletions

View file

@ -399,6 +399,12 @@ static const VMStateDescription vmstate_macio_newworld = {
} }
}; };
static Property macio_newworld_properties[] = {
DEFINE_PROP_BOOL("has-pmu", NewWorldMacIOState, has_pmu, false),
DEFINE_PROP_BOOL("has-adb", NewWorldMacIOState, has_adb, false),
DEFINE_PROP_END_OF_LIST()
};
static void macio_newworld_class_init(ObjectClass *oc, void *data) static void macio_newworld_class_init(ObjectClass *oc, void *data)
{ {
PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc); PCIDeviceClass *pdc = PCI_DEVICE_CLASS(oc);
@ -407,6 +413,7 @@ static void macio_newworld_class_init(ObjectClass *oc, void *data)
pdc->realize = macio_newworld_realize; pdc->realize = macio_newworld_realize;
pdc->device_id = PCI_DEVICE_ID_APPLE_UNI_N_KEYL; pdc->device_id = PCI_DEVICE_ID_APPLE_UNI_N_KEYL;
dc->vmsd = &vmstate_macio_newworld; dc->vmsd = &vmstate_macio_newworld;
dc->props = macio_newworld_properties;
} }
static Property macio_properties[] = { static Property macio_properties[] = {

View file

@ -71,9 +71,15 @@
#define CORE99_MACHINE(obj) OBJECT_CHECK(Core99MachineState, (obj), \ #define CORE99_MACHINE(obj) OBJECT_CHECK(Core99MachineState, (obj), \
TYPE_CORE99_MACHINE) TYPE_CORE99_MACHINE)
#define CORE99_VIA_CONFIG_CUDA 0x0
#define CORE99_VIA_CONFIG_PMU 0x1
#define CORE99_VIA_CONFIG_PMU_ADB 0x2
typedef struct Core99MachineState { typedef struct Core99MachineState {
/*< private >*/ /*< private >*/
MachineState parent; MachineState parent;
uint8_t via_config;
} Core99MachineState; } Core99MachineState;
/* MacIO */ /* MacIO */

View file

@ -111,6 +111,7 @@ static void ppc_core99_init(MachineState *machine)
const char *kernel_cmdline = machine->kernel_cmdline; const char *kernel_cmdline = machine->kernel_cmdline;
const char *initrd_filename = machine->initrd_filename; const char *initrd_filename = machine->initrd_filename;
const char *boot_device = machine->boot_order; const char *boot_device = machine->boot_order;
Core99MachineState *core99_machine = CORE99_MACHINE(machine);
PowerPCCPU *cpu = NULL; PowerPCCPU *cpu = NULL;
CPUPPCState *env = NULL; CPUPPCState *env = NULL;
char *filename; char *filename;
@ -122,6 +123,7 @@ static void ppc_core99_init(MachineState *machine)
UNINHostState *uninorth_pci; UNINHostState *uninorth_pci;
PCIBus *pci_bus; PCIBus *pci_bus;
NewWorldMacIOState *macio; NewWorldMacIOState *macio;
bool has_pmu, has_adb;
MACIOIDEState *macio_ide; MACIOIDEState *macio_ide;
BusState *adb_bus; BusState *adb_bus;
MacIONVRAMState *nvr; MacIONVRAMState *nvr;
@ -361,6 +363,9 @@ static void ppc_core99_init(MachineState *machine)
} }
machine->usb |= defaults_enabled() && !machine->usb_disabled; machine->usb |= defaults_enabled() && !machine->usb_disabled;
has_pmu = (core99_machine->via_config != CORE99_VIA_CONFIG_CUDA);
has_adb = (core99_machine->via_config == CORE99_VIA_CONFIG_CUDA ||
core99_machine->via_config == CORE99_VIA_CONFIG_PMU_ADB);
/* Timebase Frequency */ /* Timebase Frequency */
if (kvm_enabled()) { if (kvm_enabled()) {
@ -376,6 +381,8 @@ static void ppc_core99_init(MachineState *machine)
macio = NEWWORLD_MACIO(pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO)); macio = NEWWORLD_MACIO(pci_create(pci_bus, -1, TYPE_NEWWORLD_MACIO));
dev = DEVICE(macio); dev = DEVICE(macio);
qdev_prop_set_uint64(dev, "frequency", tbfreq); qdev_prop_set_uint64(dev, "frequency", tbfreq);
qdev_prop_set_bit(dev, "has-pmu", has_pmu);
qdev_prop_set_bit(dev, "has-adb", has_adb);
object_property_set_link(OBJECT(macio), OBJECT(pic_dev), "pic", object_property_set_link(OBJECT(macio), OBJECT(pic_dev), "pic",
&error_abort); &error_abort);
qdev_init_nofail(dev); qdev_init_nofail(dev);
@ -391,19 +398,21 @@ static void ppc_core99_init(MachineState *machine)
"ide[1]")); "ide[1]"));
macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]); macio_ide_init_drives(macio_ide, &hd[MAX_IDE_DEVS]);
dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda")); if (has_adb) {
adb_bus = qdev_get_child_bus(dev, "adb.0"); dev = DEVICE(object_resolve_path_component(OBJECT(macio), "cuda"));
dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD); adb_bus = qdev_get_child_bus(dev, "adb.0");
qdev_init_nofail(dev); dev = qdev_create(adb_bus, TYPE_ADB_KEYBOARD);
dev = qdev_create(adb_bus, TYPE_ADB_MOUSE); qdev_init_nofail(dev);
qdev_init_nofail(dev); dev = qdev_create(adb_bus, TYPE_ADB_MOUSE);
qdev_init_nofail(dev);
}
if (machine->usb) { if (machine->usb) {
pci_create_simple(pci_bus, -1, "pci-ohci"); pci_create_simple(pci_bus, -1, "pci-ohci");
/* U3 needs to use USB for input because Linux doesn't support via-cuda /* U3 needs to use USB for input because Linux doesn't support via-cuda
on PPC64 */ on PPC64 */
if (machine_arch == ARCH_MAC99_U3) { if (!has_adb || machine_arch == ARCH_MAC99_U3) {
USBBus *usb_bus = usb_bus_find(-1); USBBus *usb_bus = usb_bus_find(-1);
usb_create_simple(usb_bus, "usb-kbd"); usb_create_simple(usb_bus, "usb-kbd");
@ -459,6 +468,8 @@ static void ppc_core99_init(MachineState *machine)
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_HEIGHT, graphic_height);
fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth); fw_cfg_add_i16(fw_cfg, FW_CFG_PPC_DEPTH, graphic_depth);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_VIACONFIG, core99_machine->via_config);
fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled()); fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
if (kvm_enabled()) { if (kvm_enabled()) {
#ifdef CONFIG_KVM #ifdef CONFIG_KVM
@ -515,8 +526,52 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
#endif #endif
} }
static char *core99_get_via_config(Object *obj, Error **errp)
{
Core99MachineState *cms = CORE99_MACHINE(obj);
switch (cms->via_config) {
default:
case CORE99_VIA_CONFIG_CUDA:
return g_strdup("cuda");
case CORE99_VIA_CONFIG_PMU:
return g_strdup("pmu");
case CORE99_VIA_CONFIG_PMU_ADB:
return g_strdup("pmu-adb");
}
}
static void core99_set_via_config(Object *obj, const char *value, Error **errp)
{
Core99MachineState *cms = CORE99_MACHINE(obj);
if (!strcmp(value, "cuda")) {
cms->via_config = CORE99_VIA_CONFIG_CUDA;
} else if (!strcmp(value, "pmu")) {
cms->via_config = CORE99_VIA_CONFIG_PMU;
} else if (!strcmp(value, "pmu-adb")) {
cms->via_config = CORE99_VIA_CONFIG_PMU_ADB;
} else {
error_setg(errp, "Invalid via value");
error_append_hint(errp, "Valid values are cuda, pmu, pmu-adb.\n");
}
}
static void core99_instance_init(Object *obj) static void core99_instance_init(Object *obj)
{ {
Core99MachineState *cms = CORE99_MACHINE(obj);
/* Default via_config is CORE99_VIA_CONFIG_CUDA */
cms->via_config = CORE99_VIA_CONFIG_CUDA;
object_property_add_str(obj, "via", core99_get_via_config,
core99_set_via_config, NULL);
object_property_set_description(obj, "via",
"Set VIA configuration. "
"Valid values are cuda, pmu and pmu-adb",
NULL);
return; return;
} }

View file

@ -70,6 +70,8 @@ typedef struct NewWorldMacIOState {
MacIOState parent_obj; MacIOState parent_obj;
/*< public >*/ /*< public >*/
bool has_pmu;
bool has_adb;
OpenPICState *pic; OpenPICState *pic;
MACIOIDEState ide[2]; MACIOIDEState ide[2];
} NewWorldMacIOState; } NewWorldMacIOState;

View file

@ -101,6 +101,7 @@ enum {
#define FW_CFG_PPC_NVRAM_ADDR (FW_CFG_ARCH_LOCAL + 0x08) #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_BUSFREQ (FW_CFG_ARCH_LOCAL + 0x09)
#define FW_CFG_PPC_NVRAM_FLAT (FW_CFG_ARCH_LOCAL + 0x0a) #define FW_CFG_PPC_NVRAM_FLAT (FW_CFG_ARCH_LOCAL + 0x0a)
#define FW_CFG_PPC_VIACONFIG (FW_CFG_ARCH_LOCAL + 0x0b)
#define PPC_SERIAL_MM_BAUDBASE 399193 #define PPC_SERIAL_MM_BAUDBASE 399193