[PATCH 0/6] Refactor Aspeed SoCs support

This patch series refactors the existing Aspeed platform code and file/folder structure for better flexibility to extend the support of other Aspeed SoCs. The maintainers for Aspeed SoCs are also added.
Chia-Wei, Wang (6): MAINTAINERS: Add maintainers for Aspeed SoCs aspeed: ast2500: Add lowlevel_init assembly cosmetic: aspeed: ast2500: Rename board file include/configs: aspeed: Remove hardcoded variables configs: evb-ast2500: Move BOOTCOMMAND from header to defconfig configs: evb-ast2500: Convert to OF_SEPARATE
MAINTAINERS | 12 ++++++ arch/arm/include/asm/arch-aspeed/platform.h | 20 +++++++++ arch/arm/mach-aspeed/Makefile | 2 +- arch/arm/mach-aspeed/ast2500/Makefile | 2 + .../board_common.c} | 25 ----------- arch/arm/mach-aspeed/ast2500/lowlevel_init.S | 41 +++++++++++++++++++ configs/evb-ast2500_defconfig | 5 ++- include/configs/aspeed-common.h | 18 ++++---- 8 files changed, 88 insertions(+), 37 deletions(-) create mode 100644 arch/arm/include/asm/arch-aspeed/platform.h rename arch/arm/mach-aspeed/{ast2500-board.c => ast2500/board_common.c} (58%) create mode 100644 arch/arm/mach-aspeed/ast2500/lowlevel_init.S

Update maintainers for Aspeed SoC platforms.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com --- MAINTAINERS | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/MAINTAINERS b/MAINTAINERS index 889a73f15f..163f571f65 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -148,6 +148,18 @@ F: include/configs/meson64_android.h F: doc/board/amlogic/ N: meson
+ARM ASPEED +M: Ryan Chen ryan_chen@aspeedtech.com +M: Chia-Wei Wang chiawei_wang@aspeedtech.com +R: Aspeed BMC SW team BMC-SW@aspeedtech.com +S: Maintained +F: arch/arm/mach-aspeed/ +F: arch/arm/include/asm/arch-aspeed/ +F: board/aspeed/ +F: drivers/clk/aspeed/ +F: drivers/pinctrl/aspeed/ +N: aspeed + ARM BROADCOM BCM283X M: Matthias Brugger mbrugger@suse.com S: Maintained

On Mon, Aug 03, 2020 at 05:36:05PM +0800, Chia-Wei, Wang wrote:
Update maintainers for Aspeed SoC platforms.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com
Applied to u-boot/master, thanks!

The original lowlevel_init function of AST2500 is written in C. However, the C runtime environment is not ready until _main execution.
This patch adds the assembly version of the lowlevel_init function. Additional initialization to DRAM configuration and LPC reset source are also added.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com --- arch/arm/mach-aspeed/ast2500-board.c | 25 ------------ arch/arm/mach-aspeed/ast2500/Makefile | 1 + arch/arm/mach-aspeed/ast2500/lowlevel_init.S | 41 ++++++++++++++++++++ 3 files changed, 42 insertions(+), 25 deletions(-) create mode 100644 arch/arm/mach-aspeed/ast2500/lowlevel_init.S
diff --git a/arch/arm/mach-aspeed/ast2500-board.c b/arch/arm/mach-aspeed/ast2500-board.c index f74dcbbb62..3482ee91ef 100644 --- a/arch/arm/mach-aspeed/ast2500-board.c +++ b/arch/arm/mach-aspeed/ast2500-board.c @@ -28,31 +28,6 @@
DECLARE_GLOBAL_DATA_PTR;
-void lowlevel_init(void) -{ - /* - * These two watchdogs need to be stopped as soon as possible, - * otherwise the board might hang. By default they are set to - * a very short timeout and even simple debug write to serial - * console early in the init process might cause them to fire. - */ - struct ast_wdt *flash_addr_wdt = - (struct ast_wdt *)(WDT_BASE + - sizeof(struct ast_wdt) * - AST_FLASH_ADDR_DETECT_WDT); - - clrbits_le32(&flash_addr_wdt->ctrl, WDT_CTRL_EN); - -#ifndef CONFIG_FIRMWARE_2ND_BOOT - struct ast_wdt *sec_boot_wdt = - (struct ast_wdt *)(WDT_BASE + - sizeof(struct ast_wdt) * - AST_2ND_BOOT_WDT); - - clrbits_le32(&sec_boot_wdt->ctrl, WDT_CTRL_EN); -#endif -} - int board_init(void) { gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100; diff --git a/arch/arm/mach-aspeed/ast2500/Makefile b/arch/arm/mach-aspeed/ast2500/Makefile index a35b239ef3..2e9e15d831 100644 --- a/arch/arm/mach-aspeed/ast2500/Makefile +++ b/arch/arm/mach-aspeed/ast2500/Makefile @@ -1 +1,2 @@ +obj-y += lowlevel_init.o obj-y += clk_ast2500.o sdram_ast2500.o diff --git a/arch/arm/mach-aspeed/ast2500/lowlevel_init.S b/arch/arm/mach-aspeed/ast2500/lowlevel_init.S new file mode 100644 index 0000000000..9ec3dd46b7 --- /dev/null +++ b/arch/arm/mach-aspeed/ast2500/lowlevel_init.S @@ -0,0 +1,41 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) ASPEED Technology Inc. + */ +#include <asm/arch/scu_ast2500.h> + +/* registers for low level init */ +#define SCU_PROT_KEY 0x1e6e2000 +#define SCU_VGA_HANDSHAKE 0x1e6e2040 +#define SCU_HW_STRAP 0x1e6e2070 +#define SCU_HW_STRAP_CLR 0x1e6e207c +#define WDT3_CTRL 0x1e78504c + +.global lowlevel_init +lowlevel_init: + + /* unlock SCU */ + ldr r0, =SCU_PROT_KEY + ldr r1, =SCU_UNLOCK_VALUE + str r1, [r0] + + /* set BMC FW as DRAM initializer */ + ldr r0, =SCU_VGA_HANDSHAKE + ldr r1, [r0] + orr r1, #0x80 + str r1, [r0] + + /* set PERST# as LPC reset source if eSPI mode is enabled*/ + ldr r0, =SCU_HW_STRAP + ldr r1, [r0] + tst r1, #(0x1 << 25) + ldrne r0, =SCU_HW_STRAP_CLR + movne r1, #(0x1 << 14) + strne r1, [r0] + + /* disable WDT3 for SPI 3/4 bytes auto-detection */ + ldr r0, =WDT3_CTRL + mov r1, #0x0 + str r1, [r0] + + mov pc, lr

On Mon, Aug 03, 2020 at 05:36:06PM +0800, Chia-Wei, Wang wrote:
The original lowlevel_init function of AST2500 is written in C. However, the C runtime environment is not ready until _main execution.
This patch adds the assembly version of the lowlevel_init function. Additional initialization to DRAM configuration and LPC reset source are also added.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com
Applied to u-boot/master, thanks!

Rename the ast2500-board.c to board_common.c and place the renamed file under the ast2500 folder.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com --- arch/arm/mach-aspeed/Makefile | 2 +- arch/arm/mach-aspeed/ast2500/Makefile | 1 + .../arm/mach-aspeed/{ast2500-board.c => ast2500/board_common.c} | 0 3 files changed, 2 insertions(+), 1 deletion(-) rename arch/arm/mach-aspeed/{ast2500-board.c => ast2500/board_common.c} (100%)
diff --git a/arch/arm/mach-aspeed/Makefile b/arch/arm/mach-aspeed/Makefile index 1557dcae66..33f65b50b2 100644 --- a/arch/arm/mach-aspeed/Makefile +++ b/arch/arm/mach-aspeed/Makefile @@ -3,4 +3,4 @@ # Copyright (c) 2016 Google, Inc
obj-$(CONFIG_ARCH_ASPEED) += ast_wdt.o -obj-$(CONFIG_ASPEED_AST2500) += ast2500/ ast2500-board.o +obj-$(CONFIG_ASPEED_AST2500) += ast2500/ diff --git a/arch/arm/mach-aspeed/ast2500/Makefile b/arch/arm/mach-aspeed/ast2500/Makefile index 2e9e15d831..4c27c8fc46 100644 --- a/arch/arm/mach-aspeed/ast2500/Makefile +++ b/arch/arm/mach-aspeed/ast2500/Makefile @@ -1,2 +1,3 @@ obj-y += lowlevel_init.o +obj-y += board_common.o obj-y += clk_ast2500.o sdram_ast2500.o diff --git a/arch/arm/mach-aspeed/ast2500-board.c b/arch/arm/mach-aspeed/ast2500/board_common.c similarity index 100% rename from arch/arm/mach-aspeed/ast2500-board.c rename to arch/arm/mach-aspeed/ast2500/board_common.c

On Mon, Aug 03, 2020 at 05:36:07PM +0800, Chia-Wei, Wang wrote:
Rename the ast2500-board.c to board_common.c and place the renamed file under the ast2500 folder.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com
Applied to u-boot/master, thanks!

The hardcoded platform variables such as DRAM base address are not common to Aspeed SoCs AST24xx/AST25xx/AST26xx. This patch replaces those hardcoded with macros defined in a newly added header, where the basic SoC HW information are assigned accordingly.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com --- arch/arm/include/asm/arch-aspeed/platform.h | 20 ++++++++++++++++++++ include/configs/aspeed-common.h | 16 +++++++++------- 2 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 arch/arm/include/asm/arch-aspeed/platform.h
diff --git a/arch/arm/include/asm/arch-aspeed/platform.h b/arch/arm/include/asm/arch-aspeed/platform.h new file mode 100644 index 0000000000..6cee036f54 --- /dev/null +++ b/arch/arm/include/asm/arch-aspeed/platform.h @@ -0,0 +1,20 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * Copyright (C) ASPEED Technology Inc. + * Ryan Chen ryan_chen@aspeedtech.com + * + */ + +#ifndef _ASM_ARCH_PLATFORM_H +#define _ASM_ARCH_PLATFORM_H + +#if defined(CONFIG_ASPEED_AST2500) +#define ASPEED_MAC_COUNT 2 +#define ASPEED_DRAM_BASE 0x80000000 +#define ASPEED_SRAM_BASE 0x1e720000 +#define ASPEED_SRAM_SIZE 0x9000 +#else +#err "Unrecognized Aspeed platform." +#endif + +#endif diff --git a/include/configs/aspeed-common.h b/include/configs/aspeed-common.h index 1295a6cd19..14dd5c795d 100644 --- a/include/configs/aspeed-common.h +++ b/include/configs/aspeed-common.h @@ -7,22 +7,24 @@ * (C) Copyright 2016 Google, Inc */
-#ifndef __AST_COMMON_CONFIG_H -#define __AST_COMMON_CONFIG_H +#ifndef _ASPEED_COMMON_CONFIG_H +#define _ASPEED_COMMON_CONFIG_H + +#include <asm/arch/platform.h>
/* Misc CPU related */ #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS #define CONFIG_INITRD_TAG
-#define CONFIG_SYS_SDRAM_BASE 0x80000000 +#define CONFIG_SYS_SDRAM_BASE ASPEED_DRAM_BASE
#ifdef CONFIG_PRE_CON_BUF_SZ -#define CONFIG_SYS_INIT_RAM_ADDR (0x1e720000 + CONFIG_PRE_CON_BUF_SZ) -#define CONFIG_SYS_INIT_RAM_SIZE (36*1024 - CONFIG_PRE_CON_BUF_SZ) +#define CONFIG_SYS_INIT_RAM_ADDR (ASPEED_SRAM_BASE + CONFIG_PRE_CON_BUF_SZ) +#define CONFIG_SYS_INIT_RAM_SIZE (ASPEED_SRAM_SIZE - CONFIG_PRE_CON_BUF_SZ) #else -#define CONFIG_SYS_INIT_RAM_ADDR (0x1e720000) -#define CONFIG_SYS_INIT_RAM_SIZE (36*1024) +#define CONFIG_SYS_INIT_RAM_ADDR (ASPEED_SRAM_BASE) +#define CONFIG_SYS_INIT_RAM_SIZE (ASPEED_SRAM_SIZE) #endif
#define SYS_INIT_RAM_END (CONFIG_SYS_INIT_RAM_ADDR \

On Mon, Aug 03, 2020 at 05:36:08PM +0800, Chia-Wei, Wang wrote:
The hardcoded platform variables such as DRAM base address are not common to Aspeed SoCs AST24xx/AST25xx/AST26xx. This patch replaces those hardcoded with macros defined in a newly added header, where the basic SoC HW information are assigned accordingly.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com
Applied to u-boot/master, thanks!

Move the BOOTCOMMAND definition from the board inclusion header to the default configuration file.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com --- configs/evb-ast2500_defconfig | 4 +++- include/configs/aspeed-common.h | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/configs/evb-ast2500_defconfig b/configs/evb-ast2500_defconfig index 5de42679ca..ce38b38183 100644 --- a/configs/evb-ast2500_defconfig +++ b/configs/evb-ast2500_defconfig @@ -5,12 +5,14 @@ CONFIG_SYS_TEXT_BASE=0x0 CONFIG_ASPEED_AST2500=y CONFIG_TARGET_EVB_AST2500=y CONFIG_SYS_MALLOC_F_LEN=0x2000 -CONFIG_ENV_SIZE=0x20000 CONFIG_NR_DRAM_BANKS=1 +CONFIG_ENV_SIZE=0x20000 CONFIG_PRE_CON_BUF_ADDR=0x1e720000 CONFIG_DEFAULT_DEVICE_TREE="ast2500-evb" CONFIG_USE_BOOTARGS=y CONFIG_BOOTARGS="console=ttyS4,115200n8 root=/dev/ram rw" +CONFIG_USE_BOOTCOMMAND=y +CONFIG_BOOTCOMMAND="bootm 20080000 20300000" CONFIG_PRE_CONSOLE_BUFFER=y # CONFIG_DISPLAY_CPUINFO is not set CONFIG_HUSH_PARSER=y diff --git a/include/configs/aspeed-common.h b/include/configs/aspeed-common.h index 14dd5c795d..df0f5d2e76 100644 --- a/include/configs/aspeed-common.h +++ b/include/configs/aspeed-common.h @@ -47,8 +47,6 @@ * Miscellaneous configurable options */
-#define CONFIG_BOOTCOMMAND "bootm 20080000 20300000" - #define CONFIG_EXTRA_ENV_SETTINGS \ "verify=yes\0" \ "spi_dma=yes\0" \

On Mon, Aug 03, 2020 at 05:36:09PM +0800, Chia-Wei, Wang wrote:
Move the BOOTCOMMAND definition from the board inclusion header to the default configuration file.
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com
Applied to u-boot/master, thanks!

Switch DTB provider form OF_EMBED to OF_SEPARATE to avoid the compile warning message:
==================== WARNING ====================== CONFIG_OF_EMBED is enabled. This option should only be used for debugging purposes. Please use CONFIG_OF_SEPARATE for boards in mainline. See doc/README.fdt-control for more info. ====================================================
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com --- configs/evb-ast2500_defconfig | 1 - 1 file changed, 1 deletion(-)
diff --git a/configs/evb-ast2500_defconfig b/configs/evb-ast2500_defconfig index ce38b38183..105975c9e6 100644 --- a/configs/evb-ast2500_defconfig +++ b/configs/evb-ast2500_defconfig @@ -22,7 +22,6 @@ CONFIG_CMD_MMC=y CONFIG_CMD_DHCP=y CONFIG_CMD_MII=y CONFIG_CMD_PING=y -CONFIG_OF_EMBED=y CONFIG_ENV_OVERWRITE=y CONFIG_SYS_RELOC_GD_ENV_ADDR=y CONFIG_NET_RANDOM_ETHADDR=y

On Mon, Aug 03, 2020 at 05:36:10PM +0800, Chia-Wei, Wang wrote:
Switch DTB provider form OF_EMBED to OF_SEPARATE to avoid the compile warning message:
==================== WARNING ====================== CONFIG_OF_EMBED is enabled. This option should only be used for debugging purposes. Please use CONFIG_OF_SEPARATE for boards in mainline. See doc/README.fdt-control for more info. ====================================================
Signed-off-by: Chia-Wei, Wang chiawei_wang@aspeedtech.com
Applied to u-boot/master, thanks!
participants (2)
-
Chia-Wei, Wang
-
Tom Rini