From 60971dcd01ba52685690fd6bf39e6fe2a8cbdb88 Mon Sep 17 00:00:00 2001 From: Angel Pons Date: Sat, 14 Nov 2020 00:49:38 +0100 Subject: 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/47607 Tested-by: build bot (Jenkins) Reviewed-by: Arthur Heymans --- src/northbridge/intel/sandybridge/raminit_common.c | 97 ++++++++++++---------- 1 file changed, 52 insertions(+), 45 deletions(-) (limited to 'src') 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); } -- cgit v1.2.3