nb/intel/x4x: Fix and deflate `dimm_config` in raminit

By shifting the `chan` right instead of left, values were always taken
from the DIMMs of the first channel. The diff-stat also looks like an
improvement.

Change-Id: I605eb4f9b04520c51eea9995a2d4a1f050f02ecc
Signed-off-by: Nico Huber <nico.h@gmx.de>
Reviewed-on: https://review.coreboot.org/17587
Tested-by: build bot (Jenkins)
Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-by: Damien Zammit <damien@zamaudio.com>
This commit is contained in:
Nico Huber 2016-11-23 23:56:53 +01:00
parent c7098a61b1
commit 696abfcfd3
2 changed files with 16 additions and 100 deletions

View File

@ -140,108 +140,20 @@ static void sdram_read_spds(struct sysinfo *s)
} }
FOR_EACH_POPULATED_CHANNEL(s->dimms, chan) { FOR_EACH_POPULATED_CHANNEL(s->dimms, chan) {
if (s->dimms[chan>>1].sides == 0) { FOR_EACH_POPULATED_DIMM_IN_CHANNEL(s->dimms, chan, i) {
// NC int dimm_config;
if (s->dimms[(chan>>1) + 1].sides == 0) { if (s->dimms[i].ranks == 1) {
// NC/NC if (s->dimms[i].width == 0) /* x8 */
s->dimm_config[chan] = 0; dimm_config = 1;
} else if (s->dimms[(chan>>1) + 1].sides == 1) { else /* x16 */
// NC/SS dimm_config = 3;
if (s->dimms[(chan>>1) + 1].width == 0) {
// NC/8SS
s->dimm_config[chan] = 4;
} else {
// NC/16SS
s->dimm_config[chan] = 12;
}
} else { } else {
// NC/DS if (s->dimms[i].width == 0) /* x8 */
if (s->dimms[(chan>>1) + 1].width == 0) { dimm_config = 2;
// NC/8DS else
s->dimm_config[chan] = 8; die("Dual-rank x16 not supported\n");
} else {
// NOT SUPPORTED
die("16DS Not supported\n");
}
}
} else if (s->dimms[chan>>1].sides == 1) {
// SS
if (s->dimms[(chan>>1) + 1].sides == 0) {
// SS/NC
if (s->dimms[chan>>1].width == 0) {
// 8SS/NC
s->dimm_config[chan] = 1;
} else {
// 16SS/NC
s->dimm_config[chan] = 3;
}
} else if (s->dimms[(chan>>1) + 1].sides == 1) {
// SS/SS
if (s->dimms[chan>>1].width == 0) {
if (s->dimms[(chan>>1) + 1].width == 0) {
// 8SS/8SS
s->dimm_config[chan] = 5;
} else {
// 8SS/16SS
s->dimm_config[chan] = 13;
}
} else {
if (s->dimms[(chan>>1) + 1].width == 0) {
// 16SS/8SS
s->dimm_config[chan] = 7;
} else {
// 16SS/16SS
s->dimm_config[chan] = 15;
}
}
} else {
// SS/DS
if (s->dimms[chan>>1].width == 0) {
if (s->dimms[(chan>>1) + 1].width == 0) {
// 8SS/8DS
s->dimm_config[chan] = 9;
} else {
die("16DS not supported\n");
}
} else {
if (s->dimms[(chan>>1) + 1].width == 0) {
// 16SS/8DS
s->dimm_config[chan] = 11;
} else {
die("16DS not supported\n");
}
}
}
} else {
// DS
if (s->dimms[(chan>>1) + 1].sides == 0) {
// DS/NC
if (s->dimms[chan>>1].width == 0) {
// 8DS/NC
s->dimm_config[chan] = 2;
} else {
die("16DS not supported\n");
}
} else if (s->dimms[(chan>>1) + 1].sides == 1) {
// DS/SS
if (s->dimms[chan>>1].width == 0) {
if (s->dimms[(chan>>1) + 1].width == 0) {
// 8DS/8SS
s->dimm_config[chan] = 6;
} else {
// 8DS/16SS
s->dimm_config[chan] = 14;
}
} else {
die("16DS not supported\n");
}
} else {
// DS/DS
if (s->dimms[chan>>1].width == 0 && s->dimms[(chan>>1)+1].width == 0) {
// 8DS/8DS
s->dimm_config[chan] = 10;
}
} }
s->dimm_config[chan] |= dimm_config << (i - chan) * 2;
} }
printk(BIOS_DEBUG, " Config[CH%d] : %d\n", chan, s->dimm_config[chan]); printk(BIOS_DEBUG, " Config[CH%d] : %d\n", chan, s->dimm_config[chan]);
} }

View File

@ -161,6 +161,10 @@
for (idx = 0; idx < TOTAL_DIMMS; ++idx) for (idx = 0; idx < TOTAL_DIMMS; ++idx)
#define FOR_EACH_POPULATED_DIMM(dimms, idx) \ #define FOR_EACH_POPULATED_DIMM(dimms, idx) \
FOR_EACH_DIMM(idx) IF_DIMM_POPULATED(dimms, idx) FOR_EACH_DIMM(idx) IF_DIMM_POPULATED(dimms, idx)
#define FOR_EACH_DIMM_IN_CHANNEL(ch, idx) \
for (idx = (ch); idx < (ch) + 2; ++idx)
#define FOR_EACH_POPULATED_DIMM_IN_CHANNEL(dimms, ch, idx) \
FOR_EACH_DIMM_IN_CHANNEL(ch, idx) IF_DIMM_POPULATED(dimms, idx)
#define CHANNEL_IS_POPULATED(dimms, idx) ((dimms[idx<<1].card_type != RAW_CARD_UNPOPULATED) || (dimms[(idx<<1) + 1].card_type != RAW_CARD_UNPOPULATED)) #define CHANNEL_IS_POPULATED(dimms, idx) ((dimms[idx<<1].card_type != RAW_CARD_UNPOPULATED) || (dimms[(idx<<1) + 1].card_type != RAW_CARD_UNPOPULATED))
#define CHANNEL_IS_CARDF(dimms, idx) ((dimms[idx<<1].card_type == 0xf) || (dimms[(idx<<1) + 1].card_type == 0xf)) #define CHANNEL_IS_CARDF(dimms, idx) ((dimms[idx<<1].card_type == 0xf) || (dimms[(idx<<1) + 1].card_type == 0xf))
#define IF_CHANNEL_POPULATED(dimms, idx) if ((dimms[idx<<1].card_type != RAW_CARD_UNPOPULATED) || (dimms[(idx<<1) + 1].card_type != RAW_CARD_UNPOPULATED)) #define IF_CHANNEL_POPULATED(dimms, idx) if ((dimms[idx<<1].card_type != RAW_CARD_UNPOPULATED) || (dimms[(idx<<1) + 1].card_type != RAW_CARD_UNPOPULATED))