avr32 patches for 1.3.4
Subsystems (2)
cover avr32 patches for 1.3.4
The 18 patches posted as followups to this mail are avr32-related changes I intend to get merged before the end of this merge window. Please review -- I'm going to push all of it into master in a couple of days unless I hear any complaints.
Note to any out-of-tree board maintainers: You need to pay special attention to patches 5 and 12 and update your linker script the same way as is done for ATSTK1000 and ATNGW100. Basically you need to
* Add "*(.exception.text)" to the beginning of the .text section
* Remove everything related to the .flashprog section
You can try out everything by pulling the "for-1.3.4" branch of
git://git.denx.de/u-boot-avr32.git for-1.3.4
Shortlog and diffstat for the whole series follows. David Brownell (2):
avr32: stk1002 and ngw100 convergence
avr32: Disable the AP7000 internal watchdog on startup
Haavard Skinnemoen (16):
avr32: Use correct condition around macb clock accessors
avr32: Remove unneeded .flashprog section from NGW100 ldscript
avr32: Get rid of the .flashprog section
avr32: Add support for the ATSTK1006 board
avr32: Clean up the HMATRIX code
avr32: Remove unused file cpu/at32ap/pm.c
avr32: Use new-style Makefile for the at32ap platform
avr32: Rename pm_init() as clk_init() and make SoC-specific
avr32: Put memset in its own section
avr32: Use the same entry point for reset and exception handling
avr32: Do stricter stack checking in the exception handler
avr32: Rework SDRAM initialization code
atmel_usart: Support fractional baud rate dividers
avr32: Fix two warnings in atmel_mci.c
avr32: Fix wrong error flags in atmel_mci driver
avr32: Compile atmel_mci.o conditionally
MAINTAINERS | 1 +
MAKEALL | 1 +
Makefile | 3 +
board/atmel/atngw100/atngw100.c | 27 ++-
board/atmel/atngw100/u-boot.lds | 9 +-
board/atmel/atstk1000/atstk1000.c | 54 +++++-
board/atmel/atstk1000/flash.c | 6 +-
board/atmel/atstk1000/u-boot.lds | 9 +-
cpu/at32ap/Makefile | 20 ++-
cpu/at32ap/at32ap700x/Makefile | 2 +-
cpu/at32ap/at32ap700x/clk.c | 68 +++++++
cpu/at32ap/{ => at32ap700x}/sm.h | 0
cpu/at32ap/atmel_mci.c | 12 +-
cpu/at32ap/cpu.c | 50 +-----
cpu/at32ap/entry.S | 64 -------
cpu/at32ap/exception.c | 3 +-
cpu/at32ap/hsdramc.c | 102 ++++-------
cpu/at32ap/pm.c | 42 -----
cpu/at32ap/start.S | 129 ++++++++++++-
drivers/serial/atmel_usart.c | 14 ++-
drivers/serial/atmel_usart.h | 2 +
include/asm-avr32/arch-at32ap700x/clk.h | 4 +-
include/asm-avr32/arch-at32ap700x/hmatrix.h | 61 ++++++
include/asm-avr32/arch-at32ap700x/hmatrix2.h | 232 ------------------------
include/asm-avr32/arch-at32ap700x/memory-map.h | 20 ++
include/asm-avr32/hmatrix-common.h | 131 +++++++++++++
include/asm-avr32/sdram.h | 27 +++-
include/asm-avr32/sections.h | 7 -
include/configs/atngw100.h | 26 +--
include/configs/atstk1002.h | 19 +-
include/configs/atstk1003.h | 15 +-
include/configs/atstk1004.h | 16 +-
include/configs/{atstk1002.h => atstk1006.h} | 21 +-
lib_avr32/memset.S | 2 +-
34 files changed, 632 insertions(+), 567 deletions(-)
create mode 100644 cpu/at32ap/at32ap700x/clk.c
rename cpu/at32ap/{ => at32ap700x}/sm.h (100%)
delete mode 100644 cpu/at32ap/entry.S
delete mode 100644 cpu/at32ap/pm.c
create mode 100644 include/asm-avr32/arch-at32ap700x/hmatrix.h
delete mode 100644 include/asm-avr32/arch-at32ap700x/hmatrix2.h
create mode 100644 include/asm-avr32/hmatrix-common.h
copy include/configs/{atstk1002.h => atstk1006.h} (92%)PATCH 1/18 avr32: stk1002 and ngw100 convergence
From: David Brownell <[email protected]>
Make STK1002 and NGW100 boards act more alike:
- STK boards can use as many arguments as NGW
- STK boards don't need to manage FPGAs either
- NGW commands should match STK ones
Also spell U-Boot right in prompts for STK1002 and NGW100.
--- include/configs/atngw100.h | 5 ++++- include/configs/atstk1002.h | 6 +++--- include/configs/atstk1003.h | 2 +- include/configs/atstk1004.h | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-)
include/configs/atngw100.h +4 -1
@@ -112,8 +112,11 @@#define CONFIG_CMD_FAT #define CONFIG_CMD_JFFS2 #define CONFIG_CMD_MMC + +#undef CONFIG_CMD_AUTOSCRIPT#undef CONFIG_CMD_FPGA#undef CONFIG_CMD_SETGETDCR +#undef CONFIG_CMD_XIMG#define CONFIG_ATMEL_USART 1#define CONFIG_MACB 1
@@ -164,7 +167,7 @@#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */ -#define CFG_PROMPT "Uboot> " +#define CFG_PROMPT "U-Boot> "#define CFG_CBSIZE 256#define CFG_MAXARGS 16#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)
include/configs/atstk1002.h +3 -3
@@ -139,9 +139,9 @@#define CONFIG_CMD_FAT #define CONFIG_CMD_JFFS2 #define CONFIG_CMD_MMC -#define CONFIG_CMD_REGINFO #undef CONFIG_CMD_AUTOSCRIPT +#undef CONFIG_CMD_FPGA#undef CONFIG_CMD_SETGETDCR#undef CONFIG_CMD_XIMG
@@ -189,9 +189,9 @@#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */ -#define CFG_PROMPT "Uboot> " +#define CFG_PROMPT "U-Boot> "#define CFG_CBSIZE 256 -#define CFG_MAXARGS 8 +#define CFG_MAXARGS 16#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)#define CFG_LONGHELP 1
include/configs/atstk1003.h +1 -1
@@ -171,7 +171,7 @@#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */ -#define CFG_PROMPT "Uboot> " +#define CFG_PROMPT "U-Boot> "#define CFG_CBSIZE 256#define CFG_MAXARGS 16#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)
include/configs/atstk1004.h +1 -1
@@ -172,7 +172,7 @@#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */ -#define CFG_PROMPT "Uboot> " +#define CFG_PROMPT "U-Boot> "#define CFG_CBSIZE 256#define CFG_MAXARGS 16#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)
Signature · 1 line
1.5.5.1
PATCH 2/18 avr32: Disable the AP7000 internal watchdog on startup
From: David Brownell <[email protected]>
This patch forces the watchdog off in all cases. That will at least get rid of the constant reboot cycle, though it won't let the watchdog actually run in the new kernels: its probe() comes up with a polite warning.
--- cpu/at32ap/cpu.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-)
cpu/at32ap/cpu.c +4 -0
@@ -86,6 +86,10 @@ int cpu_init(void)extern void _evba (void );char *p; +/* in case of soft resets, disable watchdog */ +sm_writel (WDT_CTRL ,SM_BF (KEY ,0x55 )); +sm_writel (WDT_CTRL ,SM_BF (KEY ,0xaa )); + gd->cpu_hz =CFG_OSC0_HZ ;/* TODO: Move somewhere else, but needs to be run before we
Signature · 1 line
1.5.5.1
PATCH 3/18 avr32: Use correct condition around macb clock accessors
get_macb_pclk_rate() and get_macb_hclk_rate() should be available when the chip has a MACB controller, not when it has a USART.
--- include/asm-avr32/arch-at32ap700x/clk.h | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
include/asm-avr32/arch-at32ap700x/clk.h +1 -1
@@ -58,7 +58,7 @@ static inline unsigned long get_usart_clk_rate(unsigned int dev_id)return get_pba_clk_rate (); }#endif -#ifdef AT32AP700x_CHIP_HAS_USART +#ifdef AT32AP700x_CHIP_HAS_MACBstatic inline unsigned long get_macb_pclk_rate (unsigned int dev_id) {return get_pbb_clk_rate ();
Signature · 1 line
1.5.5.1
PATCH 4/18 avr32: Remove unneeded .flashprog section from NGW100 ldscript
The .flashprog section was only needed back when we were running directly from flash, and it's even more useless on NGW100 since it uses the CFI flash driver which never used this workaround in the first place.
--- board/atmel/atngw100/u-boot.lds | 8 -------- 1 files changed, 0 insertions(+), 8 deletions(-)
board/atmel/atngw100/u-boot.lds +0 -8
@@ -32,14 +32,6 @@ SECTIONS *(.text) *(.text.*) } - - . = ALIGN(32); - __flashprog_start = .; - .flashprog : { - *(.flashprog) - } - . = ALIGN(32); - __flashprog_end = .; _etext = .; .rodata : {
Signature · 1 line
1.5.5.1
PATCH 5/18 avr32: Get rid of the .flashprog section
The .flashprog section was only needed back when we were running directly from flash. Remove it on STK1000, and get rid of all the associated code and annotations.
--- board/atmel/atstk1000/flash.c | 6 +++--- board/atmel/atstk1000/u-boot.lds | 8 -------- cpu/at32ap/cpu.c | 6 ------ include/asm-avr32/sections.h | 7 ------- 4 files changed, 3 insertions(+), 24 deletions(-)
board/atmel/atstk1000/flash.c +3 -3
@@ -30,7 +30,7 @@ DECLARE_GLOBAL_DATA_PTR;flash_info_t flash_info[1 ]; -static void __flashprog flash_identify(uint16_t *flash, flash_info_t *info) +static void flash_identify (uint16_t *flash,flash_info_t *info) {unsigned long flags;
@@ -76,7 +76,7 @@ void flash_print_info(flash_info_t *info) info->size >> 10, info->sector_count); } -int __flashprog flash_erase(flash_info_t *info, int s_first, int s_last) +int flash_erase (flash_info_t *info,int s_first,int s_last) {unsigned long flags;unsigned long start_time;
@@ -154,7 +154,7 @@ int __flashprog flash_erase(flash_info_t *info, int s_first, int s_last)return ERR_OK ; } -int __flashprog write_buff(flash_info_t *info, uchar *src, +int write_buff (flash_info_t *info,uchar *src,ulong addr,ulong count) {unsigned long flags;
board/atmel/atstk1000/u-boot.lds +0 -8
@@ -32,14 +32,6 @@ SECTIONS *(.text) *(.text.*) } - - . = ALIGN(32); - __flashprog_start = .; - .flashprog : { - *(.flashprog) - } - . = ALIGN(32); - __flashprog_end = .; _etext = .; .rodata : {
cpu/at32ap/cpu.c +0 -6
@@ -84,7 +84,6 @@ static void pm_init(void)int cpu_init (void ) {extern void _evba (void ); -char *p;/* in case of soft resets, disable watchdog */ sm_writel (WDT_CTRL ,SM_BF (KEY ,0x55 ));
@@ -104,11 +103,6 @@ int cpu_init(void)sysreg_write (EVBA , (unsigned long )&_evba); asmvolatile ("csrf %0" : :"i" (SYSREG_EM_OFFSET )); -/* Lock everything that mess with the flash in the icache */ -for (p = __flashprog_start; p <= (__flashprog_end +CFG_ICACHE_LINESZ ); - p +=CFG_ICACHE_LINESZ ) - asmvolatile ("cache %0, 0x02" :"=m" (*p) ::"memory" ); -return 0 ; }
include/asm-avr32/sections.h +0 -7
@@ -25,15 +25,8 @@/* References to section boundaries */ extern char _text[], _etext[]; -extern char __flashprog_start[], __flashprog_end[];extern char _data[], __data_lma[], _edata[], __edata_lma[];extern char __got_start[], __got_lma[], __got_end[];extern char _end[]; -/* -* Everything in .flashprog will be locked in the icache so it doesn't -* get disturbed when executing flash commands. -*/ -#define __flashprog __attribute__((section(".flashprog"), __noinline__)) -#endif /* __ASM_AVR32_SECTIONS_H */
Signature · 1 line
1.5.5.1
PATCH 6/18 avr32: Add support for the ATSTK1006 board
This is a replacement for ATSTK1002 with 64MB SDRAM and NAND flash on board. It's currently in production and will be available soon.
--- MAINTAINERS | 1 + MAKEALL | 1 + Makefile | 3 + board/atmel/atstk1000/atstk1000.c | 20 ++++ include/configs/atstk1006.h | 202 +++++++++++++++++++++++++++++++++++++ 5 files changed, 227 insertions(+), 0 deletions(-) create mode 100644 include/configs/atstk1006.h
MAINTAINERS +1 -0
@@ -695,6 +695,7 @@ Haavard Skinnemoen <[email protected]> ATSTK1002 AT32AP7000 ATSTK1003 AT32AP7001 ATSTK1004 AT32AP7002 + ATSTK1006 AT32AP7000 ATNGW100 AT32AP7000 #########################################################################
MAKEALL +1 -0
@@ -697,6 +697,7 @@ LIST_avr32=" \ atstk1002 \ atstk1003 \ atstk1004 \ + atstk1006 \ atngw100 \ "
Makefile +3 -0
@@ -2879,6 +2879,9 @@ atstk1003_config : unconfig atstk1004_config : unconfig @$(MKCONFIG) $(@:_config=) avr32 at32ap atstk1000 atmel at32ap700x +atstk1006_config : unconfig + @$(MKCONFIG) $(@:_config=) avr32 at32ap atstk1000 atmel at32ap700x + atngw100_config : unconfig @$(MKCONFIG) $(@:_config=) avr32 at32ap atngw100 atmel at32ap700x
board/atmel/atstk1000/atstk1000.c +20 -0
@@ -29,6 +29,25 @@DECLARE_GLOBAL_DATA_PTR ; +#ifdef CONFIG_ATSTK1006 +/* Dual MT48LC16M16A2-7E on daughterboard */ +static const struct sdram_info sdram = { + .phys_addr =CFG_SDRAM_BASE , + .row_bits =13 , + .col_bits =9 , + .bank_bits =2 , + .cas =2 , + .twr =2 , + .trc =7 , + .trp =2 , + .trcd =2 , + .tras =4 , + .txsr =7 , +/* 7.81 us */ + .refresh_period = (781 * (SDRAMC_BUS_HZ /1000 )) /100000 , +}; +#else +/* MT48LC2M32B2-5 on motherboard */ static const struct sdram_info sdram = { .phys_addr =CFG_SDRAM_BASE , .row_bits = 11,
@@ -44,6 +63,7 @@ static const struct sdram_info sdram = {/* 15.6 us */ .refresh_period = (156 * (SDRAMC_BUS_HZ / 1000)) / 10000, }; +#endif int board_early_init_f (void ) {
include/configs/atstk1006.h new file +202 -0
202 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 7/18 avr32: Clean up the HMATRIX code
Rework the HMATRIX configuration interface so that it becomes easier to configure the HMATRIX for boards with special needs, and add new parts.
The HMATRIX header file has been split into a general, chip-independent part with register definitions, etc. and a chip-specific part with SFR bitfield definitions and master/slave identifiers.
--- board/atmel/atngw100/atngw100.c | 6 +- board/atmel/atstk1000/atstk1000.c | 6 +- include/asm-avr32/arch-at32ap700x/hmatrix.h | 61 +++++++ include/asm-avr32/arch-at32ap700x/hmatrix2.h | 232 -------------------------- include/asm-avr32/hmatrix-common.h | 131 +++++++++++++++ 5 files changed, 198 insertions(+), 238 deletions(-) create mode 100644 include/asm-avr32/arch-at32ap700x/hmatrix.h delete mode 100644 include/asm-avr32/arch-at32ap700x/hmatrix2.h create mode 100644 include/asm-avr32/hmatrix-common.h
board/atmel/atngw100/atngw100.c +3 -3
@@ -25,7 +25,7 @@#include <asm/sdram.h> #include <asm/arch/clk.h> #include <asm/arch/gpio.h> -#include <asm/arch/hmatrix2.h> +#include <asm/arch/hmatrix.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -47,8 +47,8 @@ static const struct sdram_info sdram = {int board_early_init_f (void ) { -/* Set the SDRAM_ENABLE bit in the HEBI SFR */ -hmatrix2_writel (SFR4 ,1 <<1 ); +/* Enable SDRAM in the EBI mux */ +hmatrix_slave_write (EBI ,SFR ,HMATRIX_BIT (EBI_SDRAM_ENABLE ));gpio_enable_ebi ();gpio_enable_usart1 ();
board/atmel/atstk1000/atstk1000.c +3 -3
@@ -25,7 +25,7 @@#include <asm/sdram.h> #include <asm/arch/clk.h> #include <asm/arch/gpio.h> -#include <asm/arch/hmatrix2.h> +#include <asm/arch/hmatrix.h> DECLARE_GLOBAL_DATA_PTR ;
@@ -67,8 +67,8 @@ static const struct sdram_info sdram = {int board_early_init_f (void ) { -/* Set the SDRAM_ENABLE bit in the HEBI SFR */ -hmatrix2_writel (SFR4 ,1 <<1 ); +/* Enable SDRAM in the EBI mux */ +hmatrix_slave_write (EBI ,SFR ,HMATRIX_BIT (EBI_SDRAM_ENABLE ));gpio_enable_ebi ();gpio_enable_usart1 ();
include/asm-avr32/arch-at32ap700x/hmatrix.h new file +61 -0
61 lines not on this page · raw message
include/asm-avr32/arch-at32ap700x/hmatrix2.h deleted +0 -232
232 lines not on this page · raw message
include/asm-avr32/hmatrix-common.h new file +131 -0
131 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 8/18 avr32: Remove unused file cpu/at32ap/pm.c
--- cpu/at32ap/pm.c | 42 ------------------------------------------ 1 files changed, 0 insertions(+), 42 deletions(-) delete mode 100644 cpu/at32ap/pm.c
cpu/at32ap/pm.c deleted +0 -42
@@ -1,42 +0,0 @@ -/* -* Copyright (C) 2006 Atmel Corporation -* -* 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 <common.h> - -#ifdef CFG_POWER_MANAGER -#include <asm/errno.h> -#include <asm/io.h> - -#include <asm/arch/memory-map.h> - -#include "sm.h" - - -#ifdef CONFIG_PLL -#define MAIN_CLK_RATE ((CFG_OSC0_HZ / CFG_PLL0_DIV) * CFG_PLL0_MUL) -#else -#define MAIN_CLK_RATE (CFG_OSC0_HZ) -#endif - -DECLARE_GLOBAL_DATA_PTR ; - - -#endif /* CFG_POWER_MANAGER */
Signature · 1 line
1.5.5.1
PATCH 9/18 avr32: Use new-style Makefile for the at32ap platform
This makes it easier to avoid compiling certain files later.
--- cpu/at32ap/Makefile | 21 ++++++++++++++------- 1 files changed, 14 insertions(+), 7 deletions(-)
cpu/at32ap/Makefile +14 -7
@@ -27,13 +27,20 @@ include $(TOPDIR)/config.mk LIB := $(obj)lib$(CPU).a -START := start.o -SOBJS := entry.o -COBJS := cpu.o hsdramc.o exception.o cache.o -COBJS += interrupts.o pio.o atmel_mci.o -SRCS := $(START:.o=.S) $(SOBJS:.o=.S) $(COBJS:.o=.c) -OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS)) -START := $(addprefix $(obj),$(START)) +START-y += start.o + +SOBJS-y += entry.o +COBJS-y += cpu.o +COBJS-y += hsdramc.o +COBJS-y += exception.o +COBJS-y += cache.o +COBJS-y += interrupts.o +COBJS-y += pio.o +COBJS-y += atmel_mci.o + +SRCS := $(START-y:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) +OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y)) +START := $(addprefix $(obj),$(START-y)) all: $(obj).depend $(START) $(LIB)
Signature · 1 line
1.5.5.1
PATCH 10/18 avr32: Rename pm_init() as clk_init() and make SoC-specific
pm_init() was always more about clock initialization than anything else. Dealing with PLLs, clock gating and such is also inherently SoC-specific, so move it into a SoC-specific directory.
---
cpu/at32ap/at32ap700x/Makefile | 2 +-
cpu/at32ap/at32ap700x/clk.c | 68 +++++++++++++++++++++++++++++++
cpu/at32ap/{ => at32ap700x}/sm.h | 0
cpu/at32ap/cpu.c | 48 ++-------------------
include/asm-avr32/arch-at32ap700x/clk.h | 2 +
5 files changed, 76 insertions(+), 44 deletions(-)
create mode 100644 cpu/at32ap/at32ap700x/clk.c
rename cpu/at32ap/{ => at32ap700x}/sm.h (100%)cpu/at32ap/at32ap700x/Makefile +1 -1
@@ -24,7 +24,7 @@ include $(TOPDIR)/config.mk LIB := $(obj)lib$(SOC).a -COBJS := gpio.o +COBJS := gpio.o clk.o SRCS := $(SOBJS:.o=.S) $(COBJS:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS) $(COBJS))
cpu/at32ap/at32ap700x/clk.c new file +68 -0
68 lines not on this page · raw message
cpu/at32ap/at32ap700x/sm.h renamed from cpu/at32ap/sm.h +0 -0
cpu/at32ap/cpu.c +5 -43
71 lines not on this page · raw message
include/asm-avr32/arch-at32ap700x/clk.h +2 -0
@@ -75,6 +75,8 @@ static inline unsigned long get_mci_clk_rate(void) }#endif +extern void clk_init (void ); +/* Board code may need the SDRAM base clock as a compile-time constant */ #define SDRAMC_BUS_HZ (MAIN_CLK_RATE >> CFG_CLKDIV_HSB)
Signature · 1 line
1.5.5.1
PATCH 11/18 avr32: Put memset in its own section
All C code is compiled with -ffunction-sections -fdata-sections. Assembly functions should get their own sections as well so that everything looks consistent.
--- lib_avr32/memset.S | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
lib_avr32/memset.S +1 -1
@@ -27,7 +27,7 @@ * * Returns b in r12 */ - .text + .section .text.memset, "ax", @progbits .global memset .type memset, @function
Signature · 1 line
1.5.5.1
PATCH 12/18 avr32: Use the same entry point for reset and exception handling
Since the reset vector is always aligned to a very large boundary, we can save a couple of KB worth of alignment padding by placing the exception vectors at the same address.
Deciding which one it is is easy: If we're handling an exception, the CPU is in Exception mode. If we're starting up after reset, the CPU is in Supervisor mode. So this adds a very minimal overhead to the reset path (only executed once) and the exception handling path (normally never executed at all.)
--- board/atmel/atngw100/u-boot.lds | 1 + board/atmel/atstk1000/u-boot.lds | 1 + cpu/at32ap/Makefile | 1 - cpu/at32ap/entry.S | 64 ------------------- cpu/at32ap/start.S | 129 +++++++++++++++++++++++++++++++++++--- 5 files changed, 122 insertions(+), 74 deletions(-) delete mode 100644 cpu/at32ap/entry.S
board/atmel/atngw100/u-boot.lds +1 -0
@@ -29,6 +29,7 @@ SECTIONS . = 0; _text = .; .text : { + *(.exception.text) *(.text) *(.text.*) }
board/atmel/atstk1000/u-boot.lds +1 -0
@@ -29,6 +29,7 @@ SECTIONS . = 0; _text = .; .text : { + *(.exception.text) *(.text) *(.text.*) }
cpu/at32ap/Makefile +0 -1
@@ -29,7 +29,6 @@ LIB := $(obj)lib$(CPU).a START-y += start.o -SOBJS-y += entry.o COBJS-y += cpu.o COBJS-y += hsdramc.o COBJS-y += exception.o
cpu/at32ap/entry.S deleted +0 -64
64 lines not on this page · raw message
cpu/at32ap/start.S +120 -9
166 lines not on this page · raw message
Signature · 1 line
1.5.5.1
PATCH 13/18 avr32: Do stricter stack checking in the exception handler
Don't do a stack dump if the stack pointer is outside the memory area reserved for stack.
--- cpu/at32ap/exception.c | 3 ++- 1 files changed, 2 insertions(+), 1 deletions(-)
cpu/at32ap/exception.c +2 -1
@@ -111,7 +111,8 @@ void do_unknown_exception(unsigned int ecr, struct pt_regs *regs)printf ("CPU Mode: %s\n" , cpu_modes[mode]);/* Avoid exception loops */ -if (regs->sp <CFG_SDRAM_BASE || regs->sp >= gd->stack_end) +if (regs->sp < (gd->stack_end -CONFIG_STACKSIZE ) + || regs->sp >= gd->stack_end)printf ("\nStack pointer seems bogus, won't do stack dump\n" );else dump_mem ("\nStack: " , regs->sp, gd->stack_end);
Signature · 1 line
1.5.5.1
PATCH 14/18 avr32: Rework SDRAM initialization code
This cleans up the SDRAM initialization and related code a bit, and allows faster booting.
* Add definitions for EBI and internal SRAM to asm/arch/memory-map.h
* Remove memory test from sdram_init() and make caller responsible for verifying the SDRAM and determining its size.
* Remove base_address member from struct sdram_config (was sdram_info)
* Add data_bits member to struct sdram_config and kill CFG_SDRAM_16BIT
* Add support for a common STK1000 hack: 16MB SDRAM instead of 8.
--- board/atmel/atngw100/atngw100.c | 21 ++++- board/atmel/atstk1000/atstk1000.c | 42 ++++++++--- cpu/at32ap/hsdramc.c | 102 +++++++++--------------- include/asm-avr32/arch-at32ap700x/memory-map.h | 20 +++++ include/asm-avr32/sdram.h | 27 +++++- include/configs/atngw100.h | 21 ++--- include/configs/atstk1002.h | 13 ++-- include/configs/atstk1003.h | 13 ++-- include/configs/atstk1004.h | 14 ++-- include/configs/atstk1006.h | 13 ++-- 10 files changed, 166 insertions(+), 120 deletions(-)
board/atmel/atngw100/atngw100.c +18 -3
@@ -29,8 +29,8 @@DECLARE_GLOBAL_DATA_PTR ; -static const struct sdram_info sdram = { - .phys_addr =CFG_SDRAM_BASE , +static const struct sdram_config sdram_config = { + .data_bits =SDRAM_DATA_16BIT , .row_bits =13 , .col_bits =9 , .bank_bits =2 ,
@@ -66,7 +66,22 @@ int board_early_init_f(void)long int initdram (int board_type) { -return sdram_init (&sdram); +unsigned long expected_size; +unsigned long actual_size; +void *sdram_base; + + sdram_base =map_physmem (EBI_SDRAM_BASE ,EBI_SDRAM_SIZE ,MAP_NOCACHE ); + + expected_size =sdram_init (sdram_base, &sdram_config); + actual_size =get_ram_size (sdram_base, expected_size); + +unmap_physmem (sdram_base,EBI_SDRAM_SIZE ); + +if (expected_size != actual_size) +printf ("Warning: Only %u of %u MiB SDRAM is working\n" , + actual_size >>20 , expected_size >>20 ); + +return actual_size; }void board_init_info (void )
board/atmel/atstk1000/atstk1000.c +32 -10
69 lines not on this page · raw message
cpu/at32ap/hsdramc.c +39 -63
143 lines not on this page · raw message
include/asm-avr32/arch-at32ap700x/memory-map.h +20 -0
@@ -22,6 +22,26 @@#ifndef __AT32AP7000_MEMORY_MAP_H__#define __AT32AP7000_MEMORY_MAP_H__ +/* Internal and external memories */ +#define EBI_SRAM_CS0_BASE 0x00000000 +#define EBI_SRAM_CS0_SIZE 0x04000000 +#define EBI_SRAM_CS4_BASE 0x04000000 +#define EBI_SRAM_CS4_SIZE 0x04000000 +#define EBI_SRAM_CS2_BASE 0x08000000 +#define EBI_SRAM_CS2_SIZE 0x04000000 +#define EBI_SRAM_CS3_BASE 0x0c000000 +#define EBI_SRAM_CS3_SIZE 0x04000000 +#define EBI_SRAM_CS1_BASE 0x10000000 +#define EBI_SRAM_CS1_SIZE 0x10000000 +#define EBI_SRAM_CS5_BASE 0x20000000 +#define EBI_SRAM_CS5_SIZE 0x04000000 + +#define EBI_SDRAM_BASE EBI_SRAM_CS1_BASE +#define EBI_SDRAM_SIZE EBI_SRAM_CS1_SIZE + +#define INTERNAL_SRAM_BASE 0x24000000 +#define INTERNAL_SRAM_SIZE 0x00008000 +/* Devices on the High Speed Bus (HSB) */ #define LCDC_BASE 0xFF000000#define DMAC_BASE 0xFF200000
include/asm-avr32/sdram.h +22 -5
@@ -22,15 +22,32 @@#ifndef __ASM_AVR32_SDRAM_H#define __ASM_AVR32_SDRAM_H -struct sdram_info { -unsigned long phys_addr; -unsigned int row_bits, col_bits, bank_bits; -unsigned int cas, twr, trc, trp, trcd, tras, txsr; +struct sdram_config { +/* Number of data bits. */ +enum { +SDRAM_DATA_16BIT , +SDRAM_DATA_32BIT , + } data_bits; + +/* Number of address bits */ +uint8_t row_bits, col_bits, bank_bits; + +/* SDRAM timings in cycles */ +uint8_t cas, twr, trc, trp, trcd, tras, txsr;/* SDRAM refresh period in cycles */ unsigned long refresh_period; }; -extern unsigned long sdram_init (const struct sdram_info *info); +/* +* Attempt to initialize the SDRAM controller using the specified +* parameters. Return the expected size of the memory area based on +* the number of address and data bits. +* +* The caller should verify that the configuration is correct by +* running a memory test, e.g. get_ram_size(). +*/ +extern unsigned long sdram_init (void *sdram_base, +const struct sdram_config *config);#endif /* __ASM_AVR32_SDRAM_H */
include/configs/atngw100.h +7 -14
@@ -24,6 +24,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#include <asm/arch/memory-map.h> +#define CONFIG_AVR32 1#define CONFIG_AT32AP 1#define CONFIG_AT32AP7000 1
@@ -140,11 +142,9 @@#define CFG_MONITOR_BASE CFG_FLASH_BASE -#define CFG_INTRAM_BASE 0x24000000 -#define CFG_INTRAM_SIZE 0x8000 - -#define CFG_SDRAM_BASE 0x10000000 -#define CFG_SDRAM_16BIT 1 +#define CFG_INTRAM_BASE INTERNAL_SRAM_BASE +#define CFG_INTRAM_SIZE INTERNAL_SRAM_SIZE +#define CFG_SDRAM_BASE EBI_SDRAM_BASE#define CFG_ENV_IS_IN_FLASH 1#define CFG_ENV_SIZE 65536
@@ -153,17 +153,10 @@#define CFG_INIT_SP_ADDR (CFG_INTRAM_BASE + CFG_INTRAM_SIZE)#define CFG_MALLOC_LEN (256*1024) -#define CFG_MALLOC_END \ - ({ \ - DECLARE_GLOBAL_DATA_PTR; \ - CFG_SDRAM_BASE + gd->sdram_size; \ - }) -#define CFG_MALLOC_START (CFG_MALLOC_END - CFG_MALLOC_LEN) -#define CFG_DMA_ALLOC_LEN (16384)/* Allow 4MB for the kernel run-time image */ -#define CFG_LOAD_ADDR (CFG_SDRAM_BASE + 0x00400000) +#define CFG_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000)#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */
@@ -173,7 +166,7 @@#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)#define CFG_LONGHELP 1 -#define CFG_MEMTEST_START CFG_SDRAM_BASE +#define CFG_MEMTEST_START EBI_SDRAM_BASE#define CFG_MEMTEST_END (CFG_MEMTEST_START + 0x1f00000)#define CFG_BAUDRATE_TABLE { 115200, 38400, 19200, 9600, 2400 }
include/configs/atstk1002.h +7 -6
@@ -24,6 +24,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#include <asm/arch/memory-map.h> +#define CONFIG_AVR32 1#define CONFIG_AT32AP 1#define CONFIG_AT32AP7000 1
@@ -170,10 +172,9 @@#define CFG_MONITOR_BASE CFG_FLASH_BASE -#define CFG_INTRAM_BASE 0x24000000 -#define CFG_INTRAM_SIZE 0x8000 - -#define CFG_SDRAM_BASE 0x10000000 +#define CFG_INTRAM_BASE INTERNAL_SRAM_BASE +#define CFG_INTRAM_SIZE INTERNAL_SRAM_SIZE +#define CFG_SDRAM_BASE EBI_SDRAM_BASE#define CFG_ENV_IS_IN_FLASH 1#define CFG_ENV_SIZE 65536
@@ -185,7 +186,7 @@#define CFG_DMA_ALLOC_LEN (16384)/* Allow 4MB for the kernel run-time image */ -#define CFG_LOAD_ADDR (CFG_SDRAM_BASE + 0x00400000) +#define CFG_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000)#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */
@@ -195,7 +196,7 @@#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)#define CFG_LONGHELP 1 -#define CFG_MEMTEST_START CFG_SDRAM_BASE +#define CFG_MEMTEST_START EBI_SDRAM_BASE#define CFG_MEMTEST_END (CFG_MEMTEST_START + 0x700000)#define CFG_BAUDRATE_TABLE { 115200, 38400, 19200, 9600, 2400 }
include/configs/atstk1003.h +7 -6
@@ -24,6 +24,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#include <asm/arch/memory-map.h> +#define CONFIG_AVR32 1#define CONFIG_AT32AP 1#define CONFIG_AT32AP7001 1
@@ -153,10 +155,9 @@#define CFG_MONITOR_BASE CFG_FLASH_BASE -#define CFG_INTRAM_BASE 0x24000000 -#define CFG_INTRAM_SIZE 0x8000 - -#define CFG_SDRAM_BASE 0x10000000 +#define CFG_INTRAM_BASE INTERNAL_SRAM_BASE +#define CFG_INTRAM_SIZE INTERNAL_SRAM_SIZE +#define CFG_SDRAM_BASE EBI_SDRAM_BASE#define CFG_ENV_IS_IN_FLASH 1#define CFG_ENV_SIZE 65536
@@ -167,7 +168,7 @@#define CFG_MALLOC_LEN (256*1024)/* Allow 4MB for the kernel run-time image */ -#define CFG_LOAD_ADDR (CFG_SDRAM_BASE + 0x00400000) +#define CFG_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000)#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */
@@ -177,7 +178,7 @@#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)#define CFG_LONGHELP 1 -#define CFG_MEMTEST_START CFG_SDRAM_BASE +#define CFG_MEMTEST_START EBI_SDRAM_BASE#define CFG_MEMTEST_END (CFG_MEMTEST_START + 0x700000)#define CFG_BAUDRATE_TABLE { 115200, 38400, 19200, 9600, 2400 }
include/configs/atstk1004.h +7 -7
@@ -24,6 +24,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#include <asm/arch/memory-map.h> +#define CONFIG_AVR32 1#define CONFIG_AT32AP 1#define CONFIG_AT32AP7002 1
@@ -153,11 +155,9 @@#define CFG_MONITOR_BASE CFG_FLASH_BASE -#define CFG_INTRAM_BASE 0x24000000 -#define CFG_INTRAM_SIZE 0x8000 - -#define CFG_SDRAM_BASE 0x10000000 -#define CFG_SDRAM_16BIT 1 +#define CFG_INTRAM_BASE INTERNAL_SRAM_BASE +#define CFG_INTRAM_SIZE INTERNAL_SRAM_SIZE +#define CFG_SDRAM_BASE EBI_SDRAM_BASE#define CFG_ENV_IS_IN_FLASH 1#define CFG_ENV_SIZE 65536
@@ -168,7 +168,7 @@#define CFG_MALLOC_LEN (256*1024)/* Allow 2MB for the kernel run-time image */ -#define CFG_LOAD_ADDR (CFG_SDRAM_BASE + 0x00200000) +#define CFG_LOAD_ADDR (EBI_SDRAM_BASE + 0x00200000)#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */
@@ -178,7 +178,7 @@#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)#define CFG_LONGHELP 1 -#define CFG_MEMTEST_START CFG_SDRAM_BASE +#define CFG_MEMTEST_START EBI_SDRAM_BASE#define CFG_MEMTEST_END (CFG_MEMTEST_START + 0x700000)#define CFG_BAUDRATE_TABLE { 115200, 38400, 19200, 9600, 2400 }
include/configs/atstk1006.h +7 -6
@@ -24,6 +24,8 @@#ifndef __CONFIG_H#define __CONFIG_H +#include <asm/arch/memory-map.h> +#define CONFIG_AVR32 1#define CONFIG_AT32AP 1#define CONFIG_AT32AP7000 1
@@ -170,10 +172,9 @@#define CFG_MONITOR_BASE CFG_FLASH_BASE -#define CFG_INTRAM_BASE 0x24000000 -#define CFG_INTRAM_SIZE 0x8000 - -#define CFG_SDRAM_BASE 0x10000000 +#define CFG_INTRAM_BASE INTERNAL_SRAM_BASE +#define CFG_INTRAM_SIZE INTERNAL_SRAM_SIZE +#define CFG_SDRAM_BASE EBI_SDRAM_BASE#define CFG_ENV_IS_IN_FLASH 1#define CFG_ENV_SIZE 65536
@@ -185,7 +186,7 @@#define CFG_DMA_ALLOC_LEN (16384)/* Allow 4MB for the kernel run-time image */ -#define CFG_LOAD_ADDR (CFG_SDRAM_BASE + 0x00400000) +#define CFG_LOAD_ADDR (EBI_SDRAM_BASE + 0x00400000)#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */
@@ -195,7 +196,7 @@#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)#define CFG_LONGHELP 1 -#define CFG_MEMTEST_START CFG_SDRAM_BASE +#define CFG_MEMTEST_START EBI_SDRAM_BASE#define CFG_MEMTEST_END (CFG_MEMTEST_START + 0x3f00000)#define CFG_BAUDRATE_TABLE { 115200, 38400, 19200, 9600, 2400 }
Signature · 1 line
1.5.5.1
PATCH 15/18 atmel_usart: Support fractional baud rate dividers
Newer Atmel chips (post-AT91SAM9261; including AT91SAM9260 and all AVR32 chips) have a "Fractional Part" bitfield in BRGR that allows more precise baud rate generation. Use this field to make the USART work on lower clock frequencies, for example when not using the PLL, on chips that support it.
--- drivers/serial/atmel_usart.c | 14 ++++++++++++-- drivers/serial/atmel_usart.h | 2 ++ 2 files changed, 14 insertions(+), 2 deletions(-)
drivers/serial/atmel_usart.c +12 -2
@@ -44,6 +44,8 @@ void serial_setbrg(void) {unsigned long divisor;unsigned long usart_hz; +unsigned long cd; +unsigned long fp;/* * Master Clock
@@ -51,8 +53,16 @@ void serial_setbrg(void)* 16 * CD */ usart_hz =get_usart_clk_rate (USART_ID ); - divisor = (usart_hz /16 + gd->baudrate /2 ) / gd->baudrate; -usart3_writel (BRGR ,USART3_BF (CD , divisor)); + divisor = ((usart_hz +1 ) /2 + gd->baudrate /2 ) / gd->baudrate; +#if defined(CONFIG_AT91RM9200 ) || defined(CONFIG_AT91SAM9261 ) +/* Some chips don't support fractional dividers */ + cd = (divisor +4 ) /8 ; + fp =0 ; +#else + cd = divisor /8 ; + fp = divisor %8 ; +#endif +usart3_writel (BRGR ,USART3_BF (CD , cd) |USART3_BF (FP , fp)); }int serial_init (void )
drivers/serial/atmel_usart.h +2 -0
@@ -178,6 +178,8 @@/* Bitfields in BRGR */ #define USART3_CD_OFFSET 0#define USART3_CD_SIZE 16 +#define USART3_FP_OFFSET 16 +#define USART3_FP_SIZE 3/* Bitfields in RTOR */ #define USART3_TO_OFFSET 0
Signature · 1 line
1.5.5.1
PATCH 15/18 atmel_usart: Support fractional baud rate dividers
Quoted 7 lines · Haavard Skinnemoen
Newer Atmel chips (post-AT91SAM9261; including AT91SAM9260 and all AVR32 chips) have a "Fractional Part" bitfield in BRGR that allows more precise baud rate generation. Use this field to make the USART work on lower clock frequencies, for example when not using the PLL, on chips that support it.
Signed-off-by Haavard Skinnemoen <[email protected]>
Hmm...I think I'm gonna drop this one since it confuses the Linux driver. It tries to come up with a default baud rate by looking at the BRGR register, but it interprets the FP field as part of the divider, so it will end up at a rate that is way too low.
I'll post a patch to fix the Linux driver, but we shouldn't modify u-boot until the fix has been in mainline for a while.
Haavard
PATCH 16/18 avr32: Fix two warnings in atmel_mci.c
In reply to Haavard SkinnemoenThe warnings are harmless but annoying. Let's fix them.
--- cpu/at32ap/atmel_mci.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)
cpu/at32ap/atmel_mci.c +4 -2
@@ -182,12 +182,13 @@ static int mmc_acmd(unsigned long cmd, unsigned long arg,static unsigned long mmc_bread (int dev,unsigned long start,lbaint_t blkcnt, -unsigned long *buffer) +void *buffer) {int ret, i =0 ;unsigned long resp[4 ];unsigned long card_status, data;unsigned long wordcount; +u32 *p = buffer;u32 status;if (blkcnt ==0 )
@@ -225,7 +226,7 @@ mmc_bread(int dev, unsigned long start, lbaint_t blkcnt,if (status &MMCI_BIT (RXRDY )) { data =mmci_readl (RDR );/* pr_debug("%x\n", data); */ - *buffer++ = data; + *p++ = data; wordcount++; } }while (wordcount < (mmc_blkdev.blksz /4 ));
@@ -443,6 +444,7 @@ static void mci_set_data_timeout(struct mmc_csd *csd) dtocyc = timeout_clks; dtomul =0 ; + shift =0 ;while (dtocyc >15 && dtomul <8 ) { dtomul++; shift = dtomul_to_shift[dtomul];
Signature · 1 line
1.5.5.1
PATCH 17/18 avr32: Fix wrong error flags in atmel_mci driver
Make sure we check for CRC errors when sending commands that use CRC checking.
--- cpu/at32ap/atmel_mci.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
cpu/at32ap/atmel_mci.c +1 -1
@@ -139,7 +139,7 @@ mmc_cmd(unsigned long cmd, unsigned long arg,pr_debug ("mmc: status 0x%08lx\n" , status); -if (status &ERROR_FLAGS ) { +if (status & error_flags) {printf ("mmc: command %lu failed (status: 0x%08lx)\n" , cmd, status);return -EIO ;
Signature · 1 line
1.5.5.1
PATCH 18/18 avr32: Compile atmel_mci.o conditionally
Remove #ifdef CONFIG_MMC from the source file and use conditional compilation in the Makefile instead.
--- cpu/at32ap/Makefile | 2 +- cpu/at32ap/atmel_mci.c | 4 ---- 2 files changed, 1 insertions(+), 5 deletions(-)
cpu/at32ap/Makefile +1 -1
@@ -35,7 +35,7 @@ COBJS-y += exception.o COBJS-y += cache.o COBJS-y += interrupts.o COBJS-y += pio.o -COBJS-y += atmel_mci.o +COBJS-$(CONFIG_MMC) += atmel_mci.o SRCS := $(START-y:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
cpu/at32ap/atmel_mci.c +0 -4
@@ -21,8 +21,6 @@*/ #include <common.h> -#ifdef CONFIG_MMC -#include <part.h> #include <mmc.h>
@@ -548,5 +546,3 @@ int mmc2info(ulong addr) {return 0 ; } - -#endif /* CONFIG_MMC */
Signature · 1 line
1.5.5.1
PATCH 18/18 avr32: Compile atmel_mci.oconditionally
Quoted 2 lines · Haavard Skinnemoen
Remove #ifdef
CONFIG_MMCfrom the source file and use conditional compilation in theMakefileinstead.
What's wrong with the current code? Why are you doing this?
Quoted 40 lines
Signed-off-by Haavard Skinnemoen <[email protected]>--- cpu/at32ap/Makefile | 2 +- cpu/at32ap/atmel_mci.c | 4 ---- 2 files changed, 1 insertions(+), 5 deletions(-)cpu/at32ap/Makefile +1
-1@@ -35,7 +35,7 @@ COBJS-y += exception.o COBJS-y += cache.o COBJS-y += interrupts.o COBJS-y += pio.o -COBJS-y += atmel_mci.o +COBJS-$(CONFIG_MMC) += atmel_mci.o SRCS := $(START-y:.o=.S) $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c) OBJS := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))cpu/at32ap/atmel_mci.c +0
-4@@ -21,8 +21,6 @@*/ #include <common.h> -#ifdef CONFIG_MMC -#include <part.h> #include <mmc.h> @@ -548,5 +546,3 @@ int mmc2info(ulong addr) {return 0 ; } - -#endif /* CONFIG_MMC */ Signature · 1 line
1.5.5.1
Sincerely,
Ken Fuchs
PATCH 18/18 avr32: Compile atmel_mci.oconditionally
Quoted 7 lines · Ken.Fuchs at bench.com
Quoted 2 lines · Haavard Skinnemoen
Remove #ifdef
CONFIG_MMCfrom the source file and use conditional compilation in theMakefileinstead.What's wrong with the current code? Why are you doing this?
Because it is the right thing to do. :-)
So that we don't gratuitously compile files that aren't even necessarily involved in the build as per configuration selections. This is all part of the longer term goal of moving to a Kconfig/Kbuild mechanism.
jdl
PATCH 18/18 avr32: Compileatmel_mci.oconditionally
In reply to Ken.Fuchs at bench.comQuoted 9 lines
Quoted 2 lines · Haavard Skinnemoen
Remove #ifdef
CONFIG_MMCfrom the source file and use conditional compilation in theMakefileinstead.What's wrong with the current code? Why are you doing this?
It is more efficient to avoid starting the C compiler instead of compiling an empty file.
Best Regards
Ulf Samuelsson
PATCH 16/18 avr32: Fix two warnings in atmel_mci.c
In reply to Haavard SkinnemoenQuoted 1 line · Haavard Skinnemoen
The warnings are harmless but annoying. Let's fix them.
If the warnings are "harmless", why are you "fixing them"?
The compiler has switches to turn off warnings, if they annoy you too much.
Does this refactoring of the code do something more than just avoid a warning or two? If not, I would reject it.
Quoted 43 lines
Signed-off-by Haavard Skinnemoen <[email protected]>--- cpu/at32ap/atmel_mci.c | 6 ++++-- 1 files changed, 4 insertions(+), 2 deletions(-)cpu/at32ap/atmel_mci.c +2
-1@@ -182,12 +182,13 @@ static int mmc_acmd(unsigned long cmd,unsigned long arg, static unsigned long mmc_bread(int dev, unsigned long start, lbaint_t blkcnt, - unsigned long *buffer) + void *buffer) { int ret, i = 0;unsigned long resp[4 ];unsigned long card_status, data;unsigned long wordcount; +u32 *p = buffer;u32 status;cpu/at32ap/atmel_mci.c +1
-1if (blkcnt ==0 )@@ -225,7 +226,7 @@ mmc_bread(int dev, unsigned long start,lbaint_t blkcnt, if (status & MMCI_BIT(RXRDY)) { data =mmci_readl (RDR );/* pr_debug("%x\n", data); */ - *buffer++ = data; + *p++ = data; wordcount++; }cpu/at32ap/atmel_mci.c +1
-0}while (wordcount < (mmc_blkdev.blksz /4 ));@@ -443,6 +444,7 @@ static void mci_set_data_timeout(struct mmc_csd *csd) dtocyc = timeout_clks; dtomul =0 ; + shift =0 ;while (dtocyc >15 && dtomul <8 ) { dtomul++;
Quoted 3 lines
shift = dtomul_to_shift[dtomul];
Signature · 1 line
1.5.5.1
Sincerely,
Ken Fuchs
PATCH 16/18 avr32: Fix two warnings in atmel_mci.c
Quoted 5 lines · Ken.Fuchs at bench.com
Quoted 1 line · Haavard Skinnemoen
The warnings are harmless but annoying. Let's fix them.
If the warnings are "harmless", why are you "fixing them"?
Warnings are never completely harmless -- they make it harder to notice other warnings that point out real problems.
Quoted 2 lines
The compiler has switches to turn off warnings, if they annoy you too much.
I'd suggest doing the opposite, and enabling -Werror. :-)
-Scott
PATCH 16/18 avr32: Fix two warnings in atmel_mci.c
In reply to Ken.Fuchs at bench.comQuoted 5 lines · <[email protected]> wrote:
Quoted 1 line · Haavard Skinnemoen
The warnings are harmless but annoying. Let's fix them.
If the warnings are "harmless", why are you "fixing them"?
They are "harmless" as in "doesn't actually cause any wrong behaviour". But as Scott points out, they may make warnings that indicate real problems harder to catch.
For example, if someone comes along and changes the signature of the "block_read" hook in struct block_dev_desc, I may not notice because gcc is _already_ warning about a possible mismatch.
Quoted 2 lines
The compiler has switches to turn off warnings, if they annoy you too much.
Well, sure. But the "assignment to incompatible pointer type" is usually very good at catching real API violations, so even if it in this case catches code that is merely ugly, turning it off altogether would be the wrong thing to do IMO.
On the other hand, the "may be used uninitialized" warning tends to come up with a lot of false positives, but there's AFAIK no way to turn it off without also turning off the "is used uninitialized" warning, which is very useful.
Quoted 2 lines
Does this refactoring of the code do something more than just avoid a warning or two? If not, I would reject it.
I wouldn't call these tiny changes "refactoring". And I can't see any downsides except _maybe_ two bytes of additional .text usage.
I have to admit I wasn't sure about this one though:
Quoted 9 lines
Quoted 9 lines
cpu/at32ap/atmel_mci.c +1
-0@@ -443,6 +444,7 @@ static void mci_set_data_timeout(struct mmc_csd *csd) dtocyc = timeout_clks; dtomul =0 ; + shift =0 ;while (dtocyc >15 && dtomul <8 ) { dtomul++;shift = dtomul_to_shift[dtomul];
While I'm no fan of adding spurious initializations just because gcc can't figure out what the code is doing well enough to prove that it is always initialized, I think that in this case, it certainly isn't obvious, and 0 is a reasonable default.
So I decided to add it anyway, just in case later changes makes the assumption invalid.
Haavard
PATCH 6/18 avr32: Add support for the ATSTK1006 board
In reply to Haavard Skinnemoeninclude/configs/atstk1006.h line 161
Quoted 7 lines
include/configs/atstk1006.h new file +7
-0+#define CFG_DCACHE_LINESZ 32 +#define CFG_ICACHE_LINESZ 32 + +#define CONFIG_NR_DRAM_BANKS 1 + +/* External flash on STK1000 */ +#if 0
is it possible to use CFG_EXTERNAL_FLASH or something?
Quoted 21 lines
include/configs/atstk1006.h new file +21
-0+#define CFG_FLASH_CFI 1 +#define CFG_FLASH_CFI_DRIVER 1 +#endif + +#define CFG_FLASH_BASE 0x00000000 +#define CFG_FLASH_SIZE 0x800000 +#define CFG_MAX_FLASH_BANKS 1 +#define CFG_MAX_FLASH_SECT 135 + +#define CFG_MONITOR_BASE CFG_FLASH_BASE + +#define CFG_INTRAM_BASE 0x24000000 +#define CFG_INTRAM_SIZE 0x8000 + +#define CFG_SDRAM_BASE 0x10000000 + +#define CFG_ENV_IS_IN_FLASH 1 +#define CFG_ENV_SIZE 65536 +#define CFG_ENV_ADDR (CFG_FLASH_BASE + CFG_FLASH_SIZE - CFG_ENV_SIZE) + +#define CFG_INIT_SP_ADDR (CFG_INTRAM_BASE + CFG_INTRAM_SIZE)
include/configs/atstk1006.h line 192
Quoted 10 lines
include/configs/atstk1006.h new file +10
-0+ +#define CFG_MALLOC_LEN (256*1024) +#define CFG_DMA_ALLOC_LEN (16384) + +/* Allow 4MB for the kernel run-time image */ +#define CFG_LOAD_ADDR (CFG_SDRAM_BASE + 0x00400000) +#define CFG_BOOTPARAMS_LEN (16 * 1024) + +/* Other configuration settings that shouldn't have to change all that often */ +#define CFG_PROMPT "Uboot> "
In the precedent patch you put U-Boot is possible to do it here too?
include/configs/atstk1006.h line 196
Quoted 4 lines
include/configs/atstk1006.h new file +4
-0+#define CFG_CBSIZE 256 +#define CFG_MAXARGS 16to do it here too? +#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16) +#define CFG_LONGHELP 1
Best Regards,
J.
PATCH 6/18 avr32: Add support for the ATSTK1006 board
Quoted 11 lines · Jean-Christophe PLAGNIOL-VILLARD
Review
Quoted 7 lines
(quoted diff) +7
-0+#define CFG_DCACHE_LINESZ 32 +#define CFG_ICACHE_LINESZ 32 + +#define CONFIG_NR_DRAM_BANKS 1 + +/* External flash on STK1000 */ +#if 0is it possible to use
CFG_EXTERNAL_FLASHor something?Review
Quoted 3 lines
(quoted diff) +3
-0+#define CFG_FLASH_CFI 1 +#define CFG_FLASH_CFI_DRIVER 1 +#endif
Actually, I've been wanting to switch to the CFI driver for the STK1000 and its derivatives for a long time. However, the (obsolete) AT49BV6416 chip needs a fixup due to wrong erase region information, and there's currently no way to tell it apart from AT49BV642D, which doesn't need the fixup, since the CFI driver only reads the lower 8 bits of the device ID.
So while fixing the CFI driver isn't exactly top priority right now, this #if 0 block is very much intended as a temporary thing.
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+/* Other configuration settings that shouldn't have to change all that often */ +#define CFG_PROMPT "Uboot> "In the precedent patch you put U-Boot is possible to do it here too?
Absolutely. Nice catch.
I'm going to fold the below patch into this; there were a couple of other things that weren't in sync with patch #1 as well.
Thanks for reviewing!
Haavard
--- include/configs/atstk1006.h | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
include/configs/atstk1006.h +2 -2
@@ -141,9 +141,9 @@#define CONFIG_CMD_FAT #define CONFIG_CMD_JFFS2 #define CONFIG_CMD_MMC -#define CONFIG_CMD_REGINFO #undef CONFIG_CMD_AUTOSCRIPT +#undef CONFIG_CMD_FPGA#undef CONFIG_CMD_SETGETDCR#undef CONFIG_CMD_XIMG
@@ -190,7 +190,7 @@#define CFG_BOOTPARAMS_LEN (16 * 1024)/* Other configuration settings that shouldn't have to change all that often */ -#define CFG_PROMPT "Uboot> " +#define CFG_PROMPT "U-Boot> "#define CFG_CBSIZE 256#define CFG_MAXARGS 16#define CFG_PBSIZE (CFG_CBSIZE + sizeof(CFG_PROMPT) + 16)
Signature · 1 line
1.5.5.1
PATCH 5/18 avr32: Get rid of the .flashprog section
In reply to Haavard SkinnemoenQuoted 4 lines · Haavard Skinnemoen
The .flashprog section was only needed back when we were running directly from flash. Remove it on STK1000, and get rid of all the associated code and annotations.
Is it possible to join patch 4 and 5 which take care of the same thing?
Quoted 7 lines
Signed-off-by Haavard Skinnemoen <[email protected]>--- board/atmel/atstk1000/flash.c | 6 +++--- board/atmel/atstk1000/u-boot.lds | 8 -------- cpu/at32ap/cpu.c | 6 ------ include/asm-avr32/sections.h | 7 ------- 4 files changed, 3 insertions(+), 24 deletions(-)
Best Regards,
J.
PATCH 5/18 avr32: Get rid of the .flashprog section
Quoted 6 lines · Jean-Christophe PLAGNIOL-VILLARD
Quoted 4 lines · Haavard Skinnemoen
The .flashprog section was only needed back when we were running directly from flash. Remove it on STK1000, and get rid of all the associated code and annotations.
Is it possible to join patch 4 and 5 which take care of the same thing?
Yeah, splitting them up was silly. I'll join them.
The result is below, and I've also updated the for-1.3.4 branch. Thanks!
Haavard