From patchwork Mon Jul 15 18:20:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 716 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f200.google.com (mail-pg1-f200.google.com [209.85.215.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id AE24D3F0E1 for ; Mon, 15 Jul 2019 20:21:30 +0200 (CEST) Received: by mail-pg1-f200.google.com with SMTP id c18sf10957409pgk.2 for ; Mon, 15 Jul 2019 11:21:30 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1563214889; cv=pass; d=google.com; s=arc-20160816; b=tHyPicE8WQ8dGQj1FzUillHFwqMuRrZ9VbYlrJIF6AOcbcESiWG8UK0oea0xBMJ0Pl hFPBzOpfKK//SUf9DF8j/lyZSYT1YiGiwOpTJbNvYrCMi9EFNCtd2StVclKx3Nhdr7n6 dvxzyYjAEQk8h1D4zmDGpiS8vYuEdPg4I5JltP0mQVlXVOuj+xY6iAsEVkolyPf5QZ6o Cnafku8rEfBry7nLAeVLIEMZONHgoxqBz+MWpN4P0I9SozgvOspdExV1psZv/yg3bx8K BHFU9Ox17/t6Bq6Ir7mVG0V+/AcCb0qcuGsTApbla7tN41Tf4OKb9bSmAFFK1qZlHxNd jcMA== 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=UpxS2f6EJlWVL0GNXl8SsihK+H8nqSTPHPQbBRCXmOg=; b=TvE138odBqm7Ey9UKXsrVovnuaJqUDdFgaZM6gv3LhZvSWsvsKEbyLDwb3PrSFfvPc 9OvZu6Jt9L/HmRnkycxfaTvP8yzjlo2vhKrF56JaElG1sTl1lmNcwVze8ejVKiR9mmGU caVv9g9FCYCnmcjKEGv75NKJ/vXzFlLWMqtBszYyNNSrpWH6M9eXkf0tPtlyp0Sho1Oe 2KaiN8kGRv3lQRZa3pluptId/wOTx7vBGmDMgJkzGtHpcREOY/uQg3I96ABLLRIybsKY 3tnwD9SL2sZBuSmXpQWNzkd2Zj8OcV6nq+qe7TzSChOWCGFq7X220uDmUoiJ/0j/cjBO 265g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=DFiE9O5X; 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=UpxS2f6EJlWVL0GNXl8SsihK+H8nqSTPHPQbBRCXmOg=; b=aCyPeSX4u+DgDZjgDiPWM/brqb6hF3ETPvxXcHbeCGxtLoBtWZ+cKlUS0lxXvg9opY cNFvnGWD2ODHckfxPJUIdv3MFTMPg1CYBvzMeqrlX3dimdspZQAnXPW+rDuAyYvoHtuj KJYRimj0geKUeRZB8mfqeB0yXLipYGo3CB+cY= 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=UpxS2f6EJlWVL0GNXl8SsihK+H8nqSTPHPQbBRCXmOg=; b=Bv6duP3/OcjTb8rHlZUZwjT8VVjO6D5e2nQYY3QJufPh8UoRrpUeeb0XLq56LPokpd mhxj/CYa6wKvchslHMt346SbbXAfJf9KiwwmryopCdxgLMsOdq4iLOX9XF8SRon0ahs7 OppZz9FMEbi9Vr9Dae697bp4A0/JXaxc7v8v1Gl74ns64O4isjTx7BOMfIBwyzfdurXX 3b9pL82MJ3aoYQOiy/uYN9bOIHlt01AM+u6o0n1PQSJfsDOLStphSo3Zanmyw4sIjeMY B9aV9WNKqciPEWQlZ/mNfULdeU9/TVGRpFObrxXUGOisg5Rj6SYMFPBiHZbldSWjCW0+ SNKA== X-Gm-Message-State: APjAAAX4R2cEyMFF6uUKWJO2cc3qZevm0IN2b9v0KcOZJtteLYXgxtFr CMqqIIQPI1te2C71VjNJR2kL1Xt9 X-Google-Smtp-Source: APXvYqyyw1Qy37R4oDYce9VFJsf6wJrPf1t/6+cfl8fuLrowrQzvD+d+r7tXGUoMCct2v5imrJcFdQ== X-Received: by 2002:a17:902:f46:: with SMTP id 64mr30105296ply.235.1563214889505; Mon, 15 Jul 2019 11:21:29 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a62:63c1:: with SMTP id x184ls2995639pfb.5.gmail; Mon, 15 Jul 2019 11:21:29 -0700 (PDT) X-Received: by 2002:a63:181:: with SMTP id 123mr29038468pgb.63.1563214889038; Mon, 15 Jul 2019 11:21:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563214889; cv=none; d=google.com; s=arc-20160816; b=qjlRmU1I73B74sIkckJ0yiKbd2dFa+1uzyWaAKEnLqjnhb3toVLt2Gd+VSWLoBLRLA lf+7l4cMIZi3KWUxz0ZId1pcQdeZgkXa1hW3bqkswjmfFcAATQqf5eaaRoPviAoJawDE 61+Z53kwGlTo2DVXE64vL0Yj3OeyuICmRFFC1HJFg2QTDSSskjvOI0rnA9So/rei2H9/ iJ392fnUk4BkxZvDgD4c1BsQy9oT7Z8SSnRMcTyXMeZJrjKtx38sAG9ABou7JYkijDDv C3Cj0t7nj1zBb23fMGYQUB5B8SSn/lIGL971NZge7Zirmlwlj5CEgLY/91VozZ56ySKA segw== 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=91XSnQx5BFEbjjDU1Kng5TwLgRBduu4DBFPUieipXW0=; b=VgaQD57+x10Dr/X+EZqXg5shgnPoiQ0VsdpAw4+Fjc1bmON7YGli92s586uCGzZ/Nk rsylqIvQowrt5SXe7zhG0BGQgOPd0cphFXqDbv5y4l1Fhe4pS4s6z4QKK2AYkGx3LZfF FDVfc7LwLMo5qzLeb1iRRsq/VJE5qeUqIALgAf/Z8oaetLGJ1UqVKP1jYkhnzCdNkIW/ JdTdAWc8GcFqbtvLCCwA00xmdGPEJHd3uviozoCBBkm+vY9YL3YTOVZoYEJDYro4QfJ2 mh6LA7IIdG58fDDZWwWaTJMbcO97p4TZstaCFxU8AUPVwz2pSs17P8I3ZvEf8i9j+tLi FsFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=DFiE9O5X; 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 l4sor9514720pgj.48.2019.07.15.11.21.28 for (Google Transport Security); Mon, 15 Jul 2019 11:21:28 -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:a63:d4c:: with SMTP id 12mr28947708pgn.30.1563214887849; Mon, 15 Jul 2019 11:21:27 -0700 (PDT) Received: from localhost.localdomain ([49.206.201.107]) by smtp.gmail.com with ESMTPSA id l15sm18152405pgf.5.2019.07.15.11.21.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 11:21:27 -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 v3 02/15] ram: rk3399: Some trivial code fixes Date: Mon, 15 Jul 2019 23:50:57 +0530 Message-Id: <20190715182110.21336-3-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190715182110.21336-1-jagan@amarulasolutions.com> References: <20190715182110.21336-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=DFiE9O5X; 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: , - Add proper spaces in data training, rk3399_dmc_init, pctl_cfg - Order include files - Move macro after include files Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/ram/rockchip/sdram_rk3399.c | 60 +++++++++++++++++++++-------- 1 file changed, 43 insertions(+), 17 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 541e4a4b1e..733864f5d2 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -14,14 +14,27 @@ #include #include #include -#include -#include #include #include #include +#include +#include #include #include +#define PRESET_SGRF_HOLD(n) ((0x1 << (6 + 16)) | ((n) << 6)) +#define PRESET_GPIO0_HOLD(n) ((0x1 << (7 + 16)) | ((n) << 7)) +#define PRESET_GPIO1_HOLD(n) ((0x1 << (8 + 16)) | ((n) << 8)) + +#define PHY_DRV_ODT_HI_Z 0x0 +#define PHY_DRV_ODT_240 0x1 +#define PHY_DRV_ODT_120 0x8 +#define PHY_DRV_ODT_80 0x9 +#define PHY_DRV_ODT_60 0xc +#define PHY_DRV_ODT_48 0xd +#define PHY_DRV_ODT_40 0xe +#define PHY_DRV_ODT_34_3 0xf + struct chan_info { struct rk3399_ddr_pctl_regs *pctl; struct rk3399_ddr_pi_regs *pi; @@ -43,19 +56,6 @@ struct dram_info { struct rk3399_pmugrf_regs *pmugrf; }; -#define PRESET_SGRF_HOLD(n) ((0x1 << (6 + 16)) | ((n) << 6)) -#define PRESET_GPIO0_HOLD(n) ((0x1 << (7 + 16)) | ((n) << 7)) -#define PRESET_GPIO1_HOLD(n) ((0x1 << (8 + 16)) | ((n) << 8)) - -#define PHY_DRV_ODT_HI_Z 0x0 -#define PHY_DRV_ODT_240 0x1 -#define PHY_DRV_ODT_120 0x8 -#define PHY_DRV_ODT_80 0x9 -#define PHY_DRV_ODT_60 0xc -#define PHY_DRV_ODT_48 0xd -#define PHY_DRV_ODT_40 0xe -#define PHY_DRV_ODT_34_3 0xf - #if defined(CONFIG_TPL_BUILD) || \ (!defined(CONFIG_TPL) && defined(CONFIG_SPL_BUILD)) @@ -473,8 +473,10 @@ 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], sizeof(struct rk3399_ddr_pi_regs)); + /* rank count need to set for init */ set_memory_map(chan, channel, sdram_params); @@ -620,8 +622,10 @@ static int data_training_ca(const struct chan_info *chan, u32 channel, for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); + /* PI_100 PI_CALVL_EN:RW:8:2 */ clrsetbits_le32(&denali_pi[100], 0x3 << 8, 0x2 << 8); + /* PI_92 PI_CALVL_REQ:WR:16:1,PI_CALVL_CS:RW:24:2 */ clrsetbits_le32(&denali_pi[92], (0x1 << 16) | (0x3 << 24), @@ -651,9 +655,11 @@ static int data_training_ca(const struct chan_info *chan, u32 channel, (obs_err == 1)) return -EIO; } + /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); } + clrbits_le32(&denali_pi[100], 0x3 << 8); return 0; @@ -670,8 +676,10 @@ static int data_training_wl(const struct chan_info *chan, u32 channel, for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); + /* PI_60 PI_WRLVL_EN:RW:8:2 */ clrsetbits_le32(&denali_pi[60], 0x3 << 8, 0x2 << 8); + /* PI_59 PI_WRLVL_REQ:WR:8:1,PI_WRLVL_CS:RW:16:2 */ clrsetbits_le32(&denali_pi[59], (0x1 << 8) | (0x3 << 16), @@ -705,6 +713,7 @@ static int data_training_wl(const struct chan_info *chan, u32 channel, (obs_err == 1)) return -EIO; } + /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); } @@ -726,8 +735,10 @@ static int data_training_rg(const struct chan_info *chan, u32 channel, for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); + /* PI_80 PI_RDLVL_GATE_EN:RW:24:2 */ clrsetbits_le32(&denali_pi[80], 0x3 << 24, 0x2 << 24); + /* * PI_74 PI_RDLVL_GATE_REQ:WR:16:1 * PI_RDLVL_CS:RW:24:2 @@ -764,9 +775,11 @@ static int data_training_rg(const struct chan_info *chan, u32 channel, (obs_err == 1)) return -EIO; } + /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); } + clrbits_le32(&denali_pi[80], 0x3 << 24); return 0; @@ -781,8 +794,10 @@ static int data_training_rl(const struct chan_info *chan, u32 channel, for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); + /* PI_80 PI_RDLVL_EN:RW:16:2 */ clrsetbits_le32(&denali_pi[80], 0x3 << 16, 0x2 << 16); + /* PI_74 PI_RDLVL_REQ:WR:8:1,PI_RDLVL_CS:RW:24:2 */ clrsetbits_le32(&denali_pi[74], (0x1 << 8) | (0x3 << 24), @@ -805,9 +820,11 @@ static int data_training_rl(const struct chan_info *chan, u32 channel, else if (((tmp >> 2) & 0x1) == 0x1) return -EIO; } + /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); } + clrbits_le32(&denali_pi[80], 0x3 << 16); return 0; @@ -822,13 +839,16 @@ static int data_training_wdql(const struct chan_info *chan, u32 channel, for (i = 0; i < rank; i++) { select_per_cs_training_index(chan, i); + /* * disable PI_WDQLVL_VREF_EN before wdq leveling? * PI_181 PI_WDQLVL_VREF_EN:RW:8:1 */ clrbits_le32(&denali_pi[181], 0x1 << 8); + /* PI_124 PI_WDQLVL_EN:RW:16:2 */ clrsetbits_le32(&denali_pi[124], 0x3 << 16, 0x2 << 16); + /* PI_121 PI_WDQLVL_REQ:WR:8:1,PI_WDQLVL_CS:RW:16:2 */ clrsetbits_le32(&denali_pi[121], (0x1 << 8) | (0x3 << 16), @@ -845,9 +865,11 @@ static int data_training_wdql(const struct chan_info *chan, u32 channel, else if (((tmp >> 6) & 0x1) == 0x1) return -EIO; } + /* clear interrupt,PI_175 PI_INT_ACK:WR:0:17 */ writel(0x00003f7c, (&denali_pi[175])); } + clrbits_le32(&denali_pi[124], 0x3 << 16); return 0; @@ -938,6 +960,7 @@ static void dram_all_config(struct dram_info *dram, sys_reg |= sdram_params->base.dramtype << SYS_REG_DDRTYPE_SHIFT; sys_reg |= (sdram_params->base.num_channels - 1) << SYS_REG_NUM_CH_SHIFT; + for (channel = 0, idx = 0; (idx < sdram_params->base.num_channels) && (channel < 2); channel++) { @@ -1164,6 +1187,7 @@ static int rk3399_dmc_init(struct udevice *dev) priv->chan[1].publ, priv->chan[1].msch); debug("cru %p, cic %p, grf %p, sgrf %p, pmucru %p\n", priv->cru, priv->cic, priv->pmugrf, priv->pmusgrf, priv->pmucru); + #if CONFIG_IS_ENABLED(OF_PLATDATA) ret = clk_get_by_index_platdata(dev, 0, dtplat->clocks, &priv->ddr_clk); #else @@ -1173,14 +1197,16 @@ static int rk3399_dmc_init(struct udevice *dev) printf("%s clk get failed %d\n", __func__, ret); return ret; } + ret = clk_set_rate(&priv->ddr_clk, params->base.ddr_freq * MHz); if (ret < 0) { printf("%s clk set failed %d\n", __func__, ret); return ret; } + ret = sdram_init(priv, params); if (ret < 0) { - printf("%s DRAM init failed%d\n", __func__, ret); + printf("%s DRAM init failed %d\n", __func__, ret); return ret; } @@ -1198,7 +1224,7 @@ static int rk3399_dmc_probe(struct udevice *dev) struct dram_info *priv = dev_get_priv(dev); priv->pmugrf = syscon_get_first_range(ROCKCHIP_SYSCON_PMUGRF); - debug("%s: pmugrf=%p\n", __func__, priv->pmugrf); + debug("%s: pmugrf = %p\n", __func__, priv->pmugrf); priv->info.base = CONFIG_SYS_SDRAM_BASE; priv->info.size = rockchip_sdram_size((phys_addr_t)&priv->pmugrf->os_reg2);