4 * Southbridge Initial routine
\r
8 * @xrefitem bom "File Content Label" "Release Content"
\r
9 * @e project: CIMx-SB
\r
11 * @e \$Revision:$ @e \$Date:$
\r
15 *****************************************************************************
\r
17 * This file is part of the coreboot project.
\r
19 * Copyright (C) 2010 Advanced Micro Devices, Inc.
\r
21 * This program is free software; you can redistribute it and/or modify
\r
22 * it under the terms of the GNU General Public License as published by
\r
23 * the Free Software Foundation; version 2 of the License.
\r
25 * This program is distributed in the hope that it will be useful,
\r
26 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
27 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
28 * GNU General Public License for more details.
\r
30 * You should have received a copy of the GNU General Public License
\r
31 * along with this program; if not, write to the Free Software
\r
32 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
\r
33 * ***************************************************************************
\r
37 #include "SBPLATFORM.h"
\r
39 // Declaration of local functions
\r
42 VOID abcfgTbl (IN ABTBLENTRY* pABTbl);
\r
45 * sbUsbPhySetting - USB Phy Calibration Adjustment
\r
48 * @param[in] Value Controller PCI config address (bus# + device# + function#)
\r
51 VOID sbUsbPhySetting (IN UINT32 Value);
\r
54 /*--------------------------- Documentation Pages ---------------------------*/
\r
56 * @page LegacyInterfaceCalls Legacy Interface Calls
\r
57 * <TD>@subpage SB_POWERON_INIT_Page "SB_POWERON_INIT"</TD><TD></TD>
\r
58 * <TD>@subpage SB_BEFORE_PCI_INIT_Page "SB_BEFORE_PCI_INIT"</TD><TD></TD>
\r
59 * <TD>@subpage SB_AFTER_PCI_INIT_Page "SB_AFTER_PCI_INIT"</TD><TD></TD>
\r
60 * <TD>@subpage SB_LATE_POST_INIT_Page "SB_LATE_POST_INIT"</TD><TD></TD>
\r
61 * <TD>@subpage SB_BEFORE_PCI_RESTORE_INIT_Page "SB_BEFORE_PCI_RESTORE_INIT"</TD><TD></TD>
\r
62 * <TD>@subpage SB_AFTER_PCI_RESTORE_INIT_Page "SB_AFTER_PCI_RESTORE_INIT"</TD><TD></TD>
\r
63 * <TD>@subpage SB_SMM_SERVICE_Page "SB_SMM_SERVICE"</TD><TD></TD>
\r
64 * <TD>@subpage SB_SMM_ACPION_Page "SB_SMM_ACPION"</TD><TD></TD>
\r
66 * @page LegacyInterfaceCallOuts Legacy Interface CallOuts
\r
67 * <TD>@subpage CB_SBGPP_RESET_ASSERT_Page CB_SBGPP_RESET_ASSERT
\r
68 * <TD>@subpage CB_SBGPP_RESET_DEASSERT_Page CB_SBGPP_RESET_DEASSERT
\r
73 * sbEarlyPostByteInitTable - PCI device registers initial during early POST.
\r
76 const static REG8MASK sbEarlyPostByteInitTable[] =
\r
78 // SMBUS Device (Bus 0, Dev 20, Func 0)
\r
79 {0x00, SMBUS_BUS_DEV_FUN, 0},
\r
80 {SB_CFG_REG10, 0X00, (SBCIMx_Version & 0xFF)}, //Program the version information
\r
81 {SB_CFG_REG11, 0X00, (SBCIMx_Version >> 8)},
\r
84 // IDE Device (Bus 0, Dev 20, Func 1)
\r
85 {0x00, IDE_BUS_DEV_FUN, 0},
\r
86 {SB_IDE_REG62 + 1, ~BIT0, BIT5}, // Enabling IDE Explicit Pre-Fetch IDE PCI Config 0x62[8]=0
\r
87 // Allow MSI capability of IDE controller to be visible. IDE PCI Config 0x62[13]=1
\r
90 // Azalia Device (Bus 0, Dev 20, Func 2)
\r
91 {0x00, AZALIA_BUS_DEV_FUN, 0},
\r
92 {SB_AZ_REG4C, ~BIT0, BIT0},
\r
95 // LPC Device (Bus 0, Dev 20, Func 3)
\r
96 {0x00, LPC_BUS_DEV_FUN, 0},
\r
97 {SB_LPC_REG40, ~BIT2, BIT2}, // RPR 1.1 Enabling LPC DMA Function 0x40[2]=1b 0x78[0]=0b
\r
98 {SB_LPC_REG78, ~BIT0, 00}, // RPR 1.1 Enabling LPC DMA Function 0x40[2]=1b 0x78[0]=0b
\r
99 {SB_LPC_REG78, ~BIT1, 00}, // Disables MSI capability
\r
100 {SB_LPC_REGBB, ~BIT0, BIT0 + BIT3 + BIT4 + BIT5}, // Enabled SPI Prefetch from HOST.
\r
101 {0xFF, 0xFF, 0xFF},
\r
103 // PCIB Bridge (Bus 0, Dev 20, Func 4)
\r
104 {0x00, PCIB_BUS_DEV_FUN, 0},
\r
105 {SB_PCIB_REG40, 0xFF, BIT5}, // RPR PCI-bridge Subtractive Decode
\r
106 {SB_PCIB_REG4B, 0xFF, BIT7}, //
\r
107 {SB_PCIB_REG66, 0xFF, BIT4}, // RPR Enabling One-Prefetch-Channel Mode, PCIB_PCI_config 0x64 [20]
\r
108 {SB_PCIB_REG65, 0xFF, BIT7}, // RPR proper operation of CLKRUN#.
\r
109 {SB_PCIB_REG0D, 0x00, 0x40}, // Setting Latency Timers to 0x40, Enables the PCIB to retain ownership
\r
110 {SB_PCIB_REG1B, 0x00, 0x40}, // of the bus on the Primary side and on the Secondary side when GNT# is deasserted.
\r
111 {SB_PCIB_REG66 + 1, 0xFF, BIT1}, // RPR Enable PCI bus GNT3#..
\r
112 {0xFF, 0xFF, 0xFF},
\r
114 // SATA Device (Bus 0, Dev 17, Func 0)
\r
115 {0x00, SATA_BUS_DEV_FUN, 0},
\r
116 {SB_SATA_REG44, 0xff, BIT0}, // Enables the SATA watchdog timer register prior to the SATA BIOS post
\r
117 {SB_SATA_REG44 + 2, 0, 0x20}, // RPR 8.12 SATA PCI Watchdog timer setting
\r
118 // [SB01923] Set timer out to 0x20 to fix IDE to SATA Bridge dropping drive issue.
\r
119 {0xFF, 0xFF, 0xFF},
\r
124 * sbPmioEPostInitTable - Southbridge ACPI MMIO initial during POST.
\r
127 const static AcpiRegWrite sbPmioEPostInitTable[] =
\r
130 {PMIO_BASE >> 8, SB_PMIOA_REG54 + 3, 0xFC, BIT0 + BIT1},
\r
131 {PMIO_BASE >> 8, SB_PMIOA_REG54 + 2, 0x7F, BIT7},
\r
132 {PMIO_BASE >> 8, SB_PMIOA_REG54 + 2, 0x7F, 0x00},
\r
133 // End of HPET workaround
\r
134 // Enable SB800 A12 ACPI bits at PMIO 0xC0 [30,10:3]
\r
135 // ClrAllStsInThermalEvent 3 Set to 1 to allow ASF remote power down/power cycle, Thermal event, Fan slow event to clear all the Gevent status and enabled bits. The bit should be set to 1 all the time.
\r
136 // UsbGoodClkDlyEn 4 Set to 1 to delay de-assertion of Usb clk by 6 Osc clk. The bit should be set to 1 all the time.
\r
137 // ForceNBCPUPwr 5 Set to 1 to force CPU pwrGood to be toggled along with NB pwrGood.
\r
138 // MergeUsbPerReq 6 Set to 1 to merge usb perdical traffic into usb request as one of break event.
\r
139 // IMCWatchDogRstEn 7 Set to 1 to allow IMC watchdog timer to reset entire acpi block. The bit should be set to 1 when IMC is enabled.
\r
140 // GeventStsFixEn 8 1: Gevent status is not reset by its enable bit. 0: Gevent status is reset by its enable bit.
\r
141 // PmeTimerFixEn 9 Set to 1 to reset Pme Timer when going to sleep state.
\r
142 // UserRst2EcEn 10 Set to 1 to route user reset event to Ec. The bit should be set to 1 when IMC is enabled.
\r
143 // Smbus0ClkSEn 30 Set to 1 to enable SMBus0 controller clock stretch support.
\r
144 {PMIO_BASE >> 8, SB_PMIOA_REGC4, ~(BIT2 + BIT4), BIT2 + BIT4},
\r
145 {PMIO_BASE >> 8, SB_PMIOA_REGC0, 0, 0xF9},
\r
146 // PM_reg xC1 [3] = 1b, per RPR 2.7 CPU PwrGood Setting
\r
147 {PMIO_BASE >> 8, SB_PMIOA_REGC0 + 1, 0x04, 0x0B},
\r
148 // RtcSts 19-17 RTC_STS set only in Sleep State.
\r
149 // GppPme 20 Set to 1 to enable PME request from SB GPP.
\r
150 // Pcireset 22 Set to 1 to allow SW to reset PCIe.
\r
151 {PMIO_BASE >> 8, SB_PMIOA_REGC2, 0x20, 0x58},
\r
152 {PMIO_BASE >> 8, SB_PMIOA_REGC2 + 1, 0, 0x40},
\r
154 //Item Id: SB02037: RTC_STS should be set in S state
\r
155 //set PMIO 0xC0 [19:16] Set to 1110 to allow RTC_STS to be set only in non_G0 state.
\r
156 //{PMIO_BASE >> 8, SB_PMIOA_REGC2, (UINT8)~(0x0F), 0x0E},
\r
159 //Title: SB GPP NIC auto wake at second time sleep
\r
160 //set PMIO 0xC4 bit 2 to 1 then set PMIO 0xC0 bit 20 to 1 to enable fix for SB02034
\r
162 {PMIO_BASE >> 8, SB_PMIOA_REGC2, ~(BIT4), BIT4},
\r
164 //{GPIO_BASE >> 8, SB_GPIO_REG62 , 0x00, 0x4E},
\r
165 {PMIO_BASE >> 8, SB_PMIOA_REG74, 0x00, BIT0 + BIT1 + BIT2 + BIT4},
\r
166 {PMIO_BASE >> 8, SB_PMIOA_REGDE + 1, ~(BIT0 + BIT1), BIT0 + BIT1},
\r
167 {PMIO_BASE >> 8, SB_PMIOA_REGDE, ~BIT4, BIT4},
\r
168 {PMIO_BASE >> 8, SB_PMIOA_REGBA, ~BIT3, BIT3},
\r
169 {PMIO_BASE >> 8, SB_PMIOA_REGBA + 1, ~BIT6, BIT6},
\r
170 {PMIO_BASE >> 8, SB_PMIOA_REGBC, ~BIT1, BIT1},
\r
171 {PMIO_BASE >> 8, SB_PMIOA_REGED, ~(BIT0 + BIT1), 0},
\r
172 //RPR Hiding Flash Controller PM_IO 0xDC[7] = 0x0 & PM_IO 0xDC [1:0]=0x01
\r
173 {PMIO_BASE >> 8, SB_PMIOA_REGDC, 0x7C, BIT0},
\r
174 // RPR Turning off FC clock
\r
175 {MISC_BASE >> 8, SB_MISC_REG40 + 1, ~(BIT3 + BIT2), BIT3 + BIT2},
\r
176 {MISC_BASE >> 8, SB_MISC_REG40 + 2, ~BIT0, BIT0},
\r
177 {SMI_BASE >> 8, SB_SMI_Gevent0, 0, 29},
\r
178 {SMI_BASE >> 8, SB_SMI_Gevent1, 0, 1},
\r
179 {SMI_BASE >> 8, SB_SMI_Gevent2, 0, 29},
\r
180 {SMI_BASE >> 8, SB_SMI_Gevent3, 0, 29},
\r
181 {SMI_BASE >> 8, SB_SMI_Gevent4, 0, 4},
\r
182 {SMI_BASE >> 8, SB_SMI_Gevent5, 0, 5},
\r
183 {SMI_BASE >> 8, SB_SMI_Gevent6, 0, 6},
\r
184 {SMI_BASE >> 8, SB_SMI_Gevent7, 0, 29},
\r
186 {SMI_BASE >> 8, SB_SMI_Gevent9, 0, 29},
\r
187 {SMI_BASE >> 8, SB_SMI_Gevent10, 0, 29},
\r
188 {SMI_BASE >> 8, SB_SMI_Gevent11, 0, 29},
\r
189 {SMI_BASE >> 8, SB_SMI_Gevent12, 0, 29},
\r
190 {SMI_BASE >> 8, SB_SMI_Gevent13, 0, 29},
\r
191 {SMI_BASE >> 8, SB_SMI_Gevent14, 0, 29},
\r
192 {SMI_BASE >> 8, SB_SMI_Gevent15, 0, 29},
\r
193 {SMI_BASE >> 8, SB_SMI_Gevent16, 0, 29},
\r
194 {SMI_BASE >> 8, SB_SMI_Gevent17, 0, 29},
\r
195 {SMI_BASE >> 8, SB_SMI_Gevent18, 0, 29},
\r
196 {SMI_BASE >> 8, SB_SMI_Gevent19, 0, 29},
\r
197 {SMI_BASE >> 8, SB_SMI_Gevent20, 0, 29},
\r
198 {SMI_BASE >> 8, SB_SMI_Gevent21, 0, 29},
\r
199 {SMI_BASE >> 8, SB_SMI_Gevent22, 0, 29},
\r
200 {SMI_BASE >> 8, SB_SMI_Gevent23, 0, 29},
\r
202 {SMI_BASE >> 8, SB_SMI_Usbwakup0, 0, 11},
\r
203 {SMI_BASE >> 8, SB_SMI_Usbwakup1, 0, 11},
\r
204 {SMI_BASE >> 8, SB_SMI_Usbwakup2, 0, 11},
\r
205 {SMI_BASE >> 8, SB_SMI_Usbwakup3, 0, 11},
\r
206 {SMI_BASE >> 8, SB_SMI_IMCGevent0, 0, 12},
\r
207 {SMI_BASE >> 8, SB_SMI_IMCGevent1, 0, 29},
\r
208 {SMI_BASE >> 8, SB_SMI_FanThGevent, 0, 13},
\r
209 {SMI_BASE >> 8, SB_SMI_SBGppPme0, 0, 15},
\r
210 {SMI_BASE >> 8, SB_SMI_SBGppPme1, 0, 16},
\r
211 {SMI_BASE >> 8, SB_SMI_SBGppPme2, 0, 17},
\r
212 {SMI_BASE >> 8, SB_SMI_SBGppPme3, 0, 18},
\r
213 {SMI_BASE >> 8, SB_SMI_SBGppHp0, 0, 29},
\r
214 {SMI_BASE >> 8, SB_SMI_SBGppHp1, 0, 29},
\r
215 {SMI_BASE >> 8, SB_SMI_SBGppHp2, 0, 29},
\r
216 {SMI_BASE >> 8, SB_SMI_SBGppHp3, 0, 29},
\r
217 {SMI_BASE >> 8, SB_SMI_GecPme, 0, 19},
\r
218 {SMI_BASE >> 8, SB_SMI_CIRPme, 0, 23},
\r
219 {SMI_BASE >> 8, SB_SMI_Gevent8, 0, 26},
\r
220 {SMI_BASE >> 8, SB_SMI_AzaliaPme, 0, 27},
\r
221 {SMI_BASE >> 8, SB_SMI_SataGevent0, 0, 30},
\r
222 {SMI_BASE >> 8, SB_SMI_SataGevent1, 0, 31},
\r
224 {SMI_BASE >> 8, SB_SMI_WakePinGevent, 0, 29},
\r
225 {SMI_BASE >> 8, SB_SMI_ASFMasterIntr, 0, 29},
\r
226 {SMI_BASE >> 8, SB_SMI_ASFSlaveIntr, 0, 29},
\r
228 // {SMI_BASE >> 8, SB_SMI_REG04, ~BIT4, BIT4},
\r
229 // {SMI_BASE >> 8, SB_SMI_REG04 + 1, ~BIT0, BIT0},
\r
230 // {SMI_BASE >> 8, SB_SMI_REG04 + 2, ~BIT3, BIT3},
\r
231 {SMI_BASE >> 8, SB_SMI_REG08, ~BIT4, 0},
\r
232 {SMI_BASE >> 8, SB_SMI_REG08+3, ~BIT2, 0},
\r
233 // {SMI_BASE >> 8, SB_SMI_REG0C, ~BIT4, BIT4},
\r
234 {SMI_BASE >> 8, SB_SMI_REG0C + 2, ~BIT3, BIT3},
\r
235 {SMI_BASE >> 8, SB_SMI_TWARN, 0, 9},
\r
236 {SMI_BASE >> 8, SB_SMI_TMI, 0, 29},
\r
237 {0xFF, 0xFF, 0xFF, 0xFF},
\r
241 * abTblEntry800 - AB-Link Configuration Table for SB800
\r
244 const static ABTBLENTRY abTblEntry800[] =
\r
246 // RPR Enable downstream posted transactions to pass non-posted transactions.
\r
247 {ABCFG, SB_ABCFG_REG10090, BIT8 + BIT16, BIT8 + BIT16},
\r
249 // RPR Enable SB800 to issue memory read/write requests in the upstream direction.
\r
250 {AXCFG, SB_AB_REG04, BIT2, BIT2},
\r
252 // RPR Enabling IDE/PCIB Prefetch for Performance Enhancement
\r
253 // PCIB prefetch ABCFG 0x10060 [20] = 1 ABCFG 0x10064 [20] = 1
\r
254 {ABCFG, SB_ABCFG_REG10060, BIT20, BIT20}, // PCIB prefetch enable
\r
255 {ABCFG, SB_ABCFG_REG10064, BIT20, BIT20}, // PCIB prefetch enable
\r
257 // RPR Controls the USB OHCI controller prefetch used for enhancing performance of ISO out devices.
\r
258 // RPR Setting B-Link Prefetch Mode (ABCFG 0x80 [18:17] = 11)
\r
259 {ABCFG, SB_ABCFG_REG80, BIT0 + BIT17 + BIT18, BIT0 + BIT17 + BIT18},
\r
261 // RPR Enabled SMI ordering enhancement. ABCFG 0x90[21]
\r
262 // RPR USB Delay A-Link Express L1 State. ABCFG 0x90[17]
\r
263 {ABCFG, SB_ABCFG_REG90, BIT21 + BIT17, BIT21 + BIT17},
\r
265 // RPR Disable the credit variable in the downstream arbitration equation
\r
266 // RPR Register bit to qualify additional address bits into downstream register programming. (A12 BIT1 default is set)
\r
267 {ABCFG, SB_ABCFG_REG9C, BIT0, BIT0},
\r
269 // RPR Enabling Detection of Upstream Interrupts ABCFG 0x94 [20] = 1
\r
270 // ABCFG 0x94 [19:0] = cpu interrupt delivery address [39:20]
\r
271 {ABCFG, SB_ABCFG_REG94, BIT20, BIT20 + 0x00FEE},
\r
273 // RPR Programming cycle delay for AB and BIF clock gating
\r
274 // RPR Enable the AB and BIF clock-gating logic.
\r
275 // RPR Enable the A-Link int_arbiter enhancement to allow the A-Link bandwidth to be used more efficiently
\r
276 // RPR Enable the requester ID for upstream traffic. [16]: SB/NB link [17]: GPP
\r
277 {ABCFG, SB_ABCFG_REG10054, 0x00FFFFFF, 0x010407FF},
\r
278 {ABCFG, SB_ABCFG_REG98, 0xFFFF00FF, 0x00034700},
\r
279 {ABCFG, SB_ABCFG_REG54, 0x00FF0000, 0x00040000},
\r
280 // RPR Non-Posted Memory Write Support
\r
281 {AX_INDXC, SB_AX_INDXC_REG10, BIT9, BIT9},
\r
282 {ABCFG, 0, 0, (UINT8) 0xFF}, // This dummy entry is to clear ab index
\r
283 { (UINT8)0xFF, (UINT8)0xFF, (UINT8)0xFF, (UINT8)0xFF},
\r
287 * SbPcieOrderRule - AB-Link Configuration Table for ablink Post Pass Np Downstream/Upstream Feature
\r
290 const static ABTBLENTRY SbPcieOrderRule[] =
\r
292 // abPostPassNpDownStreamTbl
\r
293 {ABCFG, SB_ABCFG_REG10060, BIT31, BIT31},
\r
294 {ABCFG, SB_ABCFG_REG1009C, BIT4 + BIT5, BIT4 + BIT5},
\r
295 {ABCFG, SB_ABCFG_REG9C, BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7, BIT2 + BIT3 + BIT4 + BIT5 + BIT6 + BIT7},
\r
296 {ABCFG, SB_ABCFG_REG90, BIT21 + BIT22 + BIT23, BIT21 + BIT22 + BIT23},
\r
297 {ABCFG, SB_ABCFG_REGF0, BIT6 + BIT5, BIT6 + BIT5},
\r
298 {AXINDC, SB_AX_INDXC_REG02, BIT9, BIT9},
\r
299 {ABCFG, SB_ABCFG_REG10090, BIT9 + BIT10 + BIT11 + BIT12, BIT9 + BIT10 + BIT11 + BIT12},
\r
300 // abPostPassNpUpStreamTbl
\r
301 {ABCFG, SB_ABCFG_REG58, BIT10, BIT10},
\r
302 {ABCFG, SB_ABCFG_REGF0, BIT3 + BIT4, BIT3 + BIT4},
\r
303 {ABCFG, SB_ABCFG_REG54, BIT1, BIT1},
\r
304 { (UINT8)0xFF, (UINT8)0xFF, (UINT8)0xFF, (UINT8)0xFF},
\r
308 * commonInitEarlyBoot - Config Southbridge SMBUS/ACPI/IDE/LPC/PCIB.
\r
310 * This settings should be done during S3 resume also
\r
312 * @param[in] pConfig Southbridge configuration structure pointer.
\r
316 commonInitEarlyBoot (
\r
317 IN AMDSBCFG* pConfig
\r
322 SB_CPUID_DATA CpuId;
\r
323 UINT8 cimNativepciesupport;
\r
327 cimNativepciesupport = (UINT8) pConfig->NativePcieSupport;
\r
328 cimIrConfig = (UINT8) pConfig->IrConfig;
\r
329 #if SB_CIMx_PARAMETER == 0
\r
330 cimNativepciesupport = cimNativepciesupportDefault;
\r
331 cimIrConfig = cimIrConfigDefault;
\r
334 //IR init Logical device 0x05
\r
335 if ( cimIrConfig ) {
\r
336 // Enable EC_PortActive
\r
337 RWPCI (((LPC_BUS_DEV_FUN << 16) + SB_LPC_REGA4), AccWidthUint16 | S3_SAVE, 0xFFFE, BIT0);
\r
339 RWEC8 (0x07, 0x00, 0x05); //Select logical device 05, IR controller
\r
340 RWEC8 (0x60, 0x00, 0x05); //Set Base Address to 550h
\r
341 RWEC8 (0x61, 0x00, 0x50);
\r
342 RWEC8 (0x70, 0xF0, 0x05); //Set IRQ to 05h
\r
343 RWEC8 (0x30, 0x00, 0x01); //Enable logical device 5, IR controller
\r
345 WriteIO (0x550, AccWidthUint8, &Data);
\r
346 ReadIO (0x551, AccWidthUint8, &Data);
\r
347 Data = ((Data & 0xFC ) | cimIrConfig);
\r
348 WriteIO (0x551, AccWidthUint8, &Data);
\r
350 Data = 0xA0; // EC APIC index
\r
351 WriteIO (SB_IOMAP_REGC00, AccWidthUint8, &Data);
\r
352 Data = 0x05; // IRQ5
\r
353 WriteIO (SB_IOMAP_REGC01, AccWidthUint8, &Data);
\r
356 RWEC8 (0x07, 0x00, 0x05); //Select logical device 05, IR controller
\r
357 RWEC8 (0x30, 0x00, 0x00); //Disable logical device 5, IR controller
\r
362 CpuidRead (0x01, &CpuId);
\r
365 // SB CFG programming
\r
367 //Make BAR registers of smbus visible.
\r
368 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGC8 + 1, AccWidthUint8, ~BIT6, 0);
\r
369 //Early post initialization of pci config space
\r
370 programPciByteTable ((REG8MASK*) FIXUP_PTR (&sbEarlyPostByteInitTable[0]), sizeof (sbEarlyPostByteInitTable) / sizeof (REG8MASK) );
\r
371 if ( pConfig->BuildParameters.SmbusSsid != NULL ) {
\r
372 RWPCI ((SMBUS_BUS_DEV_FUN << 16) + SB_CFG_REG2C, AccWidthUint32 | S3_SAVE, 0x00, pConfig->BuildParameters.SmbusSsid);
\r
374 //Make BAR registers of smbus invisible.
\r
375 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGC8 + 1, AccWidthUint8, ~BIT6, BIT6);
\r
378 // LPC CFG programming
\r
380 // SSID for LPC Controller
\r
381 if (pConfig->BuildParameters.LpcSsid != NULL ) {
\r
382 RWPCI ((LPC_BUS_DEV_FUN << 16) + SB_LPC_REG2C, AccWidthUint32 | S3_SAVE, 0x00, pConfig->BuildParameters.LpcSsid);
\r
385 if ( pConfig->BuildParameters.LpcMsi) {
\r
386 RWPCI ((LPC_BUS_DEV_FUN << 16) + SB_LPC_REG78, AccWidthUint32 | S3_SAVE, ~BIT1, BIT1);
\r
390 // PCIB CFG programming
\r
392 //Disable or Enable PCI Clks based on input
\r
393 RWPCI ((PCIB_BUS_DEV_FUN << 16) + SB_PCIB_REG42, AccWidthUint8 | S3_SAVE, ~(BIT5 + BIT4 + BIT3 + BIT2), ((pConfig->PciClks) & 0x0F) << 2 );
\r
394 RWPCI ((PCIB_BUS_DEV_FUN << 16) + SB_PCIB_REG4A, AccWidthUint8 | S3_SAVE, ~(BIT1 + BIT0), (pConfig->PciClks) >> 4 );
\r
396 if ( pConfig->BuildParameters.PcibMsi) {
\r
397 RWPCI ((PCIB_BUS_DEV_FUN << 16) + SB_PCIB_REG40, AccWidthUint8 | S3_SAVE, ~BIT3, BIT3);
\r
401 // AB CFG programming
\r
403 // Read Arbiter address, Arbiter address is in PMIO 6Ch
\r
404 ReadMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG6C, AccWidthUint16, &dwTempVar);
\r
405 RWIO (dwTempVar, AccWidthUint8, 0, 0); // Write 0 to enable the arbiter
\r
407 abLinkInitBeforePciEnum (pConfig); // Set ABCFG registers
\r
409 if ( pConfig->BuildParameters.AbMsi) {
\r
410 abValue = readAlink (SB_ABCFG_REG94 | (UINT32) (ABCFG << 29));
\r
411 abValue = abValue | BIT20;
\r
412 writeAlink (SB_ABCFG_REG94 | (UINT32) (ABCFG << 29), abValue);
\r
417 // SB Specific Function programming
\r
420 // PCIE Native setting
\r
421 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGBA + 1, AccWidthUint8, ~BIT14, 0);
\r
422 if ( pConfig->NativePcieSupport == 1) {
\r
423 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG74 + 3, AccWidthUint8, ~(BIT3 + BIT1 + BIT0), BIT2 + BIT0);
\r
425 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG74 + 3, AccWidthUint8, ~(BIT3 + BIT1 + BIT0), BIT2);
\r
428 #ifdef ACPI_SLEEP_TRAP
\r
429 // Set SLP_TYPE as SMI event
\r
430 RWMEM (ACPI_MMIO_BASE + SMI_BASE + SB_SMI_REGB0, AccWidthUint8, ~(BIT2 + BIT3), BIT2);
\r
431 // Disabled SLP function for S1/S3/S4/S5
\r
432 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGBE, AccWidthUint8, ~BIT5, 0x00);
\r
433 // Set S state transition disabled (BIT0) force ACPI to send SMI message when writing to SLP_TYP Acpi register. (BIT1)
\r
434 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG08 + 3, AccWidthUint8, ~(BIT0 + BIT1), BIT1);
\r
435 // Enabled Global Smi ( BIT7 clear as 0 to enable )
\r
436 RWMEM (ACPI_MMIO_BASE + SMI_BASE + SB_SMI_REG98 + 3 , AccWidthUint8, ~BIT7, 0x00);
\r
438 if ( pConfig->SbUsbPll == 0) {
\r
439 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGF3, AccWidthUint8, 0, 0x20);
\r
441 // Set Stutter timer settings
\r
442 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG80 + 1, AccWidthUint8, ~(BIT3 + BIT4), BIT3 + BIT4);
\r
443 // Set LDTSTP# duration to 10us for HydraD CPU, or when HT link is 200MHz
\r
444 if ((pConfig->AnyHT200MhzLink) || ((CpuId.EAX_Reg & 0x00ff00f0) == 0x100080) || ((CpuId.EAX_Reg & 0x00ff00f0) == 0x100090) || ((CpuId.EAX_Reg & 0x00ff00f0) == 0x1000A0)) {
\r
445 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG94, AccWidthUint8, 0, 0x0A);
\r
446 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG80 + 3, AccWidthUint8 | S3_SAVE, 0xFE, 0x28);
\r
448 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG94, AccWidthUint8, 0, 0x01);
\r
449 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG80 + 3, AccWidthUint8 | S3_SAVE, 0xFE, 0x20);
\r
452 //PM_Reg 0x7A[15] (CountHaltMsgEn) should be set when C1e option is enabled
\r
453 //PM_Reg 0x7A[3:0] (NumOfCpu) should be set to 1h when C1e option is enabled
\r
454 //PM_Reg 0x80[13] has to set to 1 to enable Message C scheme.
\r
455 if (pConfig->MTC1e) {
\r
456 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG7A, AccWidthUint16 | S3_SAVE, 0x7FF0, BIT15 + 1);
\r
457 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG80 + 1, AccWidthUint8 | S3_SAVE, ~BIT5, BIT5);
\r
460 programSbAcpiMmioTbl ((AcpiRegWrite *) (pConfig->OEMPROGTBL.OemProgrammingTablePtr_Ptr));
\r
464 * abSpecialSetBeforePciEnum - Special setting ABCFG registers before PCI emulation.
\r
467 * @param[in] pConfig Southbridge configuration structure pointer.
\r
471 abSpecialSetBeforePciEnum (
\r
472 IN AMDSBCFG* pConfig
\r
476 abValue = readAlink (SB_ABCFG_REGC0 | (UINT32) (ABCFG << 29));
\r
478 if ( pConfig->SbPcieOrderRule && abValue ) {
\r
479 abValue = readAlink (SB_RCINDXC_REG02 | (UINT32) (RCINDXC << 29));
\r
480 abValue = abValue | BIT9;
\r
481 writeAlink (SB_RCINDXC_REG02 | (UINT32) (RCINDXC << 29), abValue);
\r
487 IN AMDSBCFG* pConfig
\r
490 if ( pConfig->SbUsbPll == 0) {
\r
491 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGF3, AccWidthUint8, 0, 0x00);
\r
496 * commonInitEarlyPost - Config Southbridge SMBUS/ACPI/IDE/LPC/PCIB.
\r
498 * This settings might not program during S3 resume
\r
500 * @param[in] pConfig Southbridge configuration structure pointer.
\r
504 commonInitEarlyPost (
\r
505 IN AMDSBCFG* pConfig
\r
508 UINT8 dbPortStatus;
\r
509 UINT8 cimSpreadSpectrum;
\r
510 UINT32 cimSpreadSpectrumType;
\r
514 cimSpreadSpectrum = pConfig->SpreadSpectrum;
\r
515 cimSpreadSpectrumType = pConfig->BuildParameters.SpreadSpectrumType;
\r
516 #if SB_CIMx_PARAMETER == 0
\r
517 cimSpreadSpectrum = cimSpreadSpectrumDefault;
\r
518 cimSpreadSpectrumType = cimSpreadSpectrumTypeDefault;
\r
520 programSbAcpiMmioTbl ((AcpiRegWrite*) FIXUP_PTR (&sbPmioEPostInitTable[0]));
\r
522 // CallBackToOEM (PULL_UP_PULL_DOWN_SETTINGS, NULL, pConfig);
\r
524 if ( cimSpreadSpectrum ) {
\r
525 // Misc_Reg_40[25]=1 -> allow to change spread profile
\r
526 // Misc_Reg19=83 -> new spread profile
\r
527 // Misc_Reg[12:10]=9975be
\r
530 // Misc_Misc_Reg_08[0]=1 -> enable spread
\r
531 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x43, AccWidthUint8, ~BIT1, BIT1);
\r
532 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x19, AccWidthUint8, 0, 0x83);
\r
533 getChipSysMode (&dbPortStatus);
\r
534 if ( ((dbPortStatus & ChipSysIntClkGen) != ChipSysIntClkGen) ) {
\r
535 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x1A, AccWidthUint8, ~(BIT5 + BIT6 + BIT7), 0x80);
\r
538 if ( cimSpreadSpectrumType == 0 ) {
\r
539 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x12, AccWidthUint8, 0, 0x99);
\r
540 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x11, AccWidthUint8, 0, 0x75);
\r
541 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x10, AccWidthUint8, 0, 0xBE);
\r
542 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x0B, AccWidthUint8, 0, 0x91);
\r
543 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x09, AccWidthUint8, 0, 0x21);
\r
544 } else { // Spread profile for Ontario CPU related platform
\r
545 // This spread profile setting is for Ontario HDMI & DVI output from DP with -0.425%
\r
546 // Misc_Reg[12:10]=828FA8
\r
549 // Misc_Reg10[25:24]=01b
\r
550 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x12, AccWidthUint8, 0, 0x82);
\r
551 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x11, AccWidthUint8, 0, 0x8F);
\r
552 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x10, AccWidthUint8, 0, 0xA8);
\r
553 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x0B, AccWidthUint8, 0, 0x11);
\r
554 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x09, AccWidthUint8, 0, 0x21);
\r
555 RWMEM (ACPI_MMIO_BASE + MISC_BASE + 0x13, AccWidthUint8, 0xFC, 0x1);
\r
558 RWMEM (ACPI_MMIO_BASE + MISC_BASE + SB_MISC_REG08, AccWidthUint8, 0xFE, 0x01);
\r
560 RWMEM (ACPI_MMIO_BASE + MISC_BASE + SB_MISC_REG08, AccWidthUint8, 0xFE, 0x00);
\r
563 // RPR PLL 100Mhz Reference Clock Buffer setting for internal clock generator mode
\r
564 getChipSysMode (&dbPortStatus);
\r
565 if ( ((dbPortStatus & ChipSysIntClkGen) == ChipSysIntClkGen) ) {
\r
566 RWMEM (ACPI_MMIO_BASE + MISC_BASE + SB_MISC_REG04 + 1, AccWidthUint8, ~BIT5, BIT5);
\r
569 // Set ASF SMBUS master function enabled here (temporary)
\r
570 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG28, AccWidthUint16 | S3_SAVE, ~(BIT0 + BIT2), BIT0 + BIT2);
\r
572 programSbAcpiMmioTbl ((AcpiRegWrite *) (pConfig->OEMPROGTBL.OemProgrammingTablePtr_Ptr));
\r
573 #ifndef NO_EC_SUPPORT
\r
574 // Software IMC enable
\r
575 if (((pConfig->BuildParameters.ImcEnableOverWrite == 1) && ((dbPortStatus & ChipSysEcEnable) == 0)) || ((pConfig->BuildParameters.ImcEnableOverWrite == 2) && ((dbPortStatus & ChipSysEcEnable) == ChipSysEcEnable))) {
\r
576 if (validateImcFirmware (pConfig)) {
\r
577 softwareToggleImcStrapping (pConfig);
\r
579 CallBackToOEM (IMC_FIRMWARE_FAIL, 0, pConfig);
\r
586 * abLinkInitBeforePciEnum - Set ABCFG registers before PCI emulation.
\r
589 * @param[in] pConfig Southbridge configuration structure pointer.
\r
593 abLinkInitBeforePciEnum (
\r
594 IN AMDSBCFG* pConfig
\r
597 UINT32 cimResetCpuOnSyncFlood;
\r
598 ABTBLENTRY *pAbTblPtr;
\r
601 cimResetCpuOnSyncFlood = pConfig->ResetCpuOnSyncFlood;
\r
602 #if SB_CIMx_PARAMETER == 0
\r
603 cimResetCpuOnSyncFlood = cimResetCpuOnSyncFloodDefault;
\r
606 if ( pConfig->SbPcieOrderRule ) {
\r
607 pAbTblPtr = (ABTBLENTRY *) FIXUP_PTR (&SbPcieOrderRule[0]);
\r
608 abcfgTbl (pAbTblPtr);
\r
610 pAbTblPtr = (ABTBLENTRY *) FIXUP_PTR (&abTblEntry800[0]);
\r
611 abcfgTbl (pAbTblPtr);
\r
612 if ( cimResetCpuOnSyncFlood ) {
\r
613 rwAlink (SB_ABCFG_REG10050 | (UINT32) (ABCFG << 29), ~BIT2, BIT2);
\r
618 * abcfgTbl - Program ABCFG by input table.
\r
621 * @param[in] pABTbl ABCFG config table.
\r
626 IN ABTBLENTRY* pABTbl
\r
631 while ( (pABTbl->regType) != 0xFF ) {
\r
632 if ( pABTbl->regType > AXINDC ) {
\r
633 ddValue = pABTbl->regIndex | (pABTbl->regType << 29);
\r
634 writeAlink (ddValue, ((readAlink (ddValue)) & (0xFFFFFFFF^ (pABTbl->regMask))) | pABTbl->regData);
\r
636 ddValue = 0x30 | (pABTbl->regType << 29);
\r
637 writeAlink (ddValue, pABTbl->regIndex);
\r
638 ddValue = 0x34 | (pABTbl->regType << 29);
\r
639 writeAlink (ddValue, ((readAlink (ddValue)) & (0xFFFFFFFF^ (pABTbl->regMask))) | pABTbl->regData);
\r
644 //Clear ALink Access Index
\r
646 WriteIO (ALINK_ACCESS_INDEX, AccWidthUint32 | S3_SAVE, &ddValue);
\r
650 * commonInitLateBoot - Prepare Southbridge register setting to boot to OS.
\r
653 * @param[in] pConfig Southbridge configuration structure pointer.
\r
657 commonInitLateBoot (
\r
658 IN AMDSBCFG* pConfig
\r
663 // We need to do the following setting in late post also because some bios core pci enumeration changes these values
\r
664 // programmed during early post.
\r
665 // RPR 4.5 Master Latency Timer
\r
668 WritePCI ((PCIB_BUS_DEV_FUN << 16) + SB_PCIB_REG0D, AccWidthUint8, &dbValue);
\r
669 WritePCI ((PCIB_BUS_DEV_FUN << 16) + SB_PCIB_REG1B, AccWidthUint8, &dbValue);
\r
671 //SB P2P AutoClock control settings.
\r
672 ddVar = (pConfig->PcibAutoClkCtrlHigh << 16) | (pConfig->PcibAutoClkCtrlLow);
\r
673 WritePCI ((PCIB_BUS_DEV_FUN << 16) + SB_PCIB_REG4C, AccWidthUint32, &ddVar);
\r
674 ddVar = (pConfig->PcibClkStopOverride);
\r
675 RWPCI ((PCIB_BUS_DEV_FUN << 16) + SB_PCIB_REG50, AccWidthUint16, 0x3F, (UINT16) (ddVar << 6));
\r
677 RWPCI ((LPC_BUS_DEV_FUN << 16) + SB_LPC_REGBB, AccWidthUint8, 0xBF | S3_SAVE, BIT3 + BIT4 + BIT5);
\r
679 // USB Phy Calibration Adjustment
\r
680 ddVar = (USB1_EHCI_BUS_DEV_FUN << 16);
\r
681 sbUsbPhySetting (ddVar);
\r
682 ddVar = (USB2_EHCI_BUS_DEV_FUN << 16);
\r
683 sbUsbPhySetting (ddVar);
\r
684 ddVar = (USB3_EHCI_BUS_DEV_FUN << 16);
\r
685 sbUsbPhySetting (ddVar);
\r
687 c3PopupSetting (pConfig);
\r
688 FusionRelatedSetting (pConfig);
\r
692 * sbUsbPhySetting - USB Phy Calibration Adjustment
\r
695 * @param[in] Value Controller PCI config address (bus# + device# + function#)
\r
703 UINT32 ddBarAddress;
\r
704 UINT32 ddPhyStatus03;
\r
705 UINT32 ddPhyStatus4;
\r
708 ReadPCI ((UINT32) Value + SB_EHCI_REG10, AccWidthUint32, &ddBarAddress);
\r
709 if ( (ddBarAddress != - 1) && (ddBarAddress != 0) ) {
\r
710 ReadMEM ( ddBarAddress + SB_EHCI_BAR_REGA8, AccWidthUint32, &ddPhyStatus03);
\r
711 ReadMEM ( ddBarAddress + SB_EHCI_BAR_REGAC, AccWidthUint32, &ddPhyStatus4);
\r
712 ddPhyStatus03 &= 0x07070707;
\r
713 ddPhyStatus4 &= 0x00000007;
\r
714 if ( (ddPhyStatus03 != 0x00) | (ddPhyStatus4 != 0x00) ) {
\r
715 // RPR 7.7 USB 2.0 Ports Driving Strength step 1
\r
716 //Make BAR registers of smbus visible.
\r
717 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGC8 + 1, AccWidthUint8, ~BIT6, 0);
\r
718 ReadPCI ((SMBUS_BUS_DEV_FUN << 16) + SB_CFG_REG08, AccWidthUint8, &dbRevId);
\r
719 //Make BAR registers of smbus invisible.
\r
720 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGC8 + 1, AccWidthUint8, ~BIT6, BIT6);
\r
721 if (dbRevId == 0x41) { // A12
\r
722 RWMEM (ddBarAddress + SB_EHCI_BAR_REGC0, AccWidthUint32, 0xFFFF00FF, 0x1500);
\r
723 RWMEM (ddBarAddress + SB_EHCI_BAR_REGC4, AccWidthUint32, 0xFFFFF0FF, 0);
\r
724 } else if (dbRevId == 0x42) { // A13
\r
725 RWMEM (ddBarAddress + SB_EHCI_BAR_REGC0, AccWidthUint32, 0xFFFF00FF, 0x0F00);
\r
726 RWMEM (ddBarAddress + SB_EHCI_BAR_REGC4, AccWidthUint32, 0xFFFFF0FF, 0x0100);
\r
733 * hpetInit - Program Southbridge HPET function
\r
737 * @param[in] pConfig Southbridge configuration structure pointer.
\r
738 * @param[in] pStaticOptions Platform build configuration table.
\r
743 IN AMDSBCFG* pConfig,
\r
744 IN BUILDPARAM *pStaticOptions
\r
747 DESCRIPTION_HEADER* pHpetTable;
\r
748 UINT8 cimHpetTimer;
\r
749 UINT8 cimHpetMsiDis;
\r
751 cimHpetTimer = (UINT8) pConfig->HpetTimer;
\r
752 cimHpetMsiDis = (UINT8) pConfig->HpetMsiDis;
\r
753 #if SB_CIMx_PARAMETER == 0
\r
754 cimHpetTimer = cimHpetTimerDefault;
\r
755 cimHpetMsiDis = cimHpetMsiDisDefault;
\r
758 if ( cimHpetTimer == TRUE ) {
\r
759 //Program the HPET BAR address
\r
760 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG50, AccWidthUint32 | S3_SAVE, 0xFFFFF800, pStaticOptions->HpetBase);
\r
761 //Enabling decoding of HPET MMIO
\r
762 //Enable HPET MSI support
\r
763 //Enable High Precision Event Timer (also called Multimedia Timer) interrupt
\r
764 if ( cimHpetMsiDis == FALSE ) {
\r
765 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG50, AccWidthUint32 | S3_SAVE, 0xFFFFF800, BIT0 + BIT1 + BIT2 + BIT3 + BIT4);
\r
767 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG50, AccWidthUint32 | S3_SAVE, 0xFFFFF800, BIT0 + BIT1);
\r
771 if ( ! (pConfig->S3Resume) ) {
\r
772 pHpetTable = (DESCRIPTION_HEADER*) ACPI_LocateTable (Int32FromChar('H', 'P', 'E', 'T'));
\r
774 if ( pHpetTable != NULL ) {
\r
775 pHpetTable->Signature = Int32FromChar('T', 'E', 'P', 'H');
\r
781 * c3PopupSetting - Program Southbridge C state function
\r
785 * @param[in] pConfig Southbridge configuration structure pointer.
\r
790 IN AMDSBCFG* pConfig
\r
796 //RPR C-State and VID/FID Change
\r
797 dbValue = getNumberOfCpuCores ();
\r
799 //PM 0x80[2]=1, For system with dual core CPU, set this bit to 1 to automatically clear BM_STS when the C3 state is being initiated.
\r
800 //PM 0x80[1]=1, For system with dual core CPU, set this bit to 1 and BM_STS will cause C3 to wakeup regardless of BM_RLD
\r
801 //PM 0x7E[6]=1, Enable pop-up for C3. For internal bus mastering or BmReq# from the NB, the SB will de-assert
\r
802 //LDTSTP# (pop-up) to allow DMA traffic, then assert LDTSTP# again after some idle time.
\r
803 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG80, AccWidthUint8 | S3_SAVE, ~(BIT1 + BIT2), (BIT1 + BIT2));
\r
804 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG7E, AccWidthUint8 | S3_SAVE, ~BIT6, BIT6);
\r
806 //SB800 needs to changed for RD790 support
\r
807 //PM 0x80 [8] = 0 for system with RS780
\r
808 //Note: RS690 north bridge has AllowLdtStop built for both display and PCIE traffic to wake up the HT link.
\r
809 //BmReq# needs to be ignored otherwise may cause LDTSTP# not to toggle.
\r
810 //PM_IO 0x80[3]=1, Ignore BM_STS_SET message from NB
\r
811 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG80, AccWidthUint16 | S3_SAVE, ~(BIT9 + BIT8 + BIT7 + BIT4 + BIT3 + BIT2 + BIT1 + BIT0), 0x21F);
\r
812 //LdtStartTime = 10h for minimum LDTSTP# de-assertion duration of 16us in StutterMode. This is to guarantee that
\r
813 //the HT link has been safely reconnected before it can be disconnected again. If C3 pop-up is enabled, the 16us also
\r
814 //serves as the minimum idle time before LDTSTP# can be asserted again. This allows DMA to finish before the HT
\r
815 //link is disconnected.
\r
816 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG94 + 2, AccWidthUint8, 0, 0x10);
\r
818 //This setting provides 16us delay before the assertion of LDTSTOP# when C3 is entered. The
\r
819 //delay will allow USB DMA to go on in a continuous manner
\r
820 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG98 + 1, AccWidthUint8, 0, 0x10);
\r
821 // Not in the RPR so far, it's hand writing from ASIC
\r
822 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG7C, AccWidthUint8 | S3_SAVE, 0, 0x85);
\r
823 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG7C + 1, AccWidthUint8 | S3_SAVE, 0, 0x01);
\r
824 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG7E + 1, AccWidthUint8 | S3_SAVE, ~(BIT7 + BIT5), BIT7 + BIT5);
\r
825 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG88 + 1, AccWidthUint8 | S3_SAVE, ~BIT4, BIT4);
\r
826 // RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG94, AccWidthUint8, 0, 0x10);
\r
827 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG98 + 3, AccWidthUint8, 0, 0x10);
\r
828 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGB4 + 1, AccWidthUint8, 0, 0x0B);
\r
829 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG88, AccWidthUint8 | S3_SAVE, 0xFF, BIT4);
\r
830 if (pConfig->LdtStpDisable) {
\r
831 RWMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REG88, AccWidthUint8 | S3_SAVE, ~BIT5, 0);
\r
836 * FusionRelatedSetting - Program Fusion C related function
\r
840 * @param[in] pConfig Southbridge configuration structure pointer.
\r
844 FusionRelatedSetting (
\r
845 IN AMDSBCFG* pConfig
\r
849 UINT8 cimTimerTickTrack;
\r
850 UINT8 cimClockInterruptTag;
\r
851 UINT8 cimOhciTrafficHanding;
\r
852 UINT8 cimEhciTrafficHanding;
\r
853 UINT8 cimFusionMsgCMultiCore;
\r
854 UINT8 cimFusionMsgCStage;
\r
857 cimAcDcMsg = (UINT8) pConfig->AcDcMsg;
\r
858 cimTimerTickTrack = (UINT8) pConfig->TimerTickTrack;
\r
859 cimClockInterruptTag = (UINT8) pConfig->ClockInterruptTag;
\r
860 cimOhciTrafficHanding = (UINT8) pConfig->OhciTrafficHanding;
\r
861 cimEhciTrafficHanding = (UINT8) pConfig->EhciTrafficHanding;
\r
862 cimFusionMsgCMultiCore = (UINT8) pConfig->FusionMsgCMultiCore;
\r
863 cimFusionMsgCStage = (UINT8) pConfig->FusionMsgCStage;
\r
864 #if SB_CIMx_PARAMETER == 0
\r
865 cimAcDcMsg = cimAcDcMsgDefault;
\r
866 cimTimerTickTrack = cimTimerTickTrackDefault;
\r
867 cimClockInterruptTag = cimClockInterruptTagDefault;
\r
868 cimOhciTrafficHanding = cimOhciTrafficHandingDefault;
\r
869 cimEhciTrafficHanding = cimEhciTrafficHandingDefault;
\r
870 cimFusionMsgCMultiCore = cimFusionMsgCMultiCoreDefault;
\r
871 cimFusionMsgCStage = cimFusionMsgCStageDefault;
\r
873 ReadMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGA0, AccWidthUint32 | S3_SAVE, &ddValue);
\r
874 ddValue = ddValue & 0xC07F00A0;
\r
875 if ( cimAcDcMsg ) {
\r
876 ddValue = ddValue | BIT0;
\r
878 if ( cimTimerTickTrack ) {
\r
879 ddValue = ddValue | BIT1;
\r
881 if ( cimClockInterruptTag ) {
\r
882 ddValue = ddValue | BIT10;
\r
884 if ( cimOhciTrafficHanding ) {
\r
885 ddValue = ddValue | BIT13;
\r
887 if ( cimEhciTrafficHanding ) {
\r
888 ddValue = ddValue | BIT15;
\r
890 if ( cimFusionMsgCMultiCore ) {
\r
891 ddValue = ddValue | BIT23;
\r
893 if ( cimFusionMsgCStage ) {
\r
894 ddValue = (ddValue | (BIT6 + BIT4 + BIT3 + BIT2));
\r
896 WriteMEM (ACPI_MMIO_BASE + PMIO_BASE + SB_PMIOA_REGA0, AccWidthUint32 | S3_SAVE, &ddValue);
\r
898 #ifndef NO_EC_SUPPORT
\r
900 * validateImcFirmware - Validate IMC Firmware.
\r
903 * @param[in] pConfig Southbridge configuration structure pointer.
\r
905 * @retval TRUE Pass
\r
906 * @retval FALSE Failed
\r
909 validateImcFirmware (
\r
910 IN AMDSBCFG* pConfig
\r
920 UINT8 dbIMCChecksume;
\r
924 // Software IMC enable
\r
925 ImcSigAddr = 0x80000; // start from 512k to 64M
\r
927 while ( ( ImcSig != 0x55aa55aa ) && ( ImcSigAddr <= 0x4000000 ) ) {
\r
928 CurAddr = 0xffffffff - ImcSigAddr + 0x20001;
\r
929 ReadMEM (CurAddr, AccWidthUint32, &ImcSig);
\r
930 ReadMEM ((CurAddr + 4), AccWidthUint32, &ImcAddr);
\r
934 dbIMCChecksume = 0xff;
\r
935 if ( ImcSig == 0x55aa55aa ) {
\r
936 // "_AMD_IMC_C" at offset 0x2000 of the binary
\r
937 ReadMEM ((ImcAddr + 0x2000), AccWidthUint32, &ImcBinSig0);
\r
938 ReadMEM ((ImcAddr + 0x2004), AccWidthUint32, &ImcBinSig1);
\r
939 ReadMEM ((ImcAddr + 0x2008), AccWidthUint16, &ImcBinSig2);
\r
940 if ((ImcBinSig0 == 0x444D415F) && (ImcBinSig1 == 0x434D495F) && (ImcBinSig2 == 0x435F) ) {
\r
941 dbIMCChecksume = 0;
\r
942 for ( CurAddr = ImcAddr; CurAddr < ImcAddr + 0x10000; CurAddr++ ) {
\r
943 ReadMEM (CurAddr, AccWidthUint8, &dbIMC);
\r
944 dbIMCChecksume = dbIMCChecksume + dbIMC;
\r
948 if ( dbIMCChecksume ) {
\r
956 * softwareToggleImcStrapping - Software Toggle IMC Firmware Strapping.
\r
959 * @param[in] pConfig Southbridge configuration structure pointer.
\r
963 softwareToggleImcStrapping (
\r
964 IN AMDSBCFG* pConfig
\r
968 UINT8 dbPortStatus;
\r
972 getChipSysMode (&dbPortStatus);
\r
974 ReadPMIO (SB_PMIOA_REGBF, AccWidthUint8, &dbValue);
\r
975 //if ( (dbValue & (BIT6 + BIT7)) != 0xC0 ) { // PwrGoodOut =1, PwrGoodEnB=1
\r
976 //The strapStatus register is not mapped into StrapOveride not in the same bit position. The following is difference.
\r
978 //StrapStatus StrapOverride
\r
984 ReadMEM ((ACPI_MMIO_BASE + MISC_BASE + SB_MISC_REG80), AccWidthUint32, &abValue);
\r
985 abValue1 = abValue;
\r
986 if (abValue & BIT4) {
\r
987 abValue1 = (abValue1 & ~BIT4) | BIT17;
\r
989 if (abValue & BIT6) {
\r
990 abValue1 = (abValue1 & ~BIT6) | BIT12;
\r
992 if (abValue & BIT12) {
\r
993 abValue1 = (abValue1 & ~BIT12) | BIT15;
\r
995 if (abValue & BIT15) {
\r
996 abValue1 = (abValue1 & ~BIT15) | BIT16;
\r
998 if (abValue & BIT16) {
\r
999 abValue1 = (abValue1 & ~BIT16) | BIT18;
\r
1001 abValue1 |= BIT31; // Overwrite enable
\r
1002 if ((dbPortStatus & ChipSysEcEnable) == 0) {
\r
1003 abValue1 |= BIT2; // bit2- EcEnableStrap
\r
1005 abValue1 &= ~BIT2; // bit2=0 EcEnableStrap
\r
1007 WriteMEM ((ACPI_MMIO_BASE + MISC_BASE + SB_MISC_REG84), AccWidthUint32, &abValue1);
\r
1008 dbValue |= BIT6; // PwrGoodOut =1
\r
1009 dbValue &= ~BIT7; // PwrGoodEnB =0
\r
1010 WritePMIO (SB_PMIOA_REGBF, AccWidthUint8, &dbValue);
\r
1013 WriteIO (0xcf9, AccWidthUint8, &dbValue);
\r
1014 SbStall (0xffffffff);
\r
1018 #ifndef NO_HWM_SUPPORT
\r
1020 * validateImcFirmware - Validate IMC Firmware.
\r
1023 * @param[in] pConfig Southbridge configuration structure pointer.
\r
1028 IN AMDSBCFG* pConfig
\r
1031 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xB2, AccWidthUint8 | S3_SAVE, 0, 0x55);
\r
1032 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xB3, AccWidthUint8 | S3_SAVE, 0, 0x55);
\r
1033 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x91, AccWidthUint8 | S3_SAVE, 0, 0x55);
\r
1034 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x92, AccWidthUint8 | S3_SAVE, 0, 0x55);
\r
1036 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x00, AccWidthUint8 | S3_SAVE, 0, 0x06);
\r
1037 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x10, AccWidthUint8 | S3_SAVE, 0, 0x06);
\r
1038 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x20, AccWidthUint8 | S3_SAVE, 0, 0x06);
\r
1039 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x30, AccWidthUint8 | S3_SAVE, 0, 0x06);
\r
1040 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x40, AccWidthUint8 | S3_SAVE, 0, 0x06);
\r
1042 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x66, AccWidthUint8 | S3_SAVE, 0, 0x01);
\r
1043 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x6B, AccWidthUint8 | S3_SAVE, 0, 0x01);
\r
1044 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x70, AccWidthUint8 | S3_SAVE, 0, 0x01);
\r
1045 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x75, AccWidthUint8 | S3_SAVE, 0, 0x01);
\r
1046 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0x7A, AccWidthUint8 | S3_SAVE, 0, 0x01);
\r
1048 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xF8, AccWidthUint8 | S3_SAVE, 0, 0x05);
\r
1049 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xF9, AccWidthUint8 | S3_SAVE, 0, 0x06);
\r
1050 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xFF, AccWidthUint8 | S3_SAVE, 0, 0x42);
\r
1051 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xE9, AccWidthUint8 | S3_SAVE, 0, 0xFF);
\r
1052 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xEB, AccWidthUint8 | S3_SAVE, 0, 0x1F);
\r
1053 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xEF, AccWidthUint8 | S3_SAVE, 0, 0x04);
\r
1054 RWMEM (ACPI_MMIO_BASE + PMIO2_BASE + 0xFB, AccWidthUint8 | S3_SAVE, 0, 0x00);
\r