Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2009 One Laptop per Child, Association, Inc. |
| 5 | * |
| 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; either version 2 of the License, or |
| 9 | * (at your option) any later version. |
| 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. |
| 15 | * |
| 16 | * You should have received a copy of the GNU General Public License |
| 17 | * along with this program; if not, write to the Free Software |
| 18 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
| 19 | */ |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 20 | |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 21 | #include "northbridge/via/vx800/DrivingClkPhaseData.h" |
| 22 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 23 | // DQS Driving |
| 24 | // Reg0xE0, 0xE1 |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 25 | // According to #Bank to set DRAM DQS Driving |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 26 | // #Bank 1 2 3 4 5 6 7 8 |
| 27 | static const u8 DDR2_DQSA_Driving_Table[4] = { 0xEE, 0xEE, 0xEE, 0xEE }; |
| 28 | static const u8 DDR2_DQSB_Driving_Table[2] = { 0xEE, 0xEE }; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 29 | |
| 30 | // DQ Driving |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 31 | // Reg0xE2, 0xE3 |
| 32 | // For DDR2: According to bank to set DRAM DQ Driving |
| 33 | static const u8 DDR2_DQA_Driving_Table[4] = { 0xAC, 0xAC, 0xAC, 0xAC }; |
| 34 | static const u8 DDR2_DQB_Driving_Table[2] = { 0xCA, 0xCA }; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 35 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 36 | // CS Driving |
| 37 | // Reg0xE4, 0xE5 |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 38 | // According to #Bank to set DRAM CS Driving |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 39 | // DDR1 #Bank 1 2 3 4 5 6 7 8 |
| 40 | static const u8 DDR2_CSA_Driving_Table_x8[4] = { 0x44, 0x44, 0x44, 0x44 }; |
| 41 | static const u8 DDR2_CSB_Driving_Table_x8[2] = { 0x44, 0x44 }; |
| 42 | static const u8 DDR2_CSA_Driving_Table_x16[4] = { 0x44, 0x44, 0x44, 0x44 }; |
| 43 | static const u8 DDR2_CSB_Driving_Table_x16[2] = { 0x44, 0x44 }; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 44 | |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 45 | // MAA Driving |
| 46 | // Reg0xE8, Reg0xE9 |
| 47 | static const u8 DDR2_MAA_Driving_Table[MA_Table][5] = { |
| 48 | // Chip number, 400, 533, 667 800 ;(SRAS, SCAS, SWE)RxE8 |
| 49 | {6, 0x86, 0x86, 0x86, 0x86}, // total MAA chips = 00 ~ 06 |
| 50 | {18, 0x86, 0x86, 0x86, 0x86}, // total MAA chips = 06 ~ 18 |
| 51 | {255, 0xDB, 0xDB, 0xDB, 0xDB}, // total MAA chips = 18 ~ |
| 52 | }; |
| 53 | |
| 54 | static const u8 DDR2_MAB_Driving_Table[MA_Table][2] = { |
| 55 | // Chip number, Value ;(SRAS, SCAS, SWE)RxE9 |
| 56 | {6, 0x86}, // total MAB chips = 00 ~ 06 |
| 57 | {18, 0x86}, // total MAB chips = 06 ~ 18 |
| 58 | {255, 0xDB}, // total MAB chips = 18 ~ |
| 59 | }; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 60 | |
| 61 | // DCLK Driving |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 62 | // Reg0xE6, 0xE7 |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 63 | // For DDR2: According to #Freq to set DRAM DCLK Driving |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 64 | // freq 400M, 533M, 667M, 800M |
| 65 | static const u8 DDR2_DCLKA_Driving_Table[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; |
| 66 | static const u8 DDR2_DCLKB_Driving_Table[4] = { 0xFF, 0xFF, 0xFF, 0xFF }; |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 67 | |
| 68 | /* |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 69 | * Duty cycle |
| 70 | * Duty cycle Control for DQ/DQS/DDRCKG in ChA & ChB |
| 71 | * D0F3RxEC/D0F3RxED/D0F3RxEE/D0F3RxEF |
| 72 | * According to DRAM frequency to control Duty Cycle |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 73 | */ |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 74 | static const u8 ChA_Duty_Control_DDR2[DUTY_CYCLE_REG_NUM][DUTY_CYCLE_FREQ_NUM] = { |
| 75 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 76 | //Reg Mask Value Value Value Value |
| 77 | {0xEC, 0x00, 0x30, 0x30, 0x30, 0x30}, // 1Rank |
| 78 | {0xEE, 0x0F, 0x40, 0x40, 0x00, 0x00}, |
| 79 | {0xEF, 0xCF, 0x00, 0x30, 0x30, 0x30}, |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 80 | }; |
Uwe Hermann | 0ffff34 | 2009-06-07 13:46:50 +0000 | [diff] [blame^] | 81 | |
| 82 | static const u8 ChB_Duty_Control_DDR2[DUTY_CYCLE_REG_NUM][DUTY_CYCLE_FREQ_NUM] = { |
| 83 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 84 | //Reg Mask Value Value Value Value |
| 85 | {0xED, 0x00, 0x88, 0x88, 0x84, 0x88}, // 1Rank |
| 86 | {0xEE, 0xF0, 0x00, 0x00, 0x00, 0x00}, |
| 87 | {0xEF, 0xFC, 0x00, 0x00, 0x00, 0x00}, |
| 88 | }; |
| 89 | |
| 90 | /* |
| 91 | * DRAM Clock Phase Control for FeedBack Mode |
| 92 | * Modify NB Reg: Rx90[7]/Rx91/Rx92/Rx93/Rx94 |
| 93 | * Processing: |
| 94 | * 1. Program VIA_NB3DRAM_REG90[7]=0b for FeedBack mode. |
| 95 | * 2. Program clock phase value with ChA/B DCLK enable, |
| 96 | * VIA_NB3DRAM_REG91[7:3]=00b |
| 97 | * 3. Check ChB rank #, if 0, VIA_NB3DRAM_REG91[7]=1b, to disable ChB DCLKO |
| 98 | * ChA DCLKO can't be disabled, so always program VIA_NB3DRAM_REG91[3]=0b. |
| 99 | */ |
| 100 | static const u8 DDR2_ChA_Clk_Phase_Table_1R[3][Clk_Phase_Table_DDR2_Width] = { |
| 101 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 102 | //Reg Mask Value Value Value Value |
| 103 | {0x91, 0xF8, 0x02, 0x01, 0x00, 0x07}, // 1Rank |
| 104 | {0x92, 0xF8, 0x04, 0x03, 0x03, 0x02}, |
| 105 | {0x93, 0xF8, 0x06, 0x05, 0x04, 0x03}, |
| 106 | }; |
| 107 | |
| 108 | static const u8 DDR2_ChB_Clk_Phase_Table_1R[3][Clk_Phase_Table_DDR2_Width] = { |
| 109 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 110 | //Reg Mask Value Value Value Value |
| 111 | {0x91, 0x0F, 0x20, 0x10, 0x00, 0x70}, // 1Rank |
| 112 | {0x92, 0x0F, 0x40, 0x30, 0x30, 0x20}, |
| 113 | {0x93, 0x0F, 0x60, 0x50, 0x40, 0x30}, |
| 114 | }; |
| 115 | |
| 116 | /* vt6413c */ |
| 117 | #if 0 |
| 118 | static const u8 DDR2_ChA_Clk_Phase_Table_2R[3][Clk_Phase_Table_DDR2_Width] = { |
| 119 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 120 | //Reg Mask Value Value Value Value |
| 121 | {0x91, 0xF8, 0x04, 0x03, 0x04, 0x01 }, // 1Rank |
| 122 | {0x92, 0xF8, 0x03, 0x06, 0x05, 0x04 }, |
| 123 | {0x93, 0xF8, 0x03, 0x07, 0x06, 0x05 }, |
| 124 | }; |
| 125 | #endif |
| 126 | |
| 127 | /* vt6413d */ |
| 128 | static const u8 DDR2_ChA_Clk_Phase_Table_2R[3][Clk_Phase_Table_DDR2_Width] = { |
| 129 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 130 | //Reg Mask Value Value Value Value |
| 131 | {0x91, 0xF8, 0x02, 0x01, 0x00, 0x07}, // 1Rank |
| 132 | {0x92, 0xF8, 0x04, 0x03, 0x03, 0x02}, |
| 133 | {0x93, 0xF8, 0x06, 0x05, 0x04, 0x03}, |
| 134 | }; |
| 135 | |
| 136 | /* |
| 137 | * DRAM Write Data phase control |
| 138 | * Modify NB Reg: Rx74/Rx75/Rx76 |
| 139 | */ |
| 140 | /* vt6413c */ |
| 141 | #if 0 |
| 142 | static const u8 DDR2_ChA_WrtData_Phase_Table[WrtData_REG_NUM ][WrtData_FREQ_NUM] = { |
| 143 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 144 | //Reg Mask Value Value Value Value |
| 145 | {0x74, 0xF8, 0x03, 0x04, 0x05, 0x02 }, // 1Rank |
| 146 | {0x75, 0xF8, 0x03, 0x04, 0x05, 0x02 }, |
| 147 | {0x76, 0x00, 0x10, 0x80, 0x00, 0x07 }, |
| 148 | }; |
| 149 | #endif |
| 150 | |
| 151 | /* vt6413D */ |
| 152 | static const u8 DDR2_ChA_WrtData_Phase_Table[WrtData_REG_NUM][WrtData_FREQ_NUM] = { |
| 153 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 154 | //Reg Mask Value Value Value Value |
| 155 | {0x74, 0xF8, 0x01, 0x00, 0x00, 0x07}, // 1Rank |
| 156 | {0x75, 0xF8, 0x01, 0x00, 0x00, 0x07}, |
| 157 | {0x76, 0x10, 0x80, 0x87, 0x07, 0x06}, |
| 158 | {0x8C, 0xFC, 0x03, 0x03, 0x03, 0x03}, |
| 159 | }; |
| 160 | |
| 161 | #if 0 |
| 162 | static const u8 DDR2_ChB_WrtData_Phase_Table[WrtData_REG_NUM ][WrtData_FREQ_NUM] = { |
| 163 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 164 | //Reg Mask Value Value Value Value |
| 165 | {0x74, 0x8F, 0x30, 0x40, 0x30, 0x20 }, // 1Rank |
| 166 | {0x75, 0x8F, 0x30, 0x40, 0x30, 0x20 }, |
| 167 | {0x8A, 0x00, 0x10, 0x80, 0x07, 0x07 }, |
| 168 | }; |
| 169 | #endif |
| 170 | |
| 171 | /* |
| 172 | * DQ/DQS Output Delay Control |
| 173 | * Modify NB D0F3: RxF0/RxF1/RxF2/RxF3 |
| 174 | */ |
| 175 | static const u8 DDR2_CHA_DQ_DQS_Delay_Table[4][DQ_DQS_Delay_Table_Width] = { |
| 176 | //RxF0 RxF1 RxF2 RxF3 |
| 177 | {0x00, 0x00, 0x00, 0x00}, /* DDR400 */ |
| 178 | {0x00, 0x00, 0x00, 0x00}, /* DDR533 */ |
| 179 | {0x00, 0x00, 0x00, 0x00}, /* DDR667 */ |
| 180 | {0x00, 0x00, 0x00, 0x00}, /* DDR800 */ |
| 181 | }; |
| 182 | |
| 183 | static const u8 DDR2_CHB_DQ_DQS_Delay_Table[4][DQ_DQS_Delay_Table_Width] = { |
| 184 | //RxF4 RxF5 RxF6 RxF7 |
| 185 | {0x00, 0x00, 0x00, 0x00}, /* DDR400 */ |
| 186 | {0x00, 0x00, 0x00, 0x00}, /* DDR533 */ |
| 187 | {0x00, 0x00, 0x00, 0x00}, /* DDR667 */ |
| 188 | {0x00, 0x00, 0x00, 0x00}, /* DDR800 */ |
| 189 | }; |
| 190 | |
| 191 | /* |
| 192 | * DQ/DQS input Capture Control |
| 193 | * modify NB D0F3_Reg:Rx78/Rx79/Rx7A/Rx7B |
| 194 | */ |
| 195 | /* vt6413C */ |
| 196 | #if 0 |
| 197 | static const u8 DDR2_ChA_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM ][DQS_INPUT_CAPTURE_FREQ_NUM] = { |
| 198 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 199 | //Reg Mask Value Value Value Value |
| 200 | {0x78, 0x00, 0x83, 0x8D, 0x87, 0x83 }, // 1Rank |
| 201 | {0x7A, 0xF0, 0x00, 0x00, 0x00, 0x00 }, |
| 202 | {0x7B, 0x00, 0x10, 0x30, 0x20, 0x10 } |
| 203 | }; |
| 204 | #endif |
| 205 | |
| 206 | /* vt6413D */ |
| 207 | static const u8DDR2_ChA_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM][DQS_INPUT_CAPTURE_FREQ_NUM] = { |
| 208 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 209 | //Reg Mask Value Value Value Value |
| 210 | {0x78, 0xC0, 0x0D, 0x07, 0x03, 0x01}, // 1Rank |
| 211 | {0x7A, 0xF0, 0x00, 0x00, 0x00, 0x00}, |
| 212 | {0x7B, 0x00, 0x34, 0x34, 0x20, 0x10} |
| 213 | }; |
| 214 | |
| 215 | static const u8 DDR2_ChB_DQS_Input_Capture_Tbl[DQS_INPUT_CAPTURE_REG_NUM][DQS_INPUT_CAPTURE_FREQ_NUM] = { |
| 216 | // (And NOT) DDR800 DDR667 DDR533 DDR400 |
| 217 | //Reg Mask Value Value Value Value |
| 218 | {0x79, 0x00, 0x89, 0x89, 0x87, 0x83}, // 1Rank |
| 219 | {0x7A, 0x0F, 0x00, 0x00, 0x00, 0x00}, |
| 220 | {0x8B, 0x00, 0x34, 0x34, 0x20, 0x10} |
| 221 | }; |
| 222 | |
| 223 | static const u8 Fixed_DQSA_1_2_Rank_Table[4][2] = { |
| 224 | //Rx70 Rx71 |
| 225 | {0x00, 0x05}, /* DDR800 */ |
| 226 | {0x00, 0x06}, /* DDR667 */ |
| 227 | {0x00, 0x04}, /* DDR533 */ |
| 228 | {0x00, 0x05}, /* DDR400 */ |
| 229 | }; |
| 230 | |
| 231 | static const u8 Fixed_DQSA_3_4_Rank_Table[4][2] = { |
| 232 | //Rx70 Rx71 |
| 233 | {0x00, 0x04}, /* DDR800 */ |
| 234 | {0x00, 0x04}, /* DDR667 */ |
| 235 | {0x00, 0x03}, /* DDR533 */ |
| 236 | {0x00, 0x04}, /* DDR400 */ |
Uwe Hermann | 20a98c9 | 2009-06-05 23:02:43 +0000 | [diff] [blame] | 237 | }; |