Initial ESWIN/EIC7700 and Hifive P550 support
v5 cover Initial ESWIN/EIC7700 and Hifive P550 support
EIC7700 is the SoC used in HiFive P550 and Milk-V Megrez. This SoC is currently one of the only off-the-shelf board/chips that support H extension, although it's v0.6.1. It also supports pre-ratified N-trace. Add support for it so people can benefit from latest OpenSBI features.
The device-tree of HiFive P550 has been upstreamed to Linux:
https://lore.kernel.org/all/[email protected]/
However U-boot is not, and there are bugs in vendor U-boot device-tree, and also inconsistencies between the two. Thus, this patch is coded with the upstreamed device-tree as the reference, but tested with the patched vendor U-boot device tree as FW_FDT_PATH. The patched vendor U-boot is hosted here: https://github.com/ganboing/u-boot-eic7x/tree/eic7x-dt-fix
Refer to the last PATCH for the instructions on building the firmware blob and launch it through UART boot.
The major complication of this chip is that it requires certain memory regions to be blocked with PMP entries to prevent speculative execution or HW prefetcher from touching the data-cacheable regions within to avoid bus errors. Due to the fact that this SoC handles cache incoherent DMA by mapping memory twice, one as cached, and the other as uncached, we also need an extra PMP to protect the OpenSBI in the uncached portion in address space. The PMP handling is tricky, so I documented it very extensively for people to reason about it. I managed to get it done with only NAPOT PMP entries and still got 1 free PMP for root harts for die 0 (No free PMP for die 1 root harts). This even permits a udomain/tdomain like partitioning, so we can even try out TEEs. Sample boot log:
OpenSBI v1.7-95-g68b64d77
Build time: 2025-12-17 05:08:58 -0800
Build compiler: gcc version 13.2.0 (gc891d8dc23e-dirty)
____ _____ ____ _____
/ __ \ / ____| _ \_ _|
| | | |_ __ ___ _ __ | (___ | |_) || |
| | | | '_ \ / _ \ '_ \ \___ \| _ < | |
| |__| | |_) | __/ | | |____) | |_) || |_
\____/| .__/ \___|_| |_|_____/|____/_____|
| |
|_|Platform Name : SiFive HiFive Premier P550
Platform Features : medeleg
Platform HART Count : 4
Platform HART Protection : eic7700_pmp
Platform IPI Device : aclint-mswi
Platform Timer Device : aclint-mtimer @ 1000000Hz
Platform Console Device : uart8250
Platform HSM Device : ---
Platform PMU Device : ---
Platform Reboot Device : hfp_reset
Platform Shutdown Device : hfp_reset
Platform Suspend Device : ---
Platform CPPC Device : ---
Firmware Base : 0x80000000
Firmware Size : 357 KB
Firmware RW Offset : 0x40000
Firmware RW Size : 101 KB
Firmware Heap Offset : 0x4d000
Firmware Heap Size : 49 KB (total), 0 KB (reserved), 13 KB (used), 35 KB (free)
Firmware Scratch Size : 4096 B (total), 424 B (used), 3672 B (free)
Runtime SBI Version : 3.0
Standard SBI Extensions : time,rfnc,ipi,base,hsm,srst,pmu,dbcn,fwft,legacy,dbtr,sse
Experimental SBI Extensions : none
Domain0 Name : root
Domain0 Boot HART : 3
Domain0 HARTs : 0*,1*,2*,3*
Domain0 Region00 : 0x0000000080000000-0x000000008007ffff M: (F,R,W,X) S/U: ()
Domain0 Region01 : 0x000000c000000000-0x000000c00007ffff M: (I,F,R,W,X) S/U: ()
Domain0 Region02 : 0x0000000002000000-0x000000000200ffff M: (I,R,W) S/U: ()
Domain0 Region03 : 0x0000000000000000-0x000000007fffffff M: (I,R,W) S/U: (R,W)
Domain0 Region04 : 0x0000000000000000-0x0000000fffffffff M: (R,W) S/U: (R,W,X)
Domain0 Region05 : 0x0000000000000000-0x0000007fffffffff M: (I) S/U: ()
Domain0 Region06 : 0x0000000000000000-0xffffffffffffffff M: () S/U: (R,W,X)
Domain0 Next Address : 0x0000000080200000
Domain0 Next Arg1 : 0x00000000f8000000
Domain0 Next Mode : S-mode
Domain0 SysReset : yes
Domain0 SysSuspend : yes
Boot HART ID : 3
Boot HART Domain : root
Boot HART Priv Version : v1.11
Boot HART Base ISA : rv64imafdchx
Boot HART ISA Extensions : sscofpmf,zihpm,sdtrig
Boot HART PMP Count : 8
Boot HART PMP Granularity : 12 bits
Boot HART PMP Address Bits : 39
Boot HART MHPM Info : 4 (0x00000078)
Boot HART Debug Triggers : 4 triggers
Boot HART MIDELEG : 0x0000000000002666
Boot HART MEDELEG : 0x0000000000f0b509
---
Changes in v5:
- Add Hifive P550 shutdown/reboot support.
- Add a sbi_printf() just before SoC reset to workaround flaky memory corruption issue after reset. This issue has been reported to ESWIN, and it's been reproduced with their vendor OpenSBI code. ESWIN's actively investigating it.
Changes in v4:
- Adapt to the hart protection abstraction.
Also make use of sbi_hart_pmp_fence for correctness.
- Specify MMIO flag for the uncached mapping of OpenSBI.
It'll avoid adding an extraneous reserved memory region in FDT for S mode.
Changes in v3:
- Figure out the cause behind bus error, and document it properly
- Drop the consolidation logic and let the lib/memregion logic to optimize out unnecessary regions -- simplifies many things.
- Better and more comprehensive comments in source code.
- Support tdomain/udomain like use cases on die 0.
Changes in v2:
- Major enhancement of PMP consolidation logic. Also fixed a Linux Panic bug due to the mismatch between PMP settings and reserved memory regions passed to Linux via FDT.
- Also protects the OpenSBI firmware in uncached memory portion of address space.
- More detailed documentation on EIC770X/P550
---
Bo Gan (7):
lib: sbi_hart_pmp: make sbi_hart_pmp_fence public
lib: sbi_domain: add sbi_domain_get_oldpmp_flags
lib: sbi_domain: make is_region_subset public
lib: sbi: give platform choice of using single memregion to cover
OpenSBI
platform: generic: eswin: add EIC7700
lib: utils/serial: Support multiple UART8250 devices
platform: generic: eswin: Add shutdown/reboot support for Hifive
Premier P550
include/sbi/sbi_domain.h | 29 ++ include/sbi/sbi_hart_pmp.h | 1 + include/sbi/sbi_platform.h | 21 ++ include/sbi_utils/serial/uart8250.h | 16 + lib/sbi/sbi_domain.c | 81 +++-- lib/sbi/sbi_hart_pmp.c | 19 +- lib/sbi/sbi_init.c | 1 - lib/utils/serial/uart8250.c | 104 +++--- platform/generic/Kconfig | 5 + platform/generic/configs/defconfig | 1 + platform/generic/eswin/Kconfig | 29 ++ platform/generic/eswin/eic770x.c | 405 +++++++++++++++++++++++ platform/generic/eswin/hfp.c | 118 +++++++ platform/generic/eswin/objects.mk | 12 + platform/generic/include/eswin/eic770x.h | 101 ++++++ platform/generic/include/eswin/hfp.h | 64 ++++ 16 files changed, 912 insertions(+), 95 deletions(-) create mode 100644 platform/generic/eswin/Kconfig create mode 100644 platform/generic/eswin/eic770x.c create mode 100644 platform/generic/eswin/hfp.c create mode 100644 platform/generic/eswin/objects.mk create mode 100644 platform/generic/include/eswin/eic770x.h create mode 100644 platform/generic/include/eswin/hfp.h
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v5 1/7 lib: sbi_hart_pmp: make sbi_hart_pmp_fence public
sbi_hart_pmp_fence can now be utilized by other hart-protection implementation.
--- include/sbi/sbi_hart_pmp.h | 1 + lib/sbi/sbi_hart_pmp.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-)
include/sbi/sbi_hart_pmp.h +1 -0
@@ -15,6 +15,7 @@ unsigned int sbi_hart_pmp_count(struct sbi_scratch *scratch);unsigned int sbi_hart_pmp_log2gran (struct sbi_scratch *scratch);unsigned int sbi_hart_pmp_addrbits (struct sbi_scratch *scratch);bool sbi_hart_smepmp_is_fw_region (unsigned int pmp_idx); +void sbi_hart_pmp_fence (void );int sbi_hart_pmp_init (struct sbi_scratch *scratch);#endif
lib/sbi/sbi_hart_pmp.c +1 -1
@@ -62,7 +62,7 @@ bool sbi_hart_smepmp_is_fw_region(unsigned int pmp_idx)return bitmap_test (fw_smepmp_ids, pmp_idx) ? true : false; } -static void sbi_hart_pmp_fence (void ) +void sbi_hart_pmp_fence (void ) {/* * As per section 3.7.2 of privileged specification v1.12,
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v5 2/7 lib: sbi_domain: add sbi_domain_get_oldpmp_flags
In reply to Bo GanFactor out logic in sbi_hart_oldpmp_configure into function sbi_domain_get_oldpmp_flags, analogous to sbi_domain_get_smepmp_flags. Platform specific hart-protection implementation can now leverage it.
--- include/sbi/sbi_domain.h | 7 +++++++ lib/sbi/sbi_domain.c | 22 ++++++++++++++++++++++ lib/sbi/sbi_hart_pmp.c | 17 +---------------- 3 files changed, 30 insertions(+), 16 deletions(-)
include/sbi/sbi_domain.h +7 -0
@@ -253,6 +253,13 @@ void sbi_domain_memregion_init(unsigned long addr,unsigned long flags, struct sbi_domain_memregion *reg); +/** +* Return the oldpmp pmpcfg LRWX encoding for the flags in @reg. +* +* @param reg pointer to memory region; its flags field encodes permissions. +*/ +unsigned int sbi_domain_get_oldpmp_flags (struct sbi_domain_memregion *reg); +/** * Return the Smepmp pmpcfg LRWX encoding for the flags in @reg. *
lib/sbi/sbi_domain.c +22 -0
@@ -121,6 +121,28 @@ void sbi_domain_memregion_init(unsigned long addr, } } +unsigned int sbi_domain_get_oldpmp_flags (struct sbi_domain_memregion *reg) +{ + +unsigned int pmp_flags =0 ; + +/* +* If permissions are to be enforced for all modes on +* this region, the lock bit should be set. +*/ +if (reg->flags &SBI_DOMAIN_MEMREGION_ENF_PERMISSIONS ) + pmp_flags |=PMP_L ; + +if (reg->flags &SBI_DOMAIN_MEMREGION_SU_READABLE ) + pmp_flags |=PMP_R ; +if (reg->flags &SBI_DOMAIN_MEMREGION_SU_WRITABLE ) + pmp_flags |=PMP_W ; +if (reg->flags &SBI_DOMAIN_MEMREGION_SU_EXECUTABLE ) + pmp_flags |=PMP_X ; + +return pmp_flags; +} +unsigned int sbi_domain_get_smepmp_flags (struct sbi_domain_memregion *reg) {unsigned int pmp_flags =0 ;
lib/sbi/sbi_hart_pmp.c +1 -16
@@ -272,22 +272,7 @@ static int sbi_hart_oldpmp_configure(struct sbi_scratch *scratch)if (!is_valid_pmp_idx (pmp_count, pmp_idx))return SBI_EFAIL ; - pmp_flags =0 ; - -/* -* If permissions are to be enforced for all modes on -* this region, the lock bit should be set. -*/ -if (reg->flags &SBI_DOMAIN_MEMREGION_ENF_PERMISSIONS ) - pmp_flags |=PMP_L ; - -if (reg->flags &SBI_DOMAIN_MEMREGION_SU_READABLE ) - pmp_flags |=PMP_R ; -if (reg->flags &SBI_DOMAIN_MEMREGION_SU_WRITABLE ) - pmp_flags |=PMP_W ; -if (reg->flags &SBI_DOMAIN_MEMREGION_SU_EXECUTABLE ) - pmp_flags |=PMP_X ; - + pmp_flags =sbi_domain_get_oldpmp_flags (reg); pmp_addr = reg->base >>PMP_SHIFT ;if (pmp_log2gran <= reg->order && pmp_addr < pmp_addr_max) { sbi_platform_pmp_set(sbi_platform_ptr(scratch),
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v5 3/7 lib: sbi_domain: make is_region_subset public
In reply to Bo GanThe helper function is renamed as sbi_domain_memregion_is_subset, and made public in header file.
Also add a convenient helper of sbi_domain_for_each_memregion_idx.
--- include/sbi/sbi_domain.h | 22 ++++++++++++++++++++++ lib/sbi/sbi_domain.c | 23 +++-------------------- 2 files changed, 25 insertions(+), 20 deletions(-)
include/sbi/sbi_domain.h +22 -0
@@ -164,6 +164,25 @@ struct sbi_domain_memregion {unsigned long flags; }; +/** Check if regionA is sub-region of regionB */ +static inline bool sbi_domain_memregion_is_subset ( +const struct sbi_domain_memregion *regA, +const struct sbi_domain_memregion *regB) +{ +ulong regA_start = regA->base; +ulong regA_end = regA->base + (BIT (regA->order) -1 ); +ulong regB_start = regB->base; +ulong regB_end = regB->base + (BIT (regB->order) -1 ); + +if ((regB_start <= regA_start) && + (regA_start < regB_end) && + (regB_start < regA_end) && + (regA_end <= regB_end)) +return true; + +return false; +} +/** Representation of OpenSBI domain */ struct sbi_domain {/** Node in linked list of domains */
@@ -222,6 +241,9 @@ extern struct sbi_dlist domain_list;#define sbi_domain_for_each_memregion (__d, __r) \ for ((__r) = (__d)->regions; (__r)->order; (__r)++) +#define sbi_domain_for_each_memregion_idx (__d, __r, __i) \ + for ((__r) = (__d)->regions, (__i) = 0; (__r)->order; (__r)++, (__i)++) +/** * Check whether given HART is assigned to specified domain * @param dom pointer to domain
lib/sbi/sbi_domain.c +3 -20
@@ -285,29 +285,12 @@ static bool is_region_valid(const struct sbi_domain_memregion *reg)return true; } -/** Check if regionA is sub-region of regionB */ -static bool is_region_subset (const struct sbi_domain_memregion *regA, -const struct sbi_domain_memregion *regB) -{ -ulong regA_start = regA->base; -ulong regA_end = regA->base + (BIT (regA->order) -1 ); -ulong regB_start = regB->base; -ulong regB_end = regB->base + (BIT (regB->order) -1 ); - -if ((regB_start <= regA_start) && - (regA_start < regB_end) && - (regB_start < regA_end) && - (regA_end <= regB_end)) -return true; - -return false; -} -/** Check if regionA can be replaced by regionB */ static bool is_region_compatible (const struct sbi_domain_memregion *regA,const struct sbi_domain_memregion *regB) { -if (is_region_subset (regA, regB) && regA->flags == regB->flags) +if (sbi_domain_memregion_is_subset (regA, regB) && + regA->flags == regB->flags)return true;return false;
@@ -367,7 +350,7 @@ static const struct sbi_domain_memregion *find_next_subset_region(sbi_domain_for_each_memregion (dom, sreg) {if (sreg == reg || (sreg->base <= addr) || - !is_region_subset (sreg, reg)) + !sbi_domain_memregion_is_subset (sreg, reg))continue ; if (!ret || (sreg->base < ret->base) ||
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v5 4/7 lib: sbi: give platform choice of using single memregion to cover OpenSBI
In reply to Bo GanBy default the OpenSBI itself is covered by 2 memregions for RX/RW sections. This is required by platforms with Smepmp to enforce proper permissions in M mode. Note: M-mode only regions can't have RWX permissions with Smepmp. Platforms with traditional PMPs won't be able to benefit from it, as both regions are effectively RWX in M mode, but usually it's harmless to so. Now we provide these platforms with an option to disable this logic. It saves 1 PMP entry. For platforms really in short of PMPs, it does make a difference.
Note: Platform requesting single OpenSBI memregion must be using
traditional (old) PMP. We expect the platform code to do the right thing.
--- include/sbi/sbi_platform.h | 21 +++++++++++++++++++++ lib/sbi/sbi_domain.c | 36 ++++++++++++++++++++++++------------ 2 files changed, 45 insertions(+), 12 deletions(-)
include/sbi/sbi_platform.h +21 -0
@@ -76,6 +76,9 @@ struct sbi_platform_operations {/* Check if specified HART is allowed to do cold boot */ bool (*cold_boot_allowed)(u32 hartid); +/* Check if platform requires single firmware region */ +bool (*single_fw_region)(void ); +/* Platform nascent initialization */ int (*nascent_init)(void );
@@ -347,6 +350,24 @@ static inline bool sbi_platform_cold_boot_allowed(return true; } +/** +* Check whether platform requires single firmware region +* +* Note: Single firmware region only works with legacy PMP because with +* Smepmp M-mode only regions can't have RWX permissions. +* +* @param plat pointer to struct sbi_platform +* +* @return true if single firmware region required and false otherwise +*/ +static inline bool sbi_platform_single_fw_region ( +const struct sbi_platform *plat) +{ +if (plat &&sbi_platform_ops (plat)->single_fw_region) +return sbi_platform_ops (plat)->single_fw_region (); +return false; +} +/** * Nascent (very early) initialization for current HART *
lib/sbi/sbi_domain.c +24 -12
@@ -923,18 +923,30 @@ int sbi_domain_init(struct sbi_scratch *scratch, u32 cold_hartid) root.possible_harts = root_hmask;/* Root domain firmware memory region */ -sbi_domain_memregion_init (scratch->fw_start, scratch->fw_rw_offset, - (SBI_DOMAIN_MEMREGION_M_READABLE | -SBI_DOMAIN_MEMREGION_M_EXECUTABLE | -SBI_DOMAIN_MEMREGION_FW ), - &root_memregs[root_memregs_count++]); - -sbi_domain_memregion_init ((scratch->fw_start + scratch->fw_rw_offset), - (scratch->fw_size - scratch->fw_rw_offset), - (SBI_DOMAIN_MEMREGION_M_READABLE | -SBI_DOMAIN_MEMREGION_M_WRITABLE | -SBI_DOMAIN_MEMREGION_FW ), - &root_memregs[root_memregs_count++]); +if (sbi_platform_single_fw_region (sbi_platform_ptr (scratch))) { +sbi_domain_memregion_init (scratch->fw_start, scratch->fw_size, + (SBI_DOMAIN_MEMREGION_M_READABLE | +SBI_DOMAIN_MEMREGION_M_WRITABLE | +SBI_DOMAIN_MEMREGION_M_EXECUTABLE | +SBI_DOMAIN_MEMREGION_FW ), + &root_memregs[root_memregs_count++]); + }else { +sbi_domain_memregion_init (scratch->fw_start, + scratch->fw_rw_offset, + (SBI_DOMAIN_MEMREGION_M_READABLE | +SBI_DOMAIN_MEMREGION_M_EXECUTABLE | +SBI_DOMAIN_MEMREGION_FW ), + &root_memregs[root_memregs_count++]); + +sbi_domain_memregion_init ((scratch->fw_start + + scratch->fw_rw_offset), + (scratch->fw_size - + scratch->fw_rw_offset), + (SBI_DOMAIN_MEMREGION_M_READABLE | +SBI_DOMAIN_MEMREGION_M_WRITABLE | +SBI_DOMAIN_MEMREGION_FW ), + &root_memregs[root_memregs_count++]); + } root.fw_region_inited = true;
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v5 5/7 platform: generic: eswin: add EIC7700
In reply to Bo GanInitial platform support for ESWIN Computing EIC7700 based on public SoC datasheet[1] and tested on HiFive Premier P550. Vendor U-boot/Linux boots fine, and I've tested Geekbench 6.5.0 Preview and got scores on par with the vendor OpenSBI. System shutdown/reboot for HiFive Premier P550 and other boards will be implemented in subsequent commits. At this point, only SoC-level warm reset is implemented.
The files and functions are intentionally named as eic770x in many places for future enhancements to support the 2 die version of the same SoC, namely EIC7702, seen on DC-ROMA AI PC FML13V03 [2]. This patch set only deals with the single die version, and the assumption is we can be either die with id=0 or id=1, but there's only a single die in the system, or we are only using a single die out of 2. However, the way the SoC handles 2- die greatly affects how we configure it in a 1-die setup. EIC770X address map has die 0/1 memory regions interleaved (see comments in eic770x.c). If only 1 die is connected or active, it creates holes in the address map for those regions corresponding to the remote die. When speculative- execution or HW prefetcher touches data-cacheable regions that happen to fall into those holes, it can trigger bus error. Specifically:
- Remote (non-existent) die L3 zero device
- Remote (non-existent) die cached memory region
- Other holes in Memory Port
To make matters worse, EIC770X doesn't have cache coherent DMA, and due to the fact that the P550 core lacks Svpbmt, the SoC maps main memory twice as different regions, so it can bypass cache and fetch the data directly from memory. In address space, we have two memory regions, one as cached, the other as uncached. Thus, we also need an extra PMP entry to protect OpenSBI blob from the uncached window. To do this, platform code requires single_fw_region, otherwise, we'll run out of PMP entries.
EIC770X also have several feature disable/enable CSRs accessible in M mode. By default many core features such as speculation and HW prefetch are disabled, and M mode software is responsible of enabling. Hence, introduce 4 new build time tunable parameters to Kconfig, which reflects the values get updated to those CSRs:
- ESWIN_EIC770X_FEAT0_CFG
- ESWIN_EIC770X_FEAT1_CFG
- ESWIN_EIC770X_L1_HWPF_CFG
- ESWIN_EIC770X_L2_HWPF_CFG
The default values are somewhat optimal for generic workloads. They are dumped when running SiFive's vendor OpenSBI, and in addition, with my own tuning to address the perf regression reported by drmpeg [3]
To build the firmware+u-boot blob, Use the following, and docs [4] for testing it with UART boot without flashing:
make FW_TEXT_START=0x80000000 \
FW_PAYLOAD_OFFSET=0x200000 \
FW_PAYLOAD_PATH=u-boot-nodtb.bin \
FW_PAYLOAD_FDT_ADDR=0xf8000000 \
FW_FDT_PATH=u-boot.dtb[1] https://github.com/eswincomputing/EIC7700X-SoC-Technical-Reference-Manual
[2] https://github.com/geerlingguy/sbc-reviews/issues/82
[3] https://forums.sifive.com/t/low-1-core-stream-bandwidth/7274/15
[4] https://github.com/ganboing/EIC770x-Docs/blob/main/p550/bootchain/UART-Boot.md
--- lib/sbi/sbi_init.c | 1 - platform/generic/Kconfig | 5 + platform/generic/configs/defconfig | 1 + platform/generic/eswin/Kconfig | 29 ++ platform/generic/eswin/eic770x.c | 403 +++++++++++++++++++++++ platform/generic/eswin/objects.mk | 11 + platform/generic/include/eswin/eic770x.h | 79 +++++ 7 files changed, 528 insertions(+), 1 deletion(-) create mode 100644 platform/generic/eswin/Kconfig create mode 100644 platform/generic/eswin/eic770x.c create mode 100644 platform/generic/eswin/objects.mk create mode 100644 platform/generic/include/eswin/eic770x.h
lib/sbi/sbi_init.c +0 -1
@@ -467,7 +467,6 @@ static void __noreturn init_warm_startup(struct sbi_scratch *scratch, rc =sbi_sse_init (scratch, false);if (rc)sbi_hart_hang (); -/* * Configure hart isolation at last because if SMEPMP is, * detected, M-mode access to the S/U space will be rescinded.
platform/generic/Kconfig +5 -0
@@ -97,7 +97,12 @@ config PLATFORM_SPACEMIT_K1 select FDT_HSM_SPACEMIT default n +config PLATFORM_ESWIN_EIC770X + bool "ESWIN EIC770X support" + default n + source "$(OPENSBI_SRC_DIR)/platform/generic/andes/Kconfig" +source "$(OPENSBI_SRC_DIR)/platform/generic/eswin/Kconfig" source "$(OPENSBI_SRC_DIR)/platform/generic/thead/Kconfig" endif
platform/generic/configs/defconfig +1 -0
@@ -11,6 +11,7 @@ CONFIG_PLATFORM_STARFIVE_JH7110=y CONFIG_PLATFORM_THEAD=y CONFIG_PLATFORM_MIPS_P8700=y CONFIG_PLATFORM_SPACEMIT_K1=y +CONFIG_PLATFORM_ESWIN_EIC770X=y CONFIG_FDT_CACHE=y CONFIG_FDT_CACHE_SIFIVE_CCACHE=y CONFIG_FDT_CACHE_SIFIVE_EC=y
platform/generic/eswin/Kconfig new file +29 -0
@@ -0,0 +1,29 @@ +# SPDX-License-Identifier: BSD-2-Clause + +config ESWIN_EIC770X_FEAT0_CFG + int "ESWIN EIC7700X Feature Disable 0 CSR Configuration" + default 0x4000 + help + CSR Value to initialize EIC770X_FEAT0 (0x7c1) with. + Refer to EIC770X SoC TRM for recommendations. + +config ESWIN_EIC770X_FEAT1_CFG + int "ESWIN EIC7700X Feature Disable 1 CSR Configuration" + default 0x80 + help + CSR Value to initialize EIC770X_FEAT1 (0x7c2) with. + Refer to EIC770X SoC TRM for recommendations. + +config ESWIN_EIC770X_L1_HWPF_CFG + int "ESWIN EIC7700X L1 HW Prefetcher CSR Configuration" + default 0x1005c1be649 + help + CSR Value to initialize EIC770X_L1_HWPF (0x7c3) with. + Refer to EIC770X SoC TRM for recommendations. + +config ESWIN_EIC770X_L2_HWPF_CFG + int "ESWIN EIC7700X L2 HW Prefetcher CSR Configuration" + default 0x929f + help + CSR Value to initialize EIC770X_L2_HWPF (0x7c4) with. + Refer to EIC770X SoC TRM for recommendations.
platform/generic/eswin/eic770x.c new file +403 -0
403 lines not on this page · raw message
platform/generic/eswin/objects.mk new file +11 -0
@@ -0,0 +1,11 @@ +# +# SPDX-License-Identifier: BSD-2-Clause +# +# Copyright (C) 2025 Bo Gan <[email protected]> +# + +carray-platform_override_modules-$(CONFIG_PLATFORM_ESWIN_EIC770X) += eswin_eic7700 +platform-objs-$(CONFIG_PLATFORM_ESWIN_EIC770X) += eswin/eic770x.o + +FW_PAYLOAD=y +FW_PAYLOAD_OFFSET=0x200000
platform/generic/include/eswin/eic770x.h new file +79 -0
79 lines not on this page · raw message
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v5 6/7 lib: utils/serial: Support multiple UART8250 devices
In reply to Bo GanPreviously we assume only 1 UART8250 instance can be used. Now we support multiple instances by introducing counterpart functions to putc/getc/init which take an extra *dev parameter, and name them as uart8250_device_xyz() The original functions without the *dev parameter will operate on the default instance exactly the same as before, so no changes on the caller is required.
Note: uart8250_device_init only does device initialization without the console registration logic.
--- include/sbi_utils/serial/uart8250.h | 16 +++++ lib/utils/serial/uart8250.c | 104 ++++++++++++++++------------ 2 files changed, 75 insertions(+), 45 deletions(-)
include/sbi_utils/serial/uart8250.h +16 -0
@@ -14,6 +14,22 @@#define UART_CAP_UUE BIT(0)/* Check UUE capability for XScale PXA UARTs */ +struct uart8250_device { +volatile char *base; +u32 in_freq; +u32 baudrate; +u32 reg_width; +u32 reg_shift; +}; + +int uart8250_device_getc (struct uart8250_device *dev); + +void uart8250_device_putc (struct uart8250_device *dev,char ch); + +void uart8250_device_init (struct uart8250_device *dev,unsigned long base, +u32 in_freq,u32 baudrate,u32 reg_shift, +u32 reg_width,u32 reg_offset,u32 caps); +int uart8250_init (unsigned long base,u32 in_freq,u32 baudrate,u32 reg_shift,u32 reg_width,u32 reg_offset,u32 caps);
lib/utils/serial/uart8250.c +59 -45
156 lines not on this page · raw message
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH v5 7/7 platform: generic: eswin: Add shutdown/reboot support for Hifive Premier P550
In reply to Bo GanHifive Premier P550[1] is a Mini-DTX form factor board with EIC7700X. It has a STM32F407VET6 onboard MCU acting as the BMC, controlling ATX power on/off while providing remote management features. The EIC7700X SoC/SoM communicates with the BMC via UART2, using ESWIN's protocol. The messages transmitted are fixed sizes (267 bytes), and depending on the type, can be directional or bi-directional. The shutdown and cold reboot requests are directional messages from SoC to BMC (NOTIFY type) with CMD_POWER_OFF or CMD_RESTART. The payload of shutdown/cold reboot requests should be empty and are ignored by the BMC at the moment. A HFP (Hifive Premier) specific reset device is registered in addition to the SoC reset device. For shutdown and cold reboot, the board-level reset takes precedence.
The definitions of the SoC <-> BMC message protocol is taken from ESWIN's repo [2]. The only file used from that repo is hf_common.h It's disjunctively dual licensed as (GPL-2.0-only OR BSD-2-Clause), hence, compatible with the license of OpenSBI. It's heavily modified and renamed as platform/generic/include/eswin/hfp.h. The author and copyright in the original file are retained.
Validated shutdown/core reboot working on Hifive Premier P550.
[1] https://www.sifive.com/boards/hifive-premier-p550#documentation
[2] https://github.com/eswincomputing/hifive-premier-p550-mcu-patches.git
--- platform/generic/eswin/eic770x.c | 2 + platform/generic/eswin/hfp.c | 118 +++++++++++++++++++++++ platform/generic/eswin/objects.mk | 1 + platform/generic/include/eswin/eic770x.h | 22 +++++ platform/generic/include/eswin/hfp.h | 64 ++++++++++++ 5 files changed, 207 insertions(+) create mode 100644 platform/generic/eswin/hfp.c create mode 100644 platform/generic/include/eswin/hfp.h
platform/generic/eswin/eic770x.c +2 -0
@@ -13,6 +13,7 @@#include <sbi/sbi_hart_pmp.h> #include <sbi/sbi_hart_protection.h> #include <eswin/eic770x.h> +#include <eswin/hfp.h> static struct sbi_hart_protection eswin_eic7700_pmp_protection;
@@ -393,6 +394,7 @@ static int eswin_eic7700_platform_init(const void *fdt, int nodeoff, }static const struct fdt_match eswin_eic7700_match[] = { + { .compatible ="sifive,hifive-premier-p550" , .data = &hfp_override }, { .compatible ="eswin,eic7700" }, { }, };
platform/generic/eswin/hfp.c new file +118 -0
118 lines not on this page · raw message
platform/generic/eswin/objects.mk +1 -0
@@ -6,6 +6,7 @@ carray-platform_override_modules-$(CONFIG_PLATFORM_ESWIN_EIC770X) += eswin_eic7700 platform-objs-$(CONFIG_PLATFORM_ESWIN_EIC770X) += eswin/eic770x.o +platform-objs-$(CONFIG_PLATFORM_ESWIN_EIC770X) += eswin/hfp.o FW_PAYLOAD=y FW_PAYLOAD_OFFSET=0x200000
platform/generic/include/eswin/eic770x.h +22 -0
@@ -48,7 +48,16 @@ struct eic770x_board_override {#define EIC770X_SYSPORT_SIZE 0x20000000UL#define EIC770X_SYSPORT_BASE (d) (0x40000000UL + EIC770X_SYSPORT_SIZE * (d))#define EIC770X_SYSPORT_LOCAL EIC770X_SYSPORT_BASE(current_hart_die()) + +#define EIC770X_UART0 (EIC770X_SYSPORT_LOCAL + 0x10900000UL) +#define EIC770X_UART_SIZE 0x10000UL +#define EIC770X_UART (x) (EIC770X_UART0 + EIC770X_UART_SIZE * (x)) +#define EIC770X_UART_REG_SHIFT 2 +#define EIC770X_UART_REG_WIDTH 4 +#define EIC770X_SYSCRG (EIC770X_SYSPORT_LOCAL + 0x11828000UL) +#define EIC770X_SYSCRG_LSPCLK0 (EIC770X_SYSCRG + 0x200UL) +#define EIC770X_SYSCRG_SYSCLK (EIC770X_SYSCRG + 0x20cUL)#define EIC770X_SYSCRG_RST (EIC770X_SYSCRG + 0x300UL)#define EIC770X_SYSCRG_RST_VAL 0x1AC0FFE6UL
@@ -76,4 +85,17 @@ struct eic770x_board_override {#define EIC770X_TO_UNCACHED (x) ((x) - EIC770X_CACHED_BASE + \ EIC770X_UNCACHED_BASE) +/* Clock definitions */ +#define EIC770X_XTAL_CLK_RATE 24000000UL +#define EIC770X_SPLL0_OUT1_RATE 1600000000UL +#define EIC770X_SPLL0_OUT2_RATE 800000000UL +#define EIC770X_SPLL0_OUT3_RATE 400000000UL +#define EIC770X_UART_CLK_BIT (x) (1UL << ((x) + 17)) +#define EIC770X_SYSCLK_SEL (x) ((x) & 1) +#define EIC770X_SYSCLK_DIV (x) \ + ({ \ + uint32_t divisor = ((x) >> 4) & 7; \ + divisor > 2 ? divisor : 2; \ + }) +#endif
platform/generic/include/eswin/hfp.h new file +64 -0
64 lines not on this page · raw message
Signature · 7 lines
2.34.1 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Please disregard v5. I just sent out v6 with rv32 build fix. Thanks.
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi