xref: /openbmc/linux/arch/arm/mach-omap2/omap-secure.h (revision db711893eac81442fb5cde3801e183d3abfe5693)
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 
13c1db9d73STony Lindgren /* Monitor error code */
14c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_NS2S_CONVERSION_ERROR	0xFFFFFFFE
15c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_SERVICE_UNKNWON		0xFFFFFFFF
16c1db9d73STony Lindgren 
17c1db9d73STony Lindgren /* HAL API error codes */
18c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_OK		0x00
19c1db9d73STony Lindgren #define  API_HAL_RET_VALUE_FAIL		0x01
20c1db9d73STony Lindgren 
21c1db9d73STony Lindgren /* Secure HAL API flags */
22c1db9d73STony Lindgren #define FLAG_START_CRITICAL		0x4
23c1db9d73STony Lindgren #define FLAG_IRQFIQ_MASK		0x3
24c1db9d73STony Lindgren #define FLAG_IRQ_ENABLE			0x2
25c1db9d73STony Lindgren #define FLAG_FIQ_ENABLE			0x1
26c1db9d73STony Lindgren #define NO_FLAG				0x0
27c1db9d73STony Lindgren 
28c1db9d73STony Lindgren /* Maximum Secure memory storage size */
29c1db9d73STony Lindgren #define OMAP_SECURE_RAM_STORAGE	(88 * SZ_1K)
30c1db9d73STony Lindgren 
31d09220a8STony Lindgren #define OMAP3_SAVE_SECURE_RAM_SZ	0x803F
32d09220a8STony Lindgren 
33c1db9d73STony Lindgren /* Secure low power HAL API index */
34c1db9d73STony Lindgren #define OMAP4_HAL_SAVESECURERAM_INDEX	0x1a
35c1db9d73STony Lindgren #define OMAP4_HAL_SAVEHW_INDEX		0x1b
36c1db9d73STony Lindgren #define OMAP4_HAL_SAVEALL_INDEX		0x1c
37c1db9d73STony Lindgren #define OMAP4_HAL_SAVEGIC_INDEX		0x1d
38c1db9d73STony Lindgren 
39c1db9d73STony Lindgren /* Secure Monitor mode APIs */
40c1db9d73STony Lindgren #define OMAP4_MON_SCU_PWR_INDEX		0x108
41c1db9d73STony Lindgren #define OMAP4_MON_L2X0_DBG_CTRL_INDEX	0x100
42c1db9d73STony Lindgren #define OMAP4_MON_L2X0_CTRL_INDEX	0x102
43c1db9d73STony Lindgren #define OMAP4_MON_L2X0_AUXCTRL_INDEX	0x109
44c1db9d73STony Lindgren #define OMAP4_MON_L2X0_PREFETCH_INDEX	0x113
45c1db9d73STony Lindgren 
465523e409SR Sricharan #define OMAP5_DRA7_MON_SET_CNTFRQ_INDEX	0x109
474664d4d8SSantosh Shilimkar #define OMAP5_MON_AMBA_IF_INDEX		0x108
48c0053bd5SNishanth Menon #define OMAP5_DRA7_MON_SET_ACR_INDEX	0x107
495523e409SR Sricharan 
50c1db9d73STony Lindgren /* Secure PPA(Primary Protected Application) APIs */
51c1db9d73STony Lindgren #define OMAP4_PPA_L2_POR_INDEX		0x23
52c1db9d73STony Lindgren #define OMAP4_PPA_CPU_ACTRL_SMP_INDEX	0x25
53c1db9d73STony Lindgren 
544748a724SPali Rohár /* Secure RX-51 PPA (Primary Protected Application) APIs */
554748a724SPali Rohár #define RX51_PPA_HWRNG			29
564748a724SPali Rohár #define RX51_PPA_L2_INVAL		40
574748a724SPali Rohár #define RX51_PPA_WRITE_ACR		42
584748a724SPali Rohár 
59c1db9d73STony Lindgren #ifndef __ASSEMBLER__
60c1db9d73STony Lindgren 
61c1db9d73STony Lindgren extern u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs,
62c1db9d73STony Lindgren 				u32 arg1, u32 arg2, u32 arg3, u32 arg4);
63c1db9d73STony Lindgren extern u32 omap_smc2(u32 id, u32 falg, u32 pargs);
64a33f1788SPali Rohár extern u32 omap_smc3(u32 id, u32 process, u32 flag, u32 pargs);
65c1db9d73STony Lindgren extern phys_addr_t omap_secure_ram_mempool_base(void);
66f7a9b8a1SLokesh Vutla extern int omap_secure_ram_reserve_memblock(void);
67d09220a8STony Lindgren extern u32 save_secure_ram_context(u32 args_pa);
68d09220a8STony Lindgren extern u32 omap3_save_secure_ram(void __iomem *save_regs, int size);
69c1db9d73STony Lindgren 
704748a724SPali Rohár extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
714748a724SPali Rohár 				  u32 arg1, u32 arg2, u32 arg3, u32 arg4);
724748a724SPali Rohár extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
73d2065e2bSPali Rohár extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag);
744748a724SPali Rohár 
75*db711893SAndrew F. Davis void omap_secure_init(void);
76*db711893SAndrew F. Davis 
7739cec622STony Lindgren #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER
785523e409SR Sricharan void set_cntfreq(void);
7939cec622STony Lindgren #else
8039cec622STony Lindgren static inline void set_cntfreq(void)
8139cec622STony Lindgren {
8239cec622STony Lindgren }
8339cec622STony Lindgren #endif
8439cec622STony Lindgren 
85c1db9d73STony Lindgren #endif /* __ASSEMBLER__ */
86c1db9d73STony Lindgren #endif /* OMAP_ARCH_OMAP_SECURE_H */
87