This patch converts the Geode GX2 boards to CAR.
[coreboot.git] / src / cpu / amd / model_gx2 / cpureginit.c
1
2 /* ***************************************************************************/
3 /* *    cpuRegInit*/
4 /* ***************************************************************************/
5 void cpuRegInit (void)
6 {
7         int msrnum;
8         msr_t msr;
9         /*  Turn on BTM for early debug based on setup. */
10         /*if (getnvram( TOKEN_BTM_DIAG_MODE) & 3) {*/
11         /*
12          * The following is only for diagnostics mode; do not use for OLPC
13          */
14         if (0) {
15                 /*  Set Diagnostic Mode */
16                 msrnum = CPU_GLD_MSR_DIAG;
17                 msr.hi =  0;
18                 msr.lo = DIAG_SEL1_SET | DIAG_SET0_SET;
19                 wrmsr(msrnum, msr);
20
21                 /*  Set up GLCP to grab BTM data.*/
22                 msrnum = 0x04C00000C;           /*  GLCP_DBGOUT MSR*/
23                 msr.hi =  0x0;
24                 msr.lo =  0x08;                 /*  reset value (SCOPE_SEL = 0) causes FIFO toshift out,*/
25                 wrmsr(msrnum, msr);             /*  exchange it to anything else to prevent this*/
26
27                 /* ;Turn off debug clock*/
28                 msrnum = 0x04C000016;           /* DBG_CLK_CTL*/
29                 msr.lo =  0x00;                 /* No clock*/
30                 msr.hi =  0x00;
31                 wrmsr(msrnum, msr);
32
33                 /* ;Set debug clock to CPU*/
34                 msrnum = 0x04C000016;           /* DBG_CLK_CTL*/
35                 msr.lo =  0x01;                 /* CPU CLOCK*/
36                 msr.hi =  0x00;
37                 wrmsr(msrnum, msr);
38
39                 /* ;Set fifo ctl to BTM bits wide*/
40                 msrnum = 0x04C00005E;           /*  FIFO_CTL*/
41                 msr.lo =  0x003880000;          /*  Bit [25:24] are size (11=BTM, 10 = 64 bit, 01= 32 bit, 00 = 16bit)*/
42                 wrmsr(msrnum, msr);     /*  Bit [23:21] are position (100 = CPU downto0)*/
43                                                         /*  Bit [19] sets it up in slow data mode.*/
44
45                 /* ;enable fifo loading - BTM sizing will constrain*/
46                 /* ; only valid BTM packets to load - this action should always be on*/
47
48                 msrnum = 0x04C00006F;           /*  GLCP ACTION7 - load fifo*/
49                 msr.lo =  0x00000F000;          /*    Any nibble all 1's will always trigger*/
50                 msr.hi =  0x000000000;          /* */
51                 wrmsr(msrnum, msr);
52
53                 /* ;start storing diag data in the fifo*/
54                 msrnum = 0x04C00005F;           /* DIAG CTL*/
55                 msr.lo =  0x080000000;          /*  enable actions*/
56                 msr.hi =  0x000000000;
57                 wrmsr(msrnum, msr);
58
59                 /*  Set up delay on data lines, so that the hold time*/
60                 /*  is 1 ns.*/
61                 msrnum = 0x04C00000D ;  /*  GLCP IO DELAY CONTROLS*/
62                 msr.lo =  0x082b5ad68;
63                 msr.hi =  0x080ad6b57;  /*  RGB delay = 0x07*/
64                 wrmsr(msrnum, msr);
65
66                 /*  Set up DF to output diag information on DF pins.*/
67                 msrnum = DF_GLD_MSR_MASTER_CONF;
68                 msr.lo =  0x0220;
69                 msr.hi = 0;
70                 wrmsr(msrnum, msr);
71
72                 msrnum = 0x04C00000C ;  /*  GLCP_DBGOUT MSR*/
73                 msr.hi =  0x0;
74                 msr.lo =  0x0;                          /*  reset value (SCOPE_SEL = 0) causes FIFO to shift out,*/
75                 wrmsr(msrnum, msr);
76                 /* end of code for BTM */
77         }
78
79         /*  Enable Suspend on Halt*/
80         msrnum = CPU_XC_CONFIG;
81         msr = rdmsr(msrnum);
82         msr.lo |=  XC_CONFIG_SUSP_ON_HLT;
83         wrmsr(msrnum, msr);
84
85         /*  ENable SUSP and allow TSC to run in Suspend */
86         /*  to keep speed detection happy*/
87         msrnum = CPU_BC_CONF_0;
88         msr = rdmsr(msrnum);
89         msr.lo |=  TSC_SUSP_SET | SUSP_EN_SET;
90         wrmsr(msrnum, msr);
91
92         /*  Setup throttling to proper mode if it is ever enabled.*/
93         msrnum = 0x04C00001E;
94         msr.hi =  0x000000000;
95         msr.lo =  0x00000603C;
96         wrmsr(msrnum, msr);
97
98
99 /*  Only do this if we are building for 5535*/
100 /* */
101 /*  FooGlue Setup*/
102 /* */
103 #if 1
104         /*  Enable CIS mode B in FooGlue*/
105         msrnum = MSR_FG + 0x10;
106         msr = rdmsr(msrnum);
107         msr.lo &= ~3;
108         msr.lo |= 2;                    /*  ModeB*/
109         wrmsr(msrnum, msr);
110 #endif
111
112 /* */
113 /*  Disable DOT PLL. Graphics init will enable it if needed.*/
114 /* */
115         msrnum = GLCP_DOTPLL;
116         msr = rdmsr(msrnum);
117         msr.lo |= DOTPPL_LOWER_PD_SET;
118         wrmsr(msrnum, msr);
119
120 /* */
121 /*  Enable RSDC*/
122 /* */
123         msrnum = 0x1301 ;
124         msr = rdmsr(msrnum);
125         msr.lo |=  0x08;
126         wrmsr(msrnum, msr);
127
128 /* */
129 /*  Enable BTB*/
130 /* */
131         /*  I hate to put this check here but it doesn't really work in cpubug.asm*/
132         msrnum = MSR_GLCP+0x17;
133         msr = rdmsr(msrnum);
134         if (msr.lo >= CPU_REV_2_1){
135                 msrnum = CPU_PF_BTB_CONF;
136                 msr = rdmsr(msrnum);
137                 msr.lo |= BTB_ENABLE_SET | RETURN_STACK_ENABLE_SET;
138                 wrmsr(msrnum, msr);
139         }
140
141 /* */
142 /*  FPU impercise exceptions bit*/
143 /* */
144         /*if (getnvram( TOKEN_FPU_IE_ENABLE) != TVALUE_DISABLE) {*/
145         {
146                 msrnum = CPU_FPU_MSR_MODE;
147                 msr = rdmsr(msrnum);
148                 msr.lo |= FPU_IE_SET;
149                 wrmsr(msrnum, msr);
150         }
151
152 #if 0
153         /* */
154         /*  Cache Overides*/
155         /* */
156         /* This code disables the data cache.  Don't execute this
157          * unless you're testing something.
158          */
159         /*  Allow NVRam to override DM Setup*/
160         /*if (getnvram( TOKEN_CACHE_DM_MODE) != 1) {*/
161         {
162
163                 msrnum = CPU_DM_CONFIG0;
164                 msr = rdmsr(msrnum);
165                 msr.lo |=  DM_CONFIG0_LOWER_DCDIS_SET;
166                 wrmsr(msrnum, msr);
167         }
168         /* This code disables the instruction cache.  Don't execute
169          * this unless you're testing something.
170         */
171         /*  Allow NVRam to override IM Setup*/
172         /*if (getnvram( TOKEN_CACHE_IM_MODE) ==1) {*/
173         {
174                 msrnum = CPU_IM_CONFIG;
175                 msr = rdmsr(msrnum);
176                 msr.lo |=  IM_CONFIG_LOWER_ICD_SET;
177                 wrmsr(msrnum, msr);
178         }
179 #endif
180 }