xref: /linux/arch/arm/mach-omap2/omap-secure.h (revision 48840e16c299d886a1fc333375f0564c34cab127)
1d2912cb1SThomas Gleixner /* SPDX-License-Identifier: GPL-2.0-only */
2c1db9d73STony Lindgren /*
3c1db9d73STony Lindgren  * omap-secure.h: OMAP Secure infrastructure header.
4c1db9d73STony Lindgren  *
5c1db9d73STony Lindgren  * Copyright (C) 2011 Texas Instruments, Inc.
6c1db9d73STony Lindgren  *	Santosh Shilimkar <santosh.shilimkar@ti.com>
74748a724SPali Rohár  * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
84748a724SPali Rohár  * Copyright (C) 2013 Pali Rohár <pali.rohar@gmail.com>
9c1db9d73STony Lindgren  */
10c1db9d73STony Lindgren #ifndef OMAP_ARCH_OMAP_SECURE_H
11c1db9d73STony Lindgren #define OMAP_ARCH_OMAP_SECURE_H
12c1db9d73STony Lindgren 
13dbebc8bfSAndrew F. Davis #include <linux/types.h>
14dbebc8bfSAndrew F. Davis 
15c1db9d73STony Lindgren /* Monitor error code */
16c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR	0xFFFFFFFE
17c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_SERVICE_UNKNWON		0xFFFFFFFF
18c1db9d73STony Lindgren 
19c1db9d73STony Lindgren /* HAL API error codes */
20c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_OK		0x00
21c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_FAIL		0x01
22c1db9d73STony Lindgren 
23c1db9d73STony Lindgren /* Secure HAL API flags */
24c1db9d73STony Lindgren #define FLAG_START_CRITICAL		0x4
25c1db9d73STony Lindgren #define FLAG_IRQFIQ_MASK		0x3
26c1db9d73STony Lindgren #define FLAG_IRQ_ENABLE			0x2
27c1db9d73STony Lindgren #define FLAG_FIQ_ENABLE			0x1
28c1db9d73STony Lindgren #define NO_FLAG				0x0
29c1db9d73STony Lindgren 
30c1db9d73STony Lindgren /* Maximum Secure memory storage size */
31c1db9d73STony Lindgren #define OMAP_SECURE_RAM_STORAGE	(88 * SZ_1K)
32c1db9d73STony Lindgren 
33d09220a8STony Lindgren #define OMAP3_SAVE_SECURE_RAM_SZ	0x803F
34d09220a8STony Lindgren 
35c1db9d73STony Lindgren /* Secure low power HAL API index */
36c1db9d73STony Lindgren #define OMAP4_HAL_SAVESECURERAM_INDEX	0x1a
37c1db9d73STony Lindgren #define OMAP4_HAL_SAVEHW_INDEX		0x1b
38c1db9d73STony Lindgren #define OMAP4_HAL_SAVEALL_INDEX		0x1c
39c1db9d73STony Lindgren #define OMAP4_HAL_SAVEGIC_INDEX		0x1d
40c1db9d73STony Lindgren 
41c1db9d73STony Lindgren /* Secure Monitor mode APIs */
42c1db9d73STony Lindgren #define OMAP4_MON_SCU_PWR_INDEX		0x108
43c1db9d73STony Lindgren #define OMAP4_MON_L2X0_DBG_CTRL_INDEX	0x100
44c1db9d73STony Lindgren #define OMAP4_MON_L2X0_CTRL_INDEX	0x102
45c1db9d73STony Lindgren #define OMAP4_MON_L2X0_AUXCTRL_INDEX	0x109
46c1db9d73STony Lindgren #define OMAP4_MON_L2X0_PREFETCH_INDEX	0x113
47c1db9d73STony Lindgren 
485523e409SR Sricharan #define OMAP5_DRA7_MON_SET_CNTFRQ_INDEX	0x109
494664d4d8SSantosh Shilimkar #define OMAP5_MON_AMBA_IF_INDEX		0x108
50c0053bd5SNishanth Menon #define OMAP5_DRA7_MON_SET_ACR_INDEX	0x107
515523e409SR Sricharan 
52c1db9d73STony Lindgren /* Secure PPA(Primary Protected Application) APIs */
53c1db9d73STony Lindgren #define OMAP4_PPA_L2_POR_INDEX		0x23
54c1db9d73STony Lindgren #define OMAP4_PPA_CPU_ACTRL_SMP_INDEX	0x25
55c1db9d73STony Lindgren 
564748a724SPali Rohár /* Secure RX-51 PPA (Primary Protected Application) APIs */
574748a724SPali Rohár #define RX51_PPA_HWRNG			29
584748a724SPali Rohár #define RX51_PPA_L2_INVAL		40
594748a724SPali Rohár #define RX51_PPA_WRITE_ACR		42
604748a724SPali Rohár 
61c1db9d73STony Lindgren #ifndef __ASSEMBLER__
62c1db9d73STony Lindgren 
63c1db9d73STony Lindgren extern u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs,
64c1db9d73STony Lindgren 				u32 arg1, u32 arg2, u32 arg3, u32 arg4);
65*48840e16SAndrew F. Davis extern void omap_smccc_smc(u32 fn, u32 arg);
66*48840e16SAndrew F. Davis extern void omap_smc1(u32 fn, u32 arg);
67c1db9d73STony Lindgren extern u32 omap_smc2(u32 id, u32 falg, u32 pargs);
68a33f1788SPali Rohár extern u32 omap_smc3(u32 id, u32 process, u32 flag, u32 pargs);
69c1db9d73STony Lindgren extern phys_addr_t omap_secure_ram_mempool_base(void);
70f7a9b8a1SLokesh Vutla extern int omap_secure_ram_reserve_memblock(void);
71d09220a8STony Lindgren extern u32 save_secure_ram_context(u32 args_pa);
72d09220a8STony Lindgren extern u32 omap3_save_secure_ram(void __iomem *save_regs, int size);
73c1db9d73STony Lindgren 
744748a724SPali Rohár extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
754748a724SPali Rohár 				  u32 arg1, u32 arg2, u32 arg3, u32 arg4);
764748a724SPali Rohár extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
77d2065e2bSPali Rohár extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
784748a724SPali Rohár 
79dbebc8bfSAndrew F. Davis extern bool optee_available;
80db711893SAndrew F. Davis void omap_secure_init(void);
81db711893SAndrew F. Davis 
8239cec622STony Lindgren #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
835523e409SR Sricharan void set_cntfreq(void);
8439cec622STony Lindgren #else
8539cec622STony Lindgren static inline void set_cntfreq(void)
8639cec622STony Lindgren {
8739cec622STony Lindgren }
8839cec622STony Lindgren #endif
8939cec622STony Lindgren 
90c1db9d73STony Lindgren #endif /* __ASSEMBLER__ */
91c1db9d73STony Lindgren #endif /* OMAP_ARCH_OMAP_SECURE_H */
92