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.
16 static const u8 RefreshCounter
[7][2] = {
17 //Non_256Mbit, 256Mbit
18 {0xCA, 0xA8}, // DRAM400
19 {0xCA, 0xA8}, // DRAM333
20 {0xCA, 0x86}, // DRAM266
21 {0xCA, 0x65}, // DRAM200
22 {0xA8, 0x54}, // DRAM166
23 {0x86, 0x43}, // DRAM133
24 {0x65, 0x32} // DRAM100
27 void DRAMRefreshCounter(DRAM_SYS_ATTR
* DramAttr
)
30 u8 Freq
= 5, i
, Dram_256_Mb
;
31 if (DramAttr
->DramFreq
== DIMMFREQ_800
)
33 else if (DramAttr
->DramFreq
== DIMMFREQ_667
)
35 else if (DramAttr
->DramFreq
== DIMMFREQ_533
)
37 else if (DramAttr
->DramFreq
== DIMMFREQ_400
)
39 else if (DramAttr
->DramFreq
== DIMMFREQ_333
)
41 else if (DramAttr
->DramFreq
== DIMMFREQ_266
)
43 else if (DramAttr
->DramFreq
== DIMMFREQ_200
)
49 for (i
= 0; i
< MAX_SOCKETS
; i
++) {
50 if (DramAttr
->DimmInfo
[i
].SPDDataBuf
[SPD_SDRAM_ROW_ADDR
] == 13) {
56 Data
= RefreshCounter
[Freq
][Dram_256_Mb
];
58 pci_write_config8(MEMCTRL
, 0x6a, Data
);
61 /*===================================================================
62 Function : DRAMRegFinalValue()
65 DramAttr: pointer point to DRAM_SYS_ATTR which consist the DDR and Dimm information
68 Purpose : Chipset Performance UP and other setting after DRAM Sizing
69 Turn on register directly to promote performance
70 ===================================================================*/
72 //--------------------------------------------------------------------------
74 //--------------------------------------------------------------------------
75 #define DRAM_table_item 9
76 static const u8 DRAM_table
[DRAM_table_item
][3] = {
78 {0x66, 0xcf, 0x80}, // DRAMC queue > 2
79 {0x69, 0xff, 0x07}, // Enable multiple page
88 #define PM_table_item 5
89 static const u8 PM_table
[PM_table_item
][3] = {
97 void DRAMRegFinalValue(DRAM_SYS_ATTR
* DramAttr
)
102 for (i
= 0; i
< DRAM_table_item
; i
++) {
103 Data
= pci_read_config8(MEMCTRL
, DRAM_table
[i
][0]);
104 Data
= (u8
) ((Data
& DRAM_table
[i
][1]) | DRAM_table
[i
][2]);
105 pci_write_config8(MEMCTRL
, DRAM_table
[i
][0], Data
);
108 //enable dram By-Rank self refresh
109 Data
= pci_read_config8(MEMCTRL
, 0x96);
111 for (i
= 0x01; i
< 0x10; i
= i
<< 1) {
112 if ((DramAttr
->RankPresentMap
& i
) != 0x00)
115 pci_write_config8(MEMCTRL
, 0x96, Data
);
117 for (i
= 0; i
< PM_table_item
; i
++) {
118 Data
= pci_read_config8(PCI_DEV(0, 0, 4), PM_table
[i
][0]);
119 Data
= (u8
) ((Data
& PM_table
[i
][1]) | PM_table
[i
][2]);
120 pci_write_config8(PCI_DEV(0, 0, 4), PM_table
[i
][0], Data
);