From patchwork Mon Jul 15 18:28:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jagan Teki X-Patchwork-Id: 735 Return-Path: X-Original-To: linux-amarula@patchwork.amarulasolutions.com Delivered-To: linux-amarula@patchwork.amarulasolutions.com Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by ganimede.amarulasolutions.com (Postfix) with ESMTPS id 28A603F08F for ; Mon, 15 Jul 2019 20:29:28 +0200 (CEST) Received: by mail-pl1-f199.google.com with SMTP id o6sf8699353plk.23 for ; Mon, 15 Jul 2019 11:29:28 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1563215367; cv=pass; d=google.com; s=arc-20160816; b=I0eK3Cb3ek9RRc493EG7gDsI3/1dPoe2E+EA0EE+56hhOntXP6U8YW7m+Brf9Rv3UB U6ecA18Nv9TNcr2JAit7GCJAAMYZkJwj23EFmgHSHSDVLhd3+QIFC167/7hQFvBInsME WmLg93dm+CmTcTVaAXlP1LbDmHoVjxrXziSAEz2dXk5ft8qToGbXVfaFi1YdGU6OaTf5 J3d/i4zqvrGgEIyXMBlf3lHwepNvB8p0LIackWvBae45O4FRt5MGQ7AH5cda4OzdvI7q AuLMuHBvSK7P08eCU7vQQF9zww9Q1y7A5je0ssk9BsstKyPVVzX7EQ3NJYY8EED5gdKO J+Pg== 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=KLM1QMiCrSYn2ccrNHgj+RTck1v7nkuk+ZeYMmwS4OM=; b=Y5O0RYj14h/Qp7y+C13hCF6wUvLXZ+lpHTb1/Ks4sCkv2mBPzqH6cKD8k1ERUgRNAo +ez0DPRPhn3v5oh8W5+J8LOuc4m9J1xMAtjqrcFYVEiMGaHzZO72r1KPFnrxC6Q+uXfR mA87wJRq/xemBWNULOT0qRmrCsmzEEhrgIet0k3lO7iNx6WYrfGkVOFzZfzUuFOZ/URF BbjO6QKTUjVhRKARBDDBI9kCF61Q/th1R8vPX14blQj4+kCDeL4BR4XSHJaUAoLga1ha LQEK+N8+8ym5zBFvDJkQqpnbtq2fVO776UlWM5Bq9pznydyZBaVJ/+yexVRWhvKCZcbS beug== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Tat/u98o"; 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=KLM1QMiCrSYn2ccrNHgj+RTck1v7nkuk+ZeYMmwS4OM=; b=MOyyE8gCw7ghhHLwzJU4+cVEXK9ylessdZ7NdeGmac51vpwLMDDqBINm5swNpvcbSP DohIcmj345F126/vyS0VY9o3xsJOxt7pS7l8zS2f/R9Hvmv3rI5FSxKHiWirgRgdRuQY xOm7d2rKHghCJXwtsjRQDeOSZRtOBu7mKhzJc= 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=KLM1QMiCrSYn2ccrNHgj+RTck1v7nkuk+ZeYMmwS4OM=; b=f3mgM9s4tc1yP5C07b0Jo1we8WjJyNrKYuLalm5ihj3csc5wfPkvdd1ULlw5iJ3Q49 AVVkyWGleaqfwXpmt82m/jYLo8DLNkObczzym+mHrYpf7TevhXlzGhhnn2kgFsbkmkRU COzmUG2TBa/83Gkhqt7MY7NHl8+sCkEaJF1ofKOhNfETIqsoSaVW5BFAki9x7DSwFRZm uMsDUQkV1n7aUXQ1csicOJXipkRjFKd4XxY63PBXTVSA0lyAjRXF9UIbZ4AtkVHq8vXD WjCQ8Xw9RX/ICaUPA086cxV7m02mk5f7vcFcSZwvTlhv11Wd+1dDj6JfzpmQ0I07Kret 6krg== X-Gm-Message-State: APjAAAWavZXZ05JCq6yLIhBIm3XfORq17WHqL7t0V97KbdUE3E0QeRQP ON1snZ8hsXXrqej2fwBftua7ntMP X-Google-Smtp-Source: APXvYqwN8QdxvUCHCDR+K17GBPJf6KibML3/QE2D5IgqBQ3xdaATK9ZcDCyFvrMljLaNJs29Ikii1w== X-Received: by 2002:a17:90a:db52:: with SMTP id u18mr31043960pjx.107.1563215366964; Mon, 15 Jul 2019 11:29:26 -0700 (PDT) X-BeenThere: linux-amarula@amarulasolutions.com Received: by 2002:a65:614e:: with SMTP id o14ls2983631pgv.7.gmail; Mon, 15 Jul 2019 11:29:26 -0700 (PDT) X-Received: by 2002:a63:6f8f:: with SMTP id k137mr28356138pgc.90.1563215366612; Mon, 15 Jul 2019 11:29:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563215366; cv=none; d=google.com; s=arc-20160816; b=nRW3KWqpLgC7lHuo1UoHMI8s+FvelSqWogkYw0Whr/QJOwslJL/Y7iwr+Gr1sWgQ5d 73Z5v/TwHK+Mevfm4/tJYGwVPSeWcbgyO4Bgto8UOrwbjT7Cs0P4HNx/izFaH4KG+Zat O15w4t3JDOg9SzsRp+/NiS7bdaB+IxyjT7IoLGFRMvO44P1Ecw71lSAsnjTmidMiApDo wnVcCTiyZFnUFi945/N4ctvkKZyn7RTFKnrOfWVMFhfAXKLLadJB3RxOhy5hAfdm2mkS bSkQjO0FthZbP0YKPrYsWnU+EGTYA3f/2R1VPfz3r9scMinMGPrgTa1iDvc0hPpIHfOy YSOQ== 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=uXXBkPZwOdhHsGqVX2Jarm/YH+B2FAJpIkLEG7ZU9Pk=; b=vh15ZcdnFreS9v5K9BiiOTTNJdgKIRs9a/tZ377/wzoVc/2ybvi58R4JhusBBCQSgX Jdc4XFXA1afg5lUQxRTE6SeuoZiic1vHQSTAMfDVNZbvMelDSAvglRb5JmhRRtkJS04Z IdTEn44+dZ7MIESdUJ+mVpIJ6O8nmFyCfq6WtnVr3WTVrYiuluyT6j15ziAwIP4lUlpK XShlBzI5C/mfWiUy1RXB3Pcmodo4hPxi8NcX+QILHPP5TzEYf9Cblcv3MYl8qyMNFP2J VS8Weu6SRnU4B8G6uZiY86Oj6wdamOTj6DrDALqrALEGjRHioZ5S+2fsmZoQjKdxumvy U+XA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@amarulasolutions.com header.s=google header.b="Tat/u98o"; 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 f89sor21947873plb.5.2019.07.15.11.29.26 for (Google Transport Security); Mon, 15 Jul 2019 11:29:26 -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:902:744c:: with SMTP id e12mr29734884plt.287.1563215366319; Mon, 15 Jul 2019 11:29:26 -0700 (PDT) Received: from localhost.localdomain ([49.206.201.107]) by smtp.gmail.com with ESMTPSA id y133sm20250075pfb.28.2019.07.15.11.29.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Jul 2019 11:29:25 -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 05/18] ram: rk3399: Add phy pctrl reset support Date: Mon, 15 Jul 2019 23:58:43 +0530 Message-Id: <20190715182856.21688-6-jagan@amarulasolutions.com> X-Mailer: git-send-email 2.18.0.321.gffc6fa0e3 In-Reply-To: <20190715182856.21688-1-jagan@amarulasolutions.com> References: <20190715182856.21688-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="Tat/u98o"; 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 Reviewed-by: Kever Yang --- 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 16bd9427a6..a5da985e1a 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) { @@ -1129,6 +1156,7 @@ static int sdram_init(struct dram_info *dram, { unsigned char dramtype = params->base.dramtype; unsigned int ddr_freq = params->base.ddr_freq; + struct rk3399_cru *cru = dram->cru; int channel; int ret; @@ -1145,6 +1173,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 >= params->base.num_channels)