blob: 15244b519cbacf0cfb8b2515affc495bea73086b [file] [log] [blame]
efdesign9895b66112011-07-20 13:23:04 -06001/*
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
Paul Menzela46a7122013-02-23 18:37:27 +010017 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
efdesign9895b66112011-07-20 13:23:04 -060018 */
19
Kyösti Mälkki526c2fb2014-07-10 22:16:58 +030020#include "AGESA.h"
efdesign9895b66112011-07-20 13:23:04 -060021#include "amdlib.h"
Kyösti Mälkki26f297e2014-05-26 11:27:54 +030022#include <northbridge/amd/agesa/BiosCallOuts.h>
efdesign9895b66112011-07-20 13:23:04 -060023#include "Ids.h"
24#include "OptionsIds.h"
25#include "heapManager.h"
Kimarie Hooteef45f92013-03-08 13:54:10 -070026#include <arch/io.h>
Kimarie Hooteef45f92013-03-08 13:54:10 -070027
28#ifdef __PRE_RAM__
29/* These defines are used to select the appropriate socket for the SPD read
30 * because this is a multi-socket design.
31 */
32#define PCI_REG_GPIO_56_to_53_CNTRL (0x52)
33#define GPIO_OUT_BIT_GPIO53 (BIT0)
34#define GPIO_OUT_BIT_GPIO54 (BIT1)
35#define GPIO_OUT_ENABLE_BIT_GPIO53 (BIT4)
36#define GPIO_OUT_ENABLE_BIT_GPIO54 (BIT5)
37
38#define GPIO_OUT_BIT_GPIO54_to_53_MASK \
39 (GPIO_OUT_BIT_GPIO54 | GPIO_OUT_BIT_GPIO53)
40#define GPIO_OUT_ENABLE_BIT_GPIO54_to_53_MASK \
41 (GPIO_OUT_ENABLE_BIT_GPIO54 | GPIO_OUT_ENABLE_BIT_GPIO53)
42
43static UINT8 select_socket(UINT8 socket_id)
44{
45 device_t sm_dev = PCI_DEV(0, 0x14, 0); //SMBus
46 UINT8 value = 0;
47 UINT8 gpio56_to_53 = 0;
48
49 /* Configure GPIO54,53 to select the desired socket
50 * GPIO54,53 control the HC4052 S1,S0
51 * S1 S0 true table
52 * 0 0 channel 1 (Socket1)
53 * 0 1 channel 2 (Socket2)
54 * 1 0 channel 3 (Socket3)
55 * 1 1 channel 4 (Socket4)
56 */
57 gpio56_to_53 = pci_read_config8(sm_dev, PCI_REG_GPIO_56_to_53_CNTRL);
58 value = gpio56_to_53 & (~GPIO_OUT_BIT_GPIO54_to_53_MASK);
59 value |= socket_id;
60 value &= (~GPIO_OUT_ENABLE_BIT_GPIO54_to_53_MASK); // 0=Output Enabled, 1=Tristate
61 pci_write_config8(sm_dev, PCI_REG_GPIO_56_to_53_CNTRL, value);
62
63 return gpio56_to_53;
64}
65
66static void restore_socket(UINT8 original_value)
67{
68 device_t sm_dev = PCI_DEV(0, 0x14, 0); //SMBus
69 pci_write_config8(sm_dev, PCI_REG_GPIO_56_to_53_CNTRL, original_value);
70}
71#endif
efdesign9895b66112011-07-20 13:23:04 -060072
Kyösti Mälkkic0096012014-05-05 18:56:33 +030073static AGESA_STATUS board_ReadSpd (UINT32 Func,UINT32 Data,VOID *ConfigPtr);
74
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030075#include <stdlib.h>
76const BIOS_CALLOUT_STRUCT BiosCallouts[] =
efdesign9895b66112011-07-20 13:23:04 -060077{
Kyösti Mälkkief9343c2014-05-04 11:42:55 +030078 {AGESA_ALLOCATE_BUFFER, agesa_AllocateBuffer },
79 {AGESA_DEALLOCATE_BUFFER, agesa_DeallocateBuffer },
80 {AGESA_LOCATE_BUFFER, agesa_LocateBuffer },
Kyösti Mälkki5e19fa42014-05-04 23:13:54 +030081 {AGESA_DO_RESET, agesa_Reset },
Kyösti Mälkkic0096012014-05-05 18:56:33 +030082 {AGESA_READ_SPD, board_ReadSpd },
Kyösti Mälkkic459f962014-05-04 17:07:45 +030083 {AGESA_READ_SPD_RECOVERY, agesa_NoopUnsupported },
Kyösti Mälkki6b4b1512014-05-05 12:05:53 +030084 {AGESA_RUNFUNC_ONAP, agesa_RunFuncOnAp },
Kyösti Mälkkic459f962014-05-04 17:07:45 +030085 {AGESA_GET_IDS_INIT_DATA, agesa_EmptyIdsInitData },
86 {AGESA_HOOKBEFORE_DQS_TRAINING, agesa_NoopSuccess },
87 {AGESA_HOOKBEFORE_DRAM_INIT, agesa_NoopSuccess },
88 {AGESA_HOOKBEFORE_EXIT_SELF_REF, agesa_NoopSuccess },
efdesign9895b66112011-07-20 13:23:04 -060089};
Kyösti Mälkki6025efa2014-05-05 13:20:56 +030090const int BiosCalloutsLen = ARRAY_SIZE(BiosCallouts);
efdesign9895b66112011-07-20 13:23:04 -060091
Kyösti Mälkkic0096012014-05-05 18:56:33 +030092static AGESA_STATUS board_ReadSpd (UINT32 Func, UINT32 Data, VOID *ConfigPtr)
efdesign9895b66112011-07-20 13:23:04 -060093{
94 AGESA_STATUS Status;
Kimarie Hooteef45f92013-03-08 13:54:10 -070095#ifdef __PRE_RAM__
96 UINT8 original_value = 0;
97
98 if (ConfigPtr == NULL)
99 return AGESA_ERROR;
100
101 original_value = select_socket(((AGESA_READ_SPD_PARAMS *)ConfigPtr)->SocketId);
102
Kyösti Mälkkia1ebbc42014-10-17 22:33:22 +0300103 Status = agesa_ReadSpd (Func, Data, ConfigPtr);
Kimarie Hooteef45f92013-03-08 13:54:10 -0700104
105 restore_socket(original_value);
106#else
107 Status = AGESA_UNSUPPORTED;
108#endif
efdesign9895b66112011-07-20 13:23:04 -0600109
110 return Status;
111}