1 #include <linux/proc_fs.h>
2 #include <linux/sched.h>
3 #include <linux/seq_file.h>
4 #include <linux/kallsyms.h>
5 #include <linux/utsname.h>
6 #include <asm/uaccess.h>
8 #include <linux/module.h>
11 #include <linux/irq.h>
12 #include <linux/interrupt.h>
14 #include <linux/aee.h>
15 #include <linux/stacktrace.h>
17 #include <linux/printk.h>
19 /* Some utility macro*/
20 #define SEQ_printf(m, x...) \
28 #define MT_DEBUG_ENTRY(name) \
29 static int mt_##name##_show(struct seq_file *m, void *v);\
30 static ssize_t mt_##name##_write(struct file *filp, const char *ubuf, ssize_t cnt, loff_t *data);\
31 static int mt_##name##_open(struct inode *inode, struct file *file) \
33 return single_open(file, mt_##name##_show, inode->i_private); \
36 static const struct file_operations mt_##name##_fops = { \
37 .open = mt_##name##_open, \
38 .write = mt_##name##_write,\
40 .llseek = seq_lseek, \
41 .release = single_release, \
43 void mt_##name##_switch(int on);
46 * Ease the printing of nsec fields:
49 static long long nsec_high(unsigned long long nsec)
51 if ((long long)nsec < 0) {
53 do_div(nsec, 1000000);
56 do_div(nsec, 1000000);
61 static unsigned long nsec_low(unsigned long long nsec)
63 if ((long long)nsec < 0)
66 return do_div(nsec, 1000000);
68 #define SPLIT_NS(x) nsec_high(x), nsec_low(x)
71 /* //////////////////////////////////////////////////////// */
72 /* --------------------------------------------------- */
74 /* --------------------------------------------------- */
75 /* Define Proc entry */
76 /* --------------------------------------------------- */
77 MT_DEBUG_ENTRY(printk_ctrl
);
78 int mt_need_uart_console
= 0;
79 extern void mt_enable_uart(void); /* printk.c */
80 extern void mt_disable_uart(void); /* printk.c */
81 extern bool printk_disable_uart
;
82 static int mt_printk_ctrl_show(struct seq_file
*m
, void *v
)
84 SEQ_printf(m
, "=== mt printk controller ===\n");
85 SEQ_printf(m
, "mt_need_uart_console:%d, printk_disable_uart:%d\n", mt_need_uart_console
,
91 static ssize_t
mt_printk_ctrl_write(struct file
*filp
, const char *ubuf
, ssize_t cnt
, loff_t
*data
)
96 if (cnt
>= sizeof(buf
))
99 if (copy_from_user(&buf
, ubuf
, cnt
))
104 ret
= strict_strtoul(buf
, 10, (unsigned long *)&val
);
107 } else if (val
== 1) {
108 mt_need_uart_console
= 1;
110 pr_err("need uart log\n");
114 pr_err(" %d\n", val
);
118 //[BUGFIX]-Add-BEGIN by SCDTABLET.(fangyou.wang),10/10/2015,1097303,
119 //auto reboot after power off
120 void force_enable_uart_log(void)
122 if(mt_need_uart_console
){
123 pr_err("uart log alrady opened!!!!\n");
127 mt_need_uart_console
= 1;
129 pr_err("--------------need uart log,force open uart log now-------------\n");
132 //[BUGFIX]-Add-END by SCDTABLET.(fangyou.wang)
134 static int __init
init_mt_printk_ctrl(void)
136 struct proc_dir_entry
*pe
;
137 mt_need_uart_console
= 0; /* defualt, no uart */
138 pe
= proc_create("mtprintk", 0664, NULL
, &mt_printk_ctrl_fops
);
144 __initcall(init_mt_printk_ctrl
);