diff options
Diffstat (limited to 'include/asm-ppc64/pci-bridge.h')
| -rw-r--r-- | include/asm-ppc64/pci-bridge.h | 45 |
1 files changed, 39 insertions, 6 deletions
diff --git a/include/asm-ppc64/pci-bridge.h b/include/asm-ppc64/pci-bridge.h index c4f9023ea5ed..6b4a5b1f695e 100644 --- a/include/asm-ppc64/pci-bridge.h +++ b/include/asm-ppc64/pci-bridge.h | |||
| @@ -48,19 +48,52 @@ struct pci_controller { | |||
| 48 | unsigned long dma_window_size; | 48 | unsigned long dma_window_size; |
| 49 | }; | 49 | }; |
| 50 | 50 | ||
| 51 | /* | ||
| 52 | * PCI stuff, for nodes representing PCI devices, pointed to | ||
| 53 | * by device_node->data. | ||
| 54 | */ | ||
| 55 | struct pci_controller; | ||
| 56 | struct iommu_table; | ||
| 57 | |||
| 58 | struct pci_dn { | ||
| 59 | int busno; /* for pci devices */ | ||
| 60 | int bussubno; /* for pci devices */ | ||
| 61 | int devfn; /* for pci devices */ | ||
| 62 | int eeh_mode; /* See eeh.h for possible EEH_MODEs */ | ||
| 63 | int eeh_config_addr; | ||
| 64 | int eeh_capable; /* from firmware */ | ||
| 65 | int eeh_check_count; /* # times driver ignored error */ | ||
| 66 | int eeh_freeze_count; /* # times this device froze up. */ | ||
| 67 | int eeh_is_bridge; /* device is pci-to-pci bridge */ | ||
| 68 | |||
| 69 | int pci_ext_config_space; /* for pci devices */ | ||
| 70 | struct pci_controller *phb; /* for pci devices */ | ||
| 71 | struct iommu_table *iommu_table; /* for phb's or bridges */ | ||
| 72 | struct pci_dev *pcidev; /* back-pointer to the pci device */ | ||
| 73 | struct device_node *node; /* back-pointer to the device_node */ | ||
| 74 | u32 config_space[16]; /* saved PCI config space */ | ||
| 75 | }; | ||
| 76 | |||
| 77 | /* Get the pointer to a device_node's pci_dn */ | ||
| 78 | #define PCI_DN(dn) ((struct pci_dn *) (dn)->data) | ||
| 79 | |||
| 51 | struct device_node *fetch_dev_dn(struct pci_dev *dev); | 80 | struct device_node *fetch_dev_dn(struct pci_dev *dev); |
| 52 | 81 | ||
| 53 | /* Get a device_node from a pci_dev. This code must be fast except in the case | 82 | /* Get a device_node from a pci_dev. This code must be fast except |
| 54 | * where the sysdata is incorrect and needs to be fixed up (hopefully just once) | 83 | * in the case where the sysdata is incorrect and needs to be fixed |
| 84 | * up (this will only happen once). | ||
| 85 | * In this case the sysdata will have been inherited from a PCI host | ||
| 86 | * bridge or a PCI-PCI bridge further up the tree, so it will point | ||
| 87 | * to a valid struct pci_dn, just not the one we want. | ||
| 55 | */ | 88 | */ |
| 56 | static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev) | 89 | static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev) |
| 57 | { | 90 | { |
| 58 | struct device_node *dn = dev->sysdata; | 91 | struct device_node *dn = dev->sysdata; |
| 92 | struct pci_dn *pdn = dn->data; | ||
| 59 | 93 | ||
| 60 | if (dn->devfn == dev->devfn && dn->busno == dev->bus->number) | 94 | if (pdn && pdn->devfn == dev->devfn && pdn->busno == dev->bus->number) |
| 61 | return dn; /* fast path. sysdata is good */ | 95 | return dn; /* fast path. sysdata is good */ |
| 62 | else | 96 | return fetch_dev_dn(dev); |
| 63 | return fetch_dev_dn(dev); | ||
| 64 | } | 97 | } |
| 65 | 98 | ||
| 66 | static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus) | 99 | static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus) |
| @@ -83,7 +116,7 @@ static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) | |||
| 83 | struct device_node *busdn = bus->sysdata; | 116 | struct device_node *busdn = bus->sysdata; |
| 84 | 117 | ||
| 85 | BUG_ON(busdn == NULL); | 118 | BUG_ON(busdn == NULL); |
| 86 | return busdn->phb; | 119 | return PCI_DN(busdn)->phb; |
| 87 | } | 120 | } |
| 88 | 121 | ||
| 89 | #endif | 122 | #endif |
