summaryrefslogtreecommitdiff
path: root/arch/arm64/kernel/pci.c
blob: ce5836c14ec1d8e9c1fa46a01d7f09bee80880ac (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
/*
 * Code borrowed from powerpc/kernel/pci-common.c
 *
 * Copyright (C) 2003 Anton Blanchard <anton@au.ibm.com>, IBM
 * Copyright (C) 2014 ARM Ltd.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * version 2 as published by the Free Software Foundation.
 *
 */

#include <linux/init.h>
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/mm.h>
#include <linux/of_pci.h>
#include <linux/of_platform.h>
#include <linux/slab.h>

#include <asm/pci-bridge.h>

/*
 * Called after each bus is probed, but before its children are examined
 */
void pcibios_fixup_bus(struct pci_bus *bus)
{
	/* nothing to do, expected to be removed in the future */
}

/*
 * We don't have to worry about legacy ISA devices, so nothing to do here
 */
resource_size_t pcibios_align_resource(void *data, const struct resource *res,
				resource_size_t size, resource_size_t align)
{
	return res->start;
}

/*
 * Try to assign the IRQ number from DT when adding a new device
 */
int pcibios_add_device(struct pci_dev *dev)
{
	dev->irq = of_irq_parse_and_map_pci(dev, 0, 0);

	return 0;
}


#ifdef CONFIG_PCI_DOMAINS_GENERIC
static bool dt_domain_found = false;

void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
{
	int domain = of_get_pci_domain_nr(parent->of_node);

	if (domain >= 0) {
		dt_domain_found = true;
	} else if (dt_domain_found == true) {
		dev_err(parent, "Node %s is missing \"linux,pci-domain\" property in DT\n",
			parent->of_node->full_name);
		return;
	} else {
		domain = pci_get_new_domain_nr();
	}

	bus->domain_nr = domain;
}
#endif