Root/
1 | /* |
2 | * PCI <-> OF mapping helpers |
3 | * |
4 | * Copyright 2011 IBM Corp. |
5 | * |
6 | * This program is free software; you can redistribute it and/or |
7 | * modify it under the terms of the GNU General Public License |
8 | * as published by the Free Software Foundation; either version |
9 | * 2 of the License, or (at your option) any later version. |
10 | */ |
11 | |
12 | #include <linux/kernel.h> |
13 | #include <linux/pci.h> |
14 | #include <linux/of.h> |
15 | #include <linux/of_pci.h> |
16 | #include "pci.h" |
17 | |
18 | void pci_set_of_node(struct pci_dev *dev) |
19 | { |
20 | if (!dev->bus->dev.of_node) |
21 | return; |
22 | dev->dev.of_node = of_pci_find_child_device(dev->bus->dev.of_node, |
23 | dev->devfn); |
24 | } |
25 | |
26 | void pci_release_of_node(struct pci_dev *dev) |
27 | { |
28 | of_node_put(dev->dev.of_node); |
29 | dev->dev.of_node = NULL; |
30 | } |
31 | |
32 | void pci_set_bus_of_node(struct pci_bus *bus) |
33 | { |
34 | if (bus->self == NULL) |
35 | bus->dev.of_node = pcibios_get_phb_of_node(bus); |
36 | else |
37 | bus->dev.of_node = of_node_get(bus->self->dev.of_node); |
38 | } |
39 | |
40 | void pci_release_bus_of_node(struct pci_bus *bus) |
41 | { |
42 | of_node_put(bus->dev.of_node); |
43 | bus->dev.of_node = NULL; |
44 | } |
45 | |
46 | struct device_node * __weak pcibios_get_phb_of_node(struct pci_bus *bus) |
47 | { |
48 | /* This should only be called for PHBs */ |
49 | if (WARN_ON(bus->self || bus->parent)) |
50 | return NULL; |
51 | |
52 | /* Look for a node pointer in either the intermediary device we |
53 | * create above the root bus or it's own parent. Normally only |
54 | * the later is populated. |
55 | */ |
56 | if (bus->bridge->of_node) |
57 | return of_node_get(bus->bridge->of_node); |
58 | if (bus->bridge->parent && bus->bridge->parent->of_node) |
59 | return of_node_get(bus->bridge->parent->of_node); |
60 | return NULL; |
61 | } |
62 |
Branches:
ben-wpan
ben-wpan-stefan
javiroman/ks7010
jz-2.6.34
jz-2.6.34-rc5
jz-2.6.34-rc6
jz-2.6.34-rc7
jz-2.6.35
jz-2.6.36
jz-2.6.37
jz-2.6.38
jz-2.6.39
jz-3.0
jz-3.1
jz-3.11
jz-3.12
jz-3.13
jz-3.15
jz-3.16
jz-3.18-dt
jz-3.2
jz-3.3
jz-3.4
jz-3.5
jz-3.6
jz-3.6-rc2-pwm
jz-3.9
jz-3.9-clk
jz-3.9-rc8
jz47xx
jz47xx-2.6.38
master
Tags:
od-2011-09-04
od-2011-09-18
v2.6.34-rc5
v2.6.34-rc6
v2.6.34-rc7
v3.9