2 * This file is part of the coreboot project.
4 * Copyright (C) 2009 One Laptop per Child, Association, Inc.
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; version 2 of the License.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 static const u8 RefreshCounter[7][2] = {
21 //Non_256Mbit, 256Mbit
22 {0xCA, 0xA8}, // DRAM400
23 {0xCA, 0xA8}, // DRAM333
24 {0xCA, 0x86}, // DRAM266
25 {0xCA, 0x65}, // DRAM200
26 {0xA8, 0x54}, // DRAM166
27 {0x86, 0x43}, // DRAM133
28 {0x65, 0x32} // DRAM100
31 void DRAMRefreshCounter(DRAM_SYS_ATTR * DramAttr)
34 u8 Freq = 5, i, Dram_256_Mb;
35 if (DramAttr->DramFreq == DIMMFREQ_800)
37 else if (DramAttr->DramFreq == DIMMFREQ_667)
39 else if (DramAttr->DramFreq == DIMMFREQ_533)
41 else if (DramAttr->DramFreq == DIMMFREQ_400)
43 else if (DramAttr->DramFreq == DIMMFREQ_333)
45 else if (DramAttr->DramFreq == DIMMFREQ_266)
47 else if (DramAttr->DramFreq == DIMMFREQ_200)
53 for (i = 0; i < MAX_SOCKETS; i++) {
54 if (DramAttr->DimmInfo[i].SPDDataBuf[SPD_SDRAM_ROW_ADDR] == 13) {
60 Data = RefreshCounter[Freq][Dram_256_Mb];
62 pci_write_config8(MEMCTRL, 0x6a, Data);
65 /*===================================================================
66 Function : DRAMRegFinalValue()
69 DramAttr: pointer point to DRAM_SYS_ATTR which consist the DDR and Dimm information
72 Purpose : Chipset Performance UP and other setting after DRAM Sizing
73 Turn on register directly to promote performance
74 ===================================================================*/
76 //--------------------------------------------------------------------------
78 //--------------------------------------------------------------------------
79 #define DRAM_table_item 9
80 static const u8 DRAM_table[DRAM_table_item][3] = {
82 {0x66, 0xcf, 0x80}, // DRAMC queue > 2
83 {0x69, 0xff, 0x07}, // Enable multiple page
92 #define PM_table_item 5
93 static const u8 PM_table[PM_table_item][3] = {
101 void DRAMRegFinalValue(DRAM_SYS_ATTR * DramAttr)
106 for (i = 0; i < DRAM_table_item; i++) {
107 Data = pci_read_config8(MEMCTRL, DRAM_table[i][0]);
108 Data = (u8) ((Data & DRAM_table[i][1]) | DRAM_table[i][2]);
109 pci_write_config8(MEMCTRL, DRAM_table[i][0], Data);
112 //enable dram By-Rank self refresh
113 Data = pci_read_config8(MEMCTRL, 0x96);
115 for (i = 0x01; i < 0x10; i = i << 1) {
116 if ((DramAttr->RankPresentMap & i) != 0x00)
119 pci_write_config8(MEMCTRL, 0x96, Data);
121 for (i = 0; i < PM_table_item; i++) {
122 Data = pci_read_config8(PCI_DEV(0, 0, 4), PM_table[i][0]);
123 Data = (u8) ((Data & PM_table[i][1]) | PM_table[i][2]);
124 pci_write_config8(PCI_DEV(0, 0, 4), PM_table[i][0], Data);