Skip to content

Commit

Permalink
sync sdk v2.0.2 code
Browse files Browse the repository at this point in the history
Signed-off-by: Han Gao <[email protected]>
  • Loading branch information
RevySR committed Sep 20, 2024
1 parent 999acab commit e6170c2
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 10 deletions.
2 changes: 2 additions & 0 deletions firmware/fw_base.S
Original file line number Diff line number Diff line change
Expand Up @@ -738,6 +738,8 @@ memcmp:
.globl _trap_handler
.globl _trap_exit
_trap_handler:
sfence.vma zero, t0

TRAP_SAVE_AND_SETUP_SP_T0

TRAP_SAVE_MEPC_MSTATUS 0
Expand Down
9 changes: 9 additions & 0 deletions lib/sbi/sbi_trap.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,15 @@ int sbi_trap_redirect(struct sbi_trap_regs *regs,
static int sbi_trap_nonaia_irq(struct sbi_trap_regs *regs, ulong mcause)
{
mcause &= ~(1UL << (__riscv_xlen - 1));

/*
* DCACHE.CALL:
* | 31 - 25 | 24 - 20 | 19 - 15 | 14 - 12 | 11 - 7 | 6 - 0 |
* 0000000 00001 00000 000 00000 0001011
*/
if ((regs->mepc & 0x7f) == 4)
asm volatile(".long 0x0010000b\n");

switch (mcause) {
case IRQ_M_TIMER:
sbi_timer_process();
Expand Down
2 changes: 2 additions & 0 deletions lib/utils/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,6 @@ source "$(OPENSBI_SRC_DIR)/lib/utils/sys/Kconfig"

source "$(OPENSBI_SRC_DIR)/lib/utils/timer/Kconfig"

source "$(OPENSBI_SRC_DIR)/lib/utils/mbox/Kconfig"

endmenu
2 changes: 1 addition & 1 deletion lib/utils/mbox/fdt_mbox_thead.c
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ static int thead_mbox_init(void *fdt, int nodeoff,
{
int rc = 0, bitmap = 0, len = 0;
struct thead_mbox_adapter *adapter;
uint8_t data = 0x0;
uint32_t data = 0x0;

adapter = sbi_zalloc(sizeof(*adapter));
if (!adapter)
Expand Down
28 changes: 19 additions & 9 deletions platform/generic/thead/thead-generic.c
Original file line number Diff line number Diff line change
Expand Up @@ -264,6 +264,9 @@ static void sbi_thead_reserved_pmp_set(void)
unsigned int num, reg_val;

for (num = 0; num < 4; num++) {
if (__sbi_hsm_hart_get_state(num) == SBI_HSM_STATE_STOPPED)
continue;

/* pmp entry 28 for reserved memory */
writel(RESERVED_START_ADDR >> 12, (void *)(PMP_ENTRY_START_ADDR(28) + num*PMP_SIZE_PER_CORE));
writel(RESERVED_END_ADDR >> 12, (void *)(PMP_ENTRY_END_ADDR(28) + num*PMP_SIZE_PER_CORE));
Expand All @@ -286,12 +289,18 @@ static void sbi_thead_tcm0_pmp_set(unsigned long auth)

if (reg_val != TCM0_START_ADDR >> 12)
for(num = 0; num < 4; num++) {
if (__sbi_hsm_hart_get_state(num) == SBI_HSM_STATE_STOPPED)
continue;

/* pmp entry 26 for dsp tcm0 */
writel(TCM0_START_ADDR >> 12, (void *)(PMP_ENTRY_START_ADDR(26) + num*PMP_SIZE_PER_CORE));
writel(TCM0_END_ADDR >> 12, (void *)(PMP_ENTRY_END_ADDR(26) + num*PMP_SIZE_PER_CORE));
}

for(num = 0; num < 4; num++) {
if (__sbi_hsm_hart_get_state(num) == SBI_HSM_STATE_STOPPED)
continue;

/* pmp entry 26 config */
reg_val = readl((void *)(PMP_ENTRY_CFG_ADDR(26) + num*PMP_SIZE_PER_CORE));
reg_val = (reg_val & 0xff00ffff) | (auth << 16);
Expand All @@ -309,12 +318,18 @@ static void sbi_thead_tcm1_pmp_set(unsigned long auth)
reg_val = readl((void *)PMP_ENTRY_START_ADDR(27));
if (reg_val != TCM1_START_ADDR >> 12)
for (num = 0; num < 4; num++) {
if (__sbi_hsm_hart_get_state(num) == SBI_HSM_STATE_STOPPED)
continue;

/* pmp entry 27 for dsp tcm1 */
writel(TCM1_START_ADDR >> 12, (void *)(PMP_ENTRY_START_ADDR(27) + num*PMP_SIZE_PER_CORE));
writel(TCM1_END_ADDR >> 12, (void *)(PMP_ENTRY_END_ADDR(27) + num*PMP_SIZE_PER_CORE));
}

for (num = 0; num < 4; num++) {
if (__sbi_hsm_hart_get_state(num) == SBI_HSM_STATE_STOPPED)
continue;

/* pmp entry 27 config */
reg_val = readl((void *)(PMP_ENTRY_CFG_ADDR(27) + num*PMP_SIZE_PER_CORE));
reg_val = (reg_val & 0x00ffffff) | (auth << 24);
Expand Down Expand Up @@ -406,18 +421,13 @@ static int thead_generic_final_init(bool cold_boot,
return 0;
}

/* static struct thead_generic_quirks thead_th1520_quirks = {
.errata = THEAD_QUIRK_ERRATA_TLB_FLUSH,
}; */

static struct thead_generic_quirks thead_light_quirks = {
.errata = THEAD_QUIRK_ERRATA_TLB_FLUSH | THEAD_QUIRK_ERRATA_LOGHT_PPU,
static struct thead_generic_quirks thead_th1520_quirks = {
.errata = THEAD_QUIRK_ERRATA_LOGHT_PPU,
};

static const struct fdt_match thead_generic_match[] = {
/* { .compatible = "thead,th1520", .data = &thead_th1520_quirks }, */
{ .compatible = "thead,th1520", .data = &thead_light_quirks },
{ .compatible = "thead,light", .data = &thead_light_quirks },
{ .compatible = "thead,th1520", .data = &thead_th1520_quirks },
{ .compatible = "thead,light", .data = &thead_th1520_quirks },
{ },
};

Expand Down

0 comments on commit e6170c2

Please sign in to comment.