aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLiviu Dudau <Liviu.Dudau@arm.com>2014-09-29 10:29:31 -0400
committerBjorn Helgaas <bhelgaas@google.com>2014-09-30 19:08:57 -0400
commitd1e6dc91b532d3d3dbbd0fa356b775ca320dc2c2 (patch)
tree8470f782b1a12d70ccae0ce4ea983e5977a44c50
parent8b921acfeffdb0b45085da862fc301a2d25ed2cf (diff)
arm64: Add architectural support for PCI
Use the generic PCI domain and OF functions to provide support for PCI on arm64. [bhelgaas: Change comments to use generic PCI, not just PCIe. Nothing at this level is PCIe-specific.] Signed-off-by: Liviu Dudau <Liviu.Dudau@arm.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com>
-rw-r--r--arch/arm64/Kconfig22
-rw-r--r--arch/arm64/include/asm/Kbuild1
-rw-r--r--arch/arm64/include/asm/io.h3
-rw-r--r--arch/arm64/include/asm/pci.h37
-rw-r--r--arch/arm64/include/asm/pgtable.h2
-rw-r--r--arch/arm64/kernel/Makefile1
-rw-r--r--arch/arm64/kernel/pci.c70
7 files changed, 134 insertions, 2 deletions
diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig
index fd4e81a4e1ce..bc97147d326c 100644
--- a/arch/arm64/Kconfig
+++ b/arch/arm64/Kconfig
@@ -81,7 +81,7 @@ config MMU
81 def_bool y 81 def_bool y
82 82
83config NO_IOPORT_MAP 83config NO_IOPORT_MAP
84 def_bool y 84 def_bool y if !PCI
85 85
86config STACKTRACE_SUPPORT 86config STACKTRACE_SUPPORT
87 def_bool y 87 def_bool y
@@ -156,6 +156,26 @@ menu "Bus support"
156config ARM_AMBA 156config ARM_AMBA
157 bool 157 bool
158 158
159config 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
166config PCI_DOMAINS
167 def_bool PCI
168
169config PCI_DOMAINS_GENERIC
170 def_bool PCI
171
172config PCI_SYSCALL
173 def_bool PCI
174
175source "drivers/pci/Kconfig"
176source "drivers/pci/pcie/Kconfig"
177source "drivers/pci/hotplug/Kconfig"
178
159endmenu 179endmenu
160 180
161menu "Kernel Features" 181menu "Kernel Features"
diff --git a/arch/arm64/include/asm/Kbuild b/arch/arm64/include/asm/Kbuild
index 0b3fcf86e6ba..07cb417026b6 100644
--- a/arch/arm64/include/asm/Kbuild
+++ b/arch/arm64/include/asm/Kbuild
@@ -29,6 +29,7 @@ generic-y += mman.h
29generic-y += msgbuf.h 29generic-y += msgbuf.h
30generic-y += mutex.h 30generic-y += mutex.h
31generic-y += pci.h 31generic-y += pci.h
32generic-y += pci-bridge.h
32generic-y += poll.h 33generic-y += poll.h
33generic-y += preempt.h 34generic-y += preempt.h
34generic-y += resource.h 35generic-y += resource.h
diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h
index e0ecdcf6632d..f998d90bc389 100644
--- a/arch/arm64/include/asm/io.h
+++ b/arch/arm64/include/asm/io.h
@@ -121,7 +121,8 @@ static inline u64 __raw_readq(const volatile void __iomem *addr)
121/* 121/*
122 * I/O port access primitives. 122 * I/O port access primitives.
123 */ 123 */
124#define IO_SPACE_LIMIT 0xffff 124#define arch_has_dev_port() (1)
125#define IO_SPACE_LIMIT (SZ_32M - 1)
125#define PCI_IOBASE ((void __iomem *)(MODULES_VADDR - SZ_32M)) 126#define PCI_IOBASE ((void __iomem *)(MODULES_VADDR - SZ_32M))
126 127
127static inline u8 inb(unsigned long addr) 128static inline u8 inb(unsigned long addr)
diff --git a/arch/arm64/include/asm/pci.h b/arch/arm64/include/asm/pci.h
new file mode 100644
index 000000000000..872ba939fcb2
--- /dev/null
+++ b/arch/arm64/include/asm/pci.h
@@ -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
27extern int isa_dma_bridge_buggy;
28
29#ifdef CONFIG_PCI
30static 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 */
diff --git a/arch/arm64/include/asm/pgtable.h b/arch/arm64/include/asm/pgtable.h
index ffe1ba0506d1..a968523adf56 100644
--- a/arch/arm64/include/asm/pgtable.h
+++ b/arch/arm64/include/asm/pgtable.h
@@ -296,6 +296,8 @@ static inline int has_transparent_hugepage(void)
296 __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRnE) | PTE_PXN | PTE_UXN) 296 __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_DEVICE_nGnRnE) | PTE_PXN | PTE_UXN)
297#define pgprot_writecombine(prot) \ 297#define pgprot_writecombine(prot) \
298 __pgprot_modify(prot, PTE_ATTRINDX_MASK, PTE_ATTRINDX(MT_NORMAL_NC) | PTE_PXN | PTE_UXN) 298 __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)
299#define __HAVE_PHYS_MEM_ACCESS_PROT 301#define __HAVE_PHYS_MEM_ACCESS_PROT
300struct file; 302struct file;
301extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn, 303extern pgprot_t phys_mem_access_prot(struct file *file, unsigned long pfn,
diff --git a/arch/arm64/kernel/Makefile b/arch/arm64/kernel/Makefile
index df7ef8768fc2..1ed5a06a3863 100644
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -29,6 +29,7 @@ arm64-obj-$(CONFIG_ARM64_CPU_SUSPEND) += sleep.o suspend.o
29arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o 29arm64-obj-$(CONFIG_JUMP_LABEL) += jump_label.o
30arm64-obj-$(CONFIG_KGDB) += kgdb.o 30arm64-obj-$(CONFIG_KGDB) += kgdb.o
31arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o 31arm64-obj-$(CONFIG_EFI) += efi.o efi-stub.o efi-entry.o
32arm64-obj-$(CONFIG_PCI) += pci.o
32 33
33obj-y += $(arm64-obj-y) vdso/ 34obj-y += $(arm64-obj-y) vdso/
34obj-m += $(arm64-obj-m) 35obj-m += $(arm64-obj-m)
diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
new file mode 100644
index 000000000000..ce5836c14ec1
--- /dev/null
+++ b/arch/arm64/kernel/pci.c
@@ -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 */
26void 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 */
34resource_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 */
43int 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
52static bool dt_domain_found = false;
53
54void 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