23 #include <linux/types.h>
24 #include <linux/pci.h>
25 #include <linux/kernel.h>
33 static inline void clear_status(
void)
35 unsigned long pci_stat;
41 static inline unsigned int
53 config_access(
unsigned int pci_cmd,
struct pci_bus *bus,
unsigned int devfn,
int where,
unsigned int pci_mode,
unsigned int *
val)
56 unsigned long loops = 0;
57 unsigned long ioaddr = calc_cfg_addr(bus, devfn, where);
91 printk(
"%s : Arbiter Locked.\n", __func__);
97 printk(
"%s timeout (GPPM_CTRL=%X) ioaddr %lX pci_cmd %X\n",
113 read_config_byte(
struct pci_bus *bus,
unsigned int devfn,
int where,
u8 * val)
115 unsigned int data = 0;
122 switch (where & 0x03) {
124 *val = (
unsigned char)(data & 0x000000ff);
127 *val = (
unsigned char)((data & 0x0000ff00) >> 8);
130 *val = (
unsigned char)((data & 0x00ff0000) >> 16);
133 *val = (
unsigned char)((data & 0xff000000) >> 24);
141 read_config_word(
struct pci_bus *bus,
unsigned int devfn,
int where,
u16 * val)
143 unsigned int data = 0;
153 switch (where & 0x02) {
155 *val = (
unsigned short)(data & 0x0000ffff);
158 *val = (
unsigned short)((data & 0xffff0000) >> 16);
166 read_config_dword(
struct pci_bus *bus,
unsigned int devfn,
int where,
u32 * val)
181 write_config_byte(
struct pci_bus *bus,
unsigned int devfn,
int where,
u8 val)
183 unsigned int data = (
unsigned int)val;
189 switch (where & 0x03) {
209 write_config_word(
struct pci_bus *bus,
unsigned int devfn,
int where,
u16 val)
211 unsigned int data = (
unsigned int)val;
220 switch (where & 0x02) {
233 write_config_dword(
struct pci_bus *bus,
unsigned int devfn,
int where,
u32 val)
247 static int config_read(
struct pci_bus *bus,
unsigned int devfn,
int where,
int size,
u32 * val)
252 int rc = read_config_byte(bus, devfn, where, &_val);
258 int rc = read_config_word(bus, devfn, where, &_val);
263 return read_config_dword(bus, devfn, where, val);
267 static int config_write(
struct pci_bus *bus,
unsigned int devfn,
int where,
int size,
u32 val)
271 return write_config_byte(bus, devfn, where, (
u8) val);
273 return write_config_word(bus, devfn, where, (
u16) val);
275 return write_config_dword(bus, devfn, where, val);