Skip to contentSkip to conversation

lib/utils: Support the official clint DT bindings

PATCH New Bin Meng 2 participants 9 messages Mar 27, 2021 – Apr 1, 2021

lore
Share & tools
lore

Bin Meng

author
#0 lore raw

PATCH 1/3 lib/utils: Support the official clint DT bindings

Linux kernel commit a2770b57d083 ("dt-bindings: timer: Add CLINT bindings") adds the official DT bindings for CLINT, which uses "sifive,clint0" as the compatible string. "riscv,clint0" is now legacy and has to be kept for backward compatibility of legacy systems.

---

 lib/utils/ipi/fdt_ipi_clint.c     | 1 +
 lib/utils/timer/fdt_timer_clint.c | 1 +
 2 files changed, 2 insertions(+)
lib/utils/ipi/fdt_ipi_clint.c +1 -0
index e992440..e799fd7 100644
@@ -36,6 +36,7 @@ static int ipi_clint_cold_init(void *fdt, int nodeoff,
 
 static const struct fdt_match ipi_clint_match[] = {
 	{ .compatible = "riscv,clint0" },
+	{ .compatible = "sifive,clint0" },
 	{ },
 };
 
lib/utils/timer/fdt_timer_clint.c +1 -0
index fe66708..6ba6c7b 100644
@@ -38,6 +38,7 @@ static int timer_clint_cold_init(void *fdt, int nodeoff,
 
 static const struct fdt_match timer_clint_match[] = {
 	{ .compatible = "riscv,clint0" },
+	{ .compatible = "sifive,clint0" },
 	{ },
 };
 
Signature · 1 line
2.25.1
author
#1 lore raw

PATCH 2/3 lib/utils: Drop the 'compat' parameter of fdt_plic_fixup()

At present fdt_plic_fixup() accepts a 'compat' parameter for PLIC compatible string. In preparation to support the new DT bindings, drop this and use "riscv,plic0" directly in fdt_plic_fixup().

---

 include/sbi_utils/fdt/fdt_fixup.h | 3 +--
 lib/utils/fdt/fdt_fixup.c         | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)
include/sbi_utils/fdt/fdt_fixup.h +1 -2
index 0697a18..c38e5d9 100644
@@ -30,9 +30,8 @@ void fdt_cpu_fixup(void *fdt);
  * It is recommended that platform codes call this helper in their final_init()
  *
  * @param fdt: device tree blob
- * @param compat: PLIC node compatible string
  */
-void fdt_plic_fixup(void *fdt, const char *compat);
+void fdt_plic_fixup(void *fdt);
 
 /**
  * Fix up the reserved memory node in the device tree
lib/utils/fdt/fdt_fixup.c +3 -3
index eea450d..a306ff5 100644
@@ -51,13 +51,13 @@ void fdt_cpu_fixup(void *fdt)
 	}
 }
 
-void fdt_plic_fixup(void *fdt, const char *compat)
+void fdt_plic_fixup(void *fdt)
 {
 	u32 *cells;
 	int i, cells_count;
 	int plic_off;
 
-	plic_off = fdt_node_offset_by_compatible(fdt, 0, compat);
+	plic_off = fdt_node_offset_by_compatible(fdt, 0, "riscv,plic0");
 	if (plic_off < 0)
 		return;
 
@@ -257,7 +257,7 @@ int fdt_reserved_memory_nomap_fixup(void *fdt)
 
 void fdt_fixups(void *fdt)
 {
-	fdt_plic_fixup(fdt, "riscv,plic0");
+	fdt_plic_fixup(fdt);
 
 	fdt_reserved_memory_fixup(fdt);
 }
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/3 lib/utils: Drop the 'compat' parameter of fdt_plic_fixup()

Quoted 11 lines

-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Bin Meng
Sent: 27 March 2021 10:35
To: opensbi at lists.infradead.org
Cc: Bin Meng <[email protected]>
Subject: [PATCH 2/3] lib/utils: Drop the 'compat' parameter of fdt_plic_fixup()

Quoted 5 lines

At present fdt_plic_fixup() accepts a 'compat' parameter for PLIC compatible string. In preparation to support the new DT bindings, drop this and use "riscv,plic0" directly in fdt_plic_fixup().

Looks good to me.

Regards,
Anup

Quoted 59 lines

---

 include/sbi_utils/fdt/fdt_fixup.h | 3 +--
 lib/utils/fdt/fdt_fixup.c         | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)
include/sbi_utils/fdt/fdt_fixup.h +1 -2
index 0697a18..c38e5d9 100644
@@ -30,9 +30,8 @@ void fdt_cpu_fixup(void *fdt);
  * It is recommended that platform codes call this helper in their final_init()
  *
  * @param fdt: device tree blob
- * @param compat: PLIC node compatible string
  */
-void fdt_plic_fixup(void *fdt, const char *compat);
+void fdt_plic_fixup(void *fdt);
 
 /**
  * Fix up the reserved memory node in the device tree diff --git

a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c index eea450d..a306ff5 100644

lib/utils/fdt/fdt_fixup.c +3 -4
@@ -51,13 +51,13 @@ void fdt_cpu_fixup(void *fdt)
 	}
 }
 
-void fdt_plic_fixup(void *fdt, const char *compat)
+void fdt_plic_fixup(void *fdt)
 {
 	u32 *cells;
 	int i, cells_count;
 	int plic_off;
 
-	plic_off = fdt_node_offset_by_compatible(fdt, 0, compat);
+	plic_off = fdt_node_offset_by_compatible(fdt, 0, "riscv,plic0");
 	if (plic_off < 0)
 		return;
 
@@ -257,7 +257,7 @@ int fdt_reserved_memory_nomap_fixup(void *fdt)
 
 void fdt_fixups(void *fdt)
 {
-	fdt_plic_fixup(fdt, "riscv,plic0");
+	fdt_plic_fixup(fdt);
 
 	fdt_reserved_memory_fixup(fdt);
 }
--

2.25.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

Applied
#3 lore raw

PATCH 2/3 lib/utils: Drop the 'compat' parameter of fdt_plic_fixup()

Quoted 24 lines

-----Original Message-----
From: Anup Patel
Sent: 31 March 2021 10:25
To: Bin Meng <[email protected]>; opensbi at lists.infradead.org
Subject: RE: [PATCH 2/3] lib/utils: Drop the 'compat' parameter of fdt_plic_fixup()

Quoted 13 lines

-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Bin Meng
Sent: 27 March 2021 10:35
To: opensbi at lists.infradead.org
Cc: Bin Meng <[email protected]>
Subject: [PATCH 2/3] lib/utils: Drop the 'compat' parameter of fdt_plic_fixup()

At present fdt_plic_fixup() accepts a 'compat' parameter for PLIC compatible string. In preparation to support the new DT bindings, drop this and use "riscv,plic0" directly in fdt_plic_fixup().

Quoted 5 lines
Quoted 1 line

Looks good to me.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 64 lines

Regards,
Anup

Quoted 60 lines

---

 include/sbi_utils/fdt/fdt_fixup.h | 3 +--
 lib/utils/fdt/fdt_fixup.c         | 6 +++---
 2 files changed, 4 insertions(+), 5 deletions(-)
include/sbi_utils/fdt/fdt_fixup.h +1 -2
index 0697a18..c38e5d9 100644
@@ -30,9 +30,8 @@ void fdt_cpu_fixup(void *fdt);
  * It is recommended that platform codes call this helper in their final_init()
  *
  * @param fdt: device tree blob
- * @param compat: PLIC node compatible string
  */
-void fdt_plic_fixup(void *fdt, const char *compat);
+void fdt_plic_fixup(void *fdt);
 
 /**
  * Fix up the reserved memory node in the device tree diff --git

a/lib/utils/fdt/fdt_fixup.c b/lib/utils/fdt/fdt_fixup.c index eea450d..a306ff5
100644

lib/utils/fdt/fdt_fixup.c +3 -4
@@ -51,13 +51,13 @@ void fdt_cpu_fixup(void *fdt)
 	}
 }
 
-void fdt_plic_fixup(void *fdt, const char *compat)
+void fdt_plic_fixup(void *fdt)
 {
 	u32 *cells;
 	int i, cells_count;
 	int plic_off;
 
-	plic_off = fdt_node_offset_by_compatible(fdt, 0, compat);
+	plic_off = fdt_node_offset_by_compatible(fdt, 0, "riscv,plic0");
 	if (plic_off < 0)
 		return;
 
@@ -257,7 +257,7 @@ int fdt_reserved_memory_nomap_fixup(void *fdt)
 
 void fdt_fixups(void *fdt)
 {
-	fdt_plic_fixup(fdt, "riscv,plic0");
+	fdt_plic_fixup(fdt);
 
 	fdt_reserved_memory_fixup(fdt);
 }
--

2.25.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

author
#4 lore raw

PATCH 3/3 lib/utils: Support fixing up the official DT bindings of PLIC

In reply to Bin Meng

Current fdt_plic_fixup() only does necessary fix-up against the legacy "riscv,plic0" node. The upstream Linux kernel defines its official DT bindings which uses "sifive,plic-1.0.0" as the compatible string and we should check that first, and if not present fall back to legacy.

---

 lib/utils/fdt/fdt_fixup.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
lib/utils/fdt/fdt_fixup.c +6 -3
index a306ff5..1465500 100644
@@ -57,9 +57,12 @@ void fdt_plic_fixup(void *fdt)
 	int i, cells_count;
 	int plic_off;
 
-	plic_off = fdt_node_offset_by_compatible(fdt, 0, "riscv,plic0");
-	if (plic_off < 0)
-		return;
+	plic_off = fdt_node_offset_by_compatible(fdt, 0, "sifive,plic-1.0.0");
+	if (plic_off < 0) {
+		plic_off = fdt_node_offset_by_compatible(fdt, 0, "riscv,plic0");
+		if (plic_off < 0)
+			return;
+	}
 
 	cells = (u32 *)fdt_getprop(fdt, plic_off,
 				   "interrupts-extended", &cells_count);
Signature · 1 line
2.25.1
#5 lore raw

PATCH 3/3 lib/utils: Support fixing up the official DT bindings of PLIC

Quoted 11 lines

-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Bin Meng
Sent: 27 March 2021 10:35
To: opensbi at lists.infradead.org
Cc: Bin Meng <[email protected]>
Subject: [PATCH 3/3] lib/utils: Support fixing up the official DT bindings of PLIC

Quoted 6 lines

Current fdt_plic_fixup() only does necessary fix-up against the legacy "riscv,plic0" node. The upstream Linux kernel defines its official DT bindings which uses "sifive,plic-1.0.0" as the compatible string and we should check that first, and if not present fall back to legacy.

Looks good to me.

Regards,
Anup

Quoted 34 lines

---

 lib/utils/fdt/fdt_fixup.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
lib/utils/fdt/fdt_fixup.c index renamed from lib/utils/fdt/fdt_fixup.c +0 -0

a306ff5..1465500 100644

lib/utils/fdt/fdt_fixup.c +6 -3
@@ -57,9 +57,12 @@ void fdt_plic_fixup(void *fdt)
 	int i, cells_count;
 	int plic_off;
 
-	plic_off = fdt_node_offset_by_compatible(fdt, 0, "riscv,plic0");
-	if (plic_off < 0)
-		return;
+	plic_off = fdt_node_offset_by_compatible(fdt, 0, "sifive,plic-1.0.0");
+	if (plic_off < 0) {
+		plic_off = fdt_node_offset_by_compatible(fdt, 0,
 "riscv,plic0");
+		if (plic_off < 0)
+			return;
+	}
 
 	cells = (u32 *)fdt_getprop(fdt, plic_off,

"interrupts-extended", &cells_count);
--
2.25.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

Applied
#6 lore raw

PATCH 3/3 lib/utils: Support fixing up the official DT bindings of PLIC

Quoted 25 lines

-----Original Message-----
From: Anup Patel
Sent: 31 March 2021 10:26
To: Bin Meng <[email protected]>; opensbi at lists.infradead.org
Subject: RE: [PATCH 3/3] lib/utils: Support fixing up the official DT bindings of PLIC

Quoted 14 lines

-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Bin Meng
Sent: 27 March 2021 10:35
To: opensbi at lists.infradead.org
Cc: Bin Meng <[email protected]>
Subject: [PATCH 3/3] lib/utils: Support fixing up the official DT bindings of PLIC

Current fdt_plic_fixup() only does necessary fix-up against the legacy "riscv,plic0" node. The upstream Linux kernel defines its official DT bindings which uses "sifive,plic-1.0.0" as the compatible string and we should check that first, and if not present fall back to legacy.

Quoted 5 lines
Quoted 1 line

Looks good to me.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 39 lines

Regards,
Anup

Quoted 35 lines

---

 lib/utils/fdt/fdt_fixup.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
lib/utils/fdt/fdt_fixup.c +0 -0

index
a306ff5..1465500 100644

lib/utils/fdt/fdt_fixup.c +6 -3
@@ -57,9 +57,12 @@ void fdt_plic_fixup(void *fdt)
 	int i, cells_count;
 	int plic_off;
 
-	plic_off = fdt_node_offset_by_compatible(fdt, 0, "riscv,plic0");
-	if (plic_off < 0)
-		return;
+	plic_off = fdt_node_offset_by_compatible(fdt, 0, "sifive,plic-1.0.0");
+	if (plic_off < 0) {
+		plic_off = fdt_node_offset_by_compatible(fdt, 0,
 "riscv,plic0");
+		if (plic_off < 0)
+			return;
+	}
 
 	cells = (u32 *)fdt_getprop(fdt, plic_off,

"interrupts-extended", &cells_count);
--
2.25.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

#7 lore raw

PATCH 1/3 lib/utils: Support the official clint DT bindings

In reply to Bin Meng
Quoted 10 lines

-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Bin Meng
Sent: 27 March 2021 10:35
To: opensbi at lists.infradead.org
Cc: Bin Meng <[email protected]>
Subject: [PATCH 1/3] lib/utils: Support the official clint DT bindings

Quoted 6 lines

Linux kernel commit a2770b57d083 ("dt-bindings: timer: Add CLINT bindings") adds the official DT bindings for CLINT, which uses "sifive,clint0" as the compatible string. "riscv,clint0" is now legacy and has to be kept for backward compatibility of legacy systems.

Looks good to me.

Regards,
Anup

Quoted 38 lines

---

 lib/utils/ipi/fdt_ipi_clint.c     | 1 +
 lib/utils/timer/fdt_timer_clint.c | 1 +
 2 files changed, 2 insertions(+)
lib/utils/ipi/fdt_ipi_clint.c index renamed from lib/utils/ipi/fdt_ipi_clint.c +0 -0

e992440..e799fd7 100644

lib/utils/ipi/fdt_ipi_clint.c +1 -0
@@ -36,6 +36,7 @@ static int ipi_clint_cold_init(void *fdt, int nodeoff,
 
 static const struct fdt_match ipi_clint_match[] = {
 	{ .compatible = "riscv,clint0" },
+	{ .compatible = "sifive,clint0" },
 	{ },
 };
 
lib/utils/timer/fdt_timer_clint.c +1 -1
index fe66708..6ba6c7b 100644
@@ -38,6 +38,7 @@ static int timer_clint_cold_init(void *fdt, int nodeoff,
 
 static const struct fdt_match timer_clint_match[] = {
 	{ .compatible = "riscv,clint0" },
+	{ .compatible = "sifive,clint0" },
 	{ },
 };
 
--

2.25.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi

Applied
#8 lore raw

PATCH 1/3 lib/utils: Support the official clint DT bindings

Quoted 23 lines

-----Original Message-----
From: Anup Patel
Sent: 31 March 2021 10:23
To: 'Bin Meng' <[email protected]>; opensbi at lists.infradead.org
Subject: RE: [PATCH 1/3] lib/utils: Support the official clint DT bindings

Quoted 13 lines

-----Original Message-----
From: opensbi <[email protected]> On Behalf Of Bin Meng
Sent: 27 March 2021 10:35
To: opensbi at lists.infradead.org
Cc: Bin Meng <[email protected]>
Subject: [PATCH 1/3] lib/utils: Support the official clint DT bindings

Linux kernel commit a2770b57d083 ("dt-bindings: timer: Add CLINT bindings") adds the official DT bindings for CLINT, which uses "sifive,clint0" as the compatible string. "riscv,clint0" is now legacy and has to be kept for backward compatibility of legacy systems.

Quoted 5 lines
Quoted 1 line

Looks good to me.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

Quoted 46 lines

Regards,
Anup

Quoted 42 lines

---

 lib/utils/ipi/fdt_ipi_clint.c     | 1 +
 lib/utils/timer/fdt_timer_clint.c | 1 +
 2 files changed, 2 insertions(+)
(quoted diff) +0 -0

b/lib/utils/ipi/fdt_ipi_clint.c index
e992440..e799fd7 100644

lib/utils/ipi/fdt_ipi_clint.c +1 -0
@@ -36,6 +36,7 @@ static int ipi_clint_cold_init(void *fdt, int
 nodeoff,
 
 static const struct fdt_match ipi_clint_match[] = {
 	{ .compatible = "riscv,clint0" },
+	{ .compatible = "sifive,clint0" },
 	{ },
 };
lib/utils/timer/fdt_timer_clint.c +1 -1
index fe66708..6ba6c7b 100644
@@ -38,6 +38,7 @@ static int timer_clint_cold_init(void *fdt, int
 nodeoff,
 
 static const struct fdt_match timer_clint_match[] = {
 	{ .compatible = "riscv,clint0" },
+	{ .compatible = "sifive,clint0" },
 	{ },
 };
 
--

2.25.1

--
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi