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
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
|
/*
* This file is part of the coreboot project.
*
* Copyright (C) 2010 Advanced Micro Devices, Inc.
* Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
*
* 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; version 2 of the License.
*
* 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.
*/
#ifndef __SR5650_CMN_H__
#define __SR5650_CMN_H__
#include <device/pci_ops.h>
#define NBMISC_INDEX 0x60
#define NBHTIU_INDEX 0x94 /* Note: It is different with RS690, whose HTIU index is 0xA8 */
#define NBMC_INDEX 0xE8
#define NBPCIE_INDEX 0xE0
#define L2CFG_INDEX 0xF0
#define L1CFG_INDEX 0xF8
#define EXT_CONF_BASE_ADDRESS CONFIG_MMCONF_BASE_ADDRESS
#define TEMP_MMIO_BASE_ADDRESS 0xC0000000
#define axindxc_reg(reg, mask, val) \
alink_ax_indx(0, (reg), (mask), (val))
#define AB_INDX 0xCD8
#define AB_DATA (AB_INDX+4)
#ifdef __SIMPLE_DEVICE__
static inline u32 nb_read_index(pci_devfn_t dev, u32 index_reg, u32 index)
#else
static inline u32 nb_read_index(struct device *dev, u32 index_reg, u32 index)
#endif
{
pci_write_config32(dev, index_reg, index);
return pci_read_config32(dev, index_reg + 0x4);
}
#ifdef __SIMPLE_DEVICE__
static inline void nb_write_index(pci_devfn_t dev, u32 index_reg, u32 index,
u32 data)
#else
static inline void nb_write_index(struct device *dev, u32 index_reg, u32 index,
u32 data)
#endif
{
pci_write_config32(dev, index_reg, index);
pci_write_config32(dev, index_reg + 0x4, data);
}
#ifdef __SIMPLE_DEVICE__
static inline u32 nbmisc_read_index(pci_devfn_t nb_dev, u32 index)
#else
static inline u32 nbmisc_read_index(struct device *nb_dev, u32 index)
#endif
{
return nb_read_index((nb_dev), NBMISC_INDEX, (index));
}
#ifdef __SIMPLE_DEVICE__
static inline void nbmisc_write_index(pci_devfn_t nb_dev, u32 index, u32 data)
#else
static inline void nbmisc_write_index(struct device *nb_dev, u32 index,
u32 data)
#endif
{
nb_write_index((nb_dev), NBMISC_INDEX, ((index) | 0x80), (data));
}
#ifdef __SIMPLE_DEVICE__
static inline void set_nbmisc_enable_bits(pci_devfn_t nb_dev, u32 reg_pos,
u32 mask, u32 val)
#else
static inline void set_nbmisc_enable_bits(struct device *nb_dev, u32 reg_pos,
u32 mask, u32 val)
#endif
{
u32 reg_old, reg;
reg = reg_old = nbmisc_read_index(nb_dev, reg_pos);
reg &= ~mask;
reg |= val;
if (reg != reg_old) {
nbmisc_write_index(nb_dev, reg_pos, reg);
}
}
#ifdef __SIMPLE_DEVICE__
static inline u32 htiu_read_index(pci_devfn_t nb_dev, u32 index)
#else
static inline u32 htiu_read_index(struct device *nb_dev, u32 index)
#endif
{
return nb_read_index((nb_dev), NBHTIU_INDEX, (index));
}
#ifdef __SIMPLE_DEVICE__
static inline void htiu_write_index(pci_devfn_t nb_dev, u32 index, u32 data)
#else
static inline void htiu_write_index(struct device *nb_dev, u32 index, u32 data)
#endif
{
nb_write_index((nb_dev), NBHTIU_INDEX, ((index) | 0x100), (data));
}
#ifdef __SIMPLE_DEVICE__
static inline u32 nbmc_read_index(pci_devfn_t nb_dev, u32 index)
#else
static inline u32 nbmc_read_index(struct device *nb_dev, u32 index)
#endif
{
return nb_read_index((nb_dev), NBMC_INDEX, (index));
}
#ifdef __SIMPLE_DEVICE__
static inline void nbmc_write_index(pci_devfn_t nb_dev, u32 index, u32 data)
#else
static inline void nbmc_write_index(struct device *nb_dev, u32 index, u32 data)
#endif
{
nb_write_index((nb_dev), NBMC_INDEX, ((index) | 1 << 9), (data));
}
#ifdef __SIMPLE_DEVICE__
static inline void set_htiu_enable_bits(pci_devfn_t nb_dev, u32 reg_pos,
u32 mask, u32 val)
#else
static inline void set_htiu_enable_bits(struct device *nb_dev, u32 reg_pos,
u32 mask, u32 val)
#endif
{
u32 reg_old, reg;
reg = reg_old = htiu_read_index(nb_dev, reg_pos);
reg &= ~mask;
reg |= val;
if (reg != reg_old) {
htiu_write_index(nb_dev, reg_pos, reg);
}
}
#ifdef __SIMPLE_DEVICE__
static inline void set_nbcfg_enable_bits(pci_devfn_t nb_dev, u32 reg_pos,
u32 mask, u32 val)
#else
static inline void set_nbcfg_enable_bits(struct device *nb_dev, u32 reg_pos,
u32 mask, u32 val)
#endif
{
u32 reg_old, reg;
reg = reg_old = pci_read_config32(nb_dev, reg_pos);
reg &= ~mask;
reg |= val;
if (reg != reg_old) {
pci_write_config32(nb_dev, reg_pos, reg);
}
}
#ifdef __SIMPLE_DEVICE__
static inline void set_nbcfg_enable_bits_8(pci_devfn_t nb_dev, u32 reg_pos,
u8 mask, u8 val)
#else
static inline void set_nbcfg_enable_bits_8(struct device *nb_dev, u32 reg_pos,
u8 mask, u8 val)
#endif
{
u8 reg_old, reg;
reg = reg_old = pci_read_config8(nb_dev, reg_pos);
reg &= ~mask;
reg |= val;
if (reg != reg_old) {
pci_write_config8(nb_dev, reg_pos, reg);
}
}
#ifdef __SIMPLE_DEVICE__
static inline void set_nbmc_enable_bits(pci_devfn_t nb_dev, u32 reg_pos,
u32 mask, u32 val)
#else
static inline void set_nbmc_enable_bits(struct device *nb_dev, u32 reg_pos,
u32 mask, u32 val)
#endif
{
u32 reg_old, reg;
reg = reg_old = nbmc_read_index(nb_dev, reg_pos);
reg &= ~mask;
reg |= val;
if (reg != reg_old) {
nbmc_write_index(nb_dev, reg_pos, reg);
}
}
#ifdef __SIMPLE_DEVICE__
static inline void set_pcie_enable_bits(pci_devfn_t dev, u32 reg_pos, u32 mask,
u32 val)
#else
static inline void set_pcie_enable_bits(struct device *dev, u32 reg_pos,
u32 mask, u32 val)
#endif
{
u32 reg_old, reg;
reg = reg_old = nb_read_index(dev, NBPCIE_INDEX, reg_pos);
reg &= ~mask;
reg |= val;
if (reg != reg_old) {
nb_write_index(dev, NBPCIE_INDEX, reg_pos, reg);
}
}
void set_pcie_reset(void);
void set_pcie_dereset(void);
#endif /* __SR5650_CMN_H__ */
|