summaryrefslogtreecommitdiffstats
path: root/sys/arm/versatile/versatile_pci.c
diff options
context:
space:
mode:
authorgonzo <gonzo@FreeBSD.org>2013-06-29 23:51:17 +0000
committergonzo <gonzo@FreeBSD.org>2013-06-29 23:51:17 +0000
commit6a2a51f2ee33ca5a0c343bd7f45df4f972b2d566 (patch)
treed885511c4d76819572876f2c2eba7cc5c67b1bca /sys/arm/versatile/versatile_pci.c
parent4050245570c8670761c4817e97620d1ba5181f36 (diff)
downloadFreeBSD-src-6a2a51f2ee33ca5a0c343bd7f45df4f972b2d566.zip
FreeBSD-src-6a2a51f2ee33ca5a0c343bd7f45df4f972b2d566.tar.gz
- Fix IMAPx registers values calculation
- Initialize SMAPx registers too although they're unused in QEMU - Do not pass IO/MEM resources to upper bus for activation, handle them locally. Previously ACTIVATE method of upper bus was no-op so nothing bad happened. But now FDT maps physaddr to vaddr and it causes troubles: fdtbus_activate_resource resource assumes that bustag/bushandle are already set which in this case is wrong.
Diffstat (limited to 'sys/arm/versatile/versatile_pci.c')
-rw-r--r--sys/arm/versatile/versatile_pci.c44
1 files changed, 24 insertions, 20 deletions
diff --git a/sys/arm/versatile/versatile_pci.c b/sys/arm/versatile/versatile_pci.c
index 1ef92ef..131209a 100644
--- a/sys/arm/versatile/versatile_pci.c
+++ b/sys/arm/versatile/versatile_pci.c
@@ -173,16 +173,17 @@ versatile_pci_attach(device_t dev)
/*
* Setup memory windows
*/
- versatile_pci_core_write_4(PCI_CORE_IMAP0, (PCI_IO_WINDOW >> 11));
- versatile_pci_core_write_4(PCI_CORE_IMAP1, (PCI_NPREFETCH_WINDOW >> 11));
- versatile_pci_core_write_4(PCI_CORE_IMAP2, (PCI_PREFETCH_WINDOW >> 11));
+ versatile_pci_core_write_4(PCI_CORE_IMAP0, (PCI_IO_WINDOW >> 28));
+ versatile_pci_core_write_4(PCI_CORE_IMAP1, (PCI_NPREFETCH_WINDOW >> 28));
+ versatile_pci_core_write_4(PCI_CORE_IMAP2, (PCI_PREFETCH_WINDOW >> 28));
/*
* XXX: this is SDRAM offset >> 28
+ * Unused as of QEMU 1.5
*/
- versatile_pci_core_write_4(PCI_CORE_SMAP0, 0);
- versatile_pci_core_write_4(PCI_CORE_SMAP1, 0);
- versatile_pci_core_write_4(PCI_CORE_SMAP2, 0);
+ versatile_pci_core_write_4(PCI_CORE_SMAP0, (PCI_IO_WINDOW >> 28));
+ versatile_pci_core_write_4(PCI_CORE_SMAP1, (PCI_NPREFETCH_WINDOW >> 28));
+ versatile_pci_core_write_4(PCI_CORE_SMAP2, (PCI_NPREFETCH_WINDOW >> 28));
versatile_pci_sys_write_4(SYS_PCICTL, 1);
@@ -307,7 +308,7 @@ versatile_pci_alloc_resource(device_t bus, device_t child, int type, int *rid,
struct resource *rv;
struct rman *rm;
- printf("Alloc resources %d, %08lx..%08lx, %ld\n", type, start, end, count);
+ dprintf("Alloc resources %d, %08lx..%08lx, %ld\n", type, start, end, count);
switch (type) {
case SYS_RES_IOPORT:
@@ -344,20 +345,23 @@ versatile_pci_activate_resource(device_t bus, device_t child, int type, int rid,
struct resource *r)
{
vm_offset_t vaddr;
- int res = (BUS_ACTIVATE_RESOURCE(device_get_parent(bus),
- child, type, rid, r));
-
- if (!res) {
- switch(type) {
- case SYS_RES_MEMORY:
- case SYS_RES_IOPORT:
- vaddr = (vm_offset_t)pmap_mapdev(rman_get_start(r),
- rman_get_size(r));
- rman_set_bushandle(r, vaddr);
- rman_set_bustag(r, versatile_bus_space_pcimem);
- break;
- }
+ int res;
+
+ switch(type) {
+ case SYS_RES_MEMORY:
+ case SYS_RES_IOPORT:
+ vaddr = (vm_offset_t)pmap_mapdev(rman_get_start(r),
+ rman_get_size(r));
+ rman_set_bushandle(r, vaddr);
+ rman_set_bustag(r, versatile_bus_space_pcimem);
+ res = rman_activate_resource(r);
+ break;
+ case SYS_RES_IRQ:
+ res = (BUS_ACTIVATE_RESOURCE(device_get_parent(bus),
+ child, type, rid, r));
+ break;
}
+
return (res);
}
OpenPOWER on IntegriCloud