Skip to contentSkip to conversation

arm: atmel: sama5d3: enable spl boot from SD card

PATCH New Bo Shen 2 participants 15 messages Nov 15, 2013 – Dec 1, 2013

Subsystems (2)
lore
Share & tools
lore

Bo Shen

author
#0 lore raw

v4 cover arm: atmel: sama5d3: enable spl boot from SD card

This patch series enable spl boot from SD card, it only can boot u-boot itself.

Changes in v4:
- Using blank replace table after defined
- Align the register define with datasheet
- constify the ram_address and ddr configuration value
- Add comments to DDR refresh timing register.

Changes in v3:
- Correct the clock enable code, the ID can not OR
- Move to at91 common folder
- Move plla and mck configure to spl.c file

Changes in v2:
- Move spl related code to at91-common folder

Bo Shen (7):
arm: atmel: sama5d3: correct the ID for DBGU and PIT
arm: at91: pm9261: remove undefined bit in mckr
arm: atmel: sama5d3: correct the error define of DIV
arm: atmel: sama5d3: the offset of MULA is 18
arm: atmel: sama5d3: early enable PIO peripherals
arm: atmel: add ddr2 initialization function
arm: atmel: sama5d3: spl boot from fat fs SD card

 arch/arm/cpu/Makefile                         |    1 +
 arch/arm/cpu/armv7/Makefile                   |    2 +-
 arch/arm/cpu/armv7/at91/sama5d3_devices.c     |    2 +-
 arch/arm/cpu/armv7/at91/timer.c               |    2 +-
 arch/arm/cpu/at91-common/Makefile             |   11 +++
 arch/arm/cpu/at91-common/mpddrc.c             |  124 +++++++++++++++++++++++++
 arch/arm/cpu/at91-common/spl.c                |   90 ++++++++++++++++++
 arch/arm/cpu/at91-common/u-boot-spl.lds       |   50 ++++++++++
 arch/arm/include/asm/arch-at91/at91_common.h  |    4 +
 arch/arm/include/asm/arch-at91/at91_pmc.h     |    8 +-
 arch/arm/include/asm/arch-at91/atmel_mpddrc.h |  115 +++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/spl.h          |   20 ++++
 board/atmel/sama5d3xek/sama5d3xek.c           |   91 ++++++++++++++++++
 include/configs/pm9261.h                      |    6 +-
 include/configs/sama5d3xek.h                  |   34 +++++++
 15 files changed, 551 insertions(+), 9 deletions(-)
 create mode 100644 arch/arm/cpu/at91-common/Makefile
 create mode 100644 arch/arm/cpu/at91-common/mpddrc.c
 create mode 100644 arch/arm/cpu/at91-common/spl.c
 create mode 100644 arch/arm/cpu/at91-common/u-boot-spl.lds
 create mode 100644 arch/arm/include/asm/arch-at91/atmel_mpddrc.h
 create mode 100644 arch/arm/include/asm/arch-at91/spl.h
Signature · 1 line
1.7.9.5
author
#1 lore raw

PATCH v4 1/7 arm: atmel: sama5d3: correct the ID for DBGU and PIT

As the DBGU and PIT has its own ID on sama5d3 SoC, while not share with SYS ID. So, correct them.

---
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- None

 arch/arm/cpu/armv7/at91/sama5d3_devices.c |    2 +-
 arch/arm/cpu/armv7/at91/timer.c           |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)
arch/arm/cpu/armv7/at91/sama5d3_devices.c +1 -1
index 51f0a6d..ebe99d2 100644
@@ -82,7 +82,7 @@ void at91_seriald_hw_init(void)
 	at91_set_a_periph(AT91_PIO_PORTB, 30, 0);	/* DRXD */
 
 	/* Enable clock */
-	at91_periph_clk_enable(ATMEL_ID_SYS);
+	at91_periph_clk_enable(ATMEL_ID_DBGU);
 }
 
 #if defined(CONFIG_ATMEL_SPI)
arch/arm/cpu/armv7/at91/timer.c +1 -1
index 3808aed..e3ebfe0 100644
@@ -60,7 +60,7 @@ int timer_init(void)
 	at91_pit_t *pit = (at91_pit_t *)ATMEL_BASE_PIT;
 
 	/* Enable PITC Clock */
-	at91_periph_clk_enable(ATMEL_ID_SYS);
+	at91_periph_clk_enable(ATMEL_ID_PIT);
 
 	/* Enable PITC */
 	writel(TIMER_LOAD_VAL | AT91_PIT_MR_EN , &pit->mr);
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v4 1/7 arm: atmel: sama5d3: correct the ID for DBGU and PIT

Dear Bo Shen,

Quoted 13 lines · Bo Shen

As the DBGU and PIT has its own ID on sama5d3 SoC, while not share with SYS ID. So, correct them.

---
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- None

Quoted 3 lines
arch/arm/cpu/armv7/at91/sama5d3_devices.c |    2 +-
arch/arm/cpu/armv7/at91/timer.c           |    2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

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

Best regards,
Andreas Bie?mann

author
#3 lore raw

PATCH v4 2/7 arm: at91: pm9261: remove undefined bit in mckr

In reply to Bo Shen

The PLLADIV2 bit is not defined in at91sam9261 SoC, so remove it.

---
Changes in v4:
- New
Changes in v3:
- None
Changes in v2:
- None

 include/configs/pm9261.h |    6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)
include/configs/pm9261.h +2 -4
index fc95cf0..acf6d61 100644
@@ -50,15 +50,13 @@
 #define	CONFIG_SYS_MCKR1_VAL		\
 		(AT91_PMC_MCKR_CSS_SLOW |	\
 		 AT91_PMC_MCKR_PRES_1 |	\
-		 AT91_PMC_MCKR_MDIV_2 |	\
-		 AT91_PMC_MCKR_PLLADIV_1)
+		 AT91_PMC_MCKR_MDIV_2)
 
 /* PCK/2 = MCK Master Clock from PLLA */
 #define	CONFIG_SYS_MCKR2_VAL		\
 		(AT91_PMC_MCKR_CSS_PLLA |	\
 		 AT91_PMC_MCKR_PRES_1 |	\
-		 AT91_PMC_MCKR_MDIV_2 |	\
-		 AT91_PMC_MCKR_PLLADIV_1)
+		 AT91_PMC_MCKR_MDIV_2)
 
 /* define PDC[31:16] as DATA[31:16] */
 #define CONFIG_SYS_PIOC_PDR_VAL1	0xFFFF0000
Signature · 1 line
1.7.9.5
#4 lore raw

PATCH v4 2/7 arm: at91: pm9261: remove undefined bit in mckr

Dear Bo Shen,

Quoted 12 lines · Bo Shen

The PLLADIV2 bit is not defined in at91sam9261 SoC, so remove it.

---
Changes in v4:
- New
Changes in v3:
- None
Changes in v2:
- None

Quoted 2 lines

include/configs/pm9261.h | 6 ++----

1 file changed, 2 insertions(+), 4 deletions(-)

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

Best regards,
Andreas Bie?mann

author
#5 lore raw

PATCH v4 3/7 arm: atmel: sama5d3: correct the error define of DIV

In reply to Bo Shen

Correct the error define of DIV.

---
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- None

 arch/arm/include/asm/arch-at91/at91_pmc.h |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
arch/arm/include/asm/arch-at91/at91_pmc.h +2 -2
index 7b36f74..3efdc37 100644
@@ -124,8 +124,8 @@ typedef struct at91_pmc {
 #define AT91_PMC_MCKR_MDIV_MASK		0x00000300
 #endif
 
-#define AT91_PMC_MCKR_PLLADIV_1		0x00001000
-#define AT91_PMC_MCKR_PLLADIV_2		0x00002000
+#define AT91_PMC_MCKR_PLLADIV_1		0x00000000
+#define AT91_PMC_MCKR_PLLADIV_2		0x00001000
 
 #define AT91_PMC_IXR_MOSCS		0x00000001
 #define AT91_PMC_IXR_LOCKA		0x00000002
Signature · 1 line
1.7.9.5
#6 lore raw

PATCH v4 3/7 arm: atmel: sama5d3: correct the error define of DIV

Dear Bo Shen,

Quoted 12 lines · Bo Shen

Correct the error define of DIV.

---
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- None

Quoted 2 lines

arch/arm/include/asm/arch-at91/at91_pmc.h | 4 ++--

1 file changed, 2 insertions(+), 2 deletions(-)

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

Best regards,
Andreas Bie?mann

author
#7 lore raw

PATCH v4 4/7 arm: atmel: sama5d3: the offset of MULA is 18

In reply to Bo Shen

The offset of MULA field in PLLA register in sama5d3 is 18, and the length only 7 bits.

---
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- None

 arch/arm/include/asm/arch-at91/at91_pmc.h |    4 ++++
 1 file changed, 4 insertions(+)
arch/arm/include/asm/arch-at91/at91_pmc.h +4 -0
index 3efdc37..b6e542e 100644
@@ -73,7 +73,11 @@ typedef struct at91_pmc {
 #define AT91_PMC_PLLXR_DIV(x)		(x & 0xFF)
 #define AT91_PMC_PLLXR_PLLCOUNT(x)	((x & 0x3F) << 8)
 #define AT91_PMC_PLLXR_OUT(x)		((x & 0x03) << 14)
+#ifdef CONFIG_SAMA5D3
+#define AT91_PMC_PLLXR_MUL(x)		((x & 0x7F) << 18)
+#else
 #define AT91_PMC_PLLXR_MUL(x)		((x & 0x7FF) << 16)
+#endif
 #define AT91_PMC_PLLAR_29		0x20000000
 #define AT91_PMC_PLLBR_USBDIV_1		0x00000000
 #define AT91_PMC_PLLBR_USBDIV_2		0x10000000
Signature · 1 line
1.7.9.5
#8 lore raw

PATCH v4 4/7 arm: atmel: sama5d3: the offset of MULA is 18

Dear Bo Shen,

Quoted 13 lines · Bo Shen

The offset of MULA field in PLLA register in sama5d3 is 18, and the length only 7 bits.

---
Changes in v4:
- None
Changes in v3:
- None
Changes in v2:
- None

Quoted 2 lines

arch/arm/include/asm/arch-at91/at91_pmc.h | 4 ++++

1 file changed, 4 insertions(+)

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

Best regards,
Andreas Bie?mann

author
#9 lore raw

PATCH v4 5/7 arm: atmel: sama5d3: early enable PIO peripherals

In reply to Bo Shen

Enable the PIO peripherals early than other peripherals.

---
Changes in v4:
- None
Changes in v3:
- Correct the clock enable code, the ID can not OR

Changes in v2:
- None

 board/atmel/sama5d3xek/sama5d3xek.c |    6 ++++++
 1 file changed, 6 insertions(+)
board/atmel/sama5d3xek/sama5d3xek.c +6 -0
index b0965ef..f245f98 100644
@@ -158,6 +158,12 @@ void lcd_show_board_info(void)
 
 int board_early_init_f(void)
 {
+	at91_periph_clk_enable(ATMEL_ID_PIOA);
+	at91_periph_clk_enable(ATMEL_ID_PIOB);
+	at91_periph_clk_enable(ATMEL_ID_PIOC);
+	at91_periph_clk_enable(ATMEL_ID_PIOD);
+	at91_periph_clk_enable(ATMEL_ID_PIOE);
+
 	at91_seriald_hw_init();
 
 	return 0;
Signature · 1 line
1.7.9.5
#10 lore raw

PATCH v4 5/7 arm: atmel: sama5d3: early enable PIO peripherals

Dear Bo Shen,

Quoted 10 lines · Bo Shen

Enable the PIO peripherals early than other peripherals.

---
Changes in v4:
- None
Changes in v3:
- Correct the clock enable code, the ID can not OR

Quoted 5 lines

Changes in v2:
- None

board/atmel/sama5d3xek/sama5d3xek.c | 6 ++++++

1 file changed, 6 insertions(+)

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

Best regards,
Andreas Bie?mann

author
#11 lore raw

PATCH v4 6/7 arm: atmel: add ddr2 initialization function

In reply to Bo Shen

The MPDDRC supports different type of SDRAM
This patch add ddr2 initialization function

---
Changes in v4:
- Using blank replace table after defined
- Align the register define with datasheet
- constify the ram_address and ddr configuration value

Changes in v3:
- Move to at91 common folder

Changes in v2:
- None

 arch/arm/cpu/Makefile                         |    1 +
 arch/arm/cpu/at91-common/Makefile             |   11 +++
 arch/arm/cpu/at91-common/mpddrc.c             |  124 +++++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/atmel_mpddrc.h |  115 +++++++++++++++++++++++
 4 files changed, 251 insertions(+)
 create mode 100644 arch/arm/cpu/at91-common/Makefile
 create mode 100644 arch/arm/cpu/at91-common/mpddrc.c
 create mode 100644 arch/arm/include/asm/arch-at91/atmel_mpddrc.h
arch/arm/cpu/Makefile +1 -0
index fd0da53..b2d30b1 100644
@@ -1,2 +1,3 @@
+obj-$(CONFIG_AT91FAMILY) += at91-common/
 obj-$(CONFIG_TEGRA) += $(SOC)-common/
 obj-$(CONFIG_TEGRA) += tegra-common/
arch/arm/cpu/at91-common/Makefile new file +11 -0
new file mode 100644
index 0000000..671a05e
@@ -0,0 +1,11 @@
+#
+# (C) Copyright 2000-2008
+# Wolfgang Denk, DENX Software Engineering, wd at denx.de.
+#
+# (C) Copyright 2013 Atmel Corporation
+#		     Bo Shen <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-$(CONFIG_SPL_BUILD) += mpddrc.o
arch/arm/cpu/at91-common/mpddrc.c new file +124 -0

124 lines not on this page · raw message

arch/arm/include/asm/arch-at91/atmel_mpddrc.h new file +115 -0

115 lines not on this page · raw message

Signature · 1 line
1.7.9.5
#12 lore raw

PATCH v4 6/7 arm: atmel: add ddr2 initialization function

Dear Bo Shen,

Quoted 17 lines · Bo Shen

The MPDDRC supports different type of SDRAM
This patch add ddr2 initialization function

---
Changes in v4:
- Using blank replace table after defined
- Align the register define with datasheet
- constify the ram_address and ddr configuration value

Changes in v3:
- Move to at91 common folder

Changes in v2:
- None

Quoted 8 lines
arch/arm/cpu/Makefile                         |    1 +
arch/arm/cpu/at91-common/Makefile             |   11 +++
arch/arm/cpu/at91-common/mpddrc.c             |  124 +++++++++++++++++++++++++
arch/arm/include/asm/arch-at91/atmel_mpddrc.h |  115 +++++++++++++++++++++++
4 files changed, 251 insertions(+)

create mode 100644 arch/arm/cpu/at91-common/Makefile create mode 100644 arch/arm/cpu/at91-common/mpddrc.c create mode 100644 arch/arm/include/asm/arch-at91/atmel_mpddrc.h

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

Best regards,
Andreas Bie?mann

author
#13 lore raw

PATCH v4 7/7 arm: atmel: sama5d3: spl boot from fat fs SD card

In reply to Bo Shen

Enable Atmel sama5d3xek boart spl boot support, which can load u-boot from SD card with FAT file system.

---
Changes in v4:
- Add comments to DDR refresh timing register.

Changes in v3:
- Move plla and mck configure to spl.c file

Changes in v2:
- Move spl related code to at91-common folder

 arch/arm/cpu/armv7/Makefile                  |    2 +-
 arch/arm/cpu/at91-common/Makefile            |    2 +-
 arch/arm/cpu/at91-common/spl.c               |   90 ++++++++++++++++++++++++++
 arch/arm/cpu/at91-common/u-boot-spl.lds      |   50 ++++++++++++++
 arch/arm/include/asm/arch-at91/at91_common.h |    4 ++
 arch/arm/include/asm/arch-at91/spl.h         |   20 ++++++
 board/atmel/sama5d3xek/sama5d3xek.c          |   85 ++++++++++++++++++++++++
 include/configs/sama5d3xek.h                 |   34 ++++++++++
 8 files changed, 285 insertions(+), 2 deletions(-)
 create mode 100644 arch/arm/cpu/at91-common/spl.c
 create mode 100644 arch/arm/cpu/at91-common/u-boot-spl.lds
 create mode 100644 arch/arm/include/asm/arch-at91/spl.h
arch/arm/cpu/armv7/Makefile +1 -1
index d3347b3..0467d00 100644
@@ -12,7 +12,7 @@ obj-y	+= cache_v7.o
 obj-y	+= cpu.o
 obj-y	+= syslib.o
 
-ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX),)
+ifneq ($(CONFIG_AM43XX)$(CONFIG_AM33XX)$(CONFIG_OMAP44XX)$(CONFIG_OMAP54XX)$(CONFIG_TEGRA)$(CONFIG_MX6)$(CONFIG_TI81XX)$(CONFIG_AT91FAMILY),)
 ifneq ($(CONFIG_SKIP_LOWLEVEL_INIT),y)
 obj-y	+= lowlevel_init.o
 endif
arch/arm/cpu/at91-common/Makefile +1 -1
index 671a05e..d97053f 100644
@@ -8,4 +8,4 @@
 # SPDX-License-Identifier:	GPL-2.0+
 #
 
-obj-$(CONFIG_SPL_BUILD) += mpddrc.o
+obj-$(CONFIG_SPL_BUILD) += mpddrc.o spl.o
arch/arm/cpu/at91-common/spl.c new file +90 -0

90 lines not on this page · raw message

arch/arm/cpu/at91-common/u-boot-spl.lds new file +50 -0

50 lines not on this page · raw message

arch/arm/include/asm/arch-at91/at91_common.h +4 -0
index abcb97d..3ca4d5b 100644
@@ -22,5 +22,9 @@ void at91_spi1_hw_init(unsigned long cs_mask);
 void at91_udp_hw_init(void);
 void at91_uhp_hw_init(void);
 void at91_lcd_hw_init(void);
+void at91_plla_init(u32 pllar);
+void at91_mck_init(u32 mckr);
+void at91_pmc_init(void);
+void mem_init(void);
 
 #endif /* AT91_COMMON_H */
arch/arm/include/asm/arch-at91/spl.h new file +20 -0
new file mode 100644
index 0000000..68c5349
@@ -0,0 +1,20 @@
+/*
+ * Copyright (C) 2013 Atmel Corporation
+ *		      Bo Shen <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#ifndef	_ASM_ARCH_SPL_H_
+#define	_ASM_ARCH_SPL_H_
+
+enum {
+	BOOT_DEVICE_NONE,
+#ifdef CONFIG_SYS_USE_MMC
+	BOOT_DEVICE_MMC1,
+	BOOT_DEVICE_MMC2,
+	BOOT_DEVICE_MMC2_2,
+#endif
+};
+
+#endif
board/atmel/sama5d3xek/sama5d3xek.c +85 -0

94 lines not on this page · raw message

include/configs/sama5d3xek.h +34 -0
index 5a6f0fc..c34feb5 100644
@@ -24,7 +24,10 @@
 #define CONFIG_AT91FAMILY
 #define CONFIG_ARCH_CPU_INIT
 
+#ifndef CONFIG_SPL_BUILD
 #define CONFIG_SKIP_LOWLEVEL_INIT
+#endif
+
 #define CONFIG_BOARD_EARLY_INIT_F
 #define CONFIG_DISPLAY_CPUINFO
 
@@ -93,8 +96,12 @@
 #define CONFIG_SYS_SDRAM_BASE           ATMEL_BASE_DDRCS
 #define CONFIG_SYS_SDRAM_SIZE		0x20000000
 
+#ifdef CONFIG_SPL_BUILD
+#define CONFIG_SYS_INIT_SP_ADDR		0x310000
+#else
 #define CONFIG_SYS_INIT_SP_ADDR \
 	(CONFIG_SYS_SDRAM_BASE + 4 * 1024 - GENERATED_GBL_DATA_SIZE)
+#endif
 
 /* SerialFlash */
 #define CONFIG_CMD_SF
@@ -235,4 +242,31 @@
 /* Size of malloc() pool */
 #define CONFIG_SYS_MALLOC_LEN		(1024 * 1024)
 
+/* SPL */
+#define CONFIG_SPL
+#define CONFIG_SPL_FRAMEWORK
+#define CONFIG_SPL_TEXT_BASE		0x300000
+#define CONFIG_SPL_MAX_SIZE		0x10000
+#define CONFIG_SPL_BSS_START_ADDR	0x20000000
+#define CONFIG_SPL_BSS_MAX_SIZE		0x80000
+#define CONFIG_SYS_SPL_MALLOC_START	0x20080000
+#define CONFIG_SYS_SPL_MALLOC_SIZE	0x80000
+
+#define CONFIG_SPL_LIBCOMMON_SUPPORT
+#define CONFIG_SPL_LIBGENERIC_SUPPORT
+#define CONFIG_SPL_GPIO_SUPPORT
+#define CONFIG_SPL_SERIAL_SUPPORT
+
+#define CONFIG_SPL_BOARD_INIT
+#ifdef CONFIG_SYS_USE_MMC
+#define CONFIG_SPL_LDSCRIPT		arch/arm/cpu/at91-common/u-boot-spl.lds
+#define CONFIG_SPL_MMC_SUPPORT
+#define CONFIG_SYS_U_BOOT_MAX_SIZE_SECTORS	0x400
+#define CONFIG_SYS_MMCSD_RAW_MODE_U_BOOT_SECTOR 0x200
+#define CONFIG_SYS_MMC_SD_FAT_BOOT_PARTITION	1
+#define CONFIG_SPL_FAT_LOAD_PAYLOAD_NAME	"u-boot.img"
+#define CONFIG_SPL_FAT_SUPPORT
+#define CONFIG_SPL_LIBDISK_SUPPORT
+#endif
+
 #endif
Signature · 1 line
1.7.9.5
#14 lore raw

PATCH v4 7/7 arm: atmel: sama5d3: spl boot from fat fs SD card

Dear Bo Shen,

Quoted 24 lines · Bo Shen

Enable Atmel sama5d3xek boart spl boot support, which can load u-boot from SD card with FAT file system.

---
Changes in v4:
- Add comments to DDR refresh timing register.

Changes in v3:
- Move plla and mck configure to spl.c file

Changes in v2:
- Move spl related code to at91-common folder

arch/arm/cpu/armv7/Makefile                  |    2 +-
arch/arm/cpu/at91-common/Makefile            |    2 +-
arch/arm/cpu/at91-common/spl.c               |   90 ++++++++++++++++++++++++++
arch/arm/cpu/at91-common/u-boot-spl.lds      |   50 ++++++++++++++
arch/arm/include/asm/arch-at91/at91_common.h |    4 ++
arch/arm/include/asm/arch-at91/spl.h         |   20 ++++++
board/atmel/sama5d3xek/sama5d3xek.c          |   85 ++++++++++++++++++++++++
include/configs/sama5d3xek.h                 |   34 ++++++++++
8 files changed, 285 insertions(+), 2 deletions(-)
Quoted 3 lines

create mode 100644 arch/arm/cpu/at91-common/spl.c create mode 100644 arch/arm/cpu/at91-common/u-boot-spl.lds create mode 100644 arch/arm/include/asm/arch-at91/spl.h

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

Best regards,
Andreas Bie?mann