Skip to content

Commit 07a7cbd

Browse files
committed
Merge branch 'pci/host-generic' into next
* pci/host-generic: arm64: Add architectural support for PCI PCI: Add pci_remap_iospace() to map bus I/O resources of/pci: Add support for parsing PCI host bridge resources from DT of/pci: Add pci_get_new_domain_nr() and of_get_pci_domain_nr() PCI: Add generic domain handling of/pci: Fix the conversion of IO ranges into IO resources of/pci: Move of_pci_range_to_resource() to of/address.c ARM: Define PCI_IOBASE as the base of virtual PCI IO space of/pci: Add pci_register_io_range() and pci_pio_to_address() asm-generic/io.h: Fix ioport_map() for !CONFIG_GENERIC_IOMAP Conflicts: drivers/pci/host/pci-tegra.c
2 parents cc0cb67 + d1e6dc9 commit 07a7cbd

20 files changed

Lines changed: 576 additions & 37 deletions

File tree

‎arch/arm/include/asm/io.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,7 @@ static inline void __iomem *__typesafe_io(unsigned long addr)
178178

179179
/* PCI fixed i/o mapping */
180180
#define PCI_IO_VIRT_BASE 0xfee00000
181+
#define PCI_IOBASE ((void __iomem *)PCI_IO_VIRT_BASE)
181182

182183
#if defined(CONFIG_PCI)
183184
void pci_ioremap_set_mem_type(int mem_type);

‎arch/arm/mach-integrator/pci_v3.c‎

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -660,6 +660,7 @@ static void __init pci_v3_preinit(void)
660660
{
661661
unsigned long flags;
662662
unsigned int temp;
663+
phys_addr_t io_address = pci_pio_to_address(io_mem.start);
663664

664665
pcibios_min_mem = 0x00100000;
665666

@@ -701,7 +702,7 @@ static void __init pci_v3_preinit(void)
701702
/*
702703
* Setup window 2 - PCI IO
703704
*/
704-
v3_writel(V3_LB_BASE2, v3_addr_to_lb_base2(io_mem.start) |
705+
v3_writel(V3_LB_BASE2, v3_addr_to_lb_base2(io_address) |
705706
V3_LB_BASE_ENABLE);
706707
v3_writew(V3_LB_MAP2, v3_addr_to_lb_map2(0));
707708

@@ -742,6 +743,7 @@ static void __init pci_v3_preinit(void)
742743
static void __init pci_v3_postinit(void)
743744
{
744745
unsigned int pci_cmd;
746+
phys_addr_t io_address = pci_pio_to_address(io_mem.start);
745747

746748
pci_cmd = PCI_COMMAND_MEMORY |
747749
PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE;
@@ -758,7 +760,7 @@ static void __init pci_v3_postinit(void)
758760
"interrupt: %d\n", ret);
759761
#endif
760762

761-
register_isa_ports(non_mem.start, io_mem.start, 0);
763+
register_isa_ports(non_mem.start, io_address, 0);
762764
}
763765

764766
/*
@@ -867,33 +869,32 @@ static int __init pci_v3_probe(struct platform_device *pdev)
867869

868870
for_each_of_pci_range(&parser, &range) {
869871
if (!range.flags) {
870-
of_pci_range_to_resource(&range, np, &conf_mem);
872+
ret = of_pci_range_to_resource(&range, np, &conf_mem);
871873
conf_mem.name = "PCIv3 config";
872874
}
873875
if (range.flags & IORESOURCE_IO) {
874-
of_pci_range_to_resource(&range, np, &io_mem);
876+
ret = of_pci_range_to_resource(&range, np, &io_mem);
875877
io_mem.name = "PCIv3 I/O";
876878
}
877879
if ((range.flags & IORESOURCE_MEM) &&
878880
!(range.flags & IORESOURCE_PREFETCH)) {
879881
non_mem_pci = range.pci_addr;
880882
non_mem_pci_sz = range.size;
881-
of_pci_range_to_resource(&range, np, &non_mem);
883+
ret = of_pci_range_to_resource(&range, np, &non_mem);
882884
non_mem.name = "PCIv3 non-prefetched mem";
883885
}
884886
if ((range.flags & IORESOURCE_MEM) &&
885887
(range.flags & IORESOURCE_PREFETCH)) {
886888
pre_mem_pci = range.pci_addr;
887889
pre_mem_pci_sz = range.size;
888-
of_pci_range_to_resource(&range, np, &pre_mem);
890+
ret = of_pci_range_to_resource(&range, np, &pre_mem);
889891
pre_mem.name = "PCIv3 prefetched mem";
890892
}
891-
}
892893

893-
if (!conf_mem.start || !io_mem.start ||
894-
!non_mem.start || !pre_mem.start) {
895-
dev_err(&pdev->dev, "missing ranges in device node\n");
896-
return -EINVAL;
894+
if (ret < 0) {
895+
dev_err(&pdev->dev, "missing ranges in device node\n");
896+
return ret;
897+
}
897898
}
898899

899900
pci_v3.map_irq = of_irq_parse_and_map_pci;

‎arch/arm64/Kconfig‎

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ config MMU
8181
def_bool y
8282

8383
config NO_IOPORT_MAP
84-
def_bool y
84+
def_bool y if !PCI
8585

8686
config STACKTRACE_SUPPORT
8787
def_bool y
@@ -156,6 +156,26 @@ menu "Bus support"
156156
config ARM_AMBA
157157
bool
158158

159+
config PCI
160+
bool "PCI support"
161+
help
162+
This feature enables support for PCI bus system. If you say Y
163+
here, the kernel will include drivers and infrastructure code
164+
to support PCI bus devices.
165+
166+
config PCI_DOMAINS
167+
def_bool PCI
168+
169+
config PCI_DOMAINS_GENERIC
170+
def_bool PCI
171+
172+
config PCI_SYSCALL
173+
def_bool PCI
174+
175+
source "drivers/pci/Kconfig"
176+
source "drivers/pci/pcie/Kconfig"
177+
source "drivers/pci/hotplug/Kconfig"
178+
159179
endmenu
160180

161181
menu "Kernel Features"

‎arch/arm64/include/asm/Kbuild‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ generic-y += mman.h
2929
generic-y += msgbuf.h
3030
generic-y += mutex.h
3131
generic-y += pci.h
32+
generic-y += pci-bridge.h
3233
generic-y += poll.h
3334
generic-y += preempt.h
3435
generic-y += resource.h

‎arch/arm64/include/asm/io.h‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
121121
/*
122122
* I/O port access primitives.
123123
*/
124-
#define IO_SPACE_LIMIT 0xffff
124+
#define arch_has_dev_port() (1)
125+
#define IO_SPACE_LIMIT (SZ_32M - 1)
125126
#define PCI_IOBASE ((void __iomem *)(MODULES_VADDR - SZ_32M))
126127

127128
static inline u8 inb(unsigned long addr)

‎arch/arm64/include/asm/pci.h‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#ifndef __ASM_PCI_H
2+
#define __ASM_PCI_H
3+
#ifdef __KERNEL__
4+
5+
#include <linux/types.h>
6+
#include <linux/slab.h>
7+
#include <linux/dma-mapping.h>
8+
9+
#include <asm/io.h>
10+
#include <asm-generic/pci-bridge.h>
11+
#include <asm-generic/pci-dma-compat.h>
12+
13+
#define PCIBIOS_MIN_IO 0x1000
14+
#define PCIBIOS_MIN_MEM 0
15+
16+
/*
17+
* Set to 1 if the kernel should re-assign all PCI bus numbers
18+
*/
19+
#define pcibios_assign_all_busses() \
20+
(pci_has_flag(PCI_REASSIGN_ALL_BUS))
21+
22+
/*
23+
* PCI address space differs from physical memory address space
24+
*/
25+
#define PCI_DMA_BUS_IS_PHYS (0)
26+
27+
extern int isa_dma_bridge_buggy;
28+
29+
#ifdef CONFIG_PCI
30+
static inline int pci_proc_domain(struct pci_bus *bus)
31+
{
32+
return 1;
33+
}
34+
#endif /* CONFIG_PCI */
35+
36+
#endif /* __KERNEL__ */
37+
#endif /* __ASM_PCI_H */

‎arch/arm64/include/asm/pgtable.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,8 @@ static inline int has_transparent_hugepage(void)
296296
__pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRnE) | PTE_PXN | PTE_UXN)
297297
#define pgprot_writecombine(prot) \
298298
__pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN)
299+
#define pgprot_device(prot) \
300+
__pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRE) | PTE_PXN | PTE_UXN)
299301
#define __HAVE_PHYS_MEM_ACCESS_PROT
300302
struct file;
301303
extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,

‎arch/arm64/kernel/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ arm64-obj-$(CONFIG_ARM64_CPU_SUSPEND) += sleep.o suspend.o
2929
arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o
3030
arm64-obj-$(CONFIG_KGDB) += kgdb.o
3131
arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o
32+
arm64-obj-$(CONFIG_PCI) += pci.o
3233

3334
obj-y += $(arm64-obj-y) vdso/
3435
obj-m += $(arm64-obj-m)

‎arch/arm64/kernel/pci.c‎

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
/*
2+
* Code borrowed from powerpc/kernel/pci-common.c
3+
*
4+
* Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
5+
* Copyright (C) 2014 ARM Ltd.
6+
*
7+
* This program is free software; you can redistribute it and/or
8+
* modify it under the terms of the GNU General Public License
9+
* version 2 as published by the Free Software Foundation.
10+
*
11+
*/
12+
13+
#include <linux/init.h>
14+
#include <linux/io.h>
15+
#include <linux/kernel.h>
16+
#include <linux/mm.h>
17+
#include <linux/of_pci.h>
18+
#include <linux/of_platform.h>
19+
#include <linux/slab.h>
20+
21+
#include <asm/pci-bridge.h>
22+
23+
/*
24+
* Called after each bus is probed, but before its children are examined
25+
*/
26+
void pcibios_fixup_bus(struct pci_bus *bus)
27+
{
28+
/* nothing to do, expected to be removed in the future */
29+
}
30+
31+
/*
32+
* We don't have to worry about legacy ISA devices, so nothing to do here
33+
*/
34+
resource_size_t pcibios_align_resource(void *data, const struct resource *res,
35+
resource_size_t size, resource_size_t align)
36+
{
37+
return res->start;
38+
}
39+
40+
/*
41+
* Try to assign the IRQ number from DT when adding a new device
42+
*/
43+
int pcibios_add_device(struct pci_dev *dev)
44+
{
45+
dev->irq = of_irq_parse_and_map_pci(dev, 0, 0);
46+
47+
return 0;
48+
}
49+
50+
51+
#ifdef CONFIG_PCI_DOMAINS_GENERIC
52+
static bool dt_domain_found = false;
53+
54+
void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
55+
{
56+
int domain = of_get_pci_domain_nr(parent->of_node);
57+
58+
if (domain >= 0) {
59+
dt_domain_found = true;
60+
} else if (dt_domain_found == true) {
61+
dev_err(parent, "Node %s is missing \"linux,pci-domain\" property in DT\n",
62+
parent->of_node->full_name);
63+
return;
64+
} else {
65+
domain = pci_get_new_domain_nr();
66+
}
67+
68+
bus->domain_nr = domain;
69+
}
70+
#endif

0 commit comments

Comments
 (0)