From patchwork Tue Jul 16 11:57:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 800 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 ED7EF3F08F for ; Tue, 16 Jul 2019 14:01:00 +0200 (CEST) Received: by mail-pf1-f198.google.com with SMTP id d190sf12229089pfa.0 for ; Tue, 16 Jul 2019 05:01:00 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1563278459; cv=pass; d=google.com; s=arc-20160816; b=q/PX3buZB/ClouA4qaCJ8Ot5yJtAcz7TOyLt6ANLGz5kjp7pM8CpLrTjvC0Z603JUp d+xlyubSB6JSwAUhwTkhZwi6PdmybgWhqqN823KnurntbYe8MfOLmcsHXaZ1QyYohfC0 Lc3y+niSC0a2TVEEILI7HvXzNioXwfqYccgTarOEj7QPoFEHuXw1KF+2B0Mqpu3P/dux G0zH1tM6Ul9Ux4y9xBeEMacOzej35793sXedZ+9K6E9YKjtkrwnB+638u4NhZMoi4Uzv sNx9XRDz+d4wCyMQhNxwtZTMYfqabi9PsLUTHUUS6KbB/GkRisUFbcCpJl1ua0Ia9Rup 938Q== 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=bS1aZ7AkBN4OVQ2WFFjxbmUh9ERf4SkjMJaZacAYQlc=; b=SoaSgCXKeBtD17TB02Oy6NAuDAcD6QB8sCBdP/C6xqdM+iwGI6BW0bqWYXPlT3IvmQ VUkhFKUdF4SSlQEr07qpkRtDzp5839oHzcmPR4lZja1k3eDT4nL/Bzwera8lDP3oEXkJ 0BnCbW5tCy+1j6K1JbdPrpx0l41rAQy2MhmNwK5XY3FXKlINfatf8pi2IFa1Ck7rbxdx CCRFXzjMOwqXsdTRwNSGW9u2Bk9RfNSCfNLnoUxCwDsTGJuiCX9tgZePHABTYrgnO4iq eiKapHG0Sqyuyb8bflmo490j4tFWLvjFKgoyk1YHSLLf7xlQWfQXdRjUasbu4rp/wgwF f2IA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=di7gqCHb; 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=bS1aZ7AkBN4OVQ2WFFjxbmUh9ERf4SkjMJaZacAYQlc=; b=Rqb38z+7i1S8cYi+1vGkMBCF+jERkGuuSjBf9pFhCaUbDOQ6RIhIa1FbOxkpro5y38 iVaoAgTmbZCAVd1BUZ+8oalcxe5qmlxcnuRkZA7L6BRtx4zWNuItIWhasTUGhM6aRFlv +3MoKU5LzBkO1bDPYgy8qjdeTNp5V3Ii/xhAc= 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=bS1aZ7AkBN4OVQ2WFFjxbmUh9ERf4SkjMJaZacAYQlc=; b=VnIcwa2eIMYknJKZ/T5SXhJznv39b/VSbiO9zbH6VkGyZPiBDSYFLtuhpf3UxQUSJ8 1X5W58GCH29B91Ybh0rGhhQlTR2PQ3mV3BLkOwfQic5BQ24bBlM+o/9O83COncKUHS/o /9oKaHjV3YjieSaKitXmHghWqu+BEZ6dSjeT+IwzjH+OoG87OnfG5hUxIcUdW7bpTeOW 3vNfi3CrFgQdgf8YS08qZgbi0ZrRjtkdn+7YtIbW3/cPqgQ0qJXcCaNtyENAgLymh10z JvSrxpla418EHx6W+UGZ3Makg8ctsSrR/kE+0xA9EaJugHVBL7vyCOX1RzE/PMg0wmqy PnXQ== X-Gm-Message-State: APjAAAXnKYoLk/G9WdZfwn/nCPolHLLhyrKplDr0eBRFd/Z1NBi/5+8Z xWprFeBF0on6piB6XQLvj610+aOQ X-Google-Smtp-Source: APXvYqwq+/GWIPvXX3kN2DrRFkhi50g3gUXh7vfBvDBebQ+kJgMqmKKrEPWF0zRa5iwLPmtCmDLW/w== X-Received: by 2002:a17:902:6b07:: with SMTP id o7mr33963990plk.180.1563278459794; Tue, 16 Jul 2019 05:00:59 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a17:902:6b81:: with SMTP id p1ls4223601plk.6.gmail; Tue, 16 Jul 2019 05:00:59 -0700 (PDT) X-Received: by 2002:a17:90a:20a2:: with SMTP id f31mr35417806pjg.90.1563278459469; Tue, 16 Jul 2019 05:00:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563278459; cv=none; d=google.com; s=arc-20160816; b=pal/rfAz6ZeUVPMjFbgwAkX98bVxfusaBMped4rg1LwtFiqOjAkTxELSQ0Zxa35g9y cUwFgq6TNJVHcj4wbVlxSyqs60NQbdK6M3zGHH9h73ke2qwk5/ndy1RS3KsjRhZocTWv kAFXlg3WDcFm0jWWyAndXP9EwQvP5sPOVPTWxeG9CJa4NAWpWSGxXospxLwvaBQAb+7d fU5UaPV4lLt8L5kZNaHWHeoBSY0ffSYR89VLNl79DwiWB6T7uqA1Xh3i22/B0xrlHVDo ipnGN5q0lnIM2aMDSFaiBtFOZbORzyGMOox1piPFugJYblA2+Lj7PkLku1FjwbRvvhcr 6k7g== 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=tLU23iC3mbZxkYNZeu/wIpO3JnN1O59AxLAw5YnqE/U=; b=iA/82n7nMnQEcMLCNzTT6+NL1c9rgHabvHNA4DEOdgrGQj3a7C++ZWg24ToAbxYexd 67mATJuq8V7bY6ruMk6Y++GAJfs9sBiPzuMpT25KlqN4cerzBjmOSlY0EFnibVKBRFM3 2+vdKz3Iu4RqPrdQQV36gW0oelBF25XIrXD+FY1DwkV8Wex5X3qabPq0RXGcHi+OpanX Klv/xAtkBjAX28oQm8ICjFiOF0+eybulu8bvnsb84VFX338xspoN/MIHspZqTlICcZC9 cko56X2k+5kf0ociV6MeDx6JG+vGw6n8BiTqputlKMd6pwyi+bWKQMyd+x1V6zopdZje 1I5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=di7gqCHb; 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 o11sor24085487plk.18.2019.07.16.05.00.59 for (Google Transport Security); Tue, 16 Jul 2019 05:00:59 -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:90a:fa07:: with SMTP id cm7mr34723259pjb.138.1563278459147; Tue, 16 Jul 2019 05:00:59 -0700 (PDT) Received: from localhost.localdomain ([49.206.201.107]) by smtp.gmail.com with ESMTPSA id z24sm36269566pfr.51.2019.07.16.05.00.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 16 Jul 2019 05:00:58 -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 51/57] ram: rk3399: Add set_rate sdram rk3399 ops Date: Tue, 16 Jul 2019 17:27:39 +0530 Message-Id: <20190716115745.12585-52-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=di7gqCHb; 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: , DDR set rate can be even required for lpddr4 and we need to keep the lpddr4 code to compile only for relevant boards which do support lpddr4. For this requirement, and for code readability handle data training via sdram_rk3399_ops with .set_rate and same will update in future while supporting lpddr4 code. Signed-off-by: Jagan Teki Reviewed-by: Kever Yang --- drivers/ram/rockchip/sdram_rk3399.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index 623685e3c5..c3d7665ea2 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -74,6 +74,8 @@ struct dram_info { struct sdram_rk3399_ops { int (*data_training)(struct dram_info *dram, u32 channel, u8 rank, struct rk3399_sdram_params *sdram); + int (*set_rate)(struct dram_info *dram, + const struct rk3399_sdram_params *params); }; #if defined(CONFIG_TPL_BUILD) || \ @@ -948,6 +950,7 @@ static int pctl_cfg(struct dram_info *dram, const struct chan_info *chan, return 0; } +#if !defined(CONFIG_RAM_RK3399_LPDDR4) static void select_per_cs_training_index(const struct chan_info *chan, u32 rank) { @@ -1368,6 +1371,7 @@ static int data_training(struct dram_info *dram, u32 channel, return 0; } +#endif static void set_ddrconfig(const struct chan_info *chan, const struct rk3399_sdram_params *params, @@ -1487,7 +1491,6 @@ static int default_data_training(struct dram_info *dram, u32 channel, u8 rank, return data_training(dram, channel, params, training_flag); } -#endif static int switch_to_phy_index1(struct dram_info *dram, const struct rk3399_sdram_params *params) @@ -1534,7 +1537,8 @@ static int switch_to_phy_index1(struct dram_info *dram, return 0; } -#if defined(CONFIG_RAM_RK3399_LPDDR4) +#else + static u32 get_ddr_stride(struct rk3399_pmusgrf_regs *pmusgrf) { return ((readl(&pmusgrf->soc_con4) >> 10) & 0x1F); @@ -1938,7 +1942,7 @@ static int sdram_init(struct dram_info *dram, params->base.stride = calculate_stride(params); dram_all_config(dram, params); - switch_to_phy_index1(dram, params); + dram->ops->set_rate(dram, params); debug("Finish SDRAM initialization...\n"); return 0; @@ -1986,6 +1990,7 @@ static int conv_of_platdata(struct udevice *dev) static const struct sdram_rk3399_ops rk3399_ops = { #if !defined(CONFIG_RAM_RK3399_LPDDR4) .data_training = default_data_training, + .set_rate = switch_to_phy_index1, #else .data_training = lpddr4_mr_detect, #endif