Docs: Convert bare URLs into hyperlinks
[coreboot.git] / src / mainboard / intel / kunimitsu / spd / spd_util.c
blobe79759cced5647323a76a8b1261c06a062c18d69
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 #include <cbfs.h>
3 #include <console/console.h>
4 #include <device/dram/ddr3.h>
5 #include <spd.h>
6 #include <stdint.h>
7 #include <string.h>
9 #include "boardid.h"
10 #include "spd.h"
12 void mainboard_fill_dq_map_data(void *dq_map_ch0, void *dq_map_ch1)
14 /* DQ byte map */
15 const u8 dq_map[2][12] = {
16 { 0x0F, 0xF0, 0x00, 0xF0, 0x0F, 0xF0,
17 0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00 },
18 { 0x0F, 0xF0, 0x00, 0xF0, 0x0F, 0xF0,
19 0x0F, 0x00, 0xFF, 0x00, 0xFF, 0x00 } };
20 memcpy(dq_map_ch0, dq_map[0], sizeof(dq_map[0]));
21 memcpy(dq_map_ch1, dq_map[1], sizeof(dq_map[1]));
24 void mainboard_fill_dqs_map_data(void *dqs_map_ch0, void *dqs_map_ch1)
26 /* DQS CPU<>DRAM map */
27 const u8 dqs_map[2][8] = {
28 { 0, 1, 3, 2, 6, 5, 4, 7 },
29 { 2, 3, 0, 1, 6, 7, 4, 5 } };
30 memcpy(dqs_map_ch0, dqs_map[0], sizeof(dqs_map[0]));
31 memcpy(dqs_map_ch1, dqs_map[1], sizeof(dqs_map[1]));
34 void mainboard_fill_rcomp_res_data(void *rcomp_ptr)
36 /* Rcomp resistor */
37 const u16 RcompResistor[3] = { 200, 81, 162 };
38 memcpy(rcomp_ptr, RcompResistor,
39 sizeof(RcompResistor));
42 void mainboard_fill_rcomp_strength_data(void *rcomp_strength_ptr)
44 int mem_cfg_id;
46 mem_cfg_id = get_spd_index();
47 /* Rcomp target */
48 static const u16 RcompTarget[5] = {
49 100, 40, 40, 23, 40 };
51 /* Strengthen the Rcomp Target Ctrl for 8GB K4E6E304EE -EGCF */
52 static const u16 StrengthendRcompTarget[5] = {
53 100, 40, 40, 21, 40 };
55 if (mem_cfg_id == K4E6E304EE_MEM_ID) {
56 memcpy(rcomp_strength_ptr, StrengthendRcompTarget,
57 sizeof(StrengthendRcompTarget));
58 } else {
59 memcpy(rcomp_strength_ptr, RcompTarget, sizeof(RcompTarget));
63 uintptr_t mainboard_get_spd_data(void)
65 char *spd_file;
66 int spd_index, spd_span;
67 size_t spd_file_len;
69 spd_index = get_spd_index();
70 printk(BIOS_INFO, "SPD index %d\n", spd_index);
72 /* Load SPD data from CBFS */
73 spd_file = cbfs_map("spd.bin", &spd_file_len);
74 if (!spd_file)
75 die("SPD data not found.");
77 /* make sure we have at least one SPD in the file. */
78 if (spd_file_len < SPD_SIZE_MAX_DDR3)
79 die("Missing SPD data.");
81 /* Make sure we did not overrun the buffer */
82 if (spd_file_len < ((spd_index + 1) * SPD_SIZE_MAX_DDR3)) {
83 printk(BIOS_ERR, "SPD index override to 0 - old hardware?\n");
84 spd_index = 0;
87 spd_span = spd_index * SPD_SIZE_MAX_DDR3;
88 return (uintptr_t)(spd_file + spd_span);
91 int mainboard_has_dual_channel_mem(void)
93 int spd_index;
95 spd_index = get_spd_index();
97 if (spd_index != HYNIX_SINGLE_CHAN && spd_index != SAMSUNG_SINGLE_CHAN
98 && spd_index != MIC_SINGLE_CHAN) {
99 printk(BIOS_INFO,
100 "Dual channel SPD detected writing second channel\n");
101 return 1;
103 return 0;