Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * Various NB initialization services |
| 6 | * |
| 7 | * |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: GNB |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 12 | * @e \$Revision: 48955 $ @e \$Date: 2011-03-14 18:31:17 -0600 (Mon, 14 Mar 2011) $ |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 13 | * |
| 14 | */ |
| 15 | /* |
| 16 | ***************************************************************************** |
| 17 | * |
| 18 | * Copyright (c) 2011, Advanced Micro Devices, Inc. |
| 19 | * All rights reserved. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 20 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 21 | * Redistribution and use in source and binary forms, with or without |
| 22 | * modification, are permitted provided that the following conditions are met: |
| 23 | * * Redistributions of source code must retain the above copyright |
| 24 | * notice, this list of conditions and the following disclaimer. |
| 25 | * * Redistributions in binary form must reproduce the above copyright |
| 26 | * notice, this list of conditions and the following disclaimer in the |
| 27 | * documentation and/or other materials provided with the distribution. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 28 | * * Neither the name of Advanced Micro Devices, Inc. nor the names of |
| 29 | * its contributors may be used to endorse or promote products derived |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 30 | * from this software without specific prior written permission. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 31 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 32 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
| 33 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
| 34 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
| 35 | * DISCLAIMED. IN NO EVENT SHALL ADVANCED MICRO DEVICES, INC. BE LIABLE FOR ANY |
| 36 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
| 37 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
| 38 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
| 39 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 40 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
| 41 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Edward O'Callaghan | 1542a6f | 2014-07-06 19:24:06 +1000 | [diff] [blame] | 42 | * |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 43 | * *************************************************************************** |
| 44 | * |
| 45 | */ |
| 46 | |
| 47 | /*---------------------------------------------------------------------------------------- |
| 48 | * M O D U L E S U S E D |
| 49 | *---------------------------------------------------------------------------------------- |
| 50 | */ |
| 51 | #include "AGESA.h" |
| 52 | #include "amdlib.h" |
| 53 | #include "Ids.h" |
| 54 | #include "Gnb.h" |
| 55 | #include GNB_MODULE_DEFINITIONS (GnbCommonLib) |
| 56 | #include "GfxLib.h" |
| 57 | #include "NbSmuLib.h" |
| 58 | #include "NbConfigData.h" |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 59 | #include "NbInit.h" |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 60 | #include "GnbRegistersON.h" |
| 61 | #include "Filecode.h" |
| 62 | #define FILECODE PROC_GNB_NB_NBINIT_FILECODE |
| 63 | /*---------------------------------------------------------------------------------------- |
| 64 | * D E F I N I T I O N S A N D M A C R O S |
| 65 | *---------------------------------------------------------------------------------------- |
| 66 | */ |
| 67 | |
| 68 | |
| 69 | /*---------------------------------------------------------------------------------------- |
| 70 | * T Y P E D E F S A N D S T R U C T U R E S |
| 71 | *---------------------------------------------------------------------------------------- |
| 72 | */ |
| 73 | |
| 74 | |
| 75 | /*---------------------------------------------------------------------------------------- |
| 76 | * 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 |
| 77 | *---------------------------------------------------------------------------------------- |
| 78 | */ |
| 79 | |
| 80 | CONST NB_REGISTER_ENTRY NbPciInitTable [] = { |
| 81 | { |
| 82 | D0F0x04_ADDRESS, |
| 83 | 0xffffffff, |
| 84 | (0x1 << D0F0x04_MemAccessEn_WIDTH) | (0x1 << D0F0x04_BusMasterEn_OFFSET) |
| 85 | }, |
| 86 | { |
| 87 | D0F0x4C_ADDRESS, |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 88 | ~(UINT32)(0x3 << D0F0x4C_CfgRdTime_OFFSET), |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 89 | 0x2 << D0F0x4C_CfgRdTime_OFFSET |
| 90 | }, |
| 91 | { |
| 92 | D0F0x84_ADDRESS, |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 93 | ~(UINT32)(0x1 << D0F0x84_Ev6Mode_OFFSET), |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 94 | 0x1 << D0F0x84_Ev6Mode_OFFSET |
| 95 | } |
| 96 | }; |
| 97 | |
| 98 | CONST NB_REGISTER_ENTRY NbMiscInitTable [] = { |
| 99 | { |
| 100 | D0F0x64_x46_ADDRESS, |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 101 | ~(UINT32)(0x3 << D0F0x64_x46_P2PMode_OFFSET), |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 102 | 1 << D0F0x64_x46_Msi64bitEn_OFFSET |
| 103 | } |
| 104 | }; |
| 105 | |
| 106 | |
| 107 | CONST NB_REGISTER_ENTRY NbOrbInitTable [] = { |
| 108 | { |
| 109 | D0F0x98_x07_ADDRESS, |
| 110 | 0xffffffff, |
| 111 | (1 << D0F0x98_x07_IocBwOptEn_OFFSET) | |
| 112 | (1 << D0F0x98_x07_MSIHTIntConversionEn_OFFSET) | |
| 113 | (1 << D0F0x98_x07_DropZeroMaskWrEn_OFFSET) |
| 114 | }, |
| 115 | { |
| 116 | D0F0x98_x08_ADDRESS, |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 117 | ~(UINT32)(0xff << D0F0x98_x08_NpWrrLenC_OFFSET), |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 118 | 1 << D0F0x98_x08_NpWrrLenC_OFFSET |
| 119 | }, |
| 120 | { |
| 121 | D0F0x98_x09_ADDRESS, |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 122 | ~(UINT32)(0xff << D0F0x98_x09_PWrrLenD_OFFSET), |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 123 | 1 << D0F0x98_x09_PWrrLenD_OFFSET |
| 124 | }, |
| 125 | { |
| 126 | D0F0x98_x0C_ADDRESS, |
| 127 | 0xffffffff, |
| 128 | 1 << D0F0x98_x0C_StrictSelWinnerEn_OFFSET |
| 129 | }, |
| 130 | { |
| 131 | D0F0x98_x0E_ADDRESS, |
| 132 | 0xffffffff, |
| 133 | 1 << D0F0x98_x0E_MsiHtRsvIntRemapEn_OFFSET |
| 134 | }, |
| 135 | { |
| 136 | D0F0x98_x28_ADDRESS, |
| 137 | 0xffffffff, |
| 138 | (1 << D0F0x98_x28_SmuPmInterfaceEn_OFFSET) | |
| 139 | (1 << D0F0x98_x28_ForceCoherentIntr_OFFSET) |
| 140 | } |
| 141 | }; |
| 142 | |
| 143 | |
| 144 | /*----------------------------------------------------------------------------------------*/ |
| 145 | /** |
| 146 | * Init NB at Power On |
| 147 | * |
| 148 | * |
| 149 | * |
| 150 | * @param[in] Gnb Pointer to global Gnb configuration |
| 151 | * @retval AGESA_STATUS |
| 152 | */ |
| 153 | |
| 154 | |
| 155 | AGESA_STATUS |
| 156 | NbInitOnPowerOn ( |
| 157 | IN GNB_PLATFORM_CONFIG *Gnb |
| 158 | ) |
| 159 | { |
| 160 | UINTN Index; |
| 161 | FCRxFF30_0398_STRUCT FCRxFF30_0398; |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 162 | UINT32 Value; |
| 163 | |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 164 | // Init NBCONFIG |
| 165 | for (Index = 0; Index < (sizeof (NbPciInitTable) / sizeof (NB_REGISTER_ENTRY)); Index++) { |
| 166 | GnbLibPciRMW ( |
| 167 | Gnb->GnbPciAddress.AddressValue | NbPciInitTable[Index].Reg, |
| 168 | AccessWidth32, |
| 169 | NbPciInitTable[Index].Mask, |
| 170 | NbPciInitTable[Index].Data, |
| 171 | Gnb->StdHeader |
| 172 | ); |
| 173 | } |
| 174 | |
| 175 | // Init MISCIND |
| 176 | for (Index = 0; Index < (sizeof (NbMiscInitTable) / sizeof (NB_REGISTER_ENTRY)); Index++) { |
| 177 | GnbLibPciIndirectRMW ( |
| 178 | Gnb->GnbPciAddress.AddressValue | D0F0x60_ADDRESS, |
| 179 | NbMiscInitTable[Index].Reg | IOC_WRITE_ENABLE, |
| 180 | AccessWidth32, |
| 181 | NbMiscInitTable[Index].Mask, |
| 182 | NbMiscInitTable[Index].Data, |
| 183 | Gnb->StdHeader |
| 184 | ); |
| 185 | } |
| 186 | |
| 187 | // Init ORB |
| 188 | for (Index = 0; Index < (sizeof (NbOrbInitTable) / sizeof (NB_REGISTER_ENTRY)); Index++) { |
| 189 | GnbLibPciIndirectRMW ( |
| 190 | Gnb->GnbPciAddress.AddressValue | D0F0x94_ADDRESS, |
| 191 | NbOrbInitTable[Index].Reg | (1 << D0F0x94_OrbIndWrEn_OFFSET), |
| 192 | AccessWidth32, |
| 193 | NbOrbInitTable[Index].Mask, |
| 194 | NbOrbInitTable[Index].Data, |
| 195 | Gnb->StdHeader |
| 196 | ); |
| 197 | } |
| 198 | if (!GfxLibIsControllerPresent (Gnb->StdHeader)) { |
| 199 | FCRxFF30_0398.Value = (1 << FCRxFF30_0398_SoftResetGrbm_OFFSET) | (1 << FCRxFF30_0398_SoftResetMc_OFFSET) | |
| 200 | (1 << FCRxFF30_0398_SoftResetDc_OFFSET) | (1 << FCRxFF30_0398_SoftResetRlc_OFFSET) | |
| 201 | (1 << FCRxFF30_0398_SoftResetUvd_OFFSET); |
| 202 | NbSmuSrbmRegisterWrite (FCRxFF30_0398_ADDRESS, &FCRxFF30_0398.Value, FALSE, Gnb->StdHeader); |
| 203 | } |
| 204 | |
efdesign98 | 84cbce2 | 2011-08-04 12:09:17 -0600 | [diff] [blame] | 205 | Value = 0; |
| 206 | for (Index = 0x8400; Index <= 0x85AC; Index = Index + 4) { |
| 207 | NbSmuRcuRegisterWrite ( |
| 208 | (UINT16) Index, |
| 209 | &Value, |
| 210 | 1, |
| 211 | FALSE, |
| 212 | Gnb->StdHeader |
| 213 | ); |
| 214 | } |
| 215 | |
| 216 | NbSmuRcuRegisterWrite ( |
| 217 | 0x9000, |
| 218 | &Value, |
| 219 | 1, |
| 220 | FALSE, |
| 221 | Gnb->StdHeader |
| 222 | ); |
| 223 | |
| 224 | NbSmuRcuRegisterWrite ( |
| 225 | 0x9004, |
| 226 | &Value, |
| 227 | 1, |
| 228 | FALSE, |
| 229 | Gnb->StdHeader |
| 230 | ); |
| 231 | |
Frank Vibrans | 2b4c831 | 2011-02-14 18:30:54 +0000 | [diff] [blame] | 232 | return AGESA_SUCCESS; |
| 233 | } |
| 234 | |