From patchwork Tue Jul 16 11:57:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 785 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pg1-f197.google.com (mail-pg1-f197.google.com [209.85.215.197]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 9A04F3F08F for ; Tue, 16 Jul 2019 14:00:06 +0200 (CEST) Received: by mail-pg1-f197.google.com with SMTP id u16sf494001pgj.7 for ; Tue, 16 Jul 2019 05:00:06 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1563278405; cv=pass; d=google.com; s=arc-20160816; b=o5xAeHhUOpzIkLUi6SUJr210aIkmAnurybj/o6IfipmkePsiUeOfPJjtbt5e58UK7V ihJTvlnwUzf6xh/cOxxEtdPH4Qqk+7Z90n+IFXMzDwVnb/R5/HDycD2694DTY/Kug47p EQ3KX8D6viqlzvjIYzDLjoB3D4uDqkbX6wmYCm2Sp+nP9qW2npYA9DCKcttfcqT0kfgd Ixb38MnU86S9A6y8eJXdoXuhJqmps1h/hsRRtfDty8WnQg2GZANaxEWjo/FUaY+oMQ4x UjUuh41QGp16AvZ6TvDxuimHt9g2vFr/2GwCHme+fPsdpaBDJWS2Qt97XusOjLisnIpJ 1TLw== 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=XzN4r0wjxDCF3r5wXjn3Urd0X/ba2jQ7y6KguElUcFY=; b=P3ZaHTXRB4/1cqu+MlfCyFXuh+Si/E9tYQTW/ibHCY9tYBVo3Fr6w5jqMSJMJRLibp OLGBsKv1A57X6uc6z1nmnZIdD7KwrjNizawPvv3c3kK3d5BOc6bBAk7GnHUXPfVExl1O ecXZI7zYRtaUFEGWtnpa8xDfSsmnN4UVpmjgtPdvfRFYfdM251xZDQv3ASUZcphi1ldh T0TcIitIuX7tP+MBWE0t7wuwtYqMC6lYwVvjb6oZKoeKDp79oE+ey5KfIakdilcQ98vY 9wa7HZTPrJR9bv7E5QUMeZ5W95niUOyLmBqHPIMT7kwj7jnihXcrl0Z4gYNxwnM2K43a SSJw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fxMyMKHQ; 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=XzN4r0wjxDCF3r5wXjn3Urd0X/ba2jQ7y6KguElUcFY=; b=mVoDPJDyI8uw2IXhQ2V31OFCZYwpz6p/nb5q5ErQzpOBywZdYURQSFX/V4bv38h78l EI3J7rlJHvTCrp5bu1SKDi/RvKczlDKnG1t0bgopgiStNhxDDk+Rpuo3/yA3vzAb0qK+ Cn1VxYQkIz9V/ZCDhaoNT2CZqxjNwF9ldjwPs= 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=XzN4r0wjxDCF3r5wXjn3Urd0X/ba2jQ7y6KguElUcFY=; b=T9sMF/FCVNyiBdHTMwKfCKo1dKPym7nZXB3chEC0YZ28hEYoQWMvHt12K+x2JsMphl u3XjQc2m9JbAbCpqVSgS3AO+w0Ks7/kx44SSTYLDTciKRidHV18IK7QrA8j+Ebhq6UEB masxhbU7ZohPS4MRtP4z0zHMjDK89nQgkR5Ifjzo90W0VNXGXB1J0LW2bPgTY8Rlereu EynsWqaALIquTYlS6VygrYlwcd9cVn/fqmOPtTmCvcBLxK06EOp3TIGjZ0NSQoQT+3KU O8LJRQBx3+Zlqdv5keck6j7U3O7Huugxoi2Eh8ALrNIU9f8QXTMMhxZnyeb94atkNR3e wfIA== X-Gm-Message-State: APjAAAUZTnPidfi2ogL5iM1Sx09EU2ObF4OtmNGqgzN/ymB+D3osX3NS TJPEIlQuiSlDEuZ8jWpu8vu3UOV+ X-Google-Smtp-Source: APXvYqzjPQFfBEqFIdMICdD2C4a1ZkNlC2UZTecX5ckpDo4QpW97ElRyoWb67bVPh8qXW1ptI0nL8A== X-Received: by 2002:a63:c442:: with SMTP id m2mr33550821pgg.286.1563278405353; Tue, 16 Jul 2019 05:00:05 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:90a:3662:: with SMTP id s89ls7082576pjb.1.canary-gmail; Tue, 16 Jul 2019 05:00:05 -0700 (PDT) X-Received: by 2002:a17:902:7202:: with SMTP id ba2mr35278092plb.266.1563278405030; Tue, 16 Jul 2019 05:00:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563278405; cv=none; d=google.com; s=arc-20160816; b=jdV64JBwrE1MrUMNi5oXGjQP0AGJWZskGZMiLtSmkw6zKXh2XvkeRlY+xRF5r7QZO6 6z4xdoKtPonPbYo7V0+NcrO+F89aKVL5CXNJRDiEh3clUCimDeUpaQm+5/hlqedFNDU8 BLm/B0+PItBPh4FDJGxvOfYuafnHUP3iPdzu4ZPxFij39I0NbsWdzJPhUiud6Z9mDqk3 S4A5gsZrxxiR9Oi2/L0fAKsYWt6t8iQPBqLkb4JpK7zxFBDlQDrq27i99iQfRA7QQ5+C 1uBun60iGJQ7DKpwVgOK4IeNF5LbuUzhVZ3gjtIinLMSCp+E25rUeEqEnaMlFdLhBzUO Q9sg== 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=uJaha5qbi/fzESpsHy2ICJEbRyPTEVDRBKY1OAzcEjI=; b=eYoTf+t8M85dw1hn+Ato+uBI3qXf3WVAD0N6Lajp5neNmzD0dT1Z1ncZmf3X54GrOr 11UOCZ4kJQUTPo/x2t5uI5bhRjsnprfrymqMVJ9S3G9wppu+llEzEEjpENpmJZPMcEEU 0f+vCmmExztWGeLz/FmmyV2LGjjOu+jI4W0mbd1YbHXPlaE9bBZOzgrVoRqjxe0kl/Xu 59vcou10nasDQTESomJhVVy6kvP26NMm84fx9Xnz2rtUTKae8mHgdodgzhfMwCsolLlh ecIepgotcYFruNMPN+7O4cOy4ZCaMKofiQeCn3Mnj6KKbgOJLjQCTtyOdHoKPG20unpx rksw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fxMyMKHQ; 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 k6sor10653174pgs.79.2019.07.16.05.00.05 for (Google Transport Security); Tue, 16 Jul 2019 05:00:05 -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:2606:: with SMTP id m6mr32927678pgm.436.1563278404676; Tue, 16 Jul 2019 05:00:04 -0700 (PDT) Received: from localhost.localdomain ([49.206.201.107]) by smtp.gmail.com with ESMTPSA id z24sm36269566pfr.51.2019.07.16.05.00.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 05:00:04 -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 36/57] ram: rk3399: Configure soc odt support Date: Tue, 16 Jul 2019 17:27:24 +0530 Message-Id: <20190716115745.12585-37-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190716115745.12585-1-jagan@amarulasolutions.com> References: <20190716115745.12585-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=fxMyMKHQ; 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: , CTL 145, 146, 159, 160 registers are used to configure soc odt on rk3399. These soc odt values are updated from CS0_MR22_VAL and CS1_MR22_VAL and for lpddr4 these values ORed with tsel_rd_select_n. Signed-off-by: Jagan Teki Signed-off-by: YouMin Chen Reviewed-by: Kever Yang --- drivers/ram/rockchip/sdram_rk3399.c | 49 ++++++++++++++++++++++++++++- 1 file changed, 48 insertions(+), 1 deletion(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index c38ea1d284..e0be9d2485 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -40,6 +40,8 @@ #define PHY_SLEWP_EN 0x1 #define PHY_SLEWN_EN 0x1 #define PHY_RX_CM_INPUT 0x1 +#define CS0_MR22_VAL 0 +#define CS1_MR22_VAL 3 #define CRU_SFTRST_DDR_CTRL(ch, n) ((0x1 << (8 + 16 + (ch) * 4)) | \ ((n) << (8 + (ch) * 4))) @@ -554,7 +556,7 @@ static void set_ds_odt(const struct chan_info *chan, const struct rk3399_sdram_params *params, u32 mr5) { u32 *denali_phy = chan->publ->denali_phy; - + u32 *denali_ctl = chan->pctl->denali_ctl; u32 tsel_idle_en, tsel_wr_en, tsel_rd_en; u32 tsel_idle_select_p, tsel_rd_select_p; u32 tsel_idle_select_n, tsel_rd_select_n; @@ -562,6 +564,7 @@ static void set_ds_odt(const struct chan_info *chan, u32 tsel_wr_select_dq_n, tsel_wr_select_ca_n; u32 tsel_ckcs_select_p, tsel_ckcs_select_n; struct io_setting *io = NULL; + u32 soc_odt = 0; u32 reg_value; if (params->base.dramtype == LPDDR4) { @@ -581,6 +584,35 @@ static void set_ds_odt(const struct chan_info *chan, tsel_ckcs_select_p = io->wr_ckcs_drv; tsel_ckcs_select_n = PHY_DRV_ODT_34_3; + switch (tsel_rd_select_n) { + case PHY_DRV_ODT_240: + soc_odt = 1; + break; + case PHY_DRV_ODT_120: + soc_odt = 2; + break; + case PHY_DRV_ODT_80: + soc_odt = 3; + break; + case PHY_DRV_ODT_60: + soc_odt = 4; + break; + case PHY_DRV_ODT_48: + soc_odt = 5; + break; + case PHY_DRV_ODT_40: + soc_odt = 6; + break; + case PHY_DRV_ODT_34_3: + soc_odt = 6; + printf("%s: Unable to support LPDDR4 MR22 Soc ODT\n", + __func__); + break; + case PHY_DRV_ODT_HI_Z: + default: + soc_odt = 0; + break; + } } else if (params->base.dramtype == LPDDR3) { tsel_rd_select_p = PHY_DRV_ODT_240; tsel_rd_select_n = PHY_DRV_ODT_HI_Z; @@ -621,6 +653,21 @@ static void set_ds_odt(const struct chan_info *chan, tsel_wr_en = 0; tsel_idle_en = 0; + /* F0_0 */ + clrsetbits_le32(&denali_ctl[145], 0xFF << 16, + (soc_odt | (CS0_MR22_VAL << 3)) << 16); + /* F2_0, F1_0 */ + clrsetbits_le32(&denali_ctl[146], 0xFF00FF, + ((soc_odt | (CS0_MR22_VAL << 3)) << 16) | + (soc_odt | (CS0_MR22_VAL << 3))); + /* F0_1 */ + clrsetbits_le32(&denali_ctl[159], 0xFF << 16, + (soc_odt | (CS1_MR22_VAL << 3)) << 16); + /* F2_1, F1_1 */ + clrsetbits_le32(&denali_ctl[160], 0xFF00FF, + ((soc_odt | (CS1_MR22_VAL << 3)) << 16) | + (soc_odt | (CS1_MR22_VAL << 3))); + /* * phy_dq_tsel_select_X 24bits DENALI_PHY_6/134/262/390 offset_0 * sets termination values for read/idle cycles and drive strength