nds32: Support AE3XX platform.
PATCH 3/3 nds32: Support AE3XX platform.
From: rick <[email protected]>
Support Andestech AE3xx platform: serial, timer device tree flow.
Signed-off-by rick <[email protected]>
--- arch/nds32/Kconfig | 4 + arch/nds32/cpu/n1213/Makefile | 1 + arch/nds32/cpu/n1213/ae3xx/Makefile | 18 ++ arch/nds32/cpu/n1213/ae3xx/cpu.c | 45 +++++ arch/nds32/cpu/n1213/ae3xx/lowlevel_init.S | 148 ++++++++++++++++ arch/nds32/cpu/n1213/ae3xx/timer.c | 16 ++ arch/nds32/cpu/n1213/ae3xx/watchdog.S | 17 ++ arch/nds32/cpu/n1213/ag101/Makefile | 3 - arch/nds32/cpu/n1213/ag101/cpu.c | 8 +- arch/nds32/cpu/n1213/ag101/lowlevel_init.S | 59 +++---- arch/nds32/cpu/n1213/start.S | 40 ++++- arch/nds32/dts/Makefile | 1 + arch/nds32/dts/ae3xx.dts | 65 +++++++ arch/nds32/include/asm/arch-ae3xx/ae3xx.h | 54 ++++++ arch/nds32/include/asm/bootm.h | 65 +++++++ arch/nds32/include/asm/cache.h | 23 ++- arch/nds32/include/asm/mach-types.h | 1 + arch/nds32/lib/Makefile | 1 + arch/nds32/lib/boot.c | 20 +++ arch/nds32/lib/bootm.c | 23 ++- arch/nds32/lib/cache.c | 197 +++++++++++++++++---- board/AndesTech/adp-ae3xx/Kconfig | 18 ++ board/AndesTech/adp-ae3xx/MAINTAINERS | 6 + board/AndesTech/adp-ae3xx/Makefile | 8 + board/AndesTech/adp-ae3xx/adp-ae3xx.c | 86 +++++++++ board/AndesTech/adp-ag101p/adp-ag101p.c | 9 +- configs/adp-ae3xx_defconfig | 25 +++ configs/adp-ag101p_defconfig | 1 + drivers/timer/Kconfig | 12 +- drivers/timer/Makefile | 1 + drivers/timer/ae3xx_timer.c | 117 +++++++++++++ include/configs/adp-ae3xx.h | 260 ++++++++++++++++++++++++++++ include/configs/adp-ag101p.h | 27 ++- 33 files changed, 1265 insertions(+), 114 deletions(-) create mode 100644 arch/nds32/cpu/n1213/ae3xx/Makefile create mode 100644 arch/nds32/cpu/n1213/ae3xx/cpu.c create mode 100644 arch/nds32/cpu/n1213/ae3xx/lowlevel_init.S create mode 100644 arch/nds32/cpu/n1213/ae3xx/timer.c create mode 100644 arch/nds32/cpu/n1213/ae3xx/watchdog.S create mode 100644 arch/nds32/dts/ae3xx.dts create mode 100644 arch/nds32/include/asm/arch-ae3xx/ae3xx.h create mode 100644 arch/nds32/include/asm/bootm.h create mode 100644 arch/nds32/lib/boot.c create mode 100644 board/AndesTech/adp-ae3xx/Kconfig create mode 100644 board/AndesTech/adp-ae3xx/MAINTAINERS create mode 100644 board/AndesTech/adp-ae3xx/Makefile create mode 100644 board/AndesTech/adp-ae3xx/adp-ae3xx.c create mode 100644 configs/adp-ae3xx_defconfig create mode 100644 drivers/timer/ae3xx_timer.c create mode 100644 include/configs/adp-ae3xx.h
arch/nds32/Kconfig +4 -0
@@ -11,8 +11,12 @@ choice config TARGET_ADP_AG101P bool "Support adp-ag101p" +config TARGET_ADP_AE3XX + bool "Support adp-ae3xx" + endchoice source "board/AndesTech/adp-ag101p/Kconfig" +source "board/AndesTech/adp-ae3xx/Kconfig" endmenu
arch/nds32/cpu/n1213/Makefile +1 -0
@@ -12,3 +12,4 @@ extra-y = start.o obj-$(if $(filter ag101,$(SOC)),y) += ag101/ +obj-$(if $(filter ae3xx,$(SOC)),y) += ae3xx/
arch/nds32/cpu/n1213/ae3xx/Makefile new file +18 -0
@@ -0,0 +1,18 @@ +# +# (C) Copyright 2009 +# Marvell Semiconductor <www.marvell.com> +# Written-by: Prafulla Wadaskar <[email protected]> +# +# Copyright (C) 2011 Andes Technology Corporation +# Shawn Lin, Andes Technology Corporation <[email protected]> +# Macpaul Lin, Andes Technology Corporation <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := cpu.o timer.o +obj-y += lowlevel_init.o + +ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG +obj-y += watchdog.o +endif
arch/nds32/cpu/n1213/ae3xx/cpu.c new file +45 -0
45 lines not on this page · raw message
arch/nds32/cpu/n1213/ae3xx/lowlevel_init.S new file +148 -0
148 lines not on this page · raw message
arch/nds32/cpu/n1213/ae3xx/timer.c new file +16 -0
@@ -0,0 +1,16 @@ +/* +* (C) Copyright 2009 Faraday Technology +* Po-Yu Chuang <[email protected]> +* +* Copyright (C) 2011 Andes Technology Corporation +* Shawn Lin, Andes Technology Corporation <[email protected]> +* Macpaul Lin, Andes Technology Corporation <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ +#ifndef CONFIG_TIMER +#include <common.h> +#include <asm/io.h> +#include <faraday/fttmr010.h> +#error "AE3XX timer only support DM flow" +#endif /* CONFIG_TIMER */
arch/nds32/cpu/n1213/ae3xx/watchdog.S new file +17 -0
@@ -0,0 +1,17 @@ +/* + * Copyright (C) 2011 Andes Technology Corporation + * Macpaul Lin, Andes Technology Corporation <[email protected]> + * + * SPDX-License-Identifier: GPL-2.0+ + */ + +#include <asm/arch-ag101/ag101.h> +#include <linux/linkage.h> + +.text + +#ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG +ENTRY(turnoff_watchdog) +#error "AE3XX not support wdt yet" +ENDPROC(turnoff_watchdog) +#endif
arch/nds32/cpu/n1213/ag101/Makefile +0 -3
@@ -11,10 +11,7 @@ # obj-y := cpu.o timer.o - -ifndef CONFIG_SKIP_LOWLEVEL_INIT obj-y += lowlevel_init.o -endif ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG obj-y += watchdog.o
arch/nds32/cpu/n1213/ag101/cpu.c +1 -7
@@ -31,16 +31,10 @@ int cleanup_before_linux(void) {disable_interrupts (); -#ifdef CONFIG_MMU /* turn off I/D-cache */ +cache_flush ();icache_disable ();dcache_disable (); - -/* flush I/D-cache */ -invalidate_icac (); -invalidate_dcac (); -#endif -return 0 ; }
arch/nds32/cpu/n1213/ag101/lowlevel_init.S +22 -37
100 lines not on this page · raw message
arch/nds32/cpu/n1213/start.S +33 -7
@@ -114,11 +114,39 @@ reset_gp: set_ivb: li $r0, 0x0 - /* turn on BTB */ mtsr $r0, $misc_ctl /* set IVIC, vector size: 4 bytes, base: 0x0 */ mtsr $r0, $ivb +/* + * MMU_CTL NTC0 Cacheable/Write-Back + */ + li $r0, ~0x3 + mfsr $r1, $mr8 + and $r1, $r1, $r0 + mtsr $r1, $mr8 +#if (!defined(CONFIG_SYS_ICACHE_OFF) || !defined(CONFIG_SYS_DCACHE_OFF)) + li $r0, 0x4 + mfsr $r1, $mr0 + or $r1, $r1, $r0 + mtsr $r1, $mr0 +#endif + +#if !defined(CONFIG_SYS_ICACHE_OFF) + li $r0, 0x1 + mfsr $r1, $mr8 + or $r1, $r1, $r0 + mtsr $r1, $mr8 +#endif + +#if !defined(CONFIG_SYS_DCACHE_OFF) + li $r0, 0x2 + mfsr $r1, $mr8 + or $r1, $r1, $r0 + mtsr $r1, $mr8 +#endif + + jal mem_init #ifndef CONFIG_SKIP_LOWLEVEL_INIT jal lowlevel_init
@@ -133,7 +161,6 @@ update_gp: ori $gp, $gp, lo12(_GLOBAL_OFFSET_TABLE_-4) add5.pc $gp #endif - /* * do critical initializations first (shall be in short time) * do self_relocation ASAP.
@@ -169,7 +196,6 @@ call_board_init_f: bal debug_uart_init #endif li $r0, 0x00000000 - #ifdef __PIC__ #ifdef __NDS32_N1213_43U1H__ /* __NDS32_N1213_43U1H__ implies NDS32 V0 ISA */
@@ -205,12 +231,10 @@ stack_setup: la $r1, _end at GOTOFF move $r2, $r6 /* r2 <- scratch for copy_loop */ - copy_loop: - lwi.p $r7, [$r0], #4 - swi.p $r7, [$r2], #4 + lmw.bim $r11, [$r0], $r18 + smw.bim $r11, [$r2], $r18 blt $r0, $r1, copy_loop - /* * fix relocations related issues */
@@ -250,6 +274,8 @@ clbss_l: * initialization, now running from RAM. */ call_board_init_r: + bal invalidate_icache_all + bal flush_dcache_all la $r0, board_init_r@GOTOFF move $lp, $r0 /* offset of board_init_r() */ add $lp, $lp, $r9 /* real address of board_init_r() */
arch/nds32/dts/Makefile +1 -0
@@ -3,6 +3,7 @@ # dtb-$(CONFIG_TARGET_ADP_AG101P) += ag101p.dtb +dtb-$(CONFIG_TARGET_ADP_AE3XX) += ae3xx.dtb targets += $(dtb-y) DTC_FLAGS += -R 4 -p 0x1000
arch/nds32/dts/ae3xx.dts new file +65 -0
65 lines not on this page · raw message
arch/nds32/include/asm/arch-ae3xx/ae3xx.h new file +54 -0
54 lines not on this page · raw message
arch/nds32/include/asm/bootm.h new file +65 -0
65 lines not on this page · raw message
arch/nds32/include/asm/cache.h +19 -4
@@ -16,6 +16,7 @@ void icache_disable(void);int dcache_status (void );void dcache_enable (void );void dcache_disable (void ); +void cache_flush (void );#define DEFINE_GET_SYS_REG (reg) \ static inline unsigned long GET_##reg(void) \
@@ -30,10 +31,24 @@ void dcache_disable(void);enum cache_t {ICACHE ,DCACHE };DEFINE_GET_SYS_REG (ICM_CFG );DEFINE_GET_SYS_REG (DCM_CFG ); -#define ICM_CFG_OFF_ISZ 6/* I-cache line size */ -#define ICM_CFG_MSK_ISZ (0x7UL << ICM_CFG_OFF_ISZ) -#define DCM_CFG_OFF_DSZ 6/* D-cache line size */ -#define DCM_CFG_MSK_DSZ (0x7UL << DCM_CFG_OFF_DSZ) +/* I-cache sets (# of cache lines) per way */ +#define ICM_CFG_OFF_ISET 0 +/* I-cache ways */ +#define ICM_CFG_OFF_IWAY 3 +#define ICM_CFG_MSK_ISET (0x7 << ICM_CFG_OFF_ISET) +#define ICM_CFG_MSK_IWAY (0x7 << ICM_CFG_OFF_IWAY) +/* D-cache sets (# of cache lines) per way */ +#define DCM_CFG_OFF_DSET 0 +/* D-cache ways */ +#define DCM_CFG_OFF_DWAY 3 +#define DCM_CFG_MSK_DSET (0x7 << DCM_CFG_OFF_DSET) +#define DCM_CFG_MSK_DWAY (0x7 << DCM_CFG_OFF_DWAY) +/* I-cache line size */ +#define ICM_CFG_OFF_ISZ 6 +#define ICM_CFG_MSK_ISZ (0x7UL << ICM_CFG_OFF_ISZ) +/* D-cache line size */ +#define DCM_CFG_OFF_DSZ 6 +#define DCM_CFG_MSK_DSZ (0x7UL << DCM_CFG_OFF_DSZ)/* * The current upper bound for NDS32 L1 data cache line sizes is 32 bytes.
arch/nds32/include/asm/mach-types.h +1 -0
@@ -13,6 +13,7 @@ extern unsigned int __machine_arch_type;/* see arch/arm/kernel/arch.c for a description of these */ #define MACH_TYPE_ADPAG101P 1 +#define MACH_TYPE_ADPAE3XX 2#ifdef CONFIG_ARCH_ADPAG101P # ifdef machine_arch_type
arch/nds32/lib/Makefile +1 -0
@@ -11,4 +11,5 @@ obj-y += cache.o obj-$(CONFIG_CMD_BOOTM) += bootm.o +obj-$(CONFIG_CMD_GO) += boot.o obj-y += interrupts.o
arch/nds32/lib/boot.c new file +20 -0
@@ -0,0 +1,20 @@ +/* +* Copyright (C) 2011 Andes Technology Corporation +* Rick Chen, Andes Technology Corporation <[email protected]> +* +* SPDX-License-Identifier: GPL-2.0+ +*/ + + +#include <common.h> +#include <command.h> + +DECLARE_GLOBAL_DATA_PTR ; + +unsigned long do_go_exec (ulong (*entry)(int ,char *const []), +int argc,char *const argv[]) +{ +cleanup_before_linux (); + +return entry (argc, argv); +}
arch/nds32/lib/bootm.c +15 -8
@@ -11,6 +11,7 @@#include <image.h> #include <u-boot/zlib.h> #include <asm/byteorder.h> +#include <asm/bootm.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -73,6 +74,15 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)debug ("## Transferring control to Linux (at address %08lx) ...\n" , (ulong )theKernel); +if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) { +#ifdef CONFIG_OF_LIBFDT +debug ("using: FDT\n" ); +if (image_setup_linux (images)) { +printf ("FDT creation failed! hanging..." ); +hang (); + } +#endif + }else if (BOOTM_ENABLE_TAGS ) { #if defined(CONFIG_SETUP_MEMORY_TAGS) || \ defined(CONFIG_CMDLINE_TAG) || \ defined(CONFIG_INITRD_TAG) || \
@@ -107,16 +117,17 @@ int do_bootm_linux(int flag, int argc, char *argv[], bootm_headers_t *images)udc_disconnect (); }#endif - + }cleanup_before_linux (); - -theKernel (0 , machid, bd->bi_boot_params); +if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) +theKernel (0 , machid, (unsigned long )images->ft_addr); +else +theKernel (0 , machid, bd->bi_boot_params);/* does not return */ return 1 ; } - #if defined(CONFIG_SETUP_MEMORY_TAGS) || \ defined(CONFIG_CMDLINE_TAG) || \ defined(CONFIG_INITRD_TAG) || \
@@ -136,7 +147,6 @@ static void setup_start_tag(bd_t *bd) params =tag_next (params); } -#ifdef CONFIG_SETUP_MEMORY_TAGS static void setup_memory_tags (bd_t *bd) {
@@ -154,7 +164,6 @@ static void setup_memory_tags(bd_t *bd) }#endif /* CONFIG_SETUP_MEMORY_TAGS */ -static void setup_commandline_tag (bd_t *bd,char *commandline) {char *p;
@@ -182,7 +191,6 @@ static void setup_commandline_tag(bd_t *bd, char *commandline) params =tag_next (params); } -#ifdef CONFIG_INITRD_TAG static void setup_initrd_tag (bd_t *bd,ulong initrd_start,ulong initrd_end) {
@@ -230,7 +238,6 @@ void setup_revision_tag(struct tag **in_params) }#endif /* CONFIG_REVISION_TAG */ -static void setup_end_tag (bd_t *bd) { params->hdr.tag =ATAG_NONE ;
arch/nds32/lib/cache.c +160 -37
238 lines not on this page · raw message
board/AndesTech/adp-ae3xx/Kconfig new file +18 -0
@@ -0,0 +1,18 @@ +if TARGET_ADP_AE3XX + +config SYS_CPU + default "n1213" + +config SYS_BOARD + default "adp-ae3xx" + +config SYS_VENDOR + default "AndesTech" + +config SYS_SOC + default "ae3xx" + +config SYS_CONFIG_NAME + default "adp-ae3xx" + +endif
board/AndesTech/adp-ae3xx/MAINTAINERS new file +6 -0
@@ -0,0 +1,6 @@ +ADP-AG101P BOARD +M: Andes <[email protected]> +S: Maintained +F: board/AndesTech/adp-ae3xx/ +F: include/configs/adp-ae3xx.h +F: configs/adp-ae3xx_defconfig
board/AndesTech/adp-ae3xx/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# +# Copyright (C) 2016 Andes Technology Corporation +# Rick Chen, Andes Technology Corporation <[email protected]> +# +# SPDX-License-Identifier: GPL-2.0+ +# + +obj-y := adp-ae3xx.o
board/AndesTech/adp-ae3xx/adp-ae3xx.c new file +86 -0
86 lines not on this page · raw message
board/AndesTech/adp-ag101p/adp-ag101p.c +8 -1
@@ -7,8 +7,10 @@*/ #include <common.h> +#if defined(CONFIG_FTMAC100 )#include <netdev.h> -#include <asm/io.h> +#endif +#include <linux/io.h> #include <faraday/ftsdc010.h> #include <faraday/ftsmc020.h>
@@ -25,6 +27,7 @@ int board_init(void)* refer to BOOT_PARAMETER_PA_BASE within * "linux/arch/nds32/include/asm/misc_spec.h" */ +printf ("Board: %s\n" ,CONFIG_SYS_BOARD ); gd->bd->bi_arch_number =MACH_TYPE_ADPAG101P ; gd->bd->bi_boot_params =PHYS_SDRAM_0 +0x400 ;
@@ -59,10 +62,12 @@ int dram_init_banksize(void)return 0 ; } +#if defined(CONFIG_FTMAC100 )int board_eth_init (bd_t *bd) {return ftmac100_initialize (bd); } +#endif ulong board_flash_get_legacy (ulong base,int banknum,flash_info_t *info) {
@@ -78,6 +83,8 @@ ulong board_flash_get_legacy(ulong base, int banknum, flash_info_t *info)int board_mmc_init (bd_t *bis) { +#ifdef CONFIG_FTSDC010 ftsdc010_mmc_init (0 ); +#endif return 0 ; }
configs/adp-ae3xx_defconfig new file +25 -0
@@ -0,0 +1,25 @@ +CONFIG_NDS32=y +CONFIG_TARGET_ADP_AE3XX=y +CONFIG_DEFAULT_DEVICE_TREE="ae3xx" +CONFIG_FIT=y +CONFIG_BOOTDELAY=3 +CONFIG_SYS_PROMPT="NDS32 # " +CONFIG_CMD_MMC=y +# CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y +CONFIG_CMD_PING=y +CONFIG_CMD_CACHE=y +CONFIG_CMD_DATE=y +CONFIG_CMD_EXT2=y +CONFIG_CMD_FAT=y +CONFIG_MMC=y +CONFIG_MTD_NOR_FLASH=y +CONFIG_BAUDRATE=38400 +CONFIG_OF_CONTROL=y +CONFIG_DM=y +CONFIG_MTD=y +CONFIG_CFI_FLASH=y +CONFIG_DM_SERIAL=y +CONFIG_SYS_NS16550=y +CONFIG_TIMER=y +CONFIG_AE3XX_TIMER=y
configs/adp-ag101p_defconfig +1 -0
@@ -6,6 +6,7 @@ CONFIG_BOOTDELAY=3 CONFIG_SYS_PROMPT="NDS32 # " CONFIG_CMD_MMC=y # CONFIG_CMD_SETEXPR is not set +CONFIG_CMD_DHCP=y CONFIG_CMD_PING=y CONFIG_CMD_CACHE=y CONFIG_CMD_DATE=y
drivers/timer/Kconfig +9 -3
@@ -75,9 +75,15 @@ config ARC_TIMER in U-Boot. config AG101P_TIMER - bool "Ag101p timer support" - depends on TIMER + bool "AG101P timer support" + depends on TIMER && NDS32 + help + Select this to enable a timer for AG01P devices. + +config AE3XX_TIMER + bool "AE3XX timer support" + depends on TIMER && NDS32 help - Select this to enable a timer for Ag101p devices. + Select this to enable a timer for AE3XX devices. endmenu
drivers/timer/Makefile +1 -0
@@ -13,3 +13,4 @@ obj-$(CONFIG_AST_TIMER) += ast_timer.o obj-$(CONFIG_STI_TIMER) += sti-timer.o obj-$(CONFIG_ARC_TIMER) += arc_timer.o obj-$(CONFIG_AG101P_TIMER) += ag101p_timer.o +obj-$(CONFIG_AE3XX_TIMER) += ae3xx_timer.o
drivers/timer/ae3xx_timer.c new file +117 -0
117 lines not on this page · raw message
include/configs/adp-ae3xx.h new file +260 -0
260 lines not on this page · raw message
include/configs/adp-ag101p.h +20 -7
@@ -20,12 +20,13 @@#define CONFIG_SKIP_LOWLEVEL_INIT -/* -* Definitions related to passing arguments to kernel. -*/ -#define CONFIG_CMDLINE_TAG /* send commandline to Kernel */ -#define CONFIG_SETUP_MEMORY_TAGS /* send memory definition to kernel */ -#define CONFIG_INITRD_TAG /* send initrd params */ +#define CONFIG_CMDLINE_EDITING + +#define CONFIG_SYS_ICACHE_OFF +#define CONFIG_SYS_DCACHE_OFF + +#define CONFIG_BOOTP_SEND_HOSTNAME +#define CONFIG_BOOTP_SERVERIP #ifndef CONFIG_SKIP_LOWLEVEL_INIT #define CONFIG_MEM_REMAP
@@ -99,7 +100,6 @@*/ #define CONFIG_FTMAC100 -/* * SD (MMC) controller */
@@ -352,7 +352,9 @@* There are 4 banks supported for this Controller, * but we have only 1 bank connected to flash on board */ +#ifndef CONFIG_SYS_MAX_FLASH_BANKS_DETECT #define CONFIG_SYS_MAX_FLASH_BANKS 1 +#endif #define CONFIG_SYS_FLASH_BANKS_SIZES {0x4000000}/* max number of sectors on one chip */
@@ -366,4 +368,15 @@#define CONFIG_ENV_SIZE 8192#define CONFIG_ENV_OVERWRITE +/* +* For booting Linux, the board info and command line data +* have to be in the first 16 MB of memory, since this is +* the maximum mapped by the Linux kernel during initialization. +*/ + +/* Initial Memory map for Linux*/ +#define CONFIG_SYS_BOOTMAPSZ (64 << 20) +/* Increase max gunzip size */ +#define CONFIG_SYS_BOOTM_LEN (64 << 20) +#endif /* __CONFIG_H */
Signature · 1 line
1.7.9.5