aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/edac/amd64_edac.h
diff options
context:
space:
mode:
authorBorislav Petkov <borislav.petkov@amd.com>2010-11-29 13:49:02 -0500
committerBorislav Petkov <borislav.petkov@amd.com>2011-03-17 09:46:12 -0400
commit11c75eadaf75fe6320325aa13dc135f26ad724b8 (patch)
treef55042eb1fbd039e7ab7323d00f23822414edac7 /drivers/edac/amd64_edac.h
parentbc21fa578742924aa129a493657f797c13d34ad2 (diff)
amd64_edac: Cleanup chipselect handling
Add a struct representing the DRAM chip select base/limit register pairs. Concentrate all CS handling in a single function. Also, add CS looping macros for cleaner, more readable code. While at it, adjust code to F15h. Finally, do smaller macro names cleanups (remove family names from register macros) and debug messages clarification. No functional change. Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>
Diffstat (limited to 'drivers/edac/amd64_edac.h')
-rw-r--r--drivers/edac/amd64_edac.h81
1 files changed, 25 insertions, 56 deletions
diff --git a/drivers/edac/amd64_edac.h b/drivers/edac/amd64_edac.h
index a2bc9a650fff..1964f89a28bc 100644
--- a/drivers/edac/amd64_edac.h
+++ b/drivers/edac/amd64_edac.h
@@ -160,6 +160,14 @@
160#define OFF false 160#define OFF false
161 161
162/* 162/*
163 * Create a contiguous bitmask starting at bit position @lo and ending at
164 * position @hi. For example
165 *
166 * GENMASK(21, 39) gives us the 64bit vector 0x000000ffffe00000.
167 */
168#define GENMASK(lo, hi) (((1ULL << ((hi) - (lo) + 1)) - 1) << (lo))
169
170/*
163 * PCI-defined configuration space registers 171 * PCI-defined configuration space registers
164 */ 172 */
165 173
@@ -198,45 +206,14 @@
198/* 206/*
199 * Function 2 - DRAM controller 207 * Function 2 - DRAM controller
200 */ 208 */
201#define K8_DCSB0 0x40 209#define DCSB0 0x40
202#define F10_DCSB1 0x140 210#define DCSB1 0x140
203 211#define DCSB_CS_ENABLE BIT(0)
204#define K8_DCSB_CS_ENABLE BIT(0)
205#define K8_DCSB_NPT_SPARE BIT(1)
206#define K8_DCSB_NPT_TESTFAIL BIT(2)
207
208/*
209 * REV E: select [31:21] and [15:9] from DCSB and the shift amount to form
210 * the address
211 */
212#define REV_E_DCSB_BASE_BITS (0xFFE0FE00ULL)
213#define REV_E_DCS_SHIFT 4
214
215#define REV_F_F1Xh_DCSB_BASE_BITS (0x1FF83FE0ULL)
216#define REV_F_F1Xh_DCS_SHIFT 8
217
218/*
219 * REV F and later: selects [28:19] and [13:5] from DCSB and the shift amount
220 * to form the address
221 */
222#define REV_F_DCSB_BASE_BITS (0x1FF83FE0ULL)
223#define REV_F_DCS_SHIFT 8
224
225/* DRAM CS Mask Registers */
226#define K8_DCSM0 0x60
227#define F10_DCSM1 0x160
228
229/* REV E: select [29:21] and [15:9] from DCSM */
230#define REV_E_DCSM_MASK_BITS 0x3FE0FE00
231
232/* unused bits [24:20] and [12:0] */
233#define REV_E_DCS_NOTUSED_BITS 0x01F01FFF
234 212
235/* REV F and later: select [28:19] and [13:5] from DCSM */ 213#define DCSM0 0x60
236#define REV_F_F1Xh_DCSM_MASK_BITS 0x1FF83FE0 214#define DCSM1 0x160
237 215
238/* unused bits [26:22] and [12:0] */ 216#define csrow_enabled(i, dct, pvt) ((pvt)->csels[(dct)].csbases[(i)] & DCSB_CS_ENABLE)
239#define REV_F_F1Xh_DCS_NOTUSED_BITS 0x07C01FFF
240 217
241#define DBAM0 0x80 218#define DBAM0 0x80
242#define DBAM1 0x180 219#define DBAM1 0x180
@@ -412,6 +389,15 @@ struct dram_range {
412 struct reg_pair lim; 389 struct reg_pair lim;
413}; 390};
414 391
392/* A DCT chip selects collection */
393struct chip_select {
394 u32 csbases[NUM_CHIPSELECTS];
395 u8 b_cnt;
396
397 u32 csmasks[NUM_CHIPSELECTS];
398 u8 m_cnt;
399};
400
415struct amd64_pvt { 401struct amd64_pvt {
416 struct low_ops *ops; 402 struct low_ops *ops;
417 403
@@ -434,29 +420,12 @@ struct amd64_pvt {
434 u32 dbam0; /* DRAM Base Address Mapping reg for DCT0 */ 420 u32 dbam0; /* DRAM Base Address Mapping reg for DCT0 */
435 u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */ 421 u32 dbam1; /* DRAM Base Address Mapping reg for DCT1 */
436 422
437 /* DRAM CS Base Address Registers F2x[1,0][5C:40] */ 423 /* one for each DCT */
438 u32 dcsb0[NUM_CHIPSELECTS]; 424 struct chip_select csels[2];
439 u32 dcsb1[NUM_CHIPSELECTS];
440
441 /* DRAM CS Mask Registers F2x[1,0][6C:60] */
442 u32 dcsm0[NUM_CHIPSELECTS];
443 u32 dcsm1[NUM_CHIPSELECTS];
444 425
445 /* DRAM base and limit pairs F1x[78,70,68,60,58,50,48,40] */ 426 /* DRAM base and limit pairs F1x[78,70,68,60,58,50,48,40] */
446 struct dram_range ranges[DRAM_RANGES]; 427 struct dram_range ranges[DRAM_RANGES];
447 428
448 /*
449 * The following fields are set at (load) run time, after CPU revision
450 * has been determined, since the dct_base and dct_mask registers vary
451 * based on revision
452 */
453 u32 dcsb_base; /* DCSB base bits */
454 u32 dcsm_mask; /* DCSM mask bits */
455 u32 cs_count; /* num chip selects (== num DCSB registers) */
456 u32 num_dcsm; /* Number of DCSM registers */
457 u32 dcs_mask_notused; /* DCSM notused mask bits */
458 u32 dcs_shift; /* DCSB and DCSM shift value */
459
460 u64 top_mem; /* top of memory below 4GB */ 429 u64 top_mem; /* top of memory below 4GB */
461 u64 top_mem2; /* top of memory above 4GB */ 430 u64 top_mem2; /* top of memory above 4GB */
462 431