Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 1 | /** |
| 2 | * @file |
| 3 | * |
| 4 | * SB Initialization. |
| 5 | * |
| 6 | * Init IOAPIC/IOMMU/Misc NB features. |
| 7 | * |
| 8 | * @xrefitem bom "File Content Label" "Release Content" |
| 9 | * @e project: CIMx-SB |
| 10 | * @e sub-project: |
| 11 | * @e \$Revision:$ @e \$Date:$ |
| 12 | * |
| 13 | */ |
| 14 | /* |
| 15 | ***************************************************************************** |
| 16 | * |
| 17 | * Copyright (c) 2011, Advanced Micro Devices, Inc. |
| 18 | * All rights reserved. |
Edward O'Callaghan | ef5981b | 2014-07-06 19:20:52 +1000 | [diff] [blame] | 19 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 20 | * Redistribution and use in source and binary forms, with or without |
| 21 | * modification, are permitted provided that the following conditions are met: |
| 22 | * * Redistributions of source code must retain the above copyright |
| 23 | * notice, this list of conditions and the following disclaimer. |
| 24 | * * Redistributions in binary form must reproduce the above copyright |
| 25 | * notice, this list of conditions and the following disclaimer in the |
| 26 | * documentation and/or other materials provided with the distribution. |
Edward O'Callaghan | ef5981b | 2014-07-06 19:20:52 +1000 | [diff] [blame] | 27 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 28 | * its contributors may be used to endorse or promote products derived |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 29 | * from this software without specific prior written permission. |
Edward O'Callaghan | ef5981b | 2014-07-06 19:20:52 +1000 | [diff] [blame] | 30 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 31 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 32 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 33 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 34 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 35 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 36 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 37 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 38 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 39 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 40 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Edward O'Callaghan | ef5981b | 2014-07-06 19:20:52 +1000 | [diff] [blame] | 41 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 42 | * *************************************************************************** |
| 43 | * |
| 44 | */ |
| 45 | |
| 46 | #include "SBPLATFORM.h" |
| 47 | #include "cbtypes.h" |
| 48 | |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 49 | /*----------------------------------------------------------------------------------------*/ |
| 50 | /** |
| 51 | * sbBeforePciInit - Config Southbridge before PCI emulation |
| 52 | * |
| 53 | * |
| 54 | * |
| 55 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 56 | * |
| 57 | */ |
| 58 | |
| 59 | VOID |
| 60 | sbBeforePciInit ( |
| 61 | IN AMDSBCFG* pConfig |
| 62 | ) |
| 63 | { |
| 64 | commonInitEarlyBoot (pConfig); |
| 65 | commonInitEarlyPost (pConfig); |
| 66 | #ifndef NO_EC_SUPPORT |
| 67 | ecInitBeforePciEnum (pConfig); |
| 68 | #endif |
| 69 | usbInitBeforePciEnum (pConfig); // USB POST TIME Only |
| 70 | sataInitBeforePciEnum (pConfig); // Init SATA class code and PHY |
| 71 | gecInitBeforePciEnum (pConfig); // Init GEC |
| 72 | azaliaInitBeforePciEnum (pConfig); // Detect and configure High Definition Audio |
| 73 | sbPcieGppEarlyInit (pConfig); // Gpp port init |
| 74 | abSpecialSetBeforePciEnum (pConfig); |
| 75 | usbDesertPll (pConfig); |
| 76 | } |
| 77 | |
| 78 | /** |
| 79 | * sbAfterPciInit - Config Southbridge after PCI emulation |
| 80 | * |
| 81 | * |
| 82 | * |
| 83 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 84 | * |
| 85 | */ |
| 86 | VOID |
| 87 | sbAfterPciInit ( |
| 88 | IN AMDSBCFG* pConfig |
| 89 | ) |
| 90 | { |
| 91 | usbInitAfterPciInit (pConfig); // Init USB MMIO |
| 92 | sataInitAfterPciEnum (pConfig); // SATA port enumeration |
| 93 | gecInitAfterPciEnum (pConfig); |
| 94 | azaliaInitAfterPciEnum (pConfig); // Detect and configure High Definition Audio |
| 95 | |
| 96 | #ifndef NO_HWM_SUPPORT |
| 97 | hwmInit (pConfig); |
| 98 | #endif |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * sbMidPostInit - Config Southbridge during middle of POST |
| 103 | * |
| 104 | * |
| 105 | * |
| 106 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 107 | * |
| 108 | */ |
| 109 | VOID |
| 110 | sbMidPostInit ( |
| 111 | IN AMDSBCFG* pConfig |
| 112 | ) |
| 113 | { |
| 114 | sataInitMidPost (pConfig); |
| 115 | } |
| 116 | |
| 117 | /*----------------------------------------------------------------------------------------*/ |
| 118 | /** |
| 119 | * sbLatePost - Prepare Southbridge to boot to OS. |
| 120 | * |
| 121 | * |
| 122 | * |
| 123 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 124 | * |
| 125 | */ |
| 126 | VOID |
| 127 | sbLatePost ( |
| 128 | IN AMDSBCFG* pConfig |
| 129 | ) |
| 130 | { |
| 131 | // UINT16 dwVar; |
| 132 | BUILDPARAM *pStaticOptions; |
| 133 | pStaticOptions = &(pConfig->BuildParameters); |
| 134 | commonInitLateBoot (pConfig); |
| 135 | sataInitLatePost (pConfig); |
| 136 | gecInitLatePost (pConfig); |
| 137 | hpetInit (pConfig, pStaticOptions); // SB Configure HPET base and enable bit |
| 138 | #ifndef NO_EC_SUPPORT |
| 139 | ecInitLatePost (pConfig); |
| 140 | #endif |
| 141 | sbPcieGppLateInit (pConfig); |
| 142 | |
| 143 | } |
| 144 | |
| 145 | /*----------------------------------------------------------------------------------------*/ |
| 146 | /** |
| 147 | * sbBeforePciRestoreInit - Config Southbridge before ACPI S3 resume PCI config device restore |
| 148 | * |
| 149 | * |
| 150 | * |
| 151 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 152 | * |
| 153 | */ |
| 154 | |
| 155 | VOID |
| 156 | sbBeforePciRestoreInit ( |
| 157 | IN AMDSBCFG* pConfig |
| 158 | ) |
| 159 | { |
| 160 | pConfig->S3Resume = 1; |
| 161 | commonInitEarlyBoot (pConfig); // set /SMBUS/ACPI/IDE/LPC/PCIB |
| 162 | abLinkInitBeforePciEnum (pConfig); // Set ABCFG registers |
| 163 | usbInitBeforePciEnum (pConfig); // USB POST TIME Only |
| 164 | sataInitBeforePciEnum (pConfig); |
| 165 | gecInitBeforePciEnum (pConfig); // Init GEC |
| 166 | azaliaInitBeforePciEnum (pConfig); // Detect and configure High Definition Audio |
| 167 | sbPcieGppEarlyInit (pConfig); // Gpp port init |
| 168 | abSpecialSetBeforePciEnum (pConfig); |
| 169 | } |
| 170 | |
| 171 | /*----------------------------------------------------------------------------------------*/ |
| 172 | /** |
| 173 | * sbAfterPciRestoreInit - Config Southbridge after ACPI S3 resume PCI config device restore |
| 174 | * |
| 175 | * |
| 176 | * |
| 177 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 178 | * |
| 179 | */ |
| 180 | |
| 181 | VOID |
| 182 | sbAfterPciRestoreInit ( |
| 183 | IN AMDSBCFG* pConfig |
| 184 | ) |
| 185 | { |
| 186 | BUILDPARAM *pStaticOptions; |
| 187 | |
| 188 | pConfig->S3Resume = 1; |
| 189 | |
| 190 | usbSetPllDuringS3 (pConfig); |
| 191 | pStaticOptions = &(pConfig->BuildParameters); |
| 192 | commonInitLateBoot (pConfig); |
| 193 | sataInitAfterPciEnum (pConfig); |
| 194 | gecInitAfterPciEnum (pConfig); |
| 195 | azaliaInitAfterPciEnum (pConfig); // Detect and configure High Definition Audio |
| 196 | hpetInit (pConfig, pStaticOptions); // SB Configure HPET base and enable bit |
| 197 | sataInitLatePost (pConfig); |
| 198 | c3PopupSetting (pConfig); |
| 199 | |
| 200 | #ifndef NO_HWM_SUPPORT |
| 201 | SBIMCFanInitializeS3 (); |
| 202 | #endif |
| 203 | } |
| 204 | |
| 205 | /*----------------------------------------------------------------------------------------*/ |
| 206 | /** |
| 207 | * sbSmmAcpiOn - Config Southbridge during ACPI_ON |
| 208 | * |
| 209 | * |
| 210 | * |
| 211 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 212 | * |
| 213 | */ |
| 214 | VOID |
| 215 | sbSmmAcpiOn ( |
| 216 | IN AMDSBCFG* pConfig |
| 217 | ) |
| 218 | { |
| 219 | // Commented the following code since we need to leave the IRQ1/12 filtering enabled always as per latest |
| 220 | // recommendation in RPR. This is required to fix the keyboard stuck issue when playing games under Windows |
| 221 | AMDSBCFG* pTmp; //lx-dummy for /W4 build |
| 222 | pTmp = pConfig; |
| 223 | |
| 224 | // Disable Power Button SMI |
| 225 | RWMEM (ACPI_MMIO_BASE + SMI_BASE + SB_SMI_REGB2, AccWidthUint8, ~(BIT4 + BIT5), 0); |
| 226 | RWMEM (ACPI_MMIO_BASE + SMI_BASE + SB_SMI_REGAC, AccWidthUint8, ~(BIT6 + BIT7), 0); |
| 227 | } |
| 228 | |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 229 | /*----------------------------------------------------------------------------------------*/ |
| 230 | /** |
| 231 | * Call Back routine. |
| 232 | * |
| 233 | * |
| 234 | * |
| 235 | * @param[in] Func Callback ID. |
| 236 | * @param[in] Data Callback specific data. |
| 237 | * @param[in] pConfig Southbridge configuration structure pointer. |
| 238 | */ |
Stefan Reinauer | df3b8e6 | 2015-06-17 16:05:05 -0700 | [diff] [blame] | 239 | UINT32 |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 240 | CallBackToOEM ( |
| 241 | IN UINT32 Func, |
| 242 | IN UINT32 Data, |
| 243 | IN AMDSBCFG* pConfig |
| 244 | ) |
| 245 | { |
| 246 | UINT32 Result; |
| 247 | Result = 0; |
| 248 | if ( pConfig->StdHeader.CALLBACK.CalloutPtr == NULL ) return Result; |
| 249 | Result = (pConfig->StdHeader.CALLBACK.CalloutPtr) ( Func, Data, pConfig); |
| 250 | |
| 251 | return Result; |
| 252 | } |
| 253 | |
| 254 | |