coreboot
coreboot is an Open Source project aimed at replacing the proprietary BIOS found in most computers.
raminit_shared.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-only */
2 
3 #include <console/console.h>
4 #include <device/mmio.h>
5 #include <types.h>
6 
7 #include "sandybridge.h"
8 
9 static const char *const ecc_decoder[] = {
10  "inactive",
11  "active on IO",
12  "disabled on IO",
13  "active",
14 };
15 
16 #define ON_OFF(val) (((val) & 1) ? "on" : "off")
17 
18 /* Print the memory controller configuration as read from the memory controller registers. */
20 {
21  u32 addr_decoder_common, addr_decode_ch[2];
22  int i;
23 
24  addr_decoder_common = mchbar_read32(MAD_CHNL);
25  addr_decode_ch[0] = mchbar_read32(MAD_DIMM_CH0);
26  addr_decode_ch[1] = mchbar_read32(MAD_DIMM_CH1);
27 
28  const int refclk = mchbar_read32(MC_BIOS_REQ) & 0x100 ? 100 : 133;
29 
30  printk(BIOS_DEBUG, "memcfg DDR3 ref clock %d MHz\n", refclk);
31  printk(BIOS_DEBUG, "memcfg DDR3 clock %d MHz\n",
32  (mchbar_read32(MC_BIOS_DATA) * refclk * 100 * 2 + 50) / 100);
33 
34  printk(BIOS_DEBUG, "memcfg channel assignment: A: %d, B % d, C % d\n",
35  (addr_decoder_common >> 0) & 3,
36  (addr_decoder_common >> 2) & 3,
37  (addr_decoder_common >> 4) & 3);
38 
39  for (i = 0; i < ARRAY_SIZE(addr_decode_ch); i++) {
40  u32 ch_conf = addr_decode_ch[i];
41  printk(BIOS_DEBUG, "memcfg channel[%d] config (%8.8x):\n", i, ch_conf);
42  printk(BIOS_DEBUG, " ECC %s\n", ecc_decoder[(ch_conf >> 24) & 3]);
43  printk(BIOS_DEBUG, " enhanced interleave mode %s\n", ON_OFF(ch_conf >> 22));
44  printk(BIOS_DEBUG, " rank interleave %s\n", ON_OFF(ch_conf >> 21));
45  printk(BIOS_DEBUG, " DIMMA %d MB width x%d %s rank%s\n",
46  ((ch_conf >> 0) & 0xff) * 256,
47  ((ch_conf >> 19) & 1) ? 16 : 8,
48  ((ch_conf >> 17) & 1) ? "dual" : "single",
49  ((ch_conf >> 16) & 1) ? "" : ", selected");
50  printk(BIOS_DEBUG, " DIMMB %d MB width x%d %s rank%s\n",
51  ((ch_conf >> 8) & 0xff) * 256,
52  ((ch_conf >> 20) & 1) ? 16 : 8,
53  ((ch_conf >> 18) & 1) ? "dual" : "single",
54  ((ch_conf >> 16) & 1) ? ", selected" : "");
55  }
56 }
57 #undef ON_OFF
#define ARRAY_SIZE(a)
Definition: helpers.h:12
#define printk(level,...)
Definition: stdlib.h:16
static __always_inline uint32_t mchbar_read32(const uintptr_t offset)
Definition: fixed_bars.h:21
#define MC_BIOS_DATA
Definition: mchbar.h:64
#define MAD_CHNL
Definition: mchbar.h:11
#define BIOS_DEBUG
BIOS_DEBUG - Verbose output.
Definition: loglevel.h:128
void report_memory_config(void)
static const char *const ecc_decoder[]
Definition: raminit_shared.c:9
#define ON_OFF(val)
#define MAD_DIMM_CH0
Definition: mchbar.h:468
#define MAD_DIMM_CH1
Definition: mchbar.h:469
#define MC_BIOS_REQ
Definition: mchbar.h:510
uint32_t u32
Definition: stdint.h:51