Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id D4FBDC77B7C for ; Sun, 7 May 2023 16:13:25 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id BEF9084693; Sun, 7 May 2023 18:12:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; secure) header.d=mailbox.org header.i=@mailbox.org header.b="r1BKPQAl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id C06BA846A5; Sun, 7 May 2023 18:12:29 +0200 (CEST) Received: from mout-p-103.mailbox.org (mout-p-103.mailbox.org [80.241.56.161]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 7CD4D8468D for ; Sun, 7 May 2023 18:12:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=mailbox.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=marek.vasut@mailbox.org Received: from smtp1.mailbox.org (smtp1.mailbox.org [IPv6:2001:67c:2050:b231:465::1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-103.mailbox.org (Postfix) with ESMTPS id 4QDqFP4J42z9sdQ; Sun, 7 May 2023 18:12:25 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1683475945; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=o1Pfava5v+ps2VOu0V2M6JSQgYhDuJPD+2IVzZy2ir0=; b=r1BKPQAlt3sZgkGLQc7npqsCI/8cPnMGgEF1brf0YTSHdYK2Qd4HW8GG9PJWaBKk4k4w9V r7HDvYAuBsTqN2e1AEpGp64iWFQW/LR+30AV7Wbp6floSu8EGYictnF6CNIpxcoAIF69D7 JfmO+XsjXx//qsmY63sd0VrY6sD4XdcixCU0sENOjVHU8zA8AB/JMfC45L2zsK1mRp85vE ZlVixIfdn4sCXuVoU77ochDrymM5mR0dPmjzMQgGsfjAKjKWQ4am0w7OJiQUop8R7K+Gsf dGY31gB3fjINxX+FEsfn6fp8DzznXnMXnkfr3N7VJb1CBIvu5s1EhjWYwo1RHw== Message-ID: <068b253c-b813-e918-dec0-741afc60da97@mailbox.org> Date: Sun, 7 May 2023 18:06:40 +0200 MIME-Version: 1.0 Subject: Re: [PATCH v5 08/10] board: schneider: add RZN1 board support Content-Language: en-US To: Ralph Siemsen , u-boot@lists.denx.de Cc: Chris Packham References: <20230424011515.1359255-1-ralph.siemsen@linaro.org> <20230424011515.1359255-9-ralph.siemsen@linaro.org> From: Marek Vasut In-Reply-To: <20230424011515.1359255-9-ralph.siemsen@linaro.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-MBO-RS-ID: 680c6b0d3afe53493bf X-MBO-RS-META: pyrto1m4pj3azttrd8wudg39k3nyrb3n X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.8 at phobos.denx.de X-Virus-Status: Clean On 4/24/23 03:15, Ralph Siemsen wrote: > Add support for Schneider Electronics RZ/N1D and RZ/N1S boards, which > are based on the Reneasas RZ/N1 SoC devices. > > The intention is to support both boards using a single defconfig, and to > handle the differences at runtime. The DT comes from Linux kernel, right ? Please include commit ID from which the DT is imported in the commit message, I suspect that would be Linux 6.3 commit ID. [...] > diff --git a/board/schneider/rzn1-snarc/ddr_async.c b/board/schneider/rzn1-snarc/ddr_async.c > new file mode 100644 > index 0000000000..4b4c280e45 > --- /dev/null > +++ b/board/schneider/rzn1-snarc/ddr_async.c Please correct me if I'm wrong, but shouldn't this be in drivers/ram/ ? [...] > +/* DDR PHY setup */ > +static void ddr_phy_init(struct cadence_ddr_info *priv, int ddr_type) > +{ > + u32 val; > + > + /* Disable DDR Controller clock and FlexWAY connection */ > + clk_disable(&priv->hclk_ddrc); > + clk_disable(&priv->clk_ddrc); > + > + clk_rzn1_reset_state(&priv->hclk_ddrc, 0); > + clk_rzn1_reset_state(&priv->clk_ddrc, 0); > + > + /* Enable DDR Controller clock and FlexWAY connection */ > + clk_enable(&priv->clk_ddrc); > + clk_enable(&priv->hclk_ddrc); > + > + /* DDR PHY Soft reset assert */ > + ddrc_writel(FUNCCTRL_MASKSDLOFS | FUNCCTRL_DVDDQ_1_5V, FUNCCTRL); > + > + clk_rzn1_reset_state(&priv->hclk_ddrc, 1); > + clk_rzn1_reset_state(&priv->clk_ddrc, 1); > + > + /* DDR PHY setup */ > + phy_writel(DLLCTRL_MFSL_500MHz | DLLCTRL_MDLLSTBY, DLLCTRL); > + phy_writel(0x00000182, ZQCALCTRL); > + if (ddr_type == RZN1_DDR3_DUAL_BANK) > + phy_writel(0xAB330031, ZQODTCTRL); > + else if (ddr_type == RZN1_DDR3_SINGLE_BANK) > + phy_writel(0xAB320051, ZQODTCTRL); > + else /* DDR2 */ > + phy_writel(0xAB330071, ZQODTCTRL); > + phy_writel(0xB545B544, RDCTRL); > + phy_writel(0x000000B0, RDTMG); > + phy_writel(0x020A0806, OUTCTRL); > + if (ddr_type == RZN1_DDR3_DUAL_BANK) > + phy_writel(0x80005556, WLCTRL1); > + else > + phy_writel(0x80005C5D, WLCTRL1); > + phy_writel(0x00000101, FIFOINIT); > + phy_writel(0x00004545, DQCALOFS1); > + > + /* Step 9 MDLL reset release */ > + val = phy_readl(DLLCTRL); > + val &= ~DLLCTRL_MDLLSTBY; > + phy_writel(val, DLLCTRL); > + > + /* Step 12 Soft reset release */ > + val = phy_readl(FUNCCTRL); > + val |= FUNCCTRL_RESET_N; > + phy_writel(val, FUNCCTRL); > + > + /* Step 13 FIFO pointer initialize */ > + phy_writel(FIFOINIT_RDPTINITEXE | FIFOINIT_WRPTINITEXE, FIFOINIT); > + > + /* Step 14 Execute ZQ Calibration */ > + val = phy_readl(ZQCALCTRL); > + val |= ZQCALCTRL_ZQCALRSTB; > + phy_writel(val, ZQCALCTRL); > + > + /* Step 15 Wait for 200us or more, or wait for DFIINITCOMPLETE to be "1" */ > + while (!(phy_readl(DLLCTRL) & DLLCTRL_ASDLLOCK)) > + ; Please avoid endless loops, use readl_poll_timeout() or wait_for_bit*() where possible. > + while (!(phy_readl(ZQCALCTRL) & ZQCALCTRL_ZQCALEND)) > + ; > + > + /* Step 16 Enable Address and Command output */ > + val = phy_readl(OUTCTRL); > + val |= OUTCTRL_ADCMDOE; > + phy_writel(val, OUTCTRL); > + > + /* Step 17 Wait for 200us or more(from MRESETB=0) */ > + udelay(200); > +} [...] > diff --git a/board/schneider/rzn1-snarc/rzn1.c b/board/schneider/rzn1-snarc/rzn1.c > new file mode 100644 > index 0000000000..6eb86c2592 > --- /dev/null > +++ b/board/schneider/rzn1-snarc/rzn1.c > @@ -0,0 +1,40 @@ > +// SPDX-License-Identifier: GPL-2.0+ > + > +#include > +#include > +#include > +#include > + > +DECLARE_GLOBAL_DATA_PTR; > + > +int board_init(void) > +{ > + /* > + * Initial values for gd->ram_base and gd->ram_size > + * are obtained from the "/memory" node in devicetree. > + * The size will be updated in later when probing DDR. > + */ > + fdtdec_setup_mem_size_base(); Are you absolutely sure this call ^ is needed at all ? > + gd->bd->bi_boot_params = gd->ram_base + 0x100; > + > + return 0; > +} > + > +int dram_init(void) > +{ > + struct udevice *dev; > + int err; > + > + /* > + * This will end up calling cadence_ddr_probe(), > + * and will also update gd->ram_size. > + */ > + err = uclass_get_device(UCLASS_RAM, 0, &dev); > + if (err) { > + debug("DRAM init failed: %d\n", err); You can just do this here: err = uclass...(); if (err) debug(...); return err; > + return err; > + } > + > + return 0; > +} [...] narc.h b/include/configs/rzn1-snarc.h > new file mode 100644 > index 0000000000..dce0de0d4c > --- /dev/null > +++ b/include/configs/rzn1-snarc.h > @@ -0,0 +1,13 @@ > +/* SPDX-License-Identifier: GPL-2.0+ */ > +/* > + * Configuration settings for the Schneider RZ/N1 board > + */ > + > +#ifndef __RZN1_H Better use __RZN1_SNARC_H , so that when other boards get added, there won't be trouble. > +#define __RZN1_H > + > +/* Internal RAM */ > +#define CFG_SYS_INIT_RAM_ADDR 0x20000000 > +#define CFG_SYS_INIT_RAM_SIZE (1 * 1024 * 1024) > + > +#endif /* __RZN1_H */