8522759
From patchwork Wed Aug 10 12:39:26 2022
8522759
Content-Type: text/plain; charset="utf-8"
8522759
MIME-Version: 1.0
8522759
Content-Transfer-Encoding: 7bit
8522759
X-Patchwork-Submitter: Antoine Mazeas <antoine@karthanis.net>
8522759
X-Patchwork-Id: 1665242
8522759
X-Patchwork-Delegate: matthias.bgg@gmail.com
8522759
Return-Path: <u-boot-bounces@lists.denx.de>
8522759
X-Original-To: incoming@patchwork.ozlabs.org
8522759
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
8522759
Authentication-Results: bilbo.ozlabs.org;
8522759
	dkim=pass (1024-bit key;
8522759
 unprotected) header.d=karthanis.net header.i=@karthanis.net
8522759
 header.a=rsa-sha256 header.s=20191114 header.b=mcrC/rnn;
8522759
	dkim-atps=neutral
8522759
Authentication-Results: ozlabs.org;
8522759
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
8522759
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
8522759
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
8522759
Received: from phobos.denx.de (phobos.denx.de
8522759
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
8522759
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
8522759
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
8522759
	(No client certificate requested)
8522759
	by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M2qkM6g8Vz9ryY
8522759
	for <incoming@patchwork.ozlabs.org>; Wed, 10 Aug 2022 22:58:35 +1000 (AEST)
8522759
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
8522759
	by phobos.denx.de (Postfix) with ESMTP id CB5EF842A3;
8522759
	Wed, 10 Aug 2022 14:58:11 +0200 (CEST)
8522759
Authentication-Results: phobos.denx.de;
8522759
 dmarc=pass (p=none dis=none) header.from=karthanis.net
8522759
Authentication-Results: phobos.denx.de;
8522759
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
8522759
Authentication-Results: phobos.denx.de;
8522759
	dkim=pass (1024-bit key;
8522759
 unprotected) header.d=karthanis.net header.i=@karthanis.net
8522759
 header.b="mcrC/rnn";
8522759
	dkim-atps=neutral
8522759
Received: by phobos.denx.de (Postfix, from userid 109)
8522759
 id 4FB14841DC; Wed, 10 Aug 2022 14:40:46 +0200 (CEST)
8522759
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
8522759
X-Spam-Level: 
8522759
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,
8522759
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,
8522759
 T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2
8522759
Received: from smtp-42a9.mail.infomaniak.ch (smtp-42a9.mail.infomaniak.ch
8522759
 [IPv6:2001:1600:3:17::42a9])
8522759
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
8522759
 (No client certificate requested)
8522759
 by phobos.denx.de (Postfix) with ESMTPS id CCC6784084
8522759
 for <u-boot@lists.denx.de>; Wed, 10 Aug 2022 14:40:43 +0200 (CEST)
8522759
Authentication-Results: phobos.denx.de;
8522759
 dmarc=pass (p=none dis=none) header.from=karthanis.net
8522759
Authentication-Results: phobos.denx.de;
8522759
 spf=pass smtp.mailfrom=antoine@karthanis.net
8522759
Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108])
8522759
 by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4M2qKl3S6GzMqbyx;
8522759
 Wed, 10 Aug 2022 14:40:43 +0200 (CEST)
8522759
Received: from localhost.localdomain (unknown [88.168.170.86])
8522759
 by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4M2qKk6qXKzlnSD1;
8522759
 Wed, 10 Aug 2022 14:40:42 +0200 (CEST)
8522759
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=karthanis.net;
8522759
 s=20191114; t=1660135243;
8522759
 bh=YF4GTVv5pqqW0OMrNZFlf0WHnELr1KiKKA02ok/znf4=;
8522759
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
8522759
 b=mcrC/rnnUv3FXlrllL2s9lLTjUEnTuLbiINuyrIQWr2HG3AmCcD11F7n0AypUdePp
8522759
 2XfG1PnZalJa2v3m6/DUWsz6B/cqmYo31h/6HpFeJ4g2i1pEZar7cC+9oScmbjJptV
8522759
 w2oDsFHzyK2oWHUMGFJ4N6bboD8kq3z4WLaH2vrQ=
8522759
From: Antoine Mazeas <antoine@karthanis.net>
8522759
To: u-boot@lists.denx.de
8522759
Cc: Antoine Mazeas <antoine@karthanis.net>,
8522759
 Sjoerd Simons <sjoerd@collabora.com>
8522759
Subject: [PATCH 1/2] rpi: Copy properties from firmware dtb to the loaded dtb
8522759
Date: Wed, 10 Aug 2022 14:39:26 +0200
8522759
Message-Id: <20220810123927.2567677-2-antoine@karthanis.net>
8522759
X-Mailer: git-send-email 2.37.1
8522759
In-Reply-To: <20220810123927.2567677-1-antoine@karthanis.net>
8522759
References: <20220810123927.2567677-1-antoine@karthanis.net>
8522759
MIME-Version: 1.0
8522759
X-Mailman-Approved-At: Wed, 10 Aug 2022 14:58:03 +0200
8522759
X-BeenThere: u-boot@lists.denx.de
8522759
X-Mailman-Version: 2.1.39
8522759
Precedence: list
8522759
List-Id: U-Boot discussion <u-boot.lists.denx.de>
8522759
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
8522759
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
8522759
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
8522759
List-Post: <mailto:u-boot@lists.denx.de>
8522759
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
8522759
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
8522759
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
8522759
Errors-To: u-boot-bounces@lists.denx.de
8522759
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
8522759
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
8522759
X-Virus-Status: Clean
8522759
8522759
The RPI firmware adjusts several property values in the dtb it passes
8522759
to u-boot depending on the board/SoC revision. Inherit some of these
8522759
when u-boot loads a dtb itself. Specificaly copy:
8522759
8522759
* /model: The firmware provides a more specific string
8522759
* /memreserve: The firmware defines a reserved range, better keep it
8522759
* emmc2bus and pcie0 dma-ranges: The C0T revision of the bcm2711 Soc (as
8522759
  present on rpi 400 and some rpi 4B boards) has different values for
8522759
  these then the B0T revision. So these need to be adjusted to boot on
8522759
  these boards
8522759
* blconfig: The firmware defines the memory area where the blconfig
8522759
  stored. Copy those over so it can be enabled.
8522759
* /chosen/kaslr-seed: The firmware generates a kaslr seed, take advantage
8522759
  of that.
8522759
8522759
Signed-off-by: Sjoerd Simons <sjoerd@collabora.com>
8522759
---
8522759
 board/raspberrypi/rpi/rpi.c | 48 +++++++++++++++++++++++++++++++++++++
8522759
 1 file changed, 48 insertions(+)
8522759
8522759
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
8522759
index 17b8108cc8..28b6f52506 100644
8522759
--- a/board/raspberrypi/rpi/rpi.c
8522759
+++ b/board/raspberrypi/rpi/rpi.c
8522759
@@ -504,10 +504,58 @@ void *board_fdt_blob_setup(int *err)
8522759
 	return (void *)fw_dtb_pointer;
8522759
 }
8522759
 
8522759
+int copy_property(void *dst, void *src, char *path, char *property)
8522759
+{
8522759
+	int dst_offset, src_offset;
8522759
+	const fdt32_t *prop;
8522759
+	int len;
8522759
+
8522759
+	src_offset = fdt_path_offset(src, path);
8522759
+	dst_offset = fdt_path_offset(dst, path);
8522759
+
8522759
+	if (src_offset < 0 || dst_offset < 0)
8522759
+		return -1;
8522759
+
8522759
+	prop = fdt_getprop(src, src_offset, property, &len;;
8522759
+	if (!prop)
8522759
+		return -1;
8522759
+
8522759
+	return fdt_setprop(dst, dst_offset, property, prop, len);
8522759
+}
8522759
+
8522759
+/* Copy tweaks from the firmware dtb to the loaded dtb */
8522759
+void  update_fdt_from_fw(void *fdt, void *fw_fdt)
8522759
+{
8522759
+	/* Using dtb from firmware directly; leave it alone */
8522759
+	if (fdt == fw_fdt)
8522759
+		return;
8522759
+
8522759
+	/* The firmware provides a more precie model; so copy that */
8522759
+	copy_property(fdt, fw_fdt, "/", "model");
8522759
+
8522759
+	/* memory reserve as suggested by the firmware */
8522759
+	copy_property(fdt, fw_fdt, "/", "memreserve");
8522759
+
8522759
+	/* Adjust dma-ranges for the SD card and PCI bus as they can depend on
8522759
+	 * the SoC revision
8522759
+	 */
8522759
+	copy_property(fdt, fw_fdt, "emmc2bus", "dma-ranges");
8522759
+	copy_property(fdt, fw_fdt, "pcie0", "dma-ranges");
8522759
+
8522759
+	/* Bootloader configuration template exposes as nvmem */
8522759
+	if (copy_property(fdt, fw_fdt, "blconfig", "reg") == 0)
8522759
+		copy_property(fdt, fw_fdt, "blconfig", "status");
8522759
+
8522759
+	/* kernel address randomisation seed as provided by the firmware */
8522759
+	copy_property(fdt, fw_fdt, "/chosen", "kaslr-seed");
8522759
+}
8522759
+
8522759
 int ft_board_setup(void *blob, struct bd_info *bd)
8522759
 {
8522759
 	int node;
8522759
 
8522759
+	update_fdt_from_fw(blob, (void *)fw_dtb_pointer);
8522759
+
8522759
 	node = fdt_node_offset_by_compatible(blob, -1, "simple-framebuffer");
8522759
 	if (node < 0)
8522759
 		fdt_simplefb_add_node(blob);
8522759
8522759
From patchwork Wed Aug 10 12:39:27 2022
8522759
Content-Type: text/plain; charset="utf-8"
8522759
MIME-Version: 1.0
8522759
Content-Transfer-Encoding: 7bit
8522759
X-Patchwork-Submitter: Antoine Mazeas <antoine@karthanis.net>
8522759
X-Patchwork-Id: 1665243
8522759
X-Patchwork-Delegate: matthias.bgg@gmail.com
8522759
Return-Path: <u-boot-bounces@lists.denx.de>
8522759
X-Original-To: incoming@patchwork.ozlabs.org
8522759
Delivered-To: patchwork-incoming@bilbo.ozlabs.org
8522759
Authentication-Results: bilbo.ozlabs.org;
8522759
	dkim=pass (1024-bit key;
8522759
 unprotected) header.d=karthanis.net header.i=@karthanis.net
8522759
 header.a=rsa-sha256 header.s=20191114 header.b=3Vltv92i;
8522759
	dkim-atps=neutral
8522759
Authentication-Results: ozlabs.org;
8522759
 spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de
8522759
 (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de;
8522759
 envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>)
8522759
Received: from phobos.denx.de (phobos.denx.de
8522759
 [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01])
8522759
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
8522759
	 key-exchange X25519 server-signature RSA-PSS (2048 bits))
8522759
	(No client certificate requested)
8522759
	by bilbo.ozlabs.org (Postfix) with ESMTPS id 4M2qkb5v6sz9ryY
8522759
	for <incoming@patchwork.ozlabs.org>; Wed, 10 Aug 2022 22:58:47 +1000 (AEST)
8522759
Received: from h2850616.stratoserver.net (localhost [IPv6:::1])
8522759
	by phobos.denx.de (Postfix) with ESMTP id 2E6C784564;
8522759
	Wed, 10 Aug 2022 14:58:17 +0200 (CEST)
8522759
Authentication-Results: phobos.denx.de;
8522759
 dmarc=pass (p=none dis=none) header.from=karthanis.net
8522759
Authentication-Results: phobos.denx.de;
8522759
 spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de
8522759
Authentication-Results: phobos.denx.de;
8522759
	dkim=pass (1024-bit key;
8522759
 unprotected) header.d=karthanis.net header.i=@karthanis.net
8522759
 header.b="3Vltv92i";
8522759
	dkim-atps=neutral
8522759
Received: by phobos.denx.de (Postfix, from userid 109)
8522759
 id 274CF8415B; Wed, 10 Aug 2022 14:40:48 +0200 (CEST)
8522759
X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de
8522759
X-Spam-Level: 
8522759
X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED,
8522759
 DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS,
8522759
 T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2
8522759
Received: from smtp-42a9.mail.infomaniak.ch (smtp-42a9.mail.infomaniak.ch
8522759
 [84.16.66.169])
8522759
 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits))
8522759
 (No client certificate requested)
8522759
 by phobos.denx.de (Postfix) with ESMTPS id DAC58841A4
8522759
 for <u-boot@lists.denx.de>; Wed, 10 Aug 2022 14:40:45 +0200 (CEST)
8522759
Authentication-Results: phobos.denx.de;
8522759
 dmarc=pass (p=none dis=none) header.from=karthanis.net
8522759
Authentication-Results: phobos.denx.de;
8522759
 spf=pass smtp.mailfrom=antoine@karthanis.net
8522759
Received: from smtp-3-0001.mail.infomaniak.ch (unknown [10.4.36.108])
8522759
 by smtp-2-3000.mail.infomaniak.ch (Postfix) with ESMTPS id 4M2qKn4VzjzMqnFS;
8522759
 Wed, 10 Aug 2022 14:40:45 +0200 (CEST)
8522759
Received: from localhost.localdomain (unknown [88.168.170.86])
8522759
 by smtp-3-0001.mail.infomaniak.ch (Postfix) with ESMTPA id 4M2qKn1TBqzlnSCc;
8522759
 Wed, 10 Aug 2022 14:40:45 +0200 (CEST)
8522759
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=karthanis.net;
8522759
 s=20191114; t=1660135245;
8522759
 bh=f61vvBG7E2UozLHxeE7zghMr3kXQzBW+5PpzEyEGYJU=;
8522759
 h=From:To:Cc:Subject:Date:In-Reply-To:References:From;
8522759
 b=3Vltv92i/KGKD06qHi+zyrqGwfJWUvdwHMojKKH7OqswhScJTxhUbGq6MnPrCqWsn
8522759
 QgB117zr++vQSy1jxV2vZIFLxMC3j8AZb4l3ktmU7FiPp7AUB6AqAzv+tUrYeS3nz4
8522759
 LQ0mJS4s1jk1k0WWAK3/WGdOyUAo8ZWw5oiBHUvk=
8522759
From: Antoine Mazeas <antoine@karthanis.net>
8522759
To: u-boot@lists.denx.de
8522759
Cc: Antoine Mazeas <antoine@karthanis.net>
8522759
Subject: [PATCH 2/2] rpi: Copy eth PHY address from fw DT to loaded DT
8522759
Date: Wed, 10 Aug 2022 14:39:27 +0200
8522759
Message-Id: <20220810123927.2567677-3-antoine@karthanis.net>
8522759
X-Mailer: git-send-email 2.37.1
8522759
In-Reply-To: <20220810123927.2567677-1-antoine@karthanis.net>
8522759
References: <20220810123927.2567677-1-antoine@karthanis.net>
8522759
MIME-Version: 1.0
8522759
X-Mailman-Approved-At: Wed, 10 Aug 2022 14:58:03 +0200
8522759
X-BeenThere: u-boot@lists.denx.de
8522759
X-Mailman-Version: 2.1.39
8522759
Precedence: list
8522759
List-Id: U-Boot discussion <u-boot.lists.denx.de>
8522759
List-Unsubscribe: <https://lists.denx.de/options/u-boot>,
8522759
 <mailto:u-boot-request@lists.denx.de?subject=unsubscribe>
8522759
List-Archive: <https://lists.denx.de/pipermail/u-boot/>
8522759
List-Post: <mailto:u-boot@lists.denx.de>
8522759
List-Help: <mailto:u-boot-request@lists.denx.de?subject=help>
8522759
List-Subscribe: <https://lists.denx.de/listinfo/u-boot>,
8522759
 <mailto:u-boot-request@lists.denx.de?subject=subscribe>
8522759
Errors-To: u-boot-bounces@lists.denx.de
8522759
Sender: "U-Boot" <u-boot-bounces@lists.denx.de>
8522759
X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de
8522759
X-Virus-Status: Clean
8522759
8522759
Some Raspberry Pi 400 boards, specifically rev 1.1, have a different address for the ethernet PHY device than what is provided by the kernel DTB. The correct address is provided by the firmware, so we should carry it over into the loaded device tree so that ethernet works on such boards.
8522759
8522759
Signed-off-by: Antoine Mazeas <antoine@karthanis.net>
8522759
---
8522759
 board/raspberrypi/rpi/rpi.c | 3 +++
8522759
 1 file changed, 3 insertions(+)
8522759
8522759
diff --git a/board/raspberrypi/rpi/rpi.c b/board/raspberrypi/rpi/rpi.c
8522759
index 28b6f52506..793fd1aa30 100644
8522759
--- a/board/raspberrypi/rpi/rpi.c
8522759
+++ b/board/raspberrypi/rpi/rpi.c
8522759
@@ -548,6 +548,9 @@ void  update_fdt_from_fw(void *fdt, void *fw_fdt)
8522759
 
8522759
 	/* kernel address randomisation seed as provided by the firmware */
8522759
 	copy_property(fdt, fw_fdt, "/chosen", "kaslr-seed");
8522759
+
8522759
+	/* address of the PHY device as provided by the firmware  */
8522759
+	copy_property(fdt, fw_fdt, "ethernet0/mdio@e14/ethernet-phy@1", "reg");
8522759
 }
8522759
 
8522759
 int ft_board_setup(void *blob, struct bd_info *bd)