tizen 2.4 release
[profile/mobile/platform/kernel/linux-3.10-sc7730.git] / drivers / platform / sprd / sec_getlog.c
1 /*
2  *  sec_getlog.c
3  *
4  */
5
6 #include <linux/module.h>
7 #include <linux/errno.h>
8 #include <asm/setup.h>
9
10 static struct {
11         u32 special_mark_1;
12         u32 special_mark_2;
13         u32 special_mark_3;
14         u32 special_mark_4;
15         void *p_fb;             /* it must be physical address */
16         u32 xres;
17         u32 yres;
18         u32 bpp;                /* color depth : 16 or 24 */
19         u32 frames;             /* frame buffer count : 2 */
20 } frame_buf_mark = {
21         .special_mark_1 = (('*' << 24) | ('^' << 16) | ('^' << 8) | ('*' << 0)),
22         .special_mark_2 = (('I' << 24) | ('n' << 16) | ('f' << 8) | ('o' << 0)),
23         .special_mark_3 = (('H' << 24) | ('e' << 16) | ('r' << 8) | ('e' << 0)),
24         .special_mark_4 = (('f' << 24) | ('b' << 16) | ('u' << 8) | ('f' << 0)),
25 };
26
27 void sec_getlog_supply_fbinfo(void *p_fb, u32 xres, u32 yres, u32 bpp,
28                               u32 frames)
29 {
30         if (p_fb) {
31                 pr_info("%s: 0x%p %d %d %d %d\n", __func__, p_fb, xres, yres,
32                         bpp, frames);
33                 if(strcmp(CONFIG_DEFAULT_HOSTNAME,"vlx") == 0)
34                 frame_buf_mark.p_fb = (p_fb - 0x012c2000);
35                 else
36                 frame_buf_mark.p_fb = p_fb;
37                 frame_buf_mark.xres = xres;
38                 frame_buf_mark.yres = yres;
39                 frame_buf_mark.bpp = bpp;
40                 frame_buf_mark.frames = frames;
41         }
42 }
43 EXPORT_SYMBOL(sec_getlog_supply_fbinfo);
44
45 static struct {
46         u32 special_mark_1;
47         u32 special_mark_2;
48         u32 special_mark_3;
49         u32 special_mark_4;
50         u32 log_mark_version;
51         u32 framebuffer_mark_version;
52         void *this;             /* this is used for addressing
53                                    log buffer in 2 dump files */
54         struct {
55                 u32 size;       /* memory block's size */
56                 u32 addr;       /* memory block'sPhysical address */
57         } mem[2];
58 } marks_ver_mark = {
59         .special_mark_1 = (('*' << 24) | ('^' << 16) | ('^' << 8) | ('*' << 0)),
60         .special_mark_2 = (('I' << 24) | ('n' << 16) | ('f' << 8) | ('o' << 0)),
61         .special_mark_3 = (('H' << 24) | ('e' << 16) | ('r' << 8) | ('e' << 0)),
62         .special_mark_4 = (('v' << 24) | ('e' << 16) | ('r' << 8) | ('s' << 0)),
63         .log_mark_version = 1,
64         .framebuffer_mark_version = 1,
65         .this = &marks_ver_mark,
66 };
67
68 /* mark for GetLog extraction */
69 static struct {
70         u32 special_mark_1;
71         u32 special_mark_2;
72         u32 special_mark_3;
73         u32 special_mark_4;
74         void *p_main;
75         void *p_radio;
76         void *p_events;
77         void *p_system;
78 } plat_log_mark = {
79         .special_mark_1 = (('*' << 24) | ('^' << 16) | ('^' << 8) | ('*' << 0)),
80         .special_mark_2 = (('I' << 24) | ('n' << 16) | ('f' << 8) | ('o' << 0)),
81         .special_mark_3 = (('H' << 24) | ('e' << 16) | ('r' << 8) | ('e' << 0)),
82         .special_mark_4 = (('p' << 24) | ('l' << 16) | ('o' << 8) | ('g' << 0)),
83 };
84
85 void sec_getlog_supply_loggerinfo(void *p_main,
86                                   void *p_radio, void *p_events, void *p_system)
87 {
88         pr_info("%s: 0x%p 0x%p 0x%p 0x%p\n", __func__, p_main, p_radio,
89                 p_events, p_system);
90         if(strcmp(CONFIG_DEFAULT_HOSTNAME,"vlx") == 0)
91         {
92                 plat_log_mark.p_main = p_main-0x012c2000;  // 0x2500000 means CONFIG_TEXT_OFFSET
93                 plat_log_mark.p_radio = p_radio-0x012c2000;
94                 plat_log_mark.p_events = p_events-0x012c2000;
95                 plat_log_mark.p_system = p_system-0x012c2000;
96         }
97         else
98         {
99                 plat_log_mark.p_main = p_main;
100                 plat_log_mark.p_radio = p_radio;
101                 plat_log_mark.p_events = p_events;
102                 plat_log_mark.p_system = p_system;
103         }
104
105 }
106 EXPORT_SYMBOL(sec_getlog_supply_loggerinfo);
107
108 static struct {
109         u32 special_mark_1;
110         u32 special_mark_2;
111         u32 special_mark_3;
112         u32 special_mark_4;
113         void *klog_buf;
114 } kernel_log_mark = {
115         .special_mark_1 = (('*' << 24) | ('^' << 16) | ('^' << 8) | ('*' << 0)),
116         .special_mark_2 = (('I' << 24) | ('n' << 16) | ('f' << 8) | ('o' << 0)),
117         .special_mark_3 = (('H' << 24) | ('e' << 16) | ('r' << 8) | ('e' << 0)),
118         .special_mark_4 = (('k' << 24) | ('l' << 16) | ('o' << 8) | ('g' << 0)),
119 };
120
121 void sec_getlog_supply_kloginfo(void *klog_buf)
122 {
123         pr_info("%s: 0x%p\n", __func__, klog_buf);
124         if(strcmp(CONFIG_DEFAULT_HOSTNAME,"vlx") == 0)
125         kernel_log_mark.klog_buf = klog_buf-0x012c2000; // for SPRD
126         else
127 #ifdef CONFIG_SEC_LOG_BUF_NOCACHE
128         //This is ugly code to support getlog tool(getlog tool doesnt support various vitual addr)
129         kernel_log_mark.klog_buf = 0xC6B00010;
130 #else
131         kernel_log_mark.klog_buf = klog_buf;
132 #endif
133 }
134 EXPORT_SYMBOL(sec_getlog_supply_kloginfo);
135
136 static int __init sec_getlog_init(void)
137 {
138         marks_ver_mark.mem[0].size =
139                 meminfo.bank[0].size;
140         marks_ver_mark.mem[0].addr = meminfo.bank[0].start;
141         marks_ver_mark.mem[1].size =
142                 meminfo.bank[1].size;
143         marks_ver_mark.mem[1].addr = meminfo.bank[1].start;
144
145         return 0;
146 }
147
148 core_initcall(sec_getlog_init);
149