From d4d3ba041454d435e5342e9621bd1c647db5f062 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Sat, 12 Dec 2020 17:45:14 +0100 Subject: nb/intel/sandybridge: Refactor ODT stretch table code Leverage existing `ch_dimms` value and use constants for brevity. Change-Id: I4e08166c8e9fbd15ff1dcd266abb0689e4b159f7 Signed-off-by: Angel Pons Reviewed-on: https://review.coreboot.org/c/coreboot/+/48613 Tested-by: build bot (Jenkins) Reviewed-by: Felix Held --- src/northbridge/intel/sandybridge/raminit.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/northbridge/intel/sandybridge/raminit.c b/src/northbridge/intel/sandybridge/raminit.c index 17772c661b..3077c0ae8f 100644 --- a/src/northbridge/intel/sandybridge/raminit.c +++ b/src/northbridge/intel/sandybridge/raminit.c @@ -233,10 +233,11 @@ static void dram_find_spds_ddr3(spd_raw_data *spd, ramctr_timing *ctrl) printk(BIOS_DEBUG, "channel[%d] rankmap = 0x%x\n", channel, ctrl->rankmap[channel]); } - if ((ctrl->rankmap[channel] & 0x03) && (ctrl->rankmap[channel] & 0x0c) - && ctrl->info.dimm[channel][0].reference_card <= 5 - && ctrl->info.dimm[channel][1].reference_card <= 5) { + const u8 rc_0 = ctrl->info.dimm[channel][0].reference_card; + const u8 rc_1 = ctrl->info.dimm[channel][1].reference_card; + + if (ch_dimms == NUM_SLOTS && rc_0 < 6 && rc_1 < 6) { const int ref_card_offset_table[6][6] = { { 0, 0, 0, 0, 2, 2 }, { 0, 0, 0, 0, 2, 2 }, @@ -245,9 +246,7 @@ static void dram_find_spds_ddr3(spd_raw_data *spd, ramctr_timing *ctrl) { 2, 2, 2, 1, 0, 0 }, { 2, 2, 2, 1, 0, 0 }, }; - ctrl->ref_card_offset[channel] = ref_card_offset_table - [ctrl->info.dimm[channel][0].reference_card] - [ctrl->info.dimm[channel][1].reference_card]; + ctrl->ref_card_offset[channel] = ref_card_offset_table[rc_0][rc_1]; } else { ctrl->ref_card_offset[channel] = 0; } -- cgit v1.2.3