Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [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 |
Paul Menzel | a8ae1c6 | 2013-02-20 13:21:20 +0100 | [diff] [blame] | 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 13 | * 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 Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 17 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 18 | */ |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 19 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 20 | #include "agesawrapper.h" |
| 21 | #include "amdlib.h" |
| 22 | #include "BiosCallOuts.h" |
| 23 | #include "heapManager.h" |
| 24 | #include "SB800.h" |
Martin Roth | 45f72ce | 2013-02-24 12:58:33 -0700 | [diff] [blame] | 25 | #include <northbridge/amd/agesa/family14/dimmSpd.h> |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 26 | |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 27 | STATIC BIOS_CALLOUT_STRUCT BiosCallouts[] = |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 28 | { |
Kyösti Mälkki | 08df732 | 2014-05-04 14:53:36 +0300 | [diff] [blame] | 29 | {AGESA_ALLOCATE_BUFFER, BiosAllocateBuffer }, |
| 30 | {AGESA_DEALLOCATE_BUFFER, BiosDeallocateBuffer }, |
Kyösti Mälkki | 08df732 | 2014-05-04 14:53:36 +0300 | [diff] [blame] | 31 | {AGESA_LOCATE_BUFFER, BiosLocateBuffer }, |
Kyösti Mälkki | 5e19fa4 | 2014-05-04 23:13:54 +0300 | [diff] [blame^] | 32 | {AGESA_DO_RESET, agesa_Reset }, |
Kyösti Mälkki | 08df732 | 2014-05-04 14:53:36 +0300 | [diff] [blame] | 33 | {AGESA_READ_SPD, BiosReadSpd }, |
Kyösti Mälkki | c459f96 | 2014-05-04 17:07:45 +0300 | [diff] [blame] | 34 | {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported }, |
Kyösti Mälkki | 08df732 | 2014-05-04 14:53:36 +0300 | [diff] [blame] | 35 | {AGESA_RUNFUNC_ONAP, BiosRunFuncOnAp }, |
| 36 | {AGESA_GNB_PCIE_SLOT_RESET, BiosGnbPcieSlotReset }, |
| 37 | {AGESA_HOOKBEFORE_DRAM_INIT, BiosHookBeforeDramInit }, |
Kyösti Mälkki | c459f96 | 2014-05-04 17:07:45 +0300 | [diff] [blame] | 38 | {AGESA_HOOKBEFORE_DRAM_INIT_RECOVERY, agesa_NoopSuccess }, |
| 39 | {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess }, |
| 40 | {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess }, |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 41 | }; |
| 42 | |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 43 | AGESA_STATUS GetBiosCallout (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 44 | { |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 45 | UINTN i; |
| 46 | AGESA_STATUS CalloutStatus; |
| 47 | UINTN CallOutCount = sizeof (BiosCallouts) / sizeof (BiosCallouts [0]); |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 48 | |
zbao | afd141d | 2012-03-30 15:32:07 +0800 | [diff] [blame] | 49 | /* |
| 50 | * printk(BIOS_SPEW,"%s function: %x\n", __func__, (u32) Func); |
| 51 | */ |
| 52 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 53 | CalloutStatus = AGESA_UNSUPPORTED; |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 54 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 55 | 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 Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 61 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 62 | return CalloutStatus; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 63 | } |
| 64 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 65 | /* Call the host environment interface to provide a user hook opportunity. */ |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 66 | AGESA_STATUS BiosHookBeforeDramInit (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 67 | { |
Jens Rottmann | 384ee9f | 2013-02-18 20:26:50 +0100 | [diff] [blame] | 68 | // 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 Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 72 | } |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 73 | |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 74 | /* PCIE slot reset control */ |
| 75 | AGESA_STATUS BiosGnbPcieSlotReset (UINT32 Func, UINT32 Data, VOID *ConfigPtr) |
| 76 | { |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 77 | AGESA_STATUS Status; |
| 78 | UINTN FcnData; |
| 79 | PCIe_SLOT_RESET_INFO *ResetInfo; |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 80 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 81 | UINT32 GpioMmioAddr; |
| 82 | UINT32 AcpiMmioAddr; |
| 83 | UINT8 Data8; |
| 84 | UINT16 Data16; |
efdesign98 | d7a696d | 2011-09-15 15:24:26 -0600 | [diff] [blame] | 85 | |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 86 | 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 Rottmann | fa8702c | 2013-02-18 19:40:33 +0100 | [diff] [blame] | 100 | case 46: // GPIO50 = SBGPIO_PCIE_RST# affects LAN0, LAN1, PCIe slot |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 101 | switch (ResetInfo->ResetControl) { |
zbao | afd141d | 2012-03-30 15:32:07 +0800 | [diff] [blame] | 102 | case AssertSlotReset: |
Jens Rottmann | fa8702c | 2013-02-18 19:40:33 +0100 | [diff] [blame] | 103 | Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50); |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 104 | Data8 &= ~(UINT8)BIT6 ; |
Jens Rottmann | fa8702c | 2013-02-18 19:40:33 +0100 | [diff] [blame] | 105 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG50, Data8); |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 106 | Status = AGESA_SUCCESS; |
| 107 | break; |
zbao | afd141d | 2012-03-30 15:32:07 +0800 | [diff] [blame] | 108 | case DeassertSlotReset: |
Jens Rottmann | fa8702c | 2013-02-18 19:40:33 +0100 | [diff] [blame] | 109 | Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG50); |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 110 | Data8 |= BIT6 ; |
Jens Rottmann | fa8702c | 2013-02-18 19:40:33 +0100 | [diff] [blame] | 111 | Write64Mem8 (GpioMmioAddr+SB_GPIO_REG50, Data8); |
Marc Jones | 36abff1 | 2011-11-07 23:26:14 -0700 | [diff] [blame] | 112 | Status = AGESA_SUCCESS; |
| 113 | break; |
| 114 | } |
| 115 | break; |
| 116 | } |
| 117 | return Status; |
Frank Vibrans | 69da1b6 | 2011-02-14 19:04:45 +0000 | [diff] [blame] | 118 | } |