import PULS_20160108
[GitHub/mt8127/android_kernel_alcatel_ttab.git] / drivers / misc / mediatek / uart / mt_fiq_debugger.c
1 #include <linux/device.h>
2 #include <linux/platform_device.h>
3 #include <linux/irq.h>
4 #include <linux/tty.h>
5 #include <linux/tty_flip.h>
6 #include <asm/fiq.h>
7 #include <asm/fiq_glue.h>
8 #include <asm/fiq_debugger.h>
9 #include <mach/irqs.h>
10 #include <mach/mt_reg_base.h>
11 #include <linux/uart/mtk_uart.h>
12 #include <linux/uart/mtk_uart_intf.h>
13
14 #define MT_UART_FIQ_ID MT_UART4_IRQ_ID
15
16 static void fiq_enable(struct platform_device *pdev, unsigned int fiq, bool enable)
17 {
18 if (enable)
19 enable_fiq(fiq);
20 else
21 disable_fiq(fiq);
22 }
23
24 static void fiq_dbg_force_irq(struct platform_device *pdev, unsigned int irq)
25 {
26 trigger_sw_irq(irq);
27 }
28
29 struct fiq_debugger_pdata fiq_serial_data = {
30 .uart_getc = &fiq_uart_getc,
31 .uart_putc = &fiq_uart_putc,
32 .fiq_enable = &fiq_enable,
33 .fiq_ack = 0,
34 .force_irq = &fiq_dbg_force_irq,
35 .force_irq_ack = 0,
36 };
37
38 struct resource fiq_resource[] = {
39 [0] = {
40 .start = FIQ_DBG_SGI,
41 .end = FIQ_DBG_SGI,
42 .flags = IORESOURCE_IRQ,
43 .name = "signal",
44 },
45 [1] = {
46 .start = MT_UART_FIQ_ID,
47 .end = MT_UART_FIQ_ID,
48 .flags = IORESOURCE_IRQ,
49 .name = "fiq",
50 },
51 };
52
53 struct platform_device mt_fiq_debugger = {
54 .name = "fiq_debugger",
55 .id = -1,
56 .dev = {
57 .platform_data = &fiq_serial_data,
58 },
59 .num_resources = ARRAY_SIZE(fiq_resource),
60 .resource = fiq_resource,
61 };
62
63 void mt_fiq_printf(const char *fmt, ...)
64 {
65 char buf[256];
66 va_list ap;
67 unsigned c;
68 char *s;
69
70 va_start(ap, fmt);
71 vsnprintf(buf, sizeof(buf), fmt, ap);
72 va_end(ap);
73
74 s = (char *)buf;
75 while ((c = *s++)) {
76 #if 0
77 if (c == '\n') {
78 fiq_uart_putc(NULL, '\r');
79 }
80 #endif
81 fiq_uart_putc(NULL, c);
82 }
83 }