From patchwork Fri Dec 20 20:28:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tom Hebb X-Patchwork-Id: 1214303 X-Patchwork-Delegate: ykai007@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QmGO/azy"; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47fgLg68Hmz9sPJ for ; Sat, 21 Dec 2019 07:28:40 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4FF9580E8D; Fri, 20 Dec 2019 21:28:27 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="QmGO/azy"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 293898163B; Fri, 20 Dec 2019 21:28:25 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mail-pj1-x1042.google.com (mail-pj1-x1042.google.com [IPv6:2607:f8b0:4864:20::1042]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 1573D803C3 for ; Fri, 20 Dec 2019 21:28:21 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=tommyhebb@gmail.com Received: by mail-pj1-x1042.google.com with SMTP id m13so4630003pjb.2 for ; Fri, 20 Dec 2019 12:28:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=nUUFUIUvcdy/7kAvmVWX8kUmySy2fK0yms8tZDHJpX4=; b=QmGO/azyos2zRjXWdKvPvSJIx5OvVRvTuObnJdm9B2lO6y/uoizOFwu/RMUGm7s4Ly EAfSmNKA6CVUvcg+cwIgZC+sjoPoWdqNoHRnrOTvp2eN3MxYxyJqHW2rI/rmbklfW0I0 YXaVwEiDKszS5/pPmzE7+wp6PD5kkt2v0vVDcjIpgt1DdkdAni3on86sp5kb7++zzw3X q0DPlr6IjNBcdK0tfrwn6BjwEydBdOU41JyYxuS9tweiC9LeyJRoFriZUErKnbGmZpoT A0LohXAIFMd8glNjGGo8vgQoqbM+DgdZw9OYpzz2vseDBBECYyt7bx0Az4x2YOmwPYrT 9Buw== 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:mime-version :content-transfer-encoding; bh=nUUFUIUvcdy/7kAvmVWX8kUmySy2fK0yms8tZDHJpX4=; b=W+kJyCK4yxfk1bEENvcZ4Zh+mHtLLZ/S70f8XsJ7XQqyOke2qWWCN5w9YvmzsVjUHm wErtluzY6HW69uLIamtWpxn9D4K7vMfhnatj3bXebabNdl+VwXzmfZmjZfqWzSFAs2Ou Xed5goN6DjTL33UQYjYL6X4usNqvx+J6tTh8L4J4S7KU4AhFkaPsHZQ7eiz9XLc2Z2wD EwHF2HF6QAMqvlKt/uqS6ZuLOjSO89oQ+ObsS2yvEuCHSIOi0KW0B29GNzvNGNd+VI7m gMc6T6un0LdSOtF0GNu4azr4uZjZjB7qfadg6JE9B4jkc35gKLa4drDRb8z7bCoNhza+ 9plg== X-Gm-Message-State: APjAAAXLq2aSAYwr465eF/weL5HNU+PcisZlslDIXiDo3SUzKDAQdNdg wC7AcZjodTnvhAgGHf2EJgrcQtCvVnjTtA== X-Google-Smtp-Source: APXvYqwovOJV1JYC6Wozt012zMmR1Z2MhJhIO07zJHDmNtgEEH0vXasC96uXs6yTCL0UVQw7HWu8iA== X-Received: by 2002:a17:90a:db49:: with SMTP id u9mr17742079pjx.13.1576873699813; Fri, 20 Dec 2019 12:28:19 -0800 (PST) Received: from glados.lan ([2601:647:4c01:6541:fa16:54ff:fed1:1bd6]) by smtp.gmail.com with ESMTPSA id o16sm12250621pgl.58.2019.12.20.12.28.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Dec 2019 12:28:19 -0800 (PST) From: Thomas Hebb To: u-boot@lists.denx.de Subject: [PATCH] ram: rk3399: don't assume phy_io_config() uses real regs Date: Fri, 20 Dec 2019 12:28:15 -0800 Message-Id: X-Mailer: git-send-email 2.24.1 MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean In the RK3399 DRAM driver, the function set_ds_odt() supports operating in two different modes, selected by the ctl_phy_reg argument: when true, the function reads and writes directly from the DRAM registers, accessed through "chan->pctl->denali_*"; when false, the function reads and writes from an array, accessed through "params->pctl_regs.denali_*", which is written to DRAM registers at a later time. However, phy_config_io(), which is called by set_ds_odt() to do a subset of its register operations, operates directly on DRAM registers at all times. This means that it reads incorrect values (and writes new values prematurely) when ctl_phy_reg in set_ds_odt() is false. Fix this by passing in the address of the registers to work with. This prevents an "Invalid DRV value" error in the SPL debug log and (presumably) results in a more correct end state. See the following logs from a RK3399 NanoPi M4 board (4GB LPDDR3): Before: sdram_init() Starting SDRAM initialization... phy_io_config() Invalid DRV value. phy_io_config() Invalid DRV value. sdram_init() sdram_init: data trained for rank 2, ch 0 phy_io_config() Invalid DRV value. phy_io_config() Invalid DRV value. sdram_init() sdram_init: data trained for rank 2, ch 1 Channel 0: LPDDR3, 933MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: LPDDR3, 933MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride 256B stride sdram_init() Finish SDRAM initialization... After: sdram_init() Starting SDRAM initialization... sdram_init() sdram_init: data trained for rank 2, ch 0 sdram_init() sdram_init: data trained for rank 2, ch 1 Channel 0: LPDDR3, 933MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB Channel 1: LPDDR3, 933MHz BW=32 Col=10 Bk=8 CS0 Row=15 CS1 Row=15 CS=2 Die BW=16 Size=2048MB 256B stride 256B stride sdram_init() Finish SDRAM initialization... Signed-off-by: Thomas Hebb Reviewed-by: Kever Yang --- drivers/ram/rockchip/sdram_rk3399.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/ram/rockchip/sdram_rk3399.c b/drivers/ram/rockchip/sdram_rk3399.c index aa2ea920ba..9e61641511 100644 --- a/drivers/ram/rockchip/sdram_rk3399.c +++ b/drivers/ram/rockchip/sdram_rk3399.c @@ -337,11 +337,9 @@ static void set_memory_map(const struct chan_info *chan, u32 channel, writel(0x2EC7FFFF, &denali_pi[34]); } -static int phy_io_config(const struct chan_info *chan, +static int phy_io_config(u32 *denali_phy, u32 *denali_ctl, const struct rk3399_sdram_params *params, u32 mr5) { - u32 *denali_phy = chan->publ->denali_phy; - u32 *denali_ctl = chan->pctl->denali_ctl; u32 vref_mode_dq, vref_value_dq, vref_mode_ac, vref_value_ac; u32 mode_sel; u32 speed; @@ -780,7 +778,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, mr5); + phy_io_config(denali_phy, denali_ctl, params, mr5); } static void pctl_start(struct dram_info *dram,