[v3,04/18] ram: rk3399: Use rank mask in wdql data training

Message ID 20190715182856.21688-5-jagan@amarulasolutions.com
State New
Headers show
Series
  • ram: rk3399: Add rank detection
Related show

Commit Message

Jagan Teki July 15, 2019, 6:28 p.m. UTC
Add rank_mask based on the rank number, this would keep
the wdql data training loop based on the desired rank mask
value instead of looping for all values.

Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
Signed-off-by: YouMin Chen <cym@rock-chips.com>
---
 drivers/ram/rockchip/sdram_rk3399.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

Comments

Kever Yang July 16, 2019, 7:38 a.m. UTC | #1
On 2019/7/16 上午2:28, Jagan Teki wrote:
> Add rank_mask based on the rank number, this would keep
> the wdql data training loop based on the desired rank mask
> value instead of looping for all values.
>
> Signed-off-by: Jagan Teki <jagan@amarulasolutions.com>
> Signed-off-by: YouMin Chen <cym@rock-chips.com>

Reviewed-by: Kever Yang <Kever.yang@rock-chips.com>

Thanks,
  - Kever
> ---
>   drivers/ram/rockchip/sdram_rk3399.c | 8 +++++++-
>   1 file changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c
> index b98df20fa5..16bd9427a6 100644
> --- a/drivers/ram/rockchip/sdram_rk3399.c
> +++ b/drivers/ram/rockchip/sdram_rk3399.c
> @@ -861,11 +861,17 @@ static int data_training_wdql(const struct chan_info *chan, u32 channel,
>   	u32 *denali_pi = chan->pi->denali_pi;
>   	u32 i, tmp;
>   	u32 rank = params->ch[channel].cap_info.rank;
> +	u32 rank_mask;
>   
>   	/* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */
>   	writel(0x00003f7c, (&denali_pi[175]));
>   
> -	for (i = 0; i < rank; i++) {
> +	rank_mask = (rank == 1) ? 0x1 : 0x3;
> +
> +	for (i = 0; i < 4; i++) {
> +		if (!(rank_mask & (1 << i)))
> +			continue;
> +
>   		select_per_cs_training_index(chan, i);
>   
>   		/*

Patch

diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c
index b98df20fa5..16bd9427a6 100644
--- a/drivers/ram/rockchip/sdram_rk3399.c
+++ b/drivers/ram/rockchip/sdram_rk3399.c
@@ -861,11 +861,17 @@  static int data_training_wdql(const struct chan_info *chan, u32 channel,
 	u32 *denali_pi = chan->pi->denali_pi;
 	u32 i, tmp;
 	u32 rank = params->ch[channel].cap_info.rank;
+	u32 rank_mask;
 
 	/* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */
 	writel(0x00003f7c, (&denali_pi[175]));
 
-	for (i = 0; i < rank; i++) {
+	rank_mask = (rank == 1) ? 0x1 : 0x3;
+
+	for (i = 0; i < 4; i++) {
+		if (!(rank_mask & (1 << i)))
+			continue;
+
 		select_per_cs_training_index(chan, i);
 
 		/*