public inbox for u-boot@lists.denx.de
 help / color / mirror / Atom feed
From: Ralph Siemsen <ralph.siemsen@linaro.org>
To: Marek Vasut <marek.vasut@mailbox.org>
Cc: u-boot@lists.denx.de, Chris Packham <judge.packham@gmail.com>
Subject: Re: [PATCH v4 08/10] board: schneider: add RZN1 board support
Date: Mon, 17 Apr 2023 15:45:37 -0400	[thread overview]
Message-ID: <20230417194537.GF642444@maple.netwinder.org> (raw)
In-Reply-To: <3a8dc96b-c3e4-b0e2-24d4-c9b4c35dda92@mailbox.org>

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 <asm/types.h>
>>+
>>+#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.

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.

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.

>>+++ b/board/schneider/rzn1-snarc/rzn1.c
>>@@ -0,0 +1,39 @@
>>+// SPDX-License-Identifier: GPL-2.0+
>>+
>>+#include <common.h>
>>+#include <dm.h>
>>+#include <asm/global_data.h>
>>+
>>+DECLARE_GLOBAL_DATA_PTR;
>>+
>>+int board_init(void)
>>+{
>>+	gd->bd->bi_boot_params = CFG_SYS_SDRAM_BASE + 0x100;
>>+
>>+	return 0;
>>+}
>>+
>>+int dram_init(void)
>>+{
>>+	struct udevice *dev;
>>+	int err;
>>+
>>+	/* This will end up calling cadence_ddr_probe() */
>>+	err = uclass_get_device(UCLASS_RAM, 0, &dev);
>>+	if (err) {
>>+		debug("DRAM init failed: %d\n", err);
>>+		return err;
>>+	}
>>+
>>+	if (fdtdec_setup_mem_size_base() != 0)
>>+		return -EINVAL;
>>+
>>+	return 0;
>>+}
>>+
>>+int dram_init_banksize(void)
>>+{
>>+	fdtdec_setup_memory_banksize();
>>+
>>+	return 0;
>>+}
>
>I wonder how much of this should really be in arch/... since this is 
>common to all machines with RZN1 . Maybe move it there instead ?

I can certainly do that. When I first put this together, I looked at 
many other dram_init() functions, both in arch/... and board/...

Ralph

  reply	other threads:[~2023-04-17 19:45 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-08 20:26 [PATCH v4 00/10] Renesas RZ/N1 SoC initial support Ralph Siemsen
2023-03-08 20:26 ` [PATCH v4 01/10] ARM: armv7: add non-SPL enable for Cortex SMPEN Ralph Siemsen
2023-04-17 17:04   ` Marek Vasut
2023-04-17 18:26     ` Ralph Siemsen
2023-04-17 20:21       ` Marek Vasut
2023-04-18 14:32         ` Ralph Siemsen
2023-04-18 19:35           ` Marek Vasut
2023-03-08 20:26 ` [PATCH v4 02/10] clk: renesas: prepare for non-RCAR clock drivers Ralph Siemsen
2023-04-17 17:02   ` Marek Vasut
2023-04-17 18:22     ` Ralph Siemsen
2023-04-17 20:33       ` Marek Vasut
2023-04-17 20:48         ` Ralph Siemsen
2023-04-17 22:24           ` Marek Vasut
2023-03-08 20:26 ` [PATCH v4 03/10] clk: renesas: add R906G032 driver Ralph Siemsen
2023-04-17 17:07   ` Marek Vasut
2023-04-17 18:29     ` Ralph Siemsen
2023-03-08 20:26 ` [PATCH v4 04/10] pinctrl: " Ralph Siemsen
2023-04-17 17:09   ` Marek Vasut
2023-03-08 20:26 ` [PATCH v4 05/10] ram: cadence: add driver for Cadence EDAC Ralph Siemsen
2023-04-17 17:32   ` Marek Vasut
2023-04-17 20:33     ` Ralph Siemsen
2023-03-08 20:26 ` [PATCH v4 06/10] dts: basic devicetree for Renesas RZ/N1 SoC Ralph Siemsen
2023-04-17 17:12   ` Marek Vasut
2023-04-17 18:33     ` Ralph Siemsen
2023-04-17 20:22       ` Marek Vasut
2023-03-08 20:26 ` [PATCH v4 07/10] ARM: rzn1: basic support " Ralph Siemsen
2023-04-17 17:15   ` Marek Vasut
2023-04-17 18:57     ` Ralph Siemsen
2023-04-17 20:30       ` Marek Vasut
2023-04-17 20:44         ` Ralph Siemsen
2023-04-17 22:23           ` Marek Vasut
2023-03-08 20:26 ` [PATCH v4 08/10] board: schneider: add RZN1 board support Ralph Siemsen
2023-04-17 17:18   ` Marek Vasut
2023-04-17 19:45     ` Ralph Siemsen [this message]
2023-04-17 20:27       ` Marek Vasut
2023-03-08 20:26 ` [PATCH v4 09/10] tools: spkgimage: add Renesas SPKG format Ralph Siemsen
2023-04-17 17:23   ` Marek Vasut
2023-04-17 20:17     ` Ralph Siemsen
2023-04-17 20:28       ` Marek Vasut
2023-03-08 20:26 ` [PATCH v4 10/10] doc: renesas: add Renesas board docs Ralph Siemsen
2023-04-17 17:28   ` Marek Vasut
2023-04-17 20:29     ` Ralph Siemsen
2023-04-17 20:34       ` Marek Vasut
2023-04-17 20:50         ` Ralph Siemsen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230417194537.GF642444@maple.netwinder.org \
    --to=ralph.siemsen@linaro.org \
    --cc=judge.packham@gmail.com \
    --cc=marek.vasut@mailbox.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox