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> 8149ed3d4SPali Rohár * Copyright (C) 2013 Pali Rohár <pali@kernel.org> 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 */ 53b3d09a06SCarlos Leija #define OMAP4_PPA_SERVICE_0 0x21 54c1db9d73STony Lindgren #define OMAP4_PPA_L2_POR_INDEX 0x23 55c1db9d73STony Lindgren #define OMAP4_PPA_CPU_ACTRL_SMP_INDEX 0x25 56c1db9d73STony Lindgren 578ab871f8SAndrew F. Davis #define AM43xx_PPA_SVC_PM_SUSPEND 0x71 588ab871f8SAndrew F. Davis #define AM43xx_PPA_SVC_PM_RESUME 0x72 598ab871f8SAndrew F. Davis 604748a724SPali Rohár /* Secure RX-51 PPA (Primary Protected Application) APIs */ 614748a724SPali Rohár #define RX51_PPA_HWRNG 29 624748a724SPali Rohár #define RX51_PPA_L2_INVAL 40 634748a724SPali Rohár #define RX51_PPA_WRITE_ACR 42 644748a724SPali Rohár 65c1db9d73STony Lindgren #ifndef __ASSEMBLER__ 66c1db9d73STony Lindgren 67c1db9d73STony Lindgren extern u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, 68c1db9d73STony Lindgren u32 arg1, u32 arg2, u32 arg3, u32 arg4); 6948840e16SAndrew F. Davis extern void omap_smccc_smc(u32 fn, u32 arg); 7048840e16SAndrew F. Davis extern void omap_smc1(u32 fn, u32 arg); 71c1db9d73STony Lindgren extern u32 omap_smc2(u32 id, u32 falg, u32 pargs); 72a33f1788SPali Rohár extern u32 omap_smc3(u32 id, u32 process, u32 flag, u32 pargs); 73c1db9d73STony Lindgren extern phys_addr_t omap_secure_ram_mempool_base(void); 74f7a9b8a1SLokesh Vutla extern int omap_secure_ram_reserve_memblock(void); 75d09220a8STony Lindgren extern u32 save_secure_ram_context(u32 args_pa); 76*deb44711SArnd Bergmann extern u32 omap3_save_secure_ram(void *save_regs, int size); 77c1db9d73STony Lindgren 784748a724SPali Rohár extern u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs, 794748a724SPali Rohár u32 arg1, u32 arg2, u32 arg3, u32 arg4); 804748a724SPali Rohár extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits); 81d2065e2bSPali Rohár extern u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag); 824748a724SPali Rohár 83dbebc8bfSAndrew F. Davis extern bool optee_available; 84db711893SAndrew F. Davis void omap_secure_init(void); 85db711893SAndrew F. Davis 8639cec622STony Lindgren #ifdef CONFIG_SOC_HAS_REALTIME_COUNTER 875523e409SR Sricharan void set_cntfreq(void); 8839cec622STony Lindgren #else 8939cec622STony Lindgren static inline void set_cntfreq(void) 9039cec622STony Lindgren { 9139cec622STony Lindgren } 9239cec622STony Lindgren #endif 9339cec622STony Lindgren 94c1db9d73STony Lindgren #endif /* __ASSEMBLER__ */ 95c1db9d73STony Lindgren #endif /* OMAP_ARCH_OMAP_SECURE_H */ 96