Skip to contentSkip to conversation

Enable at91sam9x5 boot from serial flash

PATCH New Bo Shen 3 participants 12 messages Aug 16, 2012 – Sep 17, 2012

Subsystems (3)
lore
Share & tools
lore

Bo Shen

author
#0 lore raw

cover Enable at91sam9x5 boot from serial flash

This series patches enable at91sam9x5 boot from serial flash

Bo Shen (3):
spi: add atmel at25db321 serial flash support
arm : at91sam9x5 : enable serial flash boot
arm : at91sam9x5 : make nand available when not boot from nand

 arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |    4 ++--
 board/atmel/at91sam9x5ek/at91sam9x5ek.c          |    2 ++
 boards.cfg                                       |    1 +
 drivers/mtd/spi/atmel.c                          |   10 ++++++++++
 include/configs/at91sam9x5ek.h                   |   18 ++++++++++++++----
 5 files changed, 29 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH 1/3 spi: add atmel at25df321 serial flash support

Add atmel at25df321 serial flash support

---
 drivers/mtd/spi/atmel.c |   10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/mtd/spi/atmel.c +10 -0
index 1ecece0..89ebe9d 100644
@@ -109,6 +109,14 @@ static const struct atmel_spi_flash_params atmel_spi_flash_table[] = {
 		.nr_sectors		= 32,
 		.name			= "AT45DB642D",
 	},
+	{
+		.idcode1		= 0x47,
+		.l2_page_size		= 8,
+		.pages_per_block	= 16,
+		.blocks_per_sector	= 16,
+		.nr_sectors		= 64,
+		.name			= "AT25DF321",
+	},
 };
 
 static int at45_wait_ready(struct spi_flash *flash, unsigned long timeout)
@@ -515,6 +523,8 @@ struct spi_flash *spi_flash_probe_atmel(struct spi_slave *spi, u8 *idcode)
 	case DF_FAMILY_AT26F:
 	case DF_FAMILY_AT26DF:
 		asf->flash.read = spi_flash_cmd_read_fast;
+		asf->flash.write = dataflash_write_p2;
+		asf->flash.erase = dataflash_erase_p2;
 		break;
 
 	default:
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH 1/3 spi: add atmel at25df321 serial flash support

Quoted 1 line · On Thursday 16 August 2012 00:44:25 Bo Shen wrote:

Add atmel at25df321 serial flash support

thanks, merged into my spi flash branch
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/615cb614/attachment.pgp>

author
#3 lore raw

PATCH 1/3 spi: add atmel at25df321 serial flash support

Hi Mike,

Quoted 3 lines · Mike Frysinger
Quoted 1 line · On Thursday 16 August 2012 00:44:25 Bo Shen wrote:

Add atmel at25df321 serial flash support

After reading the spi framework. I found there are common interface for serial flash. So, I plan to use the common interface (spi_flash_cmd_write_multi) while not the private interface (dataflash_write_p2), and etc.

I am sorry for this inconvenience. :(

Will you revert this patch? Or, maybe I should submit a patch for this base on the merged code?

which one will you prefer to?

Quoted 3 lines

thanks, merged into my spi flash branch
-mike

#4 lore raw

PATCH 1/3 spi: add atmel at25df321 serial flash support

Quoted 9 lines · On Friday 17 August 2012 01:08:01 Bo Shen wrote:
Quoted 2 lines · Mike Frysinger
Quoted 1 line · On Thursday 16 August 2012 00:44:25 Bo Shen wrote:

Add atmel at25df321 serial flash support

After reading the spi framework. I found there are common interface for serial flash. So, I plan to use the common interface (spi_flash_cmd_write_multi) while not the private interface (dataflash_write_p2), and etc.

Quoted 6 lines

I am sorry for this inconvenience. :(

Will you revert this patch? Or, maybe I should submit a patch for this base on the merged code?

which one will you prefer to?

i think this is an independent issue that the atmel driver has long not been using the unified pieces. if you want to submit a patch on top of this one, that'd be best.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20120817/77d71606/attachment.pgp>

#5 lore raw

PATCH 1/3 spi: add atmel at25df321 serial flash support

In reply to Bo Shen

Dear Bo Shen,

Quoted 4 lines · Bo Shen

Add atmel at25df321 serial flash support

---

since this patch did not appear to be merged by Mike as mentioned earlier ([1], [2], [3]) I did apply it to u-boot-atmel/master, thanks!

Best regards

Andreas Bie?mann

[1]
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/138226/focus=138332
[2]
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/137983/focus=139926
[3]
http://thread.gmane.org/gmane.comp.boot-loaders.u-boot/140642/focus=140774

author
#6 lore raw

PATCH 2/3 arm : at91sam9x5 : enable serial flash boot

In reply to Bo Shen

enable at91sam9x5 boot from serial flash

Use at91sam9x5_dataflash to configure the u-boot

---
 arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |    4 ++--
 boards.cfg                                       |    1 +
 include/configs/at91sam9x5ek.h                   |   18 ++++++++++++++----
 3 files changed, 17 insertions(+), 6 deletions(-)
arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c +2 -2
index 7558ca2..6d77219 100644
@@ -121,7 +121,7 @@ void at91_serial2_hw_init(void)
 #ifdef CONFIG_ATMEL_SPI
 void at91_spi0_hw_init(unsigned long cs_mask)
 {
-	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_PMC_BASE;
+	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 
 	at91_set_a_periph(AT91_PIO_PORTA, 11, 0);	/* SPI0_MISO */
 	at91_set_a_periph(AT91_PIO_PORTA, 12, 0);	/* SPI0_MOSI */
@@ -150,7 +150,7 @@ void at91_spi0_hw_init(unsigned long cs_mask)
 
 void at91_spi1_hw_init(unsigned long cs_mask)
 {
-	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_PMC_BASE;
+	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 
 	at91_set_b_periph(AT91_PIO_PORTA, 21, 0);	/* SPI1_MISO */
 	at91_set_b_periph(AT91_PIO_PORTA, 22, 0);	/* SPI1_MOSI */
boards.cfg +1 -0
index edd750c..945ef09 100644
@@ -91,6 +91,7 @@ at91sam9m10g45ek_nandflash   arm         arm926ejs   at91sam9m10g45ek    atmel
 at91sam9rlek_dataflash       arm         arm926ejs   at91sam9rlek        atmel          at91        at91sam9rlek:AT91SAM9RL,SYS_USE_DATAFLASH
 at91sam9rlek_nandflash       arm         arm926ejs   at91sam9rlek        atmel          at91        at91sam9rlek:AT91SAM9RL,SYS_USE_NANDFLASH
 at91sam9x5ek_nandflash       arm         arm926ejs   at91sam9x5ek        atmel          at91        at91sam9x5ek:AT91SAM9X5,SYS_USE_NANDFLASH
+at91sam9x5ek_dataflash       arm         arm926ejs   at91sam9x5ek        atmel          at91        at91sam9x5ek:AT91SAM9X5,SYS_USE_DATAFLASH
 at91sam9xeek_dataflash_cs0   arm         arm926ejs   at91sam9260ek       atmel          at91        at91sam9260ek:AT91SAM9XE,SYS_USE_DATAFLASH_CS0
 at91sam9xeek_dataflash_cs1   arm         arm926ejs   at91sam9260ek       atmel          at91        at91sam9260ek:AT91SAM9XE,SYS_USE_DATAFLASH_CS1
 at91sam9xeek_nandflash       arm         arm926ejs   at91sam9260ek       atmel          at91        at91sam9260ek:AT91SAM9XE,SYS_USE_NANDFLASH
include/configs/at91sam9x5ek.h +14 -4
index 82f6b48..21ef862 100644
@@ -86,6 +86,7 @@
 #define CONFIG_CMD_PING
 #define CONFIG_CMD_DHCP
 #define CONFIG_CMD_NAND
+#define CONFIG_CMD_SF
 
 /* SDRAM */
 #define CONFIG_NR_DRAM_BANKS		1
@@ -96,12 +97,10 @@
 	(CONFIG_SYS_SDRAM_BASE + 4 * 1024 - GENERATED_GBL_DATA_SIZE)
 
 /* DataFlash */
-#ifdef CONFIG_ATMEL_SPI
-#define CONFIG_CMD_SF
-#define CONFIG_CMD_SPI
+#ifdef CONFIG_CMD_SF
+#define CONFIG_ATMEL_SPI
 #define CONFIG_SPI_FLASH
 #define CONFIG_SPI_FLASH_ATMEL
-#define CONFIG_SYS_MAX_DATAFLASH_BANKS
 #endif
 
 /* no NOR flash */
@@ -149,6 +148,17 @@
 #define CONFIG_BOOTCOMMAND	"nand read " \
 				"0x22000000 0x200000 0x300000; " \
 				"bootm 0x22000000"
+#else
+#ifdef CONFIG_SYS_USE_DATAFLASH
+/* bootstrap + u-boot + env + linux in data flash */
+#define CONFIG_ENV_IS_IN_SPI_FLASH
+#define CONFIG_ENV_OFFSET	0x5000
+#define CONFIG_ENV_SIZE		0x3000
+#define CONFIG_ENV_SECT_SIZE	0x1000
+#define CONFIG_BOOTCOMMAND	"sf probe 0; " \
+				"sf read 0x22000000 0x100000 0x300000; " \
+				"bootm 0x22000000"
+#endif
 #endif
 
 #define CONFIG_BOOTARGS		"mem=128M console=ttyS0,115200 " \
Signature · 1 line
1.7.9.5
#7 lore raw

PATCH 2/3 arm : at91sam9x5 : enable serial flash boot

Dear Bo Shen,

Quoted 25 lines · Bo Shen

enable at91sam9x5 boot from serial flash

Use at91sam9x5_dataflash to configure the u-boot

---
 arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |    4 ++--
 boards.cfg                                       |    1 +
 include/configs/at91sam9x5ek.h                   |   18 ++++++++++++++----
 3 files changed, 17 insertions(+), 6 deletions(-)
arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c +1 -1
index 7558ca2..6d77219 100644
@@ -121,7 +121,7 @@ void at91_serial2_hw_init(void)
 #ifdef CONFIG_ATMEL_SPI
 void at91_spi0_hw_init(unsigned long cs_mask)
 {
-	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_PMC_BASE;
+	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 
 	at91_set_a_periph(AT91_PIO_PORTA, 11, 0);	/* SPI0_MISO */
 	at91_set_a_periph(AT91_PIO_PORTA, 12, 0);	/* SPI0_MOSI */

arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c void at91_spi0_hw_init(unsigned long cs_mask) · line 156

Quoted 8 lines
arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c +1 -1
@@ -150,7 +150,7 @@ void at91_spi0_hw_init(unsigned long cs_mask)
 
 void at91_spi1_hw_init(unsigned long cs_mask)
 {
-	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_PMC_BASE;
+	at91_pmc_t *pmc = (at91_pmc_t *) ATMEL_BASE_PMC;
 
 	at91_set_b_periph(AT91_PIO_PORTA, 21, 0);	/* SPI1_MISO */
 	at91_set_b_periph(AT91_PIO_PORTA, 22, 0);	/* SPI1_MOSI */

I would like to see these two fixes in a separate patch 'fix spi access' or something else.

rest of this patch looks sane to me.

Best regards

Andreas Bie?mann

author
#8 lore raw

PATCH 3/3 arm : at91sam9x5 : fix a small bug for NAND

In reply to Bo Shen

fix a bug:
when not boot from NAND, the NAND flash can not be detected. Using this to fix it

---
 board/atmel/at91sam9x5ek/at91sam9x5ek.c |    2 ++
 1 file changed, 2 insertions(+)
board/atmel/at91sam9x5ek/at91sam9x5ek.c +2 -0
index 17db0fd..88b3478 100644
@@ -60,6 +60,8 @@ static void at91sam9x5ek_nand_hw_init(void)
 	/* Enable CS3 */
 	csa = readl(&matrix->ebicsa);
 	csa |= AT91_MATRIX_EBI_CS3A_SMC_SMARTMEDIA;
+	/* NAND flash on D16 */
+	csa |= AT91_MATRIX_NFD0_ON_D16;
 	writel(csa, &matrix->ebicsa);
 
 	/* Configure SMC CS3 for NAND/SmartMedia */
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH 3/3 arm : at91sam9x5 : fix a small bug for NAND

Dear Bo Shen,

Quoted 6 lines · Bo Shen

fix a bug:
when not boot from NAND, the NAND flash can not be detected. Using this to fix it

---

applied to u-boot-atmel/master, thnaks!

Best regards

Andreas Bie?mann

author
#10 lore raw

cover Enable at91sam9x5 boot from serial flash

In reply to Bo Shen

Hi Andreas,

Quoted 7 lines · Bo Shen

This series patches enable at91sam9x5 boot from serial flash

Bo Shen (3):
spi: add atmel at25db321 serial flash support
arm : at91sam9x5 : enable serial flash boot
arm : at91sam9x5 : make nand available when not boot from nand

Please don't take this serial patches.
I found the spi only works at 1MHz speed which is too slow. I will resend it let it work at a higher speed.

BRs,
Bo Shen

Quoted 7 lines
  arch/arm/cpu/arm926ejs/at91/at91sam9x5_devices.c |    4 ++--
  board/atmel/at91sam9x5ek/at91sam9x5ek.c          |    2 ++
  boards.cfg                                       |    1 +
  drivers/mtd/spi/atmel.c                          |   10 ++++++++++
  include/configs/at91sam9x5ek.h                   |   18 ++++++++++++++----
  5 files changed, 29 insertions(+), 6 deletions(-)
#11 lore raw

cover Enable at91sam9x5 boot from serial flash

Hi Bo,

Quoted 11 lines · Bo Shen

Hi Andreas,

Quoted 7 lines · Bo Shen

This series patches enable at91sam9x5 boot from serial flash

Bo Shen (3):
spi: add atmel at25db321 serial flash support
arm : at91sam9x5 : enable serial flash boot
arm : at91sam9x5 : make nand available when not boot from nand

Quoted 3 lines

Please don't take this serial patches.
I found the spi only works at 1MHz speed which is too slow. I will resend it let it work at a higher speed.

Ok, please split 2/3 into a 'fix spi' and a 'enable spi for <board>'

Best regards

Andreas Bie?mann