80b8531eab84277f5f8bdf62dc1c1256bcb7c5de
[openwrt/svn-archive/archive.git] / target / linux / adm5120-2.6 / files / arch / mips / pci / ops-adm5120.c
1 /*
2 * Copyright (C) ADMtek Incorporated.
3 * Copyright (C) 2005 Jeroen Vreeken (pe1rxq@amsat.org)
4 */
5
6 #include <linux/autoconf.h>
7 #include <linux/types.h>
8 #include <linux/pci.h>
9 #include <linux/kernel.h>
10 #include <linux/init.h>
11
12 volatile u32* pci_config_address_reg = (volatile u32*)KSEG1ADDR(0x115ffff0);
13 volatile u32* pci_config_data_reg = (volatile u32*)KSEG1ADDR(0x115ffff8);
14
15 #define PCI_ENABLE 0x80000000
16
17 static int pci_config_read(struct pci_bus *bus, unsigned int devfn, int where,
18 int size, uint32_t *val)
19 {
20 *pci_config_address_reg = ((bus->number & 0xff) << 0x10) |
21 ((devfn & 0xff) << 0x08) | (where & 0xfc) | PCI_ENABLE;
22 switch (size) {
23 case 1:
24 *val = ((*pci_config_data_reg)>>((where&3)<<3))&0xff;
25 break;
26 case 2:
27 *val = ((*pci_config_data_reg)>>((where&3)<<3))&0xffff;
28 break;
29 default:
30 *val = (*pci_config_data_reg);
31 }
32 return PCIBIOS_SUCCESSFUL;
33 }
34
35 static int pci_config_write(struct pci_bus *bus, unsigned int devfn, int where,
36 int size, uint32_t val)
37 {
38 *pci_config_address_reg = ((bus->number & 0xff) << 0x10) |
39 ((devfn & 0xff) << 0x08) | (where & 0xfc) | PCI_ENABLE;
40 switch (size) {
41 case 1:
42 *(volatile u8 *)(((int)pci_config_data_reg) +
43 (where & 3)) = val;
44 break;
45 case 2:
46 *(volatile u16 *)(((int)pci_config_data_reg) +
47 (where & 2)) = (val);
48 break;
49 default:
50 *pci_config_data_reg = (val);
51 }
52
53 return PCIBIOS_SUCCESSFUL;
54 }
55
56 struct pci_ops adm5120_pci_ops = {
57 .read = pci_config_read,
58 .write = pci_config_write,
59 };