struct pci_ops *ops;
int nr_controllers;
void **private_data;
+ struct list_head *sys;
int (*setup)(int nr, struct pci_sys_data *);
struct pci_bus *(*scan)(int nr, struct pci_sys_data *);
void (*preinit)(void);
resource_size_t align);
void (*add_bus)(struct pci_bus *bus);
void (*remove_bus)(struct pci_bus *bus);
+ void (*teardown)(int nr, struct pci_sys_data *);
};
/*
#endif
struct list_head node;
int busnr; /* primary bus number */
+ int nr; /* controller number */
u64 mem_offset; /* bus->cpu memory mapping offset */
unsigned long io_offset; /* bus->cpu IO mapping offset */
struct pci_bus *bus; /* PCI bus */
resource_size_t align);
void (*add_bus)(struct pci_bus *bus);
void (*remove_bus)(struct pci_bus *bus);
+ void (*teardown)(int nr, struct pci_sys_data *);
void *private_data; /* platform controller private data */
};
pci_common_init_dev(NULL, hw);
}
+void pci_common_exit(struct list_head *head);
+
/*
* Setup early fixed I/O mapping.
*/
sys->domain = hw->domain;
#endif
sys->busnr = busnr;
+ sys->nr = nr;
sys->swizzle = hw->swizzle;
sys->map_irq = hw->map_irq;
sys->align_resource = hw->align_resource;
sys->add_bus = hw->add_bus;
sys->remove_bus = hw->remove_bus;
+ sys->teardown = hw->teardown;
INIT_LIST_HEAD(&sys->resources);
if (hw->private_data)
void pci_common_init_dev(struct device *parent, struct hw_pci *hw)
{
struct pci_sys_data *sys;
- LIST_HEAD(head);
+ struct list_head *head;
+ LIST_HEAD(list);
+
+ if (hw->sys)
+ head = hw->sys;
+ else
+ head = &list;
pci_add_flags(PCI_REASSIGN_ALL_RSRC);
if (hw->preinit)
hw->preinit();
- pcibios_init_hw(parent, hw, &head);
+ pcibios_init_hw(parent, hw, head);
if (hw->postinit)
hw->postinit();
pci_fixup_irqs(pcibios_swizzle, pcibios_map_irq);
- list_for_each_entry(sys, &head, node) {
+ list_for_each_entry(sys, head, node) {
struct pci_bus *bus = sys->bus;
if (!pci_has_flag(PCI_PROBE_ONLY)) {
pci_bus_add_devices(bus);
}
- list_for_each_entry(sys, &head, node) {
+ list_for_each_entry(sys, head, node) {
struct pci_bus *bus = sys->bus;
/* Configure PCI Express settings */
}
}
+void pci_common_exit(struct list_head *head)
+{
+ struct pci_sys_data *sys, *tmp;
+
+ list_for_each_entry_safe(sys, tmp, head, node) {
+ pci_stop_root_bus(sys->bus);
+ pci_remove_root_bus(sys->bus);
+ list_del(&sys->node);
+
+ release_resource(&sys->io_res);
+
+ if (sys->teardown)
+ sys->teardown(sys->nr, sys);
+
+ kfree(sys);
+ }
+}
+
#ifndef CONFIG_PCI_HOST_ITE8152
void pcibios_set_master(struct pci_dev *dev)
{