diff options
61 files changed, 1007 insertions, 228 deletions
diff --git a/Documentation/PCI/pci.txt b/Documentation/PCI/pci.txt index 9518006f6675..123881f62219 100644 --- a/Documentation/PCI/pci.txt +++ b/Documentation/PCI/pci.txt | |||
@@ -564,14 +564,14 @@ to be handled by platform and generic code, not individual drivers. | |||
564 | 8. Vendor and device identifications | 564 | 8. Vendor and device identifications |
565 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | 565 | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
566 | 566 | ||
567 | One is not required to add new device ids to include/linux/pci_ids.h. | 567 | Do not add new device or vendor IDs to include/linux/pci_ids.h unless they |
568 | Please add PCI_VENDOR_ID_xxx for vendors and a hex constant for device ids. | 568 | are shared across multiple drivers. You can add private definitions in |
569 | your driver if they're helpful, or just use plain hex constants. | ||
569 | 570 | ||
570 | PCI_VENDOR_ID_xxx constants are re-used. The device ids are arbitrary | 571 | The device IDs are arbitrary hex numbers (vendor controlled) and normally used |
571 | hex numbers (vendor controlled) and normally used only in a single | 572 | only in a single location, the pci_device_id table. |
572 | location, the pci_device_id table. | ||
573 | 573 | ||
574 | Please DO submit new vendor/device ids to pciids.sourceforge.net project. | 574 | Please DO submit new vendor/device IDs to http://pciids.sourceforge.net/. |
575 | 575 | ||
576 | 576 | ||
577 | 577 | ||
diff --git a/Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt b/Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt new file mode 100644 index 000000000000..f7ce50e38ed4 --- /dev/null +++ b/Documentation/devicetree/bindings/pci/brcm,iproc-pcie.txt | |||
@@ -0,0 +1,63 @@ | |||
1 | * Broadcom iProc PCIe controller with the platform bus interface | ||
2 | |||
3 | Required properties: | ||
4 | - compatible: Must be "brcm,iproc-pcie" | ||
5 | - reg: base address and length of the PCIe controller I/O register space | ||
6 | - #interrupt-cells: set to <1> | ||
7 | - interrupt-map-mask and interrupt-map, standard PCI properties to define the | ||
8 | mapping of the PCIe interface to interrupt numbers | ||
9 | - linux,pci-domain: PCI domain ID. Should be unique for each host controller | ||
10 | - bus-range: PCI bus numbers covered | ||
11 | - #address-cells: set to <3> | ||
12 | - #size-cells: set to <2> | ||
13 | - device_type: set to "pci" | ||
14 | - ranges: ranges for the PCI memory and I/O regions | ||
15 | |||
16 | Optional properties: | ||
17 | - phys: phandle of the PCIe PHY device | ||
18 | - phy-names: must be "pcie-phy" | ||
19 | |||
20 | Example: | ||
21 | pcie0: pcie@18012000 { | ||
22 | compatible = "brcm,iproc-pcie"; | ||
23 | reg = <0x18012000 0x1000>; | ||
24 | |||
25 | #interrupt-cells = <1>; | ||
26 | interrupt-map-mask = <0 0 0 0>; | ||
27 | interrupt-map = <0 0 0 0 &gic GIC_SPI 100 IRQ_TYPE_NONE>; | ||
28 | |||
29 | linux,pci-domain = <0>; | ||
30 | |||
31 | bus-range = <0x00 0xff>; | ||
32 | |||
33 | #address-cells = <3>; | ||
34 | #size-cells = <2>; | ||
35 | device_type = "pci"; | ||
36 | ranges = <0x81000000 0 0 0x28000000 0 0x00010000 | ||
37 | 0x82000000 0 0x20000000 0x20000000 0 0x04000000>; | ||
38 | |||
39 | phys = <&phy 0 5>; | ||
40 | phy-names = "pcie-phy"; | ||
41 | }; | ||
42 | |||
43 | pcie1: pcie@18013000 { | ||
44 | compatible = "brcm,iproc-pcie"; | ||
45 | reg = <0x18013000 0x1000>; | ||
46 | |||
47 | #interrupt-cells = <1>; | ||
48 | interrupt-map-mask = <0 0 0 0>; | ||
49 | interrupt-map = <0 0 0 0 &gic GIC_SPI 106 IRQ_TYPE_NONE>; | ||
50 | |||
51 | linux,pci-domain = <1>; | ||
52 | |||
53 | bus-range = <0x00 0xff>; | ||
54 | |||
55 | #address-cells = <3>; | ||
56 | #size-cells = <2>; | ||
57 | device_type = "pci"; | ||
58 | ranges = <0x81000000 0 0 0x48000000 0 0x00010000 | ||
59 | 0x82000000 0 0x40000000 0x40000000 0 0x04000000>; | ||
60 | |||
61 | phys = <&phy 1 6>; | ||
62 | phy-names = "pcie-phy"; | ||
63 | }; | ||
diff --git a/arch/alpha/kernel/pci.c b/arch/alpha/kernel/pci.c index 98a1525fa164..82f738e5d54c 100644 --- a/arch/alpha/kernel/pci.c +++ b/arch/alpha/kernel/pci.c | |||
@@ -338,6 +338,8 @@ common_init_pci(void) | |||
338 | 338 | ||
339 | bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops, | 339 | bus = pci_scan_root_bus(NULL, next_busno, alpha_mv.pci_ops, |
340 | hose, &resources); | 340 | hose, &resources); |
341 | if (!bus) | ||
342 | continue; | ||
341 | hose->bus = bus; | 343 | hose->bus = bus; |
342 | hose->need_domain_info = need_domain_info; | 344 | hose->need_domain_info = need_domain_info; |
343 | next_busno = bus->busn_res.end + 1; | 345 | next_busno = bus->busn_res.end + 1; |
@@ -353,6 +355,11 @@ common_init_pci(void) | |||
353 | 355 | ||
354 | pci_assign_unassigned_resources(); | 356 | pci_assign_unassigned_resources(); |
355 | pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); | 357 | pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); |
358 | for (hose = hose_head; hose; hose = hose->next) { | ||
359 | bus = hose->bus; | ||
360 | if (bus) | ||
361 | pci_bus_add_devices(bus); | ||
362 | } | ||
356 | } | 363 | } |
357 | 364 | ||
358 | 365 | ||
diff --git a/arch/alpha/kernel/sys_nautilus.c b/arch/alpha/kernel/sys_nautilus.c index 837c0fa58317..700686d04869 100644 --- a/arch/alpha/kernel/sys_nautilus.c +++ b/arch/alpha/kernel/sys_nautilus.c | |||
@@ -207,6 +207,9 @@ nautilus_init_pci(void) | |||
207 | 207 | ||
208 | /* Scan our single hose. */ | 208 | /* Scan our single hose. */ |
209 | bus = pci_scan_bus(0, alpha_mv.pci_ops, hose); | 209 | bus = pci_scan_bus(0, alpha_mv.pci_ops, hose); |
210 | if (!bus) | ||
211 | return; | ||
212 | |||
210 | hose->bus = bus; | 213 | hose->bus = bus; |
211 | pcibios_claim_one_bus(bus); | 214 | pcibios_claim_one_bus(bus); |
212 | 215 | ||
@@ -253,6 +256,7 @@ nautilus_init_pci(void) | |||
253 | for the root bus, so just clear it. */ | 256 | for the root bus, so just clear it. */ |
254 | bus->self = NULL; | 257 | bus->self = NULL; |
255 | pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); | 258 | pci_fixup_irqs(alpha_mv.pci_swizzle, alpha_mv.pci_map_irq); |
259 | pci_bus_add_devices(bus); | ||
256 | } | 260 | } |
257 | 261 | ||
258 | /* | 262 | /* |
diff --git a/arch/arm/mach-dove/pcie.c b/arch/arm/mach-dove/pcie.c index 8a275f297522..91fe97144570 100644 --- a/arch/arm/mach-dove/pcie.c +++ b/arch/arm/mach-dove/pcie.c | |||
@@ -155,17 +155,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup); | |||
155 | static struct pci_bus __init * | 155 | static struct pci_bus __init * |
156 | dove_pcie_scan_bus(int nr, struct pci_sys_data *sys) | 156 | dove_pcie_scan_bus(int nr, struct pci_sys_data *sys) |
157 | { | 157 | { |
158 | struct pci_bus *bus; | 158 | if (nr >= num_pcie_ports) { |
159 | |||
160 | if (nr < num_pcie_ports) { | ||
161 | bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | ||
162 | &sys->resources); | ||
163 | } else { | ||
164 | bus = NULL; | ||
165 | BUG(); | 159 | BUG(); |
160 | return NULL; | ||
166 | } | 161 | } |
167 | 162 | ||
168 | return bus; | 163 | return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, |
164 | &sys->resources); | ||
169 | } | 165 | } |
170 | 166 | ||
171 | static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 167 | static int __init dove_pcie_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
diff --git a/arch/arm/mach-mv78xx0/pcie.c b/arch/arm/mach-mv78xx0/pcie.c index 445e553f4a28..097ea4cb1136 100644 --- a/arch/arm/mach-mv78xx0/pcie.c +++ b/arch/arm/mach-mv78xx0/pcie.c | |||
@@ -197,17 +197,13 @@ DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_MARVELL, PCI_ANY_ID, rc_pci_fixup); | |||
197 | static struct pci_bus __init * | 197 | static struct pci_bus __init * |
198 | mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys) | 198 | mv78xx0_pcie_scan_bus(int nr, struct pci_sys_data *sys) |
199 | { | 199 | { |
200 | struct pci_bus *bus; | 200 | if (nr >= num_pcie_ports) { |
201 | |||
202 | if (nr < num_pcie_ports) { | ||
203 | bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | ||
204 | &sys->resources); | ||
205 | } else { | ||
206 | bus = NULL; | ||
207 | BUG(); | 201 | BUG(); |
202 | return NULL; | ||
208 | } | 203 | } |
209 | 204 | ||
210 | return bus; | 205 | return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, |
206 | &sys->resources); | ||
211 | } | 207 | } |
212 | 208 | ||
213 | static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot, | 209 | static int __init mv78xx0_pcie_map_irq(const struct pci_dev *dev, u8 slot, |
diff --git a/arch/arm/mach-orion5x/pci.c b/arch/arm/mach-orion5x/pci.c index 87a12d6930ff..b02f3947be51 100644 --- a/arch/arm/mach-orion5x/pci.c +++ b/arch/arm/mach-orion5x/pci.c | |||
@@ -540,37 +540,33 @@ void __init orion5x_pci_set_cardbus_mode(void) | |||
540 | 540 | ||
541 | int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys) | 541 | int __init orion5x_pci_sys_setup(int nr, struct pci_sys_data *sys) |
542 | { | 542 | { |
543 | int ret = 0; | ||
544 | |||
545 | vga_base = ORION5X_PCIE_MEM_PHYS_BASE; | 543 | vga_base = ORION5X_PCIE_MEM_PHYS_BASE; |
546 | 544 | ||
547 | if (nr == 0) { | 545 | if (nr == 0) { |
548 | orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr); | 546 | orion_pcie_set_local_bus_nr(PCIE_BASE, sys->busnr); |
549 | ret = pcie_setup(sys); | 547 | return pcie_setup(sys); |
550 | } else if (nr == 1 && !orion5x_pci_disabled) { | 548 | } |
549 | |||
550 | if (nr == 1 && !orion5x_pci_disabled) { | ||
551 | orion5x_pci_set_bus_nr(sys->busnr); | 551 | orion5x_pci_set_bus_nr(sys->busnr); |
552 | ret = pci_setup(sys); | 552 | return pci_setup(sys); |
553 | } | 553 | } |
554 | 554 | ||
555 | return ret; | 555 | return 0; |
556 | } | 556 | } |
557 | 557 | ||
558 | struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys) | 558 | struct pci_bus __init *orion5x_pci_sys_scan_bus(int nr, struct pci_sys_data *sys) |
559 | { | 559 | { |
560 | struct pci_bus *bus; | 560 | if (nr == 0) |
561 | return pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | ||
562 | &sys->resources); | ||
561 | 563 | ||
562 | if (nr == 0) { | 564 | if (nr == 1 && !orion5x_pci_disabled) |
563 | bus = pci_scan_root_bus(NULL, sys->busnr, &pcie_ops, sys, | 565 | return pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys, |
564 | &sys->resources); | 566 | &sys->resources); |
565 | } else if (nr == 1 && !orion5x_pci_disabled) { | ||
566 | bus = pci_scan_root_bus(NULL, sys->busnr, &pci_ops, sys, | ||
567 | &sys->resources); | ||
568 | } else { | ||
569 | bus = NULL; | ||
570 | BUG(); | ||
571 | } | ||
572 | 567 | ||
573 | return bus; | 568 | BUG(); |
569 | return NULL; | ||
574 | } | 570 | } |
575 | 571 | ||
576 | int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) | 572 | int __init orion5x_pci_map_irq(const struct pci_dev *dev, u8 slot, u8 pin) |
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c27447653903..e315dfe3af1b 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
@@ -2027,6 +2027,13 @@ static bool arm_setup_iommu_dma_ops(struct device *dev, u64 dma_base, u64 size, | |||
2027 | if (!iommu) | 2027 | if (!iommu) |
2028 | return false; | 2028 | return false; |
2029 | 2029 | ||
2030 | /* | ||
2031 | * currently arm_iommu_create_mapping() takes a max of size_t | ||
2032 | * for size param. So check this limit for now. | ||
2033 | */ | ||
2034 | if (size > SIZE_MAX) | ||
2035 | return false; | ||
2036 | |||
2030 | mapping = arm_iommu_create_mapping(dev->bus, dma_base, size); | 2037 | mapping = arm_iommu_create_mapping(dev->bus, dma_base, size); |
2031 | if (IS_ERR(mapping)) { | 2038 | if (IS_ERR(mapping)) { |
2032 | pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n", | 2039 | pr_warn("Failed to create %llu-byte IOMMU mapping for device %s\n", |
diff --git a/arch/frv/mb93090-mb00/pci-vdk.c b/arch/frv/mb93090-mb00/pci-vdk.c index b073f4d771a5..f211839e2cae 100644 --- a/arch/frv/mb93090-mb00/pci-vdk.c +++ b/arch/frv/mb93090-mb00/pci-vdk.c | |||
@@ -316,6 +316,7 @@ void pcibios_fixup_bus(struct pci_bus *bus) | |||
316 | 316 | ||
317 | int __init pcibios_init(void) | 317 | int __init pcibios_init(void) |
318 | { | 318 | { |
319 | struct pci_bus *bus; | ||
319 | struct pci_ops *dir = NULL; | 320 | struct pci_ops *dir = NULL; |
320 | LIST_HEAD(resources); | 321 | LIST_HEAD(resources); |
321 | 322 | ||
@@ -383,12 +384,15 @@ int __init pcibios_init(void) | |||
383 | printk("PCI: Probing PCI hardware\n"); | 384 | printk("PCI: Probing PCI hardware\n"); |
384 | pci_add_resource(&resources, &pci_ioport_resource); | 385 | pci_add_resource(&resources, &pci_ioport_resource); |
385 | pci_add_resource(&resources, &pci_iomem_resource); | 386 | pci_add_resource(&resources, &pci_iomem_resource); |
386 | pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources); | 387 | bus = pci_scan_root_bus(NULL, 0, pci_root_ops, NULL, &resources); |
387 | 388 | ||
388 | pcibios_irq_init(); | 389 | pcibios_irq_init(); |
389 | pcibios_fixup_irqs(); | 390 | pcibios_fixup_irqs(); |
390 | pcibios_resource_survey(); | 391 | pcibios_resource_survey(); |
392 | if (!bus) | ||
393 | return 0; | ||
391 | 394 | ||
395 | pci_bus_add_devices(bus); | ||
392 | return 0; | 396 | return 0; |
393 | } | 397 | } |
394 | 398 | ||
diff --git a/arch/ia64/sn/kernel/io_init.c b/arch/ia64/sn/kernel/io_init.c index 0b5ce82d203d..1be65eb074ec 100644 --- a/arch/ia64/sn/kernel/io_init.c +++ b/arch/ia64/sn/kernel/io_init.c | |||
@@ -271,7 +271,9 @@ sn_pci_controller_fixup(int segment, int busnum, struct pci_bus *bus) | |||
271 | if (bus == NULL) { | 271 | if (bus == NULL) { |
272 | kfree(res); | 272 | kfree(res); |
273 | kfree(controller); | 273 | kfree(controller); |
274 | return; | ||
274 | } | 275 | } |
276 | pci_bus_add_devices(bus); | ||
275 | } | 277 | } |
276 | 278 | ||
277 | /* | 279 | /* |
diff --git a/arch/m68k/coldfire/pci.c b/arch/m68k/coldfire/pci.c index df9679238b6d..821de928dc3f 100644 --- a/arch/m68k/coldfire/pci.c +++ b/arch/m68k/coldfire/pci.c | |||
@@ -313,12 +313,16 @@ static int __init mcf_pci_init(void) | |||
313 | schedule_timeout(msecs_to_jiffies(200)); | 313 | schedule_timeout(msecs_to_jiffies(200)); |
314 | 314 | ||
315 | rootbus = pci_scan_bus(0, &mcf_pci_ops, NULL); | 315 | rootbus = pci_scan_bus(0, &mcf_pci_ops, NULL); |
316 | if (!rootbus) | ||
317 | return -ENODEV; | ||
318 | |||
316 | rootbus->resource[0] = &mcf_pci_io; | 319 | rootbus->resource[0] = &mcf_pci_io; |
317 | rootbus->resource[1] = &mcf_pci_mem; | 320 | rootbus->resource[1] = &mcf_pci_mem; |
318 | 321 | ||
319 | pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq); | 322 | pci_fixup_irqs(pci_common_swizzle, mcf_pci_map_irq); |
320 | pci_bus_size_bridges(rootbus); | 323 | pci_bus_size_bridges(rootbus); |
321 | pci_bus_assign_resources(rootbus); | 324 | pci_bus_assign_resources(rootbus); |
325 | pci_bus_add_devices(rootbus); | ||
322 | return 0; | 326 | return 0; |
323 | } | 327 | } |
324 | 328 | ||
diff --git a/arch/microblaze/pci/pci-common.c b/arch/microblaze/pci/pci-common.c index 48528fb81eff..ae838ed5fcf2 100644 --- a/arch/microblaze/pci/pci-common.c +++ b/arch/microblaze/pci/pci-common.c | |||
@@ -1382,6 +1382,10 @@ static int __init pcibios_init(void) | |||
1382 | 1382 | ||
1383 | /* Call common code to handle resource allocation */ | 1383 | /* Call common code to handle resource allocation */ |
1384 | pcibios_resource_survey(); | 1384 | pcibios_resource_survey(); |
1385 | list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { | ||
1386 | if (hose->bus) | ||
1387 | pci_bus_add_devices(hose->bus); | ||
1388 | } | ||
1385 | 1389 | ||
1386 | return 0; | 1390 | return 0; |
1387 | } | 1391 | } |
diff --git a/arch/mips/pci/pci.c b/arch/mips/pci/pci.c index 1bf60b127377..8bb13a4af68a 100644 --- a/arch/mips/pci/pci.c +++ b/arch/mips/pci/pci.c | |||
@@ -94,27 +94,29 @@ static void pcibios_scanbus(struct pci_controller *hose) | |||
94 | pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset); | 94 | pci_add_resource_offset(&resources, hose->io_resource, hose->io_offset); |
95 | bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, | 95 | bus = pci_scan_root_bus(NULL, next_busno, hose->pci_ops, hose, |
96 | &resources); | 96 | &resources); |
97 | if (!bus) | ||
98 | pci_free_resource_list(&resources); | ||
99 | |||
100 | hose->bus = bus; | 97 | hose->bus = bus; |
101 | 98 | ||
102 | need_domain_info = need_domain_info || hose->index; | 99 | need_domain_info = need_domain_info || hose->index; |
103 | hose->need_domain_info = need_domain_info; | 100 | hose->need_domain_info = need_domain_info; |
104 | if (bus) { | ||
105 | next_busno = bus->busn_res.end + 1; | ||
106 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
107 | reserve some space for bridges. */ | ||
108 | if (next_busno > 224) { | ||
109 | next_busno = 0; | ||
110 | need_domain_info = 1; | ||
111 | } | ||
112 | 101 | ||
113 | if (!pci_has_flag(PCI_PROBE_ONLY)) { | 102 | if (!bus) { |
114 | pci_bus_size_bridges(bus); | 103 | pci_free_resource_list(&resources); |
115 | pci_bus_assign_resources(bus); | 104 | return; |
116 | } | 105 | } |
106 | |||
107 | next_busno = bus->busn_res.end + 1; | ||
108 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
109 | reserve some space for bridges. */ | ||
110 | if (next_busno > 224) { | ||
111 | next_busno = 0; | ||
112 | need_domain_info = 1; | ||
113 | } | ||
114 | |||
115 | if (!pci_has_flag(PCI_PROBE_ONLY)) { | ||
116 | pci_bus_size_bridges(bus); | ||
117 | pci_bus_assign_resources(bus); | ||
117 | } | 118 | } |
119 | pci_bus_add_devices(bus); | ||
118 | } | 120 | } |
119 | 121 | ||
120 | #ifdef CONFIG_OF | 122 | #ifdef CONFIG_OF |
diff --git a/arch/mn10300/unit-asb2305/pci.c b/arch/mn10300/unit-asb2305/pci.c index 613ca1e55b4b..3dfe2d31c67b 100644 --- a/arch/mn10300/unit-asb2305/pci.c +++ b/arch/mn10300/unit-asb2305/pci.c | |||
@@ -342,6 +342,7 @@ static int __init pcibios_init(void) | |||
342 | { | 342 | { |
343 | resource_size_t io_offset, mem_offset; | 343 | resource_size_t io_offset, mem_offset; |
344 | LIST_HEAD(resources); | 344 | LIST_HEAD(resources); |
345 | struct pci_bus *bus; | ||
345 | 346 | ||
346 | ioport_resource.start = 0xA0000000; | 347 | ioport_resource.start = 0xA0000000; |
347 | ioport_resource.end = 0xDFFFFFFF; | 348 | ioport_resource.end = 0xDFFFFFFF; |
@@ -371,11 +372,14 @@ static int __init pcibios_init(void) | |||
371 | 372 | ||
372 | pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset); | 373 | pci_add_resource_offset(&resources, &pci_ioport_resource, io_offset); |
373 | pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset); | 374 | pci_add_resource_offset(&resources, &pci_iomem_resource, mem_offset); |
374 | pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources); | 375 | bus = pci_scan_root_bus(NULL, 0, &pci_direct_ampci, NULL, &resources); |
376 | if (!bus) | ||
377 | return 0; | ||
375 | 378 | ||
376 | pcibios_irq_init(); | 379 | pcibios_irq_init(); |
377 | pcibios_fixup_irqs(); | 380 | pcibios_fixup_irqs(); |
378 | pcibios_resource_survey(); | 381 | pcibios_resource_survey(); |
382 | pci_bus_add_devices(bus); | ||
379 | return 0; | 383 | return 0; |
380 | } | 384 | } |
381 | 385 | ||
diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c index f0b85443e060..b2c76f64c530 100644 --- a/arch/s390/pci/pci.c +++ b/arch/s390/pci/pci.c | |||
@@ -780,8 +780,8 @@ static int zpci_scan_bus(struct zpci_dev *zdev) | |||
780 | zpci_cleanup_bus_resources(zdev); | 780 | zpci_cleanup_bus_resources(zdev); |
781 | return -EIO; | 781 | return -EIO; |
782 | } | 782 | } |
783 | |||
784 | zdev->bus->max_bus_speed = zdev->max_bus_speed; | 783 | zdev->bus->max_bus_speed = zdev->max_bus_speed; |
784 | pci_bus_add_devices(zdev->bus); | ||
785 | return 0; | 785 | return 0; |
786 | } | 786 | } |
787 | 787 | ||
diff --git a/arch/sh/drivers/pci/pci.c b/arch/sh/drivers/pci/pci.c index 1bc09ee7948f..d5462b7bc514 100644 --- a/arch/sh/drivers/pci/pci.c +++ b/arch/sh/drivers/pci/pci.c | |||
@@ -58,20 +58,23 @@ static void pcibios_scanbus(struct pci_channel *hose) | |||
58 | 58 | ||
59 | need_domain_info = need_domain_info || hose->index; | 59 | need_domain_info = need_domain_info || hose->index; |
60 | hose->need_domain_info = need_domain_info; | 60 | hose->need_domain_info = need_domain_info; |
61 | if (bus) { | ||
62 | next_busno = bus->busn_res.end + 1; | ||
63 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
64 | reserve some space for bridges. */ | ||
65 | if (next_busno > 224) { | ||
66 | next_busno = 0; | ||
67 | need_domain_info = 1; | ||
68 | } | ||
69 | 61 | ||
70 | pci_bus_size_bridges(bus); | 62 | if (!bus) { |
71 | pci_bus_assign_resources(bus); | ||
72 | } else { | ||
73 | pci_free_resource_list(&resources); | 63 | pci_free_resource_list(&resources); |
64 | return; | ||
65 | } | ||
66 | |||
67 | next_busno = bus->busn_res.end + 1; | ||
68 | /* Don't allow 8-bit bus number overflow inside the hose - | ||
69 | reserve some space for bridges. */ | ||
70 | if (next_busno > 224) { | ||
71 | next_busno = 0; | ||
72 | need_domain_info = 1; | ||
74 | } | 73 | } |
74 | |||
75 | pci_bus_size_bridges(bus); | ||
76 | pci_bus_assign_resources(bus); | ||
77 | pci_bus_add_devices(bus); | ||
75 | } | 78 | } |
76 | 79 | ||
77 | /* | 80 | /* |
diff --git a/arch/sparc/kernel/leon_pci.c b/arch/sparc/kernel/leon_pci.c index 899b7203a4e4..4371f72ff025 100644 --- a/arch/sparc/kernel/leon_pci.c +++ b/arch/sparc/kernel/leon_pci.c | |||
@@ -34,15 +34,17 @@ void leon_pci_init(struct platform_device *ofdev, struct leon_pci_info *info) | |||
34 | 34 | ||
35 | root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, | 35 | root_bus = pci_scan_root_bus(&ofdev->dev, 0, info->ops, info, |
36 | &resources); | 36 | &resources); |
37 | if (root_bus) { | 37 | if (!root_bus) { |
38 | /* Setup IRQs of all devices using custom routines */ | ||
39 | pci_fixup_irqs(pci_common_swizzle, info->map_irq); | ||
40 | |||
41 | /* Assign devices with resources */ | ||
42 | pci_assign_unassigned_resources(); | ||
43 | } else { | ||
44 | pci_free_resource_list(&resources); | 38 | pci_free_resource_list(&resources); |
39 | return; | ||
45 | } | 40 | } |
41 | |||
42 | /* Setup IRQs of all devices using custom routines */ | ||
43 | pci_fixup_irqs(pci_common_swizzle, info->map_irq); | ||
44 | |||
45 | /* Assign devices with resources */ | ||
46 | pci_assign_unassigned_resources(); | ||
47 | pci_bus_add_devices(root_bus); | ||
46 | } | 48 | } |
47 | 49 | ||
48 | void pcibios_fixup_bus(struct pci_bus *pbus) | 50 | void pcibios_fixup_bus(struct pci_bus *pbus) |
diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index b36365f49478..6f7251fd2eab 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c | |||
@@ -674,11 +674,10 @@ struct pci_bus *pci_scan_one_pbm(struct pci_pbm_info *pbm, | |||
674 | } | 674 | } |
675 | 675 | ||
676 | pci_of_scan_bus(pbm, node, bus); | 676 | pci_of_scan_bus(pbm, node, bus); |
677 | pci_bus_add_devices(bus); | ||
678 | pci_bus_register_of_sysfs(bus); | 677 | pci_bus_register_of_sysfs(bus); |
679 | 678 | ||
680 | pci_claim_bus_resources(bus); | 679 | pci_claim_bus_resources(bus); |
681 | 680 | pci_bus_add_devices(bus); | |
682 | return bus; | 681 | return bus; |
683 | } | 682 | } |
684 | 683 | ||
diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index 6cc78c213c01..24384e1dc33d 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c | |||
@@ -391,12 +391,16 @@ static void __init pcic_pbm_scan_bus(struct linux_pcic *pcic) | |||
391 | struct linux_pbm_info *pbm = &pcic->pbm; | 391 | struct linux_pbm_info *pbm = &pcic->pbm; |
392 | 392 | ||
393 | pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm); | 393 | pbm->pci_bus = pci_scan_bus(pbm->pci_first_busno, &pcic_ops, pbm); |
394 | if (!pbm->pci_bus) | ||
395 | return; | ||
396 | |||
394 | #if 0 /* deadwood transplanted from sparc64 */ | 397 | #if 0 /* deadwood transplanted from sparc64 */ |
395 | pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node); | 398 | pci_fill_in_pbm_cookies(pbm->pci_bus, pbm, pbm->prom_node); |
396 | pci_record_assignments(pbm, pbm->pci_bus); | 399 | pci_record_assignments(pbm, pbm->pci_bus); |
397 | pci_assign_unassigned(pbm, pbm->pci_bus); | 400 | pci_assign_unassigned(pbm, pbm->pci_bus); |
398 | pci_fixup_irq(pbm, pbm->pci_bus); | 401 | pci_fixup_irq(pbm, pbm->pci_bus); |
399 | #endif | 402 | #endif |
403 | pci_bus_add_devices(pbm->pci_bus); | ||
400 | } | 404 | } |
401 | 405 | ||
402 | /* | 406 | /* |
diff --git a/arch/tile/kernel/pci.c b/arch/tile/kernel/pci.c index 325df47f114d..9475a74cd53a 100644 --- a/arch/tile/kernel/pci.c +++ b/arch/tile/kernel/pci.c | |||
@@ -339,6 +339,8 @@ int __init pcibios_init(void) | |||
339 | struct pci_bus *next_bus; | 339 | struct pci_bus *next_bus; |
340 | struct pci_dev *dev; | 340 | struct pci_dev *dev; |
341 | 341 | ||
342 | pci_bus_add_devices(root_bus); | ||
343 | |||
342 | list_for_each_entry(dev, &root_bus->devices, bus_list) { | 344 | list_for_each_entry(dev, &root_bus->devices, bus_list) { |
343 | /* | 345 | /* |
344 | * Find the PCI host controller, ie. the 1st | 346 | * Find the PCI host controller, ie. the 1st |
diff --git a/arch/tile/kernel/pci_gx.c b/arch/tile/kernel/pci_gx.c index 2c95f37ebbed..b1df847d0686 100644 --- a/arch/tile/kernel/pci_gx.c +++ b/arch/tile/kernel/pci_gx.c | |||
@@ -1030,6 +1030,8 @@ int __init pcibios_init(void) | |||
1030 | alloc_mem_map_failed: | 1030 | alloc_mem_map_failed: |
1031 | break; | 1031 | break; |
1032 | } | 1032 | } |
1033 | |||
1034 | pci_bus_add_devices(root_bus); | ||
1033 | } | 1035 | } |
1034 | 1036 | ||
1035 | return 0; | 1037 | return 0; |
diff --git a/arch/unicore32/kernel/pci.c b/arch/unicore32/kernel/pci.c index 374a055a8e6b..d45fa5f3e9c4 100644 --- a/arch/unicore32/kernel/pci.c +++ b/arch/unicore32/kernel/pci.c | |||
@@ -266,17 +266,10 @@ static int __init pci_common_init(void) | |||
266 | pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq); | 266 | pci_fixup_irqs(pci_common_swizzle, pci_puv3_map_irq); |
267 | 267 | ||
268 | if (!pci_has_flag(PCI_PROBE_ONLY)) { | 268 | if (!pci_has_flag(PCI_PROBE_ONLY)) { |
269 | /* | ||
270 | * Size the bridge windows. | ||
271 | */ | ||
272 | pci_bus_size_bridges(puv3_bus); | 269 | pci_bus_size_bridges(puv3_bus); |
273 | |||
274 | /* | ||
275 | * Assign resources. | ||
276 | */ | ||
277 | pci_bus_assign_resources(puv3_bus); | 270 | pci_bus_assign_resources(puv3_bus); |
278 | } | 271 | } |
279 | 272 | pci_bus_add_devices(puv3_bus); | |
280 | return 0; | 273 | return 0; |
281 | } | 274 | } |
282 | subsys_initcall(pci_common_init); | 275 | subsys_initcall(pci_common_init); |
diff --git a/arch/x86/pci/common.c b/arch/x86/pci/common.c index 2fb384724ebb..8fd6f44aee83 100644 --- a/arch/x86/pci/common.c +++ b/arch/x86/pci/common.c | |||
@@ -490,7 +490,9 @@ void pcibios_scan_root(int busnum) | |||
490 | if (!bus) { | 490 | if (!bus) { |
491 | pci_free_resource_list(&resources); | 491 | pci_free_resource_list(&resources); |
492 | kfree(sd); | 492 | kfree(sd); |
493 | return; | ||
493 | } | 494 | } |
495 | pci_bus_add_devices(bus); | ||
494 | } | 496 | } |
495 | 497 | ||
496 | void __init pcibios_set_cache_line_size(void) | 498 | void __init pcibios_set_cache_line_size(void) |
diff --git a/arch/xtensa/kernel/pci.c b/arch/xtensa/kernel/pci.c index 5b3403388d7f..b848cc3dc913 100644 --- a/arch/xtensa/kernel/pci.c +++ b/arch/xtensa/kernel/pci.c | |||
@@ -174,7 +174,7 @@ static int __init pcibios_init(void) | |||
174 | struct pci_controller *pci_ctrl; | 174 | struct pci_controller *pci_ctrl; |
175 | struct list_head resources; | 175 | struct list_head resources; |
176 | struct pci_bus *bus; | 176 | struct pci_bus *bus; |
177 | int next_busno = 0; | 177 | int next_busno = 0, ret; |
178 | 178 | ||
179 | printk("PCI: Probing PCI hardware\n"); | 179 | printk("PCI: Probing PCI hardware\n"); |
180 | 180 | ||
@@ -185,14 +185,25 @@ static int __init pcibios_init(void) | |||
185 | pci_controller_apertures(pci_ctrl, &resources); | 185 | pci_controller_apertures(pci_ctrl, &resources); |
186 | bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno, | 186 | bus = pci_scan_root_bus(NULL, pci_ctrl->first_busno, |
187 | pci_ctrl->ops, pci_ctrl, &resources); | 187 | pci_ctrl->ops, pci_ctrl, &resources); |
188 | if (!bus) | ||
189 | continue; | ||
190 | |||
188 | pci_ctrl->bus = bus; | 191 | pci_ctrl->bus = bus; |
189 | pci_ctrl->last_busno = bus->busn_res.end; | 192 | pci_ctrl->last_busno = bus->busn_res.end; |
190 | if (next_busno <= pci_ctrl->last_busno) | 193 | if (next_busno <= pci_ctrl->last_busno) |
191 | next_busno = pci_ctrl->last_busno+1; | 194 | next_busno = pci_ctrl->last_busno+1; |
192 | } | 195 | } |
193 | pci_bus_count = next_busno; | 196 | pci_bus_count = next_busno; |
197 | ret = platform_pcibios_fixup(); | ||
198 | if (ret) | ||
199 | return ret; | ||
194 | 200 | ||
195 | return platform_pcibios_fixup(); | 201 | for (pci_ctrl = pci_ctrl_head; pci_ctrl; pci_ctrl = pci_ctrl->next) { |
202 | if (pci_ctrl->bus) | ||
203 | pci_bus_add_devices(pci_ctrl->bus); | ||
204 | } | ||
205 | |||
206 | return 0; | ||
196 | } | 207 | } |
197 | 208 | ||
198 | subsys_initcall(pcibios_init); | 209 | subsys_initcall(pcibios_init); |
diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index 68a5f712cd19..1b5569c092c6 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c | |||
@@ -423,8 +423,7 @@ out: | |||
423 | } | 423 | } |
424 | EXPORT_SYMBOL(acpi_pci_osc_control_set); | 424 | EXPORT_SYMBOL(acpi_pci_osc_control_set); |
425 | 425 | ||
426 | static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, | 426 | static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm) |
427 | int *clear_aspm) | ||
428 | { | 427 | { |
429 | u32 support, control, requested; | 428 | u32 support, control, requested; |
430 | acpi_status status; | 429 | acpi_status status; |
@@ -495,10 +494,12 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm, | |||
495 | decode_osc_control(root, "OS now controls", control); | 494 | decode_osc_control(root, "OS now controls", control); |
496 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { | 495 | if (acpi_gbl_FADT.boot_flags & ACPI_FADT_NO_ASPM) { |
497 | /* | 496 | /* |
498 | * We have ASPM control, but the FADT indicates | 497 | * We have ASPM control, but the FADT indicates that |
499 | * that it's unsupported. Clear it. | 498 | * it's unsupported. Leave existing configuration |
499 | * intact and prevent the OS from touching it. | ||
500 | */ | 500 | */ |
501 | *clear_aspm = 1; | 501 | dev_info(&device->dev, "FADT indicates ASPM is unsupported, using BIOS configuration\n"); |
502 | *no_aspm = 1; | ||
502 | } | 503 | } |
503 | } else { | 504 | } else { |
504 | decode_osc_control(root, "OS requested", requested); | 505 | decode_osc_control(root, "OS requested", requested); |
@@ -525,7 +526,7 @@ static int acpi_pci_root_add(struct acpi_device *device, | |||
525 | int result; | 526 | int result; |
526 | struct acpi_pci_root *root; | 527 | struct acpi_pci_root *root; |
527 | acpi_handle handle = device->handle; | 528 | acpi_handle handle = device->handle; |
528 | int no_aspm = 0, clear_aspm = 0; | 529 | int no_aspm = 0; |
529 | bool hotadd = system_state != SYSTEM_BOOTING; | 530 | bool hotadd = system_state != SYSTEM_BOOTING; |
530 | 531 | ||
531 | root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); | 532 | root = kzalloc(sizeof(struct acpi_pci_root), GFP_KERNEL); |
@@ -584,7 +585,7 @@ static int acpi_pci_root_add(struct acpi_device *device, | |||
584 | 585 | ||
585 | root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle); | 586 | root->mcfg_addr = acpi_pci_root_get_mcfg_addr(handle); |
586 | 587 | ||
587 | negotiate_os_control(root, &no_aspm, &clear_aspm); | 588 | negotiate_os_control(root, &no_aspm); |
588 | 589 | ||
589 | /* | 590 | /* |
590 | * TBD: Need PCI interface for enumeration/configuration of roots. | 591 | * TBD: Need PCI interface for enumeration/configuration of roots. |
@@ -607,10 +608,6 @@ static int acpi_pci_root_add(struct acpi_device *device, | |||
607 | goto remove_dmar; | 608 | goto remove_dmar; |
608 | } | 609 | } |
609 | 610 | ||
610 | if (clear_aspm) { | ||
611 | dev_info(&device->dev, "Disabling ASPM (FADT indicates it is unsupported)\n"); | ||
612 | pcie_clear_aspm(root->bus); | ||
613 | } | ||
614 | if (no_aspm) | 611 | if (no_aspm) |
615 | pcie_no_aspm(); | 612 | pcie_no_aspm(); |
616 | 613 | ||
diff --git a/drivers/iommu/of_iommu.c b/drivers/iommu/of_iommu.c index af1dc6a1c0a1..43429ab62228 100644 --- a/drivers/iommu/of_iommu.c +++ b/drivers/iommu/of_iommu.c | |||
@@ -133,19 +133,25 @@ struct iommu_ops *of_iommu_get_ops(struct device_node *np) | |||
133 | return ops; | 133 | return ops; |
134 | } | 134 | } |
135 | 135 | ||
136 | struct iommu_ops *of_iommu_configure(struct device *dev) | 136 | struct iommu_ops *of_iommu_configure(struct device *dev, |
137 | struct device_node *master_np) | ||
137 | { | 138 | { |
138 | struct of_phandle_args iommu_spec; | 139 | struct of_phandle_args iommu_spec; |
139 | struct device_node *np; | 140 | struct device_node *np; |
140 | struct iommu_ops *ops = NULL; | 141 | struct iommu_ops *ops = NULL; |
141 | int idx = 0; | 142 | int idx = 0; |
142 | 143 | ||
144 | if (dev_is_pci(dev)) { | ||
145 | dev_err(dev, "IOMMU is currently not supported for PCI\n"); | ||
146 | return NULL; | ||
147 | } | ||
148 | |||
143 | /* | 149 | /* |
144 | * We don't currently walk up the tree looking for a parent IOMMU. | 150 | * We don't currently walk up the tree looking for a parent IOMMU. |
145 | * See the `Notes:' section of | 151 | * See the `Notes:' section of |
146 | * Documentation/devicetree/bindings/iommu/iommu.txt | 152 | * Documentation/devicetree/bindings/iommu/iommu.txt |
147 | */ | 153 | */ |
148 | while (!of_parse_phandle_with_args(dev->of_node, "iommus", | 154 | while (!of_parse_phandle_with_args(master_np, "iommus", |
149 | "#iommu-cells", idx, | 155 | "#iommu-cells", idx, |
150 | &iommu_spec)) { | 156 | &iommu_spec)) { |
151 | np = iommu_spec.np; | 157 | np = iommu_spec.np; |
diff --git a/drivers/of/device.c b/drivers/of/device.c index 46d6c75c1404..20c1332a0018 100644 --- a/drivers/of/device.c +++ b/drivers/of/device.c | |||
@@ -2,6 +2,9 @@ | |||
2 | #include <linux/kernel.h> | 2 | #include <linux/kernel.h> |
3 | #include <linux/of.h> | 3 | #include <linux/of.h> |
4 | #include <linux/of_device.h> | 4 | #include <linux/of_device.h> |
5 | #include <linux/of_address.h> | ||
6 | #include <linux/of_iommu.h> | ||
7 | #include <linux/dma-mapping.h> | ||
5 | #include <linux/init.h> | 8 | #include <linux/init.h> |
6 | #include <linux/module.h> | 9 | #include <linux/module.h> |
7 | #include <linux/mod_devicetable.h> | 10 | #include <linux/mod_devicetable.h> |
@@ -66,6 +69,87 @@ int of_device_add(struct platform_device *ofdev) | |||
66 | return device_add(&ofdev->dev); | 69 | return device_add(&ofdev->dev); |
67 | } | 70 | } |
68 | 71 | ||
72 | /** | ||
73 | * of_dma_configure - Setup DMA configuration | ||
74 | * @dev: Device to apply DMA configuration | ||
75 | * @np: Pointer to OF node having DMA configuration | ||
76 | * | ||
77 | * Try to get devices's DMA configuration from DT and update it | ||
78 | * accordingly. | ||
79 | * | ||
80 | * If platform code needs to use its own special DMA configuration, it | ||
81 | * can use a platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE events | ||
82 | * to fix up DMA configuration. | ||
83 | */ | ||
84 | void of_dma_configure(struct device *dev, struct device_node *np) | ||
85 | { | ||
86 | u64 dma_addr, paddr, size; | ||
87 | int ret; | ||
88 | bool coherent; | ||
89 | unsigned long offset; | ||
90 | struct iommu_ops *iommu; | ||
91 | |||
92 | /* | ||
93 | * Set default coherent_dma_mask to 32 bit. Drivers are expected to | ||
94 | * setup the correct supported mask. | ||
95 | */ | ||
96 | if (!dev->coherent_dma_mask) | ||
97 | dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
98 | |||
99 | /* | ||
100 | * Set it to coherent_dma_mask by default if the architecture | ||
101 | * code has not set it. | ||
102 | */ | ||
103 | if (!dev->dma_mask) | ||
104 | dev->dma_mask = &dev->coherent_dma_mask; | ||
105 | |||
106 | ret = of_dma_get_range(np, &dma_addr, &paddr, &size); | ||
107 | if (ret < 0) { | ||
108 | dma_addr = offset = 0; | ||
109 | size = dev->coherent_dma_mask + 1; | ||
110 | } else { | ||
111 | offset = PFN_DOWN(paddr - dma_addr); | ||
112 | |||
113 | /* | ||
114 | * Add a work around to treat the size as mask + 1 in case | ||
115 | * it is defined in DT as a mask. | ||
116 | */ | ||
117 | if (size & 1) { | ||
118 | dev_warn(dev, "Invalid size 0x%llx for dma-range\n", | ||
119 | size); | ||
120 | size = size + 1; | ||
121 | } | ||
122 | |||
123 | if (!size) { | ||
124 | dev_err(dev, "Adjusted size 0x%llx invalid\n", size); | ||
125 | return; | ||
126 | } | ||
127 | dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset); | ||
128 | } | ||
129 | |||
130 | dev->dma_pfn_offset = offset; | ||
131 | |||
132 | /* | ||
133 | * Limit coherent and dma mask based on size and default mask | ||
134 | * set by the driver. | ||
135 | */ | ||
136 | dev->coherent_dma_mask = min(dev->coherent_dma_mask, | ||
137 | DMA_BIT_MASK(ilog2(dma_addr + size))); | ||
138 | *dev->dma_mask = min((*dev->dma_mask), | ||
139 | DMA_BIT_MASK(ilog2(dma_addr + size))); | ||
140 | |||
141 | coherent = of_dma_is_coherent(np); | ||
142 | dev_dbg(dev, "device is%sdma coherent\n", | ||
143 | coherent ? " " : " not "); | ||
144 | |||
145 | iommu = of_iommu_configure(dev, np); | ||
146 | dev_dbg(dev, "device is%sbehind an iommu\n", | ||
147 | iommu ? " " : " not "); | ||
148 | |||
149 | arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent); | ||
150 | } | ||
151 | EXPORT_SYMBOL_GPL(of_dma_configure); | ||
152 | |||
69 | int of_device_register(struct platform_device *pdev) | 153 | int of_device_register(struct platform_device *pdev) |
70 | { | 154 | { |
71 | device_initialize(&pdev->dev); | 155 | device_initialize(&pdev->dev); |
diff --git a/drivers/of/of_pci.c b/drivers/of/of_pci.c index 62426d81a4d6..5751dc5b6494 100644 --- a/drivers/of/of_pci.c +++ b/drivers/of/of_pci.c | |||
@@ -2,6 +2,7 @@ | |||
2 | #include <linux/export.h> | 2 | #include <linux/export.h> |
3 | #include <linux/of.h> | 3 | #include <linux/of.h> |
4 | #include <linux/of_address.h> | 4 | #include <linux/of_address.h> |
5 | #include <linux/of_device.h> | ||
5 | #include <linux/of_pci.h> | 6 | #include <linux/of_pci.h> |
6 | #include <linux/slab.h> | 7 | #include <linux/slab.h> |
7 | 8 | ||
@@ -116,6 +117,26 @@ int of_get_pci_domain_nr(struct device_node *node) | |||
116 | } | 117 | } |
117 | EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); | 118 | EXPORT_SYMBOL_GPL(of_get_pci_domain_nr); |
118 | 119 | ||
120 | /** | ||
121 | * of_pci_dma_configure - Setup DMA configuration | ||
122 | * @dev: ptr to pci_dev struct of the PCI device | ||
123 | * | ||
124 | * Function to update PCI devices's DMA configuration using the same | ||
125 | * info from the OF node of host bridge's parent (if any). | ||
126 | */ | ||
127 | void of_pci_dma_configure(struct pci_dev *pci_dev) | ||
128 | { | ||
129 | struct device *dev = &pci_dev->dev; | ||
130 | struct device *bridge = pci_get_host_bridge_device(pci_dev); | ||
131 | |||
132 | if (!bridge->parent) | ||
133 | return; | ||
134 | |||
135 | of_dma_configure(dev, bridge->parent->of_node); | ||
136 | pci_put_host_bridge_device(bridge); | ||
137 | } | ||
138 | EXPORT_SYMBOL_GPL(of_pci_dma_configure); | ||
139 | |||
119 | #if defined(CONFIG_OF_ADDRESS) | 140 | #if defined(CONFIG_OF_ADDRESS) |
120 | /** | 141 | /** |
121 | * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT | 142 | * of_pci_get_host_bridge_resources - Parse PCI host bridge resources from DT |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index b189733a1539..a01f57c9e34e 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
@@ -19,7 +19,6 @@ | |||
19 | #include <linux/slab.h> | 19 | #include <linux/slab.h> |
20 | #include <linux/of_address.h> | 20 | #include <linux/of_address.h> |
21 | #include <linux/of_device.h> | 21 | #include <linux/of_device.h> |
22 | #include <linux/of_iommu.h> | ||
23 | #include <linux/of_irq.h> | 22 | #include <linux/of_irq.h> |
24 | #include <linux/of_platform.h> | 23 | #include <linux/of_platform.h> |
25 | #include <linux/platform_device.h> | 24 | #include <linux/platform_device.h> |
@@ -150,59 +149,6 @@ struct platform_device *of_device_alloc(struct device_node *np, | |||
150 | } | 149 | } |
151 | EXPORT_SYMBOL(of_device_alloc); | 150 | EXPORT_SYMBOL(of_device_alloc); |
152 | 151 | ||
153 | /** | ||
154 | * of_dma_configure - Setup DMA configuration | ||
155 | * @dev: Device to apply DMA configuration | ||
156 | * | ||
157 | * Try to get devices's DMA configuration from DT and update it | ||
158 | * accordingly. | ||
159 | * | ||
160 | * In case if platform code need to use own special DMA configuration,it | ||
161 | * can use Platform bus notifier and handle BUS_NOTIFY_ADD_DEVICE event | ||
162 | * to fix up DMA configuration. | ||
163 | */ | ||
164 | static void of_dma_configure(struct device *dev) | ||
165 | { | ||
166 | u64 dma_addr, paddr, size; | ||
167 | int ret; | ||
168 | bool coherent; | ||
169 | unsigned long offset; | ||
170 | struct iommu_ops *iommu; | ||
171 | |||
172 | /* | ||
173 | * Set default dma-mask to 32 bit. Drivers are expected to setup | ||
174 | * the correct supported dma_mask. | ||
175 | */ | ||
176 | dev->coherent_dma_mask = DMA_BIT_MASK(32); | ||
177 | |||
178 | /* | ||
179 | * Set it to coherent_dma_mask by default if the architecture | ||
180 | * code has not set it. | ||
181 | */ | ||
182 | if (!dev->dma_mask) | ||
183 | dev->dma_mask = &dev->coherent_dma_mask; | ||
184 | |||
185 | ret = of_dma_get_range(dev->of_node, &dma_addr, &paddr, &size); | ||
186 | if (ret < 0) { | ||
187 | dma_addr = offset = 0; | ||
188 | size = dev->coherent_dma_mask; | ||
189 | } else { | ||
190 | offset = PFN_DOWN(paddr - dma_addr); | ||
191 | dev_dbg(dev, "dma_pfn_offset(%#08lx)\n", offset); | ||
192 | } | ||
193 | dev->dma_pfn_offset = offset; | ||
194 | |||
195 | coherent = of_dma_is_coherent(dev->of_node); | ||
196 | dev_dbg(dev, "device is%sdma coherent\n", | ||
197 | coherent ? " " : " not "); | ||
198 | |||
199 | iommu = of_iommu_configure(dev); | ||
200 | dev_dbg(dev, "device is%sbehind an iommu\n", | ||
201 | iommu ? " " : " not "); | ||
202 | |||
203 | arch_setup_dma_ops(dev, dma_addr, size, iommu, coherent); | ||
204 | } | ||
205 | |||
206 | static void of_dma_deconfigure(struct device *dev) | 152 | static void of_dma_deconfigure(struct device *dev) |
207 | { | 153 | { |
208 | arch_teardown_dma_ops(dev); | 154 | arch_teardown_dma_ops(dev); |
@@ -236,7 +182,7 @@ static struct platform_device *of_platform_device_create_pdata( | |||
236 | 182 | ||
237 | dev->dev.bus = &platform_bus_type; | 183 | dev->dev.bus = &platform_bus_type; |
238 | dev->dev.platform_data = platform_data; | 184 | dev->dev.platform_data = platform_data; |
239 | of_dma_configure(&dev->dev); | 185 | of_dma_configure(&dev->dev, dev->dev.of_node); |
240 | 186 | ||
241 | if (of_device_add(dev) != 0) { | 187 | if (of_device_add(dev) != 0) { |
242 | of_dma_deconfigure(&dev->dev); | 188 | of_dma_deconfigure(&dev->dev); |
@@ -299,7 +245,7 @@ static struct amba_device *of_amba_device_create(struct device_node *node, | |||
299 | dev_set_name(&dev->dev, "%s", bus_id); | 245 | dev_set_name(&dev->dev, "%s", bus_id); |
300 | else | 246 | else |
301 | of_device_make_bus_id(&dev->dev); | 247 | of_device_make_bus_id(&dev->dev); |
302 | of_dma_configure(&dev->dev); | 248 | of_dma_configure(&dev->dev, dev->dev.of_node); |
303 | 249 | ||
304 | /* Allow the HW Peripheral ID to be overridden */ | 250 | /* Allow the HW Peripheral ID to be overridden */ |
305 | prop = of_get_property(node, "arm,primecell-periphid", NULL); | 251 | prop = of_get_property(node, "arm,primecell-periphid", NULL); |
diff --git a/drivers/pci/host-bridge.c b/drivers/pci/host-bridge.c index 39b2dbe585aa..5f4a2e04c8d7 100644 --- a/drivers/pci/host-bridge.c +++ b/drivers/pci/host-bridge.c | |||
@@ -16,13 +16,27 @@ static struct pci_bus *find_pci_root_bus(struct pci_bus *bus) | |||
16 | return bus; | 16 | return bus; |
17 | } | 17 | } |
18 | 18 | ||
19 | static struct pci_host_bridge *find_pci_host_bridge(struct pci_bus *bus) | 19 | struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus) |
20 | { | 20 | { |
21 | struct pci_bus *root_bus = find_pci_root_bus(bus); | 21 | struct pci_bus *root_bus = find_pci_root_bus(bus); |
22 | 22 | ||
23 | return to_pci_host_bridge(root_bus->bridge); | 23 | return to_pci_host_bridge(root_bus->bridge); |
24 | } | 24 | } |
25 | 25 | ||
26 | struct device *pci_get_host_bridge_device(struct pci_dev *dev) | ||
27 | { | ||
28 | struct pci_bus *root_bus = find_pci_root_bus(dev->bus); | ||
29 | struct device *bridge = root_bus->bridge; | ||
30 | |||
31 | kobject_get(&bridge->kobj); | ||
32 | return bridge; | ||
33 | } | ||
34 | |||
35 | void pci_put_host_bridge_device(struct device *dev) | ||
36 | { | ||
37 | kobject_put(&dev->kobj); | ||
38 | } | ||
39 | |||
26 | void pci_set_host_bridge_release(struct pci_host_bridge *bridge, | 40 | void pci_set_host_bridge_release(struct pci_host_bridge *bridge, |
27 | void (*release_fn)(struct pci_host_bridge *), | 41 | void (*release_fn)(struct pci_host_bridge *), |
28 | void *release_data) | 42 | void *release_data) |
@@ -34,7 +48,7 @@ void pci_set_host_bridge_release(struct pci_host_bridge *bridge, | |||
34 | void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, | 48 | void pcibios_resource_to_bus(struct pci_bus *bus, struct pci_bus_region *region, |
35 | struct resource *res) | 49 | struct resource *res) |
36 | { | 50 | { |
37 | struct pci_host_bridge *bridge = find_pci_host_bridge(bus); | 51 | struct pci_host_bridge *bridge = pci_find_host_bridge(bus); |
38 | struct resource_entry *window; | 52 | struct resource_entry *window; |
39 | resource_size_t offset = 0; | 53 | resource_size_t offset = 0; |
40 | 54 | ||
@@ -59,7 +73,7 @@ static bool region_contains(struct pci_bus_region *region1, | |||
59 | void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, | 73 | void pcibios_bus_to_resource(struct pci_bus *bus, struct resource *res, |
60 | struct pci_bus_region *region) | 74 | struct pci_bus_region *region) |
61 | { | 75 | { |
62 | struct pci_host_bridge *bridge = find_pci_host_bridge(bus); | 76 | struct pci_host_bridge *bridge = pci_find_host_bridge(bus); |
63 | struct resource_entry *window; | 77 | struct resource_entry *window; |
64 | resource_size_t offset = 0; | 78 | resource_size_t offset = 0; |
65 | 79 | ||
diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig index 7b892a9cc4fc..1dfb567b3522 100644 --- a/drivers/pci/host/Kconfig +++ b/drivers/pci/host/Kconfig | |||
@@ -106,4 +106,23 @@ config PCI_VERSATILE | |||
106 | bool "ARM Versatile PB PCI controller" | 106 | bool "ARM Versatile PB PCI controller" |
107 | depends on ARCH_VERSATILE | 107 | depends on ARCH_VERSATILE |
108 | 108 | ||
109 | config PCIE_IPROC | ||
110 | tristate "Broadcom iProc PCIe controller" | ||
111 | depends on OF && ARM | ||
112 | default n | ||
113 | help | ||
114 | This enables the iProc PCIe core controller support for Broadcom's | ||
115 | iProc family of SoCs. An appropriate bus interface driver also needs | ||
116 | to be enabled | ||
117 | |||
118 | config PCIE_IPROC_PLATFORM | ||
119 | tristate "Broadcom iProc PCIe platform bus driver" | ||
120 | depends on ARCH_BCM_IPROC || (ARM && COMPILE_TEST) | ||
121 | depends on OF | ||
122 | select PCIE_IPROC | ||
123 | default ARCH_BCM_IPROC | ||
124 | help | ||
125 | Say Y here if you want to use the Broadcom iProc PCIe controller | ||
126 | through the generic platform bus interface | ||
127 | |||
109 | endmenu | 128 | endmenu |
diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile index e61d91c92bf1..f733b4e27642 100644 --- a/drivers/pci/host/Makefile +++ b/drivers/pci/host/Makefile | |||
@@ -13,3 +13,5 @@ obj-$(CONFIG_PCIE_XILINX) += pcie-xilinx.o | |||
13 | obj-$(CONFIG_PCI_XGENE) += pci-xgene.o | 13 | obj-$(CONFIG_PCI_XGENE) += pci-xgene.o |
14 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o | 14 | obj-$(CONFIG_PCI_LAYERSCAPE) += pci-layerscape.o |
15 | obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o | 15 | obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o |
16 | obj-$(CONFIG_PCIE_IPROC) += pcie-iproc.o | ||
17 | obj-$(CONFIG_PCIE_IPROC_PLATFORM) += pcie-iproc-platform.o | ||
diff --git a/drivers/pci/host/pci-exynos.c b/drivers/pci/host/pci-exynos.c index d202b37c3698..c139237e0e52 100644 --- a/drivers/pci/host/pci-exynos.c +++ b/drivers/pci/host/pci-exynos.c | |||
@@ -396,7 +396,7 @@ static void exynos_pcie_enable_irq_pulse(struct pcie_port *pp) | |||
396 | 396 | ||
397 | /* enable INTX interrupt */ | 397 | /* enable INTX interrupt */ |
398 | val = IRQ_INTA_ASSERT | IRQ_INTB_ASSERT | | 398 | val = IRQ_INTA_ASSERT | IRQ_INTB_ASSERT | |
399 | IRQ_INTC_ASSERT | IRQ_INTD_ASSERT, | 399 | IRQ_INTC_ASSERT | IRQ_INTD_ASSERT; |
400 | exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_PULSE); | 400 | exynos_elb_writel(exynos_pcie, val, PCIE_IRQ_EN_PULSE); |
401 | } | 401 | } |
402 | 402 | ||
diff --git a/drivers/pci/host/pci-keystone-dw.c b/drivers/pci/host/pci-keystone-dw.c index 66d8ea41b972..f34892e0edb4 100644 --- a/drivers/pci/host/pci-keystone-dw.c +++ b/drivers/pci/host/pci-keystone-dw.c | |||
@@ -496,11 +496,12 @@ int __init ks_dw_pcie_host_init(struct keystone_pcie *ks_pcie, | |||
496 | 496 | ||
497 | /* Index 1 is the application reg. space address */ | 497 | /* Index 1 is the application reg. space address */ |
498 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 498 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
499 | ks_pcie->app = *res; | ||
500 | ks_pcie->va_app_base = devm_ioremap_resource(pp->dev, res); | 499 | ks_pcie->va_app_base = devm_ioremap_resource(pp->dev, res); |
501 | if (IS_ERR(ks_pcie->va_app_base)) | 500 | if (IS_ERR(ks_pcie->va_app_base)) |
502 | return PTR_ERR(ks_pcie->va_app_base); | 501 | return PTR_ERR(ks_pcie->va_app_base); |
503 | 502 | ||
503 | ks_pcie->app = *res; | ||
504 | |||
504 | /* Create legacy IRQ domain */ | 505 | /* Create legacy IRQ domain */ |
505 | ks_pcie->legacy_irq_domain = | 506 | ks_pcie->legacy_irq_domain = |
506 | irq_domain_add_linear(ks_pcie->legacy_intc_np, | 507 | irq_domain_add_linear(ks_pcie->legacy_intc_np, |
diff --git a/drivers/pci/host/pci-layerscape.c b/drivers/pci/host/pci-layerscape.c index 68c9e5e9b0a8..4a6e62f67579 100644 --- a/drivers/pci/host/pci-layerscape.c +++ b/drivers/pci/host/pci-layerscape.c | |||
@@ -127,14 +127,11 @@ static int __init ls_pcie_probe(struct platform_device *pdev) | |||
127 | pcie->dev = &pdev->dev; | 127 | pcie->dev = &pdev->dev; |
128 | 128 | ||
129 | dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); | 129 | dbi_base = platform_get_resource_byname(pdev, IORESOURCE_MEM, "regs"); |
130 | if (!dbi_base) { | ||
131 | dev_err(&pdev->dev, "missing *regs* space\n"); | ||
132 | return -ENODEV; | ||
133 | } | ||
134 | |||
135 | pcie->dbi = devm_ioremap_resource(&pdev->dev, dbi_base); | 130 | pcie->dbi = devm_ioremap_resource(&pdev->dev, dbi_base); |
136 | if (IS_ERR(pcie->dbi)) | 131 | if (IS_ERR(pcie->dbi)) { |
132 | dev_err(&pdev->dev, "missing *regs* space\n"); | ||
137 | return PTR_ERR(pcie->dbi); | 133 | return PTR_ERR(pcie->dbi); |
134 | } | ||
138 | 135 | ||
139 | pcie->scfg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, | 136 | pcie->scfg = syscon_regmap_lookup_by_phandle(pdev->dev.of_node, |
140 | "fsl,pcie-scfg"); | 137 | "fsl,pcie-scfg"); |
diff --git a/drivers/pci/host/pci-mvebu.c b/drivers/pci/host/pci-mvebu.c index 1309cfbaa719..1ab863551920 100644 --- a/drivers/pci/host/pci-mvebu.c +++ b/drivers/pci/host/pci-mvebu.c | |||
@@ -129,6 +129,7 @@ struct mvebu_pcie_port { | |||
129 | size_t memwin_size; | 129 | size_t memwin_size; |
130 | phys_addr_t iowin_base; | 130 | phys_addr_t iowin_base; |
131 | size_t iowin_size; | 131 | size_t iowin_size; |
132 | u32 saved_pcie_stat; | ||
132 | }; | 133 | }; |
133 | 134 | ||
134 | static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg) | 135 | static inline void mvebu_writel(struct mvebu_pcie_port *port, u32 val, u32 reg) |
@@ -899,6 +900,35 @@ static void mvebu_pcie_msi_enable(struct mvebu_pcie *pcie) | |||
899 | pcie->msi->dev = &pcie->pdev->dev; | 900 | pcie->msi->dev = &pcie->pdev->dev; |
900 | } | 901 | } |
901 | 902 | ||
903 | static int mvebu_pcie_suspend(struct device *dev) | ||
904 | { | ||
905 | struct mvebu_pcie *pcie; | ||
906 | int i; | ||
907 | |||
908 | pcie = dev_get_drvdata(dev); | ||
909 | for (i = 0; i < pcie->nports; i++) { | ||
910 | struct mvebu_pcie_port *port = pcie->ports + i; | ||
911 | port->saved_pcie_stat = mvebu_readl(port, PCIE_STAT_OFF); | ||
912 | } | ||
913 | |||
914 | return 0; | ||
915 | } | ||
916 | |||
917 | static int mvebu_pcie_resume(struct device *dev) | ||
918 | { | ||
919 | struct mvebu_pcie *pcie; | ||
920 | int i; | ||
921 | |||
922 | pcie = dev_get_drvdata(dev); | ||
923 | for (i = 0; i < pcie->nports; i++) { | ||
924 | struct mvebu_pcie_port *port = pcie->ports + i; | ||
925 | mvebu_writel(port, port->saved_pcie_stat, PCIE_STAT_OFF); | ||
926 | mvebu_pcie_setup_hw(port); | ||
927 | } | ||
928 | |||
929 | return 0; | ||
930 | } | ||
931 | |||
902 | static int mvebu_pcie_probe(struct platform_device *pdev) | 932 | static int mvebu_pcie_probe(struct platform_device *pdev) |
903 | { | 933 | { |
904 | struct mvebu_pcie *pcie; | 934 | struct mvebu_pcie *pcie; |
@@ -1056,6 +1086,8 @@ static int mvebu_pcie_probe(struct platform_device *pdev) | |||
1056 | mvebu_pcie_msi_enable(pcie); | 1086 | mvebu_pcie_msi_enable(pcie); |
1057 | mvebu_pcie_enable(pcie); | 1087 | mvebu_pcie_enable(pcie); |
1058 | 1088 | ||
1089 | platform_set_drvdata(pdev, pcie); | ||
1090 | |||
1059 | return 0; | 1091 | return 0; |
1060 | } | 1092 | } |
1061 | 1093 | ||
@@ -1068,12 +1100,18 @@ static const struct of_device_id mvebu_pcie_of_match_table[] = { | |||
1068 | }; | 1100 | }; |
1069 | MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table); | 1101 | MODULE_DEVICE_TABLE(of, mvebu_pcie_of_match_table); |
1070 | 1102 | ||
1103 | static struct dev_pm_ops mvebu_pcie_pm_ops = { | ||
1104 | .suspend_noirq = mvebu_pcie_suspend, | ||
1105 | .resume_noirq = mvebu_pcie_resume, | ||
1106 | }; | ||
1107 | |||
1071 | static struct platform_driver mvebu_pcie_driver = { | 1108 | static struct platform_driver mvebu_pcie_driver = { |
1072 | .driver = { | 1109 | .driver = { |
1073 | .name = "mvebu-pcie", | 1110 | .name = "mvebu-pcie", |
1074 | .of_match_table = mvebu_pcie_of_match_table, | 1111 | .of_match_table = mvebu_pcie_of_match_table, |
1075 | /* driver unloading/unbinding currently not supported */ | 1112 | /* driver unloading/unbinding currently not supported */ |
1076 | .suppress_bind_attrs = true, | 1113 | .suppress_bind_attrs = true, |
1114 | .pm = &mvebu_pcie_pm_ops, | ||
1077 | }, | 1115 | }, |
1078 | .probe = mvebu_pcie_probe, | 1116 | .probe = mvebu_pcie_probe, |
1079 | }; | 1117 | }; |
diff --git a/drivers/pci/host/pci-rcar-gen2.c b/drivers/pci/host/pci-rcar-gen2.c index dd6b84e6206c..367e28fa7564 100644 --- a/drivers/pci/host/pci-rcar-gen2.c +++ b/drivers/pci/host/pci-rcar-gen2.c | |||
@@ -301,6 +301,9 @@ static int rcar_pci_probe(struct platform_device *pdev) | |||
301 | if (!mem_res || !mem_res->start) | 301 | if (!mem_res || !mem_res->start) |
302 | return -ENODEV; | 302 | return -ENODEV; |
303 | 303 | ||
304 | if (mem_res->start & 0xFFFF) | ||
305 | return -EINVAL; | ||
306 | |||
304 | priv = devm_kzalloc(&pdev->dev, | 307 | priv = devm_kzalloc(&pdev->dev, |
305 | sizeof(struct rcar_pci_priv), GFP_KERNEL); | 308 | sizeof(struct rcar_pci_priv), GFP_KERNEL); |
306 | if (!priv) | 309 | if (!priv) |
diff --git a/drivers/pci/host/pci-versatile.c b/drivers/pci/host/pci-versatile.c index 464bf492ee2a..0863d9cc25f8 100644 --- a/drivers/pci/host/pci-versatile.c +++ b/drivers/pci/host/pci-versatile.c | |||
@@ -138,19 +138,19 @@ static int versatile_pci_probe(struct platform_device *pdev) | |||
138 | LIST_HEAD(pci_res); | 138 | LIST_HEAD(pci_res); |
139 | 139 | ||
140 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 140 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
141 | if (!res) | ||
142 | return -ENODEV; | ||
143 | versatile_pci_base = devm_ioremap_resource(&pdev->dev, res); | 141 | versatile_pci_base = devm_ioremap_resource(&pdev->dev, res); |
142 | if (IS_ERR(versatile_pci_base)) | ||
143 | return PTR_ERR(versatile_pci_base); | ||
144 | 144 | ||
145 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); | 145 | res = platform_get_resource(pdev, IORESOURCE_MEM, 1); |
146 | if (!res) | ||
147 | return -ENODEV; | ||
148 | versatile_cfg_base[0] = devm_ioremap_resource(&pdev->dev, res); | 146 | versatile_cfg_base[0] = devm_ioremap_resource(&pdev->dev, res); |
147 | if (IS_ERR(versatile_cfg_base[0])) | ||
148 | return PTR_ERR(versatile_cfg_base[0]); | ||
149 | 149 | ||
150 | res = platform_get_resource(pdev, IORESOURCE_MEM, 2); | 150 | res = platform_get_resource(pdev, IORESOURCE_MEM, 2); |
151 | if (!res) | ||
152 | return -ENODEV; | ||
153 | versatile_cfg_base[1] = devm_ioremap_resource(&pdev->dev, res); | 151 | versatile_cfg_base[1] = devm_ioremap_resource(&pdev->dev, res); |
152 | if (IS_ERR(versatile_cfg_base[1])) | ||
153 | return PTR_ERR(versatile_cfg_base[1]); | ||
154 | 154 | ||
155 | ret = versatile_pci_parse_request_of_pci_ranges(&pdev->dev, &pci_res); | 155 | ret = versatile_pci_parse_request_of_pci_ranges(&pdev->dev, &pci_res); |
156 | if (ret) | 156 | if (ret) |
@@ -214,6 +214,7 @@ static int versatile_pci_probe(struct platform_device *pdev) | |||
214 | 214 | ||
215 | pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); | 215 | pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); |
216 | pci_assign_unassigned_bus_resources(bus); | 216 | pci_assign_unassigned_bus_resources(bus); |
217 | pci_bus_add_devices(bus); | ||
217 | 218 | ||
218 | return 0; | 219 | return 0; |
219 | } | 220 | } |
diff --git a/drivers/pci/host/pcie-iproc-platform.c b/drivers/pci/host/pcie-iproc-platform.c new file mode 100644 index 000000000000..afad6c21fcfa --- /dev/null +++ b/drivers/pci/host/pcie-iproc-platform.c | |||
@@ -0,0 +1,108 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2015 Broadcom Corporation | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
9 | * kind, whether express or implied; without even the implied warranty | ||
10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #include <linux/kernel.h> | ||
15 | #include <linux/pci.h> | ||
16 | #include <linux/clk.h> | ||
17 | #include <linux/module.h> | ||
18 | #include <linux/slab.h> | ||
19 | #include <linux/interrupt.h> | ||
20 | #include <linux/platform_device.h> | ||
21 | #include <linux/of_address.h> | ||
22 | #include <linux/of_pci.h> | ||
23 | #include <linux/of_irq.h> | ||
24 | #include <linux/of_platform.h> | ||
25 | #include <linux/phy/phy.h> | ||
26 | |||
27 | #include "pcie-iproc.h" | ||
28 | |||
29 | static int iproc_pcie_pltfm_probe(struct platform_device *pdev) | ||
30 | { | ||
31 | struct iproc_pcie *pcie; | ||
32 | struct device_node *np = pdev->dev.of_node; | ||
33 | struct resource reg; | ||
34 | resource_size_t iobase = 0; | ||
35 | LIST_HEAD(res); | ||
36 | int ret; | ||
37 | |||
38 | pcie = devm_kzalloc(&pdev->dev, sizeof(struct iproc_pcie), GFP_KERNEL); | ||
39 | if (!pcie) | ||
40 | return -ENOMEM; | ||
41 | |||
42 | pcie->dev = &pdev->dev; | ||
43 | platform_set_drvdata(pdev, pcie); | ||
44 | |||
45 | ret = of_address_to_resource(np, 0, ®); | ||
46 | if (ret < 0) { | ||
47 | dev_err(pcie->dev, "unable to obtain controller resources\n"); | ||
48 | return ret; | ||
49 | } | ||
50 | |||
51 | pcie->base = devm_ioremap(pcie->dev, reg.start, resource_size(®)); | ||
52 | if (!pcie->base) { | ||
53 | dev_err(pcie->dev, "unable to map controller registers\n"); | ||
54 | return -ENOMEM; | ||
55 | } | ||
56 | |||
57 | /* PHY use is optional */ | ||
58 | pcie->phy = devm_phy_get(&pdev->dev, "pcie-phy"); | ||
59 | if (IS_ERR(pcie->phy)) { | ||
60 | if (PTR_ERR(pcie->phy) == -EPROBE_DEFER) | ||
61 | return -EPROBE_DEFER; | ||
62 | pcie->phy = NULL; | ||
63 | } | ||
64 | |||
65 | ret = of_pci_get_host_bridge_resources(np, 0, 0xff, &res, &iobase); | ||
66 | if (ret) { | ||
67 | dev_err(pcie->dev, | ||
68 | "unable to get PCI host bridge resources\n"); | ||
69 | return ret; | ||
70 | } | ||
71 | |||
72 | pcie->resources = &res; | ||
73 | |||
74 | ret = iproc_pcie_setup(pcie); | ||
75 | if (ret) { | ||
76 | dev_err(pcie->dev, "PCIe controller setup failed\n"); | ||
77 | return ret; | ||
78 | } | ||
79 | |||
80 | return 0; | ||
81 | } | ||
82 | |||
83 | static int iproc_pcie_pltfm_remove(struct platform_device *pdev) | ||
84 | { | ||
85 | struct iproc_pcie *pcie = platform_get_drvdata(pdev); | ||
86 | |||
87 | return iproc_pcie_remove(pcie); | ||
88 | } | ||
89 | |||
90 | static const struct of_device_id iproc_pcie_of_match_table[] = { | ||
91 | { .compatible = "brcm,iproc-pcie", }, | ||
92 | { /* sentinel */ } | ||
93 | }; | ||
94 | MODULE_DEVICE_TABLE(of, iproc_pcie_of_match_table); | ||
95 | |||
96 | static struct platform_driver iproc_pcie_pltfm_driver = { | ||
97 | .driver = { | ||
98 | .name = "iproc-pcie", | ||
99 | .of_match_table = of_match_ptr(iproc_pcie_of_match_table), | ||
100 | }, | ||
101 | .probe = iproc_pcie_pltfm_probe, | ||
102 | .remove = iproc_pcie_pltfm_remove, | ||
103 | }; | ||
104 | module_platform_driver(iproc_pcie_pltfm_driver); | ||
105 | |||
106 | MODULE_AUTHOR("Ray Jui <rjui@broadcom.com>"); | ||
107 | MODULE_DESCRIPTION("Broadcom iPROC PCIe platform driver"); | ||
108 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/pci/host/pcie-iproc.c b/drivers/pci/host/pcie-iproc.c new file mode 100644 index 000000000000..329e1b54528b --- /dev/null +++ b/drivers/pci/host/pcie-iproc.c | |||
@@ -0,0 +1,268 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Hauke Mehrtens <hauke@hauke-m.de> | ||
3 | * Copyright (C) 2015 Broadcom Corporatcommon ion | ||
4 | * | ||
5 | * This program is free software; you can redistribute it and/or | ||
6 | * modify it under the terms of the GNU General Public License as | ||
7 | * published by the Free Software Foundation version 2. | ||
8 | * | ||
9 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
10 | * kind, whether express or implied; without even the implied warranty | ||
11 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | */ | ||
14 | |||
15 | #include <linux/kernel.h> | ||
16 | #include <linux/pci.h> | ||
17 | #include <linux/msi.h> | ||
18 | #include <linux/clk.h> | ||
19 | #include <linux/module.h> | ||
20 | #include <linux/mbus.h> | ||
21 | #include <linux/slab.h> | ||
22 | #include <linux/delay.h> | ||
23 | #include <linux/interrupt.h> | ||
24 | #include <linux/platform_device.h> | ||
25 | #include <linux/of_address.h> | ||
26 | #include <linux/of_pci.h> | ||
27 | #include <linux/of_irq.h> | ||
28 | #include <linux/of_platform.h> | ||
29 | #include <linux/phy/phy.h> | ||
30 | |||
31 | #include "pcie-iproc.h" | ||
32 | |||
33 | #define CLK_CONTROL_OFFSET 0x000 | ||
34 | #define EP_MODE_SURVIVE_PERST_SHIFT 1 | ||
35 | #define EP_MODE_SURVIVE_PERST BIT(EP_MODE_SURVIVE_PERST_SHIFT) | ||
36 | #define RC_PCIE_RST_OUTPUT_SHIFT 0 | ||
37 | #define RC_PCIE_RST_OUTPUT BIT(RC_PCIE_RST_OUTPUT_SHIFT) | ||
38 | |||
39 | #define CFG_IND_ADDR_OFFSET 0x120 | ||
40 | #define CFG_IND_ADDR_MASK 0x00001ffc | ||
41 | |||
42 | #define CFG_IND_DATA_OFFSET 0x124 | ||
43 | |||
44 | #define CFG_ADDR_OFFSET 0x1f8 | ||
45 | #define CFG_ADDR_BUS_NUM_SHIFT 20 | ||
46 | #define CFG_ADDR_BUS_NUM_MASK 0x0ff00000 | ||
47 | #define CFG_ADDR_DEV_NUM_SHIFT 15 | ||
48 | #define CFG_ADDR_DEV_NUM_MASK 0x000f8000 | ||
49 | #define CFG_ADDR_FUNC_NUM_SHIFT 12 | ||
50 | #define CFG_ADDR_FUNC_NUM_MASK 0x00007000 | ||
51 | #define CFG_ADDR_REG_NUM_SHIFT 2 | ||
52 | #define CFG_ADDR_REG_NUM_MASK 0x00000ffc | ||
53 | #define CFG_ADDR_CFG_TYPE_SHIFT 0 | ||
54 | #define CFG_ADDR_CFG_TYPE_MASK 0x00000003 | ||
55 | |||
56 | #define CFG_DATA_OFFSET 0x1fc | ||
57 | |||
58 | #define SYS_RC_INTX_EN 0x330 | ||
59 | #define SYS_RC_INTX_MASK 0xf | ||
60 | |||
61 | static inline struct iproc_pcie *sys_to_pcie(struct pci_sys_data *sys) | ||
62 | { | ||
63 | return sys->private_data; | ||
64 | } | ||
65 | |||
66 | /** | ||
67 | * Note access to the configuration registers are protected at the higher layer | ||
68 | * by 'pci_lock' in drivers/pci/access.c | ||
69 | */ | ||
70 | static void __iomem *iproc_pcie_map_cfg_bus(struct pci_bus *bus, | ||
71 | unsigned int devfn, | ||
72 | int where) | ||
73 | { | ||
74 | struct pci_sys_data *sys = bus->sysdata; | ||
75 | struct iproc_pcie *pcie = sys_to_pcie(sys); | ||
76 | unsigned slot = PCI_SLOT(devfn); | ||
77 | unsigned fn = PCI_FUNC(devfn); | ||
78 | unsigned busno = bus->number; | ||
79 | u32 val; | ||
80 | |||
81 | /* root complex access */ | ||
82 | if (busno == 0) { | ||
83 | if (slot >= 1) | ||
84 | return NULL; | ||
85 | writel(where & CFG_IND_ADDR_MASK, | ||
86 | pcie->base + CFG_IND_ADDR_OFFSET); | ||
87 | return (pcie->base + CFG_IND_DATA_OFFSET); | ||
88 | } | ||
89 | |||
90 | if (fn > 1) | ||
91 | return NULL; | ||
92 | |||
93 | /* EP device access */ | ||
94 | val = (busno << CFG_ADDR_BUS_NUM_SHIFT) | | ||
95 | (slot << CFG_ADDR_DEV_NUM_SHIFT) | | ||
96 | (fn << CFG_ADDR_FUNC_NUM_SHIFT) | | ||
97 | (where & CFG_ADDR_REG_NUM_MASK) | | ||
98 | (1 & CFG_ADDR_CFG_TYPE_MASK); | ||
99 | writel(val, pcie->base + CFG_ADDR_OFFSET); | ||
100 | |||
101 | return (pcie->base + CFG_DATA_OFFSET); | ||
102 | } | ||
103 | |||
104 | static struct pci_ops iproc_pcie_ops = { | ||
105 | .map_bus = iproc_pcie_map_cfg_bus, | ||
106 | .read = pci_generic_config_read32, | ||
107 | .write = pci_generic_config_write32, | ||
108 | }; | ||
109 | |||
110 | static void iproc_pcie_reset(struct iproc_pcie *pcie) | ||
111 | { | ||
112 | u32 val; | ||
113 | |||
114 | /* | ||
115 | * Configure the PCIe controller as root complex and send a downstream | ||
116 | * reset | ||
117 | */ | ||
118 | val = EP_MODE_SURVIVE_PERST | RC_PCIE_RST_OUTPUT; | ||
119 | writel(val, pcie->base + CLK_CONTROL_OFFSET); | ||
120 | udelay(250); | ||
121 | val &= ~EP_MODE_SURVIVE_PERST; | ||
122 | writel(val, pcie->base + CLK_CONTROL_OFFSET); | ||
123 | msleep(250); | ||
124 | } | ||
125 | |||
126 | static int iproc_pcie_check_link(struct iproc_pcie *pcie, struct pci_bus *bus) | ||
127 | { | ||
128 | u8 hdr_type; | ||
129 | u32 link_ctrl; | ||
130 | u16 pos, link_status; | ||
131 | int link_is_active = 0; | ||
132 | |||
133 | /* make sure we are not in EP mode */ | ||
134 | pci_bus_read_config_byte(bus, 0, PCI_HEADER_TYPE, &hdr_type); | ||
135 | if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) { | ||
136 | dev_err(pcie->dev, "in EP mode, hdr=%#02x\n", hdr_type); | ||
137 | return -EFAULT; | ||
138 | } | ||
139 | |||
140 | /* force class to PCI_CLASS_BRIDGE_PCI (0x0604) */ | ||
141 | pci_bus_write_config_word(bus, 0, PCI_CLASS_DEVICE, | ||
142 | PCI_CLASS_BRIDGE_PCI); | ||
143 | |||
144 | /* check link status to see if link is active */ | ||
145 | pos = pci_bus_find_capability(bus, 0, PCI_CAP_ID_EXP); | ||
146 | pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, &link_status); | ||
147 | if (link_status & PCI_EXP_LNKSTA_NLW) | ||
148 | link_is_active = 1; | ||
149 | |||
150 | if (!link_is_active) { | ||
151 | /* try GEN 1 link speed */ | ||
152 | #define PCI_LINK_STATUS_CTRL_2_OFFSET 0x0dc | ||
153 | #define PCI_TARGET_LINK_SPEED_MASK 0xf | ||
154 | #define PCI_TARGET_LINK_SPEED_GEN2 0x2 | ||
155 | #define PCI_TARGET_LINK_SPEED_GEN1 0x1 | ||
156 | pci_bus_read_config_dword(bus, 0, | ||
157 | PCI_LINK_STATUS_CTRL_2_OFFSET, | ||
158 | &link_ctrl); | ||
159 | if ((link_ctrl & PCI_TARGET_LINK_SPEED_MASK) == | ||
160 | PCI_TARGET_LINK_SPEED_GEN2) { | ||
161 | link_ctrl &= ~PCI_TARGET_LINK_SPEED_MASK; | ||
162 | link_ctrl |= PCI_TARGET_LINK_SPEED_GEN1; | ||
163 | pci_bus_write_config_dword(bus, 0, | ||
164 | PCI_LINK_STATUS_CTRL_2_OFFSET, | ||
165 | link_ctrl); | ||
166 | msleep(100); | ||
167 | |||
168 | pos = pci_bus_find_capability(bus, 0, PCI_CAP_ID_EXP); | ||
169 | pci_bus_read_config_word(bus, 0, pos + PCI_EXP_LNKSTA, | ||
170 | &link_status); | ||
171 | if (link_status & PCI_EXP_LNKSTA_NLW) | ||
172 | link_is_active = 1; | ||
173 | } | ||
174 | } | ||
175 | |||
176 | dev_info(pcie->dev, "link: %s\n", link_is_active ? "UP" : "DOWN"); | ||
177 | |||
178 | return link_is_active ? 0 : -ENODEV; | ||
179 | } | ||
180 | |||
181 | static void iproc_pcie_enable(struct iproc_pcie *pcie) | ||
182 | { | ||
183 | writel(SYS_RC_INTX_MASK, pcie->base + SYS_RC_INTX_EN); | ||
184 | } | ||
185 | |||
186 | int iproc_pcie_setup(struct iproc_pcie *pcie) | ||
187 | { | ||
188 | int ret; | ||
189 | struct pci_bus *bus; | ||
190 | |||
191 | if (!pcie || !pcie->dev || !pcie->base) | ||
192 | return -EINVAL; | ||
193 | |||
194 | if (pcie->phy) { | ||
195 | ret = phy_init(pcie->phy); | ||
196 | if (ret) { | ||
197 | dev_err(pcie->dev, "unable to initialize PCIe PHY\n"); | ||
198 | return ret; | ||
199 | } | ||
200 | |||
201 | ret = phy_power_on(pcie->phy); | ||
202 | if (ret) { | ||
203 | dev_err(pcie->dev, "unable to power on PCIe PHY\n"); | ||
204 | goto err_exit_phy; | ||
205 | } | ||
206 | |||
207 | } | ||
208 | |||
209 | iproc_pcie_reset(pcie); | ||
210 | |||
211 | pcie->sysdata.private_data = pcie; | ||
212 | |||
213 | bus = pci_create_root_bus(pcie->dev, 0, &iproc_pcie_ops, | ||
214 | &pcie->sysdata, pcie->resources); | ||
215 | if (!bus) { | ||
216 | dev_err(pcie->dev, "unable to create PCI root bus\n"); | ||
217 | ret = -ENOMEM; | ||
218 | goto err_power_off_phy; | ||
219 | } | ||
220 | pcie->root_bus = bus; | ||
221 | |||
222 | ret = iproc_pcie_check_link(pcie, bus); | ||
223 | if (ret) { | ||
224 | dev_err(pcie->dev, "no PCIe EP device detected\n"); | ||
225 | goto err_rm_root_bus; | ||
226 | } | ||
227 | |||
228 | iproc_pcie_enable(pcie); | ||
229 | |||
230 | pci_scan_child_bus(bus); | ||
231 | pci_assign_unassigned_bus_resources(bus); | ||
232 | pci_fixup_irqs(pci_common_swizzle, of_irq_parse_and_map_pci); | ||
233 | pci_bus_add_devices(bus); | ||
234 | |||
235 | return 0; | ||
236 | |||
237 | err_rm_root_bus: | ||
238 | pci_stop_root_bus(bus); | ||
239 | pci_remove_root_bus(bus); | ||
240 | |||
241 | err_power_off_phy: | ||
242 | if (pcie->phy) | ||
243 | phy_power_off(pcie->phy); | ||
244 | err_exit_phy: | ||
245 | if (pcie->phy) | ||
246 | phy_exit(pcie->phy); | ||
247 | |||
248 | return ret; | ||
249 | } | ||
250 | EXPORT_SYMBOL(iproc_pcie_setup); | ||
251 | |||
252 | int iproc_pcie_remove(struct iproc_pcie *pcie) | ||
253 | { | ||
254 | pci_stop_root_bus(pcie->root_bus); | ||
255 | pci_remove_root_bus(pcie->root_bus); | ||
256 | |||
257 | if (pcie->phy) { | ||
258 | phy_power_off(pcie->phy); | ||
259 | phy_exit(pcie->phy); | ||
260 | } | ||
261 | |||
262 | return 0; | ||
263 | } | ||
264 | EXPORT_SYMBOL(iproc_pcie_remove); | ||
265 | |||
266 | MODULE_AUTHOR("Ray Jui <rjui@broadcom.com>"); | ||
267 | MODULE_DESCRIPTION("Broadcom iPROC PCIe common driver"); | ||
268 | MODULE_LICENSE("GPL v2"); | ||
diff --git a/drivers/pci/host/pcie-iproc.h b/drivers/pci/host/pcie-iproc.h new file mode 100644 index 000000000000..e28075ed1856 --- /dev/null +++ b/drivers/pci/host/pcie-iproc.h | |||
@@ -0,0 +1,42 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014-2015 Broadcom Corporation | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or | ||
5 | * modify it under the terms of the GNU General Public License as | ||
6 | * published by the Free Software Foundation version 2. | ||
7 | * | ||
8 | * This program is distributed "as is" WITHOUT ANY WARRANTY of any | ||
9 | * kind, whether express or implied; without even the implied warranty | ||
10 | * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
11 | * GNU General Public License for more details. | ||
12 | */ | ||
13 | |||
14 | #ifndef _PCIE_IPROC_H | ||
15 | #define _PCIE_IPROC_H | ||
16 | |||
17 | #define IPROC_PCIE_MAX_NUM_IRQS 6 | ||
18 | |||
19 | /** | ||
20 | * iProc PCIe device | ||
21 | * @dev: pointer to device data structure | ||
22 | * @base: PCIe host controller I/O register base | ||
23 | * @resources: linked list of all PCI resources | ||
24 | * @sysdata: Per PCI controller data | ||
25 | * @root_bus: pointer to root bus | ||
26 | * @phy: optional PHY device that controls the Serdes | ||
27 | * @irqs: interrupt IDs | ||
28 | */ | ||
29 | struct iproc_pcie { | ||
30 | struct device *dev; | ||
31 | void __iomem *base; | ||
32 | struct list_head *resources; | ||
33 | struct pci_sys_data sysdata; | ||
34 | struct pci_bus *root_bus; | ||
35 | struct phy *phy; | ||
36 | int irqs[IPROC_PCIE_MAX_NUM_IRQS]; | ||
37 | }; | ||
38 | |||
39 | int iproc_pcie_setup(struct iproc_pcie *pcie); | ||
40 | int iproc_pcie_remove(struct iproc_pcie *pcie); | ||
41 | |||
42 | #endif /* _PCIE_IPROC_H */ | ||
diff --git a/drivers/pci/host/pcie-rcar.c b/drivers/pci/host/pcie-rcar.c index c57bd0ac39a0..c086210f2ffd 100644 --- a/drivers/pci/host/pcie-rcar.c +++ b/drivers/pci/host/pcie-rcar.c | |||
@@ -64,8 +64,8 @@ | |||
64 | #define LAR_ENABLE (1 << 1) | 64 | #define LAR_ENABLE (1 << 1) |
65 | 65 | ||
66 | /* PCIe address reg & mask */ | 66 | /* PCIe address reg & mask */ |
67 | #define PCIEPARL(x) (0x03400 + ((x) * 0x20)) | 67 | #define PCIEPALR(x) (0x03400 + ((x) * 0x20)) |
68 | #define PCIEPARH(x) (0x03404 + ((x) * 0x20)) | 68 | #define PCIEPAUR(x) (0x03404 + ((x) * 0x20)) |
69 | #define PCIEPAMR(x) (0x03408 + ((x) * 0x20)) | 69 | #define PCIEPAMR(x) (0x03408 + ((x) * 0x20)) |
70 | #define PCIEPTCTLR(x) (0x0340c + ((x) * 0x20)) | 70 | #define PCIEPTCTLR(x) (0x0340c + ((x) * 0x20)) |
71 | #define PAR_ENABLE (1 << 31) | 71 | #define PAR_ENABLE (1 << 31) |
@@ -341,8 +341,9 @@ static void rcar_pcie_setup_window(int win, struct rcar_pcie *pcie) | |||
341 | else | 341 | else |
342 | res_start = res->start; | 342 | res_start = res->start; |
343 | 343 | ||
344 | rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPARH(win)); | 344 | rcar_pci_write_reg(pcie, upper_32_bits(res_start), PCIEPAUR(win)); |
345 | rcar_pci_write_reg(pcie, lower_32_bits(res_start), PCIEPARL(win)); | 345 | rcar_pci_write_reg(pcie, lower_32_bits(res_start) & ~0x7F, |
346 | PCIEPALR(win)); | ||
346 | 347 | ||
347 | /* First resource is for IO */ | 348 | /* First resource is for IO */ |
348 | mask = PAR_ENABLE; | 349 | mask = PAR_ENABLE; |
@@ -501,7 +502,7 @@ static int rcar_pcie_hw_init(struct rcar_pcie *pcie) | |||
501 | 502 | ||
502 | /* Enable MSI */ | 503 | /* Enable MSI */ |
503 | if (IS_ENABLED(CONFIG_PCI_MSI)) | 504 | if (IS_ENABLED(CONFIG_PCI_MSI)) |
504 | rcar_pci_write_reg(pcie, 0x101f0000, PCIEMSITXR); | 505 | rcar_pci_write_reg(pcie, 0x801f0000, PCIEMSITXR); |
505 | 506 | ||
506 | /* Finish initialization - establish a PCI Express link */ | 507 | /* Finish initialization - establish a PCI Express link */ |
507 | rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); | 508 | rcar_pci_write_reg(pcie, CFINIT, PCIETCTLR); |
diff --git a/drivers/pci/hotplug/ibmphp_core.c b/drivers/pci/hotplug/ibmphp_core.c index 96c5c729cdbc..15302475f5b7 100644 --- a/drivers/pci/hotplug/ibmphp_core.c +++ b/drivers/pci/hotplug/ibmphp_core.c | |||
@@ -738,7 +738,7 @@ static void ibm_unconfigure_device(struct pci_func *func) | |||
738 | */ | 738 | */ |
739 | static u8 bus_structure_fixup(u8 busno) | 739 | static u8 bus_structure_fixup(u8 busno) |
740 | { | 740 | { |
741 | struct pci_bus *bus; | 741 | struct pci_bus *bus, *b; |
742 | struct pci_dev *dev; | 742 | struct pci_dev *dev; |
743 | u16 l; | 743 | u16 l; |
744 | 744 | ||
@@ -765,7 +765,11 @@ static u8 bus_structure_fixup(u8 busno) | |||
765 | (l != 0x0000) && (l != 0xffff)) { | 765 | (l != 0x0000) && (l != 0xffff)) { |
766 | debug("%s - Inside bus_structure_fixup()\n", | 766 | debug("%s - Inside bus_structure_fixup()\n", |
767 | __func__); | 767 | __func__); |
768 | pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL); | 768 | b = pci_scan_bus(busno, ibmphp_pci_bus->ops, NULL); |
769 | if (!b) | ||
770 | continue; | ||
771 | |||
772 | pci_bus_add_devices(b); | ||
769 | break; | 773 | break; |
770 | } | 774 | } |
771 | } | 775 | } |
diff --git a/drivers/pci/pci-acpi.c b/drivers/pci/pci-acpi.c index c93fbe76d281..6f6f175f51f7 100644 --- a/drivers/pci/pci-acpi.c +++ b/drivers/pci/pci-acpi.c | |||
@@ -18,6 +18,15 @@ | |||
18 | #include <linux/pm_qos.h> | 18 | #include <linux/pm_qos.h> |
19 | #include "pci.h" | 19 | #include "pci.h" |
20 | 20 | ||
21 | /* | ||
22 | * The UUID is defined in the PCI Firmware Specification available here: | ||
23 | * https://www.pcisig.com/members/downloads/pcifw_r3_1_13Dec10.pdf | ||
24 | */ | ||
25 | const u8 pci_acpi_dsm_uuid[] = { | ||
26 | 0xd0, 0x37, 0xc9, 0xe5, 0x53, 0x35, 0x7a, 0x4d, | ||
27 | 0x91, 0x17, 0xea, 0x4d, 0x19, 0xc3, 0x43, 0x4d | ||
28 | }; | ||
29 | |||
21 | phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) | 30 | phys_addr_t acpi_pci_root_get_mcfg_addr(acpi_handle handle) |
22 | { | 31 | { |
23 | acpi_status status = AE_NOT_EXIST; | 32 | acpi_status status = AE_NOT_EXIST; |
@@ -531,11 +540,32 @@ static struct pci_platform_pm_ops acpi_pci_platform_pm = { | |||
531 | 540 | ||
532 | void acpi_pci_add_bus(struct pci_bus *bus) | 541 | void acpi_pci_add_bus(struct pci_bus *bus) |
533 | { | 542 | { |
543 | union acpi_object *obj; | ||
544 | struct pci_host_bridge *bridge; | ||
545 | |||
534 | if (acpi_pci_disabled || !bus->bridge) | 546 | if (acpi_pci_disabled || !bus->bridge) |
535 | return; | 547 | return; |
536 | 548 | ||
537 | acpi_pci_slot_enumerate(bus); | 549 | acpi_pci_slot_enumerate(bus); |
538 | acpiphp_enumerate_slots(bus); | 550 | acpiphp_enumerate_slots(bus); |
551 | |||
552 | /* | ||
553 | * For a host bridge, check its _DSM for function 8 and if | ||
554 | * that is available, mark it in pci_host_bridge. | ||
555 | */ | ||
556 | if (!pci_is_root_bus(bus)) | ||
557 | return; | ||
558 | |||
559 | obj = acpi_evaluate_dsm(ACPI_HANDLE(bus->bridge), pci_acpi_dsm_uuid, 3, | ||
560 | RESET_DELAY_DSM, NULL); | ||
561 | if (!obj) | ||
562 | return; | ||
563 | |||
564 | if (obj->type == ACPI_TYPE_INTEGER && obj->integer.value == 1) { | ||
565 | bridge = pci_find_host_bridge(bus); | ||
566 | bridge->ignore_reset_delay = 1; | ||
567 | } | ||
568 | ACPI_FREE(obj); | ||
539 | } | 569 | } |
540 | 570 | ||
541 | void acpi_pci_remove_bus(struct pci_bus *bus) | 571 | void acpi_pci_remove_bus(struct pci_bus *bus) |
@@ -561,6 +591,57 @@ static struct acpi_device *acpi_pci_find_companion(struct device *dev) | |||
561 | check_children); | 591 | check_children); |
562 | } | 592 | } |
563 | 593 | ||
594 | /** | ||
595 | * pci_acpi_optimize_delay - optimize PCI D3 and D3cold delay from ACPI | ||
596 | * @pdev: the PCI device whose delay is to be updated | ||
597 | * @adev: the companion ACPI device of this PCI device | ||
598 | * | ||
599 | * Update the d3_delay and d3cold_delay of a PCI device from the ACPI _DSM | ||
600 | * control method of either the device itself or the PCI host bridge. | ||
601 | * | ||
602 | * Function 8, "Reset Delay," applies to the entire hierarchy below a PCI | ||
603 | * host bridge. If it returns one, the OS may assume that all devices in | ||
604 | * the hierarchy have already completed power-on reset delays. | ||
605 | * | ||
606 | * Function 9, "Device Readiness Durations," applies only to the object | ||
607 | * where it is located. It returns delay durations required after various | ||
608 | * events if the device requires less time than the spec requires. Delays | ||
609 | * from this function take precedence over the Reset Delay function. | ||
610 | * | ||
611 | * These _DSM functions are defined by the draft ECN of January 28, 2014, | ||
612 | * titled "ACPI additions for FW latency optimizations." | ||
613 | */ | ||
614 | static void pci_acpi_optimize_delay(struct pci_dev *pdev, | ||
615 | acpi_handle handle) | ||
616 | { | ||
617 | struct pci_host_bridge *bridge = pci_find_host_bridge(pdev->bus); | ||
618 | int value; | ||
619 | union acpi_object *obj, *elements; | ||
620 | |||
621 | if (bridge->ignore_reset_delay) | ||
622 | pdev->d3cold_delay = 0; | ||
623 | |||
624 | obj = acpi_evaluate_dsm(handle, pci_acpi_dsm_uuid, 3, | ||
625 | FUNCTION_DELAY_DSM, NULL); | ||
626 | if (!obj) | ||
627 | return; | ||
628 | |||
629 | if (obj->type == ACPI_TYPE_PACKAGE && obj->package.count == 5) { | ||
630 | elements = obj->package.elements; | ||
631 | if (elements[0].type == ACPI_TYPE_INTEGER) { | ||
632 | value = (int)elements[0].integer.value / 1000; | ||
633 | if (value < PCI_PM_D3COLD_WAIT) | ||
634 | pdev->d3cold_delay = value; | ||
635 | } | ||
636 | if (elements[3].type == ACPI_TYPE_INTEGER) { | ||
637 | value = (int)elements[3].integer.value / 1000; | ||
638 | if (value < PCI_PM_D3_WAIT) | ||
639 | pdev->d3_delay = value; | ||
640 | } | ||
641 | } | ||
642 | ACPI_FREE(obj); | ||
643 | } | ||
644 | |||
564 | static void pci_acpi_setup(struct device *dev) | 645 | static void pci_acpi_setup(struct device *dev) |
565 | { | 646 | { |
566 | struct pci_dev *pci_dev = to_pci_dev(dev); | 647 | struct pci_dev *pci_dev = to_pci_dev(dev); |
@@ -569,6 +650,8 @@ static void pci_acpi_setup(struct device *dev) | |||
569 | if (!adev) | 650 | if (!adev) |
570 | return; | 651 | return; |
571 | 652 | ||
653 | pci_acpi_optimize_delay(pci_dev, adev->handle); | ||
654 | |||
572 | pci_acpi_add_pm_notifier(adev, pci_dev); | 655 | pci_acpi_add_pm_notifier(adev, pci_dev); |
573 | if (!adev->wakeup.flags.valid) | 656 | if (!adev->wakeup.flags.valid) |
574 | return; | 657 | return; |
diff --git a/drivers/pci/pci-label.c b/drivers/pci/pci-label.c index 2ab1b47c7651..024b5c179348 100644 --- a/drivers/pci/pci-label.c +++ b/drivers/pci/pci-label.c | |||
@@ -31,8 +31,6 @@ | |||
31 | #include <linux/pci-acpi.h> | 31 | #include <linux/pci-acpi.h> |
32 | #include "pci.h" | 32 | #include "pci.h" |
33 | 33 | ||
34 | #define DEVICE_LABEL_DSM 0x07 | ||
35 | |||
36 | #ifdef CONFIG_DMI | 34 | #ifdef CONFIG_DMI |
37 | enum smbios_attr_enum { | 35 | enum smbios_attr_enum { |
38 | SMBIOS_ATTR_NONE = 0, | 36 | SMBIOS_ATTR_NONE = 0, |
@@ -148,11 +146,6 @@ static inline void pci_remove_smbiosname_file(struct pci_dev *pdev) | |||
148 | #endif | 146 | #endif |
149 | 147 | ||
150 | #ifdef CONFIG_ACPI | 148 | #ifdef CONFIG_ACPI |
151 | static const char device_label_dsm_uuid[] = { | ||
152 | 0xD0, 0x37, 0xC9, 0xE5, 0x53, 0x35, 0x7A, 0x4D, | ||
153 | 0x91, 0x17, 0xEA, 0x4D, 0x19, 0xC3, 0x43, 0x4D | ||
154 | }; | ||
155 | |||
156 | enum acpi_attr_enum { | 149 | enum acpi_attr_enum { |
157 | ACPI_ATTR_LABEL_SHOW, | 150 | ACPI_ATTR_LABEL_SHOW, |
158 | ACPI_ATTR_INDEX_SHOW, | 151 | ACPI_ATTR_INDEX_SHOW, |
@@ -179,7 +172,7 @@ static int dsm_get_label(struct device *dev, char *buf, | |||
179 | if (!handle) | 172 | if (!handle) |
180 | return -1; | 173 | return -1; |
181 | 174 | ||
182 | obj = acpi_evaluate_dsm(handle, device_label_dsm_uuid, 0x2, | 175 | obj = acpi_evaluate_dsm(handle, pci_acpi_dsm_uuid, 0x2, |
183 | DEVICE_LABEL_DSM, NULL); | 176 | DEVICE_LABEL_DSM, NULL); |
184 | if (!obj) | 177 | if (!obj) |
185 | return -1; | 178 | return -1; |
@@ -219,7 +212,7 @@ static bool device_has_dsm(struct device *dev) | |||
219 | if (!handle) | 212 | if (!handle) |
220 | return false; | 213 | return false; |
221 | 214 | ||
222 | return !!acpi_check_dsm(handle, device_label_dsm_uuid, 0x2, | 215 | return !!acpi_check_dsm(handle, pci_acpi_dsm_uuid, 0x2, |
223 | 1 << DEVICE_LABEL_DSM); | 216 | 1 << DEVICE_LABEL_DSM); |
224 | } | 217 | } |
225 | 218 | ||
diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 81f06e8dcc04..acc4b6ef78c4 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c | |||
@@ -126,15 +126,16 @@ EXPORT_SYMBOL_GPL(pci_bus_max_busnr); | |||
126 | #ifdef CONFIG_HAS_IOMEM | 126 | #ifdef CONFIG_HAS_IOMEM |
127 | void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) | 127 | void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar) |
128 | { | 128 | { |
129 | struct resource *res = &pdev->resource[bar]; | ||
130 | |||
129 | /* | 131 | /* |
130 | * Make sure the BAR is actually a memory resource, not an IO resource | 132 | * Make sure the BAR is actually a memory resource, not an IO resource |
131 | */ | 133 | */ |
132 | if (!(pci_resource_flags(pdev, bar) & IORESOURCE_MEM)) { | 134 | if (res->flags & IORESOURCE_UNSET || !(res->flags & IORESOURCE_MEM)) { |
133 | WARN_ON(1); | 135 | dev_warn(&pdev->dev, "can't ioremap BAR %d: %pR\n", bar, res); |
134 | return NULL; | 136 | return NULL; |
135 | } | 137 | } |
136 | return ioremap_nocache(pci_resource_start(pdev, bar), | 138 | return ioremap_nocache(res->start, resource_size(res)); |
137 | pci_resource_len(pdev, bar)); | ||
138 | } | 139 | } |
139 | EXPORT_SYMBOL_GPL(pci_ioremap_bar); | 140 | EXPORT_SYMBOL_GPL(pci_ioremap_bar); |
140 | #endif | 141 | #endif |
@@ -145,19 +146,22 @@ static int __pci_find_next_cap_ttl(struct pci_bus *bus, unsigned int devfn, | |||
145 | u8 pos, int cap, int *ttl) | 146 | u8 pos, int cap, int *ttl) |
146 | { | 147 | { |
147 | u8 id; | 148 | u8 id; |
149 | u16 ent; | ||
150 | |||
151 | pci_bus_read_config_byte(bus, devfn, pos, &pos); | ||
148 | 152 | ||
149 | while ((*ttl)--) { | 153 | while ((*ttl)--) { |
150 | pci_bus_read_config_byte(bus, devfn, pos, &pos); | ||
151 | if (pos < 0x40) | 154 | if (pos < 0x40) |
152 | break; | 155 | break; |
153 | pos &= ~3; | 156 | pos &= ~3; |
154 | pci_bus_read_config_byte(bus, devfn, pos + PCI_CAP_LIST_ID, | 157 | pci_bus_read_config_word(bus, devfn, pos, &ent); |
155 | &id); | 158 | |
159 | id = ent & 0xff; | ||
156 | if (id == 0xff) | 160 | if (id == 0xff) |
157 | break; | 161 | break; |
158 | if (id == cap) | 162 | if (id == cap) |
159 | return pos; | 163 | return pos; |
160 | pos += PCI_CAP_LIST_NEXT; | 164 | pos = (ent >> 8); |
161 | } | 165 | } |
162 | return 0; | 166 | return 0; |
163 | } | 167 | } |
@@ -2492,6 +2496,7 @@ u8 pci_common_swizzle(struct pci_dev *dev, u8 *pinp) | |||
2492 | *pinp = pin; | 2496 | *pinp = pin; |
2493 | return PCI_SLOT(dev->devfn); | 2497 | return PCI_SLOT(dev->devfn); |
2494 | } | 2498 | } |
2499 | EXPORT_SYMBOL_GPL(pci_common_swizzle); | ||
2495 | 2500 | ||
2496 | /** | 2501 | /** |
2497 | * pci_release_region - Release a PCI bar | 2502 | * pci_release_region - Release a PCI bar |
diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 4091f82239cd..d72f849174a4 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h | |||
@@ -321,4 +321,6 @@ static inline int pci_dev_specific_reset(struct pci_dev *dev, int probe) | |||
321 | } | 321 | } |
322 | #endif | 322 | #endif |
323 | 323 | ||
324 | struct pci_host_bridge *pci_find_host_bridge(struct pci_bus *bus); | ||
325 | |||
324 | #endif /* DRIVERS_PCI_H */ | 326 | #endif /* DRIVERS_PCI_H */ |
diff --git a/drivers/pci/pcie/aspm.c b/drivers/pci/pcie/aspm.c index 820740a22e94..7d4fcdc512aa 100644 --- a/drivers/pci/pcie/aspm.c +++ b/drivers/pci/pcie/aspm.c | |||
@@ -782,24 +782,6 @@ void pci_disable_link_state(struct pci_dev *pdev, int state) | |||
782 | } | 782 | } |
783 | EXPORT_SYMBOL(pci_disable_link_state); | 783 | EXPORT_SYMBOL(pci_disable_link_state); |
784 | 784 | ||
785 | void pcie_clear_aspm(struct pci_bus *bus) | ||
786 | { | ||
787 | struct pci_dev *child; | ||
788 | |||
789 | if (aspm_force) | ||
790 | return; | ||
791 | |||
792 | /* | ||
793 | * Clear any ASPM setup that the firmware has carried out on this bus | ||
794 | */ | ||
795 | list_for_each_entry(child, &bus->devices, bus_list) { | ||
796 | __pci_disable_link_state(child, PCIE_LINK_STATE_L0S | | ||
797 | PCIE_LINK_STATE_L1 | | ||
798 | PCIE_LINK_STATE_CLKPM, | ||
799 | false, true); | ||
800 | } | ||
801 | } | ||
802 | |||
803 | static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp) | 785 | static int pcie_aspm_set_policy(const char *val, struct kernel_param *kp) |
804 | { | 786 | { |
805 | int i; | 787 | int i; |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 8d2f400e96cb..6675a7a1b9fc 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -6,6 +6,7 @@ | |||
6 | #include <linux/delay.h> | 6 | #include <linux/delay.h> |
7 | #include <linux/init.h> | 7 | #include <linux/init.h> |
8 | #include <linux/pci.h> | 8 | #include <linux/pci.h> |
9 | #include <linux/of_pci.h> | ||
9 | #include <linux/pci_hotplug.h> | 10 | #include <linux/pci_hotplug.h> |
10 | #include <linux/slab.h> | 11 | #include <linux/slab.h> |
11 | #include <linux/module.h> | 12 | #include <linux/module.h> |
@@ -1520,6 +1521,7 @@ void pci_device_add(struct pci_dev *dev, struct pci_bus *bus) | |||
1520 | dev->dev.dma_mask = &dev->dma_mask; | 1521 | dev->dev.dma_mask = &dev->dma_mask; |
1521 | dev->dev.dma_parms = &dev->dma_parms; | 1522 | dev->dev.dma_parms = &dev->dma_parms; |
1522 | dev->dev.coherent_dma_mask = 0xffffffffull; | 1523 | dev->dev.coherent_dma_mask = 0xffffffffull; |
1524 | of_pci_dma_configure(dev); | ||
1523 | 1525 | ||
1524 | pci_set_dma_max_seg_size(dev, 65536); | 1526 | pci_set_dma_max_seg_size(dev, 65536); |
1525 | pci_set_dma_seg_boundary(dev, 0xffffffff); | 1527 | pci_set_dma_seg_boundary(dev, 0xffffffff); |
@@ -1993,6 +1995,7 @@ err_out: | |||
1993 | kfree(b); | 1995 | kfree(b); |
1994 | return NULL; | 1996 | return NULL; |
1995 | } | 1997 | } |
1998 | EXPORT_SYMBOL_GPL(pci_create_root_bus); | ||
1996 | 1999 | ||
1997 | int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) | 2000 | int pci_bus_insert_busn_res(struct pci_bus *b, int bus, int bus_max) |
1998 | { | 2001 | { |
@@ -2087,7 +2090,6 @@ struct pci_bus *pci_scan_root_bus(struct device *parent, int bus, | |||
2087 | if (!found) | 2090 | if (!found) |
2088 | pci_bus_update_busn_res_end(b, max); | 2091 | pci_bus_update_busn_res_end(b, max); |
2089 | 2092 | ||
2090 | pci_bus_add_devices(b); | ||
2091 | return b; | 2093 | return b; |
2092 | } | 2094 | } |
2093 | EXPORT_SYMBOL(pci_scan_root_bus); | 2095 | EXPORT_SYMBOL(pci_scan_root_bus); |
@@ -2123,7 +2125,6 @@ struct pci_bus *pci_scan_bus(int bus, struct pci_ops *ops, | |||
2123 | b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources); | 2125 | b = pci_create_root_bus(NULL, bus, ops, sysdata, &resources); |
2124 | if (b) { | 2126 | if (b) { |
2125 | pci_scan_child_bus(b); | 2127 | pci_scan_child_bus(b); |
2126 | pci_bus_add_devices(b); | ||
2127 | } else { | 2128 | } else { |
2128 | pci_free_resource_list(&resources); | 2129 | pci_free_resource_list(&resources); |
2129 | } | 2130 | } |
diff --git a/drivers/pci/quirks.c b/drivers/pci/quirks.c index 85f247e28a80..c6dc1dfd25d5 100644 --- a/drivers/pci/quirks.c +++ b/drivers/pci/quirks.c | |||
@@ -3182,7 +3182,7 @@ static void quirk_apple_wait_for_thunderbolt(struct pci_dev *dev) | |||
3182 | || nhi->subsystem_vendor != 0x2222 | 3182 | || nhi->subsystem_vendor != 0x2222 |
3183 | || nhi->subsystem_device != 0x1111) | 3183 | || nhi->subsystem_device != 0x1111) |
3184 | goto out; | 3184 | goto out; |
3185 | dev_info(&dev->dev, "quirk: wating for thunderbolt to reestablish pci tunnels...\n"); | 3185 | dev_info(&dev->dev, "quirk: waiting for thunderbolt to reestablish PCI tunnels...\n"); |
3186 | device_pm_wait_for_dev(&dev->dev, &nhi->dev); | 3186 | device_pm_wait_for_dev(&dev->dev, &nhi->dev); |
3187 | out: | 3187 | out: |
3188 | pci_dev_put(nhi); | 3188 | pci_dev_put(nhi); |
@@ -3822,6 +3822,38 @@ static const struct pci_dev_acs_enabled { | |||
3822 | { PCI_VENDOR_ID_INTEL, 0x154F, pci_quirk_mf_endpoint_acs }, | 3822 | { PCI_VENDOR_ID_INTEL, 0x154F, pci_quirk_mf_endpoint_acs }, |
3823 | { PCI_VENDOR_ID_INTEL, 0x1551, pci_quirk_mf_endpoint_acs }, | 3823 | { PCI_VENDOR_ID_INTEL, 0x1551, pci_quirk_mf_endpoint_acs }, |
3824 | { PCI_VENDOR_ID_INTEL, 0x1558, pci_quirk_mf_endpoint_acs }, | 3824 | { PCI_VENDOR_ID_INTEL, 0x1558, pci_quirk_mf_endpoint_acs }, |
3825 | /* 82580 */ | ||
3826 | { PCI_VENDOR_ID_INTEL, 0x1509, pci_quirk_mf_endpoint_acs }, | ||
3827 | { PCI_VENDOR_ID_INTEL, 0x150E, pci_quirk_mf_endpoint_acs }, | ||
3828 | { PCI_VENDOR_ID_INTEL, 0x150F, pci_quirk_mf_endpoint_acs }, | ||
3829 | { PCI_VENDOR_ID_INTEL, 0x1510, pci_quirk_mf_endpoint_acs }, | ||
3830 | { PCI_VENDOR_ID_INTEL, 0x1511, pci_quirk_mf_endpoint_acs }, | ||
3831 | { PCI_VENDOR_ID_INTEL, 0x1516, pci_quirk_mf_endpoint_acs }, | ||
3832 | { PCI_VENDOR_ID_INTEL, 0x1527, pci_quirk_mf_endpoint_acs }, | ||
3833 | /* 82576 */ | ||
3834 | { PCI_VENDOR_ID_INTEL, 0x10C9, pci_quirk_mf_endpoint_acs }, | ||
3835 | { PCI_VENDOR_ID_INTEL, 0x10E6, pci_quirk_mf_endpoint_acs }, | ||
3836 | { PCI_VENDOR_ID_INTEL, 0x10E7, pci_quirk_mf_endpoint_acs }, | ||
3837 | { PCI_VENDOR_ID_INTEL, 0x10E8, pci_quirk_mf_endpoint_acs }, | ||
3838 | { PCI_VENDOR_ID_INTEL, 0x150A, pci_quirk_mf_endpoint_acs }, | ||
3839 | { PCI_VENDOR_ID_INTEL, 0x150D, pci_quirk_mf_endpoint_acs }, | ||
3840 | { PCI_VENDOR_ID_INTEL, 0x1518, pci_quirk_mf_endpoint_acs }, | ||
3841 | { PCI_VENDOR_ID_INTEL, 0x1526, pci_quirk_mf_endpoint_acs }, | ||
3842 | /* 82575 */ | ||
3843 | { PCI_VENDOR_ID_INTEL, 0x10A7, pci_quirk_mf_endpoint_acs }, | ||
3844 | { PCI_VENDOR_ID_INTEL, 0x10A9, pci_quirk_mf_endpoint_acs }, | ||
3845 | { PCI_VENDOR_ID_INTEL, 0x10D6, pci_quirk_mf_endpoint_acs }, | ||
3846 | /* I350 */ | ||
3847 | { PCI_VENDOR_ID_INTEL, 0x1521, pci_quirk_mf_endpoint_acs }, | ||
3848 | { PCI_VENDOR_ID_INTEL, 0x1522, pci_quirk_mf_endpoint_acs }, | ||
3849 | { PCI_VENDOR_ID_INTEL, 0x1523, pci_quirk_mf_endpoint_acs }, | ||
3850 | { PCI_VENDOR_ID_INTEL, 0x1524, pci_quirk_mf_endpoint_acs }, | ||
3851 | /* 82571 (Quads omitted due to non-ACS switch) */ | ||
3852 | { PCI_VENDOR_ID_INTEL, 0x105E, pci_quirk_mf_endpoint_acs }, | ||
3853 | { PCI_VENDOR_ID_INTEL, 0x105F, pci_quirk_mf_endpoint_acs }, | ||
3854 | { PCI_VENDOR_ID_INTEL, 0x1060, pci_quirk_mf_endpoint_acs }, | ||
3855 | { PCI_VENDOR_ID_INTEL, 0x10D9, pci_quirk_mf_endpoint_acs }, | ||
3856 | /* Intel PCH root ports */ | ||
3825 | { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs }, | 3857 | { PCI_VENDOR_ID_INTEL, PCI_ANY_ID, pci_quirk_intel_pch_acs }, |
3826 | { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */ | 3858 | { 0x19a2, 0x710, pci_quirk_mf_endpoint_acs }, /* Emulex BE3-R */ |
3827 | { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */ | 3859 | { 0x10df, 0x720, pci_quirk_mf_endpoint_acs }, /* Emulex Skyhawk-R */ |
diff --git a/drivers/pci/remove.c b/drivers/pci/remove.c index 8bd76c9ba21c..8a280e9c2ad1 100644 --- a/drivers/pci/remove.c +++ b/drivers/pci/remove.c | |||
@@ -139,6 +139,7 @@ void pci_stop_root_bus(struct pci_bus *bus) | |||
139 | /* stop the host bridge */ | 139 | /* stop the host bridge */ |
140 | device_release_driver(&host_bridge->dev); | 140 | device_release_driver(&host_bridge->dev); |
141 | } | 141 | } |
142 | EXPORT_SYMBOL_GPL(pci_stop_root_bus); | ||
142 | 143 | ||
143 | void pci_remove_root_bus(struct pci_bus *bus) | 144 | void pci_remove_root_bus(struct pci_bus *bus) |
144 | { | 145 | { |
@@ -158,3 +159,4 @@ void pci_remove_root_bus(struct pci_bus *bus) | |||
158 | /* remove the host bridge */ | 159 | /* remove the host bridge */ |
159 | device_unregister(&host_bridge->dev); | 160 | device_unregister(&host_bridge->dev); |
160 | } | 161 | } |
162 | EXPORT_SYMBOL_GPL(pci_remove_root_bus); | ||
diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c index e3e17f3c0f0f..8169597e47cb 100644 --- a/drivers/pci/setup-bus.c +++ b/drivers/pci/setup-bus.c | |||
@@ -1750,3 +1750,4 @@ void pci_assign_unassigned_bus_resources(struct pci_bus *bus) | |||
1750 | __pci_bus_assign_resources(bus, &add_list, NULL); | 1750 | __pci_bus_assign_resources(bus, &add_list, NULL); |
1751 | BUG_ON(!list_empty(&add_list)); | 1751 | BUG_ON(!list_empty(&add_list)); |
1752 | } | 1752 | } |
1753 | EXPORT_SYMBOL_GPL(pci_assign_unassigned_bus_resources); | ||
diff --git a/drivers/pci/setup-irq.c b/drivers/pci/setup-irq.c index 4e2d595d50ca..95c225be49d1 100644 --- a/drivers/pci/setup-irq.c +++ b/drivers/pci/setup-irq.c | |||
@@ -65,3 +65,4 @@ void pci_fixup_irqs(u8 (*swizzle)(struct pci_dev *, u8 *), | |||
65 | for_each_pci_dev(dev) | 65 | for_each_pci_dev(dev) |
66 | pdev_fixup_irq(dev, swizzle, map_irq); | 66 | pdev_fixup_irq(dev, swizzle, map_irq); |
67 | } | 67 | } |
68 | EXPORT_SYMBOL_GPL(pci_fixup_irqs); | ||
diff --git a/drivers/pci/setup-res.c b/drivers/pci/setup-res.c index b7c3a5ea1fca..232f9254c11a 100644 --- a/drivers/pci/setup-res.c +++ b/drivers/pci/setup-res.c | |||
@@ -120,6 +120,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource) | |||
120 | if (!root) { | 120 | if (!root) { |
121 | dev_info(&dev->dev, "can't claim BAR %d %pR: no compatible bridge window\n", | 121 | dev_info(&dev->dev, "can't claim BAR %d %pR: no compatible bridge window\n", |
122 | resource, res); | 122 | resource, res); |
123 | res->flags |= IORESOURCE_UNSET; | ||
123 | return -EINVAL; | 124 | return -EINVAL; |
124 | } | 125 | } |
125 | 126 | ||
@@ -127,6 +128,7 @@ int pci_claim_resource(struct pci_dev *dev, int resource) | |||
127 | if (conflict) { | 128 | if (conflict) { |
128 | dev_info(&dev->dev, "can't claim BAR %d %pR: address conflict with %s %pR\n", | 129 | dev_info(&dev->dev, "can't claim BAR %d %pR: address conflict with %s %pR\n", |
129 | resource, res, conflict->name, conflict); | 130 | resource, res, conflict->name, conflict); |
131 | res->flags |= IORESOURCE_UNSET; | ||
130 | return -EBUSY; | 132 | return -EBUSY; |
131 | } | 133 | } |
132 | 134 | ||
diff --git a/drivers/pnp/quirks.c b/drivers/pnp/quirks.c index ebf0d6710b5a..943c1cb9566c 100644 --- a/drivers/pnp/quirks.c +++ b/drivers/pnp/quirks.c | |||
@@ -246,13 +246,16 @@ static void quirk_system_pci_resources(struct pnp_dev *dev) | |||
246 | */ | 246 | */ |
247 | for_each_pci_dev(pdev) { | 247 | for_each_pci_dev(pdev) { |
248 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { | 248 | for (i = 0; i < DEVICE_COUNT_RESOURCE; i++) { |
249 | unsigned long type; | 249 | unsigned long flags, type; |
250 | 250 | ||
251 | type = pci_resource_flags(pdev, i) & | 251 | flags = pci_resource_flags(pdev, i); |
252 | (IORESOURCE_IO | IORESOURCE_MEM); | 252 | type = flags & (IORESOURCE_IO | IORESOURCE_MEM); |
253 | if (!type || pci_resource_len(pdev, i) == 0) | 253 | if (!type || pci_resource_len(pdev, i) == 0) |
254 | continue; | 254 | continue; |
255 | 255 | ||
256 | if (flags & IORESOURCE_UNSET) | ||
257 | continue; | ||
258 | |||
256 | pci_start = pci_resource_start(pdev, i); | 259 | pci_start = pci_resource_start(pdev, i); |
257 | pci_end = pci_resource_end(pdev, i); | 260 | pci_end = pci_resource_end(pdev, i); |
258 | for (j = 0; | 261 | for (j = 0; |
diff --git a/include/linux/of_device.h b/include/linux/of_device.h index ef370210ffb2..22801b10cef5 100644 --- a/include/linux/of_device.h +++ b/include/linux/of_device.h | |||
@@ -53,6 +53,7 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) | |||
53 | return of_node_get(cpu_dev->of_node); | 53 | return of_node_get(cpu_dev->of_node); |
54 | } | 54 | } |
55 | 55 | ||
56 | void of_dma_configure(struct device *dev, struct device_node *np); | ||
56 | #else /* CONFIG_OF */ | 57 | #else /* CONFIG_OF */ |
57 | 58 | ||
58 | static inline int of_driver_match_device(struct device *dev, | 59 | static inline int of_driver_match_device(struct device *dev, |
@@ -90,6 +91,8 @@ static inline struct device_node *of_cpu_device_node_get(int cpu) | |||
90 | { | 91 | { |
91 | return NULL; | 92 | return NULL; |
92 | } | 93 | } |
94 | static inline void of_dma_configure(struct device *dev, struct device_node *np) | ||
95 | {} | ||
93 | #endif /* CONFIG_OF */ | 96 | #endif /* CONFIG_OF */ |
94 | 97 | ||
95 | #endif /* _LINUX_OF_DEVICE_H */ | 98 | #endif /* _LINUX_OF_DEVICE_H */ |
diff --git a/include/linux/of_iommu.h b/include/linux/of_iommu.h index 16c75547d725..ffbe4707d4aa 100644 --- a/include/linux/of_iommu.h +++ b/include/linux/of_iommu.h | |||
@@ -12,7 +12,8 @@ extern int of_get_dma_window(struct device_node *dn, const char *prefix, | |||
12 | size_t *size); | 12 | size_t *size); |
13 | 13 | ||
14 | extern void of_iommu_init(void); | 14 | extern void of_iommu_init(void); |
15 | extern struct iommu_ops *of_iommu_configure(struct device *dev); | 15 | extern struct iommu_ops *of_iommu_configure(struct device *dev, |
16 | struct device_node *master_np); | ||
16 | 17 | ||
17 | #else | 18 | #else |
18 | 19 | ||
@@ -24,7 +25,8 @@ static inline int of_get_dma_window(struct device_node *dn, const char *prefix, | |||
24 | } | 25 | } |
25 | 26 | ||
26 | static inline void of_iommu_init(void) { } | 27 | static inline void of_iommu_init(void) { } |
27 | static inline struct iommu_ops *of_iommu_configure(struct device *dev) | 28 | static inline struct iommu_ops *of_iommu_configure(struct device *dev, |
29 | struct device_node *master_np) | ||
28 | { | 30 | { |
29 | return NULL; | 31 | return NULL; |
30 | } | 32 | } |
diff --git a/include/linux/of_pci.h b/include/linux/of_pci.h index ce0e5abeb454..29fd3fe1c035 100644 --- a/include/linux/of_pci.h +++ b/include/linux/of_pci.h | |||
@@ -16,6 +16,7 @@ int of_pci_get_devfn(struct device_node *np); | |||
16 | int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); | 16 | int of_irq_parse_and_map_pci(const struct pci_dev *dev, u8 slot, u8 pin); |
17 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); | 17 | int of_pci_parse_bus_range(struct device_node *node, struct resource *res); |
18 | int of_get_pci_domain_nr(struct device_node *node); | 18 | int of_get_pci_domain_nr(struct device_node *node); |
19 | void of_pci_dma_configure(struct pci_dev *pci_dev); | ||
19 | #else | 20 | #else |
20 | static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) | 21 | static inline int of_irq_parse_pci(const struct pci_dev *pdev, struct of_phandle_args *out_irq) |
21 | { | 22 | { |
@@ -50,6 +51,8 @@ of_get_pci_domain_nr(struct device_node *node) | |||
50 | { | 51 | { |
51 | return -1; | 52 | return -1; |
52 | } | 53 | } |
54 | |||
55 | static inline void of_pci_dma_configure(struct pci_dev *pci_dev) { } | ||
53 | #endif | 56 | #endif |
54 | 57 | ||
55 | #if defined(CONFIG_OF_ADDRESS) | 58 | #if defined(CONFIG_OF_ADDRESS) |
diff --git a/include/linux/pci-acpi.h b/include/linux/pci-acpi.h index 24c7728ca681..a965efa52152 100644 --- a/include/linux/pci-acpi.h +++ b/include/linux/pci-acpi.h | |||
@@ -77,6 +77,11 @@ static inline void acpiphp_remove_slots(struct pci_bus *bus) { } | |||
77 | static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { } | 77 | static inline void acpiphp_check_host_bridge(struct acpi_device *adev) { } |
78 | #endif | 78 | #endif |
79 | 79 | ||
80 | extern const u8 pci_acpi_dsm_uuid[]; | ||
81 | #define DEVICE_LABEL_DSM 0x07 | ||
82 | #define RESET_DELAY_DSM 0x08 | ||
83 | #define FUNCTION_DELAY_DSM 0x09 | ||
84 | |||
80 | #else /* CONFIG_ACPI */ | 85 | #else /* CONFIG_ACPI */ |
81 | static inline void acpi_pci_add_bus(struct pci_bus *bus) { } | 86 | static inline void acpi_pci_add_bus(struct pci_bus *bus) { } |
82 | static inline void acpi_pci_remove_bus(struct pci_bus *bus) { } | 87 | static inline void acpi_pci_remove_bus(struct pci_bus *bus) { } |
diff --git a/include/linux/pci-aspm.h b/include/linux/pci-aspm.h index 8af4610c2e41..207c561fb40e 100644 --- a/include/linux/pci-aspm.h +++ b/include/linux/pci-aspm.h | |||
@@ -29,7 +29,6 @@ void pcie_aspm_pm_state_change(struct pci_dev *pdev); | |||
29 | void pcie_aspm_powersave_config_link(struct pci_dev *pdev); | 29 | void pcie_aspm_powersave_config_link(struct pci_dev *pdev); |
30 | void pci_disable_link_state(struct pci_dev *pdev, int state); | 30 | void pci_disable_link_state(struct pci_dev *pdev, int state); |
31 | void pci_disable_link_state_locked(struct pci_dev *pdev, int state); | 31 | void pci_disable_link_state_locked(struct pci_dev *pdev, int state); |
32 | void pcie_clear_aspm(struct pci_bus *bus); | ||
33 | void pcie_no_aspm(void); | 32 | void pcie_no_aspm(void); |
34 | #else | 33 | #else |
35 | static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) | 34 | static inline void pcie_aspm_init_link_state(struct pci_dev *pdev) |
@@ -47,9 +46,6 @@ static inline void pcie_aspm_powersave_config_link(struct pci_dev *pdev) | |||
47 | static inline void pci_disable_link_state(struct pci_dev *pdev, int state) | 46 | static inline void pci_disable_link_state(struct pci_dev *pdev, int state) |
48 | { | 47 | { |
49 | } | 48 | } |
50 | static inline void pcie_clear_aspm(struct pci_bus *bus) | ||
51 | { | ||
52 | } | ||
53 | static inline void pcie_no_aspm(void) | 49 | static inline void pcie_no_aspm(void) |
54 | { | 50 | { |
55 | } | 51 | } |
diff --git a/include/linux/pci.h b/include/linux/pci.h index 211e9da8a7d7..e63112fb55be 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h | |||
@@ -406,6 +406,7 @@ struct pci_host_bridge { | |||
406 | struct list_head windows; /* resource_entry */ | 406 | struct list_head windows; /* resource_entry */ |
407 | void (*release_fn)(struct pci_host_bridge *); | 407 | void (*release_fn)(struct pci_host_bridge *); |
408 | void *release_data; | 408 | void *release_data; |
409 | unsigned int ignore_reset_delay:1; /* for entire hierarchy */ | ||
409 | }; | 410 | }; |
410 | 411 | ||
411 | #define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev) | 412 | #define to_pci_host_bridge(n) container_of(n, struct pci_host_bridge, dev) |
@@ -510,6 +511,9 @@ static inline struct pci_dev *pci_upstream_bridge(struct pci_dev *dev) | |||
510 | return dev->bus->self; | 511 | return dev->bus->self; |
511 | } | 512 | } |
512 | 513 | ||
514 | struct device *pci_get_host_bridge_device(struct pci_dev *dev); | ||
515 | void pci_put_host_bridge_device(struct device *dev); | ||
516 | |||
513 | #ifdef CONFIG_PCI_MSI | 517 | #ifdef CONFIG_PCI_MSI |
514 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) | 518 | static inline bool pci_dev_msi_enabled(struct pci_dev *pci_dev) |
515 | { | 519 | { |