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 36DD2C77B76 for ; Mon, 17 Apr 2023 20:27:46 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4B2E485FAC; Mon, 17 Apr 2023 22:27:44 +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="SW5UG2KS"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id CA1C285FD0; Mon, 17 Apr 2023 22:27:42 +0200 (CEST) Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [IPv6:2001:67c:2050:0:465::101]) (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 4B64185F7B for ; Mon, 17 Apr 2023 22:27:40 +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 smtp2.mailbox.org (unknown [10.196.197.2]) (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-101.mailbox.org (Postfix) with ESMTPS id 4Q0ds63SFvz9sc8; Mon, 17 Apr 2023 22:27:38 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mailbox.org; s=mail20150812; t=1681763258; 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=DP81358xv+kFDCvGLGV26p8PsPeb9eUVLz9wXk+J6as=; b=SW5UG2KSO+3CyYI7RFlPHSVtIyDOw/aDG0ahngPn+xn8ndWoclNqRKVNYjED4DiEsPJZin exIW80jW4qmztd7P3H2al7559ucR+UYRJh1LcPUq06mbbIVvgj2+TXHKZbCNgPKyYjKo+w V27CD33KTMRFWtQgi/J8JG8KIRzjiy25KAgZMtZKh2FgqOKZbIpy3hQa9NuLXsWmnuTLiN 0dVsqLJzwHs0lHQdxu6t89BcXovIoE/XC7RmZYlCWtoxoCyOoQ8RVvH8HkvVx7ywnpOWNc RMoZYRrF7fbeAjyeC1AvwqNe6a8BI9aY6lx89WPBrGZ3DKkBJq3jESTSQBdFjg== Message-ID: <90bc0c55-a8d7-0603-0f14-e09b5704a936@mailbox.org> Date: Mon, 17 Apr 2023 22:27:37 +0200 MIME-Version: 1.0 Subject: Re: [PATCH v4 08/10] board: schneider: add RZN1 board support Content-Language: en-US To: Ralph Siemsen Cc: u-boot@lists.denx.de, Chris Packham References: <20230308202653.1926303-1-ralph.siemsen@linaro.org> <20230308202653.1926303-9-ralph.siemsen@linaro.org> <3a8dc96b-c3e4-b0e2-24d4-c9b4c35dda92@mailbox.org> <20230417194537.GF642444@maple.netwinder.org> From: Marek Vasut In-Reply-To: <20230417194537.GF642444@maple.netwinder.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-MBO-RS-META: 1fx8dx1h8ktparo9y5q3wfja6cqrnphi X-MBO-RS-ID: f7d8fd10aab0a8dd8ee 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/17/23 21:45, Ralph Siemsen wrote: > On Mon, Apr 17, 2023 at 07:18:46PM +0200, Marek Vasut wrote: >> On 3/8/23 21:26, Ralph Siemsen wrote: >>> diff --git a/board/schneider/rzn1-snarc/ddr_timing.c >>> b/board/schneider/rzn1-snarc/ddr_timing.c >>> new file mode 100644 >>> index 0000000000..8bc3fe7be4 >>> --- /dev/null >>> +++ b/board/schneider/rzn1-snarc/ddr_timing.c >>> @@ -0,0 +1,140 @@ >>> +// SPDX-License-Identifier: GPL-2.0 >>> + >>> +#include >>> + >>> +#include "jedec_ddr3_2g_x16_1333h_500_cl8.h" >>> + >>> +u32 ddr_00_87_async[] = { >> >> Should this be 'static u32...' ? > > It should, but there is bit of kludge going on here. This table is used > when starting the DDR controller, in drivers/ram/cadence/ddr_async.c > > There are several other boards in u-boot already which appear to use the > same (or a similar) DDR controller from Cadence. Some of these also use > a similar kludge as I have done. Others instead put the DDR parameters > into the device tree. The DT alternative would be nice indeed. > While using the devicetree is cleaner, it does increase the size of the > DTB by quite a bit, which creates some additional challenges. Even more > so when you need to support multiple DDR chips, each with their own > configuration parameters. Hmmm, stm32mp15xx does use the DT this way, indeed. I don't suppose one can calculate those register values from some input parameters (like, properties of the DRAM chip(s), bus, etc.) ? It might be better to not expose the table itself, but provide some sort of accessor function. In the worst case, add a comment to explain this table is used elsewhere. > So I opted for the low-tech approach, at least in this initial version. > >>> +#define               DENALI_CTL_00_DATA 0x00000600 >> >> You might want to run checkpatch --f --fix --fix-inplace on this to >> fix formatting , esp. use one space after #define and tab after the >> macro name. Note that diff -wdb will let you diff updates to this file >> while ignoring space changes. >> >>> +#define               DENALI_CTL_01_DATA 0x00000000 >>> +#define               DENALI_CTL_02_DATA 0x00000000 >>> +#define               DENALI_CTL_03_DATA 0x00000000 >>> +#define               DENALI_CTL_04_DATA 0x00000000 > > I had also considered eliminating the header file entirely, and just > putting the values directly into the array in the .c file. It is not > like the names of the #defines are particularly illuminating. > > However, this runs into friction each time a new DDR appears, along with > the new set of parameters (autogenerated by some vendor tool). In fact > I've had to add some new DDR devices quite recently (but that didn't > make it into the current patches). > > I'm happy to reformat this to match upstream preference. But I would > also be happy to discuss how we can better handle this type of "large > binary blob" of configuration data, to make it simpler for everyone. NXP has the same problem on MX8M* , large tables of binary goo. I think the best option would be to figure out how to calculate those values based on input properties of the DRAM chips/bus/... , but while that would be fantastic to have, that would be also a LOT of effort . If you have the willpower to do it, woohoo ! Else, see above for low-tech options. [...]