summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2020-11-19 21:50:33 +0100
committerFelix Held <felix-coreboot@felixheld.de>2020-12-23 16:01:53 +0000
commit075d123f6a57e4ef0f542f2f1f0b162b11cffe5a (patch)
treea3ca8cded1ec446486c86e43cff3740d20a0f05c /src
parent81ff33cffc103c184e002ccefe939efe2958a421 (diff)
nb/intel/sandybridge: Compute data timings independently
Use absolute values for the Rx and Tx bus timings instead of values relative to the CA (Command/Address) bus timing. This makes the calculations more accurate, less complex and less error-prone. Tested on Asus P8H61-M PRO, still boots. Training results do not seem to be affected by this patch, and the margins roughly have the same shape. Change-Id: I28ff1bdaadf1fcbca6a5e5ccdd456de683206410 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/47771 Reviewed-by: Felix Held <felix-coreboot@felixheld.de> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src')
-rw-r--r--src/northbridge/intel/sandybridge/raminit_common.c64
1 files changed, 11 insertions, 53 deletions
diff --git a/src/northbridge/intel/sandybridge/raminit_common.c b/src/northbridge/intel/sandybridge/raminit_common.c
index 7252574ad6..8418ccd97f 100644
--- a/src/northbridge/intel/sandybridge/raminit_common.c
+++ b/src/northbridge/intel/sandybridge/raminit_common.c
@@ -1023,71 +1023,29 @@ void program_timings(ramctr_timing *ctrl, int channel)
reg_roundtrip_latency = 0;
FOR_ALL_POPULATED_RANKS {
- int post_timA_min_high = 7, pre_timA_min_high = 7;
- int post_timA_max_high = 0, pre_timA_max_high = 0;
- int shift_402x = 0;
- int shift = ctrl->timings[channel][slotrank].pi_coding + cmd_delay;
-
- if (shift < 0)
- shift = 0;
-
- FOR_ALL_LANES {
- post_timA_min_high = MIN(post_timA_min_high,
- (ctrl->timings[channel][slotrank].lanes[lane].
- timA + shift) >> 6);
- pre_timA_min_high = MIN(pre_timA_min_high,
- ctrl->timings[channel][slotrank].lanes[lane].
- timA >> 6);
- post_timA_max_high = MAX(post_timA_max_high,
- (ctrl->timings[channel][slotrank].lanes[lane].
- timA + shift) >> 6);
- pre_timA_max_high = MAX(pre_timA_max_high,
- ctrl->timings[channel][slotrank].lanes[lane].
- timA >> 6);
- }
-
- if (pre_timA_max_high - pre_timA_min_high <
- post_timA_max_high - post_timA_min_high)
- shift_402x = +1;
-
- else if (pre_timA_max_high - pre_timA_min_high >
- post_timA_max_high - post_timA_min_high)
- shift_402x = -1;
-
- reg_io_latency |=
- (ctrl->timings[channel][slotrank].io_latency + shift_402x -
- post_timA_min_high) << (4 * slotrank);
+ reg_io_latency |= ctrl->timings[channel][slotrank].io_latency << (4 * slotrank);
reg_roundtrip_latency |=
- (ctrl->timings[channel][slotrank].roundtrip_latency +
- shift_402x) << (8 * slotrank);
+ ctrl->timings[channel][slotrank].roundtrip_latency << (8 * slotrank);
FOR_ALL_LANES {
MCHBAR32(lane_base[lane] + GDCRRX(channel, slotrank)) =
- (((ctrl->timings[channel][slotrank].lanes[lane].
- timA + shift) & 0x3f)
+ ((ctrl->timings[channel][slotrank].lanes[lane].timA & 0x3f)
+ |
+ (ctrl->timings[channel][slotrank].lanes[lane].rising << 8)
|
- ((ctrl->timings[channel][slotrank].lanes[lane].
- rising + shift) << 8)
+ ((ctrl->timings[channel][slotrank].lanes[lane].timA & 0x1c0) << 10)
|
- (((ctrl->timings[channel][slotrank].lanes[lane].
- timA + shift -
- (post_timA_min_high << 6)) & 0x1c0) << 10)
- | ((ctrl->timings[channel][slotrank].lanes[lane].
- falling + shift) << 20));
+ (ctrl->timings[channel][slotrank].lanes[lane].falling << 20));
MCHBAR32(lane_base[lane] + GDCRTX(channel, slotrank)) =
- (((ctrl->timings[channel][slotrank].lanes[lane].
- timC + shift) & 0x3f)
+ ((ctrl->timings[channel][slotrank].lanes[lane].timC & 0x3f)
|
- (((ctrl->timings[channel][slotrank].lanes[lane].
- timB + shift) & 0x3f) << 8)
+ ((ctrl->timings[channel][slotrank].lanes[lane].timB & 0x3f) << 8)
|
- (((ctrl->timings[channel][slotrank].lanes[lane].
- timB + shift) & 0x1c0) << 9)
+ ((ctrl->timings[channel][slotrank].lanes[lane].timB & 0x1c0) << 9)
|
- (((ctrl->timings[channel][slotrank].lanes[lane].
- timC + shift) & 0x40) << 13));
+ ((ctrl->timings[channel][slotrank].lanes[lane].timC & 0x40) << 13));
}
}
MCHBAR32(SC_ROUNDT_LAT_ch(channel)) = reg_roundtrip_latency;