2 * drivers/staging/android/fiq_debugger.c
4 * Serial Debugger Interface accessed through an FIQ interrupt.
6 * Copyright (C) 2008 Google, Inc.
8 * This software is licensed under the terms of the GNU General Public
9 * License version 2, as published by the Free Software Foundation, and
10 * may be copied, distributed, and modified under those terms.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
19 #include <linux/module.h>
21 #include <linux/console.h>
22 #include <linux/interrupt.h>
23 #include <linux/clk.h>
24 #include <linux/platform_device.h>
25 #include <linux/kernel_stat.h>
26 #include <linux/kmsg_dump.h>
27 #include <linux/irq.h>
28 #include <linux/delay.h>
29 #include <linux/reboot.h>
30 #include <linux/sched.h>
31 #include <linux/slab.h>
32 #include <linux/smp.h>
33 #include <linux/timer.h>
34 #include <linux/tty.h>
35 #include <linux/tty_flip.h>
36 #include <linux/wakelock.h>
38 #ifdef CONFIG_FIQ_GLUE
39 #include <asm/fiq_glue.h>
42 #include <linux/uaccess.h>
43 #include <linux/rockchip/grf.h>
44 #include <linux/rockchip/iomap.h>
45 #include <linux/rockchip/cpu.h>
47 #include "fiq_debugger.h"
48 #include "fiq_debugger_priv.h"
49 #include "fiq_debugger_ringbuf.h"
51 #ifdef CONFIG_RK29_WATCHDOG
52 extern void rk29_wdt_keepalive(void);
53 #define wdt_keepalive() rk29_wdt_keepalive()
55 #define wdt_keepalive() do {} while (0)
58 #define CMD_COUNT 0x0f
59 #define MAX_UNHANDLED_FIQ_COUNT 1000000
61 #ifdef CONFIG_ARCH_ROCKCHIP
62 #define MAX_FIQ_DEBUGGER_PORTS 1
64 #define MAX_FIQ_DEBUGGER_PORTS 4
67 struct fiq_debugger_state {
68 #ifdef CONFIG_FIQ_GLUE
69 struct fiq_glue_handler handler;
71 struct fiq_debugger_output output;
77 bool wakeup_irq_no_set_wake;
79 struct fiq_debugger_pdata *pdata;
80 struct platform_device *pdev;
82 char debug_cmd[DEBUG_MAX];
86 char debug_buf[DEBUG_MAX];
89 #ifdef CONFIG_ARCH_ROCKCHIP
90 char cmd_buf[CMD_COUNT+1][DEBUG_MAX];
96 bool ignore_next_wakeup_irq;
97 struct timer_list sleep_timer;
98 spinlock_t sleep_timer_lock;
100 struct wake_lock debugger_wake_lock;
103 atomic_t unhandled_fiq_count;
106 struct work_struct work;
107 spinlock_t work_lock;
108 char work_cmd[DEBUG_MAX];
110 #ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
111 spinlock_t console_lock;
112 struct console console;
113 struct tty_port tty_port;
114 struct fiq_debugger_ringbuf *tty_rbuf;
118 #ifdef CONFIG_ARCH_ROCKCHIP
119 unsigned int last_irqs[1024];
120 unsigned int last_local_irqs[NR_CPUS][32];
122 unsigned int last_irqs[NR_IRQS];
123 unsigned int last_local_timer_irqs[NR_CPUS];
127 #ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
128 struct tty_driver *fiq_tty_driver;
131 #ifdef CONFIG_FIQ_DEBUGGER_NO_SLEEP
132 static bool initial_no_sleep = true;
134 static bool initial_no_sleep;
137 #ifdef CONFIG_FIQ_DEBUGGER_CONSOLE_DEFAULT_ENABLE
138 static bool initial_debug_enable = true;
139 static bool initial_console_enable = true;
141 static bool initial_debug_enable;
142 static bool initial_console_enable;
145 static bool fiq_kgdb_enable;
147 static unsigned long jif = 0, recv_count0 = 0, recv_count1 = 0;
149 module_param_named(no_sleep, initial_no_sleep, bool, 0644);
150 module_param_named(debug_enable, initial_debug_enable, bool, 0644);
151 module_param_named(console_enable, initial_console_enable, bool, 0644);
152 module_param_named(kgdb_enable, fiq_kgdb_enable, bool, 0644);
154 void gic_set_irq_secure(struct irq_data *d);
155 void gic_set_irq_priority(struct irq_data *d, u8 pri);
157 #ifdef CONFIG_FIQ_DEBUGGER_WAKEUP_IRQ_ALWAYS_ON
159 void fiq_debugger_enable_wakeup_irq(struct fiq_debugger_state *state) {}
161 void fiq_debugger_disable_wakeup_irq(struct fiq_debugger_state *state) {}
164 void fiq_debugger_enable_wakeup_irq(struct fiq_debugger_state *state)
166 if (state->wakeup_irq < 0)
168 enable_irq(state->wakeup_irq);
169 if (!state->wakeup_irq_no_set_wake)
170 enable_irq_wake(state->wakeup_irq);
173 void fiq_debugger_disable_wakeup_irq(struct fiq_debugger_state *state)
175 if (state->wakeup_irq < 0)
177 disable_irq_nosync(state->wakeup_irq);
178 if (!state->wakeup_irq_no_set_wake)
179 disable_irq_wake(state->wakeup_irq);
183 static inline bool fiq_debugger_have_fiq(struct fiq_debugger_state *state)
185 return (state->fiq >= 0);
188 #ifdef CONFIG_FIQ_GLUE
189 static void fiq_debugger_force_irq(struct fiq_debugger_state *state)
191 unsigned int irq = state->signal_irq;
193 if (WARN_ON(!fiq_debugger_have_fiq(state)))
195 if (state->pdata->force_irq) {
196 state->pdata->force_irq(state->pdev, irq);
198 struct irq_chip *chip = irq_get_chip(irq);
199 if (chip && chip->irq_retrigger)
200 chip->irq_retrigger(irq_get_irq_data(irq));
205 static void fiq_debugger_uart_enable(struct fiq_debugger_state *state)
208 clk_enable(state->clk);
209 if (state->pdata->uart_enable)
210 state->pdata->uart_enable(state->pdev);
213 static void fiq_debugger_uart_disable(struct fiq_debugger_state *state)
215 if (state->pdata->uart_disable)
216 state->pdata->uart_disable(state->pdev);
218 clk_disable(state->clk);
221 static void fiq_debugger_uart_flush(struct fiq_debugger_state *state)
223 if (state->pdata->uart_flush)
224 state->pdata->uart_flush(state->pdev);
227 static void fiq_debugger_putc(struct fiq_debugger_state *state, char c)
229 state->pdata->uart_putc(state->pdev, c);
232 static void fiq_debugger_puts(struct fiq_debugger_state *state, char *s)
237 fiq_debugger_putc(state, '\r');
238 fiq_debugger_putc(state, c);
242 static void fiq_debugger_prompt(struct fiq_debugger_state *state)
244 fiq_debugger_puts(state, "debug> ");
247 static void fiq_debugger_dump_kernel_log(struct fiq_debugger_state *state)
249 #ifdef CONFIG_ARCH_ROCKCHIP
255 struct kmsg_dumper dumper = { .active = true };
258 kmsg_dump_rewind_nolock(&dumper);
259 while (kmsg_dump_get_line_nolock(&dumper, true, buf,
260 sizeof(buf) - 1, &len)) {
262 fiq_debugger_puts(state, buf);
263 #ifdef CONFIG_ARCH_ROCKCHIP
269 #ifdef CONFIG_RK_LAST_LOG
270 #include <linux/ctype.h>
271 extern char *rk_last_log_get(unsigned *size);
272 static void fiq_debugger_dump_last_kernel_log(struct fiq_debugger_state *state)
275 char *s = rk_last_log_get(&size);
277 for (i = 0; i < size; i++) {
282 state->pdata->uart_putc(state->pdev, '\r');
283 state->pdata->uart_putc(state->pdev, c);
284 } else if (isascii(c) && isprint(c)) {
285 state->pdata->uart_putc(state->pdev, c);
291 static void fiq_debugger_printf(struct fiq_debugger_output *output,
292 const char *fmt, ...)
294 struct fiq_debugger_state *state;
298 state = container_of(output, struct fiq_debugger_state, output);
300 vsnprintf(buf, sizeof(buf), fmt, ap);
303 fiq_debugger_puts(state, buf);
306 /* Safe outside fiq context */
307 static int fiq_debugger_printf_nfiq(void *cookie, const char *fmt, ...)
309 struct fiq_debugger_state *state = cookie;
312 unsigned long irq_flags;
315 vsnprintf(buf, 128, fmt, ap);
318 local_irq_save(irq_flags);
319 fiq_debugger_puts(state, buf);
320 fiq_debugger_uart_flush(state);
321 local_irq_restore(irq_flags);
322 return state->debug_abort;
325 static void fiq_debugger_dump_irqs(struct fiq_debugger_state *state)
329 struct irq_desc *desc;
331 fiq_debugger_printf(&state->output,
332 "irqnr total since-last status name\n");
333 for_each_irq_desc(n, desc) {
334 struct irqaction *act = desc->action;
335 if (!act && !kstat_irqs(n))
337 fiq_debugger_printf(&state->output, "%5d: %10u %11u %8x %s\n", n,
339 kstat_irqs(n) - state->last_irqs[n],
340 desc->status_use_accessors,
341 (act && act->name) ? act->name : "???");
342 state->last_irqs[n] = kstat_irqs(n);
345 #ifdef CONFIG_ARCH_ROCKCHIP
346 for (n = 16; n < 32; n++) {
347 desc = irq_to_desc(n);
350 for (cpu = 0; cpu < NR_CPUS; cpu++) {
351 unsigned int irqs = kstat_irqs_cpu(n, cpu);
352 struct irqaction *act = desc->action;
353 const char *name = (act && act->name) ? act->name : "???";
356 fiq_debugger_printf(&state->output,
357 "%5d: %10u %11u %s (CPU%d)\n", n,
358 irqs, irqs - state->last_local_irqs[cpu][n],
360 state->last_local_irqs[cpu][n] = irqs;
363 for (n = 0; n < NR_IPI; n++) {
364 #define S(x,s) [x] = s
371 IPI_CALL_FUNC_SINGLE,
376 static const char *ipi_types[NR_IPI] = {
377 S(IPI_WAKEUP, "CPU wakeup"),
378 S(IPI_TIMER, "Timer broadcast"),
379 S(IPI_RESCHEDULE, "Rescheduling"),
380 S(IPI_CALL_FUNC, "Function call"),
381 S(IPI_CALL_FUNC_SINGLE, "Single function call"),
382 S(IPI_CPU_STOP, "CPU stop"),
383 S(IPI_COMPLETION, "Completion"),
384 S(IPI_CPU_BACKTRACE, "CPU backtrace"),
386 #elif defined(CONFIG_ARM64)
390 IPI_CALL_FUNC_SINGLE,
394 static const char *ipi_types[NR_IPI] = {
395 S(IPI_RESCHEDULE, "Rescheduling"),
396 S(IPI_CALL_FUNC, "Function call"),
397 S(IPI_CALL_FUNC_SINGLE, "Single function call"),
398 S(IPI_CPU_STOP, "CPU stop"),
399 S(IPI_TIMER, "Timer broadcast"),
403 for (cpu = 0; cpu < NR_CPUS; cpu++) {
404 unsigned int irqs = __get_irq_stat(cpu, ipi_irqs[n]);
407 fiq_debugger_printf(&state->output,
408 "%5d: %10u %11u %s (CPU%d)\n",
409 n, irqs, irqs - state->last_local_irqs[cpu][n],
411 state->last_local_irqs[cpu][n] = irqs;
417 static void fiq_debugger_do_ps(struct fiq_debugger_state *state)
419 struct task_struct *g;
420 struct task_struct *p;
422 static const char stat_nam[] = "RSDTtZX";
424 fiq_debugger_printf(&state->output, "pid ppid prio task pc\n");
425 read_lock(&tasklist_lock);
426 do_each_thread(g, p) {
427 task_state = p->state ? __ffs(p->state) + 1 : 0;
428 fiq_debugger_printf(&state->output,
429 "%5d %5d %4d ", p->pid, p->parent->pid, p->prio);
430 fiq_debugger_printf(&state->output, "%-13.13s %c", p->comm,
431 task_state >= sizeof(stat_nam) ? '?' : stat_nam[task_state]);
432 if (task_state == TASK_RUNNING)
433 fiq_debugger_printf(&state->output, " running\n");
435 fiq_debugger_printf(&state->output, " %08lx\n",
437 } while_each_thread(g, p);
438 read_unlock(&tasklist_lock);
441 #ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
442 static void fiq_debugger_begin_syslog_dump(struct fiq_debugger_state *state)
444 state->syslog_dumping = true;
447 static void fiq_debugger_end_syslog_dump(struct fiq_debugger_state *state)
449 state->syslog_dumping = false;
452 extern int do_syslog(int type, char __user *bug, int count);
453 static void fiq_debugger_begin_syslog_dump(struct fiq_debugger_state *state)
455 do_syslog(5 /* clear */, NULL, 0);
458 static void fiq_debugger_end_syslog_dump(struct fiq_debugger_state *state)
460 fiq_debugger_dump_kernel_log(state);
464 static void fiq_debugger_do_sysrq(struct fiq_debugger_state *state, char rq)
466 if ((rq == 'g' || rq == 'G') && !fiq_kgdb_enable) {
467 fiq_debugger_printf(&state->output, "sysrq-g blocked\n");
470 fiq_debugger_begin_syslog_dump(state);
472 fiq_debugger_end_syslog_dump(state);
476 static void fiq_debugger_do_kgdb(struct fiq_debugger_state *state)
478 if (!fiq_kgdb_enable) {
479 fiq_debugger_printf(&state->output, "kgdb through fiq debugger not enabled\n");
483 fiq_debugger_printf(&state->output, "enabling console and triggering kgdb\n");
484 state->console_enable = true;
489 static void fiq_debugger_schedule_work(struct fiq_debugger_state *state,
494 spin_lock_irqsave(&state->work_lock, flags);
495 if (state->work_cmd[0] != '\0') {
496 fiq_debugger_printf(&state->output, "work command processor busy\n");
497 spin_unlock_irqrestore(&state->work_lock, flags);
501 strlcpy(state->work_cmd, cmd, sizeof(state->work_cmd));
502 spin_unlock_irqrestore(&state->work_lock, flags);
504 schedule_work(&state->work);
507 static void fiq_debugger_work(struct work_struct *work)
509 struct fiq_debugger_state *state;
510 char work_cmd[DEBUG_MAX];
514 state = container_of(work, struct fiq_debugger_state, work);
516 spin_lock_irqsave(&state->work_lock, flags);
518 strlcpy(work_cmd, state->work_cmd, sizeof(work_cmd));
519 state->work_cmd[0] = '\0';
521 spin_unlock_irqrestore(&state->work_lock, flags);
524 if (!strncmp(cmd, "reboot", 6)) {
531 kernel_restart(NULL);
533 fiq_debugger_printf(&state->output, "unknown work command '%s'\n",
538 /* This function CANNOT be called in FIQ context */
539 static void fiq_debugger_irq_exec(struct fiq_debugger_state *state, char *cmd)
542 if (!strcmp(cmd, "ps"))
543 fiq_debugger_do_ps(state);
544 if (!strcmp(cmd, "sysrq"))
545 fiq_debugger_do_sysrq(state, 'h');
546 if (!strncmp(cmd, "sysrq ", 6))
547 fiq_debugger_do_sysrq(state, cmd[6]);
549 if (!strcmp(cmd, "kgdb"))
550 fiq_debugger_do_kgdb(state);
552 if (!strncmp(cmd, "reboot", 6))
553 fiq_debugger_schedule_work(state, cmd);
554 #ifdef CONFIG_ARCH_ROCKCHIP
557 memset(state->debug_buf, 0, DEBUG_MAX);
560 if (invalid_cmd == 0) {
561 state->current_pointer = (state->current_pointer-1) & CMD_COUNT;
562 if (strcmp(state->cmd_buf[state->current_pointer], state->debug_buf)) {
563 state->current_pointer = (state->current_pointer+1) & CMD_COUNT;
564 memset(state->cmd_buf[state->current_pointer], 0, DEBUG_MAX);
565 strcpy(state->cmd_buf[state->current_pointer], state->debug_buf);
567 memset(state->debug_buf, 0, DEBUG_MAX);
568 state->current_pointer = (state->current_pointer+1) & CMD_COUNT;
569 state->back_pointer = state->current_pointer;
574 #ifdef CONFIG_ARCH_ROCKCHIP
575 static char cmd_buf[][16] = {
583 #ifdef CONFIG_RK_LAST_LOG
601 static void fiq_debugger_help(struct fiq_debugger_state *state)
603 fiq_debugger_printf(&state->output,
604 "FIQ Debugger commands:\n"
606 " regs Register dump\n"
607 " allregs Extended Register dump\n"
609 " reboot [<c>] Reboot with command <c>\n"
610 " reset [<c>] Hard reset with command <c>\n"
611 " irqs Interupt status\n"
613 " version Kernel version\n");
614 #ifdef CONFIG_RK_LAST_LOG
615 fiq_debugger_printf(&state->output,
616 " last_kmsg Last kernel log\n");
618 fiq_debugger_printf(&state->output,
619 " sleep Allow sleep while in FIQ\n"
620 " nosleep Disable sleep while in FIQ\n"
621 " console Switch terminal to console\n"
623 " cpu <number> Switch to CPU<number>\n");
624 fiq_debugger_printf(&state->output,
626 " sysrq sysrq options\n"
627 " sysrq <param> Execute sysrq with <param>\n");
629 fiq_debugger_printf(&state->output,
630 " kgdb Enter kernel debugger\n");
634 static void fiq_debugger_take_affinity(void *info)
636 struct fiq_debugger_state *state = info;
637 struct cpumask cpumask;
639 cpumask_clear(&cpumask);
640 cpumask_set_cpu(get_cpu(), &cpumask);
642 irq_set_affinity(state->uart_irq, &cpumask);
645 static void fiq_debugger_switch_cpu(struct fiq_debugger_state *state, int cpu)
647 if (!fiq_debugger_have_fiq(state))
648 smp_call_function_single(cpu, fiq_debugger_take_affinity, state,
650 #ifdef CONFIG_ARCH_ROCKCHIP
652 struct cpumask cpumask;
654 if (!cpu_online(cpu)) {
655 fiq_debugger_printf(&state->output, "cpu %d offline\n", cpu);
659 cpumask_clear(&cpumask);
660 cpumask_set_cpu(cpu, &cpumask);
662 irq_set_affinity(state->fiq, &cpumask);
663 irq_set_affinity(state->uart_irq, &cpumask);
666 state->current_cpu = cpu;
669 static bool fiq_debugger_fiq_exec(struct fiq_debugger_state *state,
670 const char *cmd, const struct pt_regs *regs,
673 bool signal_helper = false;
675 if (!strcmp(cmd, "help") || !strcmp(cmd, "?")) {
676 fiq_debugger_help(state);
677 } else if (!strcmp(cmd, "pc")) {
678 fiq_debugger_dump_pc(&state->output, regs);
679 } else if (!strcmp(cmd, "regs")) {
680 fiq_debugger_dump_regs(&state->output, regs);
681 } else if (!strcmp(cmd, "allregs")) {
682 fiq_debugger_dump_allregs(&state->output, regs);
683 } else if (!strcmp(cmd, "bt")) {
684 fiq_debugger_dump_stacktrace(&state->output, regs, 100, svc_sp);
685 } else if (!strncmp(cmd, "reset", 5)) {
691 strlcpy(tmp_cmd, cmd, sizeof(tmp_cmd));
692 machine_restart(tmp_cmd);
694 machine_restart(NULL);
696 } else if (!strcmp(cmd, "irqs")) {
697 fiq_debugger_dump_irqs(state);
698 } else if (!strcmp(cmd, "kmsg")) {
699 fiq_debugger_dump_kernel_log(state);
700 #ifdef CONFIG_RK_LAST_LOG
701 } else if (!strcmp(cmd, "last_kmsg")) {
702 fiq_debugger_dump_last_kernel_log(state);
704 } else if (!strcmp(cmd, "version")) {
705 fiq_debugger_printf(&state->output, "%s\n", linux_banner);
706 } else if (!strcmp(cmd, "sleep")) {
707 state->no_sleep = false;
708 fiq_debugger_printf(&state->output, "enabling sleep\n");
709 } else if (!strcmp(cmd, "nosleep")) {
710 state->no_sleep = true;
711 fiq_debugger_printf(&state->output, "disabling sleep\n");
712 } else if (!strcmp(cmd, "console")) {
713 fiq_debugger_printf(&state->output, "console mode\n");
714 fiq_debugger_uart_flush(state);
715 state->console_enable = true;
716 } else if (!strcmp(cmd, "cpu")) {
717 fiq_debugger_printf(&state->output, "cpu %d\n", state->current_cpu);
718 } else if (!strncmp(cmd, "cpu ", 4)) {
719 unsigned long cpu = 0;
720 if (strict_strtoul(cmd + 4, 10, &cpu) == 0)
721 fiq_debugger_switch_cpu(state, cpu);
723 fiq_debugger_printf(&state->output, "invalid cpu\n");
724 fiq_debugger_printf(&state->output, "cpu %d\n", state->current_cpu);
726 if (state->debug_busy) {
727 fiq_debugger_printf(&state->output,
728 "command processor busy. trying to abort.\n");
729 state->debug_abort = -1;
731 strcpy(state->debug_cmd, cmd);
732 state->debug_busy = 1;
737 if (!state->console_enable)
738 fiq_debugger_prompt(state);
740 return signal_helper;
743 static void fiq_debugger_sleep_timer_expired(unsigned long data)
745 struct fiq_debugger_state *state = (struct fiq_debugger_state *)data;
748 spin_lock_irqsave(&state->sleep_timer_lock, flags);
749 if (state->uart_enabled && !state->no_sleep) {
750 if (state->debug_enable && !state->console_enable) {
751 state->debug_enable = false;
752 fiq_debugger_printf_nfiq(state,
753 "suspending fiq debugger\n");
755 state->ignore_next_wakeup_irq = true;
756 fiq_debugger_uart_disable(state);
757 state->uart_enabled = false;
758 fiq_debugger_enable_wakeup_irq(state);
760 wake_unlock(&state->debugger_wake_lock);
761 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
764 static void fiq_debugger_handle_wakeup(struct fiq_debugger_state *state)
768 spin_lock_irqsave(&state->sleep_timer_lock, flags);
769 if (state->wakeup_irq >= 0 && state->ignore_next_wakeup_irq) {
770 state->ignore_next_wakeup_irq = false;
771 } else if (!state->uart_enabled) {
772 wake_lock(&state->debugger_wake_lock);
773 fiq_debugger_uart_enable(state);
774 state->uart_enabled = true;
775 fiq_debugger_disable_wakeup_irq(state);
776 mod_timer(&state->sleep_timer, jiffies + HZ / 2);
778 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
781 static irqreturn_t fiq_debugger_wakeup_irq_handler(int irq, void *dev)
783 struct fiq_debugger_state *state = dev;
785 if (!state->no_sleep)
786 fiq_debugger_puts(state, "WAKEUP\n");
787 fiq_debugger_handle_wakeup(state);
793 void fiq_debugger_handle_console_irq_context(struct fiq_debugger_state *state)
795 #if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
796 if (state->tty_port.ops) {
798 int count = fiq_debugger_ringbuf_level(state->tty_rbuf);
799 for (i = 0; i < count; i++) {
800 int c = fiq_debugger_ringbuf_peek(state->tty_rbuf, 0);
801 tty_insert_flip_char(&state->tty_port, c, TTY_NORMAL);
802 if (!fiq_debugger_ringbuf_consume(state->tty_rbuf, 1))
803 pr_warn("fiq tty failed to consume byte\n");
805 tty_flip_buffer_push(&state->tty_port);
810 static void fiq_debugger_handle_irq_context(struct fiq_debugger_state *state)
812 if (!state->no_sleep) {
815 spin_lock_irqsave(&state->sleep_timer_lock, flags);
816 wake_lock(&state->debugger_wake_lock);
817 mod_timer(&state->sleep_timer, jiffies + HZ * 5);
818 spin_unlock_irqrestore(&state->sleep_timer_lock, flags);
820 fiq_debugger_handle_console_irq_context(state);
821 if (state->debug_busy) {
822 fiq_debugger_irq_exec(state, state->debug_cmd);
823 if (!state->console_enable)
824 fiq_debugger_prompt(state);
825 state->debug_busy = 0;
829 static int fiq_debugger_getc(struct fiq_debugger_state *state)
831 return state->pdata->uart_getc(state->pdev);
834 static int fiq_debugger_cmd_check_back(struct fiq_debugger_state *state, char c)
839 state->back_pointer = (state->back_pointer-1) & CMD_COUNT;
840 if (state->back_pointer != state->current_pointer) {
841 s = state->cmd_buf[state->back_pointer];
843 for(i = 0; i < strlen(state->debug_buf)-1; i++) {
844 state->pdata->uart_putc(state->pdev, 8);
845 state->pdata->uart_putc(state->pdev, ' ');
846 state->pdata->uart_putc(state->pdev, 8);
848 memset(state->debug_buf, 0, DEBUG_MAX);
849 strcpy(state->debug_buf, s);
850 state->debug_count = strlen(state->debug_buf);
851 fiq_debugger_printf(&state->output, state->debug_buf);
853 state->back_pointer = (state->back_pointer+1) & CMD_COUNT;
857 state->back_pointer = (state->back_pointer+1) & CMD_COUNT;
859 } else if (c == 'B') {
861 if (state->back_pointer != state->current_pointer) {
862 state->back_pointer = (state->back_pointer+1) & CMD_COUNT;
863 if(state->back_pointer == state->current_pointer){
866 s = state->cmd_buf[state->back_pointer];
868 for(i = 0; i < strlen(state->debug_buf)-1; i++) {
869 state->pdata->uart_putc(state->pdev, 8);
870 state->pdata->uart_putc(state->pdev, ' ');
871 state->pdata->uart_putc(state->pdev, 8);
873 memset(state->debug_buf, 0, DEBUG_MAX);
874 strcpy(state->debug_buf, s);
875 state->debug_count = strlen(state->debug_buf);
876 fiq_debugger_printf(&state->output, state->debug_buf);
881 for(i = 0; i < strlen(state->debug_buf)-1; i++) {
882 state->pdata->uart_putc(state->pdev, 8);
883 state->pdata->uart_putc(state->pdev, ' ');
884 state->pdata->uart_putc(state->pdev, 8);
886 memset(state->debug_buf, 0, DEBUG_MAX);
887 state->debug_count = 0;
893 static void fiq_debugger_cmd_tab(struct fiq_debugger_state *state)
898 for (i = 0; i < ARRAY_SIZE(cmd_buf); i++) {
902 for (j = 1; j <= strlen(state->debug_buf); j++) {
904 for (i = 0; i < ARRAY_SIZE(cmd_buf); i++) {
905 if (cmd_buf[i][15] == 1) {
906 if (strncmp(state->debug_buf, cmd_buf[i], j)) {
918 for (i = 0; i < ARRAY_SIZE(cmd_buf); i++) {
919 if (cmd_buf[i][15] == 1)
923 for(j = 0; j < strlen(state->debug_buf); j++) {
924 state->pdata->uart_putc(state->pdev, 8);
925 state->pdata->uart_putc(state->pdev, ' ');
926 state->pdata->uart_putc(state->pdev, 8);
928 memset(state->debug_buf, 0, DEBUG_MAX);
929 strcpy(state->debug_buf, cmd_buf[i]);
930 state->debug_count = strlen(state->debug_buf);
931 fiq_debugger_printf(&state->output, state->debug_buf);
936 static bool fiq_debugger_handle_uart_interrupt(struct fiq_debugger_state *state,
937 int this_cpu, const struct pt_regs *regs, void *svc_sp)
942 bool signal_helper = false;
943 unsigned long ms = 0;
945 if (this_cpu != state->current_cpu) {
949 if (atomic_inc_return(&state->unhandled_fiq_count) !=
950 MAX_UNHANDLED_FIQ_COUNT)
953 fiq_debugger_printf(&state->output,
954 "fiq_debugger: cpu %d not responding, "
955 "reverting to cpu %d\n", state->current_cpu,
958 atomic_set(&state->unhandled_fiq_count, 0);
959 fiq_debugger_switch_cpu(state, this_cpu);
963 state->in_fiq = true;
965 while ((c = fiq_debugger_getc(state)) != FIQ_DEBUGGER_NO_CHAR) {
967 if((recv_count0 - recv_count1) > 128) {
968 ms = jiffies_to_msecs(jiffies - jif);
971 writel_relaxed((0x00c0 << 16),
972 RK_GRF_VIRT + RK3288_GRF_UOC0_CON3);
976 recv_count1 = recv_count0;
979 if (!state->debug_enable) {
980 if ((c == 13) || (c == 10)) {
981 state->debug_enable = true;
982 state->debug_count = 0;
983 fiq_debugger_prompt(state);
985 } else if (c == FIQ_DEBUGGER_BREAK) {
986 state->console_enable = false;
987 #ifdef CONFIG_ARCH_ROCKCHIP
988 fiq_debugger_puts(state, "\nWelcome to ");
990 fiq_debugger_puts(state, "fiq debugger mode\n");
991 state->debug_count = 0;
992 #ifdef CONFIG_ARCH_ROCKCHIP
993 fiq_debugger_puts(state, "Enter ? to get command help\n");
994 state->back_pointer = CMD_COUNT;
995 state->current_pointer = CMD_COUNT;
996 memset(state->cmd_buf, 0, (CMD_COUNT+1)*DEBUG_MAX);
998 fiq_debugger_prompt(state);
999 #ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
1000 } else if (state->console_enable && state->tty_rbuf) {
1001 fiq_debugger_ringbuf_push(state->tty_rbuf, c);
1002 signal_helper = true;
1004 #ifdef CONFIG_ARCH_ROCKCHIP
1005 } else if (last_c == '[' && (c == 'A' || c == 'B' || c == 'C' || c == 'D')) {
1006 if (state->debug_count > 0) {
1007 state->debug_count--;
1008 state->pdata->uart_putc(state->pdev, 8);
1009 state->pdata->uart_putc(state->pdev, ' ');
1010 state->pdata->uart_putc(state->pdev, 8);
1012 fiq_debugger_cmd_check_back(state, c);
1014 } else if (c == 9) {
1015 fiq_debugger_cmd_tab(state);
1017 } else if ((c >= ' ') && (c < 127)) {
1018 if (state->debug_count < (DEBUG_MAX - 1)) {
1019 state->debug_buf[state->debug_count++] = c;
1020 fiq_debugger_putc(state, c);
1022 } else if ((c == 8) || (c == 127)) {
1023 if (state->debug_count > 0) {
1024 state->debug_count--;
1025 fiq_debugger_putc(state, 8);
1026 fiq_debugger_putc(state, ' ');
1027 fiq_debugger_putc(state, 8);
1029 } else if ((c == 13) || (c == 10)) {
1030 if (c == '\r' || (c == '\n' && last_c != '\r')) {
1031 fiq_debugger_putc(state, '\r');
1032 fiq_debugger_putc(state, '\n');
1034 if (state->debug_count) {
1035 state->debug_buf[state->debug_count] = 0;
1036 state->debug_count = 0;
1038 fiq_debugger_fiq_exec(state,
1041 #ifdef CONFIG_ARCH_ROCKCHIP
1042 if (signal_helper == false) {
1043 state->current_pointer = (state->current_pointer-1) & CMD_COUNT;
1044 if (strcmp(state->cmd_buf[state->current_pointer], state->debug_buf)) {
1045 state->current_pointer = (state->current_pointer+1) & CMD_COUNT;
1046 memset(state->cmd_buf[state->current_pointer], 0, DEBUG_MAX);
1047 strcpy(state->cmd_buf[state->current_pointer], state->debug_buf);
1049 memset(state->debug_buf, 0, DEBUG_MAX);
1050 state->current_pointer = (state->current_pointer+1) & CMD_COUNT;
1051 state->back_pointer = state->current_pointer;
1055 fiq_debugger_prompt(state);
1060 if (!state->console_enable)
1061 fiq_debugger_uart_flush(state);
1062 if (state->pdata->fiq_ack)
1063 state->pdata->fiq_ack(state->pdev, state->fiq);
1065 /* poke sleep timer if necessary */
1066 if (state->debug_enable && !state->no_sleep)
1067 signal_helper = true;
1069 atomic_set(&state->unhandled_fiq_count, 0);
1070 state->in_fiq = false;
1072 return signal_helper;
1075 #ifdef CONFIG_FIQ_GLUE
1076 static void fiq_debugger_fiq(struct fiq_glue_handler *h,
1077 void *regs, void *svc_sp)
1079 struct fiq_debugger_state *state =
1080 container_of(h, struct fiq_debugger_state, handler);
1081 unsigned int this_cpu = THREAD_INFO(svc_sp)->cpu;
1084 /* RK2928 USB-UART function, otg dp/dm default in uart status;
1085 * connect with otg cable&usb device, dp/dm will be hi-z status
1086 * and make uart controller enter infinite fiq loop
1088 #ifdef CONFIG_RK_USB_UART
1089 if (cpu_is_rk3188()) {
1090 if (!(readl_relaxed(RK_GRF_VIRT + RK3188_GRF_SOC_STATUS0) & (1 << 13)) ||
1091 (readl_relaxed(RK_GRF_VIRT + RK3188_GRF_SOC_STATUS0) & (1 << 10))) {
1092 /* id low or bvalid high, enter usb phy */
1093 writel_relaxed((0x0300 << 16), RK_GRF_VIRT + RK3188_GRF_UOC0_CON0);
1095 } else if (cpu_is_rk3288()) {
1096 if (!(readl_relaxed(RK_GRF_VIRT + RK3288_GRF_SOC_STATUS2) & (1 << 17)) ||
1097 (readl_relaxed(RK_GRF_VIRT + RK3288_GRF_SOC_STATUS2) & (1 << 14))) {
1098 /* id low or bvalid high, enter usb phy */
1099 writel_relaxed((0x00c0 << 16), RK_GRF_VIRT + RK3288_GRF_UOC0_CON3);
1103 need_irq = fiq_debugger_handle_uart_interrupt(state, this_cpu, regs,
1106 fiq_debugger_force_irq(state);
1111 * When not using FIQs, we only use this single interrupt as an entry point.
1112 * This just effectively takes over the UART interrupt and does all the work
1115 static irqreturn_t fiq_debugger_uart_irq(int irq, void *dev)
1117 struct fiq_debugger_state *state = dev;
1120 fiq_debugger_handle_wakeup(state);
1122 /* handle the debugger irq in regular context */
1123 not_done = fiq_debugger_handle_uart_interrupt(state, smp_processor_id(),
1125 current_thread_info());
1127 fiq_debugger_handle_irq_context(state);
1133 * If FIQs are used, not everything can happen in fiq context.
1134 * FIQ handler does what it can and then signals this interrupt to finish the
1135 * job in irq context.
1137 static irqreturn_t fiq_debugger_signal_irq(int irq, void *dev)
1139 struct fiq_debugger_state *state = dev;
1141 if (state->pdata->force_irq_ack)
1142 state->pdata->force_irq_ack(state->pdev, state->signal_irq);
1144 fiq_debugger_handle_irq_context(state);
1149 #ifdef CONFIG_FIQ_GLUE
1150 static void fiq_debugger_resume(struct fiq_glue_handler *h)
1152 struct fiq_debugger_state *state =
1153 container_of(h, struct fiq_debugger_state, handler);
1154 if (state->pdata->uart_resume)
1155 state->pdata->uart_resume(state->pdev);
1159 #if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
1160 struct tty_driver *fiq_debugger_console_device(struct console *co, int *index)
1163 return fiq_tty_driver;
1166 static void fiq_debugger_console_write(struct console *co,
1167 const char *s, unsigned int count)
1169 struct fiq_debugger_state *state;
1170 unsigned long flags;
1172 state = container_of(co, struct fiq_debugger_state, console);
1174 if (!state->console_enable && !state->syslog_dumping)
1177 #ifdef CONFIG_RK_CONSOLE_THREAD
1178 if (state->pdata->console_write) {
1179 state->pdata->console_write(state->pdev, s, count);
1184 fiq_debugger_uart_enable(state);
1185 spin_lock_irqsave(&state->console_lock, flags);
1188 fiq_debugger_putc(state, '\r');
1189 fiq_debugger_putc(state, *s++);
1191 fiq_debugger_uart_flush(state);
1192 spin_unlock_irqrestore(&state->console_lock, flags);
1193 fiq_debugger_uart_disable(state);
1196 static struct console fiq_debugger_console = {
1198 .device = fiq_debugger_console_device,
1199 .write = fiq_debugger_console_write,
1200 .flags = CON_PRINTBUFFER | CON_ANYTIME | CON_ENABLED,
1203 int fiq_tty_open(struct tty_struct *tty, struct file *filp)
1205 int line = tty->index;
1206 struct fiq_debugger_state **states = tty->driver->driver_state;
1207 struct fiq_debugger_state *state = states[line];
1209 return tty_port_open(&state->tty_port, tty, filp);
1212 void fiq_tty_close(struct tty_struct *tty, struct file *filp)
1214 tty_port_close(tty->port, tty, filp);
1217 int fiq_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
1220 int line = tty->index;
1221 struct fiq_debugger_state **states = tty->driver->driver_state;
1222 struct fiq_debugger_state *state = states[line];
1224 if (!state->console_enable)
1227 fiq_debugger_uart_enable(state);
1228 spin_lock_irq(&state->console_lock);
1229 for (i = 0; i < count; i++)
1230 fiq_debugger_putc(state, *buf++);
1231 spin_unlock_irq(&state->console_lock);
1232 fiq_debugger_uart_disable(state);
1237 int fiq_tty_write_room(struct tty_struct *tty)
1242 #ifdef CONFIG_CONSOLE_POLL
1243 static int fiq_tty_poll_init(struct tty_driver *driver, int line, char *options)
1248 static int fiq_tty_poll_get_char(struct tty_driver *driver, int line)
1250 struct fiq_debugger_state **states = driver->driver_state;
1251 struct fiq_debugger_state *state = states[line];
1252 int c = NO_POLL_CHAR;
1254 fiq_debugger_uart_enable(state);
1255 if (fiq_debugger_have_fiq(state)) {
1256 int count = fiq_debugger_ringbuf_level(state->tty_rbuf);
1258 c = fiq_debugger_ringbuf_peek(state->tty_rbuf, 0);
1259 fiq_debugger_ringbuf_consume(state->tty_rbuf, 1);
1262 c = fiq_debugger_getc(state);
1263 if (c == FIQ_DEBUGGER_NO_CHAR)
1266 fiq_debugger_uart_disable(state);
1271 static void fiq_tty_poll_put_char(struct tty_driver *driver, int line, char ch)
1273 struct fiq_debugger_state **states = driver->driver_state;
1274 struct fiq_debugger_state *state = states[line];
1275 fiq_debugger_uart_enable(state);
1276 fiq_debugger_putc(state, ch);
1277 fiq_debugger_uart_disable(state);
1281 static const struct tty_port_operations fiq_tty_port_ops;
1283 static const struct tty_operations fiq_tty_driver_ops = {
1284 .write = fiq_tty_write,
1285 .write_room = fiq_tty_write_room,
1286 .open = fiq_tty_open,
1287 .close = fiq_tty_close,
1288 #ifdef CONFIG_CONSOLE_POLL
1289 .poll_init = fiq_tty_poll_init,
1290 .poll_get_char = fiq_tty_poll_get_char,
1291 .poll_put_char = fiq_tty_poll_put_char,
1295 static int fiq_debugger_tty_init(void)
1298 struct fiq_debugger_state **states = NULL;
1300 states = kzalloc(sizeof(*states) * MAX_FIQ_DEBUGGER_PORTS, GFP_KERNEL);
1302 pr_err("Failed to allocate fiq debugger state structres\n");
1306 fiq_tty_driver = alloc_tty_driver(MAX_FIQ_DEBUGGER_PORTS);
1307 if (!fiq_tty_driver) {
1308 pr_err("Failed to allocate fiq debugger tty\n");
1310 goto err_free_state;
1313 fiq_tty_driver->owner = THIS_MODULE;
1314 fiq_tty_driver->driver_name = "fiq-debugger";
1315 fiq_tty_driver->name = "ttyFIQ";
1316 fiq_tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
1317 fiq_tty_driver->subtype = SERIAL_TYPE_NORMAL;
1318 fiq_tty_driver->init_termios = tty_std_termios;
1319 fiq_tty_driver->flags = TTY_DRIVER_REAL_RAW |
1320 TTY_DRIVER_DYNAMIC_DEV;
1321 fiq_tty_driver->driver_state = states;
1323 fiq_tty_driver->init_termios.c_cflag =
1324 B115200 | CS8 | CREAD | HUPCL | CLOCAL;
1325 fiq_tty_driver->init_termios.c_ispeed = 115200;
1326 fiq_tty_driver->init_termios.c_ospeed = 115200;
1328 tty_set_operations(fiq_tty_driver, &fiq_tty_driver_ops);
1330 ret = tty_register_driver(fiq_tty_driver);
1332 pr_err("Failed to register fiq tty: %d\n", ret);
1336 pr_info("Registered FIQ tty driver\n");
1340 put_tty_driver(fiq_tty_driver);
1341 fiq_tty_driver = NULL;
1347 static int fiq_debugger_tty_init_one(struct fiq_debugger_state *state)
1350 struct device *tty_dev;
1351 struct fiq_debugger_state **states = fiq_tty_driver->driver_state;
1353 states[state->pdev->id] = state;
1355 state->tty_rbuf = fiq_debugger_ringbuf_alloc(1024);
1356 if (!state->tty_rbuf) {
1357 pr_err("Failed to allocate fiq debugger ringbuf\n");
1362 tty_port_init(&state->tty_port);
1363 state->tty_port.ops = &fiq_tty_port_ops;
1365 tty_dev = tty_port_register_device(&state->tty_port, fiq_tty_driver,
1366 state->pdev->id, &state->pdev->dev);
1367 if (IS_ERR(tty_dev)) {
1368 pr_err("Failed to register fiq debugger tty device\n");
1369 ret = PTR_ERR(tty_dev);
1373 device_set_wakeup_capable(tty_dev, 1);
1375 pr_info("Registered fiq debugger ttyFIQ%d\n", state->pdev->id);
1380 fiq_debugger_ringbuf_free(state->tty_rbuf);
1381 state->tty_rbuf = NULL;
1386 static int fiq_debugger_dev_suspend(struct device *dev)
1388 struct platform_device *pdev = to_platform_device(dev);
1389 struct fiq_debugger_state *state = platform_get_drvdata(pdev);
1391 if (state->pdata->uart_dev_suspend)
1392 return state->pdata->uart_dev_suspend(pdev);
1396 static int fiq_debugger_dev_resume(struct device *dev)
1398 struct platform_device *pdev = to_platform_device(dev);
1399 struct fiq_debugger_state *state = platform_get_drvdata(pdev);
1401 if (state->pdata->uart_dev_resume)
1402 return state->pdata->uart_dev_resume(pdev);
1406 static int fiq_debugger_probe(struct platform_device *pdev)
1409 struct fiq_debugger_pdata *pdata = dev_get_platdata(&pdev->dev);
1410 struct fiq_debugger_state *state;
1414 if (pdev->id >= MAX_FIQ_DEBUGGER_PORTS)
1417 if (!pdata->uart_getc || !pdata->uart_putc)
1419 if ((pdata->uart_enable && !pdata->uart_disable) ||
1420 (!pdata->uart_enable && pdata->uart_disable))
1423 fiq = platform_get_irq_byname(pdev, "fiq");
1424 uart_irq = platform_get_irq_byname(pdev, "uart_irq");
1426 /* uart_irq mode and fiq mode are mutually exclusive, but one of them
1428 if ((uart_irq < 0 && fiq < 0) || (uart_irq >= 0 && fiq >= 0))
1430 if (fiq >= 0 && !pdata->fiq_enable)
1433 state = kzalloc(sizeof(*state), GFP_KERNEL);
1434 state->output.printf = fiq_debugger_printf;
1435 setup_timer(&state->sleep_timer, fiq_debugger_sleep_timer_expired,
1436 (unsigned long)state);
1437 state->pdata = pdata;
1439 state->no_sleep = initial_no_sleep;
1440 state->debug_enable = initial_debug_enable;
1441 state->console_enable = initial_console_enable;
1444 state->uart_irq = uart_irq;
1445 state->signal_irq = platform_get_irq_byname(pdev, "signal");
1446 state->wakeup_irq = platform_get_irq_byname(pdev, "wakeup");
1448 INIT_WORK(&state->work, fiq_debugger_work);
1449 spin_lock_init(&state->work_lock);
1451 platform_set_drvdata(pdev, state);
1453 spin_lock_init(&state->sleep_timer_lock);
1455 if (state->wakeup_irq < 0 && fiq_debugger_have_fiq(state))
1456 state->no_sleep = true;
1457 state->ignore_next_wakeup_irq = !state->no_sleep;
1459 wake_lock_init(&state->debugger_wake_lock,
1460 WAKE_LOCK_SUSPEND, "serial-debug");
1462 state->clk = clk_get(&pdev->dev, NULL);
1463 if (IS_ERR(state->clk))
1466 /* do not call pdata->uart_enable here since uart_init may still
1467 * need to do some initialization before uart_enable can work.
1468 * So, only try to manage the clock during init.
1471 clk_enable(state->clk);
1473 if (pdata->uart_init) {
1474 ret = pdata->uart_init(pdev);
1479 fiq_debugger_printf_nfiq(state,
1480 "<hit enter %sto activate fiq debugger>\n",
1481 state->no_sleep ? "" : "twice ");
1483 #ifdef CONFIG_FIQ_GLUE
1484 if (fiq_debugger_have_fiq(state)) {
1485 state->handler.fiq = fiq_debugger_fiq;
1486 state->handler.resume = fiq_debugger_resume;
1487 ret = fiq_glue_register_handler(&state->handler);
1489 pr_err("%s: could not install fiq handler\n", __func__);
1490 goto err_register_irq;
1492 #ifdef CONFIG_ARCH_ROCKCHIP
1493 //set state->fiq to secure state, so fiq is avalable
1494 gic_set_irq_secure(irq_get_irq_data(state->fiq));
1495 //set state->fiq priority a little higher than other interrupts (normal is 0xa0)
1496 gic_set_irq_priority(irq_get_irq_data(state->fiq), 0x90);
1498 pdata->fiq_enable(pdev, state->fiq, 1);
1502 ret = request_irq(state->uart_irq, fiq_debugger_uart_irq,
1503 IRQF_NO_SUSPEND, "debug", state);
1505 pr_err("%s: could not install irq handler\n", __func__);
1506 goto err_register_irq;
1509 /* for irq-only mode, we want this irq to wake us up, if it
1512 enable_irq_wake(state->uart_irq);
1516 clk_disable(state->clk);
1518 if (state->signal_irq >= 0) {
1519 ret = request_irq(state->signal_irq, fiq_debugger_signal_irq,
1520 IRQF_TRIGGER_RISING, "debug-signal", state);
1522 pr_err("serial_debugger: could not install signal_irq");
1525 if (state->wakeup_irq >= 0) {
1526 ret = request_irq(state->wakeup_irq,
1527 fiq_debugger_wakeup_irq_handler,
1528 IRQF_TRIGGER_FALLING | IRQF_DISABLED,
1529 "debug-wakeup", state);
1531 pr_err("serial_debugger: "
1532 "could not install wakeup irq\n");
1533 state->wakeup_irq = -1;
1535 ret = enable_irq_wake(state->wakeup_irq);
1537 pr_err("serial_debugger: "
1538 "could not enable wakeup\n");
1539 state->wakeup_irq_no_set_wake = true;
1543 if (state->no_sleep)
1544 fiq_debugger_handle_wakeup(state);
1546 #if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
1547 spin_lock_init(&state->console_lock);
1548 state->console = fiq_debugger_console;
1549 state->console.index = pdev->id;
1550 if (!console_set_on_cmdline)
1551 add_preferred_console(state->console.name,
1552 state->console.index, NULL);
1553 register_console(&state->console);
1554 fiq_debugger_tty_init_one(state);
1559 if (pdata->uart_free)
1560 pdata->uart_free(pdev);
1563 clk_disable(state->clk);
1565 clk_put(state->clk);
1566 wake_lock_destroy(&state->debugger_wake_lock);
1567 platform_set_drvdata(pdev, NULL);
1572 static const struct dev_pm_ops fiq_debugger_dev_pm_ops = {
1573 .suspend = fiq_debugger_dev_suspend,
1574 .resume = fiq_debugger_dev_resume,
1577 static struct platform_driver fiq_debugger_driver = {
1578 .probe = fiq_debugger_probe,
1580 .name = "fiq_debugger",
1581 .pm = &fiq_debugger_dev_pm_ops,
1585 static int __init fiq_debugger_init(void)
1587 #if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
1588 fiq_debugger_tty_init();
1590 return platform_driver_register(&fiq_debugger_driver);
1593 postcore_initcall(fiq_debugger_init);