From patchwork Mon Jun 17 07:31:17 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 575 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 6D56B3F072 for ; Mon, 17 Jun 2019 09:36:35 +0200 (CEST) Received: by mail-pl1-f197.google.com with SMTP id bb9sf5528523plb.2 for ; Mon, 17 Jun 2019 00:36:35 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1560756994; cv=pass; d=google.com; s=arc-20160816; b=inyVicdVLQuo0jWTAQqsA+kcCO+y6aj7qai/nLIAPs87en5iq0xQH7wXahu8/GCJPJ XLQyGQbIV+4JbhpMBtCD4gs5YxH6ssfHDIHdnCWChTFBtxnKfxezNIuzHEgjdkQy/atU 0bIU3/Er/3Nl5YzQFB00Gc64iy3Vke5lG8ixsC3Lc2+84nIWolE79LMA1Sk55TYp6oYg U0cZnE9zfGtx8fPS1AtTW9QzHKZ+URp909kokc68sKYFAxEbygF/XwzUsxrHw29pSqWN VGjrBnP9MnmacyxQxcCMY3Mf0kMZnFQxcOI2ScSEI1P0pXe91I4OGK2kK1xm7vbbYAFb RzGw== 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=kAqu2JhodarQQ0OSf58ARcUsQkVcZoAuz216c4YjY4E=; b=ny6eG6N1OEQUAl+oiwQxwceIXmv2crv0u2SKwKwnVraacSBITK/VVd+ZNZCZjbKYrG VKUxylUzxo7X7yvhpTwLajnv4sN6zjCCI/fuv0e/z2Zf86tIWg4FBhEtTFF3QeNc2xZ+ CYSZI7T9h0YKqECOfzkClV+7gXOfqiRABAe2NHpW0t1NiF0MJG3Y2Ih/z7aYBmWHB57k GY7ClQSf5mSz2cjYlMzWmR0rB3Q+SQ/JXPLgOpWEbmGhV1z5E16e3JsmxHOR7L9EVeMI e+GN/Bc8sA9yaksjAKUay2pxORkNtkIvgI3n0Y4wtnfh2Nxm52VZxNTDbzZ0v0WR4LnE MEJA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ObDhJrcE; 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=kAqu2JhodarQQ0OSf58ARcUsQkVcZoAuz216c4YjY4E=; b=H1f2raHxs9Fkzbqrt+A2z1Ai/g8h6hOyTZUmFqoA/rY627m8v3I6cmrK0kTAIn5U+O dPOqhidtRouDYvQx5hmLe94K6S4ymAQoIb2wbj+LzFWGrrV5/750owDC/alummXQFybd LbI8ukc1GCXAL4WUYF7WTA3EFeorVbrj61ldc= 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=kAqu2JhodarQQ0OSf58ARcUsQkVcZoAuz216c4YjY4E=; b=kLZb6mNs3ImoRU9PuvpDANYxbHi7RxHgamSoXrI7OMvOAYGSJWIYt05cM4BBhqZ3aF 13+RiXDbPJxcu3Wt6ctM60dLozqZ5j4UqKpnyBKjFh7AQcBAQFG8+tmIjXzKwBY56XgB +yObDQvfyoieoKZQKvicvE+3f3C9jrL9xWePg7AoDHWLZQ2OaAIFn8AaPkX61KjY59i5 KbTA5mhTlxg2PQr1WTYNtW9PCTD3EgbPiy+tRVwvZvsXSvOPjqWPOCgktWJK4RDltRkK GbxTzgKpqj/a/+gG+ouNgJhmGWDuI/fjBoUlhDrhlEFRBSZnY3Xs/aQ4nS5aS6bdijar j2Ig== X-Gm-Message-State: APjAAAVOeUxHQDtUIH5wXknJUaSxDlVzzhfrD5JOi/QvvwK0eAgRXGz0 Pl6e4Trg2I1HO9WDlNaHW5MvyuET X-Google-Smtp-Source: APXvYqwIPr6ORQe2MY2UB9xnQNoZkICwBsa8UOeiwWowHLnMFqUAKfcYcxELSEEvMqn/oaPOK4MsMw== X-Received: by 2002:a63:e70c:: with SMTP id b12mr39566286pgi.242.1560756994123; Mon, 17 Jun 2019 00:36:34 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:de12:: with SMTP id m18ls2920982pjv.4.canary-gmail; Mon, 17 Jun 2019 00:36:33 -0700 (PDT) X-Received: by 2002:a17:902:9a91:: with SMTP id w17mr10177534plp.126.1560756993734; Mon, 17 Jun 2019 00:36:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560756993; cv=none; d=google.com; s=arc-20160816; b=iSCTBse5nBiNOIF9U+tfpX7oLP26BGidJhcyyBDk7dQ0w3engdZLmMoF6k74l4M8oY o9YoB8+ifXxdfWEtAwFejLkazVyhXRuKUStO2wTreycHK6q+sFp3H8bXDmMyRSe5t/LD pIlvRmB1ZnuVRd7xXmoWtdKqjxJKv8H8sYedesSOBAS+k7bo/GEhOw0Y6zrv8LppswTa sidw4xWiNfGxfruuCtjs88E54t8mMTeSTzGYe6UQPwmC/GQvmz+X2vGpkIpHzp7hlHbI yPRqtEWBATZXFn93C+qsZGV9kx1Tkl2q9ZSNvdB5GaTi4GP0WM7f9Sl3SStgVrmOZv48 QTsw== 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=o1firlkSDCDrRUP1sag0BeW+fuut4BTojrnELghdmxY=; b=aqjMcUku3+ZTuDi4xoinczbAijyZJ9O9b7tBNzPo0ZH1khDvHHfSWPxy6TIryFrEGV fz/YlFA8zUa45KDQZYx9ZlLbF9Da582klfHnQNv9vlz8FrdYnA6X56igsAb3Z+KEHMwu 1tG2twfnGIjPP3mYUFIZWW75rTsSgwwULAcqvadC5vc7V9KCtLwKbxCPMr8K2WdJSEeX oT6dIgE+FL20MQuJIzFTZb39h2fy2utXRGFsbt9XDfLvxzVHwjP5Y0Oj068Y+EgrjWGq OhfIYLCryGeRuvmhDZ+n6lETitFb0GPjWO+jZpkK/dGHNekKGMjqAnRYdt/yLdAqfE5o 8dsw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=ObDhJrcE; 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 d126sor10806355pfa.39.2019.06.17.00.36.33 for (Google Transport Security); Mon, 17 Jun 2019 00:36:33 -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:a62:b517:: with SMTP id y23mr116512596pfe.182.1560756993229; Mon, 17 Jun 2019 00:36:33 -0700 (PDT) Received: from localhost.localdomain ([49.206.203.245]) by smtp.gmail.com with ESMTPSA id m41sm15205998pje.18.2019.06.17.00.36.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 17 Jun 2019 00:36:32 -0700 (PDT) From: Jagan Teki To: Simon Glass , Philipp Tomsich , Kever Yang , YouMin Chen , u-boot@lists.denx.de Cc: Manivannan Sadhasivam , gajjar04akash@gmail.com, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH v2 04/99] ram: rk3399: s/sdram_params/params Date: Mon, 17 Jun 2019 13:01:17 +0530 Message-Id: <20190617073252.27810-5-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190617073252.27810-1-jagan@amarulasolutions.com> References: <20190617073252.27810-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=ObDhJrcE; 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: , Rename variable name of struct rk3399_sdram_params from sdram_params with params for more code readability. No functionality change. Signed-off-by: Jagan Teki --- drivers/ram/rockchip/sdram_rk3399.c | 160 ++++++++++++++-------------- 1 file changed, 78 insertions(+), 82 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index b8962d68f2..4c09009b7a 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -111,10 +111,9 @@ static void phy_dll_bypass_set(struct rk3399_ddr_publ_regs *ddr_publ_regs, } static void set_memory_map(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { - const struct rk3399_sdram_channel *sdram_ch = - &sdram_params->ch[channel]; + const struct rk3399_sdram_channel *sdram_ch = ¶ms->ch[channel]; u32 *denali_ctl = chan->pctl->denali_ctl; u32 *denali_pi = chan->pi->denali_pi; u32 cs_map; @@ -150,12 +149,12 @@ static void set_memory_map(const struct chan_info *chan, u32 channel, ((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->rank == 1 && params->base.dramtype == DDR3) writel(0x2EC7FFFF, &denali_pi[34]); } static void set_ds_odt(const struct chan_info *chan, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_phy = chan->publ->denali_phy; @@ -165,7 +164,7 @@ static void set_ds_odt(const struct chan_info *chan, u32 tsel_idle_select_n, tsel_wr_select_n, tsel_rd_select_n; u32 reg_value; - if (sdram_params->base.dramtype == LPDDR4) { + if (params->base.dramtype == LPDDR4) { tsel_rd_select_p = PHY_DRV_ODT_HI_Z; tsel_wr_select_p = PHY_DRV_ODT_40; ca_tsel_wr_select_p = PHY_DRV_ODT_40; @@ -175,7 +174,7 @@ static void set_ds_odt(const struct chan_info *chan, tsel_wr_select_n = PHY_DRV_ODT_40; ca_tsel_wr_select_n = PHY_DRV_ODT_40; tsel_idle_select_n = PHY_DRV_ODT_240; - } else if (sdram_params->base.dramtype == LPDDR3) { + } else if (params->base.dramtype == LPDDR3) { tsel_rd_select_p = PHY_DRV_ODT_240; tsel_wr_select_p = PHY_DRV_ODT_34_3; ca_tsel_wr_select_p = PHY_DRV_ODT_48; @@ -197,7 +196,7 @@ static void set_ds_odt(const struct chan_info *chan, tsel_idle_select_n = PHY_DRV_ODT_240; } - if (sdram_params->base.odt == 1) + if (params->base.odt == 1) tsel_rd_en = 1; else tsel_rd_en = 0; @@ -294,7 +293,7 @@ static void set_ds_odt(const struct chan_info *chan, } static int phy_io_config(const struct chan_info *chan, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_phy = chan->publ->denali_phy; u32 vref_mode_dq, vref_value_dq, vref_mode_ac, vref_value_ac; @@ -304,14 +303,14 @@ static int phy_io_config(const struct chan_info *chan, u32 speed; /* vref setting */ - if (sdram_params->base.dramtype == LPDDR4) { + if (params->base.dramtype == LPDDR4) { /* LPDDR4 */ vref_mode_dq = 0x6; vref_value_dq = 0x1f; vref_mode_ac = 0x6; vref_value_ac = 0x1f; - } else if (sdram_params->base.dramtype == LPDDR3) { - if (sdram_params->base.odt == 1) { + } else if (params->base.dramtype == LPDDR3) { + if (params->base.odt == 1) { vref_mode_dq = 0x5; /* LPDDR3 ODT */ drv_value = (readl(&denali_phy[6]) >> 12) & 0xf; odt_value = (readl(&denali_phy[6]) >> 4) & 0xf; @@ -370,7 +369,7 @@ static int phy_io_config(const struct chan_info *chan, } vref_mode_ac = 0x2; vref_value_ac = 0x1f; - } else if (sdram_params->base.dramtype == DDR3) { + } else if (params->base.dramtype == DDR3) { /* DDR3L */ vref_mode_dq = 0x1; vref_value_dq = 0x1f; @@ -397,11 +396,11 @@ static int phy_io_config(const struct chan_info *chan, /* PHY_915 PHY_PAD_VREF_CTRL_AC 12bits offset_16 */ clrsetbits_le32(&denali_phy[915], 0xfff << 16, reg_value << 16); - if (sdram_params->base.dramtype == LPDDR4) + if (params->base.dramtype == LPDDR4) mode_sel = 0x6; - else if (sdram_params->base.dramtype == LPDDR3) + else if (params->base.dramtype == LPDDR3) mode_sel = 0x0; - else if (sdram_params->base.dramtype == DDR3) + else if (params->base.dramtype == DDR3) mode_sel = 0x1; else return -EINVAL; @@ -424,11 +423,11 @@ static int phy_io_config(const struct chan_info *chan, clrsetbits_le32(&denali_phy[939], 0x7 << 14, mode_sel << 14); /* speed setting */ - if (sdram_params->base.ddr_freq < 400) + if (params->base.ddr_freq < 400) speed = 0x0; - else if (sdram_params->base.ddr_freq < 800) + else if (params->base.ddr_freq < 800) speed = 0x1; - else if (sdram_params->base.ddr_freq < 1200) + else if (params->base.ddr_freq < 1200) speed = 0x2; else speed = 0x3; @@ -454,13 +453,13 @@ static int phy_io_config(const struct chan_info *chan, } static int pctl_cfg(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_ctl = chan->pctl->denali_ctl; u32 *denali_pi = chan->pi->denali_pi; u32 *denali_phy = chan->publ->denali_phy; - const u32 *params_ctl = sdram_params->pctl_regs.denali_ctl; - const u32 *params_phy = sdram_params->phy_regs.denali_phy; + const u32 *params_ctl = params->pctl_regs.denali_ctl; + const u32 *params_phy = params->phy_regs.denali_phy; u32 tmp, tmp1, tmp2; u32 pwrup_srefresh_exit; int ret; @@ -473,14 +472,14 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel, copy_to_reg(&denali_ctl[1], ¶ms_ctl[1], sizeof(struct rk3399_ddr_pctl_regs) - 4); writel(params_ctl[0], &denali_ctl[0]); - copy_to_reg(denali_pi, &sdram_params->pi_regs.denali_pi[0], + copy_to_reg(denali_pi, ¶ms->pi_regs.denali_pi[0], sizeof(struct rk3399_ddr_pi_regs)); /* rank count need to set for init */ - set_memory_map(chan, channel, sdram_params); + set_memory_map(chan, channel, params); - writel(sdram_params->phy_regs.denali_phy[910], &denali_phy[910]); - writel(sdram_params->phy_regs.denali_phy[911], &denali_phy[911]); - writel(sdram_params->phy_regs.denali_phy[912], &denali_phy[912]); + writel(params->phy_regs.denali_phy[910], &denali_phy[910]); + writel(params->phy_regs.denali_phy[911], &denali_phy[911]); + writel(params->phy_regs.denali_phy[912], &denali_phy[912]); pwrup_srefresh_exit = readl(&denali_ctl[68]) & PWRUP_SREFRESH_EXIT; clrbits_le32(&denali_ctl[68], PWRUP_SREFRESH_EXIT); @@ -511,7 +510,7 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel, copy_to_reg(&denali_phy[512], ¶ms_phy[512], (549 - 512 + 1) * 4); copy_to_reg(&denali_phy[640], ¶ms_phy[640], (677 - 640 + 1) * 4); copy_to_reg(&denali_phy[768], ¶ms_phy[768], (805 - 768 + 1) * 4); - set_ds_odt(chan, sdram_params); + set_ds_odt(chan, params); /* * phy_dqs_tsel_wr_timing_X 8bits DENALI_PHY_84/212/340/468 offset_8 @@ -539,7 +538,7 @@ static int pctl_cfg(const struct chan_info *chan, u32 channel, tmp = (readl(&denali_phy[467]) >> 16) & 0xff; clrsetbits_le32(&denali_phy[467], 0xff << 16, (tmp + 0x10) << 16); - ret = phy_io_config(chan, sdram_params); + ret = phy_io_config(chan, params); if (ret) return ret; @@ -610,13 +609,13 @@ static void override_write_leveling_value(const struct chan_info *chan) } static int data_training_ca(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_pi = chan->pi->denali_pi; 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 = params->ch[channel].rank; for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); @@ -664,13 +663,13 @@ static int data_training_ca(const struct chan_info *chan, u32 channel, } static int data_training_wl(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_pi = chan->pi->denali_pi; 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 = params->ch[channel].rank; for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); @@ -723,13 +722,13 @@ static int data_training_wl(const struct chan_info *chan, u32 channel, } static int data_training_rg(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_pi = chan->pi->denali_pi; 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 = params->ch[channel].rank; for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); @@ -784,11 +783,11 @@ static int data_training_rg(const struct chan_info *chan, u32 channel, } static int data_training_rl(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_pi = chan->pi->denali_pi; u32 i, tmp; - u32 rank = sdram_params->ch[channel].rank; + u32 rank = params->ch[channel].rank; for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); @@ -829,11 +828,11 @@ static int data_training_rl(const struct chan_info *chan, u32 channel, } static int data_training_wdql(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 *denali_pi = chan->pi->denali_pi; u32 i, tmp; - u32 rank = sdram_params->ch[channel].rank; + u32 rank = params->ch[channel].rank; for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); @@ -874,7 +873,7 @@ static int data_training_wdql(const struct chan_info *chan, u32 channel, } static int data_training(const struct chan_info *chan, u32 channel, - const struct rk3399_sdram_params *sdram_params, + const struct rk3399_sdram_params *params, u32 training_flag) { u32 *denali_phy = chan->publ->denali_phy; @@ -883,14 +882,14 @@ static int data_training(const struct chan_info *chan, u32 channel, setbits_le32(&denali_phy[927], (1 << 22)); if (training_flag == PI_FULL_TRAINING) { - if (sdram_params->base.dramtype == LPDDR4) { + if (params->base.dramtype == LPDDR4) { training_flag = PI_CA_TRAINING | PI_WRITE_LEVELING | PI_READ_GATE_TRAINING | PI_READ_LEVELING | PI_WDQ_LEVELING; - } else if (sdram_params->base.dramtype == LPDDR3) { + } else if (params->base.dramtype == LPDDR3) { training_flag = PI_CA_TRAINING | PI_WRITE_LEVELING | PI_READ_GATE_TRAINING; - } else if (sdram_params->base.dramtype == DDR3) { + } else if (params->base.dramtype == DDR3) { training_flag = PI_WRITE_LEVELING | PI_READ_GATE_TRAINING | PI_READ_LEVELING; @@ -899,23 +898,23 @@ static int data_training(const struct chan_info *chan, u32 channel, /* ca training(LPDDR4,LPDDR3 support) */ if ((training_flag & PI_CA_TRAINING) == PI_CA_TRAINING) - data_training_ca(chan, channel, sdram_params); + data_training_ca(chan, channel, params); /* write leveling(LPDDR4,LPDDR3,DDR3 support) */ if ((training_flag & PI_WRITE_LEVELING) == PI_WRITE_LEVELING) - data_training_wl(chan, channel, sdram_params); + data_training_wl(chan, channel, params); /* read gate training(LPDDR4,LPDDR3,DDR3 support) */ if ((training_flag & PI_READ_GATE_TRAINING) == PI_READ_GATE_TRAINING) - data_training_rg(chan, channel, sdram_params); + data_training_rg(chan, channel, params); /* read leveling(LPDDR4,LPDDR3,DDR3 support) */ if ((training_flag & PI_READ_LEVELING) == PI_READ_LEVELING) - data_training_rl(chan, channel, sdram_params); + data_training_rl(chan, channel, params); /* wdq leveling(LPDDR4 support) */ if ((training_flag & PI_WDQ_LEVELING) == PI_WDQ_LEVELING) - data_training_wdql(chan, channel, sdram_params); + data_training_wdql(chan, channel, params); /* PHY_927 PHY_PAD_DQS_DRIVE RPULL offset_22 */ clrbits_le32(&denali_phy[927], (1 << 22)); @@ -924,7 +923,7 @@ static int data_training(const struct chan_info *chan, u32 channel, } static void set_ddrconfig(const struct chan_info *chan, - const struct rk3399_sdram_params *sdram_params, + const struct rk3399_sdram_params *params, unsigned char channel, u32 ddrconfig) { /* only need to set ddrconfig */ @@ -932,14 +931,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 << (params->ch[channel].cs0_row + + params->ch[channel].col + + params->ch[channel].bk + + params->ch[channel].bw - 20)); + if (params->ch[channel].rank > 1) + cs1_cap = cs0_cap >> (params->ch[channel].cs0_row + - params->ch[channel].cs1_row); + if (params->ch[channel].row_3_4) { cs0_cap = cs0_cap * 3 / 4; cs1_cap = cs1_cap * 3 / 4; } @@ -950,24 +949,22 @@ static void set_ddrconfig(const struct chan_info *chan, } static void dram_all_config(struct dram_info *dram, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 sys_reg = 0; unsigned int channel, idx; - sys_reg |= sdram_params->base.dramtype << SYS_REG_DDRTYPE_SHIFT; - sys_reg |= (sdram_params->base.num_channels - 1) - << SYS_REG_NUM_CH_SHIFT; + sys_reg |= params->base.dramtype << SYS_REG_DDRTYPE_SHIFT; + sys_reg |= (params->base.num_channels - 1) << SYS_REG_NUM_CH_SHIFT; for (channel = 0, idx = 0; - (idx < sdram_params->base.num_channels) && (channel < 2); + (idx < params->base.num_channels) && (channel < 2); channel++) { - const struct rk3399_sdram_channel *info = - &sdram_params->ch[channel]; + const struct rk3399_sdram_channel *info = ¶ms->ch[channel]; struct rk3399_msch_regs *ddr_msch_regs; const struct rk3399_msch_timings *noc_timing; - if (sdram_params->ch[channel].col == 0) + if (params->ch[channel].col == 0) continue; idx++; sys_reg |= info->row_3_4 << SYS_REG_ROW_3_4_SHIFT(channel); @@ -983,7 +980,7 @@ static void dram_all_config(struct dram_info *dram, sys_reg |= (2 >> info->dbw) << SYS_REG_DBW_SHIFT(channel); ddr_msch_regs = dram->chan[channel].msch; - noc_timing = &sdram_params->ch[channel].noc_timings; + noc_timing = ¶ms->ch[channel].noc_timings; writel(noc_timing->ddrtiminga0, &ddr_msch_regs->ddrtiminga0); writel(noc_timing->ddrtimingb0, @@ -996,14 +993,14 @@ 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 (params->ch[channel].rank == 1) setbits_le32(&dram->chan[channel].pctl->denali_ctl[276], 1 << 17); } writel(sys_reg, &dram->pmugrf->os_reg2); rk_clrsetreg(&dram->pmusgrf->soc_con4, 0x1f << 10, - sdram_params->base.stride << 10); + params->base.stride << 10); /* reboot hold register set */ writel(PRESET_SGRF_HOLD(0) | PRESET_GPIO0_HOLD(1) | @@ -1013,11 +1010,11 @@ static void dram_all_config(struct dram_info *dram, } static int switch_to_phy_index1(struct dram_info *dram, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { u32 channel; u32 *denali_phy; - u32 ch_count = sdram_params->base.num_channels; + u32 ch_count = params->base.num_channels; int ret; int i = 0; @@ -1048,7 +1045,7 @@ static int switch_to_phy_index1(struct dram_info *dram, denali_phy = dram->chan[channel].publ->denali_phy; clrsetbits_le32(&denali_phy[896], (0x3 << 8) | 1, 1 << 8); ret = data_training(&dram->chan[channel], channel, - sdram_params, PI_FULL_TRAINING); + params, PI_FULL_TRAINING); if (ret) { debug("index1 training failed\n"); return ret; @@ -1059,10 +1056,10 @@ static int switch_to_phy_index1(struct dram_info *dram, } static int sdram_init(struct dram_info *dram, - const struct rk3399_sdram_params *sdram_params) + const struct rk3399_sdram_params *params) { - unsigned char dramtype = sdram_params->base.dramtype; - unsigned int ddr_freq = sdram_params->base.ddr_freq; + unsigned char dramtype = params->base.dramtype; + unsigned int ddr_freq = params->base.ddr_freq; int channel; debug("Starting SDRAM initialization...\n"); @@ -1080,10 +1077,10 @@ static int sdram_init(struct dram_info *dram, phy_dll_bypass_set(publ, ddr_freq); - if (channel >= sdram_params->base.num_channels) + if (channel >= params->base.num_channels) continue; - if (pctl_cfg(chan, channel, sdram_params) != 0) { + if (pctl_cfg(chan, channel, params) != 0) { printf("pctl_cfg fail, reset\n"); return -EIO; } @@ -1092,17 +1089,16 @@ static int sdram_init(struct dram_info *dram, if (dramtype == LPDDR3) udelay(10); - if (data_training(chan, channel, - sdram_params, PI_FULL_TRAINING)) { + if (data_training(chan, channel, params, PI_FULL_TRAINING)) { printf("SDRAM initialization failed, reset\n"); return -EIO; } - set_ddrconfig(chan, sdram_params, channel, - sdram_params->ch[channel].ddrconfig); + set_ddrconfig(chan, params, channel, + params->ch[channel].ddrconfig); } - dram_all_config(dram, sdram_params); - switch_to_phy_index1(dram, sdram_params); + dram_all_config(dram, params); + switch_to_phy_index1(dram, params); debug("Finish SDRAM initialization...\n"); return 0;