Skip to contentSkip to conversation

generic/starfive: Enable Starfive JH7110 platform preferred cold boot HART implementation

PATCH New Wei Liang Lim 4 participants 12 messages Dec 29, 2022 – Apr 5, 2023

lore
Share & tools
lore
#0 lore raw

v7 cover generic/starfive: Enable Starfive JH7110 platform preferred cold boot HART implementation

This is patchset to enable Starfive JH7110 platform preferred cold boot HART implementation.
User has the option to specify preferred cold boot HART in the device tree. If unspecified, the existing lottery mechanism will be used.

v6->v7:
- Changing if (val && len) -> if (val && len >= sizeof(fdt32_t)) in /platform/generic/starfive/jh7110.c

v5->v6:
- Minor changes on TRUE->true, FALSE->false.

v4->v5:
- Move FDT boot hart id reading from cold_boot_allowed() to fw_init()callback function.

v3->v4:
- Add implementation to allow user to specify preferred cold boot HART in the device tree.
- If unspecified, the existing lottery mechanism will be used.

v3:
- Add Starfive JH7110 implementation.
- Anup's patches to allow platform specific selection of cold boot HART.

v2:
https://patchwork.ozlabs.org/project/opensbi/patch/20221202063845.14938-1-weiliang.lim at starfivetech.com/

v1:
https://patchwork.ozlabs.org/project/opensbi/patch/20221129052119.379830-1-weiliang.lim at starfivetech.com/

Anup Patel (2):
lib: sbi: Allow platform to influence cold boot HART selection
platform: generic: Allow platform_override to select cold boot HART

Wei Liang Lim (2):
platform: generic: Allow platform_override to perform firmware init generic/starfive: Add Starfive JH7110 platform implementation

 include/sbi/sbi_platform.h                   | 20 +++++++++
 lib/sbi/sbi_init.c                           |  7 ++-
 platform/generic/Kconfig                     |  4 ++
 platform/generic/configs/defconfig           |  1 +
 platform/generic/include/platform_override.h |  2 +
 platform/generic/platform.c                  | 12 +++++
 platform/generic/starfive/jh7110.c           | 47 ++++++++++++++++++++
 platform/generic/starfive/objects.mk         |  6 +++
 8 files changed, 97 insertions(+), 2 deletions(-)
 create mode 100644 platform/generic/starfive/jh7110.c
 create mode 100644 platform/generic/starfive/objects.mk
Signature · 1 line
2.25.1
#1 lore raw

PATCH v7 1/4 lib: sbi: Allow platform to influence cold boot HART selection

From: Anup Patel <[email protected]>

We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization.

If this platform callback is not available then any HART can do cold boot initialization.

---
 include/sbi/sbi_platform.h | 20 ++++++++++++++++++++
 lib/sbi/sbi_init.c         |  7 +++++--
 2 files changed, 25 insertions(+), 2 deletions(-)
include/sbi/sbi_platform.h +20 -0
index 722f27a..bd0d5ca 100644
@@ -65,6 +65,9 @@ enum sbi_platform_features {
 
 /** Platform functions */
 struct sbi_platform_operations {
+	/* Check if specified HART is allowed to do cold boot */
+	bool (*cold_boot_allowed)(u32 hartid);
+
 	/* Platform nascent initialization */
 	int (*nascent_init)(void);
 
@@ -356,6 +359,23 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,
 	return FALSE;
 }
 
+/**
+ * Check whether given HART is allowed to do cold boot
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param hartid HART ID
+ *
+ * @return true if HART is allowed to do cold boot and false otherwise
+ */
+static inline bool sbi_platform_cold_boot_allowed(
+					const struct sbi_platform *plat,
+					u32 hartid)
+{
+	if (plat && sbi_platform_ops(plat)->cold_boot_allowed)
+		return sbi_platform_ops(plat)->cold_boot_allowed(hartid);
+	return true;
+}
+
 /**
  * Nascent (very early) initialization for current HART
  *
lib/sbi/sbi_init.c +5 -2
index a8500e5..d45cee6 100644
@@ -498,8 +498,11 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
 	 * HARTs which satisfy above condition.
 	 */
 
-	if (next_mode_supported && atomic_xchg(&coldboot_lottery, 1) == 0)
-		coldboot = TRUE;
+	if (sbi_platform_cold_boot_allowed(plat, hartid)) {
+		if (next_mode_supported &&
+		    atomic_xchg(&coldboot_lottery, 1) == 0)
+			coldboot = true;
+	}
 
 	/*
 	 * Do platform specific nascent (very early) initialization so
Signature · 1 line
2.25.1
Applied
#2 lore raw

PATCH v7 1/4 lib: sbi: Allow platform to influence cold boot HART selection

Quoted 10 lines · Wei Liang Lim

From: Anup Patel <[email protected]>

We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization.

If this platform callback is not available then any HART can do cold boot initialization.

Applied this patch to the riscv/opensbi repo

Thanks,
Anup

Quoted 69 lines
---
 include/sbi/sbi_platform.h | 20 ++++++++++++++++++++
 lib/sbi/sbi_init.c         |  7 +++++--
 2 files changed, 25 insertions(+), 2 deletions(-)
include/sbi/sbi_platform.h +20 -0
index 722f27a..bd0d5ca 100644
@@ -65,6 +65,9 @@ enum sbi_platform_features {
 
 /** Platform functions */
 struct sbi_platform_operations {
+       /* Check if specified HART is allowed to do cold boot */
+       bool (*cold_boot_allowed)(u32 hartid);
+
        /* Platform nascent initialization */
        int (*nascent_init)(void);
 
@@ -356,6 +359,23 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,
        return FALSE;
 }
 
+/**
+ * Check whether given HART is allowed to do cold boot
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param hartid HART ID
+ *
+ * @return true if HART is allowed to do cold boot and false otherwise
+ */
+static inline bool sbi_platform_cold_boot_allowed(
+                                       const struct sbi_platform *plat,
+                                       u32 hartid)
+{
+       if (plat && sbi_platform_ops(plat)->cold_boot_allowed)
+               return sbi_platform_ops(plat)->cold_boot_allowed(hartid);
+       return true;
+}
+
 /**
  * Nascent (very early) initialization for current HART
  *
lib/sbi/sbi_init.c +5 -3
index a8500e5..d45cee6 100644
@@ -498,8 +498,11 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
         * HARTs which satisfy above condition.
         */
 
-       if (next_mode_supported && atomic_xchg(&coldboot_lottery, 1) == 0)
-               coldboot = TRUE;
+       if (sbi_platform_cold_boot_allowed(plat, hartid)) {
+               if (next_mode_supported &&
+                   atomic_xchg(&coldboot_lottery, 1) == 0)
+                       coldboot = true;
+       }
 
        /*
         * Do platform specific nascent (very early) initialization so
--

2.25.1

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

#3 lore raw

PATCH v7 1/4 lib: sbi: Allow platform to influence cold boot HART selection

Quoted 9 lines · Anup Patel
Quoted 6 lines · Wei Liang Lim

From: Anup Patel <[email protected]>

We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization.

Quoted 6 lines
Quoted 4 lines

If this platform callback is not available then any HART can do cold boot initialization.

Applied this patch to the riscv/opensbi repo

So, no attempt to engage with my objections to the concept as a whole in past patches? Instead you just steamrolled it through over the holiday period. I didn?t even notice this had been re-posted until now.

Jess

Quoted 77 lines

Thanks,
Anup

Quoted 69 lines

---
include/sbi/sbi_platform.h | 20 ++++++++++++++++++++
lib/sbi/sbi_init.c | 7 +++++--

2 files changed, 25 insertions(+), 2 deletions(-)
include/sbi/sbi_platform.h +20 -0
index 722f27a..bd0d5ca 100644
@@ -65,6 +65,9 @@ enum sbi_platform_features {
 
 /** Platform functions */
 struct sbi_platform_operations {
+       /* Check if specified HART is allowed to do cold boot */
+       bool (*cold_boot_allowed)(u32 hartid);
+
       /* Platform nascent initialization */
       int (*nascent_init)(void);
 
@@ -356,6 +359,23 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,
       return FALSE;
 }
 
+/**
+ * Check whether given HART is allowed to do cold boot
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param hartid HART ID
+ *
+ * @return true if HART is allowed to do cold boot and false otherwise
+ */
+static inline bool sbi_platform_cold_boot_allowed(
+                                       const struct sbi_platform *plat,
+                                       u32 hartid)
+{
+       if (plat && sbi_platform_ops(plat)->cold_boot_allowed)
+               return sbi_platform_ops(plat)->cold_boot_allowed(hartid);
+       return true;
+}
+
 /**
 * Nascent (very early) initialization for current HART
 *
lib/sbi/sbi_init.c +5 -3
index a8500e5..d45cee6 100644
@@ -498,8 +498,11 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
        * HARTs which satisfy above condition.
        */
 
-       if (next_mode_supported && atomic_xchg(&coldboot_lottery, 1) == 0)
-               coldboot = TRUE;
+       if (sbi_platform_cold_boot_allowed(plat, hartid)) {
+               if (next_mode_supported &&
+                   atomic_xchg(&coldboot_lottery, 1) == 0)
+                       coldboot = true;
+       }
 
       /*
        * Do platform specific nascent (very early) initialization so
--

2.25.1

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

Signature · 3 lines
opensbi mailing list
opensbi at lists.infradead.org
http://lists.infradead.org/mailman/listinfo/opensbi
#4 lore raw

PATCH v7 1/4 lib: sbi: Allow platform to influence cold boot HART selection

Resending ...

Quoted 14 lines · On Tue, Apr 4, 2023 at 10:50?PM Jessica Clarke <[email protected]> wrote:
Quoted 12 lines · Anup Patel
Quoted 9 lines · Wei Liang Lim

From: Anup Patel <[email protected]>

We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization.

If this platform callback is not available then any HART can do cold boot initialization.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Applied this patch to the riscv/opensbi repo

So, no attempt to engage with my objections to the concept as a whole in past patches? Instead you just steamrolled it through over the holiday period. I didn?t even notice this had been re-posted until now.

I did wait 9 days for any comments and since there were no comments I assumed there are no objections.

Overall from OpenSBI perspective, it is good to allow platforms to select HARTs which can do the cold boot sequence.

Regards,
Anup

Quoted 81 lines

Jess

Quoted 77 lines

Thanks,
Anup

Quoted 65 lines

---
include/sbi/sbi_platform.h | 20 ++++++++++++++++++++
lib/sbi/sbi_init.c | 7 +++++--

2 files changed, 25 insertions(+), 2 deletions(-)
include/sbi/sbi_platform.h +20 -0
index 722f27a..bd0d5ca 100644
@@ -65,6 +65,9 @@ enum sbi_platform_features {
 
 /** Platform functions */
 struct sbi_platform_operations {
+       /* Check if specified HART is allowed to do cold boot */
+       bool (*cold_boot_allowed)(u32 hartid);
+
       /* Platform nascent initialization */
       int (*nascent_init)(void);
 
@@ -356,6 +359,23 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,
       return FALSE;
 }
 
+/**
+ * Check whether given HART is allowed to do cold boot
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param hartid HART ID
+ *
+ * @return true if HART is allowed to do cold boot and false otherwise
+ */
+static inline bool sbi_platform_cold_boot_allowed(
+                                       const struct sbi_platform *plat,
+                                       u32 hartid)
+{
+       if (plat && sbi_platform_ops(plat)->cold_boot_allowed)
+               return sbi_platform_ops(plat)->cold_boot_allowed(hartid);
+       return true;
+}
+
 /**
 * Nascent (very early) initialization for current HART
 *
lib/sbi/sbi_init.c +5 -3
index a8500e5..d45cee6 100644
@@ -498,8 +498,11 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
        * HARTs which satisfy above condition.
        */
 
-       if (next_mode_supported && atomic_xchg(&coldboot_lottery, 1) == 0)
-               coldboot = TRUE;
+       if (sbi_platform_cold_boot_allowed(plat, hartid)) {
+               if (next_mode_supported &&
+                   atomic_xchg(&coldboot_lottery, 1) == 0)
+                       coldboot = true;
+       }
 
       /*
        * Do platform specific nascent (very early) initialization so
--

2.25.1

Quoted 4 lines

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

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

#5 lore raw

PATCH v7 1/4 lib: sbi: Allow platform to influence cold boot HART selection

Quoted 26 lines · Anup Patel

Resending ...

Quoted 14 lines · On Tue, Apr 4, 2023 at 10:50?PM Jessica Clarke <[email protected]> wrote:
Quoted 12 lines · Anup Patel
Quoted 9 lines · Wei Liang Lim

From: Anup Patel <[email protected]>

We add an optional cold_boot_allowed() platform callback which allows platform support to decide which HARTs can do cold boot initialization.

If this platform callback is not available then any HART can do cold boot initialization.

Quoted 7 lines
Quoted 3 lines
Quoted 1 line

Applied this patch to the riscv/opensbi repo

So, no attempt to engage with my objections to the concept as a whole in past patches? Instead you just steamrolled it through over the holiday period. I didn?t even notice this had been re-posted until now.

Quoted 5 lines

I did wait 9 days for any comments and since there were no comments I assumed there are no objections.

Overall from OpenSBI perspective, it is good to allow platforms to select HARTs which can do the cold boot sequence.

I shouldn?t have to repeat unaddressed comments from previous patches that were the reason behind it being reverted; reposting a patch doesn?t suddenly make the objections go away. If OpenSBI used a code review system from this millennium then updating the patch set wouldn?t lose past comments, but if you want to use outdated processes like mailing lists for code review then it?s on you as maintainer to make sure previous threads? comments have been addressed. If you don?t want to do that then use a better system, but I?m not going to waste my life repeating myself because you insist on doing everything the Linux way and remaining stuck in the previous century.

Plus, like many, I was on annual leave for much of that period, given it was 29th Dec - 7th Jan, so those 9 days are extremely aggressive in the circumstances. There was zero urgency to land this even if the overall consensus was to do so.

I am very unhappy with the process followed here, it is not the way in which you build a community of people reviewing code, nor how you build high-quality software.

I see no technical reason why a specific hart needs to perform the cold boot sequence, and if it does then you can key that off the compatible.

Jess

Quoted 83 lines

Regards,
Anup

Quoted 80 lines

Jess

Quoted 77 lines

Thanks,
Anup

Quoted 65 lines

---
include/sbi/sbi_platform.h | 20 ++++++++++++++++++++
lib/sbi/sbi_init.c | 7 +++++--

2 files changed, 25 insertions(+), 2 deletions(-)
include/sbi/sbi_platform.h +20 -0
index 722f27a..bd0d5ca 100644
@@ -65,6 +65,9 @@ enum sbi_platform_features {
 
 /** Platform functions */
 struct sbi_platform_operations {
+       /* Check if specified HART is allowed to do cold boot */
+       bool (*cold_boot_allowed)(u32 hartid);
+
      /* Platform nascent initialization */
      int (*nascent_init)(void);
 
@@ -356,6 +359,23 @@ static inline bool sbi_platform_hart_invalid(const struct sbi_platform *plat,
      return FALSE;
 }
 
+/**
+ * Check whether given HART is allowed to do cold boot
+ *
+ * @param plat pointer to struct sbi_platform
+ * @param hartid HART ID
+ *
+ * @return true if HART is allowed to do cold boot and false otherwise
+ */
+static inline bool sbi_platform_cold_boot_allowed(
+                                       const struct sbi_platform *plat,
+                                       u32 hartid)
+{
+       if (plat && sbi_platform_ops(plat)->cold_boot_allowed)
+               return sbi_platform_ops(plat)->cold_boot_allowed(hartid);
+       return true;
+}
+
 /**
 * Nascent (very early) initialization for current HART
 *
lib/sbi/sbi_init.c +5 -3
index a8500e5..d45cee6 100644
@@ -498,8 +498,11 @@ void __noreturn sbi_init(struct sbi_scratch *scratch)
       * HARTs which satisfy above condition.
       */
 
-       if (next_mode_supported && atomic_xchg(&coldboot_lottery, 1) == 0)
-               coldboot = TRUE;
+       if (sbi_platform_cold_boot_allowed(plat, hartid)) {
+               if (next_mode_supported &&
+                   atomic_xchg(&coldboot_lottery, 1) == 0)
+                       coldboot = true;
+       }
 
      /*
       * Do platform specific nascent (very early) initialization so
--

2.25.1

Quoted 4 lines

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

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

#6 lore raw

PATCH v7 2/4 platform: generic: Allow platform_override to select cold boot HART

In reply to Wei Liang Lim

From: Anup Patel <[email protected]>

We add a generic platform override callback to allow platform specific selection of cold boot HART.

---
 platform/generic/include/platform_override.h | 1 +
 platform/generic/platform.c                  | 9 +++++++++
 2 files changed, 10 insertions(+)
platform/generic/include/platform_override.h +1 -0
index 7f1558d..21354e9 100644
@@ -18,6 +18,7 @@ struct platform_override {
 	const struct fdt_match *match_table;
 	u64 (*features)(const struct fdt_match *match);
 	u64 (*tlbr_flush_limit)(const struct fdt_match *match);
+	bool (*cold_boot_allowed)(u32 hartid, const struct fdt_match *match);
 	int (*early_init)(bool cold_boot, const struct fdt_match *match);
 	int (*final_init)(bool cold_boot, const struct fdt_match *match);
 	void (*early_exit)(const struct fdt_match *match);
platform/generic/platform.c +9 -0
index bfe15f0..5fb0dc6 100644
@@ -122,6 +122,14 @@ fail:
 		wfi();
 }
 
+static bool generic_cold_boot_allowed(u32 hartid)
+{
+	if (generic_plat && generic_plat->cold_boot_allowed)
+		return generic_plat->cold_boot_allowed(
+						hartid, generic_plat_match);
+	return true;
+}
+
 static int generic_nascent_init(void)
 {
 	if (platform_has_mlevel_imsic)
@@ -261,6 +269,7 @@ static int generic_console_init(void)
 }
 
 const struct sbi_platform_operations platform_ops = {
+	.cold_boot_allowed	= generic_cold_boot_allowed,
 	.nascent_init		= generic_nascent_init,
 	.early_init		= generic_early_init,
 	.final_init		= generic_final_init,
Signature · 1 line
2.25.1
Applied
#7 lore raw

PATCH v7 2/4 platform: generic: Allow platform_override to select cold boot HART

Quoted 7 lines · Wei Liang Lim

From: Anup Patel <[email protected]>

We add a generic platform override callback to allow platform specific selection of cold boot HART.

Applied this patch to the riscv/opensbi repo

Thanks,
Anup

Quoted 52 lines
---
 platform/generic/include/platform_override.h | 1 +
 platform/generic/platform.c                  | 9 +++++++++
 2 files changed, 10 insertions(+)
platform/generic/include/platform_override.h +1 -0
index 7f1558d..21354e9 100644
@@ -18,6 +18,7 @@ struct platform_override {
        const struct fdt_match *match_table;
        u64 (*features)(const struct fdt_match *match);
        u64 (*tlbr_flush_limit)(const struct fdt_match *match);
+       bool (*cold_boot_allowed)(u32 hartid, const struct fdt_match *match);
        int (*early_init)(bool cold_boot, const struct fdt_match *match);
        int (*final_init)(bool cold_boot, const struct fdt_match *match);
        void (*early_exit)(const struct fdt_match *match);
platform/generic/platform.c +9 -1
index bfe15f0..5fb0dc6 100644
@@ -122,6 +122,14 @@ fail:
                wfi();
 }
 
+static bool generic_cold_boot_allowed(u32 hartid)
+{
+       if (generic_plat && generic_plat->cold_boot_allowed)
+               return generic_plat->cold_boot_allowed(
+                                               hartid, generic_plat_match);
+       return true;
+}
+
 static int generic_nascent_init(void)
 {
        if (platform_has_mlevel_imsic)
@@ -261,6 +269,7 @@ static int generic_console_init(void)
 }
 
 const struct sbi_platform_operations platform_ops = {
+       .cold_boot_allowed      = generic_cold_boot_allowed,
        .nascent_init           = generic_nascent_init,
        .early_init             = generic_early_init,
        .final_init             = generic_final_init,
--

2.25.1

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

#8 lore raw

PATCH v7 3/4 platform: generic: Allow platform_override to perform firmware init

In reply to Wei Liang Lim

We add a generic platform override callback to allow platform specific firmware init.

---
 platform/generic/include/platform_override.h | 1 +
 platform/generic/platform.c                  | 3 +++
 2 files changed, 4 insertions(+)
platform/generic/include/platform_override.h +1 -0
index 21354e9..a59b06a 100644
@@ -26,6 +26,7 @@ struct platform_override {
 	int (*fdt_fixup)(void *fdt, const struct fdt_match *match);
 	int (*extensions_init)(const struct fdt_match *match,
 			       struct sbi_hart_features *hfeatures);
+	void (*fw_init)(void *fdt, const struct fdt_match *match);
 	int (*vendor_ext_check)(long extid, const struct fdt_match *match);
 	int (*vendor_ext_provider)(long extid, long funcid,
 				   const struct sbi_trap_regs *regs,
platform/generic/platform.c +3 -0
index 5fb0dc6..a34d3b0 100644
@@ -85,6 +85,9 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,
 
 	fw_platform_lookup_special(fdt, root_offset);
 
+	if (generic_plat && generic_plat->fw_init)
+		generic_plat->fw_init(fdt, generic_plat_match);
+
 	model = fdt_getprop(fdt, root_offset, "model", &len);
 	if (model)
 		sbi_strncpy(platform.name, model, sizeof(platform.name) - 1);
Signature · 1 line
2.25.1
Applied
#9 lore raw

PATCH v7 3/4 platform: generic: Allow platform_override to perform firmware init

Quoted 6 lines · Wei Liang Lim

We add a generic platform override callback to allow platform specific firmware init.

Looks good to me.

Applied this patch to the riscv/opensbi repo

Thanks,
Anup

Quoted 39 lines
---
 platform/generic/include/platform_override.h | 1 +
 platform/generic/platform.c                  | 3 +++
 2 files changed, 4 insertions(+)
platform/generic/include/platform_override.h +1 -0
index 21354e9..a59b06a 100644
@@ -26,6 +26,7 @@ struct platform_override {
        int (*fdt_fixup)(void *fdt, const struct fdt_match *match);
        int (*extensions_init)(const struct fdt_match *match,
                               struct sbi_hart_features *hfeatures);
+       void (*fw_init)(void *fdt, const struct fdt_match *match);
        int (*vendor_ext_check)(long extid, const struct fdt_match *match);
        int (*vendor_ext_provider)(long extid, long funcid,
                                   const struct sbi_trap_regs *regs,
platform/generic/platform.c +3 -1
index 5fb0dc6..a34d3b0 100644
@@ -85,6 +85,9 @@ unsigned long fw_platform_init(unsigned long arg0, unsigned long arg1,
 
        fw_platform_lookup_special(fdt, root_offset);
 
+       if (generic_plat && generic_plat->fw_init)
+               generic_plat->fw_init(fdt, generic_plat_match);
+
        model = fdt_getprop(fdt, root_offset, "model", &len);
        if (model)
                sbi_strncpy(platform.name, model, sizeof(platform.name) - 1);
--

2.25.1

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

#10 lore raw

PATCH v7 4/4 generic/starfive: Add Starfive JH7110 platform implementation

In reply to Wei Liang Lim

Add Starfive JH7110 platform implementation

---
 platform/generic/Kconfig             |  4 +++
 platform/generic/configs/defconfig   |  1 +
 platform/generic/starfive/jh7110.c   | 47 ++++++++++++++++++++++++++++
 platform/generic/starfive/objects.mk |  6 ++++
 4 files changed, 58 insertions(+)
 create mode 100644 platform/generic/starfive/jh7110.c
 create mode 100644 platform/generic/starfive/objects.mk
platform/generic/Kconfig +4 -0
index 62c7a2d..47c10e5 100644
@@ -45,4 +45,8 @@ config PLATFORM_SIFIVE_FU740
 	depends on FDT_RESET && FDT_I2C
 	default n
 
+config PLATFORM_STARFIVE_JH7110
+	bool "StarFive JH7110 support"
+	default n
+
 endif
platform/generic/configs/defconfig +1 -0
index 47fca95..4b0842e 100644
@@ -3,6 +3,7 @@ CONFIG_PLATFORM_ANDES_AE350=y
 CONFIG_PLATFORM_RENESAS_RZFIVE=y
 CONFIG_PLATFORM_SIFIVE_FU540=y
 CONFIG_PLATFORM_SIFIVE_FU740=y
+CONFIG_PLATFORM_STARFIVE_JH7110=y
 CONFIG_FDT_GPIO=y
 CONFIG_FDT_GPIO_SIFIVE=y
 CONFIG_FDT_I2C=y
platform/generic/starfive/jh7110.c new file +47 -0

47 lines not on this page · raw message

platform/generic/starfive/objects.mk new file +6 -0
new file mode 100644
index 0000000..0b900fb
@@ -0,0 +1,6 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+
+carray-platform_override_modules-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive_jh7110
+platform-objs-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive/jh7110.o
Signature · 1 line
2.25.1
Applied
#11 lore raw

PATCH v7 4/4 generic/starfive: Add Starfive JH7110 platform implementation

Quoted 68 lines · Wei Liang Lim

Add Starfive JH7110 platform implementation

---
 platform/generic/Kconfig             |  4 +++
 platform/generic/configs/defconfig   |  1 +
 platform/generic/starfive/jh7110.c   | 47 ++++++++++++++++++++++++++++
 platform/generic/starfive/objects.mk |  6 ++++
 4 files changed, 58 insertions(+)
 create mode 100644 platform/generic/starfive/jh7110.c
 create mode 100644 platform/generic/starfive/objects.mk
platform/generic/Kconfig +4 -0
index 62c7a2d..47c10e5 100644
@@ -45,4 +45,8 @@ config PLATFORM_SIFIVE_FU740
        depends on FDT_RESET && FDT_I2C
        default n
 
+config PLATFORM_STARFIVE_JH7110
+       bool "StarFive JH7110 support"
+       default n
+
 endif
platform/generic/configs/defconfig +1 -0
index 47fca95..4b0842e 100644
@@ -3,6 +3,7 @@ CONFIG_PLATFORM_ANDES_AE350=y
 CONFIG_PLATFORM_RENESAS_RZFIVE=y
 CONFIG_PLATFORM_SIFIVE_FU540=y
 CONFIG_PLATFORM_SIFIVE_FU740=y
+CONFIG_PLATFORM_STARFIVE_JH7110=y
 CONFIG_FDT_GPIO=y
 CONFIG_FDT_GPIO_SIFIVE=y
 CONFIG_FDT_I2C=y
platform/generic/starfive/jh7110.c new file +22 -0
new file mode 100644
index 0000000..0eb60b2
@@ -0,0 +1,47 @@
+/*
+ * SPDX-License-Identifier: BSD-2-Clause
+ *
+ * Copyright (c) 2022 StarFive
+ *
+ * Authors:
+ *   Wei Liang Lim <[email protected]>
+ */
+
+#include <libfdt.h>
+#include <platform_override.h>
+#include <sbi_utils/fdt/fdt_helper.h>
+
+static u32 selected_hartid = -1;
+
+static bool starfive_jh7110_cold_boot_allowed(u32 hartid,
+                                  const struct fdt_match *match)
+{
+       if (selected_hartid != -1)
+               return (selected_hartid == hartid);
+
+       return true;

platform/generic/starfive/jh7110.c line 32

Quoted 10 lines
platform/generic/starfive/jh7110.c new file +10 -0
+}
+
+static void starfive_jh7110_fw_init(void *fdt, const struct fdt_match *match)
+{
+       const fdt32_t *val;
+       int len, coff;
+
+       coff = fdt_path_offset(fdt, "/chosen");
+       if (-1 < coff) {
+               val = fdt_getprop(fdt, coff, "boot-hart-id", &len);

The DT should be "starfive,boot-hart-id" to make it explicit that it is StarFive specific DT property. I have added the "starfive," prefix at the time of merging this patch.

Quoted 31 lines
platform/generic/starfive/jh7110.c new file +15 -0
+               if (val && len >= sizeof(fdt32_t))
+                       selected_hartid = (u32) fdt32_to_cpu(*val);
+       }
+}
+
+static const struct fdt_match starfive_jh7110_match[] = {
+       { .compatible = "starfive,jh7110" },
+       { },
+};
+
+const struct platform_override starfive_jh7110 = {
+       .match_table = starfive_jh7110_match,
+       .cold_boot_allowed = starfive_jh7110_cold_boot_allowed,
+       .fw_init = starfive_jh7110_fw_init,
+};
platform/generic/starfive/objects.mk new file +6 -1
new file mode 100644
index 0000000..0b900fb
@@ -0,0 +1,6 @@
+#
+# SPDX-License-Identifier: BSD-2-Clause
+#
+
+carray-platform_override_modules-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive_jh7110
+platform-objs-$(CONFIG_PLATFORM_STARFIVE_JH7110) += starfive/jh7110.o
--

2.25.1

Quoted 4 lines

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

Applied this patch to the riscv/opensbi repo

Thanks,
Anup