Commit 7b6288a6 authored by Anton Blanchard's avatar Anton Blanchard

ppc64: pci domain support

parent 79a50a32
......@@ -295,6 +295,7 @@ struct pci_controller *alloc_phb(struct device_node *dev,
int *buid_vals;
char *model;
enum phb_types phb_type;
struct property *of_prop;
model = (char *)get_property(dev, "model", NULL);
......@@ -341,6 +342,21 @@ struct pci_controller *alloc_phb(struct device_node *dev,
return NULL;
}
of_prop = (struct property *)alloc_bootmem(sizeof(struct property) +
sizeof(phb->global_number));
if (!of_prop) {
kfree(phb);
return NULL;
}
memset(of_prop, 0, sizeof(struct property));
of_prop->name = "linux,pci-domain";
of_prop->length = sizeof(phb->global_number);
of_prop->value = (unsigned char *)&of_prop[1];
memcpy(of_prop->value, &phb->global_number, sizeof(phb->global_number));
prom_add_property(dev, of_prop);
phb->first_busno = bus_range[0];
phb->last_busno = bus_range[1];
......@@ -352,26 +368,12 @@ struct pci_controller *alloc_phb(struct device_node *dev,
if (buid_vals == NULL) {
phb->buid = 0;
} else {
struct pci_bus check;
if (sizeof(check.number) == 1 || sizeof(check.primary) == 1 ||
sizeof(check.secondary) == 1 || sizeof(check.subordinate) == 1) {
udbg_printf("pSeries_pci: this system has large bus numbers and the kernel was not\n"
"built with the patch that fixes include/linux/pci.h struct pci_bus so\n"
"number, primary, secondary and subordinate are ints.\n");
panic("pSeries_pci: this system has large bus numbers and the kernel was not\n"
"built with the patch that fixes include/linux/pci.h struct pci_bus so\n"
"number, primary, secondary and subordinate are ints.\n");
}
if (len < 2 * sizeof(int))
// Support for new OF that only has 1 integer for buid.
phb->buid = (unsigned long)buid_vals[0];
else
phb->buid = (((unsigned long)buid_vals[0]) << 32UL) |
(((unsigned long)buid_vals[1]) & 0xffffffff);
phb->first_busno += (phb->global_number << 8);
phb->last_busno += (phb->global_number << 8);
}
return phb;
......
......@@ -380,6 +380,19 @@ int pci_domain_nr(struct pci_bus *bus)
return hose->global_number;
}
/* Set the name of the bus as it appears in /proc/bus/pci */
int pci_name_bus(char *name, struct pci_bus *bus)
{
struct pci_controller *hose = PCI_GET_PHB_PTR(bus);
if (hose->buid)
sprintf(name, "%04x:%02x", pci_domain_nr(bus), bus->number);
else
sprintf(name, "%02x", bus->number);
return 0;
}
/*
* Platform support for /proc/bus/pci/X/Y mmap()s,
* modelled on the sparc64 implementation by Dave Miller.
......
......@@ -42,14 +42,6 @@ void pci_devs_phb_init(void);
void pci_fix_bus_sysdata(void);
struct device_node *fetch_dev_dn(struct pci_dev *dev);
/*******************************************************************
* Helper macros for extracting data from pci structures.
* PCI_GET_PHB_PTR(struct pci_dev*) returns the Phb pointer.
* PCI_GET_PHB_NUMBER(struct pci_dev*) returns the Phb number.
* PCI_GET_BUS_NUMBER(struct pci_dev*) returns the bus number.
*******************************************************************/
#define PCI_GET_PHB_PTR(dev) (((struct device_node *)(dev)->sysdata)->phb)
#define PCI_GET_PHB_NUMBER(dev) (((dev)->bus->number&0x00FFFF00)>>8)
#define PCI_GET_BUS_NUMBER(dev) ((dev)->bus->number&0x0000FF)
#endif /* __PPC_KERNEL_PCI_H__ */
......@@ -201,18 +201,8 @@ pci_fixup_bus_sysdata_list(struct list_head *bus_list)
for (ln=bus_list->next; ln != bus_list; ln=ln->next) {
bus = pci_bus_b(ln);
if (bus->self) {
if (bus->self)
bus->sysdata = bus->self->sysdata;
/* Also fixup the bus number on large bus systems to
* include the PHB# in the next byte
*/
phb = PCI_GET_DN(bus)->phb;
if (phb && phb->buid) {
newnum = (phb->global_number << 8) | bus->number;
bus->number = newnum;
sprintf(bus->name, "PCI Bus #%x", bus->number);
}
}
pci_fixup_bus_sysdata_list(&bus->children);
}
}
......
......@@ -89,11 +89,7 @@ static inline int pci_dma_supported(struct pci_dev *hwdev, u64 mask)
extern int pci_domain_nr(struct pci_bus *bus);
/* Set the name of the bus as it appears in /proc/bus/pci */
static inline int pci_name_bus(char *name, struct pci_bus *bus)
{
sprintf(name, "%02x", bus->number);
return 0;
}
extern int pci_name_bus(char *name, struct pci_bus *bus);
struct vm_area_struct;
/* Map a range of PCI memory or I/O space for a device into user space */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment