[U-Boot] [RFC PATCH 0/5] avr32: add generic board

This is the first attempt to add generic board support to avr32 architecture. It has at least one relevant part for other manual reloc architectures.
This series is currently runtime tested on grasshhopper only. I expect some changes regarding LCD support when testing the code on atstk1002. The DMA stuff is not tested yet but I expect no serios things here. The code is not run through checkpatch nor buildman at the time of writing.
Comments welcome!
Especially for the TLB stuff placed in board_init_r.
Andreas Bießmann
Andreas Bießmann (5): avr32: use dlmalloc for DMA buffers avr32: rename cpu_init() -> arch_cpu_init() common/board_r: manual relocation for cmd table avr32: add generic board support grasshopper: enable generic board
arch/avr32/config.mk | 3 ++ arch/avr32/cpu/cpu.c | 2 +- arch/avr32/cpu/u-boot.lds | 2 ++ arch/avr32/include/asm/config.h | 1 + arch/avr32/include/asm/dma-mapping.h | 7 ++++- arch/avr32/include/asm/u-boot.h | 9 ++++++ arch/avr32/lib/Makefile | 2 ++ arch/avr32/lib/board.c | 53 +--------------------------------- arch/avr32/lib/interrupts.c | 5 ++++ common/board_f.c | 13 +++++++-- common/board_r.c | 34 ++++++++++++++++++++-- include/asm-generic/u-boot.h | 4 +++ include/configs/atngw100.h | 1 - include/configs/atngw100mkii.h | 1 - include/configs/atstk1002.h | 1 - include/configs/atstk1006.h | 1 - include/configs/favr-32-ezkit.h | 1 - include/configs/grasshopper.h | 5 +++- include/configs/hammerhead.h | 1 - include/configs/mimc200.h | 1 - 20 files changed, 80 insertions(+), 67 deletions(-)

Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com ---
arch/avr32/include/asm/dma-mapping.h | 7 ++++- arch/avr32/lib/board.c | 51 ---------------------------------- include/configs/atngw100.h | 1 - include/configs/atngw100mkii.h | 1 - include/configs/atstk1002.h | 1 - include/configs/atstk1006.h | 1 - include/configs/favr-32-ezkit.h | 1 - include/configs/grasshopper.h | 1 - include/configs/hammerhead.h | 1 - include/configs/mimc200.h | 1 - 10 files changed, 6 insertions(+), 60 deletions(-)
diff --git a/arch/avr32/include/asm/dma-mapping.h b/arch/avr32/include/asm/dma-mapping.h index dbdd2fe..1cde827 100644 --- a/arch/avr32/include/asm/dma-mapping.h +++ b/arch/avr32/include/asm/dma-mapping.h @@ -14,7 +14,12 @@ enum dma_data_direction { DMA_TO_DEVICE = 1, DMA_FROM_DEVICE = 2, }; -extern void *dma_alloc_coherent(size_t len, unsigned long *handle); + +static inline void *dma_alloc_coherent(size_t len, unsigned long *handle) +{ + *handle = (unsigned long)memalign(ARCH_DMA_MINALIGN, len); + return (void *)*handle; +}
static inline unsigned long dma_map_single(volatile void *vaddr, size_t len, enum dma_data_direction dir) diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c index bf0997f..7d13ac5 100644 --- a/arch/avr32/lib/board.c +++ b/arch/avr32/lib/board.c @@ -45,50 +45,6 @@ int cpu_mmc_init(bd_t *bd) return atmel_mci_init((void *)ATMEL_BASE_MMCI); }
-#ifdef CONFIG_SYS_DMA_ALLOC_LEN -#include <asm/arch/cacheflush.h> -#include <asm/io.h> - -static unsigned long dma_alloc_start; -static unsigned long dma_alloc_end; -static unsigned long dma_alloc_brk; - -static void dma_alloc_init(void) -{ - unsigned long monitor_addr; - - monitor_addr = CONFIG_SYS_MONITOR_BASE + gd->reloc_off; - dma_alloc_end = monitor_addr - CONFIG_SYS_MALLOC_LEN; - dma_alloc_start = dma_alloc_end - CONFIG_SYS_DMA_ALLOC_LEN; - dma_alloc_brk = dma_alloc_start; - - printf("DMA: Using memory from 0x%08lx to 0x%08lx\n", - dma_alloc_start, dma_alloc_end); - - invalidate_dcache_range((unsigned long)cached(dma_alloc_start), - dma_alloc_end); -} - -void *dma_alloc_coherent(size_t len, unsigned long *handle) -{ - unsigned long paddr = dma_alloc_brk; - - if (dma_alloc_brk + len > dma_alloc_end) - return NULL; - - dma_alloc_brk = ((paddr + len + CONFIG_SYS_DCACHE_LINESZ - 1) - & ~(CONFIG_SYS_DCACHE_LINESZ - 1)); - - *handle = paddr; - return uncached(paddr); -} -#else -static inline void dma_alloc_init(void) -{ - -} -#endif - static int init_baudrate(void) { gd->baudrate = getenv_ulong("baudrate", 10, CONFIG_BAUDRATE); @@ -180,12 +136,6 @@ void board_init_f(ulong board_type) /* Reserve memory for malloc() */ addr -= CONFIG_SYS_MALLOC_LEN;
-#ifdef CONFIG_SYS_DMA_ALLOC_LEN - /* Reserve DMA memory (must be cache aligned) */ - addr &= ~(CONFIG_SYS_DCACHE_LINESZ - 1); - addr -= CONFIG_SYS_DMA_ALLOC_LEN; -#endif - #ifdef CONFIG_LCD #ifdef CONFIG_FB_ADDR printf("LCD: Frame buffer allocated at preset 0x%08x\n", @@ -264,7 +214,6 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) /* The malloc area is right below the monitor image in RAM */ mem_malloc_init(CONFIG_SYS_MONITOR_BASE + gd->reloc_off - CONFIG_SYS_MALLOC_LEN, CONFIG_SYS_MALLOC_LEN); - dma_alloc_init();
enable_interrupts();
diff --git a/include/configs/atngw100.h b/include/configs/atngw100.h index 9c81e31..540e86a 100644 --- a/include/configs/atngw100.h +++ b/include/configs/atngw100.h @@ -143,7 +143,6 @@ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
#define CONFIG_SYS_MALLOC_LEN (256*1024) -#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000) diff --git a/include/configs/atngw100mkii.h b/include/configs/atngw100mkii.h index 7b4f9cf..35eae76 100644 --- a/include/configs/atngw100mkii.h +++ b/include/configs/atngw100mkii.h @@ -164,7 +164,6 @@ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
#define CONFIG_SYS_MALLOC_LEN (256*1024) -#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000) diff --git a/include/configs/atstk1002.h b/include/configs/atstk1002.h index 8f3fd0b..9e58238 100644 --- a/include/configs/atstk1002.h +++ b/include/configs/atstk1002.h @@ -158,7 +158,6 @@ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
#define CONFIG_SYS_MALLOC_LEN (256*1024) -#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000) diff --git a/include/configs/atstk1006.h b/include/configs/atstk1006.h index bbe0aea..25090a6 100644 --- a/include/configs/atstk1006.h +++ b/include/configs/atstk1006.h @@ -159,7 +159,6 @@ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
#define CONFIG_SYS_MALLOC_LEN (256*1024) -#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000) diff --git a/include/configs/favr-32-ezkit.h b/include/configs/favr-32-ezkit.h index 338d3dc..75bff4c 100644 --- a/include/configs/favr-32-ezkit.h +++ b/include/configs/favr-32-ezkit.h @@ -162,7 +162,6 @@ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
#define CONFIG_SYS_MALLOC_LEN (256*1024) -#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000) diff --git a/include/configs/grasshopper.h b/include/configs/grasshopper.h index 73534ad..83f0ed2 100644 --- a/include/configs/grasshopper.h +++ b/include/configs/grasshopper.h @@ -151,7 +151,6 @@ CONFIG_SYS_INTRAM_SIZE)
#define CONFIG_SYS_MALLOC_LEN (256*1024) -#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000) diff --git a/include/configs/hammerhead.h b/include/configs/hammerhead.h index 4f0603a..0bc42f1 100644 --- a/include/configs/hammerhead.h +++ b/include/configs/hammerhead.h @@ -137,7 +137,6 @@
#define CONFIG_SYS_MALLOC_LEN (256*1024)
-#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (CONFIG_SYS_SDRAM_BASE + 0x00400000) diff --git a/include/configs/mimc200.h b/include/configs/mimc200.h index fc7ecfa..2fd3add 100644 --- a/include/configs/mimc200.h +++ b/include/configs/mimc200.h @@ -157,7 +157,6 @@ #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_INTRAM_BASE + CONFIG_SYS_INTRAM_SIZE)
#define CONFIG_SYS_MALLOC_LEN (1024*1024) -#define CONFIG_SYS_DMA_ALLOC_LEN (16384)
/* Allow 4MB for the kernel run-time image */ #define CONFIG_SYS_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000)

Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com ---
arch/avr32/cpu/cpu.c | 2 +- arch/avr32/include/asm/u-boot.h | 2 ++ arch/avr32/lib/board.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/arch/avr32/cpu/cpu.c b/arch/avr32/cpu/cpu.c index cef630e..cd226a6 100644 --- a/arch/avr32/cpu/cpu.c +++ b/arch/avr32/cpu/cpu.c @@ -27,7 +27,7 @@
DECLARE_GLOBAL_DATA_PTR;
-int cpu_init(void) +int arch_cpu_init(void) { extern void _evba(void);
diff --git a/arch/avr32/include/asm/u-boot.h b/arch/avr32/include/asm/u-boot.h index 6aef808..2387f8a 100644 --- a/arch/avr32/include/asm/u-boot.h +++ b/arch/avr32/include/asm/u-boot.h @@ -25,4 +25,6 @@ typedef struct bd_info { /* For image.h:image_check_target_arch() */ #define IH_ARCH_DEFAULT IH_ARCH_AVR32
+int arch_cpu_init(void); + #endif /* __ASM_U_BOOT_H__ */ diff --git a/arch/avr32/lib/board.c b/arch/avr32/lib/board.c index 7d13ac5..95f9526 100644 --- a/arch/avr32/lib/board.c +++ b/arch/avr32/lib/board.c @@ -98,7 +98,7 @@ void board_init_f(ulong board_type)
/* Perform initialization sequence */ board_early_init_f(); - cpu_init(); + arch_cpu_init(); board_postclk_init(); env_init(); init_baudrate();

This is required for architectures still need manual relocation like avr32, mk68 and others.
Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com ---
common/board_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/common/board_r.c b/common/board_r.c index a301cc2..e712902 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -294,6 +294,15 @@ static int initr_announce(void) return 0; }
+#ifdef CONFIG_NEEDS_MANUAL_RELOC +static int initr_manual_reloc_cmdtable(void) +{ + fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd), + ll_entry_count(cmd_tbl_t, cmd)); + return 0; +} +#endif + #if !defined(CONFIG_SYS_NO_FLASH) static int initr_flash(void) { @@ -718,6 +727,9 @@ init_fnc_t init_sequence_r[] = { initr_serial, initr_announce, INIT_FUNC_WATCHDOG_RESET +#ifdef CONFIG_NEEDS_MANUAL_RELOC + initr_manual_reloc_cmdtable, +#endif #ifdef CONFIG_PPC initr_trap, #endif

Hi Andreas,
On 19 January 2015 at 16:29, Andreas Bießmann andreas.devel@googlemail.com wrote:
This is required for architectures still need manual relocation like avr32, mk68 and others.
Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com
common/board_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/common/board_r.c b/common/board_r.c index a301cc2..e712902 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -294,6 +294,15 @@ static int initr_announce(void) return 0; }
+#ifdef CONFIG_NEEDS_MANUAL_RELOC +static int initr_manual_reloc_cmdtable(void) +{
fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
ll_entry_count(cmd_tbl_t, cmd));
return 0;
+} +#endif
#if !defined(CONFIG_SYS_NO_FLASH) static int initr_flash(void) { @@ -718,6 +727,9 @@ init_fnc_t init_sequence_r[] = { initr_serial, initr_announce, INIT_FUNC_WATCHDOG_RESET +#ifdef CONFIG_NEEDS_MANUAL_RELOC
initr_manual_reloc_cmdtable,
+#endif #ifdef CONFIG_PPC initr_trap,
#endif
Reviewed-by: Simon Glass sjg@chromium.org
Why do you need manual reloc? Is this a toolchain bug?
Regards, Simon

Hi Simon,
On 20.01.15 00:34, Simon Glass wrote:
Hi Andreas,
On 19 January 2015 at 16:29, Andreas Bießmann andreas.devel@googlemail.com wrote:
This is required for architectures still need manual relocation like avr32, mk68 and others.
Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com
common/board_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/common/board_r.c b/common/board_r.c index a301cc2..e712902 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -294,6 +294,15 @@ static int initr_announce(void) return 0; }
+#ifdef CONFIG_NEEDS_MANUAL_RELOC +static int initr_manual_reloc_cmdtable(void) +{
fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
ll_entry_count(cmd_tbl_t, cmd));
return 0;
+} +#endif
#if !defined(CONFIG_SYS_NO_FLASH) static int initr_flash(void) { @@ -718,6 +727,9 @@ init_fnc_t init_sequence_r[] = { initr_serial, initr_announce, INIT_FUNC_WATCHDOG_RESET +#ifdef CONFIG_NEEDS_MANUAL_RELOC
initr_manual_reloc_cmdtable,
+#endif #ifdef CONFIG_PPC initr_trap,
#endif
Reviewed-by: Simon Glass sjg@chromium.org
Why do you need manual reloc? Is this a toolchain bug?
Just not implemented yet for avr32. It is on my list, but avr32 has not my highest priority ;) As long as there are other arches which need this also I think it is some more time to shift ... the generic board deadline end of 2014 was a bit stricter, I don't want to kick avr32 out of u-boot now. So let's get generic board working for avr32 in the next release ;)
Best regards
Andreas Bießmann

Hi Andreas,
On 19 January 2015 at 16:41, Andreas Bießmann andreas.devel@googlemail.com wrote:
Hi Simon,
On 20.01.15 00:34, Simon Glass wrote:
Hi Andreas,
On 19 January 2015 at 16:29, Andreas Bießmann andreas.devel@googlemail.com wrote:
This is required for architectures still need manual relocation like avr32, mk68 and others.
Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com
common/board_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/common/board_r.c b/common/board_r.c index a301cc2..e712902 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -294,6 +294,15 @@ static int initr_announce(void) return 0; }
+#ifdef CONFIG_NEEDS_MANUAL_RELOC +static int initr_manual_reloc_cmdtable(void) +{
fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
ll_entry_count(cmd_tbl_t, cmd));
return 0;
+} +#endif
#if !defined(CONFIG_SYS_NO_FLASH) static int initr_flash(void) { @@ -718,6 +727,9 @@ init_fnc_t init_sequence_r[] = { initr_serial, initr_announce, INIT_FUNC_WATCHDOG_RESET +#ifdef CONFIG_NEEDS_MANUAL_RELOC
initr_manual_reloc_cmdtable,
+#endif #ifdef CONFIG_PPC initr_trap,
#endif
Reviewed-by: Simon Glass sjg@chromium.org
Why do you need manual reloc? Is this a toolchain bug?
Just not implemented yet for avr32. It is on my list, but avr32 has not my highest priority ;) As long as there are other arches which need this also I think it is some more time to shift ... the generic board deadline end of 2014 was a bit stricter, I don't want to kick avr32 out of u-boot now. So let's get generic board working for avr32 in the next release ;)
OK - it would be good to tidy this up.
Regards, Simon

Hi Simon,
On Mon, 2015-01-19 at 16:34 -0700, Simon Glass wrote:
Hi Andreas,
Why do you need manual reloc? Is this a toolchain bug?
From my experience the only way to escape manual relocation is to use
PIE (Position Independent Executable), but this might not be supported in a toolchain for AVR (or it doesn't actually work good enough - this I understood from this message https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=574716)
-Alexey

2015-01-20 0:34 GMT+01:00 Simon Glass sjg@chromium.org:
Hi Andreas,
On 19 January 2015 at 16:29, Andreas Bießmann andreas.devel@googlemail.com wrote:
This is required for architectures still need manual relocation like
avr32, mk68
and others.
Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com
common/board_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)
diff --git a/common/board_r.c b/common/board_r.c index a301cc2..e712902 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -294,6 +294,15 @@ static int initr_announce(void) return 0; }
+#ifdef CONFIG_NEEDS_MANUAL_RELOC +static int initr_manual_reloc_cmdtable(void) +{
fixup_cmdtable(ll_entry_start(cmd_tbl_t, cmd),
ll_entry_count(cmd_tbl_t, cmd));
return 0;
+} +#endif
#if !defined(CONFIG_SYS_NO_FLASH) static int initr_flash(void) { @@ -718,6 +727,9 @@ init_fnc_t init_sequence_r[] = { initr_serial, initr_announce, INIT_FUNC_WATCHDOG_RESET +#ifdef CONFIG_NEEDS_MANUAL_RELOC
initr_manual_reloc_cmdtable,
+#endif #ifdef CONFIG_PPC initr_trap,
#endif
Reviewed-by: Simon Glass sjg@chromium.org
Tested-by: Michal Simek michal.simek@xilinx.com
I need this patch for microblaze generic-board support.
Thanks, Michal

Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com ---
arch/avr32/config.mk | 3 +++ arch/avr32/cpu/u-boot.lds | 2 ++ arch/avr32/include/asm/config.h | 1 + arch/avr32/include/asm/u-boot.h | 7 +++++++ arch/avr32/lib/Makefile | 2 ++ arch/avr32/lib/interrupts.c | 5 +++++ common/board_f.c | 13 ++++++++++--- common/board_r.c | 22 ++++++++++++++++++++-- include/asm-generic/u-boot.h | 4 ++++ 9 files changed, 54 insertions(+), 5 deletions(-)
diff --git a/arch/avr32/config.mk b/arch/avr32/config.mk index 469185e..8252f59 100644 --- a/arch/avr32/config.mk +++ b/arch/avr32/config.mk @@ -9,6 +9,9 @@ ifeq ($(CROSS_COMPILE),) CROSS_COMPILE := avr32-linux- endif
+# avr32 has generic board support +__HAVE_ARCH_GENERIC_BOARD := y + CONFIG_STANDALONE_LOAD_ADDR ?= 0x00000000
PLATFORM_RELFLAGS += -ffixed-r5 -fPIC -mno-init-got -mrelax diff --git a/arch/avr32/cpu/u-boot.lds b/arch/avr32/cpu/u-boot.lds index cb29a22..b0180e3 100644 --- a/arch/avr32/cpu/u-boot.lds +++ b/arch/avr32/cpu/u-boot.lds @@ -48,9 +48,11 @@ SECTIONS _edata = .;
.bss (NOLOAD) : { + __bss_start = .; *(.bss) *(.bss.*) } . = ALIGN(8); __bss_end = .; + __init_end = .; } diff --git a/arch/avr32/include/asm/config.h b/arch/avr32/include/asm/config.h index 63056a4..529fe22 100644 --- a/arch/avr32/include/asm/config.h +++ b/arch/avr32/include/asm/config.h @@ -8,5 +8,6 @@ #define _ASM_CONFIG_H_
#define CONFIG_NEEDS_MANUAL_RELOC +#define CONFIG_SYS_GENERIC_GLOBAL_DATA
#endif diff --git a/arch/avr32/include/asm/u-boot.h b/arch/avr32/include/asm/u-boot.h index 2387f8a..0f7dddd 100644 --- a/arch/avr32/include/asm/u-boot.h +++ b/arch/avr32/include/asm/u-boot.h @@ -6,6 +6,11 @@ #ifndef __ASM_U_BOOT_H__ #define __ASM_U_BOOT_H__ 1
+#ifdef CONFIG_SYS_GENERIC_BOARD +/* Use the generic board which requires a unified bd_info */ +#include <asm-generic/u-boot.h> +#else + typedef struct bd_info { unsigned char bi_phy_id[4]; unsigned long bi_board_number; @@ -22,6 +27,8 @@ typedef struct bd_info { #define bi_memstart bi_dram[0].start #define bi_memsize bi_dram[0].size
+#endif + /* For image.h:image_check_target_arch() */ #define IH_ARCH_DEFAULT IH_ARCH_AVR32
diff --git a/arch/avr32/lib/Makefile b/arch/avr32/lib/Makefile index bb45cbe..d5cb8b2 100644 --- a/arch/avr32/lib/Makefile +++ b/arch/avr32/lib/Makefile @@ -8,6 +8,8 @@ #
obj-y += memset.o +ifndef CONFIG_SYS_GENERIC_BOARD obj-y += board.o +endif obj-$(CONFIG_CMD_BOOTM) += bootm.o obj-y += interrupts.o diff --git a/arch/avr32/lib/interrupts.c b/arch/avr32/lib/interrupts.c index bacb2d1..5f3a49e 100644 --- a/arch/avr32/lib/interrupts.c +++ b/arch/avr32/lib/interrupts.c @@ -7,6 +7,11 @@
#include <asm/sysreg.h>
+int interrupt_init(void) +{ + return 0; +} + void enable_interrupts(void) { asm volatile("csrf %0" : : "n"(SYSREG_GM_OFFSET)); diff --git a/common/board_f.c b/common/board_f.c index 3a4b32c..b5eb81e 100644 --- a/common/board_f.c +++ b/common/board_f.c @@ -174,7 +174,7 @@ static int announce_dram_init(void) return 0; }
-#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) +#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_AVR32) static int init_func_ram(void) { #ifdef CONFIG_BOARD_TYPES @@ -268,6 +268,8 @@ static int setup_mon_len(void) gd->mon_len = (ulong)&_end - (ulong)_init; #elif defined(CONFIG_BLACKFIN) || defined(CONFIG_NIOS2) gd->mon_len = CONFIG_SYS_MONITOR_LEN; +#elif defined(CONFIG_AVR32) + gd->mon_len = (ulong)&__bss_end - (ulong)&_text; #else /* TODO: use (ulong)&__bss_end - (ulong)&__text_start; ? */ gd->mon_len = (ulong)&__bss_end - CONFIG_SYS_MONITOR_BASE; @@ -581,7 +583,7 @@ static int reserve_stacks(void) gd->irq_sp = gd->start_addr_sp; # endif #else -# ifdef CONFIG_PPC +# if defined(CONFIG_PPC) || defined(CONFIG_AVR32) ulong *s; # endif
@@ -611,6 +613,11 @@ static int reserve_stacks(void) s = (ulong *) gd->start_addr_sp; *s = 0; /* Terminate back chain */ *++s = 0; /* NULL return address */ +# elif defined(CONFIG_AVR32) + gd->arch.stack_end = gd->start_addr_sp; + s = (ulong *)gd->start_addr_sp; + *s = 0; + *--s = 0; # endif /* Architecture specific code */
return 0; @@ -906,7 +913,7 @@ static init_fnc_t init_sequence_f[] = { #if defined(CONFIG_ARM) || defined(CONFIG_X86) dram_init, /* configure available RAM banks */ #endif -#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) +#if defined(CONFIG_MIPS) || defined(CONFIG_PPC) || defined(CONFIG_AVR32) init_func_ram, #endif #ifdef CONFIG_POST diff --git a/common/board_r.c b/common/board_r.c index e712902..4d2000d 100644 --- a/common/board_r.c +++ b/common/board_r.c @@ -459,6 +459,16 @@ static int initr_env(void) return 0; }
+#ifdef CONFIG_SYS_BOOTPARAMS_LEN +static int initr_malloc_bootparams(void) +{ + gd->bd->bi_boot_params = (ulong)malloc(CONFIG_SYS_BOOTPARAMS_LEN); + if (!gd->bd->bi_boot_params) + puts("WARNING: Cannot allocate space for boot parameters\n"); + return 0; +} +#endif + #ifdef CONFIG_SC3 /* TODO: with new initcalls, move this into the driver */ extern void sc3_read_eeprom(void); @@ -502,7 +512,7 @@ static int show_model_r(void) #endif
/* enable exceptions */ -#ifdef CONFIG_ARM +#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) static int initr_enable_interrupts(void) { enable_interrupts(); @@ -791,6 +801,9 @@ init_fnc_t init_sequence_r[] = { initr_dataflash, #endif initr_env, +#ifdef CONFIG_SYS_BOOTPARAMS_LEN + initr_malloc_bootparams, +#endif INIT_FUNC_WATCHDOG_RESET initr_secondary_cpu, #ifdef CONFIG_SC3 @@ -826,7 +839,7 @@ init_fnc_t init_sequence_r[] = { initr_kgdb, #endif interrupt_init, -#if defined(CONFIG_ARM) +#if defined(CONFIG_ARM) || defined(CONFIG_AVR32) initr_enable_interrupts, #endif #ifdef CONFIG_X86 @@ -894,6 +907,11 @@ void board_init_r(gd_t *new_gd, ulong dest_addr) int i; #endif
+#ifdef CONFIG_AVR32 + extern void mmu_init_r(unsigned long); + mmu_init_r(dest_addr); +#endif + #if !defined(CONFIG_X86) && !defined(CONFIG_ARM) && !defined(CONFIG_ARM64) gd = new_gd; #endif diff --git a/include/asm-generic/u-boot.h b/include/asm-generic/u-boot.h index aef39d7..a63a87a 100644 --- a/include/asm-generic/u-boot.h +++ b/include/asm-generic/u-boot.h @@ -32,6 +32,10 @@ typedef struct bd_info { unsigned long bi_flashoffset; /* reserved area for startup monitor */ unsigned long bi_sramstart; /* start of SRAM memory */ unsigned long bi_sramsize; /* size of SRAM memory */ +#ifdef CONFIG_AVR32 + unsigned char bi_phy_id[4]; /* PHY address for ATAG_ETHERNET */ + unsigned long bi_board_number;/* ATAG_BOARDINFO */ +#endif #ifdef CONFIG_ARM unsigned long bi_arm_freq; /* arm frequency */ unsigned long bi_dsp_freq; /* dsp core frequency */

Signed-off-by: Andreas Bießmann andreas.devel@googlemail.com ---
include/configs/grasshopper.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/include/configs/grasshopper.h b/include/configs/grasshopper.h index 83f0ed2..54eb977 100644 --- a/include/configs/grasshopper.h +++ b/include/configs/grasshopper.h @@ -62,6 +62,10 @@ #define CONFIG_USART_BASE ATMEL_BASE_USART1 #define CONFIG_USART_ID 1
+#define CONFIG_SYS_GENERIC_BOARD +#define CONFIG_BOARD_EARLY_INIT_F +#define CONFIG_BOARD_EARLY_INIT_R + /* User serviceable stuff */ #define CONFIG_CMDLINE_TAG #define CONFIG_SETUP_MEMORY_TAGS

On 01/20/2015 12:29 AM, Andreas Bießmann wrote:
This is the first attempt to add generic board support to avr32 architecture. It has at least one relevant part for other manual reloc architectures.
This series is currently runtime tested on grasshhopper only. I expect some changes regarding LCD support when testing the code on atstk1002. The DMA stuff is not tested yet but I expect no serios things here. The code is not run through checkpatch nor buildman at the time of writing.
It seems MMC is not working properly yet!
participants (4)
-
Alexey Brodkin
-
Andreas Bießmann
-
Michal Simek
-
Simon Glass