Skip to content

Commit d1e6dc9

Browse files
dliviubjorn-helgaas
authored andcommitted
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>
1 parent 8b921ac commit d1e6dc9

7 files changed

Lines changed: 134 additions & 2 deletions

File tree

‎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)