coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
memory.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later */
2 
3 #include <baseboard/gpio.h>
4 #include <baseboard/variants.h>
5 #include <gpio.h>
6 #include <soc/romstage.h>
7 
8 static const struct mb_cfg baseboard_memcfg = {
10 
11  .rcomp = {
12  /* Baseboard uses only 100ohm Rcomp resistors */
13  .resistor = 100,
14 
15  /* Baseboard Rcomp target values */
16  .targets = { 40, 36, 35, 35, 35 },
17  },
18 
19  /* DQ byte map */
20  .lpx_dq_map = {
21  .ddr0 = {
22  .dq0 = { 12, 9, 10, 11, 14, 13, 8, 15 },
23  .dq1 = { 3, 1, 2, 0, 4, 7, 5, 6 },
24  },
25  .ddr1 = {
26  .dq0 = { 3, 1, 2, 0, 4, 7, 5, 6 },
27  .dq1 = { 13, 9, 8, 11, 10, 14, 15, 12 },
28  },
29  .ddr2 = {
30  .dq0 = { 2, 1, 3, 0, 4, 6, 5, 7 },
31  .dq1 = { 8, 9, 10, 11, 13, 14, 12, 15 },
32  },
33  .ddr3 = {
34  .dq0 = { 3, 0, 1, 2, 5, 6, 4, 7 },
35  .dq1 = { 13, 9, 11, 8, 14, 15, 10, 12 },
36  },
37  .ddr4 = {
38  .dq0 = { 12, 9, 10, 11, 14, 13, 8, 15 },
39  .dq1 = { 3, 1, 2, 0, 4, 7, 5, 6 },
40  },
41  .ddr5 = {
42  .dq0 = { 3, 1, 2, 0, 4, 7, 5, 6 },
43  .dq1 = { 13, 9, 8, 11, 10, 14, 15, 12 },
44  },
45  .ddr6 = {
46  .dq0 = { 2, 1, 3, 0, 4, 6, 5, 7 },
47  .dq1 = { 8, 9, 10, 11, 13, 14, 12, 15 },
48  },
49  .ddr7 = {
50  .dq0 = { 3, 0, 1, 2, 5, 6, 4, 7 },
51  .dq1 = { 13, 9, 11, 8, 14, 15, 10, 12 },
52  },
53  },
54 
55  /* DQS CPU<>DRAM map */
56  .lpx_dqs_map = {
57  .ddr0 = { .dqs0 = 1, .dqs1 = 0 },
58  .ddr1 = { .dqs0 = 0, .dqs1 = 1 },
59  .ddr2 = { .dqs0 = 0, .dqs1 = 1 },
60  .ddr3 = { .dqs0 = 0, .dqs1 = 1 },
61  .ddr4 = { .dqs0 = 1, .dqs1 = 0 },
62  .ddr5 = { .dqs0 = 0, .dqs1 = 1 },
63  .ddr6 = { .dqs0 = 0, .dqs1 = 1 },
64  .ddr7 = { .dqs0 = 0, .dqs1 = 1 },
65  },
66 
67  .lp5x_config = {
68  .ccc_config = 0xff,
69  },
70 
71  .ect = 1, /* Early Command Training */
72 
73  .UserBd = BOARD_TYPE_MOBILE,
74 };
75 
76 const struct mb_cfg *__weak variant_memory_params(void)
77 {
78  return &baseboard_memcfg;
79 }
80 
82 {
83  /*
84  * Memory configuration board straps
85  * GPIO_MEM_CONFIG_0 GPP_E1
86  * GPIO_MEM_CONFIG_1 GPP_E2
87  * GPIO_MEM_CONFIG_2 GPP_E3
88  */
89  gpio_t spd_gpios[] = {
90  GPP_E1,
91  GPP_E2,
92  GPP_E3,
93  };
94 
95  return gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios));
96 }
97 
99 {
100  /*
101  * Ideally half_populated is used in platforms with multiple channels to
102  * enable only one half of the channel. Alder Lake N has single channel,
103  * and it would require for new structures to be defined in meminit block
104  * driver for LPx memory configurations. In order to avoid adding new
105  * structures, set half_populated to true. This has the same effect as
106  * having single channel with 64-bit width.
107  */
108  return true;
109 }
110 
112 {
114  spd_info->cbfs_index = variant_memory_sku();
115 }
#define GPP_E3
#define GPP_E2
#define GPP_E1
@ MEM_TYPE_LP5X
Definition: meminit.h:14
#define ARRAY_SIZE(a)
Definition: helpers.h:12
@ MEM_TOPO_MEMORY_DOWN
Definition: meminit.h:25
uint32_t gpio_base2_value(const gpio_t gpio[], int num_gpio)
Definition: gpio.c:30
const struct mb_cfg *__weak variant_memory_params(void)
Definition: memory.c:67
void variant_get_spd_info(struct mem_spd *spd_info)
Definition: memory.c:32
bool variant_is_half_populated(void)
Definition: memory.c:27
int __weak variant_memory_sku(void)
Definition: memory.c:74
static const struct mb_cfg baseboard_memcfg
Definition: memory.c:8
const struct smm_save_state_ops *legacy_ops __weak
Definition: save_state.c:8
@ BOARD_TYPE_MOBILE
Definition: romstage.h:14
Definition: meminit.h:71
enum mem_type type
Definition: meminit.h:72
Definition: spd.h:11