From patchwork Tue Jun 11 14:50:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 488 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 60E2D3F08F for ; Tue, 11 Jun 2019 16:54:21 +0200 (CEST) Received: by mail-pf1-f198.google.com with SMTP id l4sf9778450pff.5 for ; Tue, 11 Jun 2019 07:54:21 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1560264860; cv=pass; d=google.com; s=arc-20160816; b=TPoMRFVYw6wtDEfPxtkZJgDwKqUXEoycuunffXqrjuHFRu2BPlkz02VEOW0xH4Q16c dPi8hovSfo2tq+/SwSe/ZHxtnKdn8Hp1iSJPYepWiKdHczjOkk95sXRyGjXdLfUufGfQ cKTCSJo/jjTL4w3B4CiA7d8k7ZemTVJMcLLS6UYy2pxG372pu3qSn2pf1ow7tg0MO+1Q ng9XPNKrUh6RfTHpGXvnSb3xpNCJvGcUGIS9FRb36S9QuTXK+Mgc4/GHh7dOj50h9fWU RW4hss9A64eHBtezloJfSDi/4BLY/Tk6SqRUndtqgfKbrGjJjebsqNUMptmLraJVT6cc K12g== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-unsubscribe:list-archive:list-help:list-post:list-id :mailing-list:precedence:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=bQta51Ro7m7AqTLJNBkTKLv7Z1eTMyFZ5VXJV8i5gYo=; b=AunuDNUX/GVij/kSUqiSZPKHSsi8VTel3kEiJ2M5448axfbRpUOWYBrNixZqscvM4E l/P+aFNHGc7zlKGM2MEc4dcItEFes+/y5vsPkBBfcmB7uATjIV3y8A7g4JBm0z6UMdXJ E8/j2Iimx7wm8N8ZbaoPV7IQO23nqdVTedA2BeC8wyE0ICpQ3ti72sVKG9lWiEGhmS0c 8Lm6Nb8G7KNna5avWu6yhbvz+5gYcpqoT9W0NA0RqXuKFubjAPDm4Opf9jCbTsJmK6EP XBZ0DAZEopabraSZW+wZoAjM/RR0ZVUN6zEMefc6DP+5V3FdhBNiAYIiOal0E28CUZQT 2Upg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=AQhq3ai+; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amarulasolutions.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:x-original-sender:x-original-authentication-results :precedence:mailing-list:list-id:list-post:list-help:list-archive :list-unsubscribe; bh=bQta51Ro7m7AqTLJNBkTKLv7Z1eTMyFZ5VXJV8i5gYo=; b=bRSVBOSb5EBpg+8cbTrs95UCJ7OnvaTuyksxalQjI/B9Tj8YAVpM9LkX2ofnC65unz kW/yFs6fnJesMEUfJi40E+EbR25SUoVYXjohlHhjpDgBqCe+crBisaS9NqTeLYOIisGa R76M0ZrOfDwPizuO0MK8csy3DyE0ALwzSH2pM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-spam-checked-in-group:list-post:list-help:list-archive :list-unsubscribe; bh=bQta51Ro7m7AqTLJNBkTKLv7Z1eTMyFZ5VXJV8i5gYo=; b=ZMMkrUCjI7STqBzXigVgNxVsfkH/3pp1EmaqrVQ/bujOAhQ2IWjsjfQYlkrP/O+zuT R49nONUiPgypZUTRB1fM/2koqQyoPX6yLfpB63qbwKDbj3WXwJFFYnTKmcheLA75tCQZ tLoqqyVg/2SYV+T9pFX6qjS5mAjEXntMfFQY9nz2sMF1mKpeGRPOBMDdDgr9nJr/dfRf fvvjuNvJ/ds3nceuOccXAFrH4B94p+hfv0lGz2ZIX100U2KkGwdzHjeOf3AoQ8e+bOEU X8Q3XV3D080ImqYRL6XWxB/OJM5MUEbctMgz8ns2K3qRtOa+34KEcIHZ1+UcF+3BV++S 9wYg== X-Gm-Message-State: APjAAAW3ya+yyUKEvW61kOmxO6xM5GtZLVN0H1yBFOnMs+dk6Jgg1GNf iUCHEyyfS7Hfe8VXDfhAQpmHWPQ3 X-Google-Smtp-Source: APXvYqzprWwxuIiNVqlJEXckmwx4zGKbBJOWnI1OWWJfww1zW6BOvzYp0O19wkRuxnHF7wVE8ZBl/g== X-Received: by 2002:a17:90a:5d15:: with SMTP id s21mr27083581pji.125.1560264860100; Tue, 11 Jun 2019 07:54:20 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:42cd:: with SMTP id l13ls115581pgp.0.gmail; Tue, 11 Jun 2019 07:54:19 -0700 (PDT) X-Received: by 2002:a63:5443:: with SMTP id e3mr20415899pgm.265.1560264859646; Tue, 11 Jun 2019 07:54:19 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560264859; cv=none; d=google.com; s=arc-20160816; b=RugO0Uu0g/wLb8GWKNStx1R5j6s6Gg7Yv/8/lH3tOrlx9InGBT9390JhRJAzJC0CHs 3hHEQY6cR9ldUx8fo3Qkn11hbAGgtmgMRR4Q0BkZTafYDvYHmIbMIMKhtwjrrKSeGi7w obxQwYu12pgx9e0XbkAsxYPnxEY3CZdcTTTWRdgH699jw6uRdHEfWa6gmQj6fJCIaNcl xMUUbfMIEMCrhDjXpWHaBv8EySa2Xjse0ZgNPjBOfx373S7pI6YeBEHdmDVpUwcH+41b ixU1xGEfNS+h2GWC8z2x6N+35sKqjr45x0nr0MXKC8ZXbNsmyH+PFsk8yzuIn4Zm2eqh Z3Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=5Yf1E/nMMJ1uTpuqkdMMi/r9H01gEX8XKmpuGy2lGns=; b=j+lvWVoNuqKjr2mt5rUEQ2BUBi6yXndtcrjQzOmZdgMawmB5d3yb4+Vqvm9boNvLPE DdBUVjkvylDY3qZrAcOwJekq4tiOgWZGZXhM4soShJPM4odadtvKRP6DCyBjbB23WybI mxrVcK7lDdPQnCHprn27h/uxikA1zj6RwQw4HOKucZCpoCtJFai+EOQx0mt7T9DKaXUY TIgzzpjMaHvVyMM9HzdgTuHmyzvJrHwjX+jPLkRYHA4Uzg2EtYjFItKalRXtI1ZT3wCe blAUn/r29wncGBfnxEl+BjaRVYCere3Jfuxy87szCTg7vJCXPcWDwksiohkDo+bPgLuW bk3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=AQhq3ai+; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id h3sor15495898pld.22.2019.06.11.07.54.19 for (Google Transport Security); Tue, 11 Jun 2019 07:54:19 -0700 (PDT) Received-SPF: pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; X-Received: by 2002:a17:902:988a:: with SMTP id s10mr76931523plp.304.1560264859282; Tue, 11 Jun 2019 07:54:19 -0700 (PDT) Received: from localhost.localdomain ([115.97.180.18]) by smtp.gmail.com with ESMTPSA id e9sm16206208pfn.154.2019.06.11.07.54.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 07:54:18 -0700 (PDT) From: Jagan Teki To: Simon Glass , Philipp Tomsich , Kever Yang , YouMin Chen , u-boot@lists.denx.de Cc: gajjar04akash@gmail.com, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 37/92] ram: rockchip: rk3399: Add cap_info structure Date: Tue, 11 Jun 2019 20:20:40 +0530 Message-Id: <20190611145135.21399-38-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190611145135.21399-1-jagan@amarulasolutions.com> References: <20190611145135.21399-1-jagan@amarulasolutions.com> MIME-Version: 1.0 X-Original-Sender: jagan@amarulasolutions.com X-Original-Authentication-Results: mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=AQhq3ai+; spf=pass (google.com: domain of jagan@amarulasolutions.com designates 209.85.220.65 as permitted sender) smtp.mailfrom=jagan@amarulasolutions.com Content-Type: text/plain; charset="UTF-8" Precedence: list Mailing-list: list linux-amarula@amarulasolutions.com; contact linux-amarula+owners@amarulasolutions.com List-ID: X-Spam-Checked-In-Group: linux-amarula@amarulasolutions.com X-Google-Group-Id: 476853432473 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , Group common ddr attributes like - rank - col - bk - bw - dbw - row_3_4 - cs0_row - cs1_row - ddrconfig into a common cap_info structure for more code readability and extend if possible based on the new features. No functionality change. Signed-off-by: Jagan Teki --- .../include/asm/arch-rockchip/sdram_rk3399.h | 6 +- drivers/ram/rockchip/sdram_rk3399.c | 71 ++++++++++--------- 2 files changed, 41 insertions(+), 36 deletions(-) diff --git a/arch/arm/include/asm/arch-rockchip/sdram_rk3399.h b/arch/arm/include/asm/arch-rockchip/sdram_rk3399.h index a191d242f8..67044f53e5 100644 --- a/arch/arm/include/asm/arch-rockchip/sdram_rk3399.h +++ b/arch/arm/include/asm/arch-rockchip/sdram_rk3399.h @@ -96,7 +96,7 @@ struct rk3399_ddr_cic_regs { /* DENALI_CTL_274 */ #define MEM_RST_VALID 1 -struct rk3399_sdram_channel { +struct sdram_cap_info { unsigned int rank; /* dram column number, 0 means this channel is invalid */ unsigned int col; @@ -114,6 +114,10 @@ struct rk3399_sdram_channel { unsigned int cs0_row; unsigned int cs1_row; unsigned int ddrconfig; +}; + +struct rk3399_sdram_channel { + struct sdram_cap_info cap_info; struct rk3399_msch_timings noc_timings; }; diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 220197a42e..1acf9efe9c 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -156,35 +156,36 @@ static void set_memory_map(const struct chan_info *chan, u32 channel, u32 row; /* Get row number from ddrconfig setting */ - if (sdram_ch->ddrconfig < 2 || sdram_ch->ddrconfig == 4) + if (sdram_ch->cap_info.ddrconfig < 2 || + sdram_ch->cap_info.ddrconfig == 4) row = 16; - else if (sdram_ch->ddrconfig == 3) + else if (sdram_ch->cap_info.ddrconfig == 3) row = 14; else row = 15; - cs_map = (sdram_ch->rank > 1) ? 3 : 1; - reduc = (sdram_ch->bw == 2) ? 0 : 1; + cs_map = (sdram_ch->cap_info.rank > 1) ? 3 : 1; + reduc = (sdram_ch->cap_info.bw == 2) ? 0 : 1; /* Set the dram configuration to ctrl */ - clrsetbits_le32(&denali_ctl[191], 0xF, (12 - sdram_ch->col)); + clrsetbits_le32(&denali_ctl[191], 0xF, (12 - sdram_ch->cap_info.col)); clrsetbits_le32(&denali_ctl[190], (0x3 << 16) | (0x7 << 24), - ((3 - sdram_ch->bk) << 16) | + ((3 - sdram_ch->cap_info.bk) << 16) | ((16 - row) << 24)); clrsetbits_le32(&denali_ctl[196], 0x3 | (1 << 16), cs_map | (reduc << 16)); /* PI_199 PI_COL_DIFF:RW:0:4 */ - clrsetbits_le32(&denali_pi[199], 0xF, (12 - sdram_ch->col)); + clrsetbits_le32(&denali_pi[199], 0xF, (12 - sdram_ch->cap_info.col)); /* PI_155 PI_ROW_DIFF:RW:24:3 PI_BANK_DIFF:RW:16:2 */ clrsetbits_le32(&denali_pi[155], (0x3 << 16) | (0x7 << 24), - ((3 - sdram_ch->bk) << 16) | + ((3 - sdram_ch->cap_info.bk) << 16) | ((16 - row) << 24)); /* PI_41 PI_CS_MAP:RW:24:4 */ clrsetbits_le32(&denali_pi[41], 0xf << 24, cs_map << 24); - if (sdram_ch->rank == 1 && sdram_params->base.dramtype == DDR3) + if (sdram_ch->cap_info.rank == 1 && sdram_params->base.dramtype == DDR3) writel(0x2EC7FFFF, &denali_pi[34]); } @@ -686,7 +687,7 @@ static int data_training_ca(const struct chan_info *chan, u32 channel, u32 *denali_phy = chan->publ->denali_phy; u32 i, tmp; u32 obs_0, obs_1, obs_2, obs_err = 0; - u32 rank = sdram_params->ch[channel].rank; + u32 rank = sdram_params->ch[channel].cap_info.rank; u32 rank_mask; /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ @@ -749,7 +750,7 @@ static int data_training_wl(const struct chan_info *chan, u32 channel, u32 *denali_phy = chan->publ->denali_phy; u32 i, tmp; u32 obs_0, obs_1, obs_2, obs_3, obs_err = 0; - u32 rank = sdram_params->ch[channel].rank; + u32 rank = sdram_params->ch[channel].cap_info.rank; /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); @@ -811,7 +812,7 @@ static int data_training_rg(const struct chan_info *chan, u32 channel, u32 *denali_phy = chan->publ->denali_phy; u32 i, tmp; u32 obs_0, obs_1, obs_2, obs_3, obs_err = 0; - u32 rank = sdram_params->ch[channel].rank; + u32 rank = sdram_params->ch[channel].cap_info.rank; /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); @@ -873,7 +874,7 @@ static int data_training_rl(const struct chan_info *chan, u32 channel, { u32 *denali_pi = chan->pi->denali_pi; u32 i, tmp; - u32 rank = sdram_params->ch[channel].rank; + u32 rank = sdram_params->ch[channel].cap_info.rank; /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); @@ -921,7 +922,7 @@ static int data_training_wdql(const struct chan_info *chan, u32 channel, { u32 *denali_pi = chan->pi->denali_pi; u32 i, tmp; - u32 rank = sdram_params->ch[channel].rank; + u32 rank = sdram_params->ch[channel].cap_info.rank; u32 rank_mask; /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ @@ -1055,14 +1056,14 @@ static void set_ddrconfig(const struct chan_info *chan, unsigned int cs0_cap = 0; unsigned int cs1_cap = 0; - cs0_cap = (1 << (sdram_params->ch[channel].cs0_row - + sdram_params->ch[channel].col - + sdram_params->ch[channel].bk - + sdram_params->ch[channel].bw - 20)); - if (sdram_params->ch[channel].rank > 1) - cs1_cap = cs0_cap >> (sdram_params->ch[channel].cs0_row - - sdram_params->ch[channel].cs1_row); - if (sdram_params->ch[channel].row_3_4) { + cs0_cap = (1 << (sdram_params->ch[channel].cap_info.cs0_row + + sdram_params->ch[channel].cap_info.col + + sdram_params->ch[channel].cap_info.bk + + sdram_params->ch[channel].cap_info.bw - 20)); + if (sdram_params->ch[channel].cap_info.rank > 1) + cs1_cap = cs0_cap >> (sdram_params->ch[channel].cap_info.cs0_row + - sdram_params->ch[channel].cap_info.cs1_row); + if (sdram_params->ch[channel].cap_info.row_3_4) { cs0_cap = cs0_cap * 3 / 4; cs1_cap = cs1_cap * 3 / 4; } @@ -1089,22 +1090,22 @@ static void dram_all_config(struct dram_info *dram, struct rk3399_msch_regs *ddr_msch_regs; const struct rk3399_msch_timings *noc_timing; - if (sdram_params->ch[channel].col == 0) + if (sdram_params->ch[channel].cap_info.col == 0) continue; idx++; - sys_reg2 |= SYS_REG_ENC_ROW_3_4(info->row_3_4, channel); + sys_reg2 |= SYS_REG_ENC_ROW_3_4(info->cap_info.row_3_4, channel); sys_reg2 |= SYS_REG_ENC_CHINFO(channel); - sys_reg2 |= SYS_REG_ENC_RANK(info->rank, channel); - sys_reg2 |= SYS_REG_ENC_COL(info->col, channel); - sys_reg2 |= SYS_REG_ENC_BK(info->bk, channel); - sys_reg2 |= SYS_REG_ENC_BW(info->bw, channel); - sys_reg2 |= SYS_REG_ENC_DBW(info->dbw, channel); - SYS_REG_ENC_CS0_ROW(info->cs0_row, sys_reg2, sys_reg3, channel); - if (info->cs1_row) - SYS_REG_ENC_CS1_ROW(info->cs1_row, sys_reg2, + sys_reg2 |= SYS_REG_ENC_RANK(info->cap_info.rank, channel); + sys_reg2 |= SYS_REG_ENC_COL(info->cap_info.col, channel); + sys_reg2 |= SYS_REG_ENC_BK(info->cap_info.bk, channel); + sys_reg2 |= SYS_REG_ENC_BW(info->cap_info.bw, channel); + sys_reg2 |= SYS_REG_ENC_DBW(info->cap_info.dbw, channel); + SYS_REG_ENC_CS0_ROW(info->cap_info.cs0_row, sys_reg2, sys_reg3, channel); + if (info->cap_info.cs1_row) + SYS_REG_ENC_CS1_ROW(info->cap_info.cs1_row, sys_reg2, sys_reg3, channel); - sys_reg3 |= SYS_REG_ENC_CS1_COL(info->col, channel); + sys_reg3 |= SYS_REG_ENC_CS1_COL(info->cap_info.col, channel); sys_reg3 |= SYS_REG_ENC_VERSION(DDR_SYS_REG_VERSION); ddr_msch_regs = dram->chan[channel].msch; @@ -1121,7 +1122,7 @@ static void dram_all_config(struct dram_info *dram, &ddr_msch_regs->ddrmode); /* rank 1 memory clock disable (dfi_dram_clk_disable = 1) */ - if (sdram_params->ch[channel].rank == 1) + if (sdram_params->ch[channel].cap_info.rank == 1) setbits_le32(&dram->chan[channel].pctl->denali_ctl[276], 1 << 17); } @@ -1232,7 +1233,7 @@ static int sdram_init(struct dram_info *dram, } set_ddrconfig(chan, sdram_params, channel, - sdram_params->ch[channel].ddrconfig); + sdram_params->ch[channel].cap_info.ddrconfig); } dram_all_config(dram, sdram_params); switch_to_phy_index1(dram, sdram_params);