Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 1 | /* |
| 2 | * This file is part of the coreboot project. |
| 3 | * |
| 4 | * Copyright (C) 2011 Advanced Micro Devices, Inc. |
| 5 | * |
| 6 | * This program is free software; you can redistribute it and/or modify |
| 7 | * it under the terms of the GNU General Public License as published by |
| 8 | * the Free Software Foundation; version 2 of the License. |
| 9 | * |
| 10 | * This program is distributed in the hope that it will be useful, |
| 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | * GNU General Public License for more details. |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 14 | */ |
| 15 | |
| 16 | #include "AGESA.h" |
| 17 | #include "amdlib.h" |
Patrick Georgi | 0e3c59e | 2017-01-28 15:59:25 +0100 | [diff] [blame^] | 18 | #include <spd_bin.h> |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 19 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
| 20 | #include "heapManager.h" |
| 21 | #include "SB800.h" |
| 22 | #include <stdlib.h> |
Kyösti Mälkki | 7809356 | 2014-11-11 17:22:23 +0200 | [diff] [blame] | 23 | #include "gpio_ftns.h" |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 24 | |
Stefan Reinauer | dd132a5 | 2015-07-30 11:16:37 -0700 | [diff] [blame] | 25 | static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr); |
| 26 | static AGESA_STATUS board_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr); |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 27 | |
| 28 | const BIOS_CALLOUT_STRUCT BiosCallouts[] = |
| 29 | { |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 30 | {AGESA_DO_RESET, agesa_Reset }, |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 31 | {AGESA_READ_SPD, board_ReadSpd_from_cbfs }, |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 32 | {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported }, |
| 33 | {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp }, |
| 34 | {AGESA_GNB_PCIE_SLOT_RESET, agesa_NoopSuccess }, |
| 35 | {AGESA_HOOKBEFORE_DRAM_INIT, board_BeforeDramInit }, |
| 36 | {AGESA_HOOKBEFORE_DRAM_INIT_RECOVERY, agesa_NoopSuccess }, |
| 37 | {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess }, |
| 38 | {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess }, |
| 39 | }; |
| 40 | const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts); |
| 41 | |
| 42 | /* Call the host environment interface to provide a user hook opportunity. */ |
Stefan Reinauer | dd132a5 | 2015-07-30 11:16:37 -0700 | [diff] [blame] | 43 | static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr) |
Kyösti Mälkki | f09e6d4 | 2015-01-10 12:13:23 +0200 | [diff] [blame] | 44 | { |
| 45 | // Unlike e.g. AMD Inagua, Persimmon is unable to vary the RAM voltage. |
| 46 | // Make sure the right speed settings are selected. |
| 47 | ((MEM_DATA_STRUCT*)ConfigPtr)->ParameterListPtr->DDR3Voltage = VOLT1_5; |
| 48 | return AGESA_SUCCESS; |
| 49 | } |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 50 | |
Stefan Reinauer | dd132a5 | 2015-07-30 11:16:37 -0700 | [diff] [blame] | 51 | static AGESA_STATUS board_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr) |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 52 | { |
| 53 | AGESA_STATUS Status = AGESA_UNSUPPORTED; |
| 54 | #ifdef __PRE_RAM__ |
| 55 | AGESA_READ_SPD_PARAMS *info = ConfigPtr; |
Kyösti Mälkki | 7809356 | 2014-11-11 17:22:23 +0200 | [diff] [blame] | 56 | u8 index = get_spd_offset(); |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 57 | |
| 58 | if (info->MemChannelId > 0) |
| 59 | return AGESA_UNSUPPORTED; |
| 60 | if (info->SocketId != 0) |
| 61 | return AGESA_UNSUPPORTED; |
| 62 | if (info->DimmId != 0) |
| 63 | return AGESA_UNSUPPORTED; |
| 64 | |
| 65 | /* Read index 0, first SPD_SIZE bytes of spd.bin file. */ |
Patrick Georgi | 2e08b59 | 2017-01-28 15:26:43 +0100 | [diff] [blame] | 66 | if (read_ddr3_spd_from_cbfs((u8*)info->Buffer, index) < 0) |
Kyösti Mälkki | 8c190f3 | 2014-11-14 16:20:22 +0200 | [diff] [blame] | 67 | die("No SPD data\n"); |
| 68 | |
| 69 | Status = AGESA_SUCCESS; |
| 70 | #endif |
| 71 | return Status; |
| 72 | } |