Skip to contentSkip to conversation

board: atmel: Add new board: SAMA5D27-SOM1-EK board.

PATCH Superseded Wenyou Yang 3 participants 15 messages Jul 20, 2017 – Jul 31, 2017

Subsystems (3)

v1 of 6 Superseded Latest is v6 →

lore
Share & tools
lore
#0 lore raw

cover board: atmel: Add new board: SAMA5D27-SOM1-EK board.

It is based on

	[PATCH v2 0/8] sf: improve support of (Q)SPI flash memories
	https://lists.denx.de/pipermail/u-boot/2017-July/298806.html

Wenyou Yang (6):
ARM: at91: spl: Adjust switching to oscillator for SAMA5D2
ARM: at91: spl: Add mck function to lower rate while switching
ARM: at91: spl: Add boot device for boot from QSPI
ARM: at91: mach: Add missing defines of MPDDRC
ARM: at91: Get the Chip ID of SAMA5D2 SiP
board: atmel: Add SAMA5D27 SOM1 EK board

 arch/arm/dts/Makefile                           |   3 +
 arch/arm/dts/at91-sama5d27_som1_ek.dts          | 155 ++++++++++++++++++
 arch/arm/dts/sama5d2.dtsi                       |  20 +++
 arch/arm/dts/sama5d27_som1.dtsi                 | 154 ++++++++++++++++++
 arch/arm/mach-at91/Kconfig                      |   7 +
 arch/arm/mach-at91/armv7/clock.c                |  36 +++++
 arch/arm/mach-at91/armv7/sama5d2_devices.c      |  26 ++-
 arch/arm/mach-at91/include/mach/at91_common.h   |   1 +
 arch/arm/mach-at91/include/mach/at91_pmc.h      |   2 +
 arch/arm/mach-at91/include/mach/atmel_mpddrc.h  |   4 +
 arch/arm/mach-at91/include/mach/sama5d2.h       |   7 +-
 arch/arm/mach-at91/spl.c                        |   2 +
 arch/arm/mach-at91/spl_atmel.c                  |  18 ++-
 board/atmel/sama5d27_som1_ek/Kconfig            |  15 ++
 board/atmel/sama5d27_som1_ek/MAINTAINERS        |   6 +
 board/atmel/sama5d27_som1_ek/Makefile           |   8 +
 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 206 ++++++++++++++++++++++++
 configs/sama5d27_som1_ek_mmc_defconfig          |  82 ++++++++++
 configs/sama5d27_som1_ek_spiflash_defconfig     |  82 ++++++++++
 include/configs/sama5d27_som1_ek.h              | 100 ++++++++++++
 20 files changed, 930 insertions(+), 4 deletions(-)
 create mode 100644 arch/arm/dts/at91-sama5d27_som1_ek.dts
 create mode 100644 arch/arm/dts/sama5d27_som1.dtsi
 create mode 100644 board/atmel/sama5d27_som1_ek/Kconfig
 create mode 100644 board/atmel/sama5d27_som1_ek/MAINTAINERS
 create mode 100644 board/atmel/sama5d27_som1_ek/Makefile
 create mode 100644 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
 create mode 100644 configs/sama5d27_som1_ek_mmc_defconfig
 create mode 100644 configs/sama5d27_som1_ek_spiflash_defconfig
 create mode 100644 include/configs/sama5d27_som1_ek.h
Signature · 1 line
2.13.0
#1 lore raw

PATCH 1/6 ARM: at91: spl: Adjust switching to oscillator for SAMA5D2

As said in 29.5.7 section of SAMA5D2 datasheet, before switching to the crystal oscillator, a check must be carried out to ensure that the oscillator is present and that its freqency is valid.

---

 arch/arm/mach-at91/include/mach/at91_pmc.h |  2 ++
 arch/arm/mach-at91/spl_atmel.c             | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
arch/arm/mach-at91/include/mach/at91_pmc.h +2 -0
index 2875ff20b1..08ad1bf2d0 100644
@@ -87,6 +87,8 @@ typedef struct at91_pmc {
 
 #define AT91_PMC_MCFR_MAINRDY		0x00010000
 #define AT91_PMC_MCFR_MAINF_MASK	0x0000FFFF
+#define AT91_PMC_MCFR_RCMEAS		0x00100000
+#define AT91_PMC_MCFR_CCSS_XTAL_OSC	0x01000000
 
 #define AT91_PMC_MCKR_CSS_SLOW		0x00000000
 #define AT91_PMC_MCKR_CSS_MAIN		0x00000001
arch/arm/mach-at91/spl_atmel.c +17 -1
index b75c2ccefd..ce16ef3bdb 100644
@@ -32,6 +32,20 @@ static void switch_to_main_crystal_osc(void)
 	while (!(readl(&pmc->sr) & AT91_PMC_IXR_MOSCS))
 		;
 
+#if defined(CONFIG_SAMA5D2)
+	/* Enable a measurement of the external oscillator */
+	tmp = readl(&pmc->mcfr);
+	tmp |= AT91_PMC_MCFR_CCSS_XTAL_OSC;
+	tmp |= AT91_PMC_MCFR_RCMEAS;
+	writel(tmp, &pmc->mcfr);
+
+	while (!(readl(&pmc->mcfr) & AT91_PMC_MCFR_MAINRDY))
+		;
+
+	if (!(readl(&pmc->mcfr) & AT91_PMC_MCFR_MAINF_MASK))
+		hang();
+#endif
+
 	tmp = readl(&pmc->mor);
 	tmp &= ~AT91_PMC_MOR_OSCBYPASS;
 	tmp &= ~AT91_PMC_MOR_KEY(0xff);
@@ -47,11 +61,13 @@ static void switch_to_main_crystal_osc(void)
 	while (!(readl(&pmc->sr) & AT91_PMC_IXR_MOSCSELS))
 		;
 
+#if !defined(CONFIG_SAMA5D2)
 	/* Wait until MAINRDY field is set to make sure main clock is stable */
 	while (!(readl(&pmc->mcfr) & AT91_PMC_MAINRDY))
 		;
+#endif
 
-#ifndef CONFIG_SAMA5D4
+#if !defined(CONFIG_SAMA5D4) && !defined(CONFIG_SAMA5D2)
 	tmp = readl(&pmc->mor);
 	tmp &= ~AT91_PMC_MOR_MOSCRCEN;
 	tmp &= ~AT91_PMC_MOR_KEY(0xff);
Signature · 1 line
2.13.0
#2 lore raw

PATCH 1/6 ARM: at91: spl: Adjust switching to oscillator for SAMA5D2

Quoted 10 lines · Wenyou Yang

As said in 29.5.7 section of SAMA5D2 datasheet, before switching to the crystal oscillator, a check must be carried out to ensure that the oscillator is present and that its freqency is valid.

---

 arch/arm/mach-at91/include/mach/at91_pmc.h |  2 ++
 arch/arm/mach-at91/spl_atmel.c             | 18 +++++++++++++++++-
 2 files changed, 19 insertions(+), 1 deletion(-)
#3 lore raw

PATCH 2/6 ARM: at91: spl: Add mck function to lower rate while switching

In reply to Wenyou Yang

Refer to the commit 70f8c8316ad(PMC: add new mck function to lower rate while switching) from AT91Bootstrap.

While switching to a lower clock source, we must switch the clock source first instead of last. Otherwise, we could end up with too high frequency on internal bus and peripherals. This happen on SAMA5D2 as we exit from ROM code @396MHz.

Add a function pmc_mck_init_down() to allow this sequence.

---

 arch/arm/mach-at91/armv7/clock.c              | 36 +++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/at91_common.h |  1 +
 2 files changed, 37 insertions(+)
arch/arm/mach-at91/armv7/clock.c +36 -0
index 2e55953799..8ae01f4020 100644
@@ -150,6 +150,42 @@ void at91_mck_init(u32 mckr)
 		;
 }
 
+void at91_mck_init_down(u32 mckr)
+{
+	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+	u32 tmp;
+
+	tmp = readl(&pmc->mckr);
+	tmp &= (~AT91_PMC_MCKR_CSS_MASK);
+	tmp |= (mckr & AT91_PMC_MCKR_CSS_MASK);
+	writel(tmp, &pmc->mckr);
+
+	while (!(readl(&pmc->sr) & AT91_PMC_MCKRDY))
+		;
+
+#ifdef CPU_HAS_H32MXDIV
+	tmp = readl(&pmc->mckr);
+	tmp &= (~AT91_PMC_MCKR_H32MXDIV);
+	tmp |= (mckr & AT91_PMC_MCKR_H32MXDIV);
+	writel(tmp, &pmc->mckr);
+#endif
+
+	tmp = readl(&pmc->mckr);
+	tmp &= (~AT91_PMC_MCKR_PLLADIV_MASK);
+	tmp |= (mckr & AT91_PMC_MCKR_PLLADIV_MASK);
+	writel(tmp, &pmc->mckr);
+
+	tmp = readl(&pmc->mckr);
+	tmp &= (~AT91_PMC_MCKR_MDIV_MASK);
+	tmp |= (mckr & AT91_PMC_MCKR_MDIV_MASK);
+	writel(tmp, &pmc->mckr);
+
+	tmp = readl(&pmc->mckr);
+	tmp &= (~AT91_PMC_MCKR_PRES_MASK);
+	tmp |= (mckr & AT91_PMC_MCKR_PRES_MASK);
+	writel(tmp, &pmc->mckr);
+}
+
 int at91_enable_periph_generated_clk(u32 id, u32 clk_source, u32 div)
 {
 	struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
arch/arm/mach-at91/include/mach/at91_common.h +1 -0
index 0742ffc56f..381312709f 100644
@@ -25,6 +25,7 @@ void at91_lcd_hw_init(void);
 void at91_plla_init(u32 pllar);
 void at91_pllb_init(u32 pllar);
 void at91_mck_init(u32 mckr);
+void at91_mck_init_down(u32 mckr);
 void at91_pmc_init(void);
 void mem_init(void);
 void at91_phy_reset(void);
Signature · 1 line
2.13.0
#4 lore raw

PATCH 2/6 ARM: at91: spl: Add mck function to lower rate while switching

Hi Wenyou,

Quoted 8 lines · Wenyou Yang

Refer to the commit 70f8c8316ad(PMC: add new mck function to lower rate while switching) from AT91Bootstrap.

While switching to a lower clock source, we must switch the clock source first instead of last. Otherwise, we could end up with too high frequency on internal bus and peripherals. This happen on SAMA5D2 as we exit from ROM code @396MHz.

Quoted 8 lines

Add a function pmc_mck_init_down() to allow this sequence.

---

 arch/arm/mach-at91/armv7/clock.c              | 36 +++++++++++++++++++++++++++
 arch/arm/mach-at91/include/mach/at91_common.h |  1 +
 2 files changed, 37 insertions(+)

Can this move into a clock driver instead?

Regards,
Simon

#5 lore raw

PATCH 2/6 ARM: at91: spl: Add mck function to lower rate while switching

Hi Simon,

Quoted 13 lines · Simon Glass

Hi Wenyou,

Quoted 10 lines · Wenyou Yang

Refer to the commit 70f8c8316ad(PMC: add new mck function to lower rate while switching) from AT91Bootstrap.

While switching to a lower clock source, we must switch the clock source first instead of last. Otherwise, we could end up with too high frequency on internal bus and peripherals. This happen on SAMA5D2 as we exit from ROM code @396MHz.

Add a function pmc_mck_init_down() to allow this sequence.

Quoted 7 lines
Quoted 6 lines

---

  arch/arm/mach-at91/armv7/clock.c              | 36 +++++++++++++++++++++++++++
  arch/arm/mach-at91/include/mach/at91_common.h |  1 +
  2 files changed, 37 insertions(+)

Can this move into a clock driver instead?

This is used for SPL, due to the limitation of the size of SRAM, it is not easy to move to the clock driver.

Quoted 3 lines

Regards,
Simon

Best Regards,
Wenyou Yang

#6 lore raw

PATCH 3/6 ARM: at91: spl: Add boot device for boot from QSPI

In reply to Wenyou Yang

Add the boot device for booting from the QSPI flash.

---

 arch/arm/mach-at91/spl.c | 2 ++
 1 file changed, 2 insertions(+)
arch/arm/mach-at91/spl.c +2 -0
index e113336b7b..98337aebbe 100644
@@ -56,6 +56,8 @@ u32 spl_boot_device(void)
 	if (dev == ATMEL_SAMA5_BOOT_FROM_SPI)
 		return BOOT_DEVICE_SPI;
 #endif
+	if (dev == ATMEL_SAMA5_BOOT_FROM_QSPI)
+		return BOOT_DEVICE_SPI;
 
 	if (dev == ATMEL_SAMA5_BOOT_FROM_SMC)
 		return BOOT_DEVICE_NAND;
Signature · 1 line
2.13.0
#8 lore raw

PATCH 4/6 ARM: at91: mach: Add missing defines of MPDDRC

In reply to Wenyou Yang

Add missing defines of Multiport DDR-SDRAM Controller (MPDDRC).

---

 arch/arm/mach-at91/include/mach/atmel_mpddrc.h | 4 ++++
 1 file changed, 4 insertions(+)
arch/arm/mach-at91/include/mach/atmel_mpddrc.h +4 -0
index 803501f5cf..40e1cf0a0a 100644
@@ -96,6 +96,10 @@ int ddr3_init(const unsigned int base,
 #define ATMEL_MPDDRC_CR_DLL_RESET_ENABLED	(0x1 << 7)
 #define ATMEL_MPDDRC_CR_DIC_DS			(0x1 << 8)
 #define ATMEL_MPDDRC_CR_DIS_DLL			(0x1 << 9)
+#define ATMEL_MPDDRC_CR_ZQ_INIT			(0x0 << 10)
+#define ATMEL_MPDDRC_CR_ZQ_LONG			(0x1 << 10)
+#define ATMEL_MPDDRC_CR_ZQ_SHORT		(0x2 << 10)
+#define ATMEL_MPDDRC_CR_ZQ_RESET		(0x3 << 10)
 #define ATMEL_MPDDRC_CR_OCD_DEFAULT		(0x7 << 12)
 #define ATMEL_MPDDRC_CR_DQMS_SHARED		(0x1 << 16)
 #define ATMEL_MPDDRC_CR_ENRDM_ON		(0x1 << 17)
Signature · 1 line
2.13.0
#10 lore raw

PATCH 5/6 ARM: at91: Get the Chip ID of SAMA5D2 SiP

In reply to Wenyou Yang

From: Wenyou Yang <[email protected]>

The SAMA5D2 SiP(System in Package) has different Chip IDs in the CHIPID and CHIP_EXID registers.

---

 arch/arm/mach-at91/armv7/sama5d2_devices.c | 26 ++++++++++++++++++++++++--
 arch/arm/mach-at91/include/mach/sama5d2.h  |  7 ++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)
arch/arm/mach-at91/armv7/sama5d2_devices.c +24 -2
index 978eac29bd..de1d9b5bfb 100644
@@ -10,11 +10,20 @@
 #include <asm/arch/clk.h>
 #include <asm/arch/sama5d2.h>
 
-char *get_cpu_name()
+int cpu_is_sama5d2(void)
 {
+	unsigned int chip_id = get_chip_id();
+
+	return ((chip_id == ARCH_ID_SAMA5D2) ||
+		(chip_id == ARCH_ID_SAMA5D2_SIP)) ? 1 : 0;
+}
+
+char *get_cpu_name(void)
+{
+	unsigned int chip_id = get_chip_id();
 	unsigned int extension_id = get_extension_chip_id();
 
-	if (cpu_is_sama5d2()) {
+	if (chip_id == ARCH_ID_SAMA5D2) {
 		switch (extension_id) {
 		case ARCH_EXID_SAMA5D21CU:
 			return "SAMA5D21";
@@ -41,6 +50,19 @@ char *get_cpu_name()
 		}
 	}
 
+	if ((chip_id == ARCH_ID_SAMA5D2) || (chip_id == ARCH_ID_SAMA5D2_SIP)) {
+		switch (extension_id) {
+		case ARCH_EXID_SAMA5D225C_D1M:
+			return "SAMA5D225 128M bits DDR2 SDRAM";
+		case ARCH_EXID_SAMA5D27C_D5M:
+			return "SAMA5D27 512M bits DDR2 SDRAM";
+		case ARCH_EXID_SAMA5D27C_D1G:
+			return "SAMA5D27 1G bits DDR2 SDRAM";
+		case ARCH_EXID_SAMA5D28C_D1G:
+			return "SAMA5D28 1G bits DDR2 SDRAM";
+		}
+	}
+
 	return "Unknown CPU type";
 }
 
arch/arm/mach-at91/include/mach/sama5d2.h +6 -1
index 25c85411e5..49283ed86b 100644
@@ -222,7 +222,11 @@
 #define ARCH_EXID_SAMA5D28CU	0x00000010
 #define ARCH_EXID_SAMA5D28CN	0x00000020
 
-#define cpu_is_sama5d2()	(get_chip_id() == ARCH_ID_SAMA5D2)
+#define ARCH_ID_SAMA5D2_SIP		0x8a5c08c2
+#define ARCH_EXID_SAMA5D225C_D1M	0x00000053
+#define ARCH_EXID_SAMA5D27C_D5M		0x00000032
+#define ARCH_EXID_SAMA5D27C_D1G		0x00000033
+#define ARCH_EXID_SAMA5D28C_D1G		0x00000013
 
 /* PIT Timer(PIT_PIIR) */
 #define CONFIG_SYS_TIMER_COUNTER	0xf804803c
@@ -233,6 +237,7 @@
 #ifndef __ASSEMBLY__
 unsigned int get_chip_id(void);
 unsigned int get_extension_chip_id(void);
+int cpu_is_sama5d2(void);
 unsigned int has_lcdc(void);
 char *get_cpu_name(void);
 #endif
Signature · 1 line
2.13.0
#11 lore raw

PATCH 5/6 ARM: at91: Get the Chip ID of SAMA5D2 SiP

Quoted 11 lines · Wenyou Yang

From: Wenyou Yang <[email protected]>

The SAMA5D2 SiP(System in Package) has different Chip IDs in the CHIPID and CHIP_EXID registers.

---

 arch/arm/mach-at91/armv7/sama5d2_devices.c | 26 ++++++++++++++++++++++++--
 arch/arm/mach-at91/include/mach/sama5d2.h  |  7 ++++++-
 2 files changed, 30 insertions(+), 3 deletions(-)
#12 lore raw

PATCH 6/6 board: atmel: Add SAMA5D27 SOM1 EK board

In reply to Wenyou Yang

From: Wenyou Yang <[email protected]>

The SAMA5D27-SiP (System in Package) integrates the SAMA5D2 with 1Gbit DDR2-SDRAM in a single package.

The SAMA5D27 SOM1 embeds a 64Mbit QSPI flash, KSZ8081 Phy and Mac-address EEPROM.

---

 arch/arm/dts/Makefile                           |   3 +
 arch/arm/dts/at91-sama5d27_som1_ek.dts          | 155 ++++++++++++++++++
 arch/arm/dts/sama5d2.dtsi                       |  20 +++
 arch/arm/dts/sama5d27_som1.dtsi                 | 154 ++++++++++++++++++
 arch/arm/mach-at91/Kconfig                      |   7 +
 board/atmel/sama5d27_som1_ek/Kconfig            |  15 ++
 board/atmel/sama5d27_som1_ek/MAINTAINERS        |   6 +
 board/atmel/sama5d27_som1_ek/Makefile           |   8 +
 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 206 ++++++++++++++++++++++++
 configs/sama5d27_som1_ek_mmc_defconfig          |  82 ++++++++++
 configs/sama5d27_som1_ek_spiflash_defconfig     |  82 ++++++++++
 include/configs/sama5d27_som1_ek.h              | 100 ++++++++++++
 12 files changed, 838 insertions(+)
 create mode 100644 arch/arm/dts/at91-sama5d27_som1_ek.dts
 create mode 100644 arch/arm/dts/sama5d27_som1.dtsi
 create mode 100644 board/atmel/sama5d27_som1_ek/Kconfig
 create mode 100644 board/atmel/sama5d27_som1_ek/MAINTAINERS
 create mode 100644 board/atmel/sama5d27_som1_ek/Makefile
 create mode 100644 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
 create mode 100644 configs/sama5d27_som1_ek_mmc_defconfig
 create mode 100644 configs/sama5d27_som1_ek_spiflash_defconfig
 create mode 100644 include/configs/sama5d27_som1_ek.h
arch/arm/dts/Makefile +3 -0
index 132fa69fe5..0a68663e9f 100644
@@ -404,6 +404,9 @@ dtb-$(CONFIG_TARGET_OMAP3_LOGIC) += \
 dtb-$(CONFIG_TARGET_SAMA5D2_XPLAINED) += \
 	at91-sama5d2_xplained.dtb
 
+dtb-$(CONFIG_TARGET_SAMA5D27_SOM1_EK) += \
+	at91-sama5d27_som1_ek.dtb
+
 dtb-$(CONFIG_TARGET_SAMA5D3XEK) += \
 	sama5d31ek.dtb \
 	sama5d33ek.dtb \
arch/arm/dts/at91-sama5d27_som1_ek.dts new file +155 -0

155 lines not on this page · raw message

arch/arm/dts/sama5d2.dtsi +20 -0
index 8d89b83b53..2a1d64d446 100644
@@ -504,11 +504,13 @@
 					qspi0_clk: qspi0_clk at 52 {
 						#clock-cells = <0>;
 						reg = <52>;
+						u-boot,dm-pre-reloc;
 					};
 
 					qspi1_clk: qspi1_clk at 53 {
 						#clock-cells = <0>;
 						reg = <53>;
+						u-boot,dm-pre-reloc;
 					};
 				};
 
@@ -595,6 +597,16 @@
 				status = "disabled";
 			};
 
+			qspi1: spi at f0024000 {
+				compatible = "atmel,sama5d2-qspi";
+				reg = <0xf0024000 0x100>, <0xd8000000 0x08000000>;
+				reg-names = "qspi_base", "qspi_mmap";
+				#address-cells = <1>;
+				#size-cells = <0>;
+				clocks = <&qspi1_clk>;
+				status = "disabled";
+			};
+
 			spi0: spi at f8000000 {
 				compatible = "atmel,at91rm9200-spi";
 				reg = <0xf8000000 0x100>;
@@ -666,6 +678,14 @@
 				status = "disabled";
 			};
 
+			uart3: serial at fc008000 {
+				compatible = "atmel,at91sam9260-usart";
+				reg = <0xfc008000 0x100>;
+				clocks = <&uart3_clk>;
+				clock-names = "usart";
+				status = "disabled";
+			};
+
 			i2c1: i2c at fc028000 {
 				compatible = "atmel,sama5d2-i2c";
 				reg = <0xfc028000 0x100>;
arch/arm/dts/sama5d27_som1.dtsi new file +154 -0

154 lines not on this page · raw message

arch/arm/mach-at91/Kconfig +7 -0
index 033c1efd2b..a9fd0fae2b 100644
@@ -98,6 +98,12 @@ config TARGET_SAMA5D2_XPLAINED
 	select SUPPORT_SPL
 	select BOARD_EARLY_INIT_F
 
+config TARGET_SAMA5D27_SOM1_EK
+	bool "SAMA5D27 SOM1 EK board"
+	select CPU_V7
+	select SUPPORT_SPL
+	select BOARD_EARLY_INIT_F
+
 config TARGET_SAMA5D3_XPLAINED
 	bool "SAMA5D3 Xplained board"
 	select CPU_V7
@@ -180,6 +186,7 @@ source "board/atmel/at91sam9rlek/Kconfig"
 source "board/atmel/at91sam9x5ek/Kconfig"
 source "board/atmel/sama5d2_ptc/Kconfig"
 source "board/atmel/sama5d2_xplained/Kconfig"
+source "board/atmel/sama5d27_som1_ek/Kconfig"
 source "board/atmel/sama5d3_xplained/Kconfig"
 source "board/atmel/sama5d3xek/Kconfig"
 source "board/atmel/sama5d4_xplained/Kconfig"
board/atmel/sama5d27_som1_ek/Kconfig new file +15 -0
new file mode 100644
index 0000000000..3276214d8c
@@ -0,0 +1,15 @@
+if TARGET_SAMA5D27_SOM1_EK
+
+config SYS_BOARD
+	default "sama5d27_som1_ek"
+
+config SYS_VENDOR
+	default "atmel"
+
+config SYS_SOC
+	default "at91"
+
+config SYS_CONFIG_NAME
+	default "sama5d27_som1_ek"
+
+endif
board/atmel/sama5d27_som1_ek/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..609583c341
@@ -0,0 +1,6 @@
+SAMA5D27 SOM1 EK BOARD
+M:	Wenyou Yang <[email protected]>
+S:	Maintained
+F:	board/atmel/sama5d27_som1_ek/
+F:	include/configs/sama5d27_som1_ek.h
+F:	configs/sama5d27_som1_ek_mmc_defconfig
board/atmel/sama5d27_som1_ek/Makefile new file +8 -0
new file mode 100644
index 0000000000..4ab242c4ac
@@ -0,0 +1,8 @@
+#
+# Copyright (C) 2017 Microchip Corporation
+#		     Wenyou Yang <[email protected]>
+#
+# SPDX-License-Identifier:	GPL-2.0+
+#
+
+obj-y += sama5d27_som1_ek.o
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +206 -0

206 lines not on this page · raw message

configs/sama5d27_som1_ek_mmc_defconfig new file +82 -0

82 lines not on this page · raw message

configs/sama5d27_som1_ek_spiflash_defconfig new file +82 -0

82 lines not on this page · raw message

include/configs/sama5d27_som1_ek.h new file +100 -0

100 lines not on this page · raw message

Signature · 1 line
2.13.0
#13 lore raw

PATCH 6/6 board: atmel: Add SAMA5D27 SOM1 EK board

Hi Wenyou,

Quoted 39 lines · Wenyou Yang

From: Wenyou Yang <[email protected]>

The SAMA5D27-SiP (System in Package) integrates the SAMA5D2 with 1Gbit DDR2-SDRAM in a single package.

The SAMA5D27 SOM1 embeds a 64Mbit QSPI flash, KSZ8081 Phy and Mac-address EEPROM.

---

 arch/arm/dts/Makefile                           |   3 +
 arch/arm/dts/at91-sama5d27_som1_ek.dts          | 155 ++++++++++++++++++
 arch/arm/dts/sama5d2.dtsi                       |  20 +++
 arch/arm/dts/sama5d27_som1.dtsi                 | 154 ++++++++++++++++++
 arch/arm/mach-at91/Kconfig                      |   7 +
 board/atmel/sama5d27_som1_ek/Kconfig            |  15 ++
 board/atmel/sama5d27_som1_ek/MAINTAINERS        |   6 +
 board/atmel/sama5d27_som1_ek/Makefile           |   8 +
 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 206 ++++++++++++++++++++++++
 configs/sama5d27_som1_ek_mmc_defconfig          |  82 ++++++++++
 configs/sama5d27_som1_ek_spiflash_defconfig     |  82 ++++++++++
 include/configs/sama5d27_som1_ek.h              | 100 ++++++++++++
 12 files changed, 838 insertions(+)
 create mode 100644 arch/arm/dts/at91-sama5d27_som1_ek.dts
 create mode 100644 arch/arm/dts/sama5d27_som1.dtsi
 create mode 100644 board/atmel/sama5d27_som1_ek/Kconfig
 create mode 100644 board/atmel/sama5d27_som1_ek/MAINTAINERS
 create mode 100644 board/atmel/sama5d27_som1_ek/Makefile
 create mode 100644 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
 create mode 100644 configs/sama5d27_som1_ek_mmc_defconfig
 create mode 100644 configs/sama5d27_som1_ek_spiflash_defconfig
 create mode 100644 include/configs/sama5d27_som1_ek.h
arch/arm/mach-at91/Kconfig +0 -0
index 033c1efd2b..a9fd0fae2b 100644

arch/arm/mach-at91/Kconfig config TARGET_SAMA5D2_XPLAINED · line 106

Quoted 9 lines
arch/arm/mach-at91/Kconfig +6 -0
@@ -98,6 +98,12 @@ config TARGET_SAMA5D2_XPLAINED
        select SUPPORT_SPL
        select BOARD_EARLY_INIT_F
 
+config TARGET_SAMA5D27_SOM1_EK
+       bool "SAMA5D27 SOM1 EK board"
+       select CPU_V7
+       select SUPPORT_SPL
+       select BOARD_EARLY_INIT_F
+

Add help here to describe the board and peripherals.

Quoted 144 lines
arch/arm/mach-at91/Kconfig +1 -0
 config TARGET_SAMA5D3_XPLAINED
        bool "SAMA5D3 Xplained board"
        select CPU_V7
@@ -180,6 +186,7 @@ source "board/atmel/at91sam9rlek/Kconfig"
 source "board/atmel/at91sam9x5ek/Kconfig"
 source "board/atmel/sama5d2_ptc/Kconfig"
 source "board/atmel/sama5d2_xplained/Kconfig"
+source "board/atmel/sama5d27_som1_ek/Kconfig"
 source "board/atmel/sama5d3_xplained/Kconfig"
 source "board/atmel/sama5d3xek/Kconfig"
 source "board/atmel/sama5d4_xplained/Kconfig"
board/atmel/sama5d27_som1_ek/Kconfig new file +15 -0
new file mode 100644
index 0000000000..3276214d8c
@@ -0,0 +1,15 @@
+if TARGET_SAMA5D27_SOM1_EK
+
+config SYS_BOARD
+       default "sama5d27_som1_ek"
+
+config SYS_VENDOR
+       default "atmel"
+
+config SYS_SOC
+       default "at91"
+
+config SYS_CONFIG_NAME
+       default "sama5d27_som1_ek"
+
+endif
board/atmel/sama5d27_som1_ek/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..609583c341
@@ -0,0 +1,6 @@
+SAMA5D27 SOM1 EK BOARD
+M:     Wenyou Yang <[email protected]>
+S:     Maintained
+F:     board/atmel/sama5d27_som1_ek/
+F:     include/configs/sama5d27_som1_ek.h
+F:     configs/sama5d27_som1_ek_mmc_defconfig
board/atmel/sama5d27_som1_ek/Makefile new file +8 -0
new file mode 100644
index 0000000000..4ab242c4ac
@@ -0,0 +1,8 @@
+#
+# Copyright (C) 2017 Microchip Corporation
+#                   Wenyou Yang <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y += sama5d27_som1_ek.o
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +80 -0
new file mode 100644
index 0000000000..1d39b65a99
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2017 Microchip Corporation
+ *                   Wenyou.Yang <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <debug_uart.h>
+#include <dm.h>
+#include <i2c.h>
+#include <asm/io.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/atmel_pio4.h>
+#include <asm/arch/atmel_mpddrc.h>
+#include <asm/arch/atmel_sdhci.h>
+#include <asm/arch/clk.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/sama5d2.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void board_usb_hw_init(void)
+{
+       atmel_pio4_set_pio_output(AT91_PIO_PORTB, 10, 1);
+}
+
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+static void board_uart1_hw_init(void)
+{
+       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 2, 1);  /* URXD1 */
+       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 3, 0);  /* UTXD1 */
+
+       at91_periph_clk_enable(ATMEL_ID_UART1);
+}
+
+void board_debug_uart_init(void)
+{
+       board_uart1_hw_init();
+}
+#endif
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+int board_early_init_f(void)
+{
+#ifdef CONFIG_DEBUG_UART
+       debug_uart_init();
+#endif
+
+       return 0;
+}
+#endif
+
+int board_init(void)
+{
+       /* address of boot parameters */
+       gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+
+#ifdef CONFIG_CMD_USB
+       board_usb_hw_init();
+#endif
+
+       return 0;
+}
+
+int dram_init(void)
+{
+       gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+                                   CONFIG_SYS_SDRAM_SIZE);
+       return 0;
+}
+
+#ifdef CONFIG_CMD_I2C
+static int set_ethaddr_from_eeprom(void)
+{
+       const int eth_addr_len = 6;
+       unsigned char ethaddr[eth_addr_len];
+       const char *ethaddr_name = "ethaddr";
+       struct udevice *bus, *dev;
+

board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c line 90

Quoted 10 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +10 -0
+       if (getenv(ethaddr_name))
+               return 0;
+
+       if (uclass_get_device_by_seq(UCLASS_I2C, MAC24AA_I2C_BUS_NUM, &bus))
+               return -1;
+
+       if (dm_i2c_probe(bus, MAC24AA_ADDR, 0, &dev))
+               return -1;
+
+       if (dm_i2c_read(dev, MAC24AA_REG, ethaddr, eth_addr_len))

Is this an i2c eeprom? If so there is a DM driver for this.

Quoted 49 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +49 -0
+               return -1;
+
+       if (!is_valid_ethaddr(ethaddr))
+               return -1;
+
+       return eth_setenv_enetaddr(ethaddr_name, ethaddr);
+}
+#endif
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+#ifdef CONFIG_CMD_I2C
+       set_ethaddr_from_eeprom();
+#endif
+       return 0;
+}
+#endif
+
+/* SPL */
+#ifdef CONFIG_SPL_BUILD
+void spl_board_init(void)
+{
+}
+
+static void ddrc_conf(struct atmel_mpddrc_config *ddrc)
+{
+       ddrc->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+       ddrc->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+                   ATMEL_MPDDRC_CR_NR_ROW_13 |
+                   ATMEL_MPDDRC_CR_CAS_DDR_CAS3 |
+                   ATMEL_MPDDRC_CR_DIC_DS |
+                   ATMEL_MPDDRC_CR_ZQ_LONG |
+                   ATMEL_MPDDRC_CR_NB_8BANKS |
+                   ATMEL_MPDDRC_CR_DECOD_INTERLEAVED |
+                   ATMEL_MPDDRC_CR_UNAL_SUPPORTED);
+
+       ddrc->rtr = 0x511;
+
+       ddrc->tpr0 = ((7 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET) |
+                     (3 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET) |
+                     (3 << ATMEL_MPDDRC_TPR0_TWR_OFFSET) |
+                     (9 << ATMEL_MPDDRC_TPR0_TRC_OFFSET) |
+                     (3 << ATMEL_MPDDRC_TPR0_TRP_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET) |
+                     (2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET));
+

board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c line 149

Quoted 10 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +10 -0
+       ddrc->tpr1 = ((22 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET) |
+                     (23 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET) |
+                     (200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET) |
+                     (3 << ATMEL_MPDDRC_TPR1_TXP_OFFSET));
+
+       ddrc->tpr2 = ((2 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET) |
+                     (8 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET) |
+                     (8 << ATMEL_MPDDRC_TPR2_TFAW_OFFSET));

Looks like this should be in drivers/ram?

Quoted 45 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +45 -0
+}
+
+void mem_init(void)
+{
+       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+       struct atmel_mpddr *mpddrc = (struct atmel_mpddr *)ATMEL_BASE_MPDDRC;
+       struct atmel_mpddrc_config ddrc_config;
+       u32 reg;
+
+       ddrc_conf(&ddrc_config);
+
+       at91_periph_clk_enable(ATMEL_ID_MPDDRC);
+       writel(AT91_PMC_DDR, &pmc->scer);
+
+       reg = readl(&mpddrc->io_calibr);
+       reg &= ~ATMEL_MPDDRC_IO_CALIBR_RDIV;
+       reg |= ATMEL_MPDDRC_IO_CALIBR_DDR3_RZQ_55;
+       reg &= ~ATMEL_MPDDRC_IO_CALIBR_TZQIO;
+       reg |= ATMEL_MPDDRC_IO_CALIBR_TZQIO_(101);
+       writel(reg, &mpddrc->io_calibr);
+
+       writel(ATMEL_MPDDRC_RD_DATA_PATH_SHIFT_ONE_CYCLE,
+              &mpddrc->rd_data_path);
+
+       ddr3_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddrc_config);
+
+       writel(0x3, &mpddrc->cal_mr4);
+       writel(64, &mpddrc->tim_cal);
+}
+
+void at91_pmc_init(void)
+{
+       u32 tmp;
+
+       /*
+        * while coming from the ROM code, we run on PLLA @ 492 MHz / 164 MHz
+        * so we need to slow down and configure MCKR accordingly.
+        * This is why we have a special flavor of the switching function.
+        */
+       tmp = AT91_PMC_MCKR_PLLADIV_2 |
+             AT91_PMC_MCKR_MDIV_3 |
+             AT91_PMC_MCKR_CSS_MAIN;
+       at91_mck_init_down(tmp);
+
+       tmp = AT91_PMC_PLLAR_29 |

board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c line 204

Quoted 10 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +10 -0
+             AT91_PMC_PLLXR_PLLCOUNT(0x3f) |
+             AT91_PMC_PLLXR_MUL(40) |
+             AT91_PMC_PLLXR_DIV(1);
+       at91_plla_init(tmp);
+
+       tmp = AT91_PMC_MCKR_H32MXDIV |
+             AT91_PMC_MCKR_PLLADIV_2 |
+             AT91_PMC_MCKR_MDIV_3 |
+             AT91_PMC_MCKR_CSS_PLLA;
+       at91_mck_init(tmp);

Should this be in the clock driver?

configs/sama5d27_som1_ek_mmc_defconfig

Quoted 6 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +2 -0
+}
+#endif
configs/sama5d27_som1_ek_mmc_defconfig new file +0 -1
new file mode 100644
index 0000000000..b6b84952f4
--- /dev/null

Regards,
Simon

#14 lore raw

PATCH 6/6 board: atmel: Add SAMA5D27 SOM1 EK board

Hi Simon,

Quoted 44 lines · Simon Glass

Hi Wenyou,

Quoted 41 lines · Wenyou Yang

From: Wenyou Yang <[email protected]>

The SAMA5D27-SiP (System in Package) integrates the SAMA5D2 with 1Gbit DDR2-SDRAM in a single package.

The SAMA5D27 SOM1 embeds a 64Mbit QSPI flash, KSZ8081 Phy and Mac-address EEPROM.

---

  arch/arm/dts/Makefile                           |   3 +
  arch/arm/dts/at91-sama5d27_som1_ek.dts          | 155 ++++++++++++++++++
  arch/arm/dts/sama5d2.dtsi                       |  20 +++
  arch/arm/dts/sama5d27_som1.dtsi                 | 154 ++++++++++++++++++
  arch/arm/mach-at91/Kconfig                      |   7 +
  board/atmel/sama5d27_som1_ek/Kconfig            |  15 ++
  board/atmel/sama5d27_som1_ek/MAINTAINERS        |   6 +
  board/atmel/sama5d27_som1_ek/Makefile           |   8 +
  board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 206 ++++++++++++++++++++++++
  configs/sama5d27_som1_ek_mmc_defconfig          |  82 ++++++++++
  configs/sama5d27_som1_ek_spiflash_defconfig     |  82 ++++++++++
  include/configs/sama5d27_som1_ek.h              | 100 ++++++++++++
  12 files changed, 838 insertions(+)

create mode 100644 arch/arm/dts/at91-sama5d27_som1_ek.dts create mode 100644 arch/arm/dts/sama5d27_som1.dtsi create mode 100644 board/atmel/sama5d27_som1_ek/Kconfig create mode 100644 board/atmel/sama5d27_som1_ek/MAINTAINERS create mode 100644 board/atmel/sama5d27_som1_ek/Makefile create mode 100644 board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c create mode 100644 configs/sama5d27_som1_ek_mmc_defconfig create mode 100644 configs/sama5d27_som1_ek_spiflash_defconfig create mode 100644 include/configs/sama5d27_som1_ek.h

arch/arm/mach-at91/Kconfig +0 -0
index 033c1efd2b..a9fd0fae2b 100644
@@ -98,6 +98,12 @@ config TARGET_SAMA5D2_XPLAINED
         select SUPPORT_SPL
         select BOARD_EARLY_INIT_F
 
Quoted 7 lines

arch/arm/mach-at91/Kconfig config TARGET_SAMA5D2_XPLAINED · line 106

Quoted 6 lines
arch/arm/mach-at91/Kconfig +6 -0
+config TARGET_SAMA5D27_SOM1_EK
+       bool "SAMA5D27 SOM1 EK board"
+       select CPU_V7
+       select SUPPORT_SPL
+       select BOARD_EARLY_INIT_F
+

Add help here to describe the board and peripherals.

Will add in next version.

Quoted 149 lines
Quoted 149 lines
arch/arm/mach-at91/Kconfig +1 -0
  config TARGET_SAMA5D3_XPLAINED
         bool "SAMA5D3 Xplained board"
         select CPU_V7
@@ -180,6 +186,7 @@ source "board/atmel/at91sam9rlek/Kconfig"
  source "board/atmel/at91sam9x5ek/Kconfig"
  source "board/atmel/sama5d2_ptc/Kconfig"
  source "board/atmel/sama5d2_xplained/Kconfig"
+source "board/atmel/sama5d27_som1_ek/Kconfig"
  source "board/atmel/sama5d3_xplained/Kconfig"
  source "board/atmel/sama5d3xek/Kconfig"
  source "board/atmel/sama5d4_xplained/Kconfig"
board/atmel/sama5d27_som1_ek/Kconfig new file +15 -0
new file mode 100644
index 0000000000..3276214d8c
@@ -0,0 +1,15 @@
+if TARGET_SAMA5D27_SOM1_EK
+
+config SYS_BOARD
+       default "sama5d27_som1_ek"
+
+config SYS_VENDOR
+       default "atmel"
+
+config SYS_SOC
+       default "at91"
+
+config SYS_CONFIG_NAME
+       default "sama5d27_som1_ek"
+
+endif
board/atmel/sama5d27_som1_ek/MAINTAINERS new file +6 -0
new file mode 100644
index 0000000000..609583c341
@@ -0,0 +1,6 @@
+SAMA5D27 SOM1 EK BOARD
+M:     Wenyou Yang <[email protected]>
+S:     Maintained
+F:     board/atmel/sama5d27_som1_ek/
+F:     include/configs/sama5d27_som1_ek.h
+F:     configs/sama5d27_som1_ek_mmc_defconfig
board/atmel/sama5d27_som1_ek/Makefile new file +8 -0
new file mode 100644
index 0000000000..4ab242c4ac
@@ -0,0 +1,8 @@
+#
+# Copyright (C) 2017 Microchip Corporation
+#                   Wenyou Yang <[email protected]>
+#
+# SPDX-License-Identifier:     GPL-2.0+
+#
+
+obj-y += sama5d27_som1_ek.o
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +83 -0
new file mode 100644
index 0000000000..1d39b65a99
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2017 Microchip Corporation
+ *                   Wenyou.Yang <[email protected]>
+ *
+ * SPDX-License-Identifier:    GPL-2.0+
+ */
+
+#include <common.h>
+#include <debug_uart.h>
+#include <dm.h>
+#include <i2c.h>
+#include <asm/io.h>
+#include <asm/arch/at91_common.h>
+#include <asm/arch/atmel_pio4.h>
+#include <asm/arch/atmel_mpddrc.h>
+#include <asm/arch/atmel_sdhci.h>
+#include <asm/arch/clk.h>
+#include <asm/arch/gpio.h>
+#include <asm/arch/sama5d2.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+
+static void board_usb_hw_init(void)
+{
+       atmel_pio4_set_pio_output(AT91_PIO_PORTB, 10, 1);
+}
+
+#ifdef CONFIG_DEBUG_UART_BOARD_INIT
+static void board_uart1_hw_init(void)
+{
+       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 2, 1);  /* URXD1 */
+       atmel_pio4_set_a_periph(AT91_PIO_PORTD, 3, 0);  /* UTXD1 */
+
+       at91_periph_clk_enable(ATMEL_ID_UART1);
+}
+
+void board_debug_uart_init(void)
+{
+       board_uart1_hw_init();
+}
+#endif
+
+#ifdef CONFIG_BOARD_EARLY_INIT_F
+int board_early_init_f(void)
+{
+#ifdef CONFIG_DEBUG_UART
+       debug_uart_init();
+#endif
+
+       return 0;
+}
+#endif
+
+int board_init(void)
+{
+       /* address of boot parameters */
+       gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+
+#ifdef CONFIG_CMD_USB
+       board_usb_hw_init();
+#endif
+
+       return 0;
+}
+
+int dram_init(void)
+{
+       gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
+                                   CONFIG_SYS_SDRAM_SIZE);
+       return 0;
+}
+
+#ifdef CONFIG_CMD_I2C
+static int set_ethaddr_from_eeprom(void)
+{
+       const int eth_addr_len = 6;
+       unsigned char ethaddr[eth_addr_len];
+       const char *ethaddr_name = "ethaddr";
+       struct udevice *bus, *dev;
+
+       if (getenv(ethaddr_name))
+               return 0;
+
Quoted 8 lines

board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c line 90

Quoted 7 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +7 -0
+       if (uclass_get_device_by_seq(UCLASS_I2C, MAC24AA_I2C_BUS_NUM, &bus))
+               return -1;
+
+       if (dm_i2c_probe(bus, MAC24AA_ADDR, 0, &dev))
+               return -1;
+
+       if (dm_i2c_read(dev, MAC24AA_REG, ethaddr, eth_addr_len))

Is this an i2c eeprom? If so there is a DM driver for this.

Yes, it is an i2c eeprom. I will put these code to common folder and use the i2c_eeprom driver in a new patch series.

Quoted 53 lines
Quoted 53 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +52 -0
+               return -1;
+
+       if (!is_valid_ethaddr(ethaddr))
+               return -1;
+
+       return eth_setenv_enetaddr(ethaddr_name, ethaddr);
+}
+#endif
+
+#ifdef CONFIG_MISC_INIT_R
+int misc_init_r(void)
+{
+#ifdef CONFIG_CMD_I2C
+       set_ethaddr_from_eeprom();
+#endif
+       return 0;
+}
+#endif
+
+/* SPL */
+#ifdef CONFIG_SPL_BUILD
+void spl_board_init(void)
+{
+}
+
+static void ddrc_conf(struct atmel_mpddrc_config *ddrc)
+{
+       ddrc->md = (ATMEL_MPDDRC_MD_DBW_16_BITS | ATMEL_MPDDRC_MD_DDR2_SDRAM);
+
+       ddrc->cr = (ATMEL_MPDDRC_CR_NC_COL_10 |
+                   ATMEL_MPDDRC_CR_NR_ROW_13 |
+                   ATMEL_MPDDRC_CR_CAS_DDR_CAS3 |
+                   ATMEL_MPDDRC_CR_DIC_DS |
+                   ATMEL_MPDDRC_CR_ZQ_LONG |
+                   ATMEL_MPDDRC_CR_NB_8BANKS |
+                   ATMEL_MPDDRC_CR_DECOD_INTERLEAVED |
+                   ATMEL_MPDDRC_CR_UNAL_SUPPORTED);
+
+       ddrc->rtr = 0x511;
+
+       ddrc->tpr0 = ((7 << ATMEL_MPDDRC_TPR0_TRAS_OFFSET) |
+                     (3 << ATMEL_MPDDRC_TPR0_TRCD_OFFSET) |
+                     (3 << ATMEL_MPDDRC_TPR0_TWR_OFFSET) |
+                     (9 << ATMEL_MPDDRC_TPR0_TRC_OFFSET) |
+                     (3 << ATMEL_MPDDRC_TPR0_TRP_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR0_TRRD_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR0_TWTR_OFFSET) |
+                     (2 << ATMEL_MPDDRC_TPR0_TMRD_OFFSET));
+
+       ddrc->tpr1 = ((22 << ATMEL_MPDDRC_TPR1_TRFC_OFFSET) |
+                     (23 << ATMEL_MPDDRC_TPR1_TXSNR_OFFSET) |
+                     (200 << ATMEL_MPDDRC_TPR1_TXSRD_OFFSET) |
Quoted 8 lines

board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c line 149

Quoted 7 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +7 -0
+                     (3 << ATMEL_MPDDRC_TPR1_TXP_OFFSET));
+
+       ddrc->tpr2 = ((2 << ATMEL_MPDDRC_TPR2_TXARD_OFFSET) |
+                     (8 << ATMEL_MPDDRC_TPR2_TXARDS_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR2_TRPA_OFFSET) |
+                     (4 << ATMEL_MPDDRC_TPR2_TRTP_OFFSET) |
+                     (8 << ATMEL_MPDDRC_TPR2_TFAW_OFFSET));

Looks like this should be in drivers/ram?

The code is used to configure the parameter, not driver, so it is okay to put here.

Quoted 49 lines
Quoted 49 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +48 -0
+}
+
+void mem_init(void)
+{
+       struct at91_pmc *pmc = (struct at91_pmc *)ATMEL_BASE_PMC;
+       struct atmel_mpddr *mpddrc = (struct atmel_mpddr *)ATMEL_BASE_MPDDRC;
+       struct atmel_mpddrc_config ddrc_config;
+       u32 reg;
+
+       ddrc_conf(&ddrc_config);
+
+       at91_periph_clk_enable(ATMEL_ID_MPDDRC);
+       writel(AT91_PMC_DDR, &pmc->scer);
+
+       reg = readl(&mpddrc->io_calibr);
+       reg &= ~ATMEL_MPDDRC_IO_CALIBR_RDIV;
+       reg |= ATMEL_MPDDRC_IO_CALIBR_DDR3_RZQ_55;
+       reg &= ~ATMEL_MPDDRC_IO_CALIBR_TZQIO;
+       reg |= ATMEL_MPDDRC_IO_CALIBR_TZQIO_(101);
+       writel(reg, &mpddrc->io_calibr);
+
+       writel(ATMEL_MPDDRC_RD_DATA_PATH_SHIFT_ONE_CYCLE,
+              &mpddrc->rd_data_path);
+
+       ddr3_init(ATMEL_BASE_MPDDRC, ATMEL_BASE_DDRCS, &ddrc_config);
+
+       writel(0x3, &mpddrc->cal_mr4);
+       writel(64, &mpddrc->tim_cal);
+}
+
+void at91_pmc_init(void)
+{
+       u32 tmp;
+
+       /*
+        * while coming from the ROM code, we run on PLLA @ 492 MHz / 164 MHz
+        * so we need to slow down and configure MCKR accordingly.
+        * This is why we have a special flavor of the switching function.
+        */
+       tmp = AT91_PMC_MCKR_PLLADIV_2 |
+             AT91_PMC_MCKR_MDIV_3 |
+             AT91_PMC_MCKR_CSS_MAIN;
+       at91_mck_init_down(tmp);
+
+       tmp = AT91_PMC_PLLAR_29 |
+             AT91_PMC_PLLXR_PLLCOUNT(0x3f) |
+             AT91_PMC_PLLXR_MUL(40) |
+             AT91_PMC_PLLXR_DIV(1);
Quoted 8 lines

board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c line 204

Quoted 7 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +7 -0
+       at91_plla_init(tmp);
+
+       tmp = AT91_PMC_MCKR_H32MXDIV |
+             AT91_PMC_MCKR_PLLADIV_2 |
+             AT91_PMC_MCKR_MDIV_3 |
+             AT91_PMC_MCKR_CSS_PLLA;
+       at91_mck_init(tmp);

Should this be in the clock driver?

This is used by SPL, it is not easy to put it in the clock driver, maybe in the future.

Quoted 9 lines

configs/sama5d27_som1_ek_mmc_defconfig

Quoted 7 lines
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c new file +2 -0
+}
+#endif
configs/sama5d27_som1_ek_mmc_defconfig new file +0 -1
new file mode 100644
index 0000000000..b6b84952f4
--- /dev/null

Regards,
Simon

Best Regards,
Wenyou Yang