2 * PCI defines and function prototypes
3 * Copyright 1994, Drew Eckhardt
4 * Copyright 1997--1999 Martin Mares <mj@atrey.karlin.mff.cuni.cz>
6 * For more information, please consult the following manuals (look at
7 * http://www.pcisig.com/ for how to get them):
9 * PCI BIOS Specification
10 * PCI Local Bus Specification
11 * PCI to PCI Bridge Specification
12 * PCI System Design Guide
24 #include <device/pci_def.h>
25 #include <device/resource.h>
26 #include <device/device.h>
27 #include <device/pci_ops.h>
28 #include <device/pci_rom.h>
30 #ifndef __SIMPLE_DEVICE__
32 /* Common pci operations without a standard interface */
33 struct pci_operations
{
34 /* set the Subsystem IDs for the PCI device */
35 void (*set_subsystem
)(device_t dev
, unsigned int vendor
,
37 void (*set_L1_ss_latency
)(device_t dev
, unsigned int off
);
40 /* Common pci bus operations */
41 struct pci_bus_operations
{
42 uint8_t (*read8
)(struct bus
*pbus
, int bus
, int devfn
, int where
);
43 uint16_t (*read16
)(struct bus
*pbus
, int bus
, int devfn
, int where
);
44 uint32_t (*read32
)(struct bus
*pbus
, int bus
, int devfn
, int where
);
45 void (*write8
)(struct bus
*pbus
, int bus
, int devfn
, int where
, uint8_t val
);
46 void (*write16
)(struct bus
*pbus
, int bus
, int devfn
, int where
, uint16_t val
);
47 void (*write32
)(struct bus
*pbus
, int bus
, int devfn
, int where
, uint32_t val
);
51 const struct device_operations
*ops
;
52 unsigned short vendor
;
53 unsigned short device
;
54 const unsigned short *devices
;
57 #define __pci_driver __attribute__ ((used, __section__(".rodata.pci_driver")))
58 /** start of compile time generated pci driver array */
59 extern struct pci_driver _pci_drivers
[];
60 /** end of compile time generated pci driver array */
61 extern struct pci_driver _epci_drivers
[];
64 extern struct device_operations default_pci_ops_dev
;
65 extern struct device_operations default_pci_ops_bus
;
67 void pci_dev_read_resources(device_t dev
);
68 void pci_bus_read_resources(device_t dev
);
69 void pci_dev_set_resources(device_t dev
);
70 void pci_dev_enable_resources(device_t dev
);
71 void pci_bus_enable_resources(device_t dev
);
72 void pci_bus_reset(struct bus
*bus
);
73 device_t
pci_probe_dev(device_t dev
, struct bus
*bus
, unsigned int devfn
);
75 void do_pci_scan_bridge(device_t bus
,
76 void (*do_scan_bus
)(struct bus
*bus
,
77 unsigned int min_devfn
, unsigned int max_devfn
));
79 void pci_scan_bridge(device_t bus
);
80 void pci_scan_bus(struct bus
*bus
, unsigned int min_devfn
,
81 unsigned int max_devfn
);
83 uint8_t pci_moving_config8(struct device
*dev
, unsigned int reg
);
84 uint16_t pci_moving_config16(struct device
*dev
, unsigned int reg
);
85 uint32_t pci_moving_config32(struct device
*dev
, unsigned int reg
);
86 struct resource
*pci_get_resource(struct device
*dev
, unsigned long index
);
87 void pci_dev_set_subsystem(device_t dev
, unsigned int vendor
,
89 void pci_dev_init(struct device
*dev
);
90 unsigned int pci_match_simple_dev(device_t dev
, pci_devfn_t sdev
);
92 const char *pin_to_str(int pin
);
93 int get_pci_irq_pins(device_t dev
, device_t
*parent_bdg
);
94 void pci_assign_irqs(unsigned int bus
, unsigned int slot
,
95 const unsigned char pIntAtoD
[4]);
96 const char *get_pci_class_name(device_t dev
);
97 const char *get_pci_subclass_name(device_t dev
);
99 #define PCI_IO_BRIDGE_ALIGN 4096
100 #define PCI_MEM_BRIDGE_ALIGN (1024*1024)
102 static inline const struct pci_operations
*ops_pci(device_t dev
)
104 const struct pci_operations
*pops
;
107 pops
= dev
->ops
->ops_pci
;
111 #endif /* ! __SIMPLE_DEVICE__ */
113 #ifdef __SIMPLE_DEVICE__
114 unsigned int pci_find_next_capability(pci_devfn_t dev
, unsigned int cap
,
116 unsigned int pci_find_capability(pci_devfn_t dev
, unsigned int cap
);
117 #else /* !__SIMPLE_DEVICE__ */
118 unsigned int pci_find_next_capability(device_t dev
, unsigned int cap
,
120 unsigned int pci_find_capability(device_t dev
, unsigned int cap
);
121 #endif /* __SIMPLE_DEVICE__ */
123 void pci_early_bridge_init(void);
124 int pci_early_device_probe(u8 bus
, u8 dev
, u32 mmio_base
);
127 static inline int pci_base_address_is_memory_space(unsigned int attr
)
129 return (attr
& PCI_BASE_ADDRESS_SPACE
) == PCI_BASE_ADDRESS_SPACE_MEMORY
;
133 #endif /* CONFIG_PCI */