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 struct pci_controller;
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);
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,
31 * Structure of a PCI controller (host bridge)
33 struct pci_controller {
34 char what[8]; /* Eye catcher */
35 enum phb_types type; /* Type of hardware */
39 struct list_head list_node;
45 unsigned long io_base_phys;
47 /* Some machines have a non 1:1 mapping of
48 * the PCI memory space in the CPU bus space
50 unsigned long pci_mem_offset;
51 unsigned long pci_io_size;
54 volatile unsigned int *cfg_addr;
55 volatile unsigned char *cfg_data;
57 /* Currently, we limit ourselves to 1 IO range and 3 mem
58 * ranges since the common pci_bus structure can't handle more
60 struct resource io_resource;
61 struct resource mem_resources[3];
62 int mem_resource_count;
66 unsigned long dma_window_base_cur;
67 unsigned long dma_window_size;
71 * pci_device_loc returns the bus number and device/function number
72 * for a device on a PCI bus, given its device_node struct.
73 * It returns 0 if OK, -1 on error.
75 extern int pci_device_loc(struct device_node *dev, unsigned char *bus_ptr,
76 unsigned char *devfn_ptr);
78 struct device_node *fetch_dev_dn(struct pci_dev *dev);
80 extern int pcibios_remove_root_bus(struct pci_controller *phb);
82 /* Get a device_node from a pci_dev. This code must be fast except in the case
83 * where the sysdata is incorrect and needs to be fixed up (hopefully just once)
85 static inline struct device_node *pci_device_to_OF_node(struct pci_dev *dev)
87 struct device_node *dn = (struct device_node *)(dev->sysdata);
88 if (dn->devfn == dev->devfn && dn->busno == (dev->bus->number&0xff))
89 return dn; /* fast path. sysdata is good */
91 return fetch_dev_dn(dev);
94 extern void pci_process_bridge_OF_ranges(struct pci_controller *hose,
95 struct device_node *dev);
97 /* Use this macro after the PCI bus walk for max performance when it
98 * is known that sysdata is correct.
100 #define PCI_GET_DN(dev) ((struct device_node *)((dev)->sysdata))
103 #endif /* __KERNEL__ */