cfb86aa327be4338d8beb5a642ad9d7af7500b27
[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         /* The following is only for diagnostics mode; do not use for OLPC */
8         if (0) {
9                 /* Set Diagnostic Mode */
10                 msrnum = CPU_GLD_MSR_DIAG;
11                 msr.hi =  0;
12                 msr.lo = DIAG_SEL1_SET | DIAG_SET0_SET;
13                 wrmsr(msrnum, msr);
14
15                 /* Set up GLCP to grab BTM data. */
16                 msrnum = GLCP_DBGOUT;           /* GLCP_DBGOUT MSR */
17                 msr.hi =  0x0;
18                 msr.lo =  0x08;                 /* reset value (SCOPE_SEL = 0) causes FIFO toshift out, */
19                 wrmsr(msrnum, msr);             /* exchange it to anything else to prevent this */
20
21                 /* Turn off debug clock */
22                 msrnum = GLCP_DBGCLKCTL;        /* DBG_CLK_CTL */
23                 msr.lo =  0x00;                 /* No clock */
24                 msr.hi =  0x00;
25                 wrmsr(msrnum, msr);
26
27                 /* Set debug clock to CPU */
28                 msrnum = GLCP_DBGCLKCTL;        /* DBG_CLK_CTL */
29                 msr.lo =  0x01;                 /* CPU CLOCK */
30                 msr.hi =  0x00;
31                 wrmsr(msrnum, msr);
32
33                 /* Set fifo ctl to BTM bits wide */
34                 msrnum = GLCP_FIFOCTL;          /* FIFO_CTL */
35                 msr.lo =  0x003880000;          /* Bit [25:24] are size (11=BTM, 10 = 64 bit, 01= 32 bit, 00 = 16bit) */
36                 wrmsr(msrnum, msr);             /* Bit [23:21] are position (100 = CPU downto0) */
37                                                 /* Bit [19] sets it up in slow data mode. */
38
39                 /* enable fifo loading - BTM sizing will constrain */
40                 /* only valid BTM packets to load - this action should always be on */
41                 msrnum = 0x04C00006F;           /* GLCP ACTION7 - load fifo */
42                 msr.lo =  0x00000F000;          /* Any nibble all 1's will always trigger */
43                 msr.hi =  0x000000000;
44                 wrmsr(msrnum, msr);
45
46                 /* start storing diag data in the fifo */
47                 msrnum = 0x04C00005F;           /* DIAG CTL */
48                 msr.lo =  0x080000000;          /* enable actions */
49                 msr.hi =  0x000000000;
50                 wrmsr(msrnum, msr);
51
52                 /* Set up delay on data lines, so that the hold time */
53                 /* is 1 ns. */
54                 msrnum = GLCP_PROCSTAT;         /* GLCP IO DELAY CONTROLS */
55                 msr.lo =  0x082b5ad68;
56                 msr.hi =  0x080ad6b57;          /* RGB delay = 0x07 */
57                 wrmsr(msrnum, msr);
58
59                 /* Set up DF to output diag information on DF pins. */
60                 msrnum = DF_GLD_MSR_MASTER_CONF;
61                 msr.lo =  0x0220;
62                 msr.hi = 0;
63                 wrmsr(msrnum, msr);
64
65                 msrnum = GLCP_DBGOUT;           /* GLCP_DBGOUT MSR */
66                 msr.hi =  0x0;
67                 msr.lo =  0x0;                  /* reset value (SCOPE_SEL = 0) causes FIFO to shift out, */
68                 wrmsr(msrnum, msr);
69                 /* end of code for BTM */
70         }
71
72         /* Enable Suspend on Halt */
73         msrnum = CPU_XC_CONFIG;
74         msr = rdmsr(msrnum);
75         msr.lo |=  XC_CONFIG_SUSP_ON_HLT;
76         wrmsr(msrnum, msr);
77
78         /* ENable SUSP and allow TSC to run in Suspend */
79         /* to keep speed detection happy */
80         msrnum = CPU_BC_CONF_0;
81         msr = rdmsr(msrnum);
82         msr.lo |=  TSC_SUSP_SET | SUSP_EN_SET;
83         wrmsr(msrnum, msr);
84
85         /* Setup throttling to proper mode if it is ever enabled. */
86         msrnum = GLCP_TH_OD;
87         msr.hi =  0x000000000;
88         msr.lo =  0x00000603C;
89         wrmsr(msrnum, msr);
90
91 /* Only do this if we are building for 5535 */
92 /* FooGlue Setup */
93 #if 1
94         /* Enable CIS mode B in FooGlue */
95         msrnum = MSR_FG + 0x10;
96         msr = rdmsr(msrnum);
97         msr.lo &= ~3;
98         msr.lo |= 2;            /* ModeB */
99         wrmsr(msrnum, msr);
100 #endif
101
102 /* Disable DOT PLL. Graphics init will enable it if needed. */
103         msrnum = GLCP_DOTPLL;
104         msr = rdmsr(msrnum);
105         msr.lo |= DOTPPL_LOWER_PD_SET;
106         wrmsr(msrnum, msr);
107
108 /* Enable RSDC */
109         msrnum = CPU_AC_SMM_CTL;
110         msr = rdmsr(msrnum);
111         msr.lo |=  0x08;
112         wrmsr(msrnum, msr);
113
114 /* Enable BTB */
115         /* I hate to put this check here but it doesn't really work in cpubug.asm */
116         msrnum = GLCP_CHIP_REVID;
117         msr = rdmsr(msrnum);
118         if (msr.lo >= CPU_REV_2_1){
119                 msrnum = CPU_PF_BTB_CONF;
120                 msr = rdmsr(msrnum);
121                 msr.lo |= BTB_ENABLE_SET | RETURN_STACK_ENABLE_SET;
122                 wrmsr(msrnum, msr);
123         }
124
125 /* FPU impercise exceptions bit */
126         {
127                 msrnum = CPU_FPU_MSR_MODE;
128                 msr = rdmsr(msrnum);
129                 msr.lo |= FPU_IE_SET;
130                 wrmsr(msrnum, msr);
131         }
132 }