Skip to contentSkip to conversation

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

PATCH Superseded Bo Shen 2 participants 11 messages Nov 1, 2013 – Nov 5, 2013

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

Bo Shen

author
#0 lore raw

v2 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 v2:
- Move spl related code to at91-common folder

Bo Shen (7):
arm: atmel: sama5d3: correct the ID for DBGU and PIT
arm: atmel: sama5: correct the error define of DIV
arm: atmel: the offset of MULA is 18 in sama5d3
arm: atmel: sama5d3: early enable PIO peripherals
arm: atmel: add plla and mck initialize function
arm: atmel: add ddr2 initialization function
spl: mmc: FAT support boot u-boot

 arch/arm/cpu/armv7/Makefile                   |    2 +-
 arch/arm/cpu/armv7/at91/Makefile              |    1 +
 arch/arm/cpu/armv7/at91/clock.c               |   27 ++++++
 arch/arm/cpu/armv7/at91/mpddrc.c              |  123 +++++++++++++++++++++++++
 arch/arm/cpu/armv7/at91/sama5d3_devices.c     |    2 +-
 arch/arm/cpu/armv7/at91/timer.c               |    2 +-
 arch/arm/cpu/at91-common/Makefile             |   32 +++++++
 arch/arm/cpu/at91-common/spl.c                |   39 ++++++++
 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 |  111 ++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/spl.h          |   17 ++++
 board/atmel/sama5d3xek/sama5d3xek.c           |   99 ++++++++++++++++++++
 include/configs/sama5d3xek.h                  |   37 ++++++++
 spl/Makefile                                  |    4 +
 16 files changed, 553 insertions(+), 5 deletions(-)
 create mode 100644 arch/arm/cpu/armv7/at91/mpddrc.c
 create mode 100644 arch/arm/cpu/at91-common/Makefile
 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 v2 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 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
author
#2 lore raw

PATCH v2 2/7 arm: atmel: sama5: correct the error define of DIV

In reply to Bo Shen

Correct the error define of DIV.

---
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 003920c..ed5462c 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
author
#3 lore raw

PATCH v2 3/7 arm: atmel: the offset of MULA is 18 in sama5d3

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 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 ed5462c..c063213 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
author
#4 lore raw

PATCH v2 4/7 arm: atmel: sama5d3: early enable PIO peripherals

In reply to Bo Shen

Enable the PIO peripherals early than other peripherals.

---
Changes in v2:
- None

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

PATCH v2 4/7 arm: atmel: sama5d3: early enable PIO peripherals

Hi Andreas,

Quoted 16 lines · Bo Shen

Enable the PIO peripherals early than other peripherals.

---
Changes in v2:
- None

  board/atmel/sama5d3xek/sama5d3xek.c |    3 +++
  1 file changed, 3 insertions(+)
board/atmel/sama5d3xek/sama5d3xek.c +0 -0
index b0965ef..7fa3ae7 100644

board/atmel/sama5d3xek/sama5d3xek.c void lcd_show_board_info(void) · line 162

Quoted 5 lines
board/atmel/sama5d3xek/sama5d3xek.c +2 -0
@@ -158,6 +158,9 @@ void lcd_show_board_info(void)
 
  int board_early_init_f(void)
  {
+	at91_periph_clk_enable(ATMEL_ID_PIOA | ATMEL_ID_PIOB | ATMEL_ID_PIOC |
+			       ATMEL_ID_PIOD | ATMEL_ID_PIOE);

This code is wrong, it should be as following:
--->8---
at91_periph_clk_enable(ATMEL_ID_PIOA);
at91_periph_clk_enable(ATMEL_ID_PIOB);
....
at91_periph_clk_enable(ATMEL_ID_PIOE);
---8<---

board/atmel/sama5d3xek/sama5d3xek.c void lcd_show_board_info(void) · line 166

Quoted 3 lines
board/atmel/sama5d3xek/sama5d3xek.c +0 -0
  	at91_seriald_hw_init();
 
  	return 0;

Best Regards,
Bo Shen

author
#6 lore raw

PATCH v2 5/7 arm: atmel: add plla and mck initialize function

In reply to Bo Shen

Add plla and mck initialize function.

---
Changes in v2:
- None

 arch/arm/cpu/armv7/at91/clock.c              |   27 ++++++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/at91_common.h |    2 ++
 2 files changed, 29 insertions(+)
arch/arm/cpu/armv7/at91/clock.c +27 -0
index 1588e0c..d392f54 100644
@@ -120,3 +120,30 @@ void at91_periph_clk_enable(int id)
 	else
 		writel(1 << id, &pmc->pcer);
 }
+
+void at91_plla_init(u32 pllar)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+
+	writel(pllar, &pmc->pllar);
+	while (!(readl(&pmc->sr) & (AT91_PMC_LOCKA | AT91_PMC_MCKRDY)))
+		;
+}
+
+void at91_mck_init(u32 mckr)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+	u32 tmp;
+
+	tmp = readl(&pmc->mckr);
+	tmp &= ~(AT91_PMC_MCKR_PRES_MASK |
+		 AT91_PMC_MCKR_MDIV_MASK |
+		 AT91_PMC_MCKR_PLLADIV_2);
+	tmp |= mckr & (AT91_PMC_MCKR_PRES_MASK |
+		       AT91_PMC_MCKR_MDIV_MASK |
+		       AT91_PMC_MCKR_PLLADIV_2);
+	writel(tmp, &pmc->mckr);
+
+	while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+		;
+}
arch/arm/include/asm/arch-at91/at91_common.h +2 -0
index abcb97d..728a9fb 100644
@@ -22,5 +22,7 @@ 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);
 
 #endif /* AT91_COMMON_H */
Signature · 1 line
1.7.9.5
author
#7 lore raw

PATCH v2 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 v2:
- None

 arch/arm/cpu/armv7/at91/Makefile              |    1 +
 arch/arm/cpu/armv7/at91/mpddrc.c              |  123 +++++++++++++++++++++++++
 arch/arm/include/asm/arch-at91/atmel_mpddrc.h |  111 ++++++++++++++++++++++
 3 files changed, 235 insertions(+)
 create mode 100644 arch/arm/cpu/armv7/at91/mpddrc.c
 create mode 100644 arch/arm/include/asm/arch-at91/atmel_mpddrc.h
arch/arm/cpu/armv7/at91/Makefile +1 -0
index 90b9bd6..4a02d06 100644
@@ -17,6 +17,7 @@ COBJS-y += clock.o
 COBJS-y += cpu.o
 COBJS-y += reset.o
 COBJS-y += timer.o
+COBJS-$(CONFIG_SPL_BUILD) += mpddrc.o
 
 SRCS    := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
 OBJS    := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
arch/arm/cpu/armv7/at91/mpddrc.c new file +123 -0

123 lines not on this page · raw message

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

111 lines not on this page · raw message

Signature · 1 line
1.7.9.5
author
#8 lore raw

PATCH v2 7/7 spl: mmc: FAT support boot u-boot

In reply to Bo Shen

Enable SPL support which can load u-boot from SD card in FAT format.

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

 arch/arm/cpu/armv7/Makefile                  |    2 +-
 arch/arm/cpu/at91-common/Makefile            |   32 +++++++++
 arch/arm/cpu/at91-common/spl.c               |   39 +++++++++++
 arch/arm/cpu/at91-common/u-boot-spl.lds      |   50 ++++++++++++++
 arch/arm/include/asm/arch-at91/at91_common.h |    2 +
 arch/arm/include/asm/arch-at91/spl.h         |   17 +++++
 board/atmel/sama5d3xek/sama5d3xek.c          |   96 ++++++++++++++++++++++++++
 include/configs/sama5d3xek.h                 |   37 ++++++++++
 spl/Makefile                                 |    4 ++
 9 files changed, 278 insertions(+), 1 deletion(-)
 create mode 100644 arch/arm/cpu/at91-common/Makefile
 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 ee4b021..aea4e8b 100644
@@ -16,7 +16,7 @@ COBJS	+= cache_v7.o
 COBJS	+= cpu.o
 COBJS	+= 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),)
 SOBJS	+= lowlevel_init.o
 endif
 
arch/arm/cpu/at91-common/Makefile new file +32 -0
new file mode 100644
index 0000000..5c17f80
@@ -0,0 +1,32 @@
+#
+# (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+
+#
+
+include $(TOPDIR)/config.mk
+
+LIB	= $(obj)libat91-common.o
+
+COBJS-$(CONFIG_SPL_BUILD) += spl.o
+
+SRCS    := $(SOBJS-y:.o=.S) $(COBJS-y:.o=.c)
+OBJS    := $(addprefix $(obj),$(SOBJS-y) $(COBJS-y))
+
+all:	$(obj).depend $(LIB)
+
+$(LIB):	$(OBJS)
+	$(call cmd_link_o_target, $(OBJS))
+
+#########################################################################
+
+# defines $(obj).depend target
+include $(SRCTREE)/rules.mk
+
+sinclude $(obj).depend
+
+#########################################################################
arch/arm/cpu/at91-common/spl.c new file +39 -0
new file mode 100644
index 0000000..8276ec4
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2013 Atmel Corporation
+ *		      Bo Shen <[email protected]>
+ *
+ * SPDX-License-Identifier:	GPL-2.0+
+ */
+
+#include <common.h>
+#include <asm/io.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/at91_wdt.h>
+#include <asm/arch/clk.h>
+#include <spl.h>
+
+static void at91_disable_wdt(void)
+{
+	struct at91_wdt *wdt = (struct at91_wdt *)ATMEL_BASE_WDT;
+
+	writel(AT91_WDT_MR_WDDIS, &wdt->mr);
+}
+
+void s_init(void)
+{
+	/* disable watchdog */
+	at91_disable_wdt();
+
+	/* PMC configuration */
+	at91_pmc_init();
+
+	at91_clock_init(CONFIG_SYS_AT91_MAIN_CLOCK);
+
+	timer_init();
+
+	board_early_init_f();
+
+	preloader_console_init();
+
+	mem_init();
+}
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 +2 -0
index 728a9fb..3ca4d5b 100644
@@ -24,5 +24,7 @@ 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 +17 -0
new file mode 100644
index 0000000..5bbd4fc
@@ -0,0 +1,17 @@
+/*
+ * 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_MMC1,
+	BOOT_DEVICE_MMC2,
+	BOOT_DEVICE_MMC2_2,
+};
+
+#endif
board/atmel/sama5d3xek/sama5d3xek.c +96 -0

105 lines not on this page · raw message

include/configs/sama5d3xek.h +37 -0
index 79c0068..802f245 100644
@@ -25,7 +25,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
 
@@ -94,8 +97,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,34 @@
 /* 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_LDSCRIPT		arch/arm/cpu/at91-common/u-boot-spl.lds
+
+#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
+#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
spl/Makefile +4 -0
index b366ac2..6dd1e5d 100644
@@ -123,6 +123,10 @@ ifeq ($(SOC),exynos)
 LIBS-y += $(CPUDIR)/s5p-common/libs5p-common.o
 endif
 
+ifeq ($(SOC),at91)
+LIBS-y += arch/$(ARCH)/cpu/at91-common/libat91-common.o
+endif
+
 # Add GCC lib
 ifeq ("$(USE_PRIVATE_LIBGCC)", "yes")
 PLATFORM_LIBGCC = $(SPLTREE)/arch/$(ARCH)/lib/libgcc.o
Signature · 1 line
1.7.9.5
#9 lore raw

PATCH v2 7/7 spl: mmc: FAT support boot u-boot

Dear Bo Shen,

Quoted 1 line · In message <[email protected]> you wrote:

Enable SPL support which can load u-boot from SD card in FAT format.

I am sorry, but both the Subject: and the commit message are totally cryptic to me - what does this mean? Is this a bug fix, or a new feature? Does this affect all systems, or only a few? Which ones?

Please provide a descrip[tion thatg makes clear what the patch is supposed to do.

Thanks.

Best regards,

Wolfgang Denk

Signature · 5 lines
DENX Software Engineering GmbH,     MD: Wolfgang Denk & Detlev Zundel
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd at denx.de
Plans break down. You cannot plan the future. Only presumptuous fools
plan. The wise man _steers_.        - Terry Pratchett, _Making_Money_
author
#10 lore raw

PATCH v2 7/7 spl: mmc: FAT support boot u-boot

Hi Wolfgang Denk,

Quoted 9 lines · Wolfgang Denk

Dear Bo Shen,

Quoted 1 line · In message <[email protected]> you wrote:

Enable SPL support which can load u-boot from SD card in FAT format.

I am sorry, but both the Subject: and the commit message are totally cryptic to me - what does this mean? Is this a bug fix, or a new feature? Does this affect all systems, or only a few? Which ones?

Oh, sorry to make you misunderstand for this patch.
This patch is for Atmel sama5d3xek board to support SPL boot, which can boot from SD card in FAT file system.

After finished review, I will correct the subject and send this patch again.

Quoted 9 lines

Please provide a descrip[tion thatg makes clear what the patch is supposed to do.

Thanks.

Best regards,

Wolfgang Denk

Best Regards,
Bo Shen