1
2
3
4
5
6
7
8
9
10
11
12#include <linux/sched.h>
13#include <linux/kernel.h>
14#include <linux/param.h>
15#include <linux/interrupt.h>
16#include <linux/init.h>
17#include <linux/irq.h>
18#include <linux/pci.h>
19#include <linux/module.h>
20#include <linux/io.h>
21#include <mach/pci.h>
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39static int gapspci_config_access(unsigned char bus, unsigned int devfn)
40{
41 return (bus == 0) && (devfn == 0);
42}
43
44
45
46
47
48
49static int gapspci_read(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 *val)
50{
51 *val = 0xffffffff;
52
53 if (!gapspci_config_access(bus->number, devfn))
54 return PCIBIOS_DEVICE_NOT_FOUND;
55
56 switch (size) {
57 case 1: *val = inb(GAPSPCI_BBA_CONFIG+where); break;
58 case 2: *val = inw(GAPSPCI_BBA_CONFIG+where); break;
59 case 4: *val = inl(GAPSPCI_BBA_CONFIG+where); break;
60 }
61
62 return PCIBIOS_SUCCESSFUL;
63}
64
65static int gapspci_write(struct pci_bus *bus, unsigned int devfn, int where, int size, u32 val)
66{
67 if (!gapspci_config_access(bus->number, devfn))
68 return PCIBIOS_DEVICE_NOT_FOUND;
69
70 switch (size) {
71 case 1: outb(( u8)val, GAPSPCI_BBA_CONFIG+where); break;
72 case 2: outw((u16)val, GAPSPCI_BBA_CONFIG+where); break;
73 case 4: outl((u32)val, GAPSPCI_BBA_CONFIG+where); break;
74 }
75
76 return PCIBIOS_SUCCESSFUL;
77}
78
79struct pci_ops gapspci_pci_ops = {
80 .read = gapspci_read,
81 .write = gapspci_write,
82};
83