blob: 510038b3b73ae557f92682af47465b805cc2b8d2 [file] [log] [blame]
Michał Żygowskib9f9f6c2018-12-21 12:23:27 +01001/* SPDX-License-Identifier: GPL-2.0-or-later */
2/* This file is part of the coreboot project. */
3
4#include <soc/romstage.h>
5#include <spd_bin.h>
6#include <string.h>
7
8static void mainboard_fill_dq_map_data(void *dq_map_ch0, void *dq_map_ch1)
9{
10 const u8 dq_map[2][12] = {
11 { 0x0F, 0xF0, 0x00, 0xF0, 0x0F, 0xF0,
12 0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00 },
13 { 0x33, 0xCC, 0x00, 0xCC, 0x33, 0xCC,
14 0x33, 0x00, 0xFF, 0x00, 0xFF, 0x00 } };
15 memcpy(dq_map_ch0, dq_map[0], sizeof(dq_map[0]));
16 memcpy(dq_map_ch1, dq_map[1], sizeof(dq_map[1]));
17}
18
19static void mainboard_fill_dqs_map_data(void *dqs_map_ch0, void *dqs_map_ch1)
20{
21 const u8 dqs_map[2][8] = {
22 { 0, 1, 2, 3, 4, 5, 6, 7 },
23 { 1, 0, 2, 3, 4, 5, 6, 7 } };
24 memcpy(dqs_map_ch0, dqs_map[0], sizeof(dqs_map[0]));
25 memcpy(dqs_map_ch1, dqs_map[1], sizeof(dqs_map[1]));
26}
27
28static void mainboard_fill_rcomp_res_data(void *rcomp_ptr)
29{
30 const u16 RcompResistor[3] = { 121, 81, 100 };
31 memcpy(rcomp_ptr, RcompResistor, sizeof(RcompResistor));
32}
33
34static void mainboard_fill_rcomp_strength_data(void *rcomp_strength_ptr)
35{
36 const u16 RcompTarget[5] = { 100, 40, 20, 20, 26 };
37 memcpy(rcomp_strength_ptr, RcompTarget, sizeof(RcompTarget));
38}
39
40void mainboard_memory_init_params(FSPM_UPD *mupd)
41{
42 FSP_M_CONFIG *mem_cfg;
43 mem_cfg = &mupd->FspmConfig;
44
45 mainboard_fill_dq_map_data(&mem_cfg->DqByteMapCh0, &mem_cfg->DqByteMapCh1);
46 mainboard_fill_dqs_map_data(&mem_cfg->DqsMapCpu2DramCh0, &mem_cfg->DqsMapCpu2DramCh1);
47 mainboard_fill_rcomp_res_data(&mem_cfg->RcompResistor);
48 mainboard_fill_rcomp_strength_data(&mem_cfg->RcompTarget);
49
50 struct spd_block blk = {
51 .addr_map = { 0x50, 0x52, },
52 };
53
54 mem_cfg->DqPinsInterleaved = 1;
55 mem_cfg->CaVrefConfig = 2;
56
57 get_spd_smbus(&blk);
58 dump_spd_info(&blk);
59
60 mem_cfg->MemorySpdDataLen = blk.len;
61 mem_cfg->MemorySpdPtr00 = (uintptr_t)blk.spd_array[0];
62 mem_cfg->MemorySpdPtr10 = (uintptr_t)blk.spd_array[1];
63}