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>
This commit is contained in:
Angel Pons 2020-11-14 00:49:38 +01:00
parent f305339d67
commit 60971dcd01
1 changed files with 59 additions and 52 deletions

View File

@ -2350,22 +2350,10 @@ static int discover_edges_real(ramctr_timing *ctrl, int channel, int slotrank, i
return 0; 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 slotrank, lane;
int rising_edges[NUM_CHANNELS][NUM_SLOTRANKS][NUM_LANES];
int channel, slotrank, lane;
int err;
MCHBAR32(GDCRTRAININGMOD) = 0;
toggle_io_reset();
FOR_ALL_POPULATED_CHANNELS FOR_ALL_LANES {
MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) = 0;
}
FOR_ALL_POPULATED_CHANNELS {
fill_pattern0(ctrl, channel, 0, 0); fill_pattern0(ctrl, channel, 0, 0);
FOR_ALL_LANES { FOR_ALL_LANES {
MCHBAR32(IOSAV_By_BW_SERROR_C_ch(channel, lane)); MCHBAR32(IOSAV_By_BW_SERROR_C_ch(channel, lane));
@ -2417,6 +2405,25 @@ int discover_edges(ramctr_timing *ctrl)
MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) = MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) =
~MCHBAR32(IOSAV_By_BW_SERROR_ch(channel, lane)) & 0xff; ~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;
MCHBAR32(GDCRTRAININGMOD) = 0;
toggle_io_reset();
FOR_ALL_POPULATED_CHANNELS {
FOR_ALL_LANES {
MCHBAR32(IOSAV_By_BW_MASK_ch(channel, lane)) = 0;
}
find_predefined_pattern(ctrl, channel);
fill_pattern0(ctrl, channel, 0, 0xffffffff); fill_pattern0(ctrl, channel, 0, 0xffffffff);
} }