From 2ea7b194d928950db1aed87097975a8ffb9df2ac Mon Sep 17 00:00:00 2001 From: Dino Li Date: Wed, 28 Oct 2015 21:39:54 +0800 Subject: [PATCH] nds32: fix interrupt 1. To enable INT_PRI (hardware interrupt priority level 0~3) register, bit0@INT_CTRL = 0. 2. GIE need to be enabled before UART is initialized. [symptom] To define CONFIG_RWSIG / CONFIG_RSA / CONFIG_SHA256, then power on: after RW image is verified, firmware stuck in uart_flush_output(). Signed-off-by: Dino Li BRANCH=none BUG=none TEST=1. bit0@INT_CTRL = 0. 2. The RW image is verified and jump to image RW. Change-Id: I393a3d5f87ea257885b872c91bfce43aecbaea8b Reviewed-on: https://chromium-review.googlesource.com/309400 Commit-Ready: Dino Li Tested-by: Dino Li Reviewed-by: Randall Spangler --- core/nds32/cpu.c | 3 +++ core/nds32/task.c | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/core/nds32/cpu.c b/core/nds32/cpu.c index bf49a58b2e..7a8a043656 100644 --- a/core/nds32/cpu.c +++ b/core/nds32/cpu.c @@ -18,4 +18,7 @@ void cpu_init(void) if (image_type > CONFIG_RW_MEM_OFF) /* Interrupt Vector Table Base Address, in 64k Byte unit */ IT83XX_GCTRL_IVTBAR = (CONFIG_RW_MEM_OFF >> 16) & 0xFF; + + /* Global interrupt enable */ + asm volatile ("setgie.e"); } diff --git a/core/nds32/task.c b/core/nds32/task.c index a7a3bc6688..79880e059d 100644 --- a/core/nds32/task.c +++ b/core/nds32/task.c @@ -494,6 +494,19 @@ static void set_int_priority(uint32_t val) asm volatile ("mtsr %0, $INT_PRI" : : "r"(val)); } +uint32_t get_int_ctrl(void) +{ + uint32_t ret; + + asm volatile ("mfsr %0, $INT_CTRL" : "=r"(ret)); + return ret; +} + +void set_int_ctrl(uint32_t val) +{ + asm volatile ("mtsr %0, $INT_CTRL" : : "r"(val)); +} + void task_enable_all_tasks(void) { /* Mark all tasks are ready to run. */ @@ -549,6 +562,12 @@ static void ivic_init_irqs(void) /* chip-specific interrupt controller initialization */ chip_init_irqs(); + /* + * bit0 @ INT_CTRL = 0, + * Interrupts still keep programmable priority level. + */ + set_int_ctrl((get_int_ctrl() & ~(1 << 0))); + /* * Re-enable global interrupts in case they're disabled. On a reboot, * they're already enabled; if we've jumped here from another image,