summaryrefslogtreecommitdiff
path: root/src/northbridge/intel
diff options
context:
space:
mode:
authorAngel Pons <th3fanbus@gmail.com>2020-11-14 00:49:38 +0100
committerAngel Pons <th3fanbus@gmail.com>2020-11-20 00:33:30 +0000
commit60971dcd01ba52685690fd6bf39e6fe2a8cbdb88 (patch)
tree3311dc274a112a2641570b34ab59f01ebd83377f /src/northbridge/intel
parentf305339d67426387a453f85372d13c4e94eed712 (diff)
nb/intel/sandybridge: Introduce `find_predefined_pattern` function
Also fuse two per-channel loops together. Tested on Asus P8H61-M PRO, still boots. Change-Id: Iacc66f4364290a66d60d483055abef6e98223d16 Signed-off-by: Angel Pons <th3fanbus@gmail.com> Reviewed-on: https://review.coreboot.org/c/coreboot/+/47607 Tested-by: build bot (Jenkins) <no-reply@coreboot.org> Reviewed-by: Arthur Heymans <arthur@aheymans.xyz>
Diffstat (limited to 'src/northbridge/intel')
-rw-r--r--src/northbridge/intel/sandybridge/raminit_common.c97
1 files changed, 52 insertions, 45 deletions
diff --git a/src/northbridge/intel/sandybridge/raminit_common.c b/src/northbridge/intel/sandybridge/raminit_common.c
index 95e7718bbf..0eb966d2fd 100644
--- a/src/northbridge/intel/sandybridge/raminit_common.c
+++ b/src/northbridge/intel/sandybridge/raminit_common.c
@@ -2350,74 +2350,81 @@ static int discover_edges_real(ramctr_timing *ctrl, int channel, int slotrank, i
return 0;
}
-int discover_edges(ramctr_timing *ctrl)
+static void find_predefined_pattern(ramctr_timing *ctrl, const int channel)
{
- int falling_edges[NUM_CHANNELS][NUM_SLOTRANKS][NUM_LANES];
- int rising_edges[NUM_CHANNELS][NUM_SLOTRANKS][NUM_LANES];
- int channel, slotrank, lane;
- int err;
+ int slotrank, lane;
- MCHBAR32(GDCRTRAININGMOD) = 0;
-
- toggle_io_reset();
+ fill_pattern0(ctrl, channel, 0, 0);
+ FOR_ALL_LANES {
+ MCHBAR32(IOSAV_By_BW_SERROR_C_ch(channel, lane));
+ }
- FOR_ALL_POPULATED_CHANNELS FOR_ALL_LANES {
- MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) = 0;
+ FOR_ALL_POPULATED_RANKS FOR_ALL_LANES {
+ ctrl->timings[channel][slotrank].lanes[lane].falling = 16;
+ ctrl->timings[channel][slotrank].lanes[lane].rising = 16;
}
- FOR_ALL_POPULATED_CHANNELS {
- fill_pattern0(ctrl, channel, 0, 0);
- FOR_ALL_LANES {
- MCHBAR32(IOSAV_By_BW_SERROR_C_ch(channel, lane));
- }
+ program_timings(ctrl, channel);
- FOR_ALL_POPULATED_RANKS FOR_ALL_LANES {
- ctrl->timings[channel][slotrank].lanes[lane].falling = 16;
- ctrl->timings[channel][slotrank].lanes[lane].rising = 16;
- }
+ FOR_ALL_POPULATED_RANKS {
+ wait_for_iosav(channel);
- program_timings(ctrl, channel);
+ iosav_write_read_mpr_sequence(
+ channel, slotrank, ctrl->tMOD, 3, 4, 1, ctrl->CAS + 8);
- FOR_ALL_POPULATED_RANKS {
- wait_for_iosav(channel);
+ /* Execute command queue */
+ iosav_run_once(channel);
- iosav_write_read_mpr_sequence(
- channel, slotrank, ctrl->tMOD, 3, 4, 1, ctrl->CAS + 8);
+ wait_for_iosav(channel);
+ }
- /* Execute command queue */
- iosav_run_once(channel);
+ /* XXX: check any measured value ? */
- wait_for_iosav(channel);
- }
+ FOR_ALL_POPULATED_RANKS FOR_ALL_LANES {
+ ctrl->timings[channel][slotrank].lanes[lane].falling = 48;
+ ctrl->timings[channel][slotrank].lanes[lane].rising = 48;
+ }
- /* XXX: check any measured value ? */
+ program_timings(ctrl, channel);
- FOR_ALL_POPULATED_RANKS FOR_ALL_LANES {
- ctrl->timings[channel][slotrank].lanes[lane].falling = 48;
- ctrl->timings[channel][slotrank].lanes[lane].rising = 48;
- }
+ FOR_ALL_POPULATED_RANKS {
+ wait_for_iosav(channel);
- program_timings(ctrl, channel);
+ iosav_write_read_mpr_sequence(
+ channel, slotrank, ctrl->tMOD, 3, 4, 1, ctrl->CAS + 8);
- FOR_ALL_POPULATED_RANKS {
- wait_for_iosav(channel);
+ /* Execute command queue */
+ iosav_run_once(channel);
- iosav_write_read_mpr_sequence(
- channel, slotrank, ctrl->tMOD, 3, 4, 1, ctrl->CAS + 8);
+ wait_for_iosav(channel);
+ }
- /* Execute command queue */
- iosav_run_once(channel);
+ /* XXX: check any measured value ? */
- wait_for_iosav(channel);
- }
+ FOR_ALL_LANES {
+ MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) =
+ ~MCHBAR32(IOSAV_By_BW_SERROR_ch(channel, lane)) & 0xff;
+ }
+}
+
+int discover_edges(ramctr_timing *ctrl)
+{
+ int falling_edges[NUM_CHANNELS][NUM_SLOTRANKS][NUM_LANES];
+ int rising_edges[NUM_CHANNELS][NUM_SLOTRANKS][NUM_LANES];
+ int channel, slotrank, lane;
+ int err;
- /* XXX: check any measured value ? */
+ MCHBAR32(GDCRTRAININGMOD) = 0;
+ toggle_io_reset();
+
+ FOR_ALL_POPULATED_CHANNELS {
FOR_ALL_LANES {
- MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) =
- ~MCHBAR32(IOSAV_By_BW_SERROR_ch(channel, lane)) & 0xff;
+ MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) = 0;
}
+ find_predefined_pattern(ctrl, channel);
+
fill_pattern0(ctrl, channel, 0, 0xffffffff);
}