blob: 7604277346728bfa8d8497d1ad39c8a7b6526b6e [file] [log] [blame]
Kyösti Mälkkif09e6d42015-01-10 12:13:23 +02001/*
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älkkif09e6d42015-01-10 12:13:23 +020014 */
15
16#include "AGESA.h"
17#include "amdlib.h"
Patrick Georgi0e3c59e2017-01-28 15:59:25 +010018#include <spd_bin.h>
Kyösti Mälkkif09e6d42015-01-10 12:13:23 +020019#include <northbridge/amd/agesa/BiosCallOuts.h>
20#include "heapManager.h"
21#include "SB800.h"
22#include <stdlib.h>
Kyösti Mälkki78093562014-11-11 17:22:23 +020023#include "gpio_ftns.h"
Kyösti Mälkkif09e6d42015-01-10 12:13:23 +020024
Stefan Reinauerdd132a52015-07-30 11:16:37 -070025static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr);
26static AGESA_STATUS board_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr);
Kyösti Mälkkif09e6d42015-01-10 12:13:23 +020027
28const BIOS_CALLOUT_STRUCT BiosCallouts[] =
29{
Kyösti Mälkkif09e6d42015-01-10 12:13:23 +020030 {AGESA_DO_RESET, agesa_Reset },
Kyösti Mälkki8c190f32014-11-14 16:20:22 +020031 {AGESA_READ_SPD, board_ReadSpd_from_cbfs },
Kyösti Mälkkif09e6d42015-01-10 12:13:23 +020032 {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};
40const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts);
41
42/* Call the host environment interface to provide a user hook opportunity. */
Stefan Reinauerdd132a52015-07-30 11:16:37 -070043static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr)
Kyösti Mälkkif09e6d42015-01-10 12:13:23 +020044{
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älkki8c190f32014-11-14 16:20:22 +020050
Stefan Reinauerdd132a52015-07-30 11:16:37 -070051static AGESA_STATUS board_ReadSpd_from_cbfs(UINT32 Func, UINTN Data, VOID *ConfigPtr)
Kyösti Mälkki8c190f32014-11-14 16:20:22 +020052{
53 AGESA_STATUS Status = AGESA_UNSUPPORTED;
54#ifdef __PRE_RAM__
55 AGESA_READ_SPD_PARAMS *info = ConfigPtr;
Kyösti Mälkki78093562014-11-11 17:22:23 +020056 u8 index = get_spd_offset();
Kyösti Mälkki8c190f32014-11-14 16:20:22 +020057
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 Georgi2e08b592017-01-28 15:26:43 +010066 if (read_ddr3_spd_from_cbfs((u8*)info->Buffer, index) < 0)
Kyösti Mälkki8c190f32014-11-14 16:20:22 +020067 die("No SPD data\n");
68
69 Status = AGESA_SUCCESS;
70#endif
71 return Status;
72}