2 * arch/arm/common/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_debugger.h>
26 #include <linux/kernel_stat.h>
27 #include <linux/irq.h>
28 #include <linux/delay.h>
29 #include <linux/sched.h>
30 #include <linux/slab.h>
31 #include <linux/timer.h>
32 #include <linux/tty.h>
33 #include <linux/tty_flip.h>
34 #include <linux/wakelock.h>
36 #include <asm/fiq_debugger.h>
37 #include <asm/fiq_glue.h>
38 #include <asm/stacktrace.h>
40 #include <mach/system.h>
42 #include <linux/uaccess.h>
44 #include "fiq_debugger_ringbuf.h"
48 struct fiq_debugger_state {
49 struct fiq_glue_handler handler;
54 bool wakeup_irq_no_set_wake;
56 struct fiq_debugger_pdata *pdata;
57 struct platform_device *pdev;
59 char debug_cmd[DEBUG_MAX];
63 char debug_buf[DEBUG_MAX];
68 bool ignore_next_wakeup_irq;
69 struct timer_list sleep_timer;
70 bool uart_clk_enabled;
71 struct wake_lock debugger_wake_lock;
74 #ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
75 struct console console;
76 struct tty_driver *tty_driver;
77 struct tty_struct *tty;
79 struct fiq_debugger_ringbuf *tty_rbuf;
82 unsigned int last_irqs[NR_IRQS];
85 #ifdef CONFIG_FIQ_DEBUGGER_NO_SLEEP
86 static bool initial_no_sleep = true;
88 static bool initial_no_sleep;
90 static bool initial_debug_enable;
91 static bool initial_console_enable;
93 module_param_named(no_sleep, initial_no_sleep, bool, 0644);
94 module_param_named(debug_enable, initial_debug_enable, bool, 0644);
95 module_param_named(console_enable, initial_console_enable, bool, 0644);
97 #ifdef CONFIG_FIQ_DEBUGGER_WAKEUP_IRQ_ALWAYS_ON
98 static inline void enable_wakeup_irq(struct fiq_debugger_state *state) {}
99 static inline void disable_wakeup_irq(struct fiq_debugger_state *state) {}
101 static inline void enable_wakeup_irq(struct fiq_debugger_state *state)
103 if (state->wakeup_irq < 0)
105 enable_irq(state->wakeup_irq);
106 if (!state->wakeup_irq_no_set_wake)
107 enable_irq_wake(state->wakeup_irq);
109 static inline void disable_wakeup_irq(struct fiq_debugger_state *state)
111 if (state->wakeup_irq < 0)
113 disable_irq_nosync(state->wakeup_irq);
114 if (!state->wakeup_irq_no_set_wake)
115 disable_irq_wake(state->wakeup_irq);
119 static void debug_force_irq(struct fiq_debugger_state *state)
121 unsigned int irq = state->signal_irq;
122 if (state->pdata->force_irq)
123 state->pdata->force_irq(state->pdev, irq);
125 struct irq_chip *chip = get_irq_chip(irq);
126 if (chip && chip->retrigger)
127 chip->retrigger(irq);
131 static void debug_uart_flush(struct fiq_debugger_state *state)
133 if (state->pdata->uart_flush)
134 state->pdata->uart_flush(state->pdev);
137 static void debug_puts(struct fiq_debugger_state *state, char *s)
142 state->pdata->uart_putc(state->pdev, '\r');
143 state->pdata->uart_putc(state->pdev, c);
147 static void debug_prompt(struct fiq_debugger_state *state)
149 debug_puts(state, "debug> ");
152 int log_buf_copy(char *dest, int idx, int len);
153 static void dump_kernel_log(struct fiq_debugger_state *state)
160 /* setting oops_in_progress prevents log_buf_copy()
161 * from trying to take a spinlock which will make it
162 * very unhappy in some cases...
164 saved_oip = oops_in_progress;
165 oops_in_progress = 1;
167 ret = log_buf_copy(buf, idx, 1023);
171 debug_puts(state, buf);
174 oops_in_progress = saved_oip;
177 static char *mode_name(unsigned cpsr)
179 switch (cpsr & MODE_MASK) {
180 case USR_MODE: return "USR";
181 case FIQ_MODE: return "FIQ";
182 case IRQ_MODE: return "IRQ";
183 case SVC_MODE: return "SVC";
184 case ABT_MODE: return "ABT";
185 case UND_MODE: return "UND";
186 case SYSTEM_MODE: return "SYS";
187 default: return "???";
191 static int debug_printf(void *cookie, const char *fmt, ...)
193 struct fiq_debugger_state *state = cookie;
198 vsnprintf(buf, sizeof(buf), fmt, ap);
201 debug_puts(state, buf);
202 return state->debug_abort;
205 /* Safe outside fiq context */
206 static int debug_printf_nfiq(void *cookie, const char *fmt, ...)
208 struct fiq_debugger_state *state = cookie;
211 unsigned long irq_flags;
214 vsnprintf(buf, 128, fmt, ap);
217 local_irq_save(irq_flags);
218 debug_puts(state, buf);
219 debug_uart_flush(state);
220 local_irq_restore(irq_flags);
221 return state->debug_abort;
224 static void dump_regs(struct fiq_debugger_state *state, unsigned *regs)
226 debug_printf(state, " r0 %08x r1 %08x r2 %08x r3 %08x\n",
227 regs[0], regs[1], regs[2], regs[3]);
228 debug_printf(state, " r4 %08x r5 %08x r6 %08x r7 %08x\n",
229 regs[4], regs[5], regs[6], regs[7]);
230 debug_printf(state, " r8 %08x r9 %08x r10 %08x r11 %08x mode %s\n",
231 regs[8], regs[9], regs[10], regs[11],
232 mode_name(regs[16]));
233 if ((regs[16] & MODE_MASK) == USR_MODE)
234 debug_printf(state, " ip %08x sp %08x lr %08x pc %08x "
235 "cpsr %08x\n", regs[12], regs[13], regs[14],
238 debug_printf(state, " ip %08x sp %08x lr %08x pc %08x "
239 "cpsr %08x spsr %08x\n", regs[12], regs[13],
240 regs[14], regs[15], regs[16], regs[17]);
244 unsigned long sp_svc;
245 unsigned long lr_svc;
246 unsigned long spsr_svc;
248 unsigned long sp_abt;
249 unsigned long lr_abt;
250 unsigned long spsr_abt;
252 unsigned long sp_und;
253 unsigned long lr_und;
254 unsigned long spsr_und;
256 unsigned long sp_irq;
257 unsigned long lr_irq;
258 unsigned long spsr_irq;
260 unsigned long r8_fiq;
261 unsigned long r9_fiq;
262 unsigned long r10_fiq;
263 unsigned long r11_fiq;
264 unsigned long r12_fiq;
265 unsigned long sp_fiq;
266 unsigned long lr_fiq;
267 unsigned long spsr_fiq;
270 void __naked get_mode_regs(struct mode_regs *regs)
274 "msr cpsr_c, #0xd3 @(SVC_MODE | PSR_I_BIT | PSR_F_BIT)\n"
275 "stmia r0!, {r13 - r14}\n"
277 "msr cpsr_c, #0xd7 @(ABT_MODE | PSR_I_BIT | PSR_F_BIT)\n"
278 "stmia r0!, {r2, r13 - r14}\n"
280 "msr cpsr_c, #0xdb @(UND_MODE | PSR_I_BIT | PSR_F_BIT)\n"
281 "stmia r0!, {r2, r13 - r14}\n"
283 "msr cpsr_c, #0xd2 @(IRQ_MODE | PSR_I_BIT | PSR_F_BIT)\n"
284 "stmia r0!, {r2, r13 - r14}\n"
286 "msr cpsr_c, #0xd1 @(FIQ_MODE | PSR_I_BIT | PSR_F_BIT)\n"
287 "stmia r0!, {r2, r8 - r14}\n"
295 static void dump_allregs(struct fiq_debugger_state *state, unsigned *regs)
297 struct mode_regs mode_regs;
298 dump_regs(state, regs);
299 get_mode_regs(&mode_regs);
300 debug_printf(state, " svc: sp %08x lr %08x spsr %08x\n",
301 mode_regs.sp_svc, mode_regs.lr_svc, mode_regs.spsr_svc);
302 debug_printf(state, " abt: sp %08x lr %08x spsr %08x\n",
303 mode_regs.sp_abt, mode_regs.lr_abt, mode_regs.spsr_abt);
304 debug_printf(state, " und: sp %08x lr %08x spsr %08x\n",
305 mode_regs.sp_und, mode_regs.lr_und, mode_regs.spsr_und);
306 debug_printf(state, " irq: sp %08x lr %08x spsr %08x\n",
307 mode_regs.sp_irq, mode_regs.lr_irq, mode_regs.spsr_irq);
308 debug_printf(state, " fiq: r8 %08x r9 %08x r10 %08x r11 %08x "
310 mode_regs.r8_fiq, mode_regs.r9_fiq, mode_regs.r10_fiq,
311 mode_regs.r11_fiq, mode_regs.r12_fiq);
312 debug_printf(state, " fiq: sp %08x lr %08x spsr %08x\n",
313 mode_regs.sp_fiq, mode_regs.lr_fiq, mode_regs.spsr_fiq);
316 static void dump_irqs(struct fiq_debugger_state *state)
319 debug_printf(state, "irqnr total since-last status name\n");
320 for (n = 0; n < NR_IRQS; n++) {
321 struct irqaction *act = irq_desc[n].action;
322 if (!act && !kstat_irqs(n))
324 debug_printf(state, "%5d: %10u %11u %8x %s\n", n,
326 kstat_irqs(n) - state->last_irqs[n],
328 (act && act->name) ? act->name : "???");
329 state->last_irqs[n] = kstat_irqs(n);
333 struct stacktrace_state {
334 struct fiq_debugger_state *state;
338 static int report_trace(struct stackframe *frame, void *d)
340 struct stacktrace_state *sts = d;
343 debug_printf(sts->state,
344 " pc: %p (%pF), lr %p (%pF), sp %p, fp %p\n",
345 frame->pc, frame->pc, frame->lr, frame->lr,
346 frame->sp, frame->fp);
350 debug_printf(sts->state, " ...\n");
352 return sts->depth == 0;
356 struct frame_tail *fp;
359 } __attribute__((packed));
361 static struct frame_tail *user_backtrace(struct fiq_debugger_state *state,
362 struct frame_tail *tail)
364 struct frame_tail buftail[2];
366 /* Also check accessibility of one struct frame_tail beyond */
367 if (!access_ok(VERIFY_READ, tail, sizeof(buftail))) {
368 debug_printf(state, " invalid frame pointer %p\n", tail);
371 if (__copy_from_user_inatomic(buftail, tail, sizeof(buftail))) {
373 " failed to copy frame pointer %p\n", tail);
377 debug_printf(state, " %p\n", buftail[0].lr);
379 /* frame pointers should strictly progress back up the stack
380 * (towards higher addresses) */
381 if (tail >= buftail[0].fp)
384 return buftail[0].fp-1;
387 void dump_stacktrace(struct fiq_debugger_state *state,
388 struct pt_regs * const regs, unsigned int depth, void *ssp)
390 struct frame_tail *tail;
391 struct thread_info *real_thread_info = (struct thread_info *)
392 ((unsigned long)ssp & ~(THREAD_SIZE - 1));
393 struct stacktrace_state sts;
397 *current_thread_info() = *real_thread_info;
400 debug_printf(state, "current NULL\n");
402 debug_printf(state, "pid: %d comm: %s\n",
403 current->pid, current->comm);
404 dump_regs(state, (unsigned *)regs);
406 if (!user_mode(regs)) {
407 struct stackframe frame;
408 frame.fp = regs->ARM_fp;
409 frame.sp = regs->ARM_sp;
410 frame.lr = regs->ARM_lr;
411 frame.pc = regs->ARM_pc;
413 " pc: %p (%pF), lr %p (%pF), sp %p, fp %p\n",
414 regs->ARM_pc, regs->ARM_pc, regs->ARM_lr, regs->ARM_lr,
415 regs->ARM_sp, regs->ARM_fp);
416 walk_stackframe(&frame, report_trace, &sts);
420 tail = ((struct frame_tail *) regs->ARM_fp) - 1;
421 while (depth-- && tail && !((unsigned long) tail & 3))
422 tail = user_backtrace(state, tail);
425 static void debug_exec(struct fiq_debugger_state *state,
426 const char *cmd, unsigned *regs, void *svc_sp)
428 if (!strcmp(cmd, "pc")) {
429 debug_printf(state, " pc %08x cpsr %08x mode %s\n",
430 regs[15], regs[16], mode_name(regs[16]));
431 } else if (!strcmp(cmd, "regs")) {
432 dump_regs(state, regs);
433 } else if (!strcmp(cmd, "allregs")) {
434 dump_allregs(state, regs);
435 } else if (!strcmp(cmd, "bt")) {
436 dump_stacktrace(state, (struct pt_regs *)regs, 100, svc_sp);
437 } else if (!strcmp(cmd, "reboot")) {
439 } else if (!strcmp(cmd, "irqs")) {
441 } else if (!strcmp(cmd, "kmsg")) {
442 dump_kernel_log(state);
443 } else if (!strcmp(cmd, "version")) {
444 debug_printf(state, "%s\n", linux_banner);
445 } else if (!strcmp(cmd, "sleep")) {
446 state->no_sleep = false;
447 } else if (!strcmp(cmd, "nosleep")) {
448 state->no_sleep = true;
449 } else if (!strcmp(cmd, "console")) {
450 state->console_enable = true;
451 debug_printf(state, "console mode\n");
453 if (state->debug_busy) {
455 "command processor busy. trying to abort.\n");
456 state->debug_abort = -1;
458 strcpy(state->debug_cmd, cmd);
459 state->debug_busy = 1;
462 debug_force_irq(state);
466 if (!state->console_enable)
470 static void sleep_timer_expired(unsigned long data)
472 struct fiq_debugger_state *state = (struct fiq_debugger_state *)data;
474 if (state->uart_clk_enabled && !state->no_sleep) {
475 if (state->debug_enable) {
476 state->debug_enable = false;
477 debug_printf_nfiq(state, "suspending fiq debugger\n");
479 state->ignore_next_wakeup_irq = true;
481 clk_disable(state->clk);
482 state->uart_clk_enabled = false;
483 enable_wakeup_irq(state);
485 wake_unlock(&state->debugger_wake_lock);
488 static irqreturn_t wakeup_irq_handler(int irq, void *dev)
490 struct fiq_debugger_state *state = dev;
492 if (!state->no_sleep)
493 debug_puts(state, "WAKEUP\n");
494 if (state->ignore_next_wakeup_irq)
495 state->ignore_next_wakeup_irq = false;
496 else if (!state->uart_clk_enabled) {
497 wake_lock(&state->debugger_wake_lock);
499 clk_enable(state->clk);
500 state->uart_clk_enabled = true;
501 disable_wakeup_irq(state);
502 mod_timer(&state->sleep_timer, jiffies + HZ / 2);
507 static irqreturn_t debug_irq(int irq, void *dev)
509 struct fiq_debugger_state *state = dev;
510 if (state->pdata->force_irq_ack)
511 state->pdata->force_irq_ack(state->pdev, state->signal_irq);
513 if (!state->no_sleep) {
514 wake_lock(&state->debugger_wake_lock);
515 mod_timer(&state->sleep_timer, jiffies + HZ * 5);
517 #if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
520 int count = fiq_debugger_ringbuf_level(state->tty_rbuf);
521 for (i = 0; i < count; i++) {
522 int c = fiq_debugger_ringbuf_peek(state->tty_rbuf, i);
523 tty_insert_flip_char(state->tty, c, TTY_NORMAL);
524 if (!fiq_debugger_ringbuf_consume(state->tty_rbuf, 1))
525 pr_warn("fiq tty failed to consume byte\n");
527 tty_flip_buffer_push(state->tty);
530 if (state->debug_busy) {
531 struct kdbg_ctxt ctxt;
533 ctxt.printf = debug_printf_nfiq;
535 kernel_debugger(&ctxt, state->debug_cmd);
538 state->debug_busy = 0;
543 static int debug_getc(struct fiq_debugger_state *state)
545 return state->pdata->uart_getc(state->pdev);
548 static void debug_fiq(struct fiq_glue_handler *h, void *regs, void *svc_sp)
550 struct fiq_debugger_state *state =
551 container_of(h, struct fiq_debugger_state, handler);
556 while ((c = debug_getc(state)) != FIQ_DEBUGGER_NO_CHAR) {
558 if (!state->debug_enable) {
559 if ((c == 13) || (c == 10)) {
560 state->debug_enable = true;
561 state->debug_count = 0;
564 } else if (c == FIQ_DEBUGGER_BREAK) {
565 state->console_enable = false;
566 debug_puts(state, "fiq debugger mode\n");
567 state->debug_count = 0;
569 #ifdef CONFIG_FIQ_DEBUGGER_CONSOLE
570 } else if (state->console_enable && state->tty_rbuf) {
571 fiq_debugger_ringbuf_push(state->tty_rbuf, c);
572 debug_force_irq(state);
574 } else if ((c >= ' ') && (c < 127)) {
575 if (state->debug_count < (DEBUG_MAX - 1)) {
576 state->debug_buf[state->debug_count++] = c;
577 state->pdata->uart_putc(state->pdev, c);
579 } else if ((c == 8) || (c == 127)) {
580 if (state->debug_count > 0) {
581 state->debug_count--;
582 state->pdata->uart_putc(state->pdev, 8);
583 state->pdata->uart_putc(state->pdev, ' ');
584 state->pdata->uart_putc(state->pdev, 8);
586 } else if ((c == 13) || (c == 10)) {
587 if (c == '\r' || (c == '\n' && last_c != '\r')) {
588 state->pdata->uart_putc(state->pdev, '\r');
589 state->pdata->uart_putc(state->pdev, '\n');
591 if (state->debug_count) {
592 state->debug_buf[state->debug_count] = 0;
593 state->debug_count = 0;
594 debug_exec(state, state->debug_buf,
602 debug_uart_flush(state);
603 if (state->pdata->fiq_ack)
604 state->pdata->fiq_ack(state->pdev, state->fiq);
606 /* poke sleep timer if necessary */
607 if (state->debug_enable && !state->no_sleep)
608 debug_force_irq(state);
611 static void debug_resume(struct fiq_glue_handler *h)
613 struct fiq_debugger_state *state =
614 container_of(h, struct fiq_debugger_state, handler);
615 if (state->pdata->uart_resume)
616 state->pdata->uart_resume(state->pdev);
619 #if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
620 struct tty_driver *debug_console_device(struct console *co, int *index)
622 struct fiq_debugger_state *state;
623 state = container_of(co, struct fiq_debugger_state, console);
625 return state->tty_driver;
628 static void debug_console_write(struct console *co,
629 const char *s, unsigned int count)
631 struct fiq_debugger_state *state;
633 state = container_of(co, struct fiq_debugger_state, console);
635 if (!state->console_enable)
640 state->pdata->uart_putc(state->pdev, '\r');
641 state->pdata->uart_putc(state->pdev, *s++);
643 debug_uart_flush(state);
646 static struct console fiq_debugger_console = {
648 .device = debug_console_device,
649 .write = debug_console_write,
650 .flags = CON_PRINTBUFFER | CON_ANYTIME | CON_ENABLED,
653 int fiq_tty_open(struct tty_struct *tty, struct file *filp)
655 struct fiq_debugger_state *state = tty->driver->driver_state;
656 if (state->tty_open_count++)
659 tty->driver_data = state;
664 void fiq_tty_close(struct tty_struct *tty, struct file *filp)
666 struct fiq_debugger_state *state = tty->driver_data;
667 if (--state->tty_open_count)
672 int fiq_tty_write(struct tty_struct *tty, const unsigned char *buf, int count)
675 struct fiq_debugger_state *state = tty->driver_data;
677 if (!state->console_enable)
681 clk_enable(state->clk);
682 for (i = 0; i < count; i++)
683 state->pdata->uart_putc(state->pdev, *buf++);
685 clk_disable(state->clk);
690 int fiq_tty_write_room(struct tty_struct *tty)
695 static const struct tty_operations fiq_tty_driver_ops = {
696 .write = fiq_tty_write,
697 .write_room = fiq_tty_write_room,
698 .open = fiq_tty_open,
699 .close = fiq_tty_close,
702 static int fiq_debugger_tty_init(struct fiq_debugger_state *state)
706 state->tty_driver = alloc_tty_driver(1);
707 if (!state->tty_driver) {
708 pr_err("Failed to allocate fiq debugger tty\n");
712 state->tty_driver->owner = THIS_MODULE;
713 state->tty_driver->driver_name = "fiq-debugger";
714 state->tty_driver->name = "ttyFIQ";
715 state->tty_driver->type = TTY_DRIVER_TYPE_SERIAL;
716 state->tty_driver->subtype = SERIAL_TYPE_NORMAL;
717 state->tty_driver->init_termios = tty_std_termios;
718 state->tty_driver->init_termios.c_cflag =
719 B115200 | CS8 | CREAD | HUPCL | CLOCAL;
720 state->tty_driver->init_termios.c_ispeed =
721 state->tty_driver->init_termios.c_ospeed = 115200;
722 state->tty_driver->flags = TTY_DRIVER_REAL_RAW;
723 tty_set_operations(state->tty_driver, &fiq_tty_driver_ops);
724 state->tty_driver->driver_state = state;
726 ret = tty_register_driver(state->tty_driver);
728 pr_err("Failed to register fiq tty: %d\n", ret);
732 state->tty_rbuf = fiq_debugger_ringbuf_alloc(1024);
733 if (!state->tty_rbuf) {
734 pr_err("Failed to allocate fiq debugger ringbuf\n");
739 pr_info("Registered FIQ tty driver %p\n", state->tty_driver);
743 fiq_debugger_ringbuf_free(state->tty_rbuf);
744 state->tty_rbuf = NULL;
745 put_tty_driver(state->tty_driver);
750 static int fiq_debugger_probe(struct platform_device *pdev)
753 struct fiq_debugger_pdata *pdata = dev_get_platdata(&pdev->dev);
754 struct fiq_debugger_state *state;
756 if (!pdata->uart_getc || !pdata->uart_putc || !pdata->fiq_enable)
759 state = kzalloc(sizeof(*state), GFP_KERNEL);
760 state->handler.fiq = debug_fiq;
761 state->handler.resume = debug_resume;
762 setup_timer(&state->sleep_timer, sleep_timer_expired,
763 (unsigned long)state);
764 state->pdata = pdata;
766 state->no_sleep = initial_no_sleep;
767 state->debug_enable = initial_debug_enable;
768 state->console_enable = initial_console_enable;
770 state->fiq = platform_get_irq_byname(pdev, "fiq");
771 state->signal_irq = platform_get_irq_byname(pdev, "signal");
772 state->wakeup_irq = platform_get_irq_byname(pdev, "wakeup");
774 if (state->wakeup_irq < 0)
775 state->no_sleep = true;
776 state->ignore_next_wakeup_irq = !state->no_sleep;
778 wake_lock_init(&state->debugger_wake_lock,
779 WAKE_LOCK_SUSPEND, "serial-debug");
781 state->clk = clk_get(&pdev->dev, NULL);
782 if (IS_ERR(state->clk))
786 clk_enable(state->clk);
788 if (pdata->uart_init) {
789 ret = pdata->uart_init(pdev);
794 debug_printf_nfiq(state, "<hit enter %sto activate fiq debugger>\n",
795 state->no_sleep ? "" : "twice ");
797 ret = fiq_glue_register_handler(&state->handler);
799 pr_err("serial_debugger: could not install fiq handler\n");
800 goto err_register_fiq;
803 pdata->fiq_enable(pdev, state->fiq, 1);
806 clk_disable(state->clk);
808 ret = request_irq(state->signal_irq, debug_irq,
809 IRQF_TRIGGER_RISING, "debug", state);
811 pr_err("serial_debugger: could not install signal_irq");
813 if (state->wakeup_irq >= 0) {
814 ret = request_irq(state->wakeup_irq, wakeup_irq_handler,
815 IRQF_TRIGGER_FALLING | IRQF_DISABLED,
816 "debug-wakeup", state);
818 pr_err("serial_debugger: "
819 "could not install wakeup irq\n");
820 state->wakeup_irq = -1;
822 ret = enable_irq_wake(state->wakeup_irq);
824 pr_err("serial_debugger: "
825 "could not enable wakeup\n");
826 state->wakeup_irq_no_set_wake = true;
831 wakeup_irq_handler(state->wakeup_irq, state);
833 #if defined(CONFIG_FIQ_DEBUGGER_CONSOLE)
834 state->console = fiq_debugger_console;
835 register_console(&state->console);
836 fiq_debugger_tty_init(state);
841 if (pdata->uart_free)
842 pdata->uart_free(pdev);
850 static struct platform_driver fiq_debugger_driver = {
851 .probe = fiq_debugger_probe,
852 .driver.name = "fiq_debugger",
855 static int __init fiq_debugger_init(void)
857 return platform_driver_register(&fiq_debugger_driver);
860 postcore_initcall(fiq_debugger_init);