aboutsummaryrefslogtreecommitdiff
path: root/src/northbridge/amd/amdmct/mct_ddr3/modtrd.c
blob: 2904cfb3ad84b316ccd297397a320e669aa8c09d (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
/*
 * This file is part of the coreboot project.
 *
 * Copyright (C) 2010 Advanced Micro Devices, 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; 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.
 */

#include <inttypes.h>

#include "mct_d.h"
#include "mct_d_gcc.h"

u32 mct_MR1Odt_RDimm(struct MCTStatStruc *pMCTstat,
				struct DCTStatStruc *pDCTstat, u8 dct, u32 MrsChipSel)
{
	u8 Speed = pDCTstat->Speed;
	u32 ret;
	u8 DimmsInstalled, DimmNum, ChipSelect;

	ChipSelect = (MrsChipSel >> 20) & 0xF;
	DimmNum = ChipSelect & 0xFE;
	DimmsInstalled = pDCTstat->MAdimms[dct];
	if (dct == 1)
		DimmNum ++;
	ret = 0;

	if (mctGet_NVbits(NV_MAX_DIMMS) == 4) {
		if (DimmsInstalled == 1)
			ret |= 1 << 2;
		else {
			if (pDCTstat->CSPresent & 0xF0) {
				if (pDCTstat->DimmQRPresent & (1 << DimmNum)) {
					if (!(ChipSelect & 1))
						ret |= 1 << 2;
				} else
					ret |= 0x204;
			} else {
				if (Speed < 6)
					ret |= 0x44;
				else
					ret |= 0x204;
			}
		}
	} else if (DimmsInstalled == 1)
		ret |= 1 << 2;
	else if (Speed < 6)
		ret |= 0x44;
	else
		ret |= 0x204;

	//ret = 0;
	return ret;
}

u32 mct_DramTermDyn_RDimm(struct MCTStatStruc *pMCTstat,
				struct DCTStatStruc *pDCTstat, u8 dimm)
{
	u8 DimmsInstalled = dimm;
	u32 DramTermDyn = 0;
	u8 Speed = pDCTstat->Speed;

	if (mctGet_NVbits(NV_MAX_DIMMS) == 4) {
		if (pDCTstat->CSPresent & 0xF0) {
			if (DimmsInstalled == 1)
				if (Speed == 7)
					DramTermDyn |= 1 << 10;
				else
					DramTermDyn |= 1 << 11;
			else
				if (Speed == 4)
					DramTermDyn |= 1 << 11;
				else
					DramTermDyn |= 1 << 10;
		} else {
			if (DimmsInstalled != 1) {
				if (Speed == 7)
					DramTermDyn |= 1 << 10;
				else
					DramTermDyn |= 1 << 11;
			}
		}
	} else {
		if (DimmsInstalled != 1)
			DramTermDyn |= 1 << 11;
	}
	return DramTermDyn;
}