diff options
Diffstat (limited to 'arch/powerpc/platforms/powernv/pci-ioda.c')
-rw-r--r-- | arch/powerpc/platforms/powernv/pci-ioda.c | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index 1da578b7c1bf..9c9d15e4cdf2 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c | |||
@@ -68,16 +68,6 @@ define_pe_printk_level(pe_err, KERN_ERR); | |||
68 | define_pe_printk_level(pe_warn, KERN_WARNING); | 68 | define_pe_printk_level(pe_warn, KERN_WARNING); |
69 | define_pe_printk_level(pe_info, KERN_INFO); | 69 | define_pe_printk_level(pe_info, KERN_INFO); |
70 | 70 | ||
71 | static struct pci_dn *pnv_ioda_get_pdn(struct pci_dev *dev) | ||
72 | { | ||
73 | struct device_node *np; | ||
74 | |||
75 | np = pci_device_to_OF_node(dev); | ||
76 | if (!np) | ||
77 | return NULL; | ||
78 | return PCI_DN(np); | ||
79 | } | ||
80 | |||
81 | static int pnv_ioda_alloc_pe(struct pnv_phb *phb) | 71 | static int pnv_ioda_alloc_pe(struct pnv_phb *phb) |
82 | { | 72 | { |
83 | unsigned long pe; | 73 | unsigned long pe; |
@@ -110,7 +100,7 @@ static struct pnv_ioda_pe *pnv_ioda_get_pe(struct pci_dev *dev) | |||
110 | { | 100 | { |
111 | struct pci_controller *hose = pci_bus_to_host(dev->bus); | 101 | struct pci_controller *hose = pci_bus_to_host(dev->bus); |
112 | struct pnv_phb *phb = hose->private_data; | 102 | struct pnv_phb *phb = hose->private_data; |
113 | struct pci_dn *pdn = pnv_ioda_get_pdn(dev); | 103 | struct pci_dn *pdn = pci_get_pdn(dev); |
114 | 104 | ||
115 | if (!pdn) | 105 | if (!pdn) |
116 | return NULL; | 106 | return NULL; |
@@ -173,7 +163,7 @@ static int pnv_ioda_configure_pe(struct pnv_phb *phb, struct pnv_ioda_pe *pe) | |||
173 | 163 | ||
174 | /* Add to all parents PELT-V */ | 164 | /* Add to all parents PELT-V */ |
175 | while (parent) { | 165 | while (parent) { |
176 | struct pci_dn *pdn = pnv_ioda_get_pdn(parent); | 166 | struct pci_dn *pdn = pci_get_pdn(parent); |
177 | if (pdn && pdn->pe_number != IODA_INVALID_PE) { | 167 | if (pdn && pdn->pe_number != IODA_INVALID_PE) { |
178 | rc = opal_pci_set_peltv(phb->opal_id, pdn->pe_number, | 168 | rc = opal_pci_set_peltv(phb->opal_id, pdn->pe_number, |
179 | pe->pe_number, OPAL_ADD_PE_TO_DOMAIN); | 169 | pe->pe_number, OPAL_ADD_PE_TO_DOMAIN); |
@@ -252,7 +242,7 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev) | |||
252 | { | 242 | { |
253 | struct pci_controller *hose = pci_bus_to_host(dev->bus); | 243 | struct pci_controller *hose = pci_bus_to_host(dev->bus); |
254 | struct pnv_phb *phb = hose->private_data; | 244 | struct pnv_phb *phb = hose->private_data; |
255 | struct pci_dn *pdn = pnv_ioda_get_pdn(dev); | 245 | struct pci_dn *pdn = pci_get_pdn(dev); |
256 | struct pnv_ioda_pe *pe; | 246 | struct pnv_ioda_pe *pe; |
257 | int pe_num; | 247 | int pe_num; |
258 | 248 | ||
@@ -323,7 +313,7 @@ static void pnv_ioda_setup_same_PE(struct pci_bus *bus, struct pnv_ioda_pe *pe) | |||
323 | struct pci_dev *dev; | 313 | struct pci_dev *dev; |
324 | 314 | ||
325 | list_for_each_entry(dev, &bus->devices, bus_list) { | 315 | list_for_each_entry(dev, &bus->devices, bus_list) { |
326 | struct pci_dn *pdn = pnv_ioda_get_pdn(dev); | 316 | struct pci_dn *pdn = pci_get_pdn(dev); |
327 | 317 | ||
328 | if (pdn == NULL) { | 318 | if (pdn == NULL) { |
329 | pr_warn("%s: No device node associated with device !\n", | 319 | pr_warn("%s: No device node associated with device !\n", |
@@ -436,7 +426,7 @@ static void pnv_pci_ioda_setup_PEs(void) | |||
436 | 426 | ||
437 | static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev) | 427 | static void pnv_pci_ioda_dma_dev_setup(struct pnv_phb *phb, struct pci_dev *pdev) |
438 | { | 428 | { |
439 | struct pci_dn *pdn = pnv_ioda_get_pdn(pdev); | 429 | struct pci_dn *pdn = pci_get_pdn(pdev); |
440 | struct pnv_ioda_pe *pe; | 430 | struct pnv_ioda_pe *pe; |
441 | 431 | ||
442 | /* | 432 | /* |
@@ -768,6 +758,7 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev, | |||
768 | unsigned int is_64, struct msi_msg *msg) | 758 | unsigned int is_64, struct msi_msg *msg) |
769 | { | 759 | { |
770 | struct pnv_ioda_pe *pe = pnv_ioda_get_pe(dev); | 760 | struct pnv_ioda_pe *pe = pnv_ioda_get_pe(dev); |
761 | struct pci_dn *pdn = pci_get_pdn(dev); | ||
771 | struct irq_data *idata; | 762 | struct irq_data *idata; |
772 | struct irq_chip *ichip; | 763 | struct irq_chip *ichip; |
773 | unsigned int xive_num = hwirq - phb->msi_base; | 764 | unsigned int xive_num = hwirq - phb->msi_base; |
@@ -783,6 +774,10 @@ static int pnv_pci_ioda_msi_setup(struct pnv_phb *phb, struct pci_dev *dev, | |||
783 | if (pe->mve_number < 0) | 774 | if (pe->mve_number < 0) |
784 | return -ENXIO; | 775 | return -ENXIO; |
785 | 776 | ||
777 | /* Force 32-bit MSI on some broken devices */ | ||
778 | if (pdn && pdn->force_32bit_msi) | ||
779 | is_64 = 0; | ||
780 | |||
786 | /* Assign XIVE to PE */ | 781 | /* Assign XIVE to PE */ |
787 | rc = opal_pci_set_xive_pe(phb->opal_id, pe->pe_number, xive_num); | 782 | rc = opal_pci_set_xive_pe(phb->opal_id, pe->pe_number, xive_num); |
788 | if (rc) { | 783 | if (rc) { |
@@ -1035,7 +1030,7 @@ static int pnv_pci_enable_device_hook(struct pci_dev *dev) | |||
1035 | if (!phb->initialized) | 1030 | if (!phb->initialized) |
1036 | return 0; | 1031 | return 0; |
1037 | 1032 | ||
1038 | pdn = pnv_ioda_get_pdn(dev); | 1033 | pdn = pci_get_pdn(dev); |
1039 | if (!pdn || pdn->pe_number == IODA_INVALID_PE) | 1034 | if (!pdn || pdn->pe_number == IODA_INVALID_PE) |
1040 | return -EINVAL; | 1035 | return -EINVAL; |
1041 | 1036 | ||
@@ -1048,6 +1043,12 @@ static u32 pnv_ioda_bdfn_to_pe(struct pnv_phb *phb, struct pci_bus *bus, | |||
1048 | return phb->ioda.pe_rmap[(bus->number << 8) | devfn]; | 1043 | return phb->ioda.pe_rmap[(bus->number << 8) | devfn]; |
1049 | } | 1044 | } |
1050 | 1045 | ||
1046 | static void pnv_pci_ioda_shutdown(struct pnv_phb *phb) | ||
1047 | { | ||
1048 | opal_pci_reset(phb->opal_id, OPAL_PCI_IODA_TABLE_RESET, | ||
1049 | OPAL_ASSERT_RESET); | ||
1050 | } | ||
1051 | |||
1051 | void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type) | 1052 | void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type) |
1052 | { | 1053 | { |
1053 | struct pci_controller *hose; | 1054 | struct pci_controller *hose; |
@@ -1178,6 +1179,9 @@ void __init pnv_pci_init_ioda_phb(struct device_node *np, int ioda_type) | |||
1178 | /* Setup TCEs */ | 1179 | /* Setup TCEs */ |
1179 | phb->dma_dev_setup = pnv_pci_ioda_dma_dev_setup; | 1180 | phb->dma_dev_setup = pnv_pci_ioda_dma_dev_setup; |
1180 | 1181 | ||
1182 | /* Setup shutdown function for kexec */ | ||
1183 | phb->shutdown = pnv_pci_ioda_shutdown; | ||
1184 | |||
1181 | /* Setup MSI support */ | 1185 | /* Setup MSI support */ |
1182 | pnv_pci_init_ioda_msis(phb); | 1186 | pnv_pci_init_ioda_msis(phb); |
1183 | 1187 | ||