Kernel/armv7 - Renamed to reduce confusion
[tpg/acess2.git] / Kernel / arch / armv7 / pci.c
1 /*
2  *
3  */
4 #include <acess.h>
5
6 // Realview
7 //#define PCI_BASE      0x60000000
8
9 //#define PCI_BASE      0xF0400000      // VMM Mapping
10 #define PCI_BASE        0
11
12 // === PROTOTYPES ===
13 #if 1
14 void    PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data);
15 Uint32  PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);
16 Uint16  PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);
17 Uint8   PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset);
18 #endif
19
20 // === CODE ===
21 void PCI_CfgWriteDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset, Uint32 data)
22 {
23         #if PCI_BASE
24         Uint32  address = PCI_BASE | ((Uint)bus<<16) | ((Uint)dev<<11) | ((Uint)func<<8) | (offset&0xFC);
25         *(Uint32*)(address) = data;
26         #else
27         #endif
28 }
29
30 Uint32 PCI_CfgReadDWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset)
31 {
32         #if PCI_BASE
33         Uint32  address = PCI_BASE | ((Uint)bus<<16) | ((Uint)dev<<11) | ((Uint)func<<8) | (offset&0xFC);
34         return *(Uint32*)address;
35         #else
36         return 0xFFFFFFFF;
37         #endif
38 }
39
40 Uint16 PCI_CfgReadWord(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset)
41 {
42         return PCI_CfgReadDWord(bus, dev, func, offset & ~3) >> (8*(offset&2));
43 }
44
45 Uint8 PCI_CfgReadByte(Uint16 bus, Uint16 dev, Uint16 func, Uint16 offset)
46 {
47         return PCI_CfgReadDWord(bus, dev, func, offset & ~3) >> (8*(offset&3));
48 }

UCC git Repository :: git.ucc.asn.au