blob: 067b03e947de3dccd0bc8e234b8fc711e5520645 [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
Patrick Georgib890a122015-03-26 15:17:45 +010017 * Foundation, Inc.
Frank Vibrans69da1b62011-02-14 19:04:45 +000018 */
efdesign98d7a696d2011-09-15 15:24:26 -060019
Kyösti Mälkki526c2fb2014-07-10 22:16:58 +030020#include "AGESA.h"
Frank Vibrans69da1b62011-02-14 19:04:45 +000021#include "amdlib.h"
Kyösti Mälkki26f297e2014-05-26 11:27:54 +030022#include <northbridge/amd/agesa/BiosCallOuts.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000023#include "heapManager.h"
24#include "SB800.h"
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030025#include <stdlib.h>
Frank Vibrans69da1b62011-02-14 19:04:45 +000026
Stefan Reinauerdd132a52015-07-30 11:16:37 -070027static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr);
28static AGESA_STATUS board_GnbPcieSlotReset (UINT32 Func, UINTN Data, VOID *ConfigPtr);
Kyösti Mälkkic0096012014-05-05 18:56:33 +030029
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030030const BIOS_CALLOUT_STRUCT BiosCallouts[] =
Frank Vibrans69da1b62011-02-14 19:04:45 +000031{
Kyösti Mälkki5e19fa42014-05-04 23:13:54 +030032 {AGESA_DO_RESET, agesa_Reset },
Kyösti Mälkkia1ebbc42014-10-17 22:33:22 +030033 {AGESA_READ_SPD, agesa_ReadSpd },
Kyösti Mälkkic459f962014-05-04 17:07:45 +030034 {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported },
Kyösti Mälkki6b4b1512014-05-05 12:05:53 +030035 {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp },
Kyösti Mälkkic0096012014-05-05 18:56:33 +030036 {AGESA_GNB_PCIE_SLOT_RESET, board_GnbPcieSlotReset },
37 {AGESA_HOOKBEFORE_DRAM_INIT, board_BeforeDramInit },
Kyösti Mälkkic459f962014-05-04 17:07:45 +030038 {AGESA_HOOKBEFORE_DRAM_INIT_RECOVERY, agesa_NoopSuccess },
39 {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess },
40 {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess },
Frank Vibrans69da1b62011-02-14 19:04:45 +000041};
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030042const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts);
Frank Vibrans69da1b62011-02-14 19:04:45 +000043
Marc Jones36abff12011-11-07 23:26:14 -070044/* Call the host environment interface to provide a user hook opportunity. */
Stefan Reinauerdd132a52015-07-30 11:16:37 -070045static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr)
Frank Vibrans69da1b62011-02-14 19:04:45 +000046{
Jens Rottmann384ee9f2013-02-18 20:26:50 +010047 // Unlike e.g. AMD Inagua, Persimmon is unable to vary the RAM voltage.
48 // Make sure the right speed settings are selected.
49 ((MEM_DATA_STRUCT*)ConfigPtr)->ParameterListPtr->DDR3Voltage = VOLT1_5;
50 return AGESA_SUCCESS;
Frank Vibrans69da1b62011-02-14 19:04:45 +000051}
efdesign98d7a696d2011-09-15 15:24:26 -060052
Frank Vibrans69da1b62011-02-14 19:04:45 +000053/* PCIE slot reset control */
Stefan Reinauerdd132a52015-07-30 11:16:37 -070054static AGESA_STATUS board_GnbPcieSlotReset (UINT32 Func, UINTN Data, VOID *ConfigPtr)
Frank Vibrans69da1b62011-02-14 19:04:45 +000055{
Marc Jones36abff12011-11-07 23:26:14 -070056 AGESA_STATUS Status;
57 UINTN FcnData;
58 PCIe_SLOT_RESET_INFO *ResetInfo;
efdesign98d7a696d2011-09-15 15:24:26 -060059
Marc Jones36abff12011-11-07 23:26:14 -070060 UINT32 GpioMmioAddr;
61 UINT32 AcpiMmioAddr;
62 UINT8 Data8;
63 UINT16 Data16;
efdesign98d7a696d2011-09-15 15:24:26 -060064
Marc Jones36abff12011-11-07 23:26:14 -070065 FcnData = Data;
66 ResetInfo = ConfigPtr;
67 // Get SB800 MMIO Base (AcpiMmioAddr)
68 WriteIo8(0xCD6, 0x27);
69 Data8 = ReadIo8(0xCD7);
70 Data16=Data8<<8;
71 WriteIo8(0xCD6, 0x26);
72 Data8 = ReadIo8(0xCD7);
73 Data16|=Data8;
74 AcpiMmioAddr = (UINT32)Data16 << 16;
75 Status = AGESA_UNSUPPORTED;
76 GpioMmioAddr = AcpiMmioAddr + GPIO_BASE;
77 switch (ResetInfo->ResetId)
78 {
Jens Rottmannfa8702c2013-02-18 19:40:33 +010079 case 46: // GPIO50 = SBGPIO_PCIE_RST# affects LAN0, LAN1, PCIe slot
Marc Jones36abff12011-11-07 23:26:14 -070080 switch (ResetInfo->ResetControl) {
zbaoafd141d2012-03-30 15:32:07 +080081 case AssertSlotReset:
Jens Rottmannfa8702c2013-02-18 19:40:33 +010082 Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50);
Marc Jones36abff12011-11-07 23:26:14 -070083 Data8 &= ~(UINT8)BIT6 ;
Jens Rottmannfa8702c2013-02-18 19:40:33 +010084 Write64Mem8(GpioMmioAddr+SB_GPIO_REG50, Data8);
Marc Jones36abff12011-11-07 23:26:14 -070085 Status = AGESA_SUCCESS;
86 break;
zbaoafd141d2012-03-30 15:32:07 +080087 case DeassertSlotReset:
Jens Rottmannfa8702c2013-02-18 19:40:33 +010088 Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50);
Marc Jones36abff12011-11-07 23:26:14 -070089 Data8 |= BIT6 ;
Jens Rottmannfa8702c2013-02-18 19:40:33 +010090 Write64Mem8 (GpioMmioAddr+SB_GPIO_REG50, Data8);
Marc Jones36abff12011-11-07 23:26:14 -070091 Status = AGESA_SUCCESS;
92 break;
93 }
94 break;
95 }
96 return Status;
Frank Vibrans69da1b62011-02-14 19:04:45 +000097}