Update from product codes
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / include / soc / sprd / sec_debug.h
1 /* include/mach/sec-debug.h
2  *
3  * Copyright (C) 2014 Samsung Electronics Co, Ltd.
4  *
5  * This software is licensed under the terms of the GNU General Public
6  * License version 2, as published by the Free Software Foundation, and
7  * may be copied, distributed, and modified under those terms.
8  *
9  * This program is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12  * GNU General Public License for more details.
13  */
14
15
16 #ifndef SEC_DEBUG_H
17 #define SEC_DEBUG_H
18
19 #include <linux/sched.h>
20 #include <linux/semaphore.h>
21 #include <soc/sprd/hardware.h>
22
23 #ifdef CONFIG_SEC_DEBUG
24
25 struct sec_log_buffer {
26         u32     sig;
27         u32     start;
28         u32     size;
29         u32     from;
30         u32     to;
31         u8      data[0];
32 };
33
34 union sec_debug_level_t {
35         struct {
36                 u16 kernel_fault;
37                 u16 user_fault;
38         } en;
39         u32 uint_val;
40 };
41
42 #ifdef CONFIG_ARCH_SCX15
43
44 #define SEC_DEBUG_MAGIC_VA      (SEC_DEBUG_MAGIC_BASE_VA)
45 #define SPRD_INFORM0                    (SEC_DEBUG_MAGIC_VA + 0x00000004)
46 #define SPRD_INFORM1                    (SPRD_INFORM0 + 0x00000004)
47 #define SPRD_INFORM2                    (SPRD_INFORM1 + 0x00000004)
48 #define SPRD_INFORM3                    (SPRD_INFORM2 + 0x00000004)
49 #define SPRD_INFORM4                    (SPRD_INFORM3 + 0x00000004)
50 #define SPRD_INFORM5                    (SPRD_INFORM4 + 0x00000004)
51 #define SPRD_INFORM6                    (SPRD_INFORM5 + 0x00000004)
52
53 #else
54
55 #define SEC_DEBUG_MAGIC_VA              (SPRD_IRAM0_BASE + 0x00000f80)
56 #define SPRD_INFORM0                    (SEC_DEBUG_MAGIC_VA + 0x00000004)
57 #define SPRD_INFORM1                    (SPRD_INFORM0 + 0x00000004)
58 #define SPRD_INFORM2                    (SPRD_INFORM1 + 0x00000004)
59 #define SPRD_INFORM3                    (SPRD_INFORM2 + 0x00000004)
60 #define SPRD_INFORM4                    (SPRD_INFORM3 + 0x00000004)
61 #define SPRD_INFORM5                    (SPRD_INFORM4 + 0x00000004)
62 #define SPRD_INFORM6                    (SPRD_INFORM5 + 0x00000004)
63
64 #endif
65
66 extern union sec_debug_level_t sec_debug_level;
67
68 extern int sec_debug_init(void);
69
70 extern int sec_debug_magic_init(void);
71
72 extern void sec_debug_check_crash_key(unsigned int code, int value);
73
74 extern void sec_getlog_supply_fbinfo(void *p_fb, u32 res_x, u32 res_y, u32 bpp,
75                                      u32 frames);
76 extern void sec_getlog_supply_loggerinfo(void *p_main, void *p_radio,
77                                         void *p_events, void *p_system);
78
79 extern void sec_getlog_supply_kloginfo(void *klog_buf);
80
81 extern void sec_gaf_supply_rqinfo(unsigned short curr_offset,
82                                   unsigned short rq_offset);
83
84 extern void sec_debug_save_pte(void *pte, int task_addr);
85
86 int sec_debug_dump_stack(void);
87
88 extern int get_sec_debug_level(void);
89 #else
90 static inline int sec_debug_init(void)
91 {
92         return 0;
93 }
94
95 static inline int sec_debug_magic_init(void)
96 {
97         return 0;
98 }
99
100 static inline void sec_debug_check_crash_key(unsigned int code, int value)
101 {
102 }
103
104 static inline void sec_getlog_supply_fbinfo(void *p_fb, u32 res_x, u32 res_y,
105                                             u32 bpp, u32 frames)
106 {
107 }
108
109 static inline void sec_getlog_supply_meminfo(u32 size0, u32 addr0, u32 size1,
110                                              u32 addr1)
111 {
112 }
113
114 static inline void sec_getlog_supply_loggerinfo(void *p_main,
115                                                 void *p_radio, void *p_events,
116                                                 void *p_system)
117 {
118 }
119
120 static inline void sec_getlog_supply_kloginfo(void *klog_buf)
121 {
122 }
123
124 static inline void sec_gaf_supply_rqinfo(unsigned short curr_offset,
125                                          unsigned short rq_offset)
126 {
127 }
128
129 void sec_debug_save_pte(void *pte, unsigned int faulttype);
130 {
131 }
132
133 static inline int get_sec_debug_level(void)
134 {
135 }
136 #endif
137
138 struct worker;
139 struct work_struct;
140
141 #ifdef CONFIG_SEC_DEBUG_SCHED_LOG
142 extern void __sec_debug_task_log(int cpu, struct task_struct *task);
143 extern void __sec_debug_irq_log(unsigned int irq, void *fn, int en);
144 extern void __sec_debug_work_log(struct worker *worker,
145                         struct work_struct *work, work_func_t f, int en);
146 #ifdef CONFIG_SEC_DEBUG_TIMER_LOG
147 extern void __sec_debug_timer_log(unsigned int type, void *fn);
148 #endif
149
150 static inline void sec_debug_task_log(int cpu, struct task_struct *task)
151 {
152         if (unlikely(sec_debug_level.en.kernel_fault))
153                 __sec_debug_task_log(cpu, task);
154 }
155
156 static inline void sec_debug_irq_log(unsigned int irq, void *fn, int en)
157 {
158         if (unlikely(sec_debug_level.en.kernel_fault))
159                 __sec_debug_irq_log(irq, fn, en);
160 }
161
162 static inline void sec_debug_work_log(struct worker *worker,
163                         struct work_struct *work, work_func_t f, int en)
164 {
165         if (unlikely(sec_debug_level.en.kernel_fault))
166                 __sec_debug_work_log(worker, work, f, en);
167 }
168
169 #ifdef CONFIG_SEC_DEBUG_TIMER_LOG
170 static inline void sec_debug_timer_log(unsigned int type, void *fn)
171 {
172         if (unlikely(sec_debug_level.en.kernel_fault))
173                 __sec_debug_timer_log(type, fn);
174 }
175 #else
176 static inline void sec_debug_timer_log(unsigned int type, void *fn)
177 {
178 }
179 #endif
180
181 #ifdef CONFIG_SEC_DEBUG_SOFTIRQ_LOG
182 static inline void sec_debug_softirq_log(unsigned int irq, void *fn, int en)
183 {
184         if (unlikely(sec_debug_level.en.kernel_fault))
185 #else
186 static inline void sec_debug_softirq_log(unsigned int irq, void *fn, int en)
187 {
188 }
189 #endif
190
191 #else
192 static inline void sec_debug_task_log(int cpu, struct task_struct *task)
193 {
194 }
195
196 static inline void sec_debug_irq_log(unsigned int irq, void *fn, int en)
197 {
198 }
199
200 static inline void sec_debug_work_log(struct worker *worker,
201                               struct work_struct *work, work_func_t f, int en)
202 {
203 }
204
205 static inline void sec_debug_timer_log(unsigned int type, void *fn)
206 {
207 }
208
209 static inline void sec_debug_softirq_log(unsigned int irq, void *fn, int en)
210 {
211 }
212 #endif
213 #ifdef CONFIG_SEC_DEBUG_IRQ_EXIT_LOG
214 extern void sec_debug_irq_last_exit_log(void);
215 #else
216 static inline void sec_debug_irq_last_exit_log(void)
217 {
218 }
219 #endif
220
221 #ifdef CONFIG_SEC_DEBUG_SEMAPHORE_LOG
222 extern void debug_semaphore_init(void);
223 extern void debug_semaphore_down_log(struct semaphore *sem);
224 extern void debug_semaphore_up_log(struct semaphore *sem);
225 extern void debug_rwsemaphore_init(void);
226 extern void debug_rwsemaphore_down_log(struct rw_semaphore *sem, int dir);
227 extern void debug_rwsemaphore_up_log(struct rw_semaphore *sem);
228 #define debug_rwsemaphore_down_read_log(x) \
229         debug_rwsemaphore_down_log(x, READ_SEM)
230 #define debug_rwsemaphore_down_write_log(x) \
231         debug_rwsemaphore_down_log(x, WRITE_SEM)
232 #else
233 static inline void debug_semaphore_init(void)
234 {
235 }
236
237 static inline void debug_semaphore_down_log(struct semaphore *sem)
238 {
239 }
240
241 static inline void debug_semaphore_up_log(struct semaphore *sem)
242 {
243 }
244
245 static inline void debug_rwsemaphore_init(void)
246 {
247 }
248
249 static inline void debug_rwsemaphore_down_read_log(struct rw_semaphore *sem)
250 {
251 }
252
253 static inline void debug_rwsemaphore_down_write_log(struct rw_semaphore *sem)
254 {
255 }
256
257 static inline void debug_rwsemaphore_up_log(struct rw_semaphore *sem)
258 {
259 }
260 #endif
261
262 enum sec_debug_aux_log_idx {
263         SEC_DEBUG_AUXLOG_CPU_BUS_CLOCK_CHANGE,
264         SEC_DEBUG_AUXLOG_LOGBUF_LOCK_CHANGE,
265         SEC_DEBUG_AUXLOG_ITEM_MAX,
266 };
267
268 #ifdef CONFIG_SEC_DEBUG_AUXILIARY_LOG
269 extern void sec_debug_aux_log(int idx, char *fmt, ...);
270 #else
271 #define sec_debug_aux_log(idx, ...) do { } while (0)
272 #endif
273
274 #endif /* SEC_DEBUG_H */