From c35ed767cecf14521216304c1f4565b0d1cc6757 Mon Sep 17 00:00:00 2001
From: Jianqun Xu <jay.xu@rock-chips.com>
Date: Tue, 20 Oct 2015 08:42:59 +0800
Subject: [PATCH] ARM: rockchip-psci: add interface for ion to set memory
 secured

Add function "psci_set_memory_secure" for device to set memory
region secured.

Change-Id: Ife807c91d37ae66a5e1a0a3d8263c68cd601937d
Signed-off-by: Jianqun Xu <jay.xu@rock-chips.com>
---
 arch/arm/mach-rockchip/psci.c | 5 +++++
 include/linux/rockchip/psci.h | 9 +++++++++
 2 files changed, 14 insertions(+)

diff --git a/arch/arm/mach-rockchip/psci.c b/arch/arm/mach-rockchip/psci.c
index 82293468e3c9..3132c2d4c467 100644
--- a/arch/arm/mach-rockchip/psci.c
+++ b/arch/arm/mach-rockchip/psci.c
@@ -187,6 +187,11 @@ u32 rockchip_psci_smc_get_tf_ver(void)
 	return reg_rd_fn(PSCI_SIP_RKTF_VER, 0, 0, 0, NULL);
 }
 
+u32 psci_set_memory_secure(bool val)
+{
+	return reg_wr_fn(PSCI_SIP_SMEM_CONFIG, val, 0, 0);
+}
+
 /*************************** fiq debug *****************************/
 #ifdef CONFIG_ARM64
 static u64 ft_fiq_mem_phy;
diff --git a/include/linux/rockchip/psci.h b/include/linux/rockchip/psci.h
index 2ce8ae73e4cd..7a3eed6f9853 100644
--- a/include/linux/rockchip/psci.h
+++ b/include/linux/rockchip/psci.h
@@ -63,4 +63,13 @@ u32 psci_fiq_debugger_switch_cpu(u32 cpu);
 void psci_fiq_debugger_uart_irq_tf_init(u32 irq_id, void *callback);
 void psci_fiq_debugger_enable_debug(bool val);
 
+#if defined(CONFIG_ARM_PSCI) || defined(CONFIG_ARM64)
+u32 psci_set_memory_secure(bool val);
+#else
+static inline u32 psci_set_memory_secure(bool val)
+{
+	return 0;
+}
+#endif
+
 #endif /* __ROCKCHIP_PSCI_H */
-- 
2.34.1