ftp://ftp.kernel.org/pub/linux/kernel/v2.6/linux-2.6.6.tar.bz2
[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 enum phb_types { 
22         phb_type_unknown    = 0x0,
23         phb_type_hypervisor = 0x1,
24         phb_type_python     = 0x10,
25         phb_type_speedwagon = 0x11,
26         phb_type_winnipeg   = 0x12,
27         phb_type_apple      = 0xff
28 };
29
30 /*
31  * Structure of a PCI controller (host bridge)
32  */
33 struct pci_controller {
34         char what[8];                     /* Eye catcher      */
35         enum phb_types type;              /* Type of hardware */
36         struct pci_controller *next;
37         struct pci_bus *bus;
38         void *arch_data;
39
40         int first_busno;
41         int last_busno;
42
43         void *io_base_virt;
44         unsigned long io_base_phys;
45
46         /* Some machines have a non 1:1 mapping of
47          * the PCI memory space in the CPU bus space
48          */
49         unsigned long pci_mem_offset;
50         unsigned long pci_io_offset;
51
52         struct pci_ops *ops;
53         volatile unsigned int *cfg_addr;
54         volatile unsigned char *cfg_data;
55
56         /* Currently, we limit ourselves to 1 IO range and 3 mem
57          * ranges since the common pci_bus structure can't handle more
58          */
59         struct resource io_resource;
60         struct resource mem_resources[3];
61         int mem_resource_count;
62         int global_number;              
63         int local_number;               
64         unsigned long buid;
65         unsigned long dma_window_base_cur;
66         unsigned long dma_window_size;
67 };
68
69 /*
70  * pci_device_loc returns the bus number and device/function number
71  * for a device on a PCI bus, given its device_node struct.
72  * It returns 0 if OK, -1 on error.
73  */
74 int pci_device_loc(struct device_node *dev, unsigned char *bus_ptr,
75                    unsigned char *devfn_ptr);
76
77 struct device_node *fetch_dev_dn(struct pci_dev *dev);
78
79 /* Get a device_node from a pci_dev.  This code must be fast except in the case
80  * where the sysdata is incorrect and needs to be fixed up (hopefully just once)
81  */
82 static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
83 {
84         struct device_node *dn = (struct device_node *)(dev->sysdata);
85         if (dn->devfn == dev->devfn && dn->busno == (dev->bus->number&0xff))
86                 return dn;      /* fast path.  sysdata is good */
87         else
88                 return fetch_dev_dn(dev);
89 }
90
91 /* Use this macro after the PCI bus walk for max performance when it
92  * is known that sysdata is correct.
93  */
94 #define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
95
96 #endif
97 #endif /* __KERNEL__ */