-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Xuantie C908X supports fast memory configuration vector and scalar memory access instructions to access external SRAM. Configure the starting address and size through CSR_MFASTMBA. For specific settings, please refer to the datasheet. Dynamic configuration is achieved by parsing dts through opensbi. The dts reference configuration is as follows: ``` / { compatible = "xuantie,c908x"; model = "xuantie,c908x"; fastmem { mfastmba = <0x12 0x34567890>; }; }; ``` Signed-off-by: hanyu.cp <[email protected]>
- Loading branch information
Showing
8 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
|
||
#ifndef __RISCV_THEAD_C9XX_EXTFUNC_H____ | ||
#define __RISCV_THEAD_C9XX_EXTFUNC_H____ | ||
|
||
/* Fast Memory Setting */ | ||
#define THEAD_QUIRK_EXTFUNC_FASTMEM BIT(0) | ||
|
||
void thead_c9xx_fastmem_init(void); | ||
|
||
#endif // __RISCV_THEAD_C9XX_EXTFUNC_H____ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* | ||
* SPDX-License-Identifier: BSD-2-Clause | ||
*/ | ||
|
||
#include <libfdt.h> | ||
#include <libfdt_env.h> | ||
#include <sbi_utils/fdt/fdt_helper.h> | ||
#include <sbi/riscv_asm.h> | ||
#include <thead/c9xx_encoding.h> | ||
|
||
void thead_c9xx_fastmem_init(void) | ||
{ | ||
int offset, len; | ||
unsigned long mfastmbal, mfastmbah; | ||
const fdt32_t *val; | ||
|
||
void *fdt = fdt_get_address(); | ||
|
||
/* Find node offset */ | ||
offset = fdt_path_offset(fdt, "/fastmem"); | ||
if (offset < 0) | ||
return; | ||
|
||
val = fdt_getprop(fdt, offset, "mfastmba", &len); | ||
if (val && len == 8) { | ||
mfastmbah = fdt32_to_cpu(val[0]); | ||
mfastmbal = fdt32_to_cpu(val[1]); | ||
#if __riscv_xlen == 32 | ||
csr_write(THEAD_C9XX_CSR_MFASTMBA, mfastmbal); | ||
csr_write(THEAD_C9XX_CSR_MFASTMBAH, mfastmbah); | ||
#else | ||
csr_write(THEAD_C9XX_CSR_MFASTMBA, mfastmbah << 32 | mfastmbal); | ||
#endif | ||
} | ||
} |