blob: f19fb885924d0bd5eaf52ef27c04786abac70d04 [file] [log] [blame]
Frank Vibrans69da1b62011-02-14 19:04:45 +00001/*
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
Paul Menzela8ae1c62013-02-20 13:21:20 +010012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Frank Vibrans69da1b62011-02-14 19:04:45 +000013 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
Marc Jones36abff12011-11-07 23:26:14 -070017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Frank Vibrans69da1b62011-02-14 19:04:45 +000018 */
efdesign98d7a696d2011-09-15 15:24:26 -060019
Frank Vibrans69da1b62011-02-14 19:04:45 +000020#include "agesawrapper.h"
21#include "amdlib.h"
22#include "BiosCallOuts.h"
23#include "heapManager.h"
24#include "SB800.h"
Martin Roth45f72ce2013-02-24 12:58:33 -070025#include <northbridge/amd/agesa/family14/dimmSpd.h>
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030026#include <stdlib.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000027
Kyösti Mälkkic0096012014-05-05 18:56:33 +030028static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINT32 Data, VOID *ConfigPtr);
29static AGESA_STATUS board_GnbPcieSlotReset (UINT32 Func, UINT32 Data, VOID *ConfigPtr);
30
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030031const BIOS_CALLOUT_STRUCT BiosCallouts[] =
Frank Vibrans69da1b62011-02-14 19:04:45 +000032{
Kyösti Mälkki08df7322014-05-04 14:53:36 +030033 {AGESA_ALLOCATE_BUFFER, BiosAllocateBuffer },
34 {AGESA_DEALLOCATE_BUFFER, BiosDeallocateBuffer },
Kyösti Mälkki08df7322014-05-04 14:53:36 +030035 {AGESA_LOCATE_BUFFER, BiosLocateBuffer },
Kyösti Mälkki5e19fa42014-05-04 23:13:54 +030036 {AGESA_DO_RESET, agesa_Reset },
Kyösti Mälkki08df7322014-05-04 14:53:36 +030037 {AGESA_READ_SPD, BiosReadSpd },
Kyösti Mälkkic459f962014-05-04 17:07:45 +030038 {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported },
Kyösti Mälkki6b4b1512014-05-05 12:05:53 +030039 {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp },
Kyösti Mälkkic0096012014-05-05 18:56:33 +030040 {AGESA_GNB_PCIE_SLOT_RESET, board_GnbPcieSlotReset },
41 {AGESA_HOOKBEFORE_DRAM_INIT, board_BeforeDramInit },
Kyösti Mälkkic459f962014-05-04 17:07:45 +030042 {AGESA_HOOKBEFORE_DRAM_INIT_RECOVERY, agesa_NoopSuccess },
43 {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess },
44 {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess },
Frank Vibrans69da1b62011-02-14 19:04:45 +000045};
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030046const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts);
Frank Vibrans69da1b62011-02-14 19:04:45 +000047
Marc Jones36abff12011-11-07 23:26:14 -070048/* Call the host environment interface to provide a user hook opportunity. */
Kyösti Mälkkic0096012014-05-05 18:56:33 +030049static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINT32 Data, VOID *ConfigPtr)
Frank Vibrans69da1b62011-02-14 19:04:45 +000050{
Jens Rottmann384ee9f2013-02-18 20:26:50 +010051 // Unlike e.g. AMD Inagua, Persimmon is unable to vary the RAM voltage.
52 // Make sure the right speed settings are selected.
53 ((MEM_DATA_STRUCT*)ConfigPtr)->ParameterListPtr->DDR3Voltage = VOLT1_5;
54 return AGESA_SUCCESS;
Frank Vibrans69da1b62011-02-14 19:04:45 +000055}
efdesign98d7a696d2011-09-15 15:24:26 -060056
Frank Vibrans69da1b62011-02-14 19:04:45 +000057/* PCIE slot reset control */
Kyösti Mälkkic0096012014-05-05 18:56:33 +030058static AGESA_STATUS board_GnbPcieSlotReset (UINT32 Func, UINT32 Data, VOID *ConfigPtr)
Frank Vibrans69da1b62011-02-14 19:04:45 +000059{
Marc Jones36abff12011-11-07 23:26:14 -070060 AGESA_STATUS Status;
61 UINTN FcnData;
62 PCIe_SLOT_RESET_INFO *ResetInfo;
efdesign98d7a696d2011-09-15 15:24:26 -060063
Marc Jones36abff12011-11-07 23:26:14 -070064 UINT32 GpioMmioAddr;
65 UINT32 AcpiMmioAddr;
66 UINT8 Data8;
67 UINT16 Data16;
efdesign98d7a696d2011-09-15 15:24:26 -060068
Marc Jones36abff12011-11-07 23:26:14 -070069 FcnData = Data;
70 ResetInfo = ConfigPtr;
71 // Get SB800 MMIO Base (AcpiMmioAddr)
72 WriteIo8(0xCD6, 0x27);
73 Data8 = ReadIo8(0xCD7);
74 Data16=Data8<<8;
75 WriteIo8(0xCD6, 0x26);
76 Data8 = ReadIo8(0xCD7);
77 Data16|=Data8;
78 AcpiMmioAddr = (UINT32)Data16 << 16;
79 Status = AGESA_UNSUPPORTED;
80 GpioMmioAddr = AcpiMmioAddr + GPIO_BASE;
81 switch (ResetInfo->ResetId)
82 {
Jens Rottmannfa8702c2013-02-18 19:40:33 +010083 case 46: // GPIO50 = SBGPIO_PCIE_RST# affects LAN0, LAN1, PCIe slot
Marc Jones36abff12011-11-07 23:26:14 -070084 switch (ResetInfo->ResetControl) {
zbaoafd141d2012-03-30 15:32:07 +080085 case AssertSlotReset:
Jens Rottmannfa8702c2013-02-18 19:40:33 +010086 Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50);
Marc Jones36abff12011-11-07 23:26:14 -070087 Data8 &= ~(UINT8)BIT6 ;
Jens Rottmannfa8702c2013-02-18 19:40:33 +010088 Write64Mem8(GpioMmioAddr+SB_GPIO_REG50, Data8);
Marc Jones36abff12011-11-07 23:26:14 -070089 Status = AGESA_SUCCESS;
90 break;
zbaoafd141d2012-03-30 15:32:07 +080091 case DeassertSlotReset:
Jens Rottmannfa8702c2013-02-18 19:40:33 +010092 Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50);
Marc Jones36abff12011-11-07 23:26:14 -070093 Data8 |= BIT6 ;
Jens Rottmannfa8702c2013-02-18 19:40:33 +010094 Write64Mem8 (GpioMmioAddr+SB_GPIO_REG50, Data8);
Marc Jones36abff12011-11-07 23:26:14 -070095 Status = AGESA_SUCCESS;
96 break;
97 }
98 break;
99 }
100 return Status;
Frank Vibrans69da1b62011-02-14 19:04:45 +0000101}