1 /*
2 * c 2001 PPC 64 Team, IBM Corp
3 *
4 * This program is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU General Public License
6 * as published by the Free Software Foundation; either version
7 * 2 of the License, or (at your option) any later version.
8 */
9 #ifndef __PPC_KERNEL_PCI_H__
10 #define __PPC_KERNEL_PCI_H__
11
12 #include <linux/pci.h>
13 #include <asm/pci-bridge.h>
14
15 extern unsigned long isa_io_base;
16 extern unsigned long isa_mem_base;
17 extern unsigned long pci_dram_offset;
18
19 /*******************************************************************
20 * Platform independant variables referenced.
21 *******************************************************************
22 * Set pci_assign_all_busses to 1 if you want the kernel to re-assign
23 * all PCI bus numbers.
24 *******************************************************************/
25 extern int pci_assign_all_busses;
26
27 extern struct pci_controller* pci_alloc_pci_controller(char *model, enum phb_types controller_type);
28 extern struct pci_controller* pci_find_hose_for_OF_device(struct device_node* node);
29
30 extern struct pci_controller* hose_head;
31 extern struct pci_controller** hose_tail;
32 /* PHB's are also in a table. */
33 #define PCI_MAX_PHB 64
34 extern int global_phb_number;
35 extern struct pci_controller *phbtab[];
36
37 /*******************************************************************
38 * Platform functions that are brand specific implementation.
39 *******************************************************************/
40 extern unsigned long find_and_init_phbs(void);
41
42 extern void fixup_resources(struct pci_dev *dev);
43 extern void ppc64_pcibios_init(void);
44
45 extern int pci_set_reset(struct pci_dev*,int);
46 extern int device_Location(struct pci_dev*,char*);
47 extern int format_device_location(struct pci_dev*,char*, int );
48
49 extern struct pci_dev *ppc64_isabridge_dev; /* may be NULL if no ISA bus */
50
51 /*******************************************************************
52 * PCI device_node operations
53 *******************************************************************/
54 struct device_node;
55 typedef void *(*traverse_func)(struct device_node *me, void *data);
56 void *traverse_pci_devices(struct device_node *start, traverse_func pre, traverse_func post, void *data);
57 void *traverse_all_pci_devices(traverse_func pre);
58
59 struct pci_dev *pci_find_dev_by_addr(unsigned long addr);
60 void pci_devs_phb_init(void);
61 void pci_fix_bus_sysdata(void);
62 struct device_node *fetch_dev_dn(struct pci_dev *dev);
63
64 void iSeries_pcibios_init_early(void);
65 void pSeries_pcibios_init_early(void);
66 void pSeries_pcibios_init(void);
67
68 /* Get a device_node from a pci_dev. This code must be fast except in the case
69 * where the sysdata is incorrect and needs to be fixed up (hopefully just once)
70 */
pci_device_to_OF_node(struct pci_dev * dev)71 static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
72 {
73 struct device_node *dn = (struct device_node *)(dev->sysdata);
74 if (dn->devfn == dev->devfn && dn->busno == (dev->bus->number&0xff))
75 return dn; /* fast path. sysdata is good */
76 else
77 return fetch_dev_dn(dev);
78 }
79 /* Use this macro after the PCI bus walk for max performance when it
80 * is known that sysdata is correct.
81 */
82 #define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
83
84
85 /*******************************************************************
86 * Platform configuration flags.. (Live in pci.c)
87 *******************************************************************/
88 extern int Pci_Large_Bus_System; /* System has > 256 buses */
89 extern int Pci_Manage_Phb_Space; /* Manage Phb Space for IOAs*/
90
91 /*******************************************************************
92 * Helper macros for extracting data from pci structures.
93 * PCI_GET_PHB_PTR(struct pci_dev*) returns the Phb pointer.
94 * PCI_GET_PHB_NUMBER(struct pci_dev*) returns the Phb number.
95 * PCI_GET_BUS_NUMBER(struct pci_dev*) returns the bus number.
96 *******************************************************************/
97 #define PCI_GET_PHB_PTR(dev) (((struct device_node *)(dev)->sysdata)->phb)
98 #define PCI_GET_PHB_NUMBER(dev) (((dev)->bus->number&0x00FFFF00)>>8)
99 #define PCI_GET_BUS_NUMBER(dev) ((dev)->bus->number&0x0000FF)
100
101 /*******************************************************************
102 * Pci Flight Recorder support.
103 *******************************************************************/
104 #define PCIFR(...) fr_Log_Entry(PciFr,__VA_ARGS__);
105 extern struct flightRecorder* PciFr;
106 extern int Pci_Trace_Flag;
107
108 /*******************************************************************
109 * Debugging Routines.
110 *******************************************************************/
111 extern void dumpResources(struct resource* Resource);
112 extern void dumpPci_Controller(struct pci_controller* phb);
113 extern void dumpPci_Bus(struct pci_bus* Pci_Bus);
114 extern void dumpPci_Dev(struct pci_dev* Pci_Dev);
115
116 extern void dump_Phb_tree(void);
117 extern void dump_Bus_tree(void);
118 extern void dump_Dev_tree(void);
119
120 #endif /* __PPC_KERNEL_PCI_H__ */
121