From patchwork Tue Jul 16 11:57:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 787 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 933DF3F08F for ; Tue, 16 Jul 2019 14:00:13 +0200 (CEST) Received: by mail-pl1-f200.google.com with SMTP id o6sf10058883plk.23 for ; Tue, 16 Jul 2019 05:00:13 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1563278412; cv=pass; d=google.com; s=arc-20160816; b=x3i11/JNLIwC2cvUnp1QQraQTfGK8LbE8HHLIlQxEKuYfh1EQpyWt5nW9WCnY7f/M1 DxMI7kv1aRFUy3hMrCOXyhYJHz8bXoArjsvSWM2W0adU5ISjsB1AYGE+9kEMAhsQFEQi /l1W+gP8VDd6hyyhQ6adZNKgwHe15v5BPQSG8TtlOruAtvFAxOG1+Oo6q/fwvs7RaDEx 6sSn21RzwYvTyCUY77w+Jbi+D65pgpLWtcHbvlv48/LGZjU5D6aQM+9HUkKb2wASvldS 0ZJCaMKLDmjBGm21AreSqiViDV7b+GJBOIepyi/afz+EiXDuO5ZLCcvYYGrQFfzSYkS1 ep9g== 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=0FukqGSpe5UvH0exWSZO1h4uqcLDX+r8tulJlR3Wk08=; b=FKbQIEAE/yaSY/FsMY/og24wYaPIdfmyxDUTJDkksTdk19pqLybmYS2xXM5abblv8O bx5ShCu30YHvJbAROpR2GoUKesvpXa/UeskOp5XaYTHD7jhYZ0JP0/RV24/qfa8uN/rM 7yv8nm5nLr20aWf8h2zyP4d8K5YkoOPNmYGJkF+HLSVJ2rfn0QwVhc3DL4Rb2rlSzNxY XCzOwnKp1+nee850DQTY8X3LMXe+8e86Cl1GR8p7tPdxATBzOdhJEcXYayU4PEBXXYpc YlJUz8y2rzFrhmiE6dYTcrJXd87Fhl1KJCKvRFT3/Fesx+UDge6d9lAM5fYUekepZAPM CQjA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kvnO2h2S; 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=0FukqGSpe5UvH0exWSZO1h4uqcLDX+r8tulJlR3Wk08=; b=mRg+3o/HrcSxatUxYQtoLFBfhgyc19UNpaOOwic40FOyBls8TVPfRNm7yceKJXSG+e umYEbatzAlPllwAv8VPMqHM/alxFcr+u/sQXa7mo/6EeMNLynYml4lFUAKe8EoWWcQ2r JJOjLG/8qQoy/mbUIb7/b23Y06e1BmGOAyi9o= 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=0FukqGSpe5UvH0exWSZO1h4uqcLDX+r8tulJlR3Wk08=; b=eZSZOhU8klr7idBxS7iGDZCffPbL87DDc6foNzP7eZiE4vxBZdSAvErA86abC/n4V7 rSANnmjXGZpSrAuGHNHPDDAUrEp7F6romY/lhAe/e1xz6SuXQND1cEXKwAuaaExySIoM t4jYJlbtG9Tu2fHdAD2HVpmjusLNhJxyrbS+/ueJWCjmXM7TfrXwbBkkRxvo0AWEZxfi XqmbZZ6mKrTsIhCtEXe+dwRf5mvemXVIPPpQO+J2fhw/0RYicXesNXwDjiqJJVhFX6Yc efRWsxwLsX+geOvKikzHNwWdKprimzlT8jpVqYI986hziad5r5jhOx2Lvw673xK7yMM6 n47w== X-Gm-Message-State: APjAAAWFMd8jttsQqy1R1tuMXnd5ui5UIJoFA2mqAtfFcQ4xNTXfC0Oj U7zlYylTMna8rESgpHIsCJpoPRQy X-Google-Smtp-Source: APXvYqwjMTYX6fqN1Yj6UARaHbr0xfYPC+2iumSc8Wf0eN2SVNA4q63jeH+cd32JeeyBvZFW0QJCPQ== X-Received: by 2002:a17:902:23:: with SMTP id 32mr34815121pla.34.1563278412385; Tue, 16 Jul 2019 05:00:12 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:32d:: with SMTP id 42ls5470080pld.11.gmail; Tue, 16 Jul 2019 05:00:12 -0700 (PDT) X-Received: by 2002:a17:90a:21ac:: with SMTP id q41mr36313991pjc.31.1563278412044; Tue, 16 Jul 2019 05:00:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563278412; cv=none; d=google.com; s=arc-20160816; b=Qm8H59hamTkk6vNQ6UF1txrgudrLODp/+nEiipweHnTXSwYU0RrXemShS4JEO0GeGL iGeh9kvfH9el5VA6+Pd4rM8fqN7Eo1SkoNF8CrFVRHwGGxnJUWArbVF8Hi09zgLs6xVO KpZI03JGyvUuLbKofEk86sSPj/SM0FWxjm2rUMMvE/ucA5RY5mleEgY2osKB66Sz8PNK iZb0TUDS9yOEH9UwZOyqSw5ntQf+nHvm9DTmdW/A+HoVddxhMvOD5liv6OB6bWy6fAfJ NUI4PuarOaoUhr3lLPG45oQOAHx8gjs74V4Me2Y4D981b7M0vUNp2qjpqJ9nVYQusnEs qAww== 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=mh5Pf5jjoLLteLnqId9idbQ7tEs3dWgvjmHLOwZoIVk=; b=TF0j1gCShwtS7Vqqt16G86XKsmV/dz2dN1nDS3jDgel4sqifBdHoPZRi+dp2qHxt0D FEXaoOjMj8MnHwE43v1tfUrYPhnEQqfMLItniwyIjYwgGwT1vvDA9RkcKDWYF4rx8QUP RM7BI4vXiSPiUcetQuYzf44Z9l5p7AOfkniETA5iyuqcydxieajDXE47O9axyma+TyPn cmGgTJavy6GPmkM3H7ssxAPJ81NjsFR1t31A+8W779NaS+w7TogHmZzF3fQ6WrhE0R82 Nigd8/ZEEMCCjueZS3ad8yVAJIX1eL1DnNgT7PHnKtLLuI5fPKtdml3AGZNKjMQLxhJB VQUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=kvnO2h2S; 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 m9sor10379811pgq.33.2019.07.16.05.00.12 for (Google Transport Security); Tue, 16 Jul 2019 05:00:12 -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 m6mr32928694pgm.436.1563278411660; Tue, 16 Jul 2019 05:00:11 -0700 (PDT) Received: from localhost.localdomain ([49.206.201.107]) by smtp.gmail.com with ESMTPSA id z24sm36269566pfr.51.2019.07.16.05.00.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 05:00:11 -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 38/57] ram: rk3399: Update lpddr4 vref based on io settings Date: Tue, 16 Jul 2019 17:27:26 +0530 Message-Id: <20190716115745.12585-39-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=kvnO2h2S; 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: , The vref_mode_dq, vref_value_dq on lpddr4 value is depending on IO settings of rd_vref. Add support for it. Signed-off-by: Jagan Teki Signed-off-by: YouMin Chen Reviewed-by: Kever Yang --- drivers/ram/rockchip/sdram_rk3399.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 9e40880835..4a2622a440 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -338,7 +338,7 @@ static void set_memory_map(const struct chan_info *chan, u32 channel, } static int phy_io_config(const struct chan_info *chan, - const struct rk3399_sdram_params *params) + const struct rk3399_sdram_params *params, u32 mr5) { u32 *denali_phy = chan->publ->denali_phy; u32 vref_mode_dq, vref_value_dq, vref_mode_ac, vref_value_ac; @@ -349,9 +349,18 @@ static int phy_io_config(const struct chan_info *chan, /* vref setting */ if (params->base.dramtype == LPDDR4) { - /* LPDDR4 */ - vref_mode_dq = 0x6; - vref_value_dq = 0x1f; + struct io_setting *io = lpddr4_get_io_settings(params, mr5); + u32 rd_vref = io->rd_vref * 1000; + + if (rd_vref < 36700) { + /* MODE_LV[2:0] = LPDDR4 (Range 2)*/ + vref_mode_dq = 0x7; + vref_value_dq = (rd_vref - 3300) / 521; + } else { + /* MODE_LV[2:0] = LPDDR4 (Range 1)*/ + vref_mode_dq = 0x6; + vref_value_dq = (rd_vref - 15300) / 521; + } vref_mode_ac = 0x6; vref_value_ac = 0x1f; mode_sel = 0x6; @@ -770,7 +779,7 @@ static void set_ds_odt(const struct chan_info *chan, /* phy_pad_fdbk_term 1bit DENALI_PHY_930 offset_17 */ clrsetbits_le32(&denali_phy[930], 0x1 << 17, reg_value); - phy_io_config(chan, params); + phy_io_config(chan, params, mr5); } static void pctl_start(struct dram_info *dram, u8 channel)