2 #ifndef _ASM_PCI_BRIDGE_H
3 #define _ASM_PCI_BRIDGE_H
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.
15 * Structure of a PCI controller (host bridge)
17 struct pci_controller
{
21 struct list_head list_node
;
26 void __iomem
*io_base_virt
;
27 unsigned long io_base_phys
;
29 /* Some machines have a non 1:1 mapping of
30 * the PCI memory space in the CPU bus space
32 unsigned long pci_mem_offset
;
33 unsigned long pci_io_size
;
36 volatile unsigned int __iomem
*cfg_addr
;
37 volatile unsigned char __iomem
*cfg_data
;
39 /* Currently, we limit ourselves to 1 IO range and 3 mem
40 * ranges since the common pci_bus structure can't handle more
42 struct resource io_resource
;
43 struct resource mem_resources
[3];
47 unsigned long dma_window_base_cur
;
48 unsigned long dma_window_size
;
51 struct device_node
*fetch_dev_dn(struct pci_dev
*dev
);
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)
56 static inline struct device_node
*pci_device_to_OF_node(struct pci_dev
*dev
)
58 struct device_node
*dn
= dev
->sysdata
;
60 if (dn
->devfn
== dev
->devfn
&& dn
->busno
== dev
->bus
->number
)
61 return dn
; /* fast path. sysdata is good */
63 return fetch_dev_dn(dev
);
66 static inline struct device_node
*pci_bus_to_OF_node(struct pci_bus
*bus
)
69 return pci_device_to_OF_node(bus
->self
);
71 return bus
->sysdata
; /* Must be root bus (PHB) */
74 extern void pci_process_bridge_OF_ranges(struct pci_controller
*hose
,
75 struct device_node
*dev
);
77 extern int pcibios_remove_root_bus(struct pci_controller
*phb
);
79 extern void phbs_remap_io(void);
81 static inline struct pci_controller
*pci_bus_to_host(struct pci_bus
*bus
)
83 struct device_node
*busdn
= bus
->sysdata
;
85 BUG_ON(busdn
== NULL
);
90 #endif /* __KERNEL__ */