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