bq2415x_charger.patch: Make sure that hook function can be called for init reported...
[kernel-power] / kernel-power-2.6.28 / debian / patches / rx51_add_secure_ppa_api.diff
1 Index: kernel-cssu-2.6.28/arch/arm/mach-omap2/Makefile
2 ===================================================================
3 --- kernel-cssu-2.6.28.orig/arch/arm/mach-omap2/Makefile        2012-05-25 02:00:58.981062096 -0400
4 +++ kernel-cssu-2.6.28/arch/arm/mach-omap2/Makefile     2012-05-25 01:58:35.689019000 -0400
5 @@ -100,7 +100,9 @@
6                                            board-rx51-peripherals.o \
7                                            mmc-twl4030.o \
8                                            ssi.o \
9 -                                          usb-musb.o
10 +                                          usb-musb.o \
11 +                                          board-rx51-smc.o board-rx51-secure.o
12 +
13  obj-$(CONFIG_MACH_NOKIA_RX71)          += board-rx71.o \
14                                            board-rx71-peripherals.o
15  
16 Index: kernel-cssu-2.6.28/arch/arm/mach-omap2/board-rx51-secure.c
17 ===================================================================
18 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
19 +++ kernel-cssu-2.6.28/arch/arm/mach-omap2/board-rx51-secure.c  2012-05-25 01:58:35.689019000 -0400
20 @@ -0,0 +1,66 @@
21 +/*
22 + * RX51 Secure PPA API.
23 + *
24 + * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
25 + *
26 + *
27 + * This program is free software,you can redistribute it and/or modify
28 + * it under the terms of the GNU General Public License version 2 as
29 + * published by the Free Software Foundation.
30 + */
31 +#include <asm/cacheflush.h>
32 +
33 +#include "board-rx51-secure.h"
34 +
35 +/**
36 + * rx51_secure_dispatcher: Routine to dispatch secure PPA API calls
37 + * @idx: The PPA API index
38 + * @flag: The flag indicating criticality of operation
39 + * @nargs: Number of valid arguments out of four.
40 + * @arg1, arg2, arg3 args4: Parameters passed to secure API
41 + *
42 + * Return the non-zero error value on failure.
43 + */
44 +u32 rx51_secure_dispatcher(u32 idx, u32 flag, u32 nargs, u32 arg1, u32 arg2,
45 +                          u32 arg3, u32 arg4)
46 +{
47 +       u32 ret;
48 +       u32 param[5];
49 +
50 +       param[0] = nargs+1;
51 +       param[1] = arg1;
52 +       param[2] = arg2;
53 +       param[3] = arg3;
54 +       param[4] = arg4;
55 +
56 +       /*
57 +        * Secure API needs physical address
58 +        * pointer for the parameters
59 +        */
60 +       flush_cache_all();
61 +       outer_clean_range(__pa(param), __pa(param + 5));
62 +       ret = rx51_ppa_smc(idx, flag, __pa(param));
63 +
64 +       return ret;
65 +}
66 +
67 +/**
68 + * rx51_secure_update_aux_cr: Routine to modify the contents of Auxiliary Control Register
69 + *  @set_bits: bits to set in ACR
70 + *  @clr_bits: bits to clear in ACR
71 + *
72 + * Return the non-zero error value on failure.
73 +*/
74 +u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits)
75 +{
76 +       u32 acr;
77 +
78 +       /* Read ACR */
79 +       asm volatile ("mrc p15, 0, %0, c1, c0, 1" : "=r" (acr));
80 +       acr &= ~clear_bits;
81 +       acr |= set_bits;
82 +
83 +       return rx51_secure_dispatcher(RX51_PPA_WRITE_ACR,
84 +                              FLAG_START_CRITICAL,
85 +                              1,acr,0,0,0);
86 +}
87 Index: kernel-cssu-2.6.28/arch/arm/mach-omap2/board-rx51-secure.h
88 ===================================================================
89 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
90 +++ kernel-cssu-2.6.28/arch/arm/mach-omap2/board-rx51-secure.h  2012-05-25 01:58:35.689019000 -0400
91 @@ -0,0 +1,36 @@
92 +/*
93 + * board-rx51-secure.h: OMAP Secure infrastructure header.
94 + *
95 + * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
96 + *
97 + * This program is free software; you can redistribute it and/or modify
98 + * it under the terms of the GNU General Public License version 2 as
99 + * published by the Free Software Foundation.
100 + */
101 +#ifndef OMAP_RX51_SECURE_H
102 +#define OMAP_RX51_SECURE_H
103 +
104 +/* HAL API error codes */
105 +#define  API_HAL_RET_VALUE_OK           0x00
106 +#define  API_HAL_RET_VALUE_FAIL         0x01
107 +
108 +/* Secure HAL API flags */
109 +#define FLAG_START_CRITICAL             0x4
110 +#define FLAG_IRQFIQ_MASK                0x3
111 +#define FLAG_IRQ_ENABLE                 0x2
112 +#define FLAG_FIQ_ENABLE                 0x1
113 +#define NO_FLAG                         0x0
114 +
115 +/* Secure PPA(Primary Protected Application) APIs */
116 +#define RX51_PPA_L2_INVAL               40
117 +#define RX51_PPA_WRITE_ACR              42
118 +
119 +#ifndef __ASSEMBLER__
120 +
121 +extern u32 rx51_secure_dispatcher(u32 idx, u32 flag, u32 nargs,
122 +                                u32 arg1, u32 arg2, u32 arg3, u32 arg4);
123 +extern u32 rx51_ppa_smc(u32 id, u32 flag, u32 pargs);
124 +
125 +extern u32 rx51_secure_update_aux_cr(u32 set_bits, u32 clear_bits);
126 +#endif /* __ASSEMBLER__ */
127 +#endif /* OMAP_RX51_SECURE_H */
128 Index: kernel-cssu-2.6.28/arch/arm/mach-omap2/board-rx51-smc.S
129 ===================================================================
130 --- /dev/null   1970-01-01 00:00:00.000000000 +0000
131 +++ kernel-cssu-2.6.28/arch/arm/mach-omap2/board-rx51-smc.S     2012-05-25 02:09:15.244206814 -0400
132 @@ -0,0 +1,33 @@
133 +/*
134 + * RX51 secure APIs file.
135 + *
136 + * Copyright (C) 2012 Ivaylo Dimitrov <freemangordon@abv.bg>
137 + *
138 + *
139 + * This program is free software,you can redistribute it and/or modify
140 + * it under the terms of the GNU General Public License version 2 as
141 + * published by the Free Software Foundation.
142 + */
143 +
144 +#include <linux/linkage.h>
145 +
146 +/**
147 + * u32 rx51_ppa_smc(u32 id, u32 flag, u32 pargs)
148 + * Low level common routine for secure HAL and PPA APIs.
149 + * @id: Secure Service ID
150 + * @flag: Flag to indicate the criticality of operation
151 + * @pargs: Physical address of parameter list starting
152 + *          with number of parametrs
153 + */
154 +ENTRY(rx51_ppa_smc)
155 +        stmfd   sp!, {r4-r12, lr}
156 +        mov     r12, r0         @ Copy the secure service ID
157 +        mov     r3, r2          @ Copy the pointer to va_list in R3
158 +        mov     r2, r1          @ Copy the flags in R2
159 +        mov     r1, #0x0        @ Process ID - 0
160 +        mov     r6, #0xff       @ Indicate new Task call
161 +        dsb
162 +        dmb
163 +        .word  0xe1600071      @ SMC #1 to call PPA service - hand assembled
164 +        ldmfd   sp!, {r4-r12, pc}
165 +ENDPROC(rx51_ppa_smc)