First batch of indent-aided code cleanups, more will follow.
[coreboot.git] / src / northbridge / via / vx800 / dqs_search.c
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; version 2 of the License.
9  *
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.
14  *
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
18  */
19
20 void SetDQSOutputCHA(DRAM_SYS_ATTR * DramAttr);
21 void SetDQSOutputCHB(DRAM_SYS_ATTR * DramAttr);
22
23 /*===================================================================
24 Function   : DRAMDQSOutputSearchCHA()
25 Precondition : 
26 Input      :  
27                    DramAttr:  pointer point to  DRAM_SYS_ATTR  which consist the DDR and Dimm information
28                                     in MotherBoard
29 Output     : Void
30 Purpose   : set DQS output delay register reg70  and DQ output delay register reg71
31 ===================================================================*/
32
33 #define CH_A      0
34 #define CH_B      1
35 void DRAMDQSOutputSearch(DRAM_SYS_ATTR * DramAttr)
36 {
37         if (DramAttr->RankNumChA > 0)
38                 SetDQSOutputCHA(DramAttr);
39 }
40
41 /*===================================================================
42 Function   : SetDQSOutputCHA()
43 Precondition : 
44 Input      :  
45                    DramAttr:  pointer point to  DRAM_SYS_ATTR  which consist the DDR and Dimm information
46                                     in MotherBoard
47 Output     : Void
48 Purpose   :  according the frequence set CHA DQS output 
49 ===================================================================*/
50 void SetDQSOutputCHA(DRAM_SYS_ATTR * DramAttr)
51 {
52         u8 Reg70, Reg71;
53         u8 Index;
54
55         if (DramAttr->DramFreq == DIMMFREQ_400)
56                 Index = 3;
57         else if (DramAttr->DramFreq == DIMMFREQ_533)
58                 Index = 2;
59         else if (DramAttr->DramFreq == DIMMFREQ_667)
60                 Index = 1;
61         else if (DramAttr->DramFreq == DIMMFREQ_800)
62                 Index = 0;
63         else
64                 Index = 3;
65
66         if (DramAttr->RankNumChA > 2) {
67                 Reg70 = Fixed_DQSA_3_4_Rank_Table[Index][0];
68                 Reg71 = Fixed_DQSA_3_4_Rank_Table[Index][1];
69         } else {
70                 Reg70 = Fixed_DQSA_1_2_Rank_Table[Index][0];
71                 Reg71 = Fixed_DQSA_1_2_Rank_Table[Index][1];
72         }
73         pci_write_config8(MEMCTRL, 0x70, Reg70);
74         pci_write_config8(MEMCTRL, 0x71, Reg71);
75 }
76
77 //################
78 //     STEP 12   #
79 //################
80
81 /*===================================================================
82 Function   : DRAMDQSInputSearch()
83 Precondition : 
84 Input      :  
85                    DramAttr:  pointer point to  DRAM_SYS_ATTR  which consist the DDR and Dimm information
86                                     in MotherBoard
87 Output     : Void
88 Purpose   : search DQS input delay for CHA/CHB
89 ===================================================================*/
90
91 void DRAMDQSInputSearch(DRAM_SYS_ATTR * DramAttr)
92 {
93         u8 Data;
94         //auto mode
95         Data = 0x0;
96         pci_write_config8(MEMCTRL, 0x77, Data);
97 }