QEMU mac99 emulates two of the three PCI buses found on real
PowerMac3,1 but OpenBIOS only handles a single PCI bus and initialises
and puts info in the device tree of the second PCI bus only which is
where devices are connected and calls it bus 0. However, some clients
may not know about this or have hardcoded assumptions and erroneously
use the address of the first bus to access PCI config registers for
devices on the second bus which silently fails as these requests will
go to the other empty bus emulated and return invalid values. Devices
mapped via MMIO still appear to work but they may not be correctly
initialised and some cards are not detected because of this.
Until support for multiple PCI buses is implemented add an empty node
in the device tree for the uninitialised bus to let clients know about
it. This fixes detecting PCI devices (such as USB) under MorphOS and
may also fix enabling the bus master bit needed with some network
cards and allow the workarund for that to be reverted.
Signed-off-by: BALATON Zoltan <balaton(a)eik.bme.hu>
---
arch/ppc/qemu/init.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c
index f72728c..a996404 100644
--- a/arch/ppc/qemu/init.c
+++ b/arch/ppc/qemu/init.c
@@ -716,6 +716,46 @@ static void kvm_of_init(void)
fword("finish-device");
}
+static void empty_pci_bus_init(void)
+{
+ if (machine_id == ARCH_MAC99) {
+ activate_device("/");
+ fword("new-device");
+ push_str("pci");
+ fword("device-name");
+ push_str("pci");
+ fword("device-type");
+ PUSH(0xf0000000);
+ fword("encode-int");
+ PUSH(0x02000000);
+ fword("encode-int");
+ fword("encode+");
+ push_str("reg");
+ fword("property");
+ PUSH(3);
+ fword("encode-int");
+ push_str("#address-cells");
+ fword("property");
+ PUSH(2);
+ fword("encode-int");
+ push_str("#size-cells");
+ fword("property");
+ PUSH(1);
+ fword("encode-int");
+ push_str("#interrupt-cells");
+ fword("property");
+ PUSH(0);
+ fword("encode-int");
+ PUSH(0);
+ fword("encode-int");
+ fword("encode+");
+ push_str("bus-range");
+ fword("property");
+ fword("finish-device");
+ device_end();
+ }
+}
+
/*
* filll ( addr bytes quad -- )
*/
@@ -859,7 +899,17 @@ arch_of_init(void)
feval("['] ppc-dma-sync to (dma-sync)");
#ifdef CONFIG_DRIVER_PCI
+ /* Add empty node for first pci bus on MAC99 */
+ /* Remove this when pci driver is fixed to handle multiple buses */
+ empty_pci_bus_init();
ob_pci_init();
+ if (machine_id == ARCH_MAC99) {
+ phandle_t dev = find_dev("/pci@f2000000");
+ if (dev) {
+ u32 props[2] = {0, 1};
+ set_property(dev, "bus-range", (char *)props, 2 * sizeof(props[0]));
+ }
+ }
#endif
printk("\n");
--
2.13.7