From patchwork Tue Jun 11 14:50:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 485 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 3D67E3F08F for ; Tue, 11 Jun 2019 16:54:09 +0200 (CEST) Received: by mail-pl1-f200.google.com with SMTP id s22sf3900587plp.5 for ; Tue, 11 Jun 2019 07:54:09 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1560264848; cv=pass; d=google.com; s=arc-20160816; b=Kp1A/Is27O/3AJKd2lsYfbf6e1+Y6IX0YEmN/YMCE9CDDbtYH64j1TUPiYHjNLivXQ cV+pvNA4IuAgdXHU0dIZswaxjfG1CIL3qSEqmphnPcsxfGOsyKs5C4mZX9ZghPxvyQ2U QvGGEIyVj4Yy82vZJTO/6dEf2Ps8EACMNd3J24Ayu3mJCpzvojaCYlDekD2RkCSCxqwt gq6U9fNFZWK3XtpjsSobNBy0flzizXBjhpyh9+Jh9lYvfYzHvA0uF/T7N2CFK/Y/1RXG pWvzfJFGKqnDONMdiRXA4rMLF83Ethg8tZhjwWVjn3DEaowkOBEZlEvo40qz3F5P+0Vj zvFA== 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=Lqp6TIriUj+Bf1vYgbYsnNI6dGsZo02qVPnemNxb8pw=; b=vEvIf5DpL+yL/eRqWYOGJm7MzgtbUZ+14SLeyNtJiGp/o9G6ODyI5sZI1OOC9fr2bp ekjXqfmEbw9c5ElLV/o0+j+53VRMb423Jwltbo5rQVHBbRPl/F5h8Z1gdfD/T4csJSEc glfXkD4h40NnJK5vlGCbIM+0vpCHG50AhXiP3p5NTS4lS1GpwBIcea4RwD0dHHsdZj6a yZrDhJtm4iMg2KzgO+IyI2ehvIf4jODLg2gtL1apX6YoltEn/TiDJD4eQWshW0ambBIw w0i+5oWEyBCN8g0WXtQkrCtHccvUJlsAulRfd1T+2TSRaB+75TmsaSH5r4ttFurWrOhb ckjQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fWT8VJYS; 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=Lqp6TIriUj+Bf1vYgbYsnNI6dGsZo02qVPnemNxb8pw=; b=f06Dj3wVXubSeIb4XqV4m1Hg06crvZdOkxLd/YKM4wOmSYj05vU7C9UUmQD5Aoa6f7 SOlRUtFI+Z2nDG0r27A9LpXQLwugEw5z3Bw6XIi88cBfJe2CtCcXUwKJ3rnguHaFs+vG 757pn+adijp006vyMgT86yM5TjvMwABMUy4wo= 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=Lqp6TIriUj+Bf1vYgbYsnNI6dGsZo02qVPnemNxb8pw=; b=jwWuUS9RI5PHcpyEtBv5mO+2gxI6BzmJeVw9XpZbdIgnFvpwuPjJ6wMK7TI5HxcAYi IS2rw1DomQZotu1t0IyYZQyGfj8Ojq1zcB2UTbi5x7k+RdNWMMSIPePV9F/mqpsaKiQK gI+ajmqbwaFh/mzEpgDGFFae283mQvQx14jaFS3msEmObcuK4J5Om4kBYApPzNsz0R// OvH5czywF2m2mO8zT/yKfKD1FbMP8XkroyhMR1AjHu+cJCswr3s3dZplLvIGLjn2B2hZ sVYb15Wk7WRQRnwLyGih3vQhOrHGHcjma6MujysObLRLvBwIVJzBjQt+P3zuXwpcAkFw UwAQ== X-Gm-Message-State: APjAAAXjh1nYylpJWlwAOWXwX65BMCWZyM2scebo+x2Vj8CeQE+3YWye OQSo/OouDa3Yw3IuJL/0Mvi2TA39 X-Google-Smtp-Source: APXvYqx4Y5I9QPZGJjK5CdDJEFTbY0fpe7ND35CBH3+G1oQpAtxVvuFnO2mddP0XYCLBD2cTxpJ6nw== X-Received: by 2002:a17:902:7618:: with SMTP id k24mr13986300pll.208.1560264848047; Tue, 11 Jun 2019 07:54:08 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a63:b21:: with SMTP id 33ls4515417pgl.1.gmail; Tue, 11 Jun 2019 07:54:07 -0700 (PDT) X-Received: by 2002:a62:ee04:: with SMTP id e4mr77516161pfi.232.1560264847702; Tue, 11 Jun 2019 07:54:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1560264847; cv=none; d=google.com; s=arc-20160816; b=UYIAUnFbpQeUVbKogwTCQ+jXdNfcxH+D9gGgAqWtw9BmU6QjBFIdIEJrIoVtU1/hOo pFzrXD6EVDzgtOZE5+ByaSHr9d73C33tUJPx/X+Z8i9i6XOGvQNnDpGFE4FPaQYBZMWA pDdFVNnxvi9F8NapNuOV3lgwmMWDybB9fUuXWkuvc1zg6wb4H60ftL+50vRua8xm3ST2 eNeApQea3agWHKVmtQsh5Urp54csF/LmUdxIfBzmNxPP3SuHos/WHkoLS2mlq28A3SgN Upd66Q0+29fky+VwrHU6RcdG0TsuRH2aRlkGizA3wVbkBcNfm/Pkd2yDEF/rnhh04B/z Pn5A== 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=Ckb/dVtuw942Plu9XgJ6pHzs/1bm+A1p+7DNE1ADw90=; b=VTqttnmPt8AgnnVHQwghjEJTpvT68NXlFIMffBiQeqjNyvWS9wLwAG/JrWvecQH9/7 /DxiHDYFfD7CxAy3UavH0tUYPVvLKPevkP14Qk0CwxCvWsKaw+N488d1uBs/CC43FXDR UgPfn1w3bEiFvWAex27bmvMzxSpPzzm9td6n1hzIM5D77B/F57U4GzLv8Rw4jPSCW7da VHdzeuBb9V0Lg+9Jp/9X8zp3LKkgiR2taviTj9aCTB9Gfn7b3voCoQXHx7nzklMWpUpg Lv1TwqzCM1lsyZD5ZBCggmczj2AX13zRQgzNK35Q/cx8cbU7B6/whaZmNA+RDH0uzsq2 riGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b=fWT8VJYS; 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 j9sor11780659pgh.76.2019.06.11.07.54.07 for (Google Transport Security); Tue, 11 Jun 2019 07:54:07 -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:2b8a:: with SMTP id r132mr20451397pgr.196.1560264847320; Tue, 11 Jun 2019 07:54:07 -0700 (PDT) Received: from localhost.localdomain ([115.97.180.18]) by smtp.gmail.com with ESMTPSA id e9sm16206208pfn.154.2019.06.11.07.54.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Jun 2019 07:54:06 -0700 (PDT) From: Jagan Teki To: Simon Glass , Philipp Tomsich , Kever Yang , YouMin Chen , u-boot@lists.denx.de Cc: gajjar04akash@gmail.com, linux-rockchip@lists.infradead.org, linux-amarula@amarulasolutions.com, Jagan Teki Subject: [PATCH 34/92] ram: rk3399: Add phy pctrl reset support Date: Tue, 11 Jun 2019 20:20:37 +0530 Message-Id: <20190611145135.21399-35-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190611145135.21399-1-jagan@amarulasolutions.com> References: <20190611145135.21399-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=fWT8VJYS; 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 support for phy pctrl reset support for both channel 0, 1. Signed-off-by: Jagan Teki Signed-off-by: YouMin Chen --- drivers/ram/rockchip/sdram_rk3399.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index e3945feca3..bbf56f29ae 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -35,6 +35,10 @@ #define PHY_DRV_ODT_40 0xe #define PHY_DRV_ODT_34_3 0xf +#define CRU_SFTRST_DDR_CTRL(ch, n) ((0x1 << (8 + 16 + (ch) * 4)) | \ + ((n) << (8 + (ch) * 4))) +#define CRU_SFTRST_DDR_PHY(ch, n) ((0x1 << (9 + 16 + (ch) * 4)) | \ + ((n) << (9 + (ch) * 4))) struct chan_info { struct rk3399_ddr_pctl_regs *pctl; struct rk3399_ddr_pi_regs *pi; @@ -79,6 +83,29 @@ static void copy_to_reg(u32 *dest, const u32 *src, u32 n) } } +static void rkclk_ddr_reset(struct rk3399_cru *cru, u32 channel, u32 ctl, + u32 phy) +{ + channel &= 0x1; + ctl &= 0x1; + phy &= 0x1; + writel(CRU_SFTRST_DDR_CTRL(channel, ctl) | + CRU_SFTRST_DDR_PHY(channel, phy), + &cru->softrst_con[4]); +} + +static void phy_pctrl_reset(struct rk3399_cru *cru, u32 channel) +{ + rkclk_ddr_reset(cru, channel, 1, 1); + udelay(10); + + rkclk_ddr_reset(cru, channel, 1, 0); + udelay(10); + + rkclk_ddr_reset(cru, channel, 0, 0); + udelay(10); +} + static void phy_dll_bypass_set(struct rk3399_ddr_publ_regs *ddr_publ_regs, u32 freq) { @@ -1126,6 +1153,7 @@ static int sdram_init(struct dram_info *dram, { unsigned char dramtype = sdram_params->base.dramtype; unsigned int ddr_freq = sdram_params->base.ddr_freq; + struct rk3399_cru *cru = dram->cru; int channel; int ret; @@ -1142,6 +1170,7 @@ static int sdram_init(struct dram_info *dram, const struct chan_info *chan = &dram->chan[channel]; struct rk3399_ddr_publ_regs *publ = chan->publ; + phy_pctrl_reset(cru, channel); phy_dll_bypass_set(publ, ddr_freq); if (channel >= sdram_params->base.num_channels)