* [PATCH v2 1/5] board: sama5d27_som1_ek: Get dram size and base from device tree
2021-08-16 12:25 [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Clément Léger
@ 2021-08-16 12:25 ` Clément Léger
2021-08-16 12:25 ` [PATCH v2 2/5] board: sama5d27_som1_ek: Modify load addresses Clément Léger
` (4 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Clément Léger @ 2021-08-16 12:25 UTC (permalink / raw)
To: u-boot, Eugen Hristev; +Cc: Clément Léger, Wenyou Yang, Nicolas Ferre
In order to make it more flexible and allow modifying the base address
of DRAM without recompiling U-Boot, use memory node from device tree
with fdtdec functions.
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 12 ++++++++----
1 file changed, 8 insertions(+), 4 deletions(-)
diff --git a/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c b/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
index 1b7d946b50..8c0cf3da54 100644
--- a/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
+++ b/board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c
@@ -6,6 +6,7 @@
#include <common.h>
#include <debug_uart.h>
+#include <fdtdec.h>
#include <init.h>
#include <asm/global_data.h>
#include <asm/io.h>
@@ -68,7 +69,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* address of boot parameters */
- gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+ gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
#ifdef CONFIG_CMD_USB
board_usb_hw_init();
@@ -77,11 +78,14 @@ int board_init(void)
return 0;
}
+int dram_init_banksize(void)
+{
+ return fdtdec_setup_memory_banksize();
+}
+
int dram_init(void)
{
- gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
- CONFIG_SYS_SDRAM_SIZE);
- return 0;
+ return fdtdec_setup_mem_size_base();
}
#define MAC24AA_MAC_OFFSET 0xfa
--
2.32.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 2/5] board: sama5d27_som1_ek: Modify load addresses
2021-08-16 12:25 [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Clément Léger
2021-08-16 12:25 ` [PATCH v2 1/5] board: sama5d27_som1_ek: Get dram size and base from device tree Clément Léger
@ 2021-08-16 12:25 ` Clément Léger
2021-08-16 12:25 ` [PATCH v2 3/5] ARM: dts: at91: sama5d2_xplained: Add memory node in devicetree Clément Léger
` (3 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Clément Léger @ 2021-08-16 12:25 UTC (permalink / raw)
To: u-boot, Eugen Hristev; +Cc: Clément Léger, Wenyou Yang, Nicolas Ferre
When using OP-TEE, address range [0x20000000 - 0x22000000] is reserved.
This modification allows to have a system which always work even when
OP-TEE is present.
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
include/configs/sama5d27_som1_ek.h | 12 ++++--------
1 file changed, 4 insertions(+), 8 deletions(-)
diff --git a/include/configs/sama5d27_som1_ek.h b/include/configs/sama5d27_som1_ek.h
index 8942d15934..2e937c8309 100644
--- a/include/configs/sama5d27_som1_ek.h
+++ b/include/configs/sama5d27_som1_ek.h
@@ -14,15 +14,11 @@
#undef CONFIG_SYS_AT91_MAIN_CLOCK
#define CONFIG_SYS_AT91_MAIN_CLOCK 24000000 /* from 24 MHz crystal */
-/* SDRAM */
-#define CONFIG_SYS_SDRAM_BASE 0x20000000
-#define CONFIG_SYS_SDRAM_SIZE 0x8000000
-
#ifdef CONFIG_SPL_BUILD
#define CONFIG_SYS_INIT_SP_ADDR 0x218000
#else
#define CONFIG_SYS_INIT_SP_ADDR \
- (CONFIG_SYS_SDRAM_BASE + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
+ (0x22000000 + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
#endif
#define CONFIG_SYS_LOAD_ADDR 0x22000000 /* load address */
@@ -30,10 +26,10 @@
#undef CONFIG_BOOTCOMMAND
#ifdef CONFIG_SD_BOOT
/* bootstrap + u-boot + env in sd card */
-#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x21000000 " \
+#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x22000000 " \
CONFIG_DEFAULT_DEVICE_TREE ".dtb; " \
- "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x22000000 zImage; " \
- "bootz 0x22000000 - 0x21000000"
+ "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x23000000 zImage; " \
+ "bootz 0x23000000 - 0x22000000"
#endif
/* SPL */
--
2.32.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 3/5] ARM: dts: at91: sama5d2_xplained: Add memory node in devicetree
2021-08-16 12:25 [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Clément Léger
2021-08-16 12:25 ` [PATCH v2 1/5] board: sama5d27_som1_ek: Get dram size and base from device tree Clément Léger
2021-08-16 12:25 ` [PATCH v2 2/5] board: sama5d27_som1_ek: Modify load addresses Clément Léger
@ 2021-08-16 12:25 ` Clément Léger
2021-08-16 12:25 ` [PATCH v2 4/5] board: sama5d2_xplained: Get dram size and base from device tree Clément Léger
` (2 subsequent siblings)
5 siblings, 0 replies; 7+ messages in thread
From: Clément Léger @ 2021-08-16 12:25 UTC (permalink / raw)
To: u-boot, Eugen Hristev; +Cc: Clément Léger, Wenyou Yang, Nicolas Ferre
sama5d2_xplained DRAM detection code will be modified to use device tree
instead of hardcoded addresses. In order to prepare that, add the memory
node to at91-sama5d2_xplained.dts.
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
arch/arm/dts/at91-sama5d2_xplained.dts | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/arch/arm/dts/at91-sama5d2_xplained.dts b/arch/arm/dts/at91-sama5d2_xplained.dts
index b733c4d4ce..3e3cb40161 100644
--- a/arch/arm/dts/at91-sama5d2_xplained.dts
+++ b/arch/arm/dts/at91-sama5d2_xplained.dts
@@ -12,6 +12,10 @@
stdout-path = &uart1;
};
+ memory {
+ reg = <0x20000000 0x20000000>;
+ };
+
onewire_tm: onewire {
gpios = <&pioA PIN_PB0 GPIO_ACTIVE_HIGH>;
pinctrl-names = "default";
--
2.32.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 4/5] board: sama5d2_xplained: Get dram size and base from device tree
2021-08-16 12:25 [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Clément Léger
` (2 preceding siblings ...)
2021-08-16 12:25 ` [PATCH v2 3/5] ARM: dts: at91: sama5d2_xplained: Add memory node in devicetree Clément Léger
@ 2021-08-16 12:25 ` Clément Léger
2021-08-16 12:25 ` [PATCH v2 5/5] board: sama5d2_xplained: Modify load addresses Clément Léger
2021-09-02 11:36 ` [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Eugen.Hristev
5 siblings, 0 replies; 7+ messages in thread
From: Clément Léger @ 2021-08-16 12:25 UTC (permalink / raw)
To: u-boot, Eugen Hristev; +Cc: Clément Léger, Wenyou Yang, Nicolas Ferre
In order to make it more flexible and allow modifying the base address
of DRAM without recompiling U-Boot, use memory node from device tree
with fdtdec functions.
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
board/atmel/sama5d2_xplained/sama5d2_xplained.c | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/board/atmel/sama5d2_xplained/sama5d2_xplained.c b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
index 5110ec8969..8b5cd533d0 100644
--- a/board/atmel/sama5d2_xplained/sama5d2_xplained.c
+++ b/board/atmel/sama5d2_xplained/sama5d2_xplained.c
@@ -68,7 +68,7 @@ int board_early_init_f(void)
int board_init(void)
{
/* address of boot parameters */
- gd->bd->bi_boot_params = CONFIG_SYS_SDRAM_BASE + 0x100;
+ gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
#ifdef CONFIG_CMD_USB
board_usb_hw_init();
@@ -77,11 +77,14 @@ int board_init(void)
return 0;
}
+int dram_init_banksize(void)
+{
+ return fdtdec_setup_memory_banksize();
+}
+
int dram_init(void)
{
- gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE,
- CONFIG_SYS_SDRAM_SIZE);
- return 0;
+ return fdtdec_setup_mem_size_base();
}
#define AT24MAC_MAC_OFFSET 0x9a
--
2.32.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH v2 5/5] board: sama5d2_xplained: Modify load addresses
2021-08-16 12:25 [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Clément Léger
` (3 preceding siblings ...)
2021-08-16 12:25 ` [PATCH v2 4/5] board: sama5d2_xplained: Get dram size and base from device tree Clément Léger
@ 2021-08-16 12:25 ` Clément Léger
2021-09-02 11:36 ` [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Eugen.Hristev
5 siblings, 0 replies; 7+ messages in thread
From: Clément Léger @ 2021-08-16 12:25 UTC (permalink / raw)
To: u-boot, Eugen Hristev; +Cc: Clément Léger, Wenyou Yang, Nicolas Ferre
When using OP-TEE, address range [0x20000000 - 0x22000000] is reserved.
This modification allows to have a system which always work even when
OP-TEE is present.
Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
include/configs/sama5d2_xplained.h | 24 ++++++++++--------------
1 file changed, 10 insertions(+), 14 deletions(-)
diff --git a/include/configs/sama5d2_xplained.h b/include/configs/sama5d2_xplained.h
index 4f5ceca780..d00017353a 100644
--- a/include/configs/sama5d2_xplained.h
+++ b/include/configs/sama5d2_xplained.h
@@ -11,15 +11,11 @@
#include "at91-sama5_common.h"
-/* SDRAM */
-#define CONFIG_SYS_SDRAM_BASE 0x20000000
-#define CONFIG_SYS_SDRAM_SIZE 0x20000000
-
#ifdef CONFIG_SPL_BUILD
#define CONFIG_SYS_INIT_SP_ADDR 0x218000
#else
#define CONFIG_SYS_INIT_SP_ADDR \
- (CONFIG_SYS_SDRAM_BASE + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
+ (0x22000000 + 16 * 1024 - GENERATED_GBL_DATA_SIZE)
#endif
#define CONFIG_SYS_LOAD_ADDR 0x22000000 /* load address */
@@ -31,18 +27,18 @@
/* bootstrap + u-boot + env in sd card */
#undef CONFIG_BOOTCOMMAND
-#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x21000000 at91-sama5d2_xplained.dtb; " \
- "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x22000000 zImage; " \
- "bootz 0x22000000 - 0x21000000"
+#define CONFIG_BOOTCOMMAND "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x22000000 at91-sama5d2_xplained.dtb; " \
+ "fatload mmc " CONFIG_ENV_FAT_DEVICE_AND_PART " 0x23000000 zImage; " \
+ "bootz 0x23000000 - 0x22000000"
#elif CONFIG_SPI_BOOT
/* bootstrap + u-boot + env in sd card, but kernel + dtb in eMMC */
#undef CONFIG_BOOTCOMMAND
-#define CONFIG_BOOTCOMMAND "ext4load mmc 0:1 0x21000000 /boot/at91-sama5d2_xplained.dtb; " \
- "ext4load mmc 0:1 0x22000000 /boot/zImage; " \
- "bootz 0x22000000 - 0x21000000"
+#define CONFIG_BOOTCOMMAND "ext4load mmc 0:1 0x22000000 /boot/at91-sama5d2_xplained.dtb; " \
+ "ext4load mmc 0:1 0x23000000 /boot/zImage; " \
+ "bootz 0x23000000 - 0x22000000"
#endif
@@ -51,9 +47,9 @@
#undef CONFIG_BOOTCOMMAND
#define CONFIG_ENV_SPI_BUS 1
#define CONFIG_BOOTCOMMAND "sf probe 1:0; " \
- "sf read 0x21000000 0x180000 0x80000; " \
- "sf read 0x22000000 0x200000 0x600000; "\
- "bootz 0x22000000 - 0x21000000"
+ "sf read 0x22000000 0x180000 0x80000; " \
+ "sf read 0x23000000 0x200000 0x600000; "\
+ "bootz 0x23000000 - 0x22000000"
#endif
--
2.32.0
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained
2021-08-16 12:25 [PATCH v2 0/5] Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained Clément Léger
` (4 preceding siblings ...)
2021-08-16 12:25 ` [PATCH v2 5/5] board: sama5d2_xplained: Modify load addresses Clément Léger
@ 2021-09-02 11:36 ` Eugen.Hristev
5 siblings, 0 replies; 7+ messages in thread
From: Eugen.Hristev @ 2021-09-02 11:36 UTC (permalink / raw)
To: clement.leger, u-boot; +Cc: wenyou.yang, Nicolas.Ferre
On 8/16/21 3:25 PM, Clément Léger wrote:
> Loading U-Boot after OP-TEE requires to move the base address of the
> DRAM and reduce its size. Indeed, OP-TEE will be loaded at start of
> DRAM for these platforms and this DRAM will be secured and thus not
> accessible to U-Boot.
>
> Currently, addresses are hardcoded in board configs. This series adds
> memory property when missing to existing device tree and modify init
> code to fetch DRAM size from devicetree. This will allow to modify only
> the device tree to reduce DRAM when needed.
>
> Memory addresses have been chosen to have a 32Mb hole at the start of
> DRAM which allows to put OP-TEE and necessary exchange memory zones.
>
> Changes in v2:
> - Move memory node from sama5d2.dtsi to at91-sama5d2_xplained.dts
>
> Clément Léger (5):
> board: sama5d27_som1_ek: Get dram size and base from device tree
> board: sama5d27_som1_ek: Modify load addresses
> ARM: dts: at91: sama5d2_xplained: Add memory node in devicetree
> board: sama5d2_xplained: Get dram size and base from device tree
> board: sama5d2_xplained: Modify load addresses
>
> arch/arm/dts/at91-sama5d2_xplained.dts | 4 ++++
> .../atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 12 ++++++----
> .../atmel/sama5d2_xplained/sama5d2_xplained.c | 11 +++++----
> include/configs/sama5d27_som1_ek.h | 12 ++++------
> include/configs/sama5d2_xplained.h | 24 ++++++++-----------
> 5 files changed, 33 insertions(+), 30 deletions(-)
>
> --
> 2.32.0
>
Applied series to u-boot-atmel/next , thanks !
^ permalink raw reply [flat|nested] 7+ messages in thread