coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
spd_util.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <gpio.h>
5 #include <soc/gpio.h>
7 
8 /*
9  * 0b0000 - 4GiB total - 2 x 2GiB Samsung K4E8E304EE-EGCF
10  * 0b0001 - 2GiB total - 1 x 2GiB Samsung K4E8E304EE-EGCF
11  * 0b0010 - 4GiB total - 2 x 2GiB Hynix H9CCNNN8GTMLAR-NUD
12  * 0b0011 - 2GiB total - 1 x 2GiB Hynix H9CCNNN8GTMLAR-NUD
13  * 0b0100 - 4GiB total - 2 x 2GiB Micron MT52L256M32D1PF-107
14  * 0b0101 - 2GiB total - 1 x 2GiB Micron MT52L256M32D1PF-107
15  * 0b0110 - 2GiB total - 1 x 2GiB Samsung K4E8E324EB-EGCF
16  * 0b0111 - 4GiB total - 2 x 2GiB Samsung K4E8E324EB-EGCF
17  * 0b1000 - 2GiB total - 1 x 2GiB Hynix H9CCNNN8GTALAR-NUD
18  * 0b1001 - 4GiB total - 2 x 4GiB Hynix H9CCNNN8GTALAR-NUD
19  */
20 
22  (1 << 0) | (1 << 2) | (1 << 4) | (1 << 7) | (1 << 9);
23 
25 {
26  gpio_t spd_gpios[] = {
27  GP_SW_64, /* I2C3_SDA, RAMID0 */
28  GP_SE_02, /* MF_PLT_CLK1, RAMID1 */
29  GP_SW_67, /* I2C3_SCL, RAMID2 */
30  GP_SW_80, /* SATA_GP3, RAMID3 */
31  };
32 
33  return gpio_base2_value(spd_gpios, ARRAY_SIZE(spd_gpios));
34 }
35 
36 int get_variant_spd_index(int ram_id, int *dual)
37 {
38  /* Determine if single or dual channel memory system */
39  *dual = (dual_channel_config & (1 << ram_id)) ? 1 : 0;
40 
41  /* Display the RAM type */
42  switch (ram_id) {
43  case 0:
44  printk(BIOS_DEBUG, "4GiB Samsung K4E8E304EE-EGCF\n");
45  break;
46  case 1:
47  printk(BIOS_DEBUG, "2GiB Samsung K4E8E304EE-EGCF\n");
48  break;
49  case 2:
50  printk(BIOS_DEBUG, "4GiB Hynix H9CCNNN8GTMLAR-NUD\n");
51  break;
52  case 3:
53  printk(BIOS_DEBUG, "2GiB Hynix H9CCNNN8GTMLAR-NUD\n");
54  break;
55  case 4:
56  printk(BIOS_DEBUG, "4GiB Micron MT52L256M32D1PF-107\n");
57  break;
58  case 5:
59  printk(BIOS_DEBUG, "2GiB Micron MT52L256M32D1PF-107\n");
60  break;
61  case 6:
62  printk(BIOS_DEBUG, "2GiB Samsung K4E8E324EB-EGCF\n");
63  break;
64  case 7:
65  printk(BIOS_DEBUG, "4GiB Samsung K4E8E324EB-EGCF\n");
66  break;
67  case 8:
68  printk(BIOS_DEBUG, "2GiB Hynix H9CCNNN8GTALAR-NUD\n");
69  break;
70  case 9:
71  printk(BIOS_DEBUG, "4GiB Hynix H9CCNNN8GTALAR-NUD\n");
72  break;
73  }
74 
75  /* 1:1 mapping between ram_id and spd_index for setzer */
76  return ram_id;
77 }
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
int get_variant_spd_index(int ram_id, int *dual)
Definition: spd_util.c:21
uint8_t get_ramid(void)
Definition: spd_util.c:19
static const uint32_t dual_channel_config
Definition: spd_util.c:21
uint32_t gpio_base2_value(const gpio_t gpio[], int num_gpio)
Definition: gpio.c:30
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
#define GP_SW_64
Definition: gpio_defs.h:43
#define GP_SE_02
Definition: gpio_defs.h:151
#define GP_SW_80
Definition: gpio_defs.h:52
#define GP_SW_67
Definition: gpio_defs.h:46
unsigned int uint32_t
Definition: stdint.h:14
unsigned char uint8_t
Definition: stdint.h:8