Commit | Line | Data |
---|---|---|
1da177e4 LT |
1 | #ifdef __KERNEL__ |
2 | #ifndef _ASM_PCI_BRIDGE_H | |
3 | #define _ASM_PCI_BRIDGE_H | |
4 | ||
5 | #include <linux/pci.h> | |
6 | ||
7 | /* | |
8 | * This program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public License | |
10 | * as published by the Free Software Foundation; either version | |
11 | * 2 of the License, or (at your option) any later version. | |
12 | */ | |
13 | ||
14 | /* | |
15 | * Structure of a PCI controller (host bridge) | |
16 | */ | |
17 | struct pci_controller { | |
18 | struct pci_bus *bus; | |
19 | char is_dynamic; | |
20 | void *arch_data; | |
21 | struct list_head list_node; | |
22 | ||
23 | int first_busno; | |
24 | int last_busno; | |
25 | ||
26 | void __iomem *io_base_virt; | |
27 | unsigned long io_base_phys; | |
28 | ||
29 | /* Some machines have a non 1:1 mapping of | |
30 | * the PCI memory space in the CPU bus space | |
31 | */ | |
32 | unsigned long pci_mem_offset; | |
33 | unsigned long pci_io_size; | |
34 | ||
35 | struct pci_ops *ops; | |
36 | volatile unsigned int __iomem *cfg_addr; | |
37 | volatile unsigned char __iomem *cfg_data; | |
38 | ||
39 | /* Currently, we limit ourselves to 1 IO range and 3 mem | |
40 | * ranges since the common pci_bus structure can't handle more | |
41 | */ | |
42 | struct resource io_resource; | |
43 | struct resource mem_resources[3]; | |
44 | int global_number; | |
45 | int local_number; | |
46 | unsigned long buid; | |
47 | unsigned long dma_window_base_cur; | |
48 | unsigned long dma_window_size; | |
49 | }; | |
50 | ||
51 | struct device_node *fetch_dev_dn(struct pci_dev *dev); | |
52 | ||
53 | /* Get a device_node from a pci_dev. This code must be fast except in the case | |
54 | * where the sysdata is incorrect and needs to be fixed up (hopefully just once) | |
55 | */ | |
56 | static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev) | |
57 | { | |
58 | struct device_node *dn = dev->sysdata; | |
59 | ||
60 | if (dn->devfn == dev->devfn && dn->busno == dev->bus->number) | |
61 | return dn; /* fast path. sysdata is good */ | |
62 | else | |
63 | return fetch_dev_dn(dev); | |
64 | } | |
65 | ||
66 | static inline struct device_node *pci_bus_to_OF_node(struct pci_bus *bus) | |
67 | { | |
68 | if (bus->self) | |
69 | return pci_device_to_OF_node(bus->self); | |
70 | else | |
71 | return bus->sysdata; /* Must be root bus (PHB) */ | |
72 | } | |
73 | ||
74 | extern void pci_process_bridge_OF_ranges(struct pci_controller *hose, | |
75 | struct device_node *dev); | |
76 | ||
77 | extern int pcibios_remove_root_bus(struct pci_controller *phb); | |
78 | ||
79 | extern void phbs_remap_io(void); | |
80 | ||
81 | static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus) | |
82 | { | |
83 | struct device_node *busdn = bus->sysdata; | |
84 | ||
85 | BUG_ON(busdn == NULL); | |
86 | return busdn->phb; | |
87 | } | |
88 | ||
89 | #endif | |
90 | #endif /* __KERNEL__ */ |