blob: 5715f180131ca15a758115afa9a10f76bc091201 [file] [log] [blame]
Angel Ponsb5a2a522020-04-05 13:21:48 +02001/* SPDX-License-Identifier: GPL-2.0-only */
2/* This file is part of the coreboot project. */
Marc Jones2d79f162017-05-22 21:35:16 -06003
Marshall Dawson3f6c4002017-09-25 10:11:50 -06004#include <chip.h>
Richard Spiegel0ad74ac2017-12-08 16:53:29 -07005#include <amdblocks/agesawrapper.h>
chris wang76118a72018-10-18 18:52:58 +08006#include <boardid.h>
Chris Wang50c11602018-11-05 12:09:24 +08007#include <gpio.h>
8#include <console/console.h>
9#include <soc/pci_devs.h>
Marc Jones2d79f162017-05-22 21:35:16 -060010
Marshall Dawson3f6c4002017-09-25 10:11:50 -060011#define DIMMS_PER_CHANNEL 1
12#if DIMMS_PER_CHANNEL > MAX_DIMMS_PER_CH
13#error "Too many DIMM sockets defined for the mainboard"
14#endif
15
Marc Jones2d79f162017-05-22 21:35:16 -060016static const PSO_ENTRY DDR4PlatformMemoryConfiguration[] = {
17 DRAM_TECHNOLOGY(ANY_SOCKET, DDR4_TECHNOLOGY),
Marshall Dawson3f6c4002017-09-25 10:11:50 -060018 NUMBER_OF_DIMMS_SUPPORTED(ANY_SOCKET, ANY_CHANNEL, DIMMS_PER_CHANNEL),
19 NUMBER_OF_CHANNELS_SUPPORTED(ANY_SOCKET, MAX_DRAM_CH),
Marc Jones2d79f162017-05-22 21:35:16 -060020 MOTHER_BOARD_LAYERS(LAYERS_6),
21 MEMCLK_DIS_MAP(ANY_SOCKET, ANY_CHANNEL,
22 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00),
23 CKE_TRI_MAP(ANY_SOCKET, ANY_CHANNEL, 0xff, 0xff, 0xff, 0xff),
24 ODT_TRI_MAP(ANY_SOCKET, ANY_CHANNEL, 0xff, 0xff, 0xff, 0xff),
25 CS_TRI_MAP(ANY_SOCKET, ANY_CHANNEL,
26 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00),
27 PSO_END
28};
Martin Roth3f689112018-12-17 13:33:10 -070029/* Liara-specific 2T memory configuration */
Peichao Wang28086f02019-08-27 16:51:04 +080030static const PSO_ENTRY DDR4_2T_MemoryConfiguration[] = {
chris wang76118a72018-10-18 18:52:58 +080031 DRAM_TECHNOLOGY(ANY_SOCKET, DDR4_TECHNOLOGY),
32 NUMBER_OF_DIMMS_SUPPORTED(ANY_SOCKET, ANY_CHANNEL, DIMMS_PER_CHANNEL),
33 NUMBER_OF_CHANNELS_SUPPORTED(ANY_SOCKET, MAX_DRAM_CH),
34 MOTHER_BOARD_LAYERS(LAYERS_6),
35 MEMCLK_DIS_MAP(ANY_SOCKET, ANY_CHANNEL,
36 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00),
37 CKE_TRI_MAP(ANY_SOCKET, ANY_CHANNEL, 0xff, 0xff, 0xff, 0xff),
38 ODT_TRI_MAP(ANY_SOCKET, ANY_CHANNEL, 0xff, 0xff, 0xff, 0xff),
39 CS_TRI_MAP(ANY_SOCKET, ANY_CHANNEL,
40 0xff, 0xff, 0xff, 0xff, 0x00, 0x00, 0x00, 0x00),
41 TBLDRV_CONFIG_TO_OVERRIDE(DIMMS_PER_CHANNEL, ANY_SPEED, VOLT_ANY_,
42 ANY_),
43 TBLDRV_CONFIG_ENTRY_SLOWACCMODE(1),
44 PSO_END
45};
Marc Jones2d79f162017-05-22 21:35:16 -060046
47void OemPostParams(AMD_POST_PARAMS *PostParams)
48{
Peichao Wang28086f02019-08-27 16:51:04 +080049 if (CONFIG(BOARD_GOOGLE_LIARA) || CONFIG(BOARD_GOOGLE_TREEYA))
chris wang76118a72018-10-18 18:52:58 +080050 PostParams->MemConfig.PlatformMemoryConfiguration =
Peichao Wang28086f02019-08-27 16:51:04 +080051 (PSO_ENTRY *)DDR4_2T_MemoryConfiguration;
chris wang76118a72018-10-18 18:52:58 +080052 else
53 PostParams->MemConfig.PlatformMemoryConfiguration =
54 (PSO_ENTRY *)DDR4PlatformMemoryConfiguration;
Richard Spiegel9b3da9f2018-02-16 14:33:59 -070055 /*
56 * Bank interleaving is enabled by default in AGESA. However, from AMD's
57 * explanation, bank interleaving is really chip select interleave,
58 * requiring 2 chip select arriving to the DIMM (rank interleaving). As
59 * both kahlee and grunt are hardware limited to a single chip select
60 * arriving at the DIMM, interleave will not work. This causes AGESA to
61 * throw a warning. To avoid the warning, interleaving needs to be
62 * disabled.
63 */
64 PostParams->MemConfig.EnableBankIntlv = FALSE;
Marc Jones2d79f162017-05-22 21:35:16 -060065}
Richard Spiegel5d3707b2018-07-27 12:44:22 -070066
67void set_board_env_params(GNB_ENV_CONFIGURATION *params)
68{
Chris Wang50c11602018-11-05 12:09:24 +080069 const struct soc_amd_stoneyridge_config *cfg;
Kyösti Mälkkie7377552018-06-21 16:20:55 +030070 const struct device *dev = pcidev_path_on_root(GNB_DEVFN);
Chris Wang50c11602018-11-05 12:09:24 +080071 if (!dev || !dev->chip_info) {
72 printk(BIOS_WARNING, "Warning: Cannot find SoC devicetree config\n");
73 return;
74 }
75 cfg = dev->chip_info;
76 if (cfg->lvds_poseq_blon_to_varybl && cfg->lvds_poseq_varybl_to_blon) {
77 /*
78 * GPIO 133 - Backlight enable (active low)
79 * Pass control of the backlight to the video BIOS
80 */
81 gpio_set(GPIO_133, 0);
82 printk(BIOS_INFO, "Change panel init timing\n");
83 params->LvdsPowerOnSeqVaryBlToBlon =
84 cfg->lvds_poseq_varybl_to_blon;
85 params->LvdsPowerOnSeqBlonToVaryBl =
86 cfg->lvds_poseq_blon_to_varybl;
87 printk(BIOS_INFO, "LvdsPowerOnSeqVaryBlToBlon: %dms\n",
88 (params->LvdsPowerOnSeqVaryBlToBlon)*4);
89 printk(BIOS_INFO, "LvdsPowerOnSeqBlonToVaryBl: %dms\n",
90 (params->LvdsPowerOnSeqBlonToVaryBl)*4);
91 }
Richard Spiegel5d3707b2018-07-27 12:44:22 -070092 params->EDPv1_4VSMode = EDP_VS_HIGH_VDIFF_MODE;
93}