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 5C17EC6FA82 for ; Tue, 13 Sep 2022 07:00:38 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 39B9584BA0; Tue, 13 Sep 2022 09:00:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1663052436; bh=E/KL12a5rtgEtvClXf7QK9MWOBbCrRB+ODW7DuV2CUk=; h=Date:Subject:To:Cc:References:From:In-Reply-To:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=EYdaD7citunzIh9p0kzb9ltTeu1IlKTWCJva9HIp4qeejcudE/Grkh5VL6BYsbhwZ 67NXOEzedv5gnGBjS2GUpgf2cHHuA5FDxUyANXFiz/vLRErsJq4mjrio6MvUeoAP7T FWLMyewunl1luIj5kiUOGgL+pFAOMVhjSXxAl5tRRMnHnYvv0X4PsbNJI7B+3RZltB P2/26y6HutnWzzIOgdF/eYwq46NYumW+k5c8TXs8vL5FmBu2SsEEy84D4Fv4JnEOsG deZqVWodcxhSBKJpsrhY4FHnSVQ6q/8R0zKAM8vAcA+OfIui2uPA7HMFKnHXtDbaqy 7G2x5ORdF+fYg== Received: by phobos.denx.de (Postfix, from userid 109) id C77CD84BA2; Tue, 13 Sep 2022 09:00:29 +0200 (CEST) Received: from mout-u-107.mailbox.org (mout-u-107.mailbox.org [IPv6:2001:67c:2050:101:465::107]) (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 7DEA984BA4 for ; Tue, 13 Sep 2022 09:00:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sr@denx.de Received: from smtp1.mailbox.org (smtp1.mailbox.org [10.196.197.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-u-107.mailbox.org (Postfix) with ESMTPS id 4MRZ9H3lfLz9sSP; Tue, 13 Sep 2022 09:00:19 +0200 (CEST) Message-ID: Date: Tue, 13 Sep 2022 09:00:18 +0200 MIME-Version: 1.0 Subject: Re: [PATCH] arm: mvebu: turris_mox: Add support for distroboot $fdt_addr Content-Language: en-US To: =?UTF-8?Q?Pali_Roh=c3=a1r?= , =?UTF-8?Q?Marek_Beh=c3=ban?= Cc: u-boot@lists.denx.de References: <20220829134448.11570-1-pali@kernel.org> From: Stefan Roese In-Reply-To: <20220829134448.11570-1-pali@kernel.org> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit 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.6 at phobos.denx.de X-Virus-Status: Clean On 29.08.22 15:44, Pali Rohár wrote: > $fdt_addr is mandatory for systems which provides DTB in HW (e.g. ROM) and > wishes to pass that DTB to Linux. > > Turris Mox contains DTB binary in SPI NOR memory at "dtb" partition which > starts at offset 0x7f0000 and is 0x10000 bytes long. > > Armada 3700 CPU does not allow mapping SPI NOR memory into physical address > space like on other architectures and therefore set $fdt_addr variable to > memory range in RAM and loads this DTB binary from SPI NOR in misc_init_r() > function. > > Signed-off-by: Pali Rohár Applied to u-boot-marvell/master Thanks, Stefan > --- > board/CZ.NIC/turris_mox/turris_mox.c | 48 ++++++++++++++++++++++++++++ > include/configs/turris_mox.h | 1 + > 2 files changed, 49 insertions(+) > > diff --git a/board/CZ.NIC/turris_mox/turris_mox.c b/board/CZ.NIC/turris_mox/turris_mox.c > index 3dbd68e52366..3402515bbae2 100644 > --- a/board/CZ.NIC/turris_mox/turris_mox.c > +++ b/board/CZ.NIC/turris_mox/turris_mox.c > @@ -23,6 +23,7 @@ > #include > #include > #include > +#include > > #include "mox_sp.h" > > @@ -339,6 +340,51 @@ static int get_reset_gpio(struct gpio_desc *reset_gpio) > return 0; > } > > +/* Load default system DTB binary to $fdr_addr */ > +static void load_spi_dtb(void) > +{ > + const char *const env_name[1] = { "fdt_addr" }; > + unsigned long size, offset; > + struct udevice *spi_dev; > + struct spi_flash *flash; > + const char *addr_str; > + unsigned long addr; > + void *buf; > + > + addr_str = env_get(env_name[0]); > + if (!addr_str) { > + env_set_default_vars(1, (char * const *)env_name, 0); > + addr_str = env_get(env_name[0]); > + } > + > + if (!addr_str) > + return; > + > + addr = hextoul(addr_str, NULL); > + if (!addr) > + return; > + > + spi_flash_probe_bus_cs(CONFIG_SF_DEFAULT_BUS, CONFIG_SF_DEFAULT_CS, &spi_dev); > + flash = dev_get_uclass_priv(spi_dev); > + if (!flash) > + return; > + > + /* > + * SPI NOR "dtb" partition offset & size hardcoded for now because the > + * mtd subsystem does not offer finding the partition yet and we do not > + * want to reimplement OF partition parser here. > + */ > + offset = 0x7f0000; > + size = 0x10000; > + > + buf = map_physmem(addr, size, MAP_WRBACK); > + if (!buf) > + return; > + > + spi_flash_read(flash, offset, size, buf); > + unmap_physmem(buf, size); > +} > + > int misc_init_r(void) > { > u8 mac[2][6]; > @@ -358,6 +404,8 @@ int misc_init_r(void) > eth_env_set_enetaddr_by_index("eth", i, mac[i]); > } > > + load_spi_dtb(); > + > return 0; > } > > diff --git a/include/configs/turris_mox.h b/include/configs/turris_mox.h > index b8ff705ac923..f549f9f7ad06 100644 > --- a/include/configs/turris_mox.h > +++ b/include/configs/turris_mox.h > @@ -36,6 +36,7 @@ > "bootm 0x5800000" > > #define CONFIG_EXTRA_ENV_SETTINGS \ > + "fdt_addr=0x4c00000\0" \ > "scriptaddr=0x4d00000\0" \ > "pxefile_addr_r=0x4e00000\0" \ > "fdt_addr_r=0x4f00000\0" \ Viele Grüße, Stefan Roese -- DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: (+49)-8142-66989-51 Fax: (+49)-8142-66989-80 Email: sr@denx.de