/* * AmigaOne platform PCI setup * * Copyright 2007 Gerhard Pircher (gerhard_pircher@gmx.net) * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License as published by the * Free Software Foundation; either version 2 of the License, or (at your * option) any later version. */ #include #include #include #include #include #include #include #include #include #include #include void __init amigaone_find_bridges(void) { struct device_node *dev; const int *bus_range; int len, index = -1; struct pci_controller *hose; struct device_node *root = of_find_node_by_path("/"); for (dev = root->child; dev != NULL; dev = dev->sibling) { if (dev->type == NULL || strcmp(dev->type, "pci") != 0) continue; ++index; bus_range = of_get_property(dev, "bus-range", &len); if (bus_range == NULL || len < 2 * sizeof(int)) { printk(KERN_WARNING "Can't get bus-range for %s\n", dev->full_name); continue; } /* if (bus_range[1] == bus_range[0]) printk(KERN_INFO "PCI bus %d", bus_range[0]); else printk(KERN_INFO "PCI buses %d..%d", bus_range[0], bus_range[1]); printk(" controlled by %s", dev->full_name); */ hose = pcibios_alloc_controller(dev); if (!hose) { printk("Can't allocate PCI controller structure for %s\n", dev->full_name); continue; } hose->arch_data = dev; hose->first_busno = bus_range[0]; hose->last_busno = bus_range[1]; setup_indirect_pci(hose, 0xfec00cf8, 0xfee00cfc, 0); /* Interpret the "ranges" property */ /* This also maps the I/O region and sets isa_io/mem_base. */ pci_process_bridge_OF_ranges(hose, dev, index == 0); } of_node_put(root); }