summaryrefslogtreecommitdiff
path: root/Board/SB/SBSECInit.asm
blob: 2ab1c3ce17b2788191ba270332690bf4c5e26d69 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
        TITLE SBSECInit.ASM -- South Bridge SEC initialization
;*************************************************************************
;*************************************************************************
;**                                                                     **
;**        (C)Copyright 1985-2011, American Megatrends, Inc.            **
;**                                                                     **
;**                       All Rights Reserved.                          **
;**                                                                     **
;**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
;**                                                                     **
;**                       Phone: (770)-246-8600                         **
;**                                                                     **
;*************************************************************************
;*************************************************************************

;*************************************************************************
; $Header: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Board/SBSECInit.asm 2     10/23/12 8:18a Scottyang $
;
; $Revision: 2 $
;
; $Date: 10/23/12 8:18a $
;*************************************************************************
; Revision History
; ----------------
; $Log: /Alaska/BIN/Chipset/Intel/SouthBridge/LynxPoint/Intel Pch SB Board/SBSECInit.asm $
; 
; 2     10/23/12 8:18a Scottyang
; [TAG]         EIP73607
; [Category]    Bug Fix
; [Severity]    Normal
; [Symptom]     Intruder Detect state is cleaned by BIOS POST.
; [Files]       SBDXE.c; SBSECInit.asm
; 
; 1     2/08/12 8:22a Yurenlai
; Intel Lynx Point/SB eChipset initially releases.
; 
;*************************************************************************
;<AMI_FHDR_START>
;
; Name:         SBSECInit.ASM
;
; Description:  Program any workaround or initialization needed before
;               enabling Cache as memory in the SEC stage
;
;<AMI_FHDR_END>
;*************************************************************************

;----------------------------------------------------------------------------
        INCLUDE token.equ
;----------------------------------------------------------------------------

.586P
.XMM
.MODEL SMALL

; Externs
EXTERN  SECSB_EarlyInitEnd:NEAR32

IFDEF MKF_ENABLE_NB_DMI_GEN2_IN_SEC
IF MKF_ENABLE_NB_DMI_GEN2_IN_SEC
EXTERN  SECNB_DmiGen2Link:NEAR32
ENDIF
ENDIF

; Define the equates here
SB_BUS                          EQU     0
SB_DEV_FUN                      EQU     0F8h

SB_REG_RCBA                     EQU     0F0h

RCRB_MMIO_GCS                   EQU     3410h   ; General Control and Status 
RCRB_RTC_CONF                   EQU     3400h   ; RTC Configuration register 

TCO_IOREG_STS2                  EQU     6       ; TCO Status 2 Register
TCO_IOREG_CNT1                  EQU     8       ; TCO Control 1 Register

;----------------------------------------------------------------------------
;       STARTUP_SEG  S E G M E N T  STARTS
;----------------------------------------------------------------------------
STARTUP_SEG     SEGMENT     PARA PUBLIC 'CODE' USE32

;<AMI_PHDR_START>
;----------------------------------------------------------------------------
;
; Procedure:    SECSB_EarlyInit
;
; Description:  This routine initializes South bridge for PEI preparation
;
; Input:        ESP BIST Info
;               EBP Reset ID (EDX at reset)
;               Stack not available
;
; Output:       None
;
; Modified:     All, except EBP and ESP
;
; Notes:        None of the chipset initialization is done at this point.
;               System is exactly as if came out of RESET.
;               1. Enable Top of 4GB flash ROM access
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

SECSB_EarlyInit     PROC PUBLIC

        mov     al, 004h
        out     80h, al
; Program 8259 Interrupt Controller to disable all interrupts

        mov     al, 0FFh
        out     021h, al
        out     0EDh, al                ; I/O Delay
        out     0A1h, al
        out     0EDh, al                ; I/O Delay
        mov     al, 00h
        out     92h, al

; Determine if INIT or Hard Reset

;        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 44h
;        mov     dx, 0CF8h
;        out     dx, eax
;        mov     dl, 0FCh
;        in      al, dx
;        and     al, 87h                 ; PM Base address had been enabled?
;        jz      isPowerOn               ; No, is Power on.

; Do a hard Reset if INIT.

;        mov     dx, 0CF9h               ; load dx with reset control reg
;        in      al, dx                  ; read its content
;        or      al, 02h                 ; set bit 1
;        out     dx, al                  ; write it
;        out     0edh, al                ; I/O delay 
;        out     0edh, al                ; I/O delay 
;        or      al, 04h                 ; for HRST set bit 2
;        out     dx, al                  ; write it
;        jmp     $

;isPowerOn:

; Program PCH RCBA Base

        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 0F0h
        out     dx, eax
        mov     dl, 0FCh
        mov     eax, MKF_SB_RCRB_BASE_ADDRESS or 1
        out     dx, eax

; Program SPI prefetching and caching
        mov     dl, 0F8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 0DCh
        out     dx, eax
        mov     dl, 0FCh
        in      eax, dx
        or      eax, (MKF_SPI_READ_CONFIG shl 2)
        out     dx, eax

; Program PM I/O Base Address
        mov     dl, 0F8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 040h
        out     dx, eax
        mov     dl, 0FCh
        mov     ax, MKF_PM_BASE_ADDRESS
        out     dx, ax

        mov     dl, 0F8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 044h
        out     dx, eax
        mov     dl, 0FCh
        mov     al, 80h
        out     dx, al

; Enable ROM Decode for SEC stage.
        mov     dl, 0F8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 0D8h
        out     dx, eax
        mov     dl, 0FDh
        mov     al, 0FFh                ; Decode 4MB Always
        out     dx, al

; Disable Auto-Reset Function
        mov     dx, MKF_TCO_BASE_ADDRESS + TCO_IOREG_CNT1
        in      ax, dx
        out     0edh, al                ; I/O delay 
        or      ah, 08t                 ; Set Bit[11] to disable TCO timer
        out     dx, ax
        out     0edh, al                ; I/O delay 

        mov     dx, MKF_TCO_BASE_ADDRESS + TCO_IOREG_STS2
        in      ax, dx
        out     0edh, al                ; I/O delay 
        and     al, 0FEh                ; Skip Intrusion, [EIP73607]
        or      al, 02t                 ; Set Bit[1] to clear SECOND_TO_STS
        out     dx, ax
        out     0edh, al                ; I/O delay 

        mov     esi, MKF_SB_RCRB_BASE_ADDRESS + RCRB_RTC_CONF   ; Enable Upper CMOS
        mov     byte ptr [esi], 04h

        mov     esi, MKF_SB_RCRB_BASE_ADDRESS + RCRB_MMIO_GCS
        mov     byte ptr [esi], 60h or (MKF_RESERVED_PAGE_ROUTE shl 2)

; Intel 6 Series Chipset/Intelr C200 Series Chipset/Patsburg Platform Controller Hub(PCH)
; BIOS Specification Update
; Revision 1.0.1
; The System BIOS must perform the steps below early in the POST before
; generating any I/O or MMIO cycles that could be decoded by the PCI bridge
; device.
; 1. System BIOS must determine if the PCH supports the PCI Bridge device
;    via the FVEC0 - Feature Vector Register 0 by following the steps below:
;    a. Set D31:F0:Reg E4h[5:2] (Feature Vector Index) to "0".
;    b. Read D31:F0:Reg E8h[31:0] (Feature Vector Data)
;    c. If
;        FVEC0[1] = 0b, PCI bridge device is enabled.
;       else
;        FVEC0[1] = 1b, PCI bridge device is disabled.
        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 0E4h
        out     dx, eax
        mov     dl, 0FCh
        mov     eax, 0                  ; Set the Enable bit.
        out     dx, eax

        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 0E8h
        out     dx, eax
        mov     dl, 0FCh
        in      eax, dx                 ; Read 0:1F:0:E8
        and     eax, 02h                ; Check if FVECT[1] == 1
        jz      SkipDisableP2P          ; No then leave PCI bridge
                                        ; device enabled

; 2. System BIOS must set the FD - Function disable register offset RCBA +
;    3418h bit 1 PCI Bridge Disable to 1b if the PCI bridge device is not
;    supported by the PCH.
        mov     edi, MKF_SB_RCRB_BASE_ADDRESS + 3418h
        or      DWORD PTR [edi], 02h    ; Else disabled the PCI
                                        ; bridge device
SkipDisableP2P:


; Enable IO Decode range in SEC.
IF MKF_SB_IO_DECODE_IN_SEC
        ;Enable LPC IO decoding
        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 80h
        out     dx, eax
        add     dx, 04h
        mov     eax, 34030070h
 IFDEF MKF_EC_SUPPORT
        or      eax, (MKF_EC_SUPPORT shl 27t) ; Enable MC_LPC_EN
 ENDIF
        out     dx, eax

 IFDEF MKF_SIO1_CONFIG_INDEX
  IF ((MKF_SIO1_CONFIG_INDEX NE 2Eh) AND (MKF_SIO1_CONFIG_INDEX NE 4Eh))
        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 88h
        out     dx, eax
        add     dx, 04h
        mov     eax, (MKF_SIO1_CONFIG_INDEX and 0FFFCh) or 1;
        out     dx, eax
  ENDIF
 ENDIF

 IF MKF_SB_GEN_DECODE_RANGE_1
; Enable decoding of PME & GPIO Runtime Registers as Generic Decode Range 1
        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 84h
        out     dx, eax
        add     dx, 04h
        mov     eax, ((MKF_SB_GEN_DECODE_RANGE_1 AND 0FFFFh) OR (0FCh SHL 16))
        bts     eax, 0
        out     dx, eax
 ENDIF

 IF MKF_SB_GEN_DECODE_RANGE_2
; Enable decoding of PME & GPIO Runtime Registers as Generic Decode Range 2
        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 88h
        out     dx, eax
        add     dx, 04h
        mov     eax, ((MKF_SB_GEN_DECODE_RANGE_2 AND 0FFFFh) OR (0FCh SHL 16))
        bts     eax, 0
        out     dx, eax
 ENDIF

 IF MKF_SB_GEN_DECODE_RANGE_3
; Enable decoding of PME & GPIO Runtime Registers as Generic Decode Range 3
        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 8Ch
        out     dx, eax
        add     dx, 04h
        mov     eax, ((MKF_SB_GEN_DECODE_RANGE_3 AND 0FFFFh) OR (0FCh SHL 16))
        bts     eax, 0
        out     dx, eax
 ENDIF

 IF MKF_SB_GEN_DECODE_RANGE_4
; Enable decoding of PME & GPIO Runtime Registers as Generic Decode Range 4
        mov     dx, 0CF8h
        mov     eax, (1 shl 31t) + (SB_BUS shl 16t) + (SB_DEV_FUN shl 8) + 90h
        out     dx, eax
        add     dx, 04h
        mov     eax, ((MKF_SB_GEN_DECODE_RANGE_4 AND 0FFFFh) OR (0FCh SHL 16))
        bts     eax, 0
        out     dx, eax
 ENDIF

ENDIF  ; IF MKF_SB_IO_DECODE_IN_SEC


        jmp     SECSB_EarlyInitEnd
SECSB_EarlyInit     ENDP

IFDEF MKF_ENABLE_NB_DMI_GEN2_IN_SEC
IF MKF_ENABLE_NB_DMI_GEN2_IN_SEC
;<AMI_PHDR_START>
;----------------------------------------------------------------------------
;
; Procedure:    SECSB_DmiGen2Init
;
; Description:  This routine initializes South bridge DMI for PEI preparation
;
; Input:        ESP BIST Info
;               EBP Reset ID (EDX at reset)
;               Stack not available
;
; Output:       None
;
; Modified:     All, except EBP and ESP
;
; Notes:        None of the chipset initialization is done at this point.
;               System is exactly as if came out of RESET.
;               1. Enable Top of 4GB flash ROM access
;----------------------------------------------------------------------------
;<AMI_PHDR_END>

SECSB_DmiGen2Init     PROC PUBLIC

        ; Step 1
        ; RCBA + Offset 21A4h[3:0] = 0010b
        mov   esi, MKF_SB_RCRB_BASE_ADDRESS + 21A4h    
        mov   al, byte ptr [esi]
        and   al, 0Fh
        cmp   al, 02h
        jne   SECSB_DmiGen2_Exit              ; if SB DMI Gen != 0010b, jmp SECSB_DmiGen2_Exit

        ; Step 1.2.1
        ; Set RCBA + Offset 2340h[23:16] = 3Ah, Set Gen 2 Common Clock N_FTS
        mov   esi, MKF_SB_RCRB_BASE_ADDRESS + 2340h   
        mov   eax, dword ptr [esi]
        and   eax, 0FF00FFFFh
        or    eax, (3ah SHL 16)
        mov   dword ptr [esi], eax

        ; Step 1.2.2
        ; Set RCBA + Offset 21B0h[3:0] = 0010b, Set target link speed as DMI Gen 2
        mov   esi, MKF_SB_RCRB_BASE_ADDRESS + 21B0h   
        mov   al, byte ptr [esi]
        and   al, NOT (0Fh)
        or    al, (1 SHL 1)
        mov   byte ptr [esi], al

SECSB_DmiGen2_Exit:
        jmp     SECNB_DmiGen2Link
SECSB_DmiGen2Init     ENDP
ENDIF
ENDIF
;----------------------------------------------------------------------------
;       STARTUP_SEG  S E G M E N T  ENDS
;----------------------------------------------------------------------------
STARTUP_SEG     ENDS
END

;*************************************************************************
;*************************************************************************
;**                                                                     **
;**        (C)Copyright 1985-2011, American Megatrends, Inc.            **
;**                                                                     **
;**                       All Rights Reserved.                          **
;**                                                                     **
;**      5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093           **
;**                                                                     **
;**                       Phone: (770)-246-8600                         **
;**                                                                     **
;*************************************************************************
;*************************************************************************