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-only */
2 
3 #include <baseboard/variants.h>
4 #include <baseboard/gpio.h>
5 #include <boardid.h>
6 #include <gpio.h>
7 #include <soc/cnl_memcfg_init.h>
8 #include <string.h>
9 #include <variant/gpio.h>
10 
11 static const struct cnl_mb_cfg baseboard_memcfg = {
12  /*
13  * The dqs_map arrays map the SoC pins to the lpddr3 pins
14  * for both channels.
15  *
16  * "The index of the array is CPU byte number, the values are DRAM byte
17  * numbers." - doc #573387
18  *
19  * the index = pin number on SoC
20  * the value = pin number on lpddr3 part
21  */
22  .dqs_map[DDR_CH0] = {4, 7, 5, 6, 0, 3, 2, 1},
23  .dqs_map[DDR_CH1] = {0, 3, 2, 1, 4, 7, 6, 5},
24 
25  .dq_map[DDR_CH0] = {
26  {0xf0, 0xf},
27  {0x0, 0xf},
28  {0xf0, 0xf},
29  {0xf0, 0x0},
30  {0xff, 0x0},
31  {0xff, 0x0}
32  },
33  .dq_map[DDR_CH1] = {
34  {0xf, 0xf0},
35  {0x0, 0xf0},
36  {0xf, 0xf0},
37  {0xf, 0x0},
38  {0xff, 0x0},
39  {0xff, 0x0}
40  },
41 
42  /* Helios uses 200, 80.6 and 162 rcomp resistors */
43  .rcomp_resistor = {200, 81, 162},
44 
45  /* Helios Rcomp target values */
46  .rcomp_targets = {100, 40, 40, 23, 40},
47 
48  /* Set CaVref config to 0 for LPDDR3 */
49  .vref_ca_config = 0,
50 
51  /* Disable Early Command Training */
52  .ect = 0,
53 };
54 
56 {
57  memcpy(bcfg, &baseboard_memcfg, sizeof(baseboard_memcfg));
58 }
59 
61 {
62  const gpio_t spd_gpios[] = {
67  };
68 
69  int val = gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios));
70 
71  if ((board_id() != 0) && (board_id() != BOARD_ID_UNKNOWN))
72  return val;
73 
74  /*
75  * For boards with id 0 or unknown, memory straps 3 and 4 are
76  * incorrectly stuffed in hardware. This is a workaround for these
77  * boards to override memory strap 3 to 0 and 4 to 1.
78  */
79  switch (val) {
80  case 3:
81  val = 0;
82  break;
83  case 4:
84  val = 1;
85  break;
86  }
87 
88  return val;
89 }
void * memcpy(void *dest, const void *src, size_t n)
Definition: memcpy.c:7
#define BOARD_ID_UNKNOWN
Definition: boardid.h:10
#define ARRAY_SIZE(a)
Definition: helpers.h:12
@ DDR_CH0
@ DDR_CH1
uint32_t board_id(void)
board_id() - Get the board version
Definition: ec_boardid.c:6
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
int __weak variant_memory_sku(void)
Definition: memory.c:74
#define GPIO_MEM_CONFIG_3
Definition: gpio.h:27
#define GPIO_MEM_CONFIG_0
Definition: gpio.h:24
#define GPIO_MEM_CONFIG_2
Definition: gpio.h:26
#define GPIO_MEM_CONFIG_1
Definition: gpio.h:25
static const struct cnl_mb_cfg baseboard_memcfg
Definition: memory.c:11
uint8_t dqs_map[DDR_NUM_CHANNELS][DQ_BITS_PER_DQS]
u8 val
Definition: sys.c:300