xref: /openbmc/linux/arch/arm64/kernel/pci.c (revision 6774def6)
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
71