All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2] arm64: zynqmp: Create fdtfile from compatible string
@ 2019-02-14 12:56 Michal Simek
  2019-02-14 12:58 ` Alexander Graf
  0 siblings, 1 reply; 2+ messages in thread
From: Michal Simek @ 2019-02-14 12:56 UTC (permalink / raw)
  To: u-boot

distro boot expects that fdtfile name is setup for alternative DTB.
Create this file based on the first platform compatible string.
This should ensure that one rootfs can store multiple DTBs for different
boards.
Reflect structure which is used in Linux kernel. It means dtbs are
strored in xilinx folder.

Signed-off-by: Michal Simek <michal.simek@xilinx.com>
---

Changes in v2:
- Use xilinx folder.
- Update commit message

 board/xilinx/zynqmp/zynqmp.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
index a49f2f3e9ebe..0ac9b46b5f4b 100644
--- a/board/xilinx/zynqmp/zynqmp.c
+++ b/board/xilinx/zynqmp/zynqmp.c
@@ -514,6 +514,36 @@ static u32 reset_reason(void)
 	return ret;
 }
 
+static int set_fdtfile(void)
+{
+	char *compatible, *fdtfile;
+	const char *suffix = ".dtb";
+	const char *vendor = "xilinx/";
+
+	if (env_get("fdtfile"))
+		return 0;
+
+	compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);
+	if (compatible) {
+		debug("Compatible: %s\n", compatible);
+
+		/* Discard vendor prefix */
+		strsep(&compatible, ",");
+
+		fdtfile = calloc(1, strlen(vendor) + strlen(compatible) +
+				 strlen(suffix) + 1);
+		if (!fdtfile)
+			return -ENOMEM;
+
+		sprintf(fdtfile, "%s%s%s", vendor, compatible, suffix);
+
+		env_set("fdtfile", fdtfile);
+		free(fdtfile);
+	}
+
+	return 0;
+}
+
 int board_late_init(void)
 {
 	u32 reg = 0;
@@ -536,6 +566,10 @@ int board_late_init(void)
 		return 0;
 	}
 
+	ret = set_fdtfile();
+	if (ret)
+		return ret;
+
 	ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, &reg);
 	if (ret)
 		return -EINVAL;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [U-Boot] [PATCH v2] arm64: zynqmp: Create fdtfile from compatible string
  2019-02-14 12:56 [U-Boot] [PATCH v2] arm64: zynqmp: Create fdtfile from compatible string Michal Simek
@ 2019-02-14 12:58 ` Alexander Graf
  0 siblings, 0 replies; 2+ messages in thread
From: Alexander Graf @ 2019-02-14 12:58 UTC (permalink / raw)
  To: u-boot



On 14.02.19 13:56, Michal Simek wrote:
> distro boot expects that fdtfile name is setup for alternative DTB.
> Create this file based on the first platform compatible string.
> This should ensure that one rootfs can store multiple DTBs for different
> boards.
> Reflect structure which is used in Linux kernel. It means dtbs are
> strored in xilinx folder.
> 
> Signed-off-by: Michal Simek <michal.simek@xilinx.com>

Reviewed-by: Alexander Graf <agraf@suse.de>


Alex

> ---
> 
> Changes in v2:
> - Use xilinx folder.
> - Update commit message
> 
>  board/xilinx/zynqmp/zynqmp.c | 34 ++++++++++++++++++++++++++++++++++
>  1 file changed, 34 insertions(+)
> 
> diff --git a/board/xilinx/zynqmp/zynqmp.c b/board/xilinx/zynqmp/zynqmp.c
> index a49f2f3e9ebe..0ac9b46b5f4b 100644
> --- a/board/xilinx/zynqmp/zynqmp.c
> +++ b/board/xilinx/zynqmp/zynqmp.c
> @@ -514,6 +514,36 @@ static u32 reset_reason(void)
>  	return ret;
>  }
>  
> +static int set_fdtfile(void)
> +{
> +	char *compatible, *fdtfile;
> +	const char *suffix = ".dtb";
> +	const char *vendor = "xilinx/";
> +
> +	if (env_get("fdtfile"))
> +		return 0;
> +
> +	compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);
> +	if (compatible) {
> +		debug("Compatible: %s\n", compatible);
> +
> +		/* Discard vendor prefix */
> +		strsep(&compatible, ",");
> +
> +		fdtfile = calloc(1, strlen(vendor) + strlen(compatible) +
> +				 strlen(suffix) + 1);
> +		if (!fdtfile)
> +			return -ENOMEM;
> +
> +		sprintf(fdtfile, "%s%s%s", vendor, compatible, suffix);
> +
> +		env_set("fdtfile", fdtfile);
> +		free(fdtfile);
> +	}
> +
> +	return 0;
> +}
> +
>  int board_late_init(void)
>  {
>  	u32 reg = 0;
> @@ -536,6 +566,10 @@ int board_late_init(void)
>  		return 0;
>  	}
>  
> +	ret = set_fdtfile();
> +	if (ret)
> +		return ret;
> +
>  	ret = zynqmp_mmio_read((ulong)&crlapb_base->boot_mode, &reg);
>  	if (ret)
>  		return -EINVAL;
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-14 12:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-02-14 12:56 [U-Boot] [PATCH v2] arm64: zynqmp: Create fdtfile from compatible string Michal Simek
2019-02-14 12:58 ` Alexander Graf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.