blob: 4ec736f5dbd1d897d4ef15434f6a30f67e0863fb [file] [log] [blame]
Andreas Dannenberg6469e1a2016-06-27 09:19:18 -05001/*
2 *
3 * Common security related functions for OMAP devices
4 *
5 * (C) Copyright 2016
6 * Texas Instruments, <www.ti.com>
7 *
8 * Daniel Allred <d-allred@ti.com>
9 * Andreas Dannenberg <dannenberg@ti.com>
10 *
11 * SPDX-License-Identifier: GPL-2.0+
12 */
13
14#include <common.h>
15#include <stdarg.h>
16
17#include <asm/arch/sys_proto.h>
18#include <asm/omap_common.h>
19#include <asm/omap_sec_common.h>
20
21static uint32_t secure_rom_call_args[5] __aligned(ARCH_DMA_MINALIGN);
22
23u32 secure_rom_call(u32 service, u32 proc_id, u32 flag, ...)
24{
25 int i;
26 u32 num_args;
27 va_list ap;
28
29 va_start(ap, flag);
30
31 num_args = va_arg(ap, u32);
32
33 if (num_args > 4)
34 return 1;
35
36 /* Copy args to aligned args structure */
37 for (i = 0; i < num_args; i++)
38 secure_rom_call_args[i + 1] = va_arg(ap, u32);
39
40 secure_rom_call_args[0] = num_args;
41
42 va_end(ap);
43
44 /* if data cache is enabled, flush the aligned args structure */
45 flush_dcache_range(
46 (unsigned int)&secure_rom_call_args[0],
47 (unsigned int)&secure_rom_call_args[0] +
48 roundup(sizeof(secure_rom_call_args), ARCH_DMA_MINALIGN));
49
50 return omap_smc_sec(service, proc_id, flag, secure_rom_call_args);
51}