Siyuan Wang | affe85f | 2013-07-25 15:14:15 +0800 | [diff] [blame] | 1 | /* $NoKeywords:$ */ |
| 2 | /** |
| 3 | * @file |
| 4 | * |
| 5 | * Family specific function translation |
| 6 | * |
| 7 | * |
| 8 | * |
| 9 | * @xrefitem bom "File Content Label" "Release Content" |
| 10 | * @e project: AGESA |
| 11 | * @e sub-project: GNB |
| 12 | * @e \$Revision: 84150 $ @e \$Date: 2012-12-12 15:46:25 -0600 (Wed, 12 Dec 2012) $ |
| 13 | * |
| 14 | */ |
| 15 | /* |
| 16 | ***************************************************************************** |
| 17 | * |
| 18 | * Copyright (c) 2008 - 2013, Advanced Micro Devices, Inc. |
| 19 | * All rights reserved. |
| 20 | * |
| 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. |
| 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 |
| 30 | * from this software without specific prior written permission. |
| 31 | * |
| 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. |
| 42 | * *************************************************************************** |
| 43 | * |
| 44 | */ |
| 45 | |
| 46 | /*---------------------------------------------------------------------------------------- |
| 47 | * M O D U L E S U S E D |
| 48 | *---------------------------------------------------------------------------------------- |
| 49 | */ |
| 50 | #include "AGESA.h" |
| 51 | #include "Ids.h" |
| 52 | #include "amdlib.h" |
| 53 | #include "Gnb.h" |
| 54 | #include "GnbPcie.h" |
| 55 | #include "GnbPcieConfig.h" |
| 56 | #include "GnbFamServices.h" |
| 57 | #include "GnbGfxFamServices.h" |
| 58 | #include "GnbCommonLib.h" |
| 59 | #include "GnbGfx.h" |
| 60 | #include "Filecode.h" |
| 61 | #define FILECODE PROC_GNB_MODULES_GNBFAMTRANSLATION_GNBTRANSLATION_FILECODE |
| 62 | /*---------------------------------------------------------------------------------------- |
| 63 | * D E F I N I T I O N S A N D M A C R O S |
| 64 | *---------------------------------------------------------------------------------------- |
| 65 | */ |
| 66 | |
| 67 | /*---------------------------------------------------------------------------------------- |
| 68 | * T Y P E D E F S A N D S T R U C T U R E S |
| 69 | *---------------------------------------------------------------------------------------- |
| 70 | */ |
| 71 | |
| 72 | |
| 73 | /*---------------------------------------------------------------------------------------- |
| 74 | * 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 |
| 75 | *---------------------------------------------------------------------------------------- |
| 76 | */ |
| 77 | |
| 78 | /*----------------------------------------------------------------------------------------*/ |
| 79 | /** |
| 80 | * Check if IOMMU unit present and enabled |
| 81 | * |
| 82 | * |
| 83 | * |
| 84 | * |
| 85 | * @param[in] GnbHandle Gnb handle |
| 86 | * @param[in] StdHeader Standard configuration header |
| 87 | * |
| 88 | */ |
| 89 | BOOLEAN |
| 90 | GnbFmCheckIommuPresent ( |
| 91 | IN GNB_HANDLE *GnbHandle, |
| 92 | IN AMD_CONFIG_PARAMS *StdHeader |
| 93 | ) |
| 94 | { |
| 95 | AGESA_STATUS Status; |
| 96 | GNB_FAM_IOMMU_SERVICES *GnbIommuConfigService; |
Arthur Heymans | b80de18 | 2022-05-16 15:29:53 +0200 | [diff] [blame^] | 97 | Status = GnbLibLocateService (GnbIommuService, GnbGetSocketId (GnbHandle), (CONST VOID **)&GnbIommuConfigService, StdHeader); |
Siyuan Wang | affe85f | 2013-07-25 15:14:15 +0800 | [diff] [blame] | 98 | ASSERT (Status == AGESA_SUCCESS); |
| 99 | if (Status == AGESA_SUCCESS) { |
| 100 | return GnbIommuConfigService->GnbFmCheckIommuPresent (GnbHandle, StdHeader); |
| 101 | } |
| 102 | return FALSE; |
| 103 | } |
| 104 | |
| 105 | /*----------------------------------------------------------------------------------------*/ |
| 106 | /** |
| 107 | * Create IVRS entry |
| 108 | * |
| 109 | * |
| 110 | * @param[in] GnbHandle Gnb handle |
| 111 | * @param[in] Type Entry type |
| 112 | * @param[in] Ivrs IVRS table pointer |
| 113 | * @param[in] StdHeader Standard configuration header |
| 114 | * |
| 115 | */ |
| 116 | |
| 117 | AGESA_STATUS |
| 118 | GnbFmCreateIvrsEntry ( |
| 119 | IN GNB_HANDLE *GnbHandle, |
| 120 | IN IVRS_BLOCK_TYPE Type, |
| 121 | IN VOID *Ivrs, |
| 122 | IN AMD_CONFIG_PARAMS *StdHeader |
| 123 | ) |
| 124 | { |
| 125 | AGESA_STATUS Status; |
| 126 | GNB_FAM_IOMMU_SERVICES *GnbIommuConfigService; |
Arthur Heymans | b80de18 | 2022-05-16 15:29:53 +0200 | [diff] [blame^] | 127 | Status = GnbLibLocateService (GnbIommuService, GnbGetSocketId (GnbHandle), (CONST VOID **)&GnbIommuConfigService, StdHeader); |
Siyuan Wang | affe85f | 2013-07-25 15:14:15 +0800 | [diff] [blame] | 128 | ASSERT (Status == AGESA_SUCCESS); |
| 129 | if (Status == AGESA_SUCCESS) { |
| 130 | return GnbIommuConfigService->GnbFmCreateIvrsEntry (GnbHandle, Type, Ivrs, StdHeader); |
| 131 | } |
| 132 | return Status; |
| 133 | } |
| 134 | |
| 135 | /*----------------------------------------------------------------------------------------*/ |
| 136 | /** |
| 137 | * Map graphics engine to display path |
| 138 | * |
| 139 | * |
| 140 | * |
| 141 | * |
| 142 | * @param[in] Engine Engine configuration info |
| 143 | * @param[out] DisplayPathList Display path list |
| 144 | * @param[in] Gfx Pointer to global GFX configuration |
| 145 | * |
| 146 | */ |
| 147 | AGESA_STATUS |
| 148 | GfxFmMapEngineToDisplayPath ( |
| 149 | IN PCIe_ENGINE_CONFIG *Engine, |
| 150 | OUT EXT_DISPLAY_PATH *DisplayPathList, |
| 151 | IN GFX_PLATFORM_CONFIG *Gfx |
| 152 | ) |
| 153 | { |
| 154 | AGESA_STATUS Status; |
| 155 | GFX_FAM_SERVICES *GfxFamilyService; |
| 156 | GNB_HANDLE *GnbHandle; |
| 157 | GnbHandle = GnbGetHandle (GnbLibGetHeader (Gfx)); |
Arthur Heymans | b80de18 | 2022-05-16 15:29:53 +0200 | [diff] [blame^] | 158 | Status = GnbLibLocateService (GfxFamService, GnbGetSocketId (GnbHandle), (CONST VOID **)&GfxFamilyService, GnbLibGetHeader (Gfx)); |
Siyuan Wang | affe85f | 2013-07-25 15:14:15 +0800 | [diff] [blame] | 159 | ASSERT (Status == AGESA_SUCCESS); |
| 160 | if (Status == AGESA_SUCCESS) { |
| 161 | return GfxFamilyService->GfxMapEngineToDisplayPath (Engine, DisplayPathList, Gfx); |
| 162 | } |
| 163 | return Status; |
| 164 | } |
| 165 | |
| 166 | /*----------------------------------------------------------------------------------------*/ |
| 167 | /** |
| 168 | * Calculate COF for DFS out of Main PLL |
| 169 | * |
| 170 | * |
| 171 | * |
| 172 | * @param[in] Did Did |
| 173 | * @param[in] StdHeader Standard Configuration Header |
| 174 | * @retval COF in 10khz |
| 175 | */ |
| 176 | |
| 177 | UINT32 |
| 178 | GfxFmCalculateClock ( |
| 179 | IN UINT8 Did, |
| 180 | IN AMD_CONFIG_PARAMS *StdHeader |
| 181 | ) |
| 182 | { |
| 183 | AGESA_STATUS Status; |
| 184 | GFX_FAM_SERVICES *GfxFamilyService; |
| 185 | GNB_HANDLE *GnbHandle; |
| 186 | GnbHandle = GnbGetHandle (StdHeader); |
Arthur Heymans | b80de18 | 2022-05-16 15:29:53 +0200 | [diff] [blame^] | 187 | Status = GnbLibLocateService (GfxFamService, GnbGetSocketId (GnbHandle), (CONST VOID **)&GfxFamilyService, StdHeader); |
Siyuan Wang | affe85f | 2013-07-25 15:14:15 +0800 | [diff] [blame] | 188 | ASSERT (Status == AGESA_SUCCESS); |
| 189 | if (Status == AGESA_SUCCESS) { |
| 190 | return GfxFamilyService->GfxCalculateClock (Did, StdHeader); |
| 191 | } |
| 192 | return 200*100; |
| 193 | } |
| 194 | |
| 195 | /*----------------------------------------------------------------------------------------*/ |
| 196 | /** |
| 197 | * Disable GFX controller |
| 198 | * |
| 199 | * |
| 200 | * |
| 201 | * @param[in] StdHeader Standard configuration header |
| 202 | */ |
| 203 | |
| 204 | VOID |
| 205 | GfxFmDisableController ( |
| 206 | IN AMD_CONFIG_PARAMS *StdHeader |
| 207 | ) |
| 208 | { |
| 209 | AGESA_STATUS Status; |
| 210 | GFX_FAM_SERVICES *GfxFamilyService; |
| 211 | GNB_HANDLE *GnbHandle; |
| 212 | GnbHandle = GnbGetHandle (StdHeader); |
Arthur Heymans | b80de18 | 2022-05-16 15:29:53 +0200 | [diff] [blame^] | 213 | Status = GnbLibLocateService (GfxFamService, GnbGetSocketId (GnbHandle), (CONST VOID **)&GfxFamilyService, StdHeader); |
Siyuan Wang | affe85f | 2013-07-25 15:14:15 +0800 | [diff] [blame] | 214 | ASSERT (Status == AGESA_SUCCESS); |
| 215 | if (Status == AGESA_SUCCESS) { |
| 216 | GfxFamilyService->GfxDisableController (StdHeader); |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | /*----------------------------------------------------------------------------------------*/ |
| 221 | /** |
| 222 | * Set idle voltage mode for GFX |
| 223 | * |
| 224 | * |
| 225 | * @param[in] Gfx Pointer to global GFX configuration |
| 226 | */ |
| 227 | |
| 228 | BOOLEAN |
| 229 | GfxFmIsVbiosPosted ( |
| 230 | IN GFX_PLATFORM_CONFIG *Gfx |
| 231 | ) |
| 232 | { |
| 233 | AGESA_STATUS Status; |
| 234 | GFX_FAM_SERVICES *GfxFamilyService; |
| 235 | GNB_HANDLE *GnbHandle; |
| 236 | GnbHandle = GnbGetHandle (GnbLibGetHeader (Gfx)); |
Arthur Heymans | b80de18 | 2022-05-16 15:29:53 +0200 | [diff] [blame^] | 237 | Status = GnbLibLocateService (GfxFamService, GnbGetSocketId (GnbHandle), (CONST VOID **)&GfxFamilyService, GnbLibGetHeader (Gfx)); |
Siyuan Wang | affe85f | 2013-07-25 15:14:15 +0800 | [diff] [blame] | 238 | ASSERT (Status == AGESA_SUCCESS); |
| 239 | if (Status == AGESA_SUCCESS) { |
| 240 | return GfxFamilyService->GfxIsVbiosPosted (Gfx); |
| 241 | } |
| 242 | return TRUE; |
| 243 | } |