Skip to contentSkip to conversation

nds32/ag102: add header support of ag102 soc

PATCH Superseded Macpaul Lin 3 participants 18 messages Nov 18, 2011 – Nov 30, 2011 1 message not in the archive Arm/actions semi architecture

lore
Share & tools
lore
#0 lore raw

PATCH 1/4 nds32/ag102: add header support of ag102 soc

Add device address offsets header of ag102 soc. Add ag102 into mach-types.h.
Add asm-offsets.c for helping convert C headers into asm.

---
 arch/nds32/cpu/n1213/ag102/asm-offsets.c  |   54 ++++++++++++++++
 arch/nds32/include/asm/arch-ag102/ag102.h |   97 +++++++++++++++++++++++++++++
 arch/nds32/include/asm/mach-types.h       |   14 ++++
 3 files changed, 165 insertions(+), 0 deletions(-)
 create mode 100644 arch/nds32/cpu/n1213/ag102/asm-offsets.c
 create mode 100644 arch/nds32/include/asm/arch-ag102/ag102.h
arch/nds32/cpu/n1213/ag102/asm-offsets.c new file +54 -0
new file mode 100644
index 0000000..4769a95
@@ -0,0 +1,54 @@
+/*
+ * Adapted from Linux v2.6.36 kernel: arch/powerpc/kernel/asm-offsets.c
+ *
+ * Generate definitions needed by assembly language modules.
+ * This code generates raw asm output which is post-processed to extract
+ * and format the required data.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <common.h>
+
+#include <linux/kbuild.h>
+
+int main(void)
+{
+#ifdef CONFIG_FTSMC020
+	OFFSET(FTSMC020_BANK0_CR,	ftsmc020, bank[0].cr);
+	OFFSET(FTSMC020_BANK0_TPR,	ftsmc020, bank[0].tpr);
+#endif
+	BLANK();
+#ifdef CONFIG_FTAHBC020S
+	OFFSET(FTAHBC020S_SLAVE_BSR_6,	ftahbc02s, s_bsr[6]);
+	OFFSET(FTAHBC020S_CR,		ftahbc02s, cr);
+#endif
+	BLANK();
+#ifdef CONFIG_ANDES_PCU
+	OFFSET(ANDES_PCU_PCS4,		andes_pcu, pcs4.parm);	/* 0x104 */
+#endif
+	BLANK();
+#ifdef CONFIG_DWCDDR21MCTL
+	OFFSET(DWCDDR21MCTL_CCR,	dwcddr21mctl, ccr);	/* 0x04 */
+	OFFSET(DWCDDR21MCTL_DCR,	dwcddr21mctl, dcr);	/* 0x04 */
+	OFFSET(DWCDDR21MCTL_IOCR,	dwcddr21mctl, iocr);	/* 0x08 */
+	OFFSET(DWCDDR21MCTL_CSR,	dwcddr21mctl, csr);	/* 0x0c */
+	OFFSET(DWCDDR21MCTL_DRR,	dwcddr21mctl, drr);	/* 0x10 */
+	OFFSET(DWCDDR21MCTL_DLLCR0,	dwcddr21mctl, dllcr[0]); /* 0x24 */
+	OFFSET(DWCDDR21MCTL_DLLCR1,	dwcddr21mctl, dllcr[1]); /* 0x28 */
+	OFFSET(DWCDDR21MCTL_DLLCR2,	dwcddr21mctl, dllcr[2]); /* 0x2c */
+	OFFSET(DWCDDR21MCTL_DLLCR3,	dwcddr21mctl, dllcr[3]); /* 0x30 */
+	OFFSET(DWCDDR21MCTL_DLLCR4,	dwcddr21mctl, dllcr[4]); /* 0x34 */
+	OFFSET(DWCDDR21MCTL_DLLCR5,	dwcddr21mctl, dllcr[5]); /* 0x38 */
+	OFFSET(DWCDDR21MCTL_DLLCR6,	dwcddr21mctl, dllcr[6]); /* 0x3c */
+	OFFSET(DWCDDR21MCTL_DLLCR7,	dwcddr21mctl, dllcr[7]); /* 0x40 */
+	OFFSET(DWCDDR21MCTL_DLLCR8,	dwcddr21mctl, dllcr[8]); /* 0x44 */
+	OFFSET(DWCDDR21MCTL_DLLCR9,	dwcddr21mctl, dllcr[9]); /* 0x48 */
+	OFFSET(DWCDDR21MCTL_RSLR0,	dwcddr21mctl, rslr[0]);	/* 0x4c */
+	OFFSET(DWCDDR21MCTL_RDGR0,	dwcddr21mctl, rdgr[0]);	/* 0x5c */
+	OFFSET(DWCDDR21MCTL_DTAR,	dwcddr21mctl, dtar);	/* 0xa4 */
+	OFFSET(DWCDDR21MCTL_MR,		dwcddr21mctl, mr);	/* 0x1f0 */
+#endif
+	return 0;
+}
arch/nds32/include/asm/arch-ag102/ag102.h new file +97 -0

97 lines not on this page · raw message

arch/nds32/include/asm/mach-types.h +14 -0
index 7b52b98..259e4e7 100644
@@ -40,4 +40,18 @@ extern unsigned int __machine_arch_type;
 # define machine_is_adpag101p()	(1)
 #endif
 
+#define MACH_TYPE_ADPAG102             2
+
+#ifdef CONFIG_ARCH_ADPAG102
+# ifdef machine_arch_type
+#  undef machine_arch_type
+#  define machine_arch_type	__machine_arch_type
+# else
+#  define machine_arch_type	MACH_TYPE_ADPAG102
+# endif
+# define machine_is_adpag102()	(machine_arch_type == MACH_TYPE_ADPAG102)
+#else
+# define machine_is_adpag102()	(2)
+#endif
+
 #endif /* __ASM_NDS32_MACH_TYPE_H */
Signature · 1 line
1.7.3.5
#1 lore raw

PATCH 2/4 nds32/ag102: add ag102 soc support

Add lowlevel ag102 soc support.

---
 arch/nds32/cpu/n1213/ag102/Makefile        |   58 ++++++
 arch/nds32/cpu/n1213/ag102/cpu.c           |  200 +++++++++++++++++++
 arch/nds32/cpu/n1213/ag102/lowlevel_init.S |  297 ++++++++++++++++++++++++++++
 arch/nds32/cpu/n1213/ag102/timer.c         |  205 +++++++++++++++++++
 arch/nds32/cpu/n1213/ag102/watchdog.S      |   48 +++++
 5 files changed, 808 insertions(+), 0 deletions(-)
 create mode 100644 arch/nds32/cpu/n1213/ag102/Makefile
 create mode 100644 arch/nds32/cpu/n1213/ag102/cpu.c
 create mode 100644 arch/nds32/cpu/n1213/ag102/lowlevel_init.S
 create mode 100644 arch/nds32/cpu/n1213/ag102/timer.c
 create mode 100644 arch/nds32/cpu/n1213/ag102/watchdog.S
arch/nds32/cpu/n1213/ag102/Makefile new file +58 -0
new file mode 100644
index 0000000..8716c4e
@@ -0,0 +1,58 @@
+#
+# (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]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).o
+
+COBJS-y	:= cpu.o timer.o
+
+ifndef CONFIG_SKIP_LOWLEVEL_INIT
+SOBJS	:= lowlevel_init.o
+endif
+
+ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG
+SOBJS	+= watchdog.o
+endif
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS-y))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/nds32/cpu/n1213/ag102/cpu.c new file +200 -0

200 lines not on this page · raw message

arch/nds32/cpu/n1213/ag102/lowlevel_init.S new file +297 -0

297 lines not on this page · raw message

arch/nds32/cpu/n1213/ag102/timer.c new file +205 -0

205 lines not on this page · raw message

arch/nds32/cpu/n1213/ag102/watchdog.S new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#17 lore raw

PATCH 3/4 board/adp-ag102: add board specific files

In reply to Macpaul Lin

Add board specific files.

---
 board/AndesTech/adp-ag102/Makefile    |   43 +++++++++++++
 board/AndesTech/adp-ag102/adp-ag102.c |  107 +++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+), 0 deletions(-)
 create mode 100644 board/AndesTech/adp-ag102/Makefile
 create mode 100644 board/AndesTech/adp-ag102/adp-ag102.c
board/AndesTech/adp-ag102/Makefile new file +43 -0
new file mode 100644
index 0000000..1cbf2d4
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2011 Andes Technology Corporation
+# Macpaul Lin, Andes Technology Corporation <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS	:= adp-ag102.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
board/AndesTech/adp-ag102/adp-ag102.c new file +107 -0

107 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#18 lore raw

PATCH 4/4 board/adp-ag102: add configuration of adp-ag102

In reply to Macpaul Lin

board:
Add config file of board adp-ag102
Add adp-ag102 into boards.cfg
Add adp-ag102 into MAINTAINERS

doc:
add README of ag102

---
 MAINTAINERS                 |    1 +
 boards.cfg                  |    1 +
 doc/README.ag102            |   36 +++++
 include/configs/adp-ag102.h |  341 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 379 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.ag102
 create mode 100644 include/configs/adp-ag102.h
MAINTAINERS +1 -0
index 94dcb7d..0501c2c 100644
@@ -1149,6 +1149,7 @@ Macpaul Lin <[email protected]>
 
 	ADP-AG101	N1213 (AG101 SoC)
 	ADP-AG101P	N1213 (AG101P XC5 FPGA)
+	ADP-AG102	N1213f (AG102 SoC with FPU)
 
 #########################################################################
 # End of MAINTAINERS list						#
boards.cfg +1 -0
index c83d861..13ddbcb 100644
@@ -349,6 +349,7 @@ qi_lb60                      mips        xburst      qi_lb60             qi
 nios2-generic                nios2       nios2       nios2-generic       altera
 adp-ag101                    nds32       n1213       adp-ag101           AndesTech      ag101
 adp-ag101p                   nds32       n1213       adp-ag101p          AndesTech      ag101
+adp-ag102                    nds32       n1213       adp-ag102           AndesTech      ag102
 PCI5441                      nios2       nios2       pci5441             psyent
 PK1C20                       nios2       nios2       pk1c20              psyent
 EVB64260                     powerpc     74xx_7xx    evb64260            -              -           EVB64260
doc/README.ag102 new file +36 -0
new file mode 100644
index 0000000..7d142a7
@@ -0,0 +1,36 @@
+Andes Technology SoC AG102
+==========================
+
+AG102 is the second SoC produced by Andes Technology using N1213 CPU core
+with FPU and DDR contoller support.
+AG102 has integrated both AHB and APB bus and many periphals for application
+and product development.
+
+ADP-AG102
+=========
+
+ADP-AG102 is the SoC with AG102 hardcore CPU.
+
+Configurations
+==============
+
+CONFIG_MEM_REMAP:
+	Doing memory remap is essential for preparing some non-OS or RTOS
+	applications.
+
+CONFIG_SKIP_LOWLEVEL_INIT:
+	If you want to boot this system from SPI ROM and bypass e-bios (the
+	other boot loader on ROM). You should undefine CONFIG_SKIP_LOWLEVEL_INIT
+	in "include/configs/adp-ag102.h".
+
+Build and boot steps
+====================
+
+build:
+1. Prepare the toolchains and make sure the $PATH to toolchains is correct.
+2. Use `make adp-ag102` in u-boot root to build the image.
+
+Burn u-boot to SPI ROM:
+====================
+
+This section will be added later.
include/configs/adp-ag102.h new file +341 -0

341 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#2 lore raw

PATCH 2/4 nds32/ag102: add ag102 soc support

In reply to Macpaul Lin

arch/nds32/cpu/n1213/ag102/cpu.c line 50

Quoted 8 lines · On Friday 18 November 2011 03:30:55 Macpaul Lin wrote:
arch/nds32/cpu/n1213/ag102/cpu.c new file +5 -0
 
+int cleanup_before_linux(void)
+{
+#ifdef CONFIG_MMU
+	unsigned long i;
+#endif

this variable is unused

Quoted 12 lines
arch/nds32/cpu/n1213/ag102/cpu.c new file +12 -0
+int do_reset(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
+{
+	disable_interrupts();
+
+	/*
+	 * reset to the base addr of andesboot.
+	 * currently no ROM loader at addr 0.
+	 * do not use reset_cpu(0);
+	 */
+#ifdef CONFIG_FTWDT010_WATCHDOG
+	/*
+	 * workaround: if we use CONFIG_HW_WATCHDOG with ftwdt010, will lead

arch/nds32/cpu/n1213/ag102/cpu.c line 88

Quoted 10 lines
arch/nds32/cpu/n1213/ag102/cpu.c new file +10 -0
+	 * automatic hardware reset when booting Linux.
+	 * Please do not use CONFIG_HW_WATCHDOG and WATCHDOG_RESET() here.
+	 */
+	ftwdt010_wdt_reset();
+	while (1)
+		;
+#endif /* CONFIG_FTWDT010_WATCHDOG */
+
+	/*NOTREACHED*/
+}

if CONFIG_FTWDT010_WATCHDOG isn't defined, then this command will wrongly return. you probably want to move that while(1) outside of the ifdef. actually, delete that while(1) and put a hang() there.

arch/nds32/cpu/n1213/ag102/cpu.c line 128

Quoted 5 lines
arch/nds32/cpu/n1213/ag102/cpu.c new file +5 -0
+void flush_cache(unsigned long addr, unsigned long size)
+{
+	dcache_flush_range(addr , addr + size);
+	icache_inval_range(addr , addr + size);
+}

no spaces before those commas

arch/nds32/cpu/n1213/ag102/timer.c line 36

Quoted 6 lines
arch/nds32/cpu/n1213/ag102/timer.c new file +3 -0
 
+int timer_init(void)
+{
+	static struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;

don't think this needs to be static

arch/nds32/cpu/n1213/ag102/timer.c line 83

Quoted 3 lines
arch/nds32/cpu/n1213/ag102/timer.c new file +3 -0
+void reset_timer_masked(void)
+{
+	static struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;

this too

arch/nds32/cpu/n1213/ag102/timer.c line 107

Quoted 3 lines
arch/nds32/cpu/n1213/ag102/timer.c new file +3 -0
+ulong get_timer_masked(void)
+{
+	static struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;

and here

arch/nds32/cpu/n1213/ag102/timer.c line 163

Quoted 3 lines
arch/nds32/cpu/n1213/ag102/timer.c new file +3 -0
+void __udelay(unsigned long usec)
+{
+	static struct fttmr010 *tmr = (struct fttmr010 *)CONFIG_FTTMR010_BASE;

and here

arch/nds32/cpu/n1213/ag102/watchdog.S

Quoted 4 lines
arch/nds32/cpu/n1213/ag102/watchdog.S new file +1 -0
 
+#ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG

looks like a useless define ...

Quoted 6 lines

+.globl turnoff_watchdog

arch/nds32/cpu/n1213/ag102/watchdog.S new file +5 -0
+turnoff_watchdog:
+
+#define WD_CR		0xC
+#define WD_ENABLE	0x1
+

arch/nds32/cpu/n1213/ag102/watchdog.S line 44

Quoted 10 lines
arch/nds32/cpu/n1213/ag102/watchdog.S new file +10 -0
+	! Turn off the watchdog, according to Faraday FTWDT010 spec
+	li 	$p0, (CONFIG_FTWDT010_BASE+WD_CR)	! Get the addr of WD CR
+	lwi	$p1, [$p0]				! Get the config of WD
+	andi	$p1, $p1, 0x1f				! Wipe out useless bits
+	li	$r0, ~WD_ENABLE
+	and	$p1, $p1, $r0				! Set WD disable
+	sw	$p1, [$p0]				! Write back to WD CR
+
+	! Disable Interrupts by clear GIE in $PSW reg
+	setgie.d

can't this be C code ?
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111118/853abe54/attachment.pgp>

#3 lore raw

PATCH 2/4 nds32/ag102: add ag102 soc support

Hi Mike

2011/11/19 Mike Frysinger <[email protected]>

Thanks for your review.

[snip]

Quoted 17 lines

arch/nds32/cpu/n1213/ag102/watchdog.S

Quoted 9 lines

+.globl turnoff_watchdog

arch/nds32/cpu/n1213/ag102/watchdog.S new file +7 -0
+turnoff_watchdog:
+
+#define WD_CR                0xC
+#define WD_ENABLE    0x1
+
+     ! Turn off the watchdog, according to Faraday FTWDT010 spec
+     li      $p0, (CONFIG_FTWDT010_BASE+WD_CR)       ! Get the addr of

WD CR

Quoted 1 line

+ lwi $p1, [$p0] ! Get the config

of WD

Quoted 1 line

+ andi $p1, $p1, 0x1f ! Wipe out useless

bits

arch/nds32/cpu/n1213/ag102/watchdog.S

Quoted 3 lines
arch/nds32/cpu/n1213/ag102/watchdog.S new file +3 -0
+     li      $r0, ~WD_ENABLE
+     and     $p1, $p1, $r0                           ! Set WD disable
+     sw      $p1, [$p0]                              ! Write back to WD
Quoted 8 lines

CR

arch/nds32/cpu/n1213/ag102/watchdog.S line 44

Quoted 3 lines
arch/nds32/cpu/n1213/ag102/watchdog.S new file +3 -0
+
+     ! Disable Interrupts by clear GIE in $PSW reg
+     setgie.d

can't this be C code ?
-mike

This is because after reset, the watchdog might be enabled if there is another boot loader has ran before u-boot.
If the other boot loader enabled watchdog but didn't stop it, it might cause u-boot to be reset during assembly initialization phase. So we need to disable watchdog here.

Other suggestions will be adapted.
Thanks!

Signature · 2 lines
Best regards,
Macpaul Lin
#4 lore raw

PATCH 2/4 nds32/ag102: add ag102 soc support

Quoted 7 lines · On Tuesday 22 November 2011 21:16:50 Macpaul Lin wrote:

2011/11/19 Mike Frysinger <[email protected]>

Quoted 5 lines

arch/nds32/cpu/n1213/ag102/watchdog.S line 31

Quoted 3 lines

+.globl turnoff_watchdog

arch/nds32/cpu/n1213/ag102/watchdog.S new file +2 -0
+turnoff_watchdog:
+

can't this be C code ?

Quoted 5 lines

This is because after reset, the watchdog might be enabled if there is another boot loader has ran before u-boot.
If the other boot loader enabled watchdog but didn't stop it, it might cause u-boot to be reset during assembly initialization phase. So we need to disable watchdog here.

my point is, why can't turnoff_watchdog() be written in C ? why does this func need to be written in assembly ?

looking at the start.S, seems like there's a bit of logic there that should be in C and not a lot of asm. *shrug* too late now i guess.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111123/323b88a4/attachment.pgp>

#6 lore raw

PATCH 2/4 nds32/ag102: add ag102 soc support

In reply to a message not in the archive

Hi Mike,

2011/11/29 Macpaul Lin <[email protected]>

Quoted 3 lines

Hi Mike,

This reply didn't CC to u-boot mailing list.
So I forward it again.

Quoted 49 lines

2011/11/24 Mike Frysinger <[email protected]>

Quoted 8 lines · On Tuesday 22 November 2011 21:16:50 Macpaul Lin wrote:
Quoted 7 lines

2011/11/19 Mike Frysinger <[email protected]>

Quoted 5 lines

arch/nds32/cpu/n1213/ag102/watchdog.S line 31

Quoted 3 lines

+.globl turnoff_watchdog

arch/nds32/cpu/n1213/ag102/watchdog.S new file +2 -0
+turnoff_watchdog:
+

can't this be C code ?

Quoted 7 lines
Quoted 5 lines

This is because after reset, the watchdog might be enabled if there is another boot loader has ran before u-boot.
If the other boot loader enabled watchdog but didn't stop it, it might cause u-boot to be reset during assembly initialization phase. So we need to disable watchdog here.

The initialize procedure of NDS32 N1213 CPU is mentioned as follows.

1st, we set correct vector size in the system registers inside the cpu to make sure the
vector table works well.
2nd, do dram/ddr dram controller initialize since there are no memory like SRAM on
SoC could be able to used as stack.
3rd, do this watchdog disable to prevent the continuous boot strap will be interrupted by
hardware reset due to watchdog timeout.
4th, do small stack setup to prepare C environment which based on step No.2, dram/ddr
controller initialize. With out this memory initialization, the C stack couldn't be initialized
and board_init_f() cannot be executed.

Of course you can do disable watchdog timer later inside board_init_f(), but we're afraid
of to increase the probability of boot up fail caused by watchdog reset.

Quoted 9 lines

my point is, why can't turnoff_watchdog() be written in C ? why does
this func
need to be written in assembly ?

looking at the start.S, seems like there's a bit of logic there that should be
in C and not a lot of asm. *shrug* too late now i guess. -mike

Quoted 8 lines

Which left in start.S included the copy loop for relocation, and .got, .bss fixup.
Others are vectors and I/D cache operation if you want to use in board_init_f().
Please give us your idea and see if this will be better.

Thanks!

Thanks.

Signature · 2 lines
Best regards,
Macpaul Lin
#7 lore raw

PATCH v2 1/4 nds32/ag102: add header support of ag102 soc

In reply to a message not in the archive

Add device address offsets header of ag102 soc. Add ag102 into mach-types.h.
Add asm-offsets.c for helping convert C headers into asm.

---
Changes for v2:
- No change.

 arch/nds32/cpu/n1213/ag102/asm-offsets.c  |   54 ++++++++++++++++
 arch/nds32/include/asm/arch-ag102/ag102.h |   97 +++++++++++++++++++++++++++++
 arch/nds32/include/asm/mach-types.h       |   14 ++++
 3 files changed, 165 insertions(+), 0 deletions(-)
 create mode 100644 arch/nds32/cpu/n1213/ag102/asm-offsets.c
 create mode 100644 arch/nds32/include/asm/arch-ag102/ag102.h
arch/nds32/cpu/n1213/ag102/asm-offsets.c new file +54 -0
new file mode 100644
index 0000000..4769a95
@@ -0,0 +1,54 @@
+/*
+ * Adapted from Linux v2.6.36 kernel: arch/powerpc/kernel/asm-offsets.c
+ *
+ * Generate definitions needed by assembly language modules.
+ * This code generates raw asm output which is post-processed to extract
+ * and format the required data.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+#include <common.h>
+
+#include <linux/kbuild.h>
+
+int main(void)
+{
+#ifdef CONFIG_FTSMC020
+	OFFSET(FTSMC020_BANK0_CR,	ftsmc020, bank[0].cr);
+	OFFSET(FTSMC020_BANK0_TPR,	ftsmc020, bank[0].tpr);
+#endif
+	BLANK();
+#ifdef CONFIG_FTAHBC020S
+	OFFSET(FTAHBC020S_SLAVE_BSR_6,	ftahbc02s, s_bsr[6]);
+	OFFSET(FTAHBC020S_CR,		ftahbc02s, cr);
+#endif
+	BLANK();
+#ifdef CONFIG_ANDES_PCU
+	OFFSET(ANDES_PCU_PCS4,		andes_pcu, pcs4.parm);	/* 0x104 */
+#endif
+	BLANK();
+#ifdef CONFIG_DWCDDR21MCTL
+	OFFSET(DWCDDR21MCTL_CCR,	dwcddr21mctl, ccr);	/* 0x04 */
+	OFFSET(DWCDDR21MCTL_DCR,	dwcddr21mctl, dcr);	/* 0x04 */
+	OFFSET(DWCDDR21MCTL_IOCR,	dwcddr21mctl, iocr);	/* 0x08 */
+	OFFSET(DWCDDR21MCTL_CSR,	dwcddr21mctl, csr);	/* 0x0c */
+	OFFSET(DWCDDR21MCTL_DRR,	dwcddr21mctl, drr);	/* 0x10 */
+	OFFSET(DWCDDR21MCTL_DLLCR0,	dwcddr21mctl, dllcr[0]); /* 0x24 */
+	OFFSET(DWCDDR21MCTL_DLLCR1,	dwcddr21mctl, dllcr[1]); /* 0x28 */
+	OFFSET(DWCDDR21MCTL_DLLCR2,	dwcddr21mctl, dllcr[2]); /* 0x2c */
+	OFFSET(DWCDDR21MCTL_DLLCR3,	dwcddr21mctl, dllcr[3]); /* 0x30 */
+	OFFSET(DWCDDR21MCTL_DLLCR4,	dwcddr21mctl, dllcr[4]); /* 0x34 */
+	OFFSET(DWCDDR21MCTL_DLLCR5,	dwcddr21mctl, dllcr[5]); /* 0x38 */
+	OFFSET(DWCDDR21MCTL_DLLCR6,	dwcddr21mctl, dllcr[6]); /* 0x3c */
+	OFFSET(DWCDDR21MCTL_DLLCR7,	dwcddr21mctl, dllcr[7]); /* 0x40 */
+	OFFSET(DWCDDR21MCTL_DLLCR8,	dwcddr21mctl, dllcr[8]); /* 0x44 */
+	OFFSET(DWCDDR21MCTL_DLLCR9,	dwcddr21mctl, dllcr[9]); /* 0x48 */
+	OFFSET(DWCDDR21MCTL_RSLR0,	dwcddr21mctl, rslr[0]);	/* 0x4c */
+	OFFSET(DWCDDR21MCTL_RDGR0,	dwcddr21mctl, rdgr[0]);	/* 0x5c */
+	OFFSET(DWCDDR21MCTL_DTAR,	dwcddr21mctl, dtar);	/* 0xa4 */
+	OFFSET(DWCDDR21MCTL_MR,		dwcddr21mctl, mr);	/* 0x1f0 */
+#endif
+	return 0;
+}
arch/nds32/include/asm/arch-ag102/ag102.h new file +97 -0

97 lines not on this page · raw message

arch/nds32/include/asm/mach-types.h +14 -0
index 7b52b98..259e4e7 100644
@@ -40,4 +40,18 @@ extern unsigned int __machine_arch_type;
 # define machine_is_adpag101p()	(1)
 #endif
 
+#define MACH_TYPE_ADPAG102             2
+
+#ifdef CONFIG_ARCH_ADPAG102
+# ifdef machine_arch_type
+#  undef machine_arch_type
+#  define machine_arch_type	__machine_arch_type
+# else
+#  define machine_arch_type	MACH_TYPE_ADPAG102
+# endif
+# define machine_is_adpag102()	(machine_arch_type == MACH_TYPE_ADPAG102)
+#else
+# define machine_is_adpag102()	(2)
+#endif
+
 #endif /* __ASM_NDS32_MACH_TYPE_H */
Signature · 1 line
1.7.3.5
#8 lore raw

PATCH v2 2/4 nds32/ag102: add ag102 soc support

In reply to a message not in the archive

Add lowlevel ag102 soc support.

---
Changes for v2:
- cpu.c:
- 1. Remove unused variables.
- 2. Replace while(1) in do_reset by hang().
- 3. Clean up other coding styles.
- timer.c: remove unneccessary static declaration

 arch/nds32/cpu/n1213/ag102/Makefile        |   58 ++++++
 arch/nds32/cpu/n1213/ag102/cpu.c           |  195 ++++++++++++++++++
 arch/nds32/cpu/n1213/ag102/lowlevel_init.S |  297 ++++++++++++++++++++++++++++
 arch/nds32/cpu/n1213/ag102/timer.c         |  205 +++++++++++++++++++
 arch/nds32/cpu/n1213/ag102/watchdog.S      |   48 +++++
 5 files changed, 803 insertions(+), 0 deletions(-)
 create mode 100644 arch/nds32/cpu/n1213/ag102/Makefile
 create mode 100644 arch/nds32/cpu/n1213/ag102/cpu.c
 create mode 100644 arch/nds32/cpu/n1213/ag102/lowlevel_init.S
 create mode 100644 arch/nds32/cpu/n1213/ag102/timer.c
 create mode 100644 arch/nds32/cpu/n1213/ag102/watchdog.S
arch/nds32/cpu/n1213/ag102/Makefile new file +58 -0
new file mode 100644
index 0000000..8716c4e
@@ -0,0 +1,58 @@
+#
+# (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]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+# MA 02110-1301 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(SOC).o
+
+COBJS-y	:= cpu.o timer.o
+
+ifndef CONFIG_SKIP_LOWLEVEL_INIT
+SOBJS	:= lowlevel_init.o
+endif
+
+ifndef CONFIG_SKIP_TRUNOFF_WATCHDOG
+SOBJS	+= watchdog.o
+endif
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS-y:.o=.c)
+OBJS	:= $(addprefix $(obj),$(SOBJS) $(COBJS-y))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/nds32/cpu/n1213/ag102/cpu.c new file +195 -0

195 lines not on this page · raw message

arch/nds32/cpu/n1213/ag102/lowlevel_init.S new file +297 -0

297 lines not on this page · raw message

arch/nds32/cpu/n1213/ag102/timer.c new file +205 -0

205 lines not on this page · raw message

arch/nds32/cpu/n1213/ag102/watchdog.S new file +48 -0

48 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#15 lore raw

PATCH v2 3/4 board/adp-ag102: add board specific files

In reply to a message not in the archive

Add board specific files.

---
Changes for v2:
- No change.

 board/AndesTech/adp-ag102/Makefile    |   43 +++++++++++++
 board/AndesTech/adp-ag102/adp-ag102.c |  107 +++++++++++++++++++++++++++++++++
 2 files changed, 150 insertions(+), 0 deletions(-)
 create mode 100644 board/AndesTech/adp-ag102/Makefile
 create mode 100644 board/AndesTech/adp-ag102/adp-ag102.c
board/AndesTech/adp-ag102/Makefile new file +43 -0
new file mode 100644
index 0000000..1cbf2d4
@@ -0,0 +1,43 @@
+#
+# Copyright (C) 2011 Andes Technology Corporation
+# Macpaul Lin, Andes Technology Corporation <[email protected]>
+#
+# See file CREDITS for list of people who contributed to this
+# project.
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License as
+# published by the Free Software Foundation; either version 2 of
+# the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+# MA 02111-1307 USA
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)lib$(BOARD).o
+
+COBJS	:= adp-ag102.o
+
+SRCS	:= $(SOBJS:.o=.S) $(COBJS:.o=.c)
+OBJS	:= $(addprefix $(obj),$(COBJS) $(SOBJS))
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
board/AndesTech/adp-ag102/adp-ag102.c new file +107 -0

107 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#16 lore raw

PATCH v2 4/4 board/adp-ag102: add configuration of adp-ag102

In reply to a message not in the archive

board:
Add config file of board adp-ag102
Add adp-ag102 into boards.cfg
Add adp-ag102 into MAINTAINERS

doc:
add README of ag102

---
Changes for v2:
- add pci and usb support to board setting adp-ag102.h

 MAINTAINERS                 |    1 +
 boards.cfg                  |    1 +
 doc/README.ag102            |   36 ++++
 include/configs/adp-ag102.h |  375 +++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 413 insertions(+), 0 deletions(-)
 create mode 100644 doc/README.ag102
 create mode 100644 include/configs/adp-ag102.h
MAINTAINERS +1 -0
index f6f6b72..892829c 100644
@@ -1145,6 +1145,7 @@ Macpaul Lin <[email protected]>
 
 	ADP-AG101	N1213 (AG101 SoC)
 	ADP-AG101P	N1213 (AG101P XC5 FPGA)
+	ADP-AG102	N1213f (AG102 SoC with FPU)
 
 #########################################################################
 # End of MAINTAINERS list						#
boards.cfg +1 -0
index c83d861..13ddbcb 100644
@@ -349,6 +349,7 @@ qi_lb60                      mips        xburst      qi_lb60             qi
 nios2-generic                nios2       nios2       nios2-generic       altera
 adp-ag101                    nds32       n1213       adp-ag101           AndesTech      ag101
 adp-ag101p                   nds32       n1213       adp-ag101p          AndesTech      ag101
+adp-ag102                    nds32       n1213       adp-ag102           AndesTech      ag102
 PCI5441                      nios2       nios2       pci5441             psyent
 PK1C20                       nios2       nios2       pk1c20              psyent
 EVB64260                     powerpc     74xx_7xx    evb64260            -              -           EVB64260
doc/README.ag102 new file +36 -0
new file mode 100644
index 0000000..7d142a7
@@ -0,0 +1,36 @@
+Andes Technology SoC AG102
+==========================
+
+AG102 is the second SoC produced by Andes Technology using N1213 CPU core
+with FPU and DDR contoller support.
+AG102 has integrated both AHB and APB bus and many periphals for application
+and product development.
+
+ADP-AG102
+=========
+
+ADP-AG102 is the SoC with AG102 hardcore CPU.
+
+Configurations
+==============
+
+CONFIG_MEM_REMAP:
+	Doing memory remap is essential for preparing some non-OS or RTOS
+	applications.
+
+CONFIG_SKIP_LOWLEVEL_INIT:
+	If you want to boot this system from SPI ROM and bypass e-bios (the
+	other boot loader on ROM). You should undefine CONFIG_SKIP_LOWLEVEL_INIT
+	in "include/configs/adp-ag102.h".
+
+Build and boot steps
+====================
+
+build:
+1. Prepare the toolchains and make sure the $PATH to toolchains is correct.
+2. Use `make adp-ag102` in u-boot root to build the image.
+
+Burn u-boot to SPI ROM:
+====================
+
+This section will be added later.
include/configs/adp-ag102.h new file +375 -0

375 lines not on this page · raw message

Signature · 1 line
1.7.3.5
#9 lore raw

PATCH v2 2/4 nds32/ag102: add ag102 soc support

In reply to Macpaul Lin
Quoted 2 lines · On Tuesday 29 November 2011 04:15:05 Macpaul Lin wrote:

+.globl turnoff_watchdog
+turnoff_watchdog:

should be:
ENTRY(turnoff_watchdog)

Review

Quoted 1 line
(quoted diff) +1 -0
+	ret

and at the end, add:
ENDPROC(turnoff_watchdog)

seems a lot of the nds32 code could use this fixup ...
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/d1c67bcf/attachment.pgp>

#10 lore raw

PATCH v2 2/4 nds32/ag102: add ag102 soc support

Hi Mike,

2011/11/30 Mike Frysinger <[email protected]>

Quoted 7 lines · On Tuesday 29 November 2011 04:15:05 Macpaul Lin wrote:
Quoted 2 lines

+.globl turnoff_watchdog
+turnoff_watchdog:

should be:
ENTRY(turnoff_watchdog)

Quoted 8 lines
Quoted 1 line

+ ret

and at the end, add:
ENDPROC(turnoff_watchdog)

seems a lot of the nds32 code could use this fixup ... -mike

Thanks for your suggestion, however, I'd like to confirm what is the benefits of
these kind of implementation? I know there are such code in Linux. One benefits might be alignment (marco ENDPROC), and the other looks like for coding style.

For supporting this kind of implementation, I must to put header support like linkage.h
from blackfin into nds32's common includes.
Currently I don't see other architecture support these kind of code. Would you like to make some comment in more detail and also suggest other custodians?
I think if this kind of implementation is good then it is worthy to be adopt to other architectures as well
just like Linux.

Thanks.

Signature · 2 lines
Best regards,
Macpaul Lin
#11 lore raw

PATCH v2 2/4 nds32/ag102: add ag102 soc support

Quoted 3 lines · On Tuesday 29 November 2011 23:32:27 Macpaul Lin wrote:

these kind of implementation? I know there are such code in Linux. One benefits might be alignment (marco ENDPROC), and the other looks like for coding style.

makes sure the visibility/alignment/ELF size is correct. for the last part, gdb won't know where the func ends without it and taking a best guess.

Quoted 2 lines

For supporting this kind of implementation, I must to put header support like linkage.h

err, i thought i saw u-boot had this in common code. seems it is not (i must have been looking in the Linux tree). don't worry about it until we get that addressed.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20111129/4c5b2789/attachment.pgp>

#12 lore raw

PATCH v2 2/4 nds32/ag102: add ag102 soc support

Hi Mike and Wolfgang,

2011/11/30 Mike Frysinger <[email protected]>

Quoted 10 lines
Quoted 2 lines

For supporting this kind of implementation, I must to put header support like linkage.h

err, i thought i saw u-boot had this in common code. seems it is not (i must
have been looking in the Linux tree). don't worry about it until we get that
addressed.
-mike

I think you can send a patch to move linkage.h to common headers at first, than we can move to this step by step.
I'll also fix this in these series of patches with manually added linkage.h to NDS32
architecture. Hope your can do this move sooner hence I do not need to send a commit
of adding linkage.h into NDS32. :-)

Thanks.

Signature · 2 lines
Best regards,
Macpaul Lin
#13 lore raw

PATCH v2 2/4 nds32/ag102: add ag102 soc support

Hi Mike,

2011/11/30 Macpaul Lin <[email protected]>

Quoted 17 lines

Hi Mike and Wolfgang,

2011/11/30 Mike Frysinger <[email protected]>

Quoted 10 lines
Quoted 2 lines

For supporting this kind of implementation, I must to put header support like linkage.h

err, i thought i saw u-boot had this in common code. seems it is not (i must
have been looking in the Linux tree). don't worry about it until we get that
addressed.
-mike

It seems the only architecture related part in this header are the following codes.
#define __ALIGN .align 4
#define __ALIGN_STR ".align 4"

In Linux, the common linkage.h will include only this part from architectures' local linkage.h.

I think we can put the common linkage.h in "include/linux" folder is okay.

Signature · 2 lines
Best regards,
Macpaul Lin
#14 lore raw

PATCH v2 2/4 nds32/ag102: add ag102 soc support

Hi Mike,

2011/11/30 Macpaul Lin <[email protected]>

Quoted 17 lines

Hi Mike,

err, i thought i saw u-boot had this in common code. seems it is not (i

Quoted 9 lines
Quoted 6 lines

must
have been looking in the Linux tree). don't worry about it until we get that
addressed.
-mike

It seems the only architecture related part in this header are the following codes.
#define __ALIGN .align 4
#define __ALIGN_STR ".align 4"

Quoted 6 lines

In Linux, the common linkage.h will include only this part from architectures' local linkage.h.

I think we can put the common linkage.h in "include/linux" folder is okay.

I have done this for blackfin also, but when I ran checkpatch to these patches, I've got several
warnings and it looks those warnings should not be problem at all. So I'll send these patches to you and hope you can run checkpatch, too and see if there are
something need to be fixed.

Thanks.

Signature · 2 lines
Best regards,
Macpaul Lin