upgrade to linux 2.6.10-1.12_FC2
[linux-2.6.git] / include / asm-ppc64 / pci-bridge.h
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 struct device_node;
15 struct pci_controller;
16
17 /* Get the PCI host controller for an OF device */
18 extern struct pci_controller*
19 pci_find_hose_for_OF_device(struct device_node* node);
20
21 /*
22  * Structure of a PCI controller (host bridge)
23  */
24 struct pci_controller {
25         char what[8];                     /* Eye catcher      */
26         struct pci_bus *bus;
27         char is_dynamic;
28         void *arch_data;
29         struct list_head list_node;
30
31         int first_busno;
32         int last_busno;
33
34         void __iomem *io_base_virt;
35         unsigned long io_base_phys;
36
37         /* Some machines have a non 1:1 mapping of
38          * the PCI memory space in the CPU bus space
39          */
40         unsigned long pci_mem_offset;
41         unsigned long pci_io_size;
42
43         struct pci_ops *ops;
44         volatile unsigned int __iomem *cfg_addr;
45         volatile unsigned char __iomem *cfg_data;
46
47         /* Currently, we limit ourselves to 1 IO range and 3 mem
48          * ranges since the common pci_bus structure can't handle more
49          */
50         struct resource io_resource;
51         struct resource mem_resources[3];
52         int mem_resource_count;
53         int global_number;              
54         int local_number;               
55         unsigned long buid;
56         unsigned long dma_window_base_cur;
57         unsigned long dma_window_size;
58 };
59
60 /*
61  * pci_device_loc returns the bus number and device/function number
62  * for a device on a PCI bus, given its device_node struct.
63  * It returns 0 if OK, -1 on error.
64  */
65 extern int pci_device_loc(struct device_node *dev, unsigned char *bus_ptr,
66                           unsigned char *devfn_ptr);
67
68 struct device_node *fetch_dev_dn(struct pci_dev *dev);
69
70 /* Get a device_node from a pci_dev.  This code must be fast except in the case
71  * where the sysdata is incorrect and needs to be fixed up (hopefully just once)
72  */
73 static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
74 {
75         struct device_node *dn = (struct device_node *)(dev->sysdata);
76         if (dn->devfn == dev->devfn && dn->busno == (dev->bus->number&0xff))
77                 return dn;      /* fast path.  sysdata is good */
78         else
79                 return fetch_dev_dn(dev);
80 }
81
82 extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
83                                          struct device_node *dev);
84
85 extern int pcibios_remove_root_bus(struct pci_controller *phb);
86
87 extern void phbs_remap_io(void);
88
89 static inline struct pci_controller *pci_bus_to_host(struct pci_bus *bus)
90 {
91         struct device_node *busdn = bus->sysdata;
92
93         BUG_ON(busdn == NULL);
94         return busdn->phb;
95 }
96
97
98 #endif
99 #endif /* __KERNEL__ */