RD890 Northbridge: AMD RD890/SR56X0 Northbridge CIMX code
[coreboot.git] / src / vendorcode / amd / cimx / rd890 / nbPowerOnReset.c
1 /**
2  * @file
3  *
4  * Power on Reset register initialization.
5  *
6  *
7  *
8  * @xrefitem bom "File Content Label" "Release Content"
9  * @e project:      CIMx-NB
10  * @e sub-project:
11  * @e \$Revision:$   @e \$Date:$
12  *
13  */
14 /*****************************************************************************
15  *
16  * Copyright (C) 2012 Advanced Micro Devices, Inc.
17  * All rights reserved.
18  *
19  * Redistribution and use in source and binary forms, with or without
20  * modification, are permitted provided that the following conditions are met:
21  *     * Redistributions of source code must retain the above copyright
22  *       notice, this list of conditions and the following disclaimer.
23  *     * Redistributions in binary form must reproduce the above copyright
24  *       notice, this list of conditions and the following disclaimer in the
25  *       documentation and/or other materials provided with the distribution.
26  *     * Neither the name of Advanced Micro Devices, Inc. nor the names of
27  *       its contributors may be used to endorse or promote products derived
28  *       from this software without specific prior written permission.
29  *
30  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
31  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
32  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
33  * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY
34  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
35  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
36  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
37  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
38  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
39  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
40  *
41  *
42  ***************************************************************************/
43
44 /*----------------------------------------------------------------------------------------
45  *                             M O D U L E S    U S E D
46  *----------------------------------------------------------------------------------------
47  */
48
49 #include "NbPlatform.h"
50 #include "amdDebugOutLib.h"
51
52 /*----------------------------------------------------------------------------------------
53  *                   D E F I N I T I O N S    A N D    M A C R O S
54  *----------------------------------------------------------------------------------------
55  */
56
57
58 /*----------------------------------------------------------------------------------------
59  *                  T Y P E D E F S     A N D     S T R U C T U  R E S
60  *----------------------------------------------------------------------------------------
61  */
62
63 /*----------------------------------------------------------------------------------------
64  *           P R O T O T Y P E S     O F     L O C A L     F U  N C T I O N S
65  *----------------------------------------------------------------------------------------
66  */
67 AGESA_STATUS
68 NbPorInitValidateInput (
69   IN      AMD_NB_CONFIG *pConfig
70   );
71
72 /*----------------------------------------------------------------------------------------
73  *                          E X P O R T E D    F U N C T I O N S
74  *----------------------------------------------------------------------------------------
75  */
76 /// PCI registers init table
77 CONST REGISTER_ENTRY NbPorPciTable[] = {
78   {NB_PCI_REG04, 0xFD, 0x02},
79 //Reg84h[4]=1 (EV6MODE) to allow decode of 640k-1MB
80   {NB_PCI_REG84, 0xEF, 0x10},
81 //Reg4Ch[1]=1 (APIC_ENABLE) force cpu request with address 0xFECx_xxxx to south-bridge
82 //Reg4Ch[6]=1 (BMMsgEn) enable BM_Set message generation
83   {NB_PCI_REG4C, 0x00, 0x42},
84 //Reg4Ch[16]=1 (WakeC2En) enable Wake_from_C2 message generation.
85 //Reg4Ch[18]=1 (P4IntEnable) Enable north-bridge to accept MSI with address 0xFEEx_xxxx from south-bridge
86   {NB_PCI_REG4E, 0xFF, 0x05},
87 //Set temporary NB TOM to 0xE0000000
88   {NB_PCI_REG90 + 3, 0x00, 0xE0}
89 };
90
91 /// MISCIND registers init table
92 CONST INDIRECT_REG_ENTRY NbPorMiscTable[] = {
93 // NB_MISC_IND_WR_EN + IOC_PCIE_CNTL
94 // Block non-snoop DMA request if PMArbDis is set.
95 // Set BMSetDis
96   {
97     NB_MISC_REG0B,
98     0xFFFF0000,
99     0x00000180
100   },
101 // NBCFG (NBMISCIND 0x0): NB_CNTL -
102 //   HIDE_NB_AGP_CAP  ([0], default=1)HIDE
103 //   HIDE_P2P_AGP_CAP ([1], default=1)HIDE
104 //   HIDE_NB_GART_BAR ([2], default=1)HIDE
105 //   HIDE_MMCFG_BAR   ([3], default=1)HIDE
106 //   AGPMODE30        ([4], default=0)DISABLE
107 //   AGP30ENCHANCED   ([5], default=0)DISABLE
108 //   HIDE_AGP_CAP     ([8], default=1)ENABLE
109   {
110     NB_MISC_REG00,
111     0xFFFF0000,
112     0x0000010e
113   },
114 //NBMISIND:0x01 Bit[8]=1 IOC will forward the byte-enable (BE), which is 16'b0 for zero-byte reads, of the PCIE DMA request upstream to HTIU.
115 //NBMISIND:0x01 Bit[9]=1 zero-byte reads.
116   {
117     NB_MISC_REG01,
118     0xFFFFFFFF,
119     0x00000310
120   },
121 //NBMISIND:0x40 Bit[8]=1 and Bit[10]=1 following bits are required to set in order to allow PWM features to work.
122   {
123     NB_MISC_REG40,
124     0xffffffff,
125     0x00000500
126   },
127 //Enable slot power message
128   {
129     NB_MISC_REG51,
130     0x00000000,
131     0x00100106
132   },
133   {
134     NB_MISC_REG53,
135     0x00000000,
136     0x00100106
137   },
138   {
139     NB_MISC_REG55,
140     0x00000000,
141     0x00100106
142   },
143   {
144     NB_MISC_REG57,
145     0x00000000,
146     0x00100106
147   },
148   {
149     NB_MISC_REG59,
150     0x00000000,
151     0x00100106
152   },
153   {
154     NB_MISC_REG5B,
155     0x00000000,
156     0x00100106
157   },
158   {
159     NB_MISC_REG5D,
160     0x00000000,
161     0x00100106
162   },
163   {
164     NB_MISC_REG5F,
165     0x00000000,
166     0x00100106
167   },
168   {
169     NB_MISC_REG61,
170     0x00000000,
171     0x00100106
172   },
173   {
174     NB_MISC_REG63,
175     0x00000000,
176     0x00100106
177   },
178   {
179     NB_MISC_REG1F,
180     0x00000000,
181     0x00100106
182   },
183 //NBMISCIND:0x0C[13]= 1 Enables GSM Mode.
184   {
185     NB_MISC_REG0C,
186     0xffffffff,
187     BIT13 + BIT20
188   },
189 //NBMISCIND:0x12[16]= 1 ReqID for GPP1 and GPP2
190 //NBMISCIND:0x12[17]= 1 ReqID for  GPP3a, GPP3b, SB
191 //NBMISCIND:0x12[18]= 0 ReqID override for SB
192 //NBMISCIND:0x12[19]= 1 Enable INT accumulators
193 //NBMISCIND:0x12[20, 21, 23]= 1 4103, 4125, 4155 4186 (A21).
194 //NBMISCIND:0x12[22]=0  Prevent spurious DR of UMA request (RPR 5.9.3)
195   {
196     NB_MISC_REG12,
197     (UINT32)~(BIT18 + BIT22),
198     0xBB0000
199   },
200 //NBMISCIND:0x75[15.13,16..18,21..19,24..22,25..25] = 0x4  Enable AER
201 //NBMISCIND:0x75[29]= 1 Device ID for hotplug and PME message.
202   {
203     NB_MISC_REG75,
204     (UINT32)~BIT28,
205     (4 << 13) | (4 << 16) | (4 << 19) | (4 << 22) | (4 << 25) | BIT29
206   },
207 //PCIe CDR setting
208   {
209     NB_MISC_REG38,
210     0xffffffff,
211     BIT6 + BIT7 + BIT14 + BIT15 + BIT22 + BIT23
212   },
213   {
214     NB_MISC_REG67,
215     0xffffffff,
216     BIT21 + BIT22
217   },
218   {
219     NB_MISC_REG2C,
220     (UINT32)~(BIT0 + BIT1 + BIT19),
221     BIT0 + BIT1
222   },
223   {
224     NB_MISC_REG6C,
225     (UINT32)~(BIT10),
226     0x0
227   },
228   {
229     NB_MISC_REG34,
230     (UINT32)~(BIT7 + BIT15 + BIT23),
231     0x0
232   },
233   {
234     NB_MISC_REG37,
235     (UINT32)~(0xffful << 20),
236     (0xdddul << 20)
237   },
238   {
239     NB_MISC_REG68,
240     (UINT32)~(0xful << 16),
241     (0xd << 16)
242     },
243   {
244     NB_MISC_REG2B,
245     (UINT32)~(0xful << 24 ),
246     (0xd << 24)
247   },
248   // Enable ACS capability
249   {
250     NB_MISC_REG6A,
251     0xffffffff,
252     BIT2
253   }
254 };
255
256 /// HTIUIND registers init table
257 CONST INDIRECT_REG_ENTRY NbPorHtiuTable[] = {
258 //HTIU x 05 [8] = 0x0 Enables PC checking for FCB release.
259 //HTIU x 05 [13,13,3,14,10,12,17,18,15,4,6,19] = 0x1 Misc (A21)
260   {NB_HTIU_REG05, 0xFFFFFEFF,  BIT8 + BIT16 + BIT13 + BIT3 + BIT14 + BIT10 + BIT12 + BIT17 + BIT18 + BIT15 +
261                                BIT4 + BIT6 + BIT19 },
262   //HTIU x 06 [0] = 0x0 Enables writes to pass in-progress reads
263 //HTIU x 06 [1] = 0x1 Enables streaming of CPU writes
264 //HTIU x 06 [9] = 0x1 Enables extended write buffer for CPU writes
265 //HTIU x 06 [13] = 0x1 Enables additional response buffers
266 //HTIU x 06 [17] = 0x1 Enables special reads to pass writes
267 //HTIU x 06 [16:15] = 0x3 Enables decoding of C1e/C3 and FID cycles
268 //HTIU x 06 [25] = 0x1 Enables HTIU-display handshake bypass.
269 //HTIU x 06 [30] = 0x1 Enables tagging fix
270   {NB_HTIU_REG06, 0xFFFFFFFE,  0x04203A202},
271 //HTIU x 07 [0] = 0x1 Enables byte-write optimization for IOC requests
272 //HTIU x 07 [1] = 0x0 Disables delaying STPCLK de-assert during FID sequence. Needed when enhanced UMA arbitration is used.
273 //HTIU x 07 [2] = 0x0 Disables upstream system-management delay
274   {NB_HTIU_REG07, 0xFFFFFFF9,  0x0001     },
275 //HTIU x 1C [31:17]=0xfff i.e. 0001 1111 1111 111 or 1FFE Enables all traffic to be detected as GSM traffic.
276   {NB_HTIU_REG1C, 0xFFFFFFFF,  0x1ffe0000 },
277 //HTIU x 15 [27]=0x1 Powers down the chipset DLLs in the LS2 state.
278   {NB_HTIU_REG15, 0xFFFFFFFF,  BIT27      },
279 //Enable transmit PHY to reinitialize in HT1 mode when tristate is enabled
280 //HTIU x 16 [10]=0x1 enable proper DLL reset sequence.
281   {NB_HTIU_REG16, 0xFFFFFFFF,  BIT11 + BIT10},
282 //HTIU x 2A [1:0]=0x1 Optimize chipset HT transmitter drive strength
283   {NB_HTIU_REG2A, 0xfffffffc, 0x00000001  }
284 };
285
286 /*----------------------------------------------------------------------------------------*/
287 /**
288  * Amd Power on Reset Initialization for all NB.
289  *
290  *
291  *
292  *
293  * @param[in] ConfigPtr   Northbridges configuration block pointer.
294  *
295  */
296
297
298 AGESA_STATUS
299 AmdPowerOnResetInit (
300   IN      AMD_NB_CONFIG_BLOCK *ConfigPtr
301   )
302 {
303   AGESA_STATUS Status;
304
305   Status = LibNbApiCall (NbPowerOnResetInit, ConfigPtr);
306   return  Status;
307 }
308
309
310 /*----------------------------------------------------------------------------------------*/
311 /**
312  * NB Power on Reset Initialization.
313  *    Basic registers initialization.
314  *
315  *
316  *
317  * @param[in] NbConfigPtr   Northbridge configuration structure pointer.
318  *
319  */
320
321
322 AGESA_STATUS
323 NbPowerOnResetInit (
324   IN      AMD_NB_CONFIG *NbConfigPtr
325   )
326 {
327   AGESA_STATUS    Status;
328   REGISTER_ENTRY  *pTable;
329   UINTN           i;
330
331   CIMX_TRACE ((TRACE_DATA (GET_BLOCK_CONFIG_PTR (NbConfigPtr), CIMX_NBPOR_TRACE), "[NBPOR]NbPowerOnResetInit Enter\n"));
332   Status = NbPorInitValidateInput (NbConfigPtr);
333   if (Status == AGESA_FATAL) {
334     REPORT_EVENT (AGESA_FATAL, GENERAL_ERROR_BAD_CONFIGURATION, 0, 0, 0, 0, NbConfigPtr);
335     CIMX_ASSERT (FALSE);
336     return  Status;
337   }
338   //Init Pci Registers
339   pTable = (REGISTER_ENTRY*)FIX_PTR_ADDR (&NbPorPciTable[0], NULL);
340   for (i = 0; i < (sizeof (NbPorPciTable) / sizeof (REGISTER_ENTRY)); i++) {
341     LibNbPciRMW (NbConfigPtr->NbPciAddress.AddressValue | pTable->Register, AccessWidth8, pTable->Mask, pTable->Data, NbConfigPtr);
342     ++pTable;
343   }
344   //Init Misc registers
345   LibNbIndirectTableInit (
346     NbConfigPtr->NbPciAddress.AddressValue | NB_MISC_INDEX,
347     0,
348     (INDIRECT_REG_ENTRY*)FIX_PTR_ADDR (&NbPorMiscTable[0], NULL),
349     (sizeof (NbPorMiscTable) / sizeof (INDIRECT_REG_ENTRY)),
350     NbConfigPtr
351     );
352
353    //Init Htiu registers
354   LibNbIndirectTableInit (
355     NbConfigPtr->NbPciAddress.AddressValue | NB_HTIU_INDEX,
356     0,
357     (INDIRECT_REG_ENTRY*)FIX_PTR_ADDR (&NbPorHtiuTable[0],NULL),
358     (sizeof (NbPorHtiuTable) / sizeof (INDIRECT_REG_ENTRY)),
359     NbConfigPtr
360     );
361
362   CIMX_TRACE ((TRACE_DATA (GET_BLOCK_CONFIG_PTR (NbConfigPtr), CIMX_NBPOR_TRACE), "[NBPOR]NbPowerOnResetInit Exit\n"));
363   return Status;
364 }
365
366 /*----------------------------------------------------------------------------------------*/
367 /**
368  * Validate input parameters
369  *
370  *
371  *
372  *
373  *  @param[in] pConfig  Northbridge configuration structure pointer.
374  */
375
376
377 AGESA_STATUS
378 NbPorInitValidateInput (
379   IN      AMD_NB_CONFIG *pConfig
380   )
381 {
382   return (LibNbGetRevisionInfo (pConfig).Type == NB_UNKNOWN)?AGESA_FATAL:AGESA_SUCCESS;
383 }