[U-Boot] [PATCH 1/4] atmel_dataflash: remove use of get_timer_masked

Commit 5dca710a3d7703e41da0e9894f2d71f9e25bea6b removed get_timer_masked for at91. The dataflash driver was still using it and so stopped compiling. This blindly fixes the compilation problem (I am not currently using dataflash).
Signed-off-by: Alessandro Rubini rubini@gnudd.com --- drivers/spi/atmel_dataflash_spi.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/atmel_dataflash_spi.c b/drivers/spi/atmel_dataflash_spi.c index 4a5c4aa..d5215c0 100644 --- a/drivers/spi/atmel_dataflash_spi.c +++ b/drivers/spi/atmel_dataflash_spi.c @@ -158,12 +158,12 @@ unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc) }
/* arm simple, non interrupt dependent timer */ - reset_timer_masked(); + reset_timer(); timeout = 0;
writel(AT91_SPI_TXTEN + AT91_SPI_RXTEN, AT91_BASE_SPI + AT91_SPI_PTCR); while (!(readl(AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_RXBUFF) && - ((timeout = get_timer_masked()) < CONFIG_SYS_SPI_WRITE_TOUT)); + ((timeout = get_timer(0)) < CONFIG_SYS_SPI_WRITE_TOUT)); writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, AT91_BASE_SPI + AT91_SPI_PTCR); pDesc->state = IDLE;

Signed-off-by: Alessandro Rubini rubini@gnudd.com --- arch/arm/lib/board.c | 23 ++++++++++++++++++++++- 1 files changed, 22 insertions(+), 1 deletions(-)
diff --git a/arch/arm/lib/board.c b/arch/arm/lib/board.c index dc46e21..dab70b5 100644 --- a/arch/arm/lib/board.c +++ b/arch/arm/lib/board.c @@ -423,8 +423,29 @@ void board_init_f (ulong bootflag) gd->relocaddr = addr; gd->start_addr_sp = addr_sp; gd->reloc_off = addr - _TEXT_BASE; + + /* + * Destination is higher than current address, but may overlap + * our address range. If so, pass the source address as destination + * address so the asm will not relocate and only clear bss + */ + if ((addr_sp - 256) < _bss_start_ofs+_TEXT_BASE) { + debug("Won't fit above us: disabling relocation\n"); + if (gd->reloc_off < 0) { + printf("Can't relocate to lower ram, currently\n"); + hang(); + } + addr -= gd->reloc_off; + addr_sp -= gd->reloc_off; + gd->start_addr_sp = addr_sp; + id -= gd->reloc_off; + gd->reloc_off = 0; + } + + debug ("relocation Offset is: %08lx\n", gd->reloc_off); - memcpy (id, (void *)gd, sizeof (gd_t)); + if (id != (void *)gd) + memcpy (id, (void *)gd, sizeof (gd_t));
relocate_code (addr_sp, id, addr);

This adds support for relocation, but won't work for the default settings whereas AT91Boot loads u-boot to the last meg and it then tries to relocate slightly later, thus overwriting itself.
Signed-off-by: Alessandro Rubini rubini@gnudd.com --- board/atmel/at91sam9261ek/at91sam9261ek.c | 3 +-- include/configs/at91sam9261ek.h | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c index de5cfae..ec1d2a3 100644 --- a/board/atmel/at91sam9261ek/at91sam9261ek.c +++ b/board/atmel/at91sam9261ek/at91sam9261ek.c @@ -273,8 +273,7 @@ int board_eth_init(bd_t *bis)
int dram_init(void) { - gd->bd->bi_dram[0].start = PHYS_SDRAM; - gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE; + gd->ram_size = get_ram_size(PHYS_SDRAM, PHYS_SDRAM_SIZE); return 0; }
diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h index 401478b..71a4357 100644 --- a/include/configs/at91sam9261ek.h +++ b/include/configs/at91sam9261ek.h @@ -30,6 +30,7 @@ #define CONFIG_AT91_LEGACY
/* ARM asynchronous clock */ +#define CONFIG_AT91FAMILY #define CONFIG_SYS_AT91_MAIN_CLOCK 18432000 /* 18.432 MHz crystal */ #define CONFIG_SYS_HZ 1000
@@ -110,6 +111,9 @@ #define CONFIG_NR_DRAM_BANKS 1 #define PHYS_SDRAM 0x20000000 #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */ +#define CONFIG_SYS_SDRAM_BASE 0x20000000 +#define CONFIG_SYS_INIT_SP_ADDR 0x20100000 /* within RAM is ok */ +
/* DataFlash */ #define CONFIG_ATMEL_DATAFLASH_SPI

Dear Alessandro Rubini,
Am 18.04.2011 11:21, schrieb Alessandro Rubini:
This adds support for relocation, but won't work for the default settings whereas AT91Boot loads u-boot to the last meg and it then tries to relocate slightly later, thus overwriting itself.
Signed-off-by: Alessandro Rubini rubini@gnudd.com
board/atmel/at91sam9261ek/at91sam9261ek.c | 3 +-- include/configs/at91sam9261ek.h | 4 ++++ 2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/board/atmel/at91sam9261ek/at91sam9261ek.c b/board/atmel/at91sam9261ek/at91sam9261ek.c index de5cfae..ec1d2a3 100644 --- a/board/atmel/at91sam9261ek/at91sam9261ek.c +++ b/board/atmel/at91sam9261ek/at91sam9261ek.c @@ -273,8 +273,7 @@ int board_eth_init(bd_t *bis)
int dram_init(void) {
- gd->bd->bi_dram[0].start = PHYS_SDRAM;
- gd->bd->bi_dram[0].size = PHYS_SDRAM_SIZE;
- gd->ram_size = get_ram_size(PHYS_SDRAM, PHYS_SDRAM_SIZE);
please stop using this PHYS_SDRAM macros. They where replaced by CONFIG_SYS_SDRAM_(BASE|SIZE).
return 0; }
diff --git a/include/configs/at91sam9261ek.h b/include/configs/at91sam9261ek.h index 401478b..71a4357 100644 --- a/include/configs/at91sam9261ek.h +++ b/include/configs/at91sam9261ek.h @@ -30,6 +30,7 @@ #define CONFIG_AT91_LEGACY
/* ARM asynchronous clock */ +#define CONFIG_AT91FAMILY
CONFIG_AT91FAMILY is defined in some asm/arch/hardware.h files. You will get 'double definition' errors here. The best solution is currently to include asm/hardware.h in board config right after the correct SoC define. I have started a discussion on that problem yesterday evening -> http://article.gmane.org/gmane.comp.boot-loaders.u-boot/97903
#define CONFIG_SYS_AT91_MAIN_CLOCK 18432000 /* 18.432 MHz crystal */
I guess SLOW_CLOCK is missing here ...
#define CONFIG_SYS_HZ 1000
@@ -110,6 +111,9 @@ #define CONFIG_NR_DRAM_BANKS 1 #define PHYS_SDRAM 0x20000000 #define PHYS_SDRAM_SIZE 0x04000000 /* 64 megs */ +#define CONFIG_SYS_SDRAM_BASE 0x20000000
just replace the PHYS_SDRAM defines by CONFIG_SYS_SDRAM defines.
+#define CONFIG_SYS_INIT_SP_ADDR 0x20100000 /* within RAM is ok */
I recommend to use SRAM here, see top900(0) header for example.
/* DataFlash */ #define CONFIG_ATMEL_DATAFLASH_SPI
regards
Andreas Bießmann

This moves config targets, but defines DATAFLASH_CS0 for "dataflash_cs0" configs and DATAFLASH_CS3 for "dataflash_cs3" configs, whereas the Makefile targets had it swapped.
Signed-off-by: Alessandro Rubini rubini@gnudd.com --- Makefile | 22 ---------------------- boards.cfg | 8 ++++++++ 2 files changed, 8 insertions(+), 22 deletions(-)
diff --git a/Makefile b/Makefile index 584105c..93c33c7 100644 --- a/Makefile +++ b/Makefile @@ -803,28 +803,6 @@ at91sam9xeek_config : unconfig fi; @$(MKCONFIG) -n $@ -a at91sam9260ek arm arm926ejs at91sam9260ek atmel at91
-at91sam9261ek_nandflash_config \ -at91sam9261ek_dataflash_cs0_config \ -at91sam9261ek_dataflash_cs3_config \ -at91sam9261ek_config \ -at91sam9g10ek_nandflash_config \ -at91sam9g10ek_dataflash_cs0_config \ -at91sam9g10ek_dataflash_cs3_config \ -at91sam9g10ek_config : unconfig - @mkdir -p $(obj)include - @if [ "$(findstring 9g10,$@)" ] ; then \ - echo "#define CONFIG_AT91SAM9G10EK 1" >>$(obj)include/config.h ; \ - else \ - echo "#define CONFIG_AT91SAM9261EK 1" >>$(obj)include/config.h ; \ - fi; - @if [ "$(findstring _nandflash,$@)" ] ; then \ - echo "#define CONFIG_SYS_USE_NANDFLASH 1" >>$(obj)include/config.h ; \ - elif [ "$(findstring dataflash_cs0,$@)" ] ; then \ - echo "#define CONFIG_SYS_USE_DATAFLASH_CS3 1" >>$(obj)include/config.h ; \ - else \ - echo "#define CONFIG_SYS_USE_DATAFLASH_CS0 1" >>$(obj)include/config.h ; \ - fi; - @$(MKCONFIG) -n $@ -a at91sam9261ek arm arm926ejs at91sam9261ek atmel at91
at91sam9263ek_norflash_config \ at91sam9263ek_norflash_boot_config \ diff --git a/boards.cfg b/boards.cfg index 9194610..80488b8 100644 --- a/boards.cfg +++ b/boards.cfg @@ -73,6 +73,14 @@ omap1510inn arm arm925t - ti aspenite arm arm926ejs - Marvell armada100 afeb9260 arm arm926ejs - - at91 at91cap9adk arm arm926ejs - atmel at91 +at91sam9261ek arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9261EK,SYS_USE_DATAFLASH_CS0 +at91sam9261ek_dataflash_cs0 arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9261EK,SYS_USE_DATAFLASH_CS0 +at91sam9261ek_dataflash_cs3 arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9261EK,SYS_USE_DATAFLASH_CS3 +at91sam9261ek_nandflash arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9261EK,SYS_USE_NANDFLASH +at91sam92g10ek arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9G10EK,SYS_USE_DATAFLASH_CS0 +at91sam92g10ek_dataflash_cs0 arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9G10EK,SYS_USE_DATAFLASH_CS0 +at91sam92g10ek_dataflash_cs3 arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9G10EK,SYS_USE_DATAFLASH_CS3 +at91sam92g10ek_nandflash arm arm926ejs - atmel at91 at91sam9261ek:AT91SAM9G10EK,SYS_USE_NANDFLASH top9000eval_xe arm arm926ejs top9000 emk at91 top9000:EVAL9000 top9000su_xe arm arm926ejs top9000 emk at91 top9000:SU9000 meesc arm arm926ejs - esd at91

Dear Alessandro Rubini:
Commit 5dca710a3d7703e41da0e9894f2d71f9e25bea6b removed get_timer_masked for at91. The dataflash driver was still using it and so stopped compiling. This blindly fixes the compilation problem (I am not currently using dataflash).
Signed-off-by: Alessandro Rubini rubini@gnudd.com
drivers/spi/atmel_dataflash_spi.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/spi/atmel_dataflash_spi.c b/drivers/spi/atmel_dataflash_spi.c index 4a5c4aa..d5215c0 100644 --- a/drivers/spi/atmel_dataflash_spi.c +++ b/drivers/spi/atmel_dataflash_spi.c @@ -158,12 +158,12 @@ unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc) }
/* arm simple, non interrupt dependent timer */
- reset_timer_masked();
reset_timer(); timeout = 0;
writel(AT91_SPI_TXTEN + AT91_SPI_RXTEN, AT91_BASE_SPI + AT91_SPI_PTCR); while (!(readl(AT91_BASE_SPI + AT91_SPI_SR) & AT91_SPI_RXBUFF) &&
((timeout = get_timer_masked()) < CONFIG_SYS_SPI_WRITE_TOUT));
writel(AT91_SPI_TXTDIS + AT91_SPI_RXTDIS, AT91_BASE_SPI + AT91_SPI_PTCR); pDesc->state = IDLE;((timeout = get_timer(0)) < CONFIG_SYS_SPI_WRITE_TOUT));
a) reset_timer(), and all *_masked() timer functions are depreciated and have been removed from AT91 timer code b) the problem has already been fixed in current u-boot-atmel/next
Best Regards, Reinhard
participants (3)
-
Alessandro Rubini
-
Andreas Bießmann
-
Reinhard Meyer