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
171
172
173
174
175
176
177
178
|
/*COPYRIGHT**
Copyright (C) 2005-2014 Intel Corporation. All Rights Reserved.
This file is part of SEP Development Kit
SEP Development Kit is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
version 2 as published by the Free Software Foundation.
SEP Development Kit 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 SEP Development Kit; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
As a special exception, you may use this file as part of a free software
library without restriction. Specifically, if other files instantiate
templates or use macros or inline functions from this file, or you compile
this file and link it with other files to produce an executable, this
file does not by itself cause the resulting executable to be covered by
the GNU General Public License. This exception does not however
invalidate any other reasons why the executable file might be covered by
the GNU General Public License.
**COPYRIGHT*/
#include "lwpmudrv_defines.h"
#include <linux/errno.h>
#include <linux/types.h>
#include <asm/page.h>
#include <asm/io.h>
#include "lwpmudrv_types.h"
#include "rise_errors.h"
#include "lwpmudrv_ecb.h"
#include "lwpmudrv_chipset.h"
#include "lwpmudrv.h"
#include "pci.h"
/* ------------------------------------------------------------------------- */
/*!
* @fn extern int PCI_Read_From_Memory_Address(addr, val)
*
* @param addr - physical address in mmio
* @param *value - value at this address
*
* @return status
*
* @brief Read memory mapped i/o physical location
*
*/
extern int
PCI_Read_From_Memory_Address (
U32 addr,
U32* val
)
{
U32 aligned_addr, offset, value;
PVOID base;
if (addr <= 0) {
return OS_INVALID;
}
SEP_PRINT_DEBUG("PCI_Read_From_Memory_Address: reading physcial address:%x\n",addr);
offset = addr & ~PAGE_MASK;
aligned_addr = addr & PAGE_MASK;
SEP_PRINT_DEBUG("PCI_Read_From_Memory_Address: aligned physcial address:%x,offset:%x\n",aligned_addr,offset);
base = ioremap_nocache(aligned_addr, PAGE_SIZE);
if (base == NULL) {
return OS_INVALID;
}
value = readl(base+offset);
*val = value;
SEP_PRINT_DEBUG("PCI_Read_From_Memory_Address: value at this physical address:%x\n",value);
iounmap(base);
return OS_SUCCESS;
}
/* ------------------------------------------------------------------------- */
/*!
* @fn extern int PCI_Write_To_Memory_Address(addr, val)
*
* @param addr - physical address in mmio
* @param value - value to be written
*
* @return status
*
* @brief Write to memory mapped i/o physical location
*
*/
extern int
PCI_Write_To_Memory_Address (
U32 addr,
U32 val
)
{
U32 aligned_addr, offset;
PVOID base;
if (addr <= 0) {
return OS_INVALID;
}
SEP_PRINT_DEBUG("PCI_Write_To_Memory_Address: writing physcial address:%x with value:%x\n",addr,val);
offset = addr & ~PAGE_MASK;
aligned_addr = addr & PAGE_MASK;
SEP_PRINT_DEBUG("PCI_Write_To_Memory_Address: aligned physcial address:%x,offset:%x\n",aligned_addr,offset);
base = ioremap_nocache(aligned_addr, PAGE_SIZE);
if (base == NULL) {
return OS_INVALID;
}
writel(val,base+offset);
iounmap(base);
return OS_SUCCESS;
}
/* ------------------------------------------------------------------------- */
/*!
* @fn extern int PCI_Read_Ulong(pci_address)
*
* @param pci_address - PCI configuration address
*
* @return value at this location
*
* @brief Reads a ULONG from PCI configuration space
*
*/
extern int
PCI_Read_Ulong (
U32 pci_address
)
{
U32 temp_ulong = 0;
outl(pci_address,PCI_ADDR_IO);
temp_ulong = inl(PCI_DATA_IO);
return temp_ulong;
}
/* ------------------------------------------------------------------------- */
/*!
* @fn extern int PCI_Write_Ulong(addr, val)
*
* @param pci_address - PCI configuration address
* @param value - Value to be written
*
* @return status
*
* @brief Writes a ULONG to PCI configuration space
*
*/
extern void
PCI_Write_Ulong (
U32 pci_address,
U32 value
)
{
outl(pci_address, PCI_ADDR_IO);
outl(value, PCI_DATA_IO);
return;
}
|