Skip to contentSkip to conversation

arm64: zynqmp: Create fdtfile from compatible string

PATCH New Michal Simek 2 participants 5 messages Feb 14, 2019 Arm/Zynq architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 arm64: zynqmp: Create fdtfile from compatible string

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.

---

How good/bad idea is this?

---
 board/xilinx/zynqmp/zynqmp.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/xilinx/zynqmp/zynqmp.c +30 -0
index a49f2f3e9ebe..64800d869819 100644
@@ -514,6 +514,32 @@ static u32 reset_reason(void)
 	return ret;
 }
 
+static int set_fdtfile(void)
+{
+	char *compatible, *fdtfile;
+
+	if (env_get("fdtfile"))
+		return 0;
+
+	compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);
+	if (compatible) {
+		debug("Compatible: %s\n", compatible);
+
+		strsep(&compatible, ",");
+
+		fdtfile = calloc(1, strlen(compatible) + 4);
+		if (!fdtfile)
+			return -ENOMEM;
+
+		sprintf(fdtfile, "%s%s", compatible, ".dtb");
+
+		env_set("fdtfile", fdtfile);
+		free(fdtfile);
+	}
+
+	return 0;
+}
+
 int board_late_init(void)
 {
 	u32 reg = 0;
@@ -536,6 +562,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;
Signature · 1 line
1.9.1
#1 lore raw

PATCH 1/1 arm64: zynqmp: Create fdtfile from compatible string

Quoted 30 lines · Michal Simek

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.

---

How good/bad idea is this?

---
 board/xilinx/zynqmp/zynqmp.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/xilinx/zynqmp/zynqmp.c +8 -0
index a49f2f3e9ebe..64800d869819 100644
@@ -514,6 +514,32 @@ static u32 reset_reason(void)
 	return ret;
 }
 
+static int set_fdtfile(void)
+{
+	char *compatible, *fdtfile;
+
+	if (env_get("fdtfile"))
+		return 0;
+
+	compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);

board/xilinx/zynqmp/zynqmp.c static u32 reset_reason(void) · line 534

Quoted 10 lines
board/xilinx/zynqmp/zynqmp.c +10 -0
+	if (compatible) {
+		debug("Compatible: %s\n", compatible);
+
+		strsep(&compatible, ",");
+
+		fdtfile = calloc(1, strlen(compatible) + 4);
+		if (!fdtfile)
+			return -ENOMEM;
+
+		sprintf(fdtfile, "%s%s", compatible, ".dtb");

AArch64 dtbs are usually stored in a directory structure which you want to match again. Is this the case for the compatible string? From a quick glimpse, it looks like it - but please make sure that something is in place to ensure it stays that way (upstream review for example).

So the only change I would make here is that this should be "xilinx/%s.dtb".

The idea itself seems sound to me.

Alex

Quoted 23 lines
board/xilinx/zynqmp/zynqmp.c +12 -0
+
+		env_set("fdtfile", fdtfile);
+		free(fdtfile);
+	}
+
+	return 0;
+}
+
 int board_late_init(void)
 {
 	u32 reg = 0;
@@ -536,6 +562,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;
#2 lore raw

PATCH 1/1 arm64: zynqmp: Create fdtfile from compatible string

Quoted 40 lines · Alexander Graf
Quoted 37 lines · Michal Simek

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.

---

How good/bad idea is this?

---
 board/xilinx/zynqmp/zynqmp.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/xilinx/zynqmp/zynqmp.c +15 -0
index a49f2f3e9ebe..64800d869819 100644
@@ -514,6 +514,32 @@ static u32 reset_reason(void)
 	return ret;
 }
 
+static int set_fdtfile(void)
+{
+	char *compatible, *fdtfile;
+
+	if (env_get("fdtfile"))
+		return 0;
+
+	compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);
+	if (compatible) {
+		debug("Compatible: %s\n", compatible);
+
+		strsep(&compatible, ",");
+
+		fdtfile = calloc(1, strlen(compatible) + 4);
+		if (!fdtfile)
Quoted 8 lines

board/xilinx/zynqmp/zynqmp.c static u32 reset_reason(void) · line 534

Quoted 3 lines
board/xilinx/zynqmp/zynqmp.c +3 -0
+			return -ENOMEM;
+
+		sprintf(fdtfile, "%s%s", compatible, ".dtb");

AArch64 dtbs are usually stored in a directory structure which you want to match again. Is this the case for the compatible string? From a quick glimpse, it looks like it - but please make sure that something is in place to ensure it stays that way (upstream review for example).

I have actually remove xlnx prefix from compatible string but just doing simple conversion xlnx,zynqmp-zcu102-revA to xlnx/zynqmp-zcu102-revA.dtb looks good to me too.

Vendor prefixes should be stable enough to ensures that.

Quoted 1 line

So the only change I would make here is that this should be "xilinx/%s.dtb".

Any issue with xlnx prefix?

Quoted 1 line

The idea itself seems sound to me.

Good.
M

#3 lore raw

PATCH 1/1 arm64: zynqmp: Create fdtfile from compatible string

Quoted 50 lines · Michal Simek
Quoted 40 lines · Alexander Graf
Quoted 37 lines · Michal Simek

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.

---

How good/bad idea is this?

---
 board/xilinx/zynqmp/zynqmp.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/xilinx/zynqmp/zynqmp.c +15 -0
index a49f2f3e9ebe..64800d869819 100644
@@ -514,6 +514,32 @@ static u32 reset_reason(void)
 	return ret;
 }
 
+static int set_fdtfile(void)
+{
+	char *compatible, *fdtfile;
+
+	if (env_get("fdtfile"))
+		return 0;
+
+	compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);
+	if (compatible) {
+		debug("Compatible: %s\n", compatible);
+
+		strsep(&compatible, ",");
+
+		fdtfile = calloc(1, strlen(compatible) + 4);
+		if (!fdtfile)
Quoted 8 lines

board/xilinx/zynqmp/zynqmp.c static u32 reset_reason(void) · line 534

Quoted 3 lines
board/xilinx/zynqmp/zynqmp.c +3 -0
+			return -ENOMEM;
+
+		sprintf(fdtfile, "%s%s", compatible, ".dtb");

AArch64 dtbs are usually stored in a directory structure which you want to match again. Is this the case for the compatible string? From a quick glimpse, it looks like it - but please make sure that something is in place to ensure it stays that way (upstream review for example).

Quoted 3 lines

I have actually remove xlnx prefix from compatible string but just doing simple conversion xlnx,zynqmp-zcu102-revA to xlnx/zynqmp-zcu102-revA.dtb looks good to me too.

That won't work, as the kernel will install the dtb in a directory called "xilinx".

Quoted 5 lines

Vendor prefixes should be stable enough to ensures that.

Quoted 1 line

So the only change I would make here is that this should be "xilinx/%s.dtb".

Any issue with xlnx prefix?

Yup :). Please stick to exactly where the kernel installs the dtbs to.

Alex

Quoted 1 line
#4 lore raw

PATCH 1/1 arm64: zynqmp: Create fdtfile from compatible string

Quoted 60 lines · Alexander Graf
Quoted 50 lines · Michal Simek
Quoted 40 lines · Alexander Graf
Quoted 37 lines · Michal Simek

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.

---

How good/bad idea is this?

---
 board/xilinx/zynqmp/zynqmp.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
board/xilinx/zynqmp/zynqmp.c +15 -0
index a49f2f3e9ebe..64800d869819 100644
@@ -514,6 +514,32 @@ static u32 reset_reason(void)
 	return ret;
 }
 
+static int set_fdtfile(void)
+{
+	char *compatible, *fdtfile;
+
+	if (env_get("fdtfile"))
+		return 0;
+
+	compatible = (char *)fdt_getprop(gd->fdt_blob, 0, "compatible", NULL);
+	if (compatible) {
+		debug("Compatible: %s\n", compatible);
+
+		strsep(&compatible, ",");
+
+		fdtfile = calloc(1, strlen(compatible) + 4);
+		if (!fdtfile)
Quoted 8 lines

board/xilinx/zynqmp/zynqmp.c static u32 reset_reason(void) · line 534

Quoted 3 lines
board/xilinx/zynqmp/zynqmp.c +3 -0
+			return -ENOMEM;
+
+		sprintf(fdtfile, "%s%s", compatible, ".dtb");

AArch64 dtbs are usually stored in a directory structure which you want to match again. Is this the case for the compatible string? From a quick glimpse, it looks like it - but please make sure that something is in place to ensure it stays that way (upstream review for example).

Quoted 3 lines

I have actually remove xlnx prefix from compatible string but just doing simple conversion xlnx,zynqmp-zcu102-revA to xlnx/zynqmp-zcu102-revA.dtb looks good to me too.

That won't work, as the kernel will install the dtb in a directory called "xilinx".

Quoted 7 lines
Quoted 5 lines

Vendor prefixes should be stable enough to ensures that.

Quoted 1 line

So the only change I would make here is that this should be "xilinx/%s.dtb".

Any issue with xlnx prefix?

Yup :). Please stick to exactly where the kernel installs the dtbs to.

Ah ok. I see. Didn't realized that xilinx is coming from arch/arm64/boot/dts structures.

Thanks,
Michal