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