From dfa01e8a2827faea771f138119c8d62c9e1bf7b5 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Thu, 10 Nov 2016 16:39:27 -0800 Subject: board: colibri_imx7: reserve DDR memory for Cortex-M4 i.MX 7's Cortex-M4 core can run from DDR and uses DDR memory for the rpmsg communication. Both use cases need a fixed location of memory reserved. For the rpmsg use case the reserved area needs to be in sync with the kernel's hardcoded vring descriptor location. Use the linux,usable-memory property to carve out 1MB of memory in case the M4 core is running. Also make sure that the i.MX 7 specific rpmsg driver does not get loaded in case we do not carve out memory. Signed-off-by: Stefan Agner Acked-by: Marcel Ziswiler --- board/toradex/colibri_imx7/colibri_imx7.c | 43 +++++++++++++++++++++++++++++++ include/configs/colibri_imx7.h | 1 + 2 files changed, 44 insertions(+) diff --git a/board/toradex/colibri_imx7/colibri_imx7.c b/board/toradex/colibri_imx7/colibri_imx7.c index 8ec2199fdd..e4a6ed5d5d 100644 --- a/board/toradex/colibri_imx7/colibri_imx7.c +++ b/board/toradex/colibri_imx7/colibri_imx7.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -782,3 +783,45 @@ void udc_pins_setting(void) } #endif /*CONFIG_IMX_UDC*/ + +#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) && defined(CONFIG_CMD_BOOTAUX) +int ft_board_setup(void *blob, bd_t *bd) +{ + int up; + + up = arch_auxiliary_core_check_up(0); + if (up) { + int ret; + int areas = 1; + u64 start[2], size[2]; + + /* + * Reserve 1MB of memory for M4 (1MiB is also the minimum + * alignment for Linux due to MMU section size restrictions). + */ + start[0] = gd->bd->bi_dram[0].start; + size[0] = SZ_256M - SZ_1M; + + /* If needed, create a second entry for memory beyond 256M */ + if (gd->bd->bi_dram[0].size > SZ_256M) { + start[1] = gd->bd->bi_dram[0].start + SZ_256M; + size[1] = gd->bd->bi_dram[0].size - SZ_256M; + areas = 2; + } + + ret = fdt_set_usable_memory(blob, start, size, areas); + if (ret) { + eprintf("Cannot set usable memory\n"); + return ret; + } + } else { + int off; + + off = fdt_node_offset_by_compatible(blob, -1, "fsl,imx7d-rpmsg"); + if (off > 0) + fdt_status_disabled(blob, off); + } + + return 0; +} +#endif diff --git a/include/configs/colibri_imx7.h b/include/configs/colibri_imx7.h index 2fe2422045..8716938034 100644 --- a/include/configs/colibri_imx7.h +++ b/include/configs/colibri_imx7.h @@ -361,6 +361,7 @@ #define CONFIG_MMCROOT "/dev/mmcblk0p2" /* USDHC1 */ #define CONFIG_OF_LIBFDT +#define CONFIG_OF_BOARD_SETUP #define CONFIG_OF_SYSTEM_SETUP #define CONFIG_CMD_BOOTZ #define CONFIG_SUPPORT_RAW_INITRD -- cgit v1.2.3