Skip to contentSkip to conversation

atmel_dataflash: remove use of get_timer_masked

PATCH New Alessandro Rubini 3 participants 6 messages Apr 18, 2011

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

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).

---
 drivers/spi/atmel_dataflash_spi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/spi/atmel_dataflash_spi.c +2 -2
index 4a5c4aa..d5215c0 100644
@@ -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;
 
Signature · 1 line
1.5.6.5
#1 lore raw

PATCH 2/4 ARM: don't relocate if we are already too high

---
 arch/arm/lib/board.c |   23 ++++++++++++++++++++++-
 1 files changed, 22 insertions(+), 1 deletions(-)
arch/arm/lib/board.c +22 -1
index dc46e21..dab70b5 100644
@@ -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);
 
Signature · 1 line
1.5.6.5
#2 lore raw

PATCH 3/4 at91sam9261/g10: support relocation

In reply to 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.

---
 board/atmel/at91sam9261ek/at91sam9261ek.c |    3 +--
 include/configs/at91sam9261ek.h           |    4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)
board/atmel/at91sam9261ek/at91sam9261ek.c +1 -2
index de5cfae..ec1d2a3 100644
@@ -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;
 }
 
include/configs/at91sam9261ek.h +4 -0
index 401478b..71a4357 100644
@@ -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
Signature · 1 line
1.5.6.5
#3 lore raw

PATCH 3/4 at91sam9261/g10: support relocation

Dear Alessandro Rubini,

Am 18.04.2011 11:21, schrieb Alessandro Rubini:

Quoted 15 lines

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.

---
 board/atmel/at91sam9261ek/at91sam9261ek.c |    3 +--
 include/configs/at91sam9261ek.h           |    4 ++++
 2 files changed, 5 insertions(+), 2 deletions(-)
board/atmel/at91sam9261ek/at91sam9261ek.c +0 -0
index de5cfae..ec1d2a3 100644

board/atmel/at91sam9261ek/at91sam9261ek.c int board_eth_init(bd_t *bis) · line 276

Quoted 6 lines
board/atmel/at91sam9261ek/at91sam9261ek.c +1 -2
@@ -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).

include/configs/at91sam9261ek.h line 33

Quoted 12 lines
board/atmel/at91sam9261ek/at91sam9261ek.c +0 -0
 	return 0;
 }
 
include/configs/at91sam9261ek.h +1 -0
index 401478b..71a4357 100644
@@ -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

include/configs/at91sam9261ek.h line 34

Quoted 1 line
include/configs/at91sam9261ek.h +0 -0
 #define CONFIG_SYS_AT91_MAIN_CLOCK	18432000	/* 18.432 MHz crystal */

I guess SLOW_CLOCK is missing here ...

include/configs/at91sam9261ek.h line 114

Quoted 7 lines
include/configs/at91sam9261ek.h +1 -0
 #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.

include/configs/at91sam9261ek.h line 116

Quoted 2 lines
include/configs/at91sam9261ek.h +2 -0
+#define CONFIG_SYS_INIT_SP_ADDR		0x20100000	/* within RAM is ok */
+

I recommend to use SRAM here, see top900(0) header for example.

include/configs/at91sam9261ek.h line 119

Quoted 3 lines
include/configs/at91sam9261ek.h +0 -0
 /* DataFlash */
 #define CONFIG_ATMEL_DATAFLASH_SPI

regards

Andreas Bie?mann

#4 lore raw

PATCH 4/4 at91sam9261/g10: move config from Makefile to boards.cfg

In reply to Alessandro Rubini

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.

---
 Makefile   |   22 ----------------------
 boards.cfg |    8 ++++++++
 2 files changed, 8 insertions(+), 22 deletions(-)
Makefile +0 -22
index 584105c..93c33c7 100644
@@ -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 \
boards.cfg +8 -0
index 9194610..80488b8 100644
@@ -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
Signature · 1 line
1.5.6.5
#5 lore raw

PATCH 1/4 atmel_dataflash: remove use of get_timer_masked

In reply to Alessandro Rubini

Dear Alessandro Rubini:

Quoted 19 lines

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).

---
 drivers/spi/atmel_dataflash_spi.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/spi/atmel_dataflash_spi.c +0 -1
index 4a5c4aa..d5215c0 100644
@@ -158,12 +158,12 @@ unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc)
 	}
 
 	/* arm simple, non interrupt dependent timer */
-	reset_timer_masked();

drivers/spi/atmel_dataflash_spi.c unsigned int AT91F_SpiWrite(AT91PS_DataflashDesc pDesc) · line 169

Quoted 10 lines
drivers/spi/atmel_dataflash_spi.c +2 -1
+	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;
 

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