1
2
3
4
5
6
7
8
9
10
11
12
13
14
15#include <linux/kernel.h>
16#include <linux/init.h>
17#include <linux/io.h>
18#include <linux/memblock.h>
19
20#include <asm/cacheflush.h>
21#include <asm/memblock.h>
22
23#include "omap-secure.h"
24
25static phys_addr_t omap_secure_memblock_base;
26
27
28
29
30
31
32
33
34
35
36
37u32 omap_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2,
38 u32 arg3, u32 arg4)
39{
40 u32 ret;
41 u32 param[5];
42
43 param[0] = nargs;
44 param[1] = arg1;
45 param[2] = arg2;
46 param[3] = arg3;
47 param[4] = arg4;
48
49
50
51
52
53 flush_cache_all();
54 outer_clean_range(__pa(param), __pa(param + 5));
55 ret = omap_smc2(idx, flag, __pa(param));
56
57 return ret;
58}
59
60
61int __init omap_secure_ram_reserve_memblock(void)
62{
63 u32 size = OMAP_SECURE_RAM_STORAGE;
64
65 size = ALIGN(size, SECTION_SIZE);
66 omap_secure_memblock_base = arm_memblock_steal(size, SECTION_SIZE);
67
68 return 0;
69}
70
71phys_addr_t omap_secure_ram_mempool_base(void)
72{
73 return omap_secure_memblock_base;
74}
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89u32 rx51_secure_dispatcher(u32 idx, u32 process, u32 flag, u32 nargs,
90 u32 arg1, u32 arg2, u32 arg3, u32 arg4)
91{
92 u32 ret;
93 u32 param[5];
94
95 param[0] = nargs+1;
96 param[1] = arg1;
97 param[2] = arg2;
98 param[3] = arg3;
99 param[4] = arg4;
100
101
102
103
104
105 local_irq_disable();
106 local_fiq_disable();
107 flush_cache_all();
108 outer_clean_range(__pa(param), __pa(param + 5));
109 ret = omap_smc3(idx, process, flag, __pa(param));
110 flush_cache_all();
111 local_fiq_enable();
112 local_irq_enable();
113
114 return ret;
115}
116
117
118
119
120
121
122
123
124u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits)
125{
126 u32 acr;
127
128
129 asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
130 acr &= ~clear_bits;
131 acr |= set_bits;
132
133 return rx51_secure_dispatcher(RX51_PPA_WRITE_ACR,
134 0,
135 FLAG_START_CRITICAL,
136 1, acr, 0, 0, 0);
137}
138
139
140
141
142u32 rx51_secure_rng_call(u32 ptr, u32 count, u32 flag)
143{
144 return rx51_secure_dispatcher(RX51_PPA_HWRNG,
145 0,
146 NO_FLAG,
147 3, ptr, count, flag, 0);
148}
149