blob: a86c319a88b25b4a046c2d7ad48c3f032c5b2323 [file] [log] [blame]
Zheng Baoeb75f652010-04-23 17:32:48 +00001/*
2 * This file is part of the coreboot project.
3 *
4 * Copyright (C) 2010 Advanced Micro Devices, Inc.
Timothy Pearsonb8a355d2015-09-05 17:55:58 -05005 * Copyright (C) 2015 Timothy Pearson <tpearson@raptorengineeringinc.com>, Raptor Engineering
Zheng Baoeb75f652010-04-23 17:32:48 +00006 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; version 2 of the License.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
Zheng Baoeb75f652010-04-23 17:32:48 +000015 */
16
Zheng Bao69436e12011-01-06 02:18:12 +000017/* mct_SetDramConfigMisc2_Cx & mct_SetDramConfigMisc2_Dx */
Zheng Baoeb75f652010-04-23 17:32:48 +000018u32 mct_SetDramConfigMisc2(struct DCTStatStruc *pDCTstat, u8 dct, u32 misc2)
19{
20 u32 val;
21
22 if (pDCTstat->LogicalCPUID & (AMD_DR_Dx | AMD_DR_Cx)) {
23 if (pDCTstat->Status & (1 << SB_Registered)) {
24 misc2 |= 1 << SubMemclkRegDly;
25 if (mctGet_NVbits(NV_MAX_DIMMS) == 8)
26 misc2 |= 1 << Ddr3FourSocketCh;
27 else
28 misc2 &= ~(1 << Ddr3FourSocketCh);
29 }
30
31 if (pDCTstat->LogicalCPUID & AMD_DR_Cx)
32 misc2 |= 1 << OdtSwizzle;
Timothy Pearson730a0432015-10-16 13:51:51 -050033 val = Get_NB32_DCT(pDCTstat->dev_dct, dct, 0x78);
Zheng Baoeb75f652010-04-23 17:32:48 +000034
35 val &= 7;
Timothy Pearsonb8a355d2015-09-05 17:55:58 -050036 val = ((~val) & 0xff) + 1;
Zheng Baoeb75f652010-04-23 17:32:48 +000037 val += 6;
Timothy Pearsonb8a355d2015-09-05 17:55:58 -050038 val &= 0x7;
39 misc2 &= 0xfff8ffff;
Zheng Baoeb75f652010-04-23 17:32:48 +000040 misc2 |= val << 16; /* DataTxFifoWrDly */
Zheng Bao69436e12011-01-06 02:18:12 +000041 if (pDCTstat->LogicalCPUID & AMD_DR_Dx)
42 misc2 |= 1 << 7; /* ProgOdtEn */
Zheng Baoeb75f652010-04-23 17:32:48 +000043 }
44 return misc2;
45}
Zheng Bao69436e12011-01-06 02:18:12 +000046
47void mct_ExtMCTConfig_Cx(struct DCTStatStruc *pDCTstat)
48{
49 u32 val;
50
51 if (pDCTstat->LogicalCPUID & (AMD_DR_Cx)) {
Timothy Pearsonb8a355d2015-09-05 17:55:58 -050052 /* Revision C */
53 Set_NB32(pDCTstat->dev_dct, 0x11c, 0x0ce00fc0 | 1 << 29/* FlushWrOnStpGnt */);
Zheng Bao69436e12011-01-06 02:18:12 +000054
Timothy Pearsonb8a355d2015-09-05 17:55:58 -050055 val = Get_NB32(pDCTstat->dev_dct, 0x1b0);
56 val &= ~0x73f;
Zheng Bao69436e12011-01-06 02:18:12 +000057 val |= 0x101; /* BKDG recommended settings */
Timothy Pearsonb8a355d2015-09-05 17:55:58 -050058
59 Set_NB32(pDCTstat->dev_dct, 0x1b0, val);
Zheng Bao69436e12011-01-06 02:18:12 +000060 }
61}