1 Allow registering PCI devices after early boot.
3 This is an ugly hack and needs to be rewritten before going upstream.
4 Index: linux-2.6.23.16/arch/mips/pci/pci.c
5 ===================================================================
6 --- linux-2.6.23.16.orig/arch/mips/pci/pci.c 2008-02-20 16:06:36.000000000 +0100
7 +++ linux-2.6.23.16/arch/mips/pci/pci.c 2008-02-20 16:09:33.000000000 +0100
13 + * Indicate whether PCI-bios init was already done.
15 +static int pcibios_init_done;
18 + * The currently used busnumber.
20 +static int next_busno;
21 +static int need_domain_info;
23 #define PCI_ASSIGN_ALL_BUSSES 1
25 unsigned int pci_probe = PCI_ASSIGN_ALL_BUSSES;
26 @@ -75,8 +86,32 @@ pcibios_align_resource(void *data, struc
30 -void __devinit register_pci_controller(struct pci_controller *hose)
31 +/* Most MIPS systems have straight-forward swizzling needs. */
33 +static inline u8 bridge_swizzle(u8 pin, u8 slot)
35 + return (((pin - 1) + slot) % 4) + 1;
38 +static u8 common_swizzle(struct pci_dev *dev, u8 *pinp)
42 + while (dev->bus->parent) {
43 + pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
44 + /* Move up the chain of bridges. */
45 + dev = dev->bus->self;
49 + /* The slot is the slot of the last bridge. */
50 + return PCI_SLOT(dev->devfn);
53 +void register_pci_controller(struct pci_controller *hose)
55 + struct pci_bus *bus;
57 if (request_resource(&iomem_resource, hose->mem_resource) < 0)
59 if (request_resource(&ioport_resource, hose->io_resource) < 0) {
60 @@ -84,9 +119,6 @@ void __devinit register_pci_controller(s
65 - hose_tail = &hose->next;
68 * Do not panic here but later - this might hapen before console init.
70 @@ -94,41 +126,47 @@ void __devinit register_pci_controller(s
72 "registering PCI controller with io_map_base unset\n");
78 - "Skipping PCI bus scan due to resource conflict\n");
80 + if (pcibios_init_done) {
83 -/* Most MIPS systems have straight-forward swizzling needs. */
84 + printk(KERN_INFO "Registering a PCI bus after boot\n");
86 -static inline u8 bridge_swizzle(u8 pin, u8 slot)
88 - return (((pin - 1) + slot) % 4) + 1;
91 + PCI_DMA_BUS_IS_PHYS = 1;
93 -static u8 __init common_swizzle(struct pci_dev *dev, u8 *pinp)
96 + bus = pci_scan_bus(next_busno, hose->pci_ops, hose);
98 + need_domain_info = need_domain_info || hose->index;
99 + hose->need_domain_info = need_domain_info;
101 + next_busno = bus->subordinate + 1;
102 + /* Don't allow 8-bit bus number overflow inside the hose -
103 + reserve some space for bridges. */
104 + if (next_busno > 224) {
106 + need_domain_info = 1;
109 + if (!pci_probe_only)
110 + pci_assign_unassigned_resources();
111 + pci_fixup_irqs(common_swizzle, pcibios_map_irq);
114 + hose_tail = &hose->next;
117 - while (dev->bus->parent) {
118 - pin = bridge_swizzle(pin, PCI_SLOT(dev->devfn));
119 - /* Move up the chain of bridges. */
120 - dev = dev->bus->self;
125 - /* The slot is the slot of the last bridge. */
126 - return PCI_SLOT(dev->devfn);
128 + printk(KERN_WARNING
129 + "Skipping PCI bus scan due to resource conflict\n");
132 static int __init pcibios_init(void)
134 struct pci_controller *hose;
137 - int need_domain_info = 0;
139 /* Scan all of the recorded PCI controllers. */
140 for (next_busno = 0, hose = hose_head; hose; hose = hose->next) {
141 @@ -157,6 +195,7 @@ static int __init pcibios_init(void)
143 pci_assign_unassigned_resources();
144 pci_fixup_irqs(common_swizzle, pcibios_map_irq);
145 + pcibios_init_done = 1;
149 Index: linux-2.6.23.16/drivers/ssb/main.c
150 ===================================================================
151 --- linux-2.6.23.16.orig/drivers/ssb/main.c 2008-02-20 16:06:36.000000000 +0100
152 +++ linux-2.6.23.16/drivers/ssb/main.c 2008-02-20 18:33:21.000000000 +0100
153 @@ -1185,9 +1185,7 @@ static int __init ssb_modinit(void)
154 /* ssb must be initialized after PCI but before the ssb drivers.
155 * That means we must use some initcall between subsys_initcall
156 * and device_initcall. */
157 -//FIXME on embedded we need to be early to make sure we can register
158 -// a new PCI bus, if needed.
159 -subsys_initcall(ssb_modinit);
160 +fs_initcall(ssb_modinit);
162 static void __exit ssb_modexit(void)