21 #include <linux/module.h>
22 #include <linux/pci.h>
23 #include <linux/string.h>
26 #include <asm/pci-bridge.h>
37 #define DLPAR_MODULE_NAME "rpadlpar_io"
39 #define NODE_TYPE_VIO 1
40 #define NODE_TYPE_SLOT 2
41 #define NODE_TYPE_PHB 3
55 if ((rc == 0) && (!
strcmp(drc_name, name)))
85 dn = find_php_slot_pci_node(drc_name,
"SLOT");
91 dn = find_php_slot_pci_node(drc_name,
"PHB");
97 dn = find_vio_slot_node(drc_name);
136 child_dn = pci_device_to_OF_node(tmp);
137 if (child_dn == dev_dn)
143 static void dlpar_pci_add_bus(
struct device_node *dn)
145 struct pci_dn *pdn = PCI_DN(dn);
172 pcibios_finish_adding_to_bus(phb->bus);
175 static int dlpar_add_pci_slot(
char *drc_name,
struct device_node *dn)
184 dlpar_pci_add_bus(dn);
187 phb = PCI_DN(dn)->phb;
188 dev = dlpar_find_new_dev(phb->bus, dn);
197 printk(
KERN_ERR "%s: unexpected header type %d, unable to add bus %s\n",
211 static int dlpar_remove_phb(
char *drc_name,
struct device_node *dn)
221 slot = find_php_slot(dn);
229 BUG_ON(!pdn || !pdn->phb);
239 static int dlpar_add_phb(
char *drc_name,
struct device_node *dn)
243 if (PCI_DN(dn) && PCI_DN(dn)->phb) {
260 static int dlpar_add_vio_slot(
char *drc_name,
struct device_node *dn)
262 if (vio_find_node(dn))
267 "%s: failed to register vio node %s\n",
296 dn = find_dlpar_node(drc_name, &node_type);
304 rc = dlpar_add_vio_slot(drc_name, dn);
307 rc = dlpar_add_pci_slot(drc_name, dn);
310 rc = dlpar_add_phb(drc_name, dn);
330 static int dlpar_remove_vio_slot(
char *drc_name,
struct device_node *dn)
334 vio_dev = vio_find_node(dn);
362 pr_debug(
"PCI: Removing PCI slot below EADS bridge %s\n",
363 bus->
self ? pci_name(bus->
self) :
"<!PHB!>");
365 slot = find_php_slot(dn);
367 pr_debug(
"PCI: Removing hotplug slot for %04x:%02x...\n",
372 "%s: unable to remove hotplug slot %s\n",
382 if (pcibios_unmap_io_space(bus)) {
390 pr_debug(
"PCI: Now removing bridge device %s\n", pci_name(bus->
self));
418 dn = find_dlpar_node(drc_name, &node_type);
426 rc = dlpar_remove_vio_slot(drc_name, dn);
429 rc = dlpar_remove_phb(drc_name, dn);
443 static inline int is_dlpar_capable(
void)
445 int rc =
rtas_token(
"ibm,configure-connector");
447 return (
int) (rc != RTAS_UNKNOWN_SERVICE);
454 if (!is_dlpar_capable()) {