Kyösti Mälkki | e4c17ce | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Advanced Micro Devices, Inc. |
| 5 | * Copyright (C) 2013 Sage Electronic Engineering, LLC |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or modify |
| 8 | * it under the terms of the GNU General Public License as published by |
| 9 | * the Free Software Foundation; version 2 of the License. |
| 10 | * |
| 11 | * This program is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 14 | * GNU General Public License for more details. |
Kyösti Mälkki | e4c17ce | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 15 | */ |
| 16 | |
| 17 | #include <cbfs.h> |
| 18 | #include <spd_cache.h> |
| 19 | |
| 20 | #include "AGESA.h" |
| 21 | #include "amdlib.h" |
| 22 | #include "Ids.h" |
| 23 | #include "agesawrapper.h" |
| 24 | #include "BiosCallOuts.h" |
| 25 | #include "dimmSpd.h" |
| 26 | |
| 27 | AGESA_STATUS GetBiosCallout (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 28 | { |
| 29 | UINTN i; |
| 30 | |
| 31 | for (i = 0; i < BiosCalloutsLen; i++) { |
| 32 | if (BiosCallouts[i].CalloutName == Func) |
| 33 | break; |
| 34 | } |
| 35 | if(i >= BiosCalloutsLen) |
| 36 | return AGESA_UNSUPPORTED; |
| 37 | |
| 38 | return BiosCallouts[i].CalloutPtr (Func, Data, ConfigPtr); |
| 39 | } |
| 40 | |
| 41 | AGESA_STATUS agesa_NoopUnsupported (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 42 | { |
| 43 | return AGESA_UNSUPPORTED; |
| 44 | } |
| 45 | |
| 46 | AGESA_STATUS agesa_NoopSuccess (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 47 | { |
| 48 | return AGESA_SUCCESS; |
| 49 | } |
| 50 | |
| 51 | AGESA_STATUS agesa_EmptyIdsInitData (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 52 | { |
| 53 | IDS_NV_ITEM *IdsPtr = ((IDS_CALLOUT_STRUCT *) ConfigPtr)->IdsNvPtr; |
| 54 | if (Data == IDS_CALLOUT_INIT) |
| 55 | IdsPtr[0].IdsNvValue = IdsPtr[0].IdsNvId = 0xffff; |
| 56 | return AGESA_SUCCESS; |
| 57 | } |
| 58 | |
| 59 | AGESA_STATUS agesa_Reset (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 60 | { |
| 61 | AGESA_STATUS Status; |
| 62 | UINT8 Value; |
| 63 | UINTN ResetType; |
| 64 | AMD_CONFIG_PARAMS *StdHeader; |
| 65 | |
| 66 | ResetType = Data; |
| 67 | StdHeader = ConfigPtr; |
| 68 | |
| 69 | // |
| 70 | // Perform the RESET based upon the ResetType. In case of |
| 71 | // WARM_RESET_WHENVER and COLD_RESET_WHENEVER, the request will go to |
| 72 | // AmdResetManager. During the critical condition, where reset is required |
| 73 | // immediately, the reset will be invoked directly by writing 0x04 to port |
| 74 | // 0xCF9 (Reset Port). |
| 75 | // |
| 76 | switch (ResetType) { |
| 77 | case WARM_RESET_WHENEVER: |
| 78 | case COLD_RESET_WHENEVER: |
| 79 | break; |
| 80 | |
| 81 | case WARM_RESET_IMMEDIATELY: |
| 82 | case COLD_RESET_IMMEDIATELY: |
| 83 | Value = 0x06; |
| 84 | LibAmdIoWrite (AccessWidth8, 0xCf9, &Value, StdHeader); |
| 85 | break; |
| 86 | |
| 87 | default: |
| 88 | break; |
| 89 | } |
| 90 | |
| 91 | Status = 0; |
| 92 | return Status; |
| 93 | } |
| 94 | |
| 95 | AGESA_STATUS agesa_RunFuncOnAp (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 96 | { |
| 97 | AGESA_STATUS Status; |
| 98 | |
| 99 | Status = agesawrapper_amdlaterunaptask (Func, Data, ConfigPtr); |
| 100 | return Status; |
| 101 | } |
| 102 | |
| 103 | AGESA_STATUS agesa_GfxGetVbiosImage(UINT32 Func, UINT32 FchData, VOID *ConfigPrt) |
| 104 | { |
| 105 | GFX_VBIOS_IMAGE_INFO *pVbiosImageInfo = (GFX_VBIOS_IMAGE_INFO *)ConfigPrt; |
Aaron Durbin | 899d13d | 2015-05-15 23:39:23 -0500 | [diff] [blame] | 106 | pVbiosImageInfo->ImagePtr = cbfs_boot_map_with_leak( |
| 107 | "pci"CONFIG_VGA_BIOS_ID".rom", |
Kyösti Mälkki | e4c17ce | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 108 | CBFS_TYPE_OPTIONROM, NULL); |
Bruce Griffith | 006364e | 2014-10-22 03:33:49 -0600 | [diff] [blame] | 109 | printk(BIOS_DEBUG, "agesa_GfxGetVbiosImage: IMGptr=%p\n", pVbiosImageInfo->ImagePtr); |
| 110 | return (pVbiosImageInfo->ImagePtr ? AGESA_SUCCESS : AGESA_WARNING); |
Kyösti Mälkki | e4c17ce | 2014-10-21 18:22:32 +0300 | [diff] [blame] | 111 | } |
| 112 | |
| 113 | AGESA_STATUS agesa_ReadSpd (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 114 | { |
| 115 | AGESA_STATUS Status = AGESA_UNSUPPORTED; |
| 116 | #ifdef __PRE_RAM__ |
| 117 | Status = AmdMemoryReadSPD (Func, Data, ConfigPtr); |
| 118 | #endif |
| 119 | return Status; |
| 120 | } |
| 121 | |
| 122 | AGESA_STATUS agesa_ReadSpd_from_cbfs(UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 123 | { |
| 124 | AGESA_STATUS Status = AGESA_UNSUPPORTED; |
| 125 | #ifdef __PRE_RAM__ |
| 126 | AGESA_READ_SPD_PARAMS *info = ConfigPtr; |
| 127 | if (info->MemChannelId > 0) |
| 128 | return AGESA_UNSUPPORTED; |
| 129 | if (info->SocketId != 0) |
| 130 | return AGESA_UNSUPPORTED; |
| 131 | if (info->DimmId != 0) |
| 132 | return AGESA_UNSUPPORTED; |
| 133 | |
| 134 | /* Read index 0, first SPD_SIZE bytes of spd.bin file. */ |
| 135 | if (read_spd_from_cbfs((u8*)info->Buffer, 0) < 0) |
| 136 | die("No SPD data\n"); |
| 137 | |
| 138 | Status = AGESA_SUCCESS; |
| 139 | #endif |
| 140 | return Status; |
| 141 | } |