summaryrefslogtreecommitdiff
path: root/src/northbridge/intel/x4x
diff options
context:
space:
mode:
authorNico Huber <nico.h@gmx.de>2016-11-23 23:56:53 +0100
committerNico Huber <nico.h@gmx.de>2016-11-26 01:51:32 +0100
commit696abfcfd3fb58b985d24903c670a2c25bed2214 (patch)
tree453f842aba9a7149d5880345827bddbb3a52f183 /src/northbridge/intel/x4x
parentc7098a61b1b8caf1fc9426bbf7adce9e2631482f (diff)
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>
Diffstat (limited to 'src/northbridge/intel/x4x')
-rw-r--r--src/northbridge/intel/x4x/raminit.c112
-rw-r--r--src/northbridge/intel/x4x/x4x.h4
2 files changed, 16 insertions, 100 deletions
diff --git a/src/northbridge/intel/x4x/raminit.c b/src/northbridge/intel/x4x/raminit.c
index bc0af04c6f..0867c31e8e 100644
--- a/src/northbridge/intel/x4x/raminit.c
+++ b/src/northbridge/intel/x4x/raminit.c
@@ -140,108 +140,20 @@ static void sdram_read_spds(struct sysinfo *s)
}
FOR_EACH_POPULATED_CHANNEL(s->dimms, chan) {
- if (s->dimms[chan>>1].sides == 0) {
- // NC
- if (s->dimms[(chan>>1) + 1].sides == 0) {
- // NC/NC
- s->dimm_config[chan] = 0;
- } else if (s->dimms[(chan>>1) + 1].sides == 1) {
- // NC/SS
- if (s->dimms[(chan>>1) + 1].width == 0) {
- // NC/8SS
- s->dimm_config[chan] = 4;
- } else {
- // NC/16SS
- s->dimm_config[chan] = 12;
- }
+ FOR_EACH_POPULATED_DIMM_IN_CHANNEL(s->dimms, chan, i) {
+ int dimm_config;
+ if (s->dimms[i].ranks == 1) {
+ if (s->dimms[i].width == 0) /* x8 */
+ dimm_config = 1;
+ else /* x16 */
+ dimm_config = 3;
} else {
- // NC/DS
- if (s->dimms[(chan>>1) + 1].width == 0) {
- // NC/8DS
- s->dimm_config[chan] = 8;
- } 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;
- }
+ if (s->dimms[i].width == 0) /* x8 */
+ dimm_config = 2;
+ else
+ die("Dual-rank x16 not supported\n");
}
+ s->dimm_config[chan] |= dimm_config << (i - chan) * 2;
}
printk(BIOS_DEBUG, " Config[CH%d] : %d\n", chan, s->dimm_config[chan]);
}
diff --git a/src/northbridge/intel/x4x/x4x.h b/src/northbridge/intel/x4x/x4x.h
index 3f5c9c72e0..b3493691cf 100644
--- a/src/northbridge/intel/x4x/x4x.h
+++ b/src/northbridge/intel/x4x/x4x.h
@@ -161,6 +161,10 @@
for (idx = 0; idx < TOTAL_DIMMS; ++idx)
#define FOR_EACH_POPULATED_DIMM(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_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))