22 #include <linux/types.h>
23 #include <linux/pci.h>
24 #include <linux/kernel.h>
29 #define PCI_ACCESS_READ 0
30 #define PCI_ACCESS_WRITE 1
32 #define CFG_SPACE_REG(offset) (void *)CKSEG1ADDR(_pcictrl_bonito_pcicfg + (offset))
33 #define ID_SEL_BEGIN 10
34 #define MAX_DEV_NUM (31 - ID_SEL_BEGIN)
37 static int bonito64_pcibios_config_access(
unsigned char access_type,
39 unsigned int devfn,
int where,
55 addr = (1 << (device +
ID_SEL_BEGIN)) | (
function << 8) | reg;
59 addr = (busnum << 16) | (device << 11) | (
function << 8) | reg;
102 static int bonito64_pcibios_read(
struct pci_bus *
bus,
unsigned int devfn,
107 if ((size == 2) && (where & 1))
109 else if ((size == 4) && (where & 3))
117 *val = (data >> ((where & 3) << 3)) & 0xff;
119 *val = (data >> ((where & 3) << 3)) & 0xffff;
126 static int bonito64_pcibios_write(
struct pci_bus *bus,
unsigned int devfn,
127 int where,
int size,
u32 val)
131 if ((size == 2) && (where & 1))
133 else if ((size == 4) && (where & 3))
144 data = (data & ~(0xff << ((where & 3) << 3))) |
145 (val << ((where & 3) << 3));
147 data = (data & ~(0xffff << ((where & 3) << 3))) |
148 (val << ((where & 3) << 3));
159 .read = bonito64_pcibios_read,
160 .write = bonito64_pcibios_write