Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +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 |
| 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 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 |
Patrick Georgi | b890a12 | 2015-03-26 15:17:45 +0100 | [diff] [blame] | 17 | * Foundation, Inc. |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 18 | */ |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 19 | |
Kyösti Mälkki | 526c2fb | 2014-07-10 22:16:58 +0300 | [diff] [blame] | 20 | #include "AGESA.h" |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 21 | #include "amdlib.h" |
Kyösti Mälkki | 26f297e | 2014-05-26 11:27:54 +0300 | [diff] [blame] | 22 | #include <northbridge/amd/agesa/BiosCallOuts.h> |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 23 | #include "heapManager.h" |
| 24 | #include "SB800.h" |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 25 | #include <stdlib.h> |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 26 | |
Kyösti Mälkki | f1bb19a | 2014-05-04 17:23:49 +0300 | [diff] [blame] | 27 | |
Stefan Reinauer | dd132a5 | 2015-07-30 11:16:37 -0700 | [diff] [blame^] | 28 | static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr); |
Kyösti Mälkki | c009601 | 2014-05-05 18:56:33 +0300 | [diff] [blame] | 29 | |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 30 | const BIOS_CALLOUT_STRUCT BiosCallouts[] = |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 31 | { |
Kyösti Mälkki | 5e19fa4 | 2014-05-04 23:13:54 +0300 | [diff] [blame] | 32 | {AGESA_DO_RESET, agesa_Reset }, |
Kyösti Mälkki | a1ebbc4 | 2014-10-17 22:33:22 +0300 | [diff] [blame] | 33 | {AGESA_READ_SPD, agesa_ReadSpd }, |
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 | 6b4b151 | 2014-05-05 12:05:53 +0300 | [diff] [blame] | 35 | {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp }, |
Kyösti Mälkki | c459f96 | 2014-05-04 17:07:45 +0300 | [diff] [blame] | 36 | {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess }, |
Kyösti Mälkki | c009601 | 2014-05-05 18:56:33 +0300 | [diff] [blame] | 37 | {AGESA_HOOKBEFORE_DRAM_INIT, board_BeforeDramInit }, |
Kyösti Mälkki | c459f96 | 2014-05-04 17:07:45 +0300 | [diff] [blame] | 38 | {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess }, |
Kyösti Mälkki | f1bb19a | 2014-05-04 17:23:49 +0300 | [diff] [blame] | 39 | {AGESA_GNB_PCIE_SLOT_RESET, agesa_NoopUnsupported }, |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 40 | }; |
Kyösti Mälkki | 6025efa | 2014-05-05 13:20:56 +0300 | [diff] [blame] | 41 | const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts); |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 42 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 43 | /* Call the host environment interface to provide a user hook opportunity. */ |
Stefan Reinauer | dd132a5 | 2015-07-30 11:16:37 -0700 | [diff] [blame^] | 44 | static AGESA_STATUS board_BeforeDramInit (UINT32 Func, UINTN Data, VOID *ConfigPtr) |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 45 | { |
| 46 | AGESA_STATUS Status; |
| 47 | UINTN FcnData; |
| 48 | MEM_DATA_STRUCT *MemData; |
| 49 | UINT32 AcpiMmioAddr; |
| 50 | UINT32 GpioMmioAddr; |
| 51 | UINT8 Data8; |
| 52 | UINT16 Data16; |
| 53 | UINT8 TempData8; |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 54 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 55 | FcnData = Data; |
| 56 | MemData = ConfigPtr; |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 57 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 58 | Status = AGESA_SUCCESS; |
| 59 | /* Get SB800 MMIO Base (AcpiMmioAddr) */ |
| 60 | WriteIo8 (0xCD6, 0x27); |
| 61 | Data8 = ReadIo8(0xCD7); |
| 62 | Data16 = Data8<<8; |
| 63 | WriteIo8 (0xCD6, 0x26); |
| 64 | Data8 = ReadIo8(0xCD7); |
| 65 | Data16 |= Data8; |
| 66 | AcpiMmioAddr = (UINT32)Data16 << 16; |
| 67 | GpioMmioAddr = AcpiMmioAddr + GPIO_BASE; |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 68 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 69 | Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG178); |
| 70 | Data8 &= ~BIT5; |
| 71 | TempData8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG178); |
| 72 | TempData8 &= 0x03; |
| 73 | TempData8 |= Data8; |
| 74 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, TempData8); |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 75 | |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 76 | Data8 |= BIT2+BIT3; |
| 77 | Data8 &= ~BIT4; |
| 78 | TempData8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG178); |
| 79 | TempData8 &= 0x23; |
| 80 | TempData8 |= Data8; |
| 81 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, TempData8); |
| 82 | Data8 = Read64Mem8(GpioMmioAddr+SB_GPIO_REG179); |
| 83 | Data8 &= ~BIT5; |
| 84 | TempData8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG179); |
| 85 | TempData8 &= 0x03; |
| 86 | TempData8 |= Data8; |
| 87 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, TempData8); |
| 88 | Data8 |= BIT2+BIT3; |
| 89 | Data8 &= ~BIT4; |
| 90 | TempData8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG179); |
| 91 | TempData8 &= 0x23; |
| 92 | TempData8 |= Data8; |
| 93 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, TempData8); |
Stefan Reinauer | 5ff7c13 | 2011-10-31 12:56:45 -0700 | [diff] [blame] | 94 | |
Felix Held | c186966 | 2014-07-19 00:21:43 +0200 | [diff] [blame] | 95 | /* this seems to be just copy-pasted from the AMD reference boards and needs |
| 96 | * some investigation |
| 97 | */ |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 98 | switch(MemData->ParameterListPtr->DDR3Voltage){ |
| 99 | case VOLT1_35: |
| 100 | Data8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG178); |
| 101 | Data8 &= ~(UINT8)BIT6; |
| 102 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, Data8); |
| 103 | Data8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG179); |
| 104 | Data8 |= (UINT8)BIT6; |
| 105 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, Data8); |
| 106 | break; |
| 107 | case VOLT1_25: |
| 108 | Data8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG178); |
| 109 | Data8 &= ~(UINT8)BIT6; |
| 110 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, Data8); |
| 111 | Data8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG179); |
| 112 | Data8 &= ~(UINT8)BIT6; |
| 113 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, Data8); |
| 114 | break; |
| 115 | case VOLT1_5: |
| 116 | default: |
| 117 | Data8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG178); |
| 118 | Data8 |= (UINT8)BIT6; |
| 119 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG178, Data8); |
| 120 | Data8 = Read64Mem8 (GpioMmioAddr+SB_GPIO_REG179); |
| 121 | Data8 &= ~(UINT8)BIT6; |
| 122 | Write64Mem8(GpioMmioAddr+SB_GPIO_REG179, Data8); |
| 123 | } |
Marshall Buschman | eab1db1 | 2011-06-10 21:16:41 -0500 | [diff] [blame] | 124 | // disable memory clear for boot time reduction |
| 125 | MemData->ParameterListPtr->EnableMemClr = FALSE; |
Scott Duplichan | a649a96 | 2011-02-24 05:00:33 +0000 | [diff] [blame] | 126 | return Status; |
| 127 | } |