Commit 259ee57a authored by Santosh Shilimkar's avatar Santosh Shilimkar Committed by Kevin Hilman

ARM: OMAP: PM: Add support to allocate the memory for secure RAM

Allocate the memory to save secure ram context which needs
to be done when MPU is hitting OFF mode.

The ROM code expects a physical address to this memory
and hence use memblock APIs to reserve this memory as part
of .reserve() callback. Maximum size as per secure RAM requirements
is allocated.

To keep omap1 build working, omap-secure.h file is created
under plat-omap directory.
Signed-off-by: default avatarSantosh Shilimkar <santosh.shilimkar@ti.com>
Acked-by: default avatarJean Pihet <j-pihet@ti.com>
Reviewed-by: default avatarKevin Hilman <khilman@ti.com>
Tested-by: default avatarVishwanath BS <vishwanath.bs@ti.com>
Signed-off-by: default avatarKevin Hilman <khilman@ti.com>
parent ba9456ac
...@@ -26,6 +26,8 @@ ...@@ -26,6 +26,8 @@
#define FLAG_FIQ_ENABLE 0x1 #define FLAG_FIQ_ENABLE 0x1
#define NO_FLAG 0x0 #define NO_FLAG 0x0
/* Maximum Secure memory storage size */
#define OMAP_SECURE_RAM_STORAGE (88 * SZ_1K)
/* Secure low power HAL API index */ /* Secure low power HAL API index */
#define OMAP4_HAL_SAVESECURERAM_INDEX 0x1a #define OMAP4_HAL_SAVESECURERAM_INDEX 0x1a
...@@ -36,5 +38,6 @@ ...@@ -36,5 +38,6 @@
extern u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, extern u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs,
u32 arg1, u32 arg2, u32 arg3, u32 arg4); u32 arg1, u32 arg2, u32 arg3, u32 arg4);
extern u32 omap_smc2(u32 id, u32 falg, u32 pargs); extern u32 omap_smc2(u32 id, u32 falg, u32 pargs);
extern phys_addr_t omap_secure_ram_mempool_base(void);
#endif /* OMAP_ARCH_OMAP_SECURE_H */ #endif /* OMAP_ARCH_OMAP_SECURE_H */
...@@ -13,11 +13,14 @@ ...@@ -13,11 +13,14 @@
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/init.h> #include <linux/init.h>
#include <linux/io.h> #include <linux/io.h>
#include <linux/memblock.h>
#include <asm/cacheflush.h> #include <asm/cacheflush.h>
#include <mach/omap-secure.h> #include <mach/omap-secure.h>
static phys_addr_t omap_secure_memblock_base;
/** /**
* omap_sec_dispatcher: Routine to dispatch low power secure * omap_sec_dispatcher: Routine to dispatch low power secure
* service routines * service routines
...@@ -50,3 +53,29 @@ u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2, ...@@ -50,3 +53,29 @@ u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2,
return ret; return ret;
} }
/* Allocate the memory to save secure ram */
int __init omap_secure_ram_reserve_memblock(void)
{
phys_addr_t paddr;
u32 size = OMAP_SECURE_RAM_STORAGE;
size = ALIGN(size, SZ_1M);
paddr = memblock_alloc(size, SZ_1M);
if (!paddr) {
pr_err("%s: failed to reserve %x bytes\n",
__func__, size);
return -ENOMEM;
}
memblock_free(paddr, size);
memblock_remove(paddr, size);
omap_secure_memblock_base = paddr;
return 0;
}
phys_addr_t omap_secure_ram_mempool_base(void)
{
return omap_secure_memblock_base;
}
...@@ -22,6 +22,8 @@ ...@@ -22,6 +22,8 @@
#include <plat/vram.h> #include <plat/vram.h>
#include <plat/dsp.h> #include <plat/dsp.h>
#include <plat/omap-secure.h>
#define NO_LENGTH_CHECK 0xffffffff #define NO_LENGTH_CHECK 0xffffffff
...@@ -66,6 +68,7 @@ void __init omap_reserve(void) ...@@ -66,6 +68,7 @@ void __init omap_reserve(void)
omapfb_reserve_sdram_memblock(); omapfb_reserve_sdram_memblock();
omap_vram_reserve_sdram_memblock(); omap_vram_reserve_sdram_memblock();
omap_dsp_reserve_sdram_memblock(); omap_dsp_reserve_sdram_memblock();
omap_secure_ram_reserve_memblock();
} }
void __init omap_init_consistent_dma_size(void) void __init omap_init_consistent_dma_size(void)
......
#ifndef __OMAP_SECURE_H__
#define __OMAP_SECURE_H__
#include <linux/types.h>
#ifdef CONFIG_ARCH_OMAP2PLUS
extern int omap_secure_ram_reserve_memblock(void);
#else
static inline void omap_secure_ram_reserve_memblock(void)
{ }
#endif
#endif /* __OMAP_SECURE_H__ */
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment