summaryrefslogtreecommitdiff
path: root/cpu/arm920t/wmt/vpci.c
blob: 76d2ef4cb48875959f1ce5b0c66b65743a03f564 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/*++ 
Copyright (c) 2010 WonderMedia Technologies, Inc.

This program is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software 
Foundation, either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.  See the GNU General Public License for more details. You
should have received a copy of the GNU General Public License along with this
program. If not, see http://www.gnu.org/licenses/>.

WonderMedia Technologies, Inc.
10F, 529, Chung-Cheng Road, Hsin-Tien, Taipei 231, R.O.C.
--*/


#if !defined(__UPC_H__)
#include "upc.h"
#endif
#if !defined(__MAC_H__)
#include "mac.h"
#endif
#if !defined(__VPCI_H__)
#include "vpci.h"
#endif

#if !defined(__PCINET_H__)
#include "pcinet.h"
#endif

/*---------------------  Static Definitions -------------------------*/

/*---------------------  Static Classes  ----------------------------*/

/*---------------------  Static Variables  --------------------------*/

/*---------------------  Static Functions  --------------------------*/

/*---------------------  Export Variables  --------------------------*/

/*---------------------  Export Functions  --------------------------*/
VOID
VPCIvInitialize(
    DWORD   dwIoBase,
    BYTE    byRevId
    )
{
    /* PATCH.... turn this on to avoid retry forever */
    VPCIvRegBitsOn(dwIoBase, PCI_REG_MODE2, MODE2_PCEROPT);
    /* PATCH.... */
    /* for some legacy BIOS and OS don't open BusM */
    /* bit in PCI configuration space. So, turn it on. */
    VPCIvRegBitsOn(dwIoBase, PCI_REG_COMMAND, COMMAND_BUSM);
    /* PATCH.... turn this on to detect MII coding error */
    VPCIvRegBitsOn(dwIoBase, PCI_REG_MODE3, MODE3_MIION);
}

VOID
VPCIvReadB(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    PBYTE   pbyData
    )
{
    DWORD   dwPCICfgAddr;


    dwPCICfgAddr = dwIoBase + PCI_CFG_SPACE_OFFSET;
    VNSvInPortB(dwPCICfgAddr + byRegOffset, pbyData);
}

VOID
VPCIvReadW(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    PWORD   pwData
    )
{
    DWORD   dwPCICfgAddr;


    dwPCICfgAddr = dwIoBase + PCI_CFG_SPACE_OFFSET;
    VNSvInPortW(dwPCICfgAddr + byRegOffset, pwData);
}

VOID
VPCIvReadD(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    PDWORD   pdwData
    )
{
    DWORD   dwPCICfgAddr;


    dwPCICfgAddr = dwIoBase + PCI_CFG_SPACE_OFFSET;
    VNSvInPortD(dwPCICfgAddr + byRegOffset, pdwData);
}

VOID
VPCIvRegBitsOn(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    BYTE    byBits
    )
{
    BYTE    byOrgData;


    VPCIvReadB(dwIoBase, byRegOffset, &byOrgData);
    VPCIvWriteB(dwIoBase, byRegOffset, (BYTE)(byOrgData | byBits));
}

VOID
VPCIvRegBitsOff(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    BYTE    byBits
    )
{
    BYTE    byOrgData;


    VPCIvReadB(dwIoBase, byRegOffset, &byOrgData);
    VPCIvWriteB(dwIoBase, byRegOffset, (BYTE)(byOrgData & ~byBits));
}

VOID
VPCIvWriteB(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    BYTE    byData
    )
{
    DWORD   dwPCICfgAddr;


    dwPCICfgAddr = dwIoBase + PCI_CFG_SPACE_OFFSET;
    VNSvOutPortB(dwPCICfgAddr + byRegOffset, byData);
}

VOID
VPCIvWriteW(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    WORD    wData
    )
{
    DWORD   dwPCICfgAddr;


    dwPCICfgAddr = dwIoBase + PCI_CFG_SPACE_OFFSET;
    VNSvOutPortW(dwPCICfgAddr + byRegOffset, wData);
}

VOID
VPCIvWriteD(
    DWORD   dwIoBase,
    BYTE    byRegOffset,
    DWORD    dwData
    )
{
    DWORD   dwPCICfgAddr;


    dwPCICfgAddr = dwIoBase + PCI_CFG_SPACE_OFFSET;
    VNSvOutPortD(dwPCICfgAddr + byRegOffset, dwData);
}