From 299c4d340511076ed4abf8c2cef278c7d9836279 Mon Sep 17 00:00:00 2001 From: BigfootACA Date: Sun, 9 Jun 2024 01:58:47 +0800 Subject: [PATCH 1/4] [board] avaota-a1: set GICR_WAKER bit 2 for BL31 GICR_WAKER is GIC Redistributor Power Management Control Register, the second bit is Processor Sleep (WAKER_CA_BIT in BL31) BL31 require GICR_WAKER bit 2 to be 1, otherwise it crashes. ASSERT: drivers/arm/gic/v3/gicv3_helpers.c:28:(gicr_read_waker(gicr_base) & WAKER_CA_BIT) != 0U when boot from SD Card, GICR_WAKER is 0x6 when boot from USB Fel, GICR_WAKER is 0x0 simply setting this bit to 1 will make bl31 to work properly --- board/avaota-a1/board.c | 8 ++++++++ board/avaota-a1/extlinux_boot/main.c | 3 +++ board/avaota-a1/syter_boot/main.c | 3 +++ board/avaota-a1/syter_boot_bl33/main.c | 3 +++ board/avaota-a1/syter_boot_uboot/main.c | 3 +++ include/drivers/sun55iw3/reg/reg-ncat.h | 3 +++ 6 files changed, 23 insertions(+) diff --git a/board/avaota-a1/board.c b/board/avaota-a1/board.c index e14d8f7a..9ea49ba9 100644 --- a/board/avaota-a1/board.c +++ b/board/avaota-a1/board.c @@ -164,6 +164,14 @@ void neon_enable(void) { asm volatile("MCR p10, 7, r3, c8, c0, 0"); } +void gicr_set_waker(void) { + uint32_t gicr_waker = read32(GICR_WAKER); + if ((gicr_waker & 2) == 0) { + gicr_waker |= 2; + write32(GICR_WAKER, gicr_waker); + } +} + void clean_syterkit_data(void) { /* Disable MMU, data cache, instruction cache, interrupts */ arm32_mmu_disable(); diff --git a/board/avaota-a1/extlinux_boot/main.c b/board/avaota-a1/extlinux_boot/main.c index afaa51b1..ee52939e 100644 --- a/board/avaota-a1/extlinux_boot/main.c +++ b/board/avaota-a1/extlinux_boot/main.c @@ -73,6 +73,7 @@ extern void enable_sram_a3(); extern void rtc_set_vccio_det_spare(); extern void set_rpio_power_mode(void); extern void sunxi_nsi_init(); +extern void gicr_set_waker(void); typedef struct atf_head { uint32_t jump_instruction; /* jumping to real code */ @@ -821,6 +822,8 @@ int main(void) { clean_syterkit_data(); + gicr_set_waker(); + jmp_to_arm64(CONFIG_BL31_LOAD_ADDR); printk_info("Back to SyterKit\n"); diff --git a/board/avaota-a1/syter_boot/main.c b/board/avaota-a1/syter_boot/main.c index 2d3a4977..e097f8f7 100644 --- a/board/avaota-a1/syter_boot/main.c +++ b/board/avaota-a1/syter_boot/main.c @@ -66,6 +66,7 @@ extern void enable_sram_a3(); extern void rtc_set_vccio_det_spare(); extern void set_rpio_power_mode(void); extern void sunxi_nsi_init(); +extern void gicr_set_waker(void); typedef struct atf_head { uint32_t jump_instruction; /* jumping to real code */ @@ -272,6 +273,8 @@ int cmd_boot(int argc, const char **argv) { clean_syterkit_data(); + gicr_set_waker(); + jmp_to_arm64(CONFIG_BL31_LOAD_ADDR); printk_info("Back to SyterKit\n"); diff --git a/board/avaota-a1/syter_boot_bl33/main.c b/board/avaota-a1/syter_boot_bl33/main.c index a067eb99..36a4d5ce 100644 --- a/board/avaota-a1/syter_boot_bl33/main.c +++ b/board/avaota-a1/syter_boot_bl33/main.c @@ -66,6 +66,7 @@ extern void enable_sram_a3(); extern void rtc_set_vccio_det_spare(); extern void set_rpio_power_mode(void); extern void sunxi_nsi_init(); +extern void gicr_set_waker(void); typedef struct atf_head { uint32_t jump_instruction; /* jumping to real code */ @@ -272,6 +273,8 @@ int cmd_boot(int argc, const char **argv) { clean_syterkit_data(); + gicr_set_waker(); + jmp_to_arm64(CONFIG_BL31_LOAD_ADDR); printk_info("Back to SyterKit\n"); diff --git a/board/avaota-a1/syter_boot_uboot/main.c b/board/avaota-a1/syter_boot_uboot/main.c index 0494151a..91dca5c3 100644 --- a/board/avaota-a1/syter_boot_uboot/main.c +++ b/board/avaota-a1/syter_boot_uboot/main.c @@ -63,6 +63,7 @@ extern void enable_sram_a3(); extern void rtc_set_vccio_det_spare(); extern void set_rpio_power_mode(void); extern void sunxi_nsi_init(); +extern void gicr_set_waker(void); typedef struct atf_head { uint32_t jump_instruction; /* jumping to real code */ @@ -261,6 +262,8 @@ int cmd_boot(int argc, const char **argv) { clean_syterkit_data(); + gicr_set_waker(); + jmp_to_arm64(CONFIG_BL31_LOAD_ADDR); printk_info("Back to SyterKit\n"); diff --git a/include/drivers/sun55iw3/reg/reg-ncat.h b/include/drivers/sun55iw3/reg/reg-ncat.h index 778ee434..b8a1531b 100644 --- a/include/drivers/sun55iw3/reg/reg-ncat.h +++ b/include/drivers/sun55iw3/reg/reg-ncat.h @@ -194,6 +194,9 @@ #define GPIO_3_3V_MODE 0 #define GPIO_1_8V_MODE 1 +#define GIC_REDISTRIBUTOR (SUNXI_CPU_GIC600_BASE + 0x60000) +#define GICR_WAKER (GIC_REDISTRIBUTOR + 0x14) + #define PIOC_REG_o_POW_MOD_SEL 0x380 #define PIOC_REG_o_POW_MS_CTL 0x384 #define PIOC_REG_o_POW_MS_VAL 0x388 From 181ffcdd4cc9b98eb003f14eb473160511bb106b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9A=E6=9C=A8=20=E9=89=89?= Date: Sun, 9 Jun 2024 14:56:10 +0800 Subject: [PATCH 2/4] add GIC600 define --- include/drivers/sun55iw3/reg/reg-ncat.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/include/drivers/sun55iw3/reg/reg-ncat.h b/include/drivers/sun55iw3/reg/reg-ncat.h index b8a1531b..0d37ee39 100644 --- a/include/drivers/sun55iw3/reg/reg-ncat.h +++ b/include/drivers/sun55iw3/reg/reg-ncat.h @@ -194,8 +194,15 @@ #define GPIO_3_3V_MODE 0 #define GPIO_1_8V_MODE 1 -#define GIC_REDISTRIBUTOR (SUNXI_CPU_GIC600_BASE + 0x60000) -#define GICR_WAKER (GIC_REDISTRIBUTOR + 0x14) +/* GIC600 */ +#define GIC_IROUTR(_n) (SUNXI_CPU_GIC600_BASE + 0x6000 + 8 * (_n)) +#define GICR_LPI_BASE(n) (SUNXI_CPU_GIC600_BASE + 0x60000 + n*0x20000) +#define GICR_WAKER(m) (GICR_LPI_BASE(m) + 0x0014) +#define GICR_PWRR(m) (GICR_LPI_BASE(m) + 0x0024) +#define LEVEL_TRIGERRED (0) +#define EDGE_TRIGERRED (1) +#define GIC_IRQ_TYPE_CFG(_n) (SUNXI_CPU_GIC600_BASE + 0xc00 + 4 * (_n)) +#define GIC_IRQ_MOD_CFG(_n) (SUNXI_CPU_GIC600_BASE + 0xd00 + 4 * (_n)) #define PIOC_REG_o_POW_MOD_SEL 0x380 #define PIOC_REG_o_POW_MS_CTL 0x384 @@ -234,4 +241,4 @@ #define SUNXI_S_SPI_CLK_REG 0x0150 #define SUNXI_S_SPI_BGR_REG 0x015C -#endif// __SUN55IW3_REG_NCAT_H__ \ No newline at end of file +#endif// __SUN55IW3_REG_NCAT_H__ From e283d9da81eed1dbaf23429ab4ac5ab81586d214 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9A=E6=9C=A8=20=E9=89=89?= Date: Sun, 9 Jun 2024 14:56:55 +0800 Subject: [PATCH 3/4] Update board.c --- board/avaota-a1/board.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/board/avaota-a1/board.c b/board/avaota-a1/board.c index 9ea49ba9..05d2597f 100644 --- a/board/avaota-a1/board.c +++ b/board/avaota-a1/board.c @@ -165,10 +165,10 @@ void neon_enable(void) { } void gicr_set_waker(void) { - uint32_t gicr_waker = read32(GICR_WAKER); + uint32_t gicr_waker = read32(GICR_WAKER(0); if ((gicr_waker & 2) == 0) { gicr_waker |= 2; - write32(GICR_WAKER, gicr_waker); + write32(GICR_WAKER(0), gicr_waker); } } From 48cabdd3ef4ae8749d01bb0184ccdebc734fd394 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9F=9A=E6=9C=A8=20=E9=89=89?= Date: Sun, 9 Jun 2024 15:06:04 +0800 Subject: [PATCH 4/4] Update board.c --- board/avaota-a1/board.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/board/avaota-a1/board.c b/board/avaota-a1/board.c index 05d2597f..e5b942e4 100644 --- a/board/avaota-a1/board.c +++ b/board/avaota-a1/board.c @@ -165,7 +165,7 @@ void neon_enable(void) { } void gicr_set_waker(void) { - uint32_t gicr_waker = read32(GICR_WAKER(0); + uint32_t gicr_waker = read32(GICR_WAKER(0)); if ((gicr_waker & 2) == 0) { gicr_waker |= 2; write32(GICR_WAKER(0), gicr_waker);