blob: 153c93930d30554f09078912beaefc221ba72d1f [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>
Frank Vibrans69da1b62011-02-14 19:04:45 +000026
efdesign98d7a696d2011-09-15 15:24:26 -060027STATIC BIOS_CALLOUT_STRUCT BiosCallouts[] =
Frank Vibrans69da1b62011-02-14 19:04:45 +000028{
Kyösti Mälkki08df7322014-05-04 14:53:36 +030029 {AGESA_ALLOCATE_BUFFER, BiosAllocateBuffer },
30 {AGESA_DEALLOCATE_BUFFER, BiosDeallocateBuffer },
Kyösti Mälkki08df7322014-05-04 14:53:36 +030031 {AGESA_LOCATE_BUFFER, BiosLocateBuffer },
Kyösti Mälkki5e19fa42014-05-04 23:13:54 +030032 {AGESA_DO_RESET, agesa_Reset },
Kyösti Mälkki08df7322014-05-04 14:53:36 +030033 {AGESA_READ_SPD, BiosReadSpd },
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älkki08df7322014-05-04 14:53:36 +030036 {AGESA_GNB_PCIE_SLOT_RESET, BiosGnbPcieSlotReset },
37 {AGESA_HOOKBEFORE_DRAM_INIT, BiosHookBeforeDramInit },
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};
42
efdesign98d7a696d2011-09-15 15:24:26 -060043AGESA_STATUS GetBiosCallout (UINT32 Func, UINT32 Data, VOID *ConfigPtr)
44{
Marc Jones36abff12011-11-07 23:26:14 -070045 UINTN i;
46 AGESA_STATUS CalloutStatus;
47 UINTN CallOutCount = sizeof (BiosCallouts) / sizeof (BiosCallouts [0]);
efdesign98d7a696d2011-09-15 15:24:26 -060048
zbaoafd141d2012-03-30 15:32:07 +080049 /*
50 * printk(BIOS_SPEW,"%s function: %x\n", __func__, (u32) Func);
51 */
52
Marc Jones36abff12011-11-07 23:26:14 -070053 CalloutStatus = AGESA_UNSUPPORTED;
efdesign98d7a696d2011-09-15 15:24:26 -060054
Marc Jones36abff12011-11-07 23:26:14 -070055 for (i = 0; i < CallOutCount; i++) {
56 if (BiosCallouts[i].CalloutName == Func) {
57 CalloutStatus = BiosCallouts[i].CalloutPtr (Func, Data, ConfigPtr);
58 return CalloutStatus;
59 }
60 }
Stefan Reinauer5ff7c132011-10-31 12:56:45 -070061
Marc Jones36abff12011-11-07 23:26:14 -070062 return CalloutStatus;
Frank Vibrans69da1b62011-02-14 19:04:45 +000063}
64
Marc Jones36abff12011-11-07 23:26:14 -070065/* Call the host environment interface to provide a user hook opportunity. */
Frank Vibrans69da1b62011-02-14 19:04:45 +000066AGESA_STATUS BiosHookBeforeDramInit (UINT32 Func, UINT32 Data, VOID *ConfigPtr)
67{
Jens Rottmann384ee9f2013-02-18 20:26:50 +010068 // Unlike e.g. AMD Inagua, Persimmon is unable to vary the RAM voltage.
69 // Make sure the right speed settings are selected.
70 ((MEM_DATA_STRUCT*)ConfigPtr)->ParameterListPtr->DDR3Voltage = VOLT1_5;
71 return AGESA_SUCCESS;
Frank Vibrans69da1b62011-02-14 19:04:45 +000072}
efdesign98d7a696d2011-09-15 15:24:26 -060073
Frank Vibrans69da1b62011-02-14 19:04:45 +000074/* PCIE slot reset control */
75AGESA_STATUS BiosGnbPcieSlotReset (UINT32 Func, UINT32 Data, VOID *ConfigPtr)
76{
Marc Jones36abff12011-11-07 23:26:14 -070077 AGESA_STATUS Status;
78 UINTN FcnData;
79 PCIe_SLOT_RESET_INFO *ResetInfo;
efdesign98d7a696d2011-09-15 15:24:26 -060080
Marc Jones36abff12011-11-07 23:26:14 -070081 UINT32 GpioMmioAddr;
82 UINT32 AcpiMmioAddr;
83 UINT8 Data8;
84 UINT16 Data16;
efdesign98d7a696d2011-09-15 15:24:26 -060085
Marc Jones36abff12011-11-07 23:26:14 -070086 FcnData = Data;
87 ResetInfo = ConfigPtr;
88 // Get SB800 MMIO Base (AcpiMmioAddr)
89 WriteIo8(0xCD6, 0x27);
90 Data8 = ReadIo8(0xCD7);
91 Data16=Data8<<8;
92 WriteIo8(0xCD6, 0x26);
93 Data8 = ReadIo8(0xCD7);
94 Data16|=Data8;
95 AcpiMmioAddr = (UINT32)Data16 << 16;
96 Status = AGESA_UNSUPPORTED;
97 GpioMmioAddr = AcpiMmioAddr + GPIO_BASE;
98 switch (ResetInfo->ResetId)
99 {
Jens Rottmannfa8702c2013-02-18 19:40:33 +0100100 case 46: // GPIO50 = SBGPIO_PCIE_RST# affects LAN0, LAN1, PCIe slot
Marc Jones36abff12011-11-07 23:26:14 -0700101 switch (ResetInfo->ResetControl) {
zbaoafd141d2012-03-30 15:32:07 +0800102 case AssertSlotReset:
Jens Rottmannfa8702c2013-02-18 19:40:33 +0100103 Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50);
Marc Jones36abff12011-11-07 23:26:14 -0700104 Data8 &= ~(UINT8)BIT6 ;
Jens Rottmannfa8702c2013-02-18 19:40:33 +0100105 Write64Mem8(GpioMmioAddr+SB_GPIO_REG50, Data8);
Marc Jones36abff12011-11-07 23:26:14 -0700106 Status = AGESA_SUCCESS;
107 break;
zbaoafd141d2012-03-30 15:32:07 +0800108 case DeassertSlotReset:
Jens Rottmannfa8702c2013-02-18 19:40:33 +0100109 Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50);
Marc Jones36abff12011-11-07 23:26:14 -0700110 Data8 |= BIT6 ;
Jens Rottmannfa8702c2013-02-18 19:40:33 +0100111 Write64Mem8 (GpioMmioAddr+SB_GPIO_REG50, Data8);
Marc Jones36abff12011-11-07 23:26:14 -0700112 Status = AGESA_SUCCESS;
113 break;
114 }
115 break;
116 }
117 return Status;
Frank Vibrans69da1b62011-02-14 19:04:45 +0000118}