All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 0/2] ARM: atmel: sama5d3xek: enable NOR flash support
@ 2014-06-20  8:15 Bo Shen
  2014-06-20  8:16 ` [U-Boot] [PATCH 1/2] ARM: atmel: sama5d3xek: add nor flash init function Bo Shen
  2014-06-20  8:16 ` [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support Bo Shen
  0 siblings, 2 replies; 7+ messages in thread
From: Bo Shen @ 2014-06-20  8:15 UTC (permalink / raw)
  To: u-boot

Add NOR flash support on sama5d3xek board. Then, we can use
NOR flash related command to access it.

Bo Shen (2):
  ARM: atmel: sama5d3xek: add nor flash init function
  ARM: atmel: sama5d3xek: enable NOR flash support

 board/atmel/sama5d3xek/sama5d3xek.c | 58 +++++++++++++++++++++++++++++++++++++
 include/configs/sama5d3xek.h        | 12 +++++++-
 2 files changed, 69 insertions(+), 1 deletion(-)

-- 
1.8.5.2

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 1/2] ARM: atmel: sama5d3xek: add nor flash init function
  2014-06-20  8:15 [U-Boot] [PATCH 0/2] ARM: atmel: sama5d3xek: enable NOR flash support Bo Shen
@ 2014-06-20  8:16 ` Bo Shen
  2014-06-20  8:16 ` [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support Bo Shen
  1 sibling, 0 replies; 7+ messages in thread
From: Bo Shen @ 2014-06-20  8:16 UTC (permalink / raw)
  To: u-boot

Add NOR flash hardware init function, including SMC and PIO
configuration.

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 board/atmel/sama5d3xek/sama5d3xek.c | 58 +++++++++++++++++++++++++++++++++++++
 1 file changed, 58 insertions(+)

diff --git a/board/atmel/sama5d3xek/sama5d3xek.c b/board/atmel/sama5d3xek/sama5d3xek.c
index c835c12..0e95609 100644
--- a/board/atmel/sama5d3xek/sama5d3xek.c
+++ b/board/atmel/sama5d3xek/sama5d3xek.c
@@ -67,6 +67,61 @@ void sama5d3xek_nand_hw_init(void)
 }
 #endif
 
+#ifndef CONFIG_SYS_NO_FLASH
+void sama5d3xek_nor_hw_init(void)
+{
+	struct at91_smc *smc = (struct at91_smc *)ATMEL_BASE_SMC;
+
+	at91_periph_clk_enable(ATMEL_ID_SMC);
+
+	/* Configure SMC CS0 for NOR flash */
+	writel(AT91_SMC_SETUP_NWE(1) | AT91_SMC_SETUP_NCS_WR(0) |
+	       AT91_SMC_SETUP_NRD(2) | AT91_SMC_SETUP_NCS_RD(0),
+	       &smc->cs[0].setup);
+	writel(AT91_SMC_PULSE_NWE(10) | AT91_SMC_PULSE_NCS_WR(11) |
+	       AT91_SMC_PULSE_NRD(10) | AT91_SMC_PULSE_NCS_RD(11),
+	       &smc->cs[0].pulse);
+	writel(AT91_SMC_CYCLE_NWE(11) | AT91_SMC_CYCLE_NRD(14),
+	       &smc->cs[0].cycle);
+	writel(AT91_SMC_TIMINGS_TCLR(0) | AT91_SMC_TIMINGS_TADL(0)  |
+	       AT91_SMC_TIMINGS_TAR(0)  | AT91_SMC_TIMINGS_TRR(0)   |
+	       AT91_SMC_TIMINGS_TWB(0)  | AT91_SMC_TIMINGS_RBNSEL(0)|
+	       AT91_SMC_TIMINGS_NFSEL(0), &smc->cs[0].timings);
+	writel(AT91_SMC_MODE_RM_NRD | AT91_SMC_MODE_WM_NWE |
+	       AT91_SMC_MODE_EXNW_DISABLE |
+	       AT91_SMC_MODE_DBW_16 |
+	       AT91_SMC_MODE_TDF_CYCLE(1),
+	       &smc->cs[0].mode);
+
+	/* Address pin (A1 ~ A23) configuration */
+	at91_set_a_periph(AT91_PIO_PORTE, 1, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 2, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 3, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 4, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 5, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 6, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 7, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 8, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 9, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 10, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 11, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 12, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 13, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 14, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 15, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 16, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 17, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 18, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 19, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 20, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 21, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 22, 0);
+	at91_set_a_periph(AT91_PIO_PORTE, 23, 0);
+	/* CS0 pin configuration */
+	at91_set_a_periph(AT91_PIO_PORTE, 26, 0);
+}
+#endif
+
 #ifdef CONFIG_CMD_USB
 static void sama5d3xek_usb_hw_init(void)
 {
@@ -181,6 +236,9 @@ int board_init(void)
 #ifdef CONFIG_NAND_ATMEL
 	sama5d3xek_nand_hw_init();
 #endif
+#ifndef CONFIG_SYS_NO_FLASH
+	sama5d3xek_nor_hw_init();
+#endif
 #ifdef CONFIG_CMD_USB
 	sama5d3xek_usb_hw_init();
 #endif
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support
  2014-06-20  8:15 [U-Boot] [PATCH 0/2] ARM: atmel: sama5d3xek: enable NOR flash support Bo Shen
  2014-06-20  8:16 ` [U-Boot] [PATCH 1/2] ARM: atmel: sama5d3xek: add nor flash init function Bo Shen
@ 2014-06-20  8:16 ` Bo Shen
  2014-06-30  9:55   ` Andy Pont
  1 sibling, 1 reply; 7+ messages in thread
From: Bo Shen @ 2014-06-20  8:16 UTC (permalink / raw)
  To: u-boot

Signed-off-by: Bo Shen <voice.shen@atmel.com>
---
 include/configs/sama5d3xek.h | 12 +++++++++++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/configs/sama5d3xek.h b/include/configs/sama5d3xek.h
index da27180..63d6775 100644
--- a/include/configs/sama5d3xek.h
+++ b/include/configs/sama5d3xek.h
@@ -79,8 +79,18 @@
 #define CONFIG_BOOTP_GATEWAY
 #define CONFIG_BOOTP_HOSTNAME
 
-/* No NOR flash */
+/* NOR flash */
+#define CONFIG_CMD_FLASH
+
+#ifdef CONFIG_CMD_FLASH
+#define CONFIG_SYS_FLASH_CFI
+#define CONFIG_FLASH_CFI_DRIVER
+#define CONFIG_SYS_FLASH_BASE		0x10000000
+#define CONFIG_SYS_MAX_FLASH_SECT	0x20000
+#define CONFIG_SYS_MAX_FLASH_BANKS	1
+#else
 #define CONFIG_SYS_NO_FLASH
+#endif
 
 /*
  * Command line configuration.
-- 
1.8.5.2

^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support
  2014-06-20  8:16 ` [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support Bo Shen
@ 2014-06-30  9:55   ` Andy Pont
  2014-06-30 10:01     ` Bo Shen
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Pont @ 2014-06-30  9:55 UTC (permalink / raw)
  To: u-boot

Hi Bo,

> -/* No NOR flash */
> +/* NOR flash */
> +#define CONFIG_CMD_FLASH
> +
> +#ifdef CONFIG_CMD_FLASH
> +#define CONFIG_SYS_FLASH_CFI
> +#define CONFIG_FLASH_CFI_DRIVER
> +#define CONFIG_SYS_FLASH_BASE		0x10000000
> +#define CONFIG_SYS_MAX_FLASH_SECT	0x20000
> +#define CONFIG_SYS_MAX_FLASH_BANKS	1
> +#else
>  #define CONFIG_SYS_NO_FLASH
> +#endif

The NOR flash device on the SAMA5D3x CPU modules supports hardware sector
protection and according to the flash datasheet: "All blocks power-up in a
locked state to protect array data from being altered during power
transitions".  In order to make your patch set work:

#define CONFIG_SYS_FLASH_PROTECTION

needs adding into the include/configs/sama5d3xek.h file.

Andy.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support
  2014-06-30  9:55   ` Andy Pont
@ 2014-06-30 10:01     ` Bo Shen
  2014-06-30 10:46       ` Andy Pont
  0 siblings, 1 reply; 7+ messages in thread
From: Bo Shen @ 2014-06-30 10:01 UTC (permalink / raw)
  To: u-boot

Hi Andy,

On 06/30/2014 05:55 PM, Andy Pont wrote:
> Hi Bo,
>
>> -/* No NOR flash */
>> +/* NOR flash */
>> +#define CONFIG_CMD_FLASH
>> +
>> +#ifdef CONFIG_CMD_FLASH
>> +#define CONFIG_SYS_FLASH_CFI
>> +#define CONFIG_FLASH_CFI_DRIVER
>> +#define CONFIG_SYS_FLASH_BASE		0x10000000
>> +#define CONFIG_SYS_MAX_FLASH_SECT	0x20000
>> +#define CONFIG_SYS_MAX_FLASH_BANKS	1
>> +#else
>>   #define CONFIG_SYS_NO_FLASH
>> +#endif
>
> The NOR flash device on the SAMA5D3x CPU modules supports hardware sector
> protection and according to the flash datasheet: "All blocks power-up in a
> locked state to protect array data from being altered during power
> transitions".  In order to make your patch set work:
>
> #define CONFIG_SYS_FLASH_PROTECTION
>
> needs adding into the include/configs/sama5d3xek.h file.

Thanks for your information.
I will add it into next version.
Thanks again.

> Andy.
>

Best Regards,
Bo Shen

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support
  2014-06-30 10:01     ` Bo Shen
@ 2014-06-30 10:46       ` Andy Pont
  2014-07-01  3:52         ` Bo Shen
  0 siblings, 1 reply; 7+ messages in thread
From: Andy Pont @ 2014-06-30 10:46 UTC (permalink / raw)
  To: u-boot

Hi Bo,

> >> +#ifdef CONFIG_CMD_FLASH
> >> +#define CONFIG_SYS_FLASH_CFI
> >> +#define CONFIG_FLASH_CFI_DRIVER
> >> +#define CONFIG_SYS_FLASH_BASE		0x10000000
> >> +#define CONFIG_SYS_MAX_FLASH_SECT	0x20000

Is this the correct value for CONFIG_SYS_MAX_FLASH_SECT?  Shouldn't it be
127 (if we ignore the top boot block) or 131 if they are included?

Regards,

Andy.

^ permalink raw reply	[flat|nested] 7+ messages in thread

* [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support
  2014-06-30 10:46       ` Andy Pont
@ 2014-07-01  3:52         ` Bo Shen
  0 siblings, 0 replies; 7+ messages in thread
From: Bo Shen @ 2014-07-01  3:52 UTC (permalink / raw)
  To: u-boot

Hi Andy,

On 06/30/2014 06:46 PM, Andy Pont wrote:
> Hi Bo,
>
>>>> +#ifdef CONFIG_CMD_FLASH
>>>> +#define CONFIG_SYS_FLASH_CFI
>>>> +#define CONFIG_FLASH_CFI_DRIVER
>>>> +#define CONFIG_SYS_FLASH_BASE		0x10000000
>>>> +#define CONFIG_SYS_MAX_FLASH_SECT	0x20000
>
> Is this the correct value for CONFIG_SYS_MAX_FLASH_SECT?  Shouldn't it be
> 127 (if we ignore the top boot block) or 131 if they are included?

oops, I fill this with the sector size.
Thanks point it out. Here, I think we should fill with 131.

> Regards,
>
> Andy.
>

Best Regards,
Bo Shen

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-07-01  3:52 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-06-20  8:15 [U-Boot] [PATCH 0/2] ARM: atmel: sama5d3xek: enable NOR flash support Bo Shen
2014-06-20  8:16 ` [U-Boot] [PATCH 1/2] ARM: atmel: sama5d3xek: add nor flash init function Bo Shen
2014-06-20  8:16 ` [U-Boot] [PATCH 2/2] ARM: atmel: sama5d3xek: enable NOR flash support Bo Shen
2014-06-30  9:55   ` Andy Pont
2014-06-30 10:01     ` Bo Shen
2014-06-30 10:46       ` Andy Pont
2014-07-01  3:52         ` Bo Shen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.