Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained
Subsystems (2)
v2 cover Use device tree to get DRAM for sama5d27_som1_ek/sama5d2_xplained
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(-)
Signature · 1 line
2.32.0
PATCH v2 1/5 board: sama5d27_som1_ek: Get dram size and base from device tree
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.
--- board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-)
board/atmel/sama5d27_som1_ek/sama5d27_som1_ek.c +8 -4
@@ -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
Signature · 1 line
2.32.0
PATCH v2 2/5 board: sama5d27_som1_ek: Modify load addresses
In reply to Clément LégerWhen 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.
--- include/configs/sama5d27_som1_ek.h | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-)
include/configs/sama5d27_som1_ek.h +4 -8
@@ -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 */
Signature · 1 line
2.32.0
PATCH v2 3/5 ARM: dts: at91: sama5d2_xplained: Add memory node in devicetree
In reply to Clément Légersama5d2_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.
--- arch/arm/dts/at91-sama5d2_xplained.dts | 4 ++++ 1 file changed, 4 insertions(+)
arch/arm/dts/at91-sama5d2_xplained.dts +4 -0
@@ -12,6 +12,10 @@ stdout-path = &uart1; }; + memory { + reg = <0x20000000 0x20000000>; + }; + onewire_tm: onewire { gpios = <&pioA PIN_PB0 GPIO_ACTIVE_HIGH>; pinctrl-names = "default";
Signature · 1 line
2.32.0
PATCH v2 4/5 board: sama5d2_xplained: Get dram size and base from device tree
In reply to Clément LégerIn 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.
--- board/atmel/sama5d2_xplained/sama5d2_xplained.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
board/atmel/sama5d2_xplained/sama5d2_xplained.c +7 -4
@@ -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
Signature · 1 line
2.32.0
PATCH v2 5/5 board: sama5d2_xplained: Modify load addresses
In reply to Clément LégerWhen 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.
--- include/configs/sama5d2_xplained.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-)
include/configs/sama5d2_xplained.h +10 -14
@@ -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
Signature · 1 line
2.32.0
Quoted 30 lines · Clément Léger
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 fromsama5d2.dtsitoat91-sama5d2_xplained.dtsClé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 addressesarch/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(-)
Quoted 3 lines
--
2.32.0
Applied series to u-boot-atmel/next , thanks !