android: colibri_imx7: reserve DDR memory for Cortex-M4
Subsystems (2)
v2 cover android: 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.
Introduce support for adding 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.
v2:
- fixed build where CONFIG_ARCH_FIXUP_FDT_MEMORY is not set.
Igor Opaniuk (2):
common: fdt_support: add support for setting usable memory
board: colibri_imx7: reserve DDR memory for Cortex-M4
arch/arm/include/asm/mach-imx/sys_proto.h | 2 ++ board/toradex/colibri_imx7/colibri_imx7.c | 37 +++++++++++++++++++++++ common/fdt_support.c | 35 +++++++++++++++++++++ include/fdt_support.h | 1 + 4 files changed, 75 insertions(+)
Signature · 1 line
2.17.1
PATCH v2 1/2 common: fdt_support: add support for setting usable memory
From: Igor Opaniuk <[email protected]>
Add support for setting linux,usable-memory property in the memory node of device tree for the kernel [1].
This property holds a base address and size, describing a limited region in which memory may be considered available for use by the kernel. Memory outside of this range is not available for use.
[1] https://www.kernel.org/doc/Documentation/devicetree/bindings/chosen.txt
---
common/fdt_support.c | 35 +++++++++++++++++++++++++++++++++++ include/fdt_support.h | 1 + 2 files changed, 36 insertions(+)
common/fdt_support.c +35 -0
@@ -467,6 +467,41 @@ int fdt_fixup_memory_banks(void *blob, u64 start[], u64 size[], int banks) }return 0 ; } + +int fdt_set_usable_memory (void *blob,u64 start[],u64 size[],int areas) +{ +int err, nodeoffset; +int len; +u8 tmp[8 *16 ];/* Up to 64-bit address + 64-bit size */ + +if (areas >8 ) { +printf ("%s: num areas %d exceeds hardcoded limit %d\n" , + __func__, areas,8 ); +return -1 ; + } + + err =fdt_check_header (blob); +if (err <0 ) { +printf ("%s: %s\n" , __func__,fdt_strerror (err)); +return err; + } + +/* find or create "/memory" node. */ + nodeoffset =fdt_find_or_add_subnode (blob,0 ,"memory" ); +if (nodeoffset <0 ) +return nodeoffset; + + len =fdt_pack_reg (blob, tmp, start, size, areas); + + err =fdt_setprop (blob, nodeoffset,"linux,usable-memory" , tmp, len); +if (err <0 ) { +printf ("WARNING: could not set %s %s.\n" , +"reg" ,fdt_strerror (err)); +return err; + } + +return 0 ; +}#endif int fdt_fixup_memory (void *blob,u64 start,u64 size)
include/fdt_support.h +1 -0
@@ -94,6 +94,7 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size);*/ #ifdef CONFIG_ARCH_FIXUP_FDT_MEMORY int fdt_fixup_memory_banks (void *blob,u64 start[],u64 size[],int banks); +int fdt_set_usable_memory (void *blob,u64 start[],u64 size[],int banks);#else static inline int fdt_fixup_memory_banks (void *blob,u64 start[],u64 size[],int banks)
Signature · 1 line
2.17.1
PATCH v2 2/2 board: colibri_imx7: reserve DDR memory for Cortex-M4
In reply to Igor OpaniukFrom: Igor Opaniuk <[email protected]>
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.
---
arch/arm/include/asm/mach-imx/sys_proto.h | 2 ++ board/toradex/colibri_imx7/colibri_imx7.c | 37 +++++++++++++++++++++++ 2 files changed, 39 insertions(+)
arch/arm/include/asm/mach-imx/sys_proto.h +2 -0
@@ -153,6 +153,8 @@ void init_src(void);void init_snvs (void );void imx_wdog_disable_powerdown (void ); +int arch_auxiliary_core_check_up (u32 core_id); +int board_mmc_get_env_dev (int devno);int nxp_board_rev (void );
board/toradex/colibri_imx7/colibri_imx7.c +37 -0
@@ -333,6 +333,43 @@ int checkboard(void) #if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) int ft_board_setup(void *blob, bd_t *bd) { +#if defined(CONFIG_IMX_BOOTAUX) && defined(CONFIG_ARCH_FIXUP_FDT_MEMORY) + 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); + } +#endif #if defined(CONFIG_FDT_FIXUP_PARTITIONS) static const struct node_info nodes[] = { { "fsl,imx7d-gpmi-nand", MTD_DEV_TYPE_NAND, }, /* NAND flash */
Signature · 1 line
2.17.1
PATCH v2 1/2 common: fdt_support: add support for setting usable memory
In reply to Igor OpaniukQuoted 7 lines · Igor Opaniuk
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
From: Igor Opaniuk <[email protected]>
Add support for setting linux,usable-memory property in the memory node of device tree for the kernel [1].
Isn't this same/similar to fdt_add_mem_rsv() ?
Jocke
PATCH v2 1/2 common: fdt_support: add support for setting usable memory
Hi Joakim,
Quoted 11 lines · Joakim Tjernlund
Quoted 7 lines · Igor Opaniuk
CAUTION: This email originated from outside of the organization. Do not click links or open attachments unless you recognize the sender and know the content is safe.
From: Igor Opaniuk <[email protected]>
Add support for setting linux,usable-memory property in the memory node of device tree for the kernel [1].
Isn't this same/similar to
fdt_add_mem_rsv()?
I would say they are opposite :)
- linux,usable-memory property let the kernel be aware about all the memory he can use.
- memreserve - what memory to exclude.
I think both should be helpful.
Quoted 3 lines
Jocke
Thanks
Signature · 8 lines
Best regards - Freundliche Grüsse - Meilleures salutations Igor Opaniuk mailto: igor.opaniuk at gmail.com skype: igor.opanyuk +380 (93) 836 40 67 http://ua.linkedin.com/in/iopaniuk