soc/rockchip/rk3399/sdram: Use rank_mask in WDQL training

Add rank_mask based on the rank number and iterate based on that rather
than iterating all values.

Note: LPDDR4 uses a different rank mask.

Ported from u-boot.

Signed-off-by: Moritz Fischer <moritzf@google.com>
Change-Id: I1bff9d20d3d66984c49073aa21212708039d578f
Signed-off-by: Moritz Fischer <moritzf@google.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/50888
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Angel Pons <th3fanbus@gmail.com>
This commit is contained in:
Moritz Fischer 2021-02-17 21:42:41 -08:00 committed by ron minnich
parent 145ecc6761
commit d4f81bc21d
1 changed files with 5 additions and 2 deletions

View File

@ -864,13 +864,16 @@ static int data_training_rl(u32 channel, const struct rk3399_sdram_params *param
static int data_training_wdql(u32 channel, const struct rk3399_sdram_params *params) static int data_training_wdql(u32 channel, const struct rk3399_sdram_params *params)
{ {
u32 *denali_pi = rk3399_ddr_pi[channel]->denali_pi; u32 *denali_pi = rk3399_ddr_pi[channel]->denali_pi;
u32 rank = params->ch[channel].rank; const u32 rank_mask = get_rank_mask(channel, params);
u32 i, tmp; u32 i, tmp;
/* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */
write32(&denali_pi[175], 0x00003f7c); write32(&denali_pi[175], 0x00003f7c);
for (i = 0; i < rank; i++) { for (i = 0; i < MAX_RANKS_PER_CHANNEL; i++) {
if (!(rank_mask & (1 << i)))
continue;
select_per_cs_training_index(channel, i); select_per_cs_training_index(channel, i);
/* /*
* disable PI_WDQLVL_VREF_EN before wdq leveling? * disable PI_WDQLVL_VREF_EN before wdq leveling?