[SCSI] zfcp: fix device registration issues
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / serial / 68328serial.c
blob7f0f35a05dcac35e30a05cce2f962ccf7e0510e6
1 /* 68328serial.c: Serial port driver for 68328 microcontroller
3 * Copyright (C) 1995 David S. Miller <davem@caip.rutgers.edu>
4 * Copyright (C) 1998 Kenneth Albanowski <kjahds@kjahds.com>
5 * Copyright (C) 1998, 1999 D. Jeff Dionne <jeff@uclinux.org>
6 * Copyright (C) 1999 Vladimir Gurevich <vgurevic@cisco.com>
7 * Copyright (C) 2002-2003 David McCullough <davidm@snapgear.com>
8 * Copyright (C) 2002 Greg Ungerer <gerg@snapgear.com>
10 * VZ Support/Fixes Evan Stawnyczy <e@lineo.ca>
11 * Multiple UART support Daniel Potts <danielp@cse.unsw.edu.au>
12 * Power management support Daniel Potts <danielp@cse.unsw.edu.au>
13 * VZ Second Serial Port enable Phil Wilshire
14 * 2.4/2.5 port David McCullough
17 #include <asm/dbg.h>
18 #include <linux/module.h>
19 #include <linux/errno.h>
20 #include <linux/signal.h>
21 #include <linux/sched.h>
22 #include <linux/timer.h>
23 #include <linux/interrupt.h>
24 #include <linux/tty.h>
25 #include <linux/tty_flip.h>
26 #include <linux/config.h>
27 #include <linux/major.h>
28 #include <linux/string.h>
29 #include <linux/fcntl.h>
30 #include <linux/mm.h>
31 #include <linux/kernel.h>
32 #include <linux/console.h>
33 #include <linux/reboot.h>
34 #include <linux/keyboard.h>
35 #include <linux/init.h>
36 #include <linux/pm.h>
37 #include <linux/pm_legacy.h>
38 #include <linux/bitops.h>
39 #include <linux/delay.h>
41 #include <asm/io.h>
42 #include <asm/irq.h>
43 #include <asm/system.h>
44 #include <asm/delay.h>
45 #include <asm/uaccess.h>
47 /* (es) */
48 /* note: perhaps we can murge these files, so that you can just
49 * define 1 of them, and they can sort that out for themselves
51 #if defined(CONFIG_M68EZ328)
52 #include <asm/MC68EZ328.h>
53 #else
54 #if defined(CONFIG_M68VZ328)
55 #include <asm/MC68VZ328.h>
56 #else
57 #include <asm/MC68328.h>
58 #endif /* CONFIG_M68VZ328 */
59 #endif /* CONFIG_M68EZ328 */
61 #include "68328serial.h"
63 /* Turn off usage of real serial interrupt code, to "support" Copilot */
64 #ifdef CONFIG_XCOPILOT_BUGS
65 #undef USE_INTS
66 #else
67 #define USE_INTS
68 #endif
70 static struct m68k_serial m68k_soft[NR_PORTS];
71 struct m68k_serial *IRQ_ports[NR_IRQS];
73 static unsigned int uart_irqs[NR_PORTS] = UART_IRQ_DEFNS;
75 /* multiple ports are contiguous in memory */
76 m68328_uart *uart_addr = (m68328_uart *)USTCNT_ADDR;
78 struct tty_struct m68k_ttys;
79 struct m68k_serial *m68k_consinfo = 0;
81 #define M68K_CLOCK (16667000) /* FIXME: 16MHz is likely wrong */
83 #ifdef CONFIG_CONSOLE
84 extern wait_queue_head_t keypress_wait;
85 #endif
87 struct tty_driver *serial_driver;
89 /* serial subtype definitions */
90 #define SERIAL_TYPE_NORMAL 1
92 /* number of characters left in xmit buffer before we ask for more */
93 #define WAKEUP_CHARS 256
95 /* Debugging... DEBUG_INTR is bad to use when one of the zs
96 * lines is your console ;(
98 #undef SERIAL_DEBUG_INTR
99 #undef SERIAL_DEBUG_OPEN
100 #undef SERIAL_DEBUG_FLOW
102 #define RS_ISR_PASS_LIMIT 256
104 #define _INLINE_ inline
106 static void change_speed(struct m68k_serial *info);
109 * Setup for console. Argument comes from the boot command line.
112 #if defined(CONFIG_M68EZ328ADS) || defined(CONFIG_ALMA_ANS) || defined(CONFIG_DRAGONIXVZ)
113 #define CONSOLE_BAUD_RATE 115200
114 #define DEFAULT_CBAUD B115200
115 #else
116 /* (es) */
117 /* note: this is messy, but it works, again, perhaps defined somewhere else?*/
118 #ifdef CONFIG_M68VZ328
119 #define CONSOLE_BAUD_RATE 19200
120 #define DEFAULT_CBAUD B19200
121 #endif
122 /* (/es) */
123 #endif
125 #ifndef CONSOLE_BAUD_RATE
126 #define CONSOLE_BAUD_RATE 9600
127 #define DEFAULT_CBAUD B9600
128 #endif
131 static int m68328_console_initted = 0;
132 static int m68328_console_baud = CONSOLE_BAUD_RATE;
133 static int m68328_console_cbaud = DEFAULT_CBAUD;
137 * tmp_buf is used as a temporary buffer by serial_write. We need to
138 * lock it in case the memcpy_fromfs blocks while swapping in a page,
139 * and some other program tries to do a serial write at the same time.
140 * Since the lock will only come under contention when the system is
141 * swapping and available memory is low, it makes sense to share one
142 * buffer across all the serial ports, since it significantly saves
143 * memory if large numbers of serial ports are open.
145 static unsigned char tmp_buf[SERIAL_XMIT_SIZE]; /* This is cheating */
147 static inline int serial_paranoia_check(struct m68k_serial *info,
148 char *name, const char *routine)
150 #ifdef SERIAL_PARANOIA_CHECK
151 static const char *badmagic =
152 "Warning: bad magic number for serial struct %s in %s\n";
153 static const char *badinfo =
154 "Warning: null m68k_serial for %s in %s\n";
156 if (!info) {
157 printk(badinfo, name, routine);
158 return 1;
160 if (info->magic != SERIAL_MAGIC) {
161 printk(badmagic, name, routine);
162 return 1;
164 #endif
165 return 0;
169 * This is used to figure out the divisor speeds and the timeouts
171 static int baud_table[] = {
172 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 1800, 2400, 4800,
173 9600, 19200, 38400, 57600, 115200, 0 };
175 #define BAUD_TABLE_SIZE (sizeof(baud_table)/sizeof(baud_table[0]))
177 /* Sets or clears DTR/RTS on the requested line */
178 static inline void m68k_rtsdtr(struct m68k_serial *ss, int set)
180 if (set) {
181 /* set the RTS/CTS line */
182 } else {
183 /* clear it */
185 return;
188 /* Utility routines */
189 static inline int get_baud(struct m68k_serial *ss)
191 unsigned long result = 115200;
192 unsigned short int baud = uart_addr[ss->line].ubaud;
193 if (GET_FIELD(baud, UBAUD_PRESCALER) == 0x38) result = 38400;
194 result >>= GET_FIELD(baud, UBAUD_DIVIDE);
196 return result;
200 * ------------------------------------------------------------
201 * rs_stop() and rs_start()
203 * This routines are called before setting or resetting tty->stopped.
204 * They enable or disable transmitter interrupts, as necessary.
205 * ------------------------------------------------------------
207 static void rs_stop(struct tty_struct *tty)
209 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
210 m68328_uart *uart = &uart_addr[info->line];
211 unsigned long flags;
213 if (serial_paranoia_check(info, tty->name, "rs_stop"))
214 return;
216 save_flags(flags); cli();
217 uart->ustcnt &= ~USTCNT_TXEN;
218 restore_flags(flags);
221 static void rs_put_char(char ch)
223 int flags, loops = 0;
225 save_flags(flags); cli();
227 while (!(UTX & UTX_TX_AVAIL) && (loops < 1000)) {
228 loops++;
229 udelay(5);
232 UTX_TXDATA = ch;
233 udelay(5);
234 restore_flags(flags);
237 static void rs_start(struct tty_struct *tty)
239 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
240 m68328_uart *uart = &uart_addr[info->line];
241 unsigned long flags;
243 if (serial_paranoia_check(info, tty->name, "rs_start"))
244 return;
246 save_flags(flags); cli();
247 if (info->xmit_cnt && info->xmit_buf && !(uart->ustcnt & USTCNT_TXEN)) {
248 #ifdef USE_INTS
249 uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
250 #else
251 uart->ustcnt |= USTCNT_TXEN;
252 #endif
254 restore_flags(flags);
257 /* Drop into either the boot monitor or kadb upon receiving a break
258 * from keyboard/console input.
260 static void batten_down_hatches(void)
262 /* Drop into the debugger */
265 static _INLINE_ void status_handle(struct m68k_serial *info, unsigned short status)
267 #if 0
268 if(status & DCD) {
269 if((info->tty->termios->c_cflag & CRTSCTS) &&
270 ((info->curregs[3] & AUTO_ENAB)==0)) {
271 info->curregs[3] |= AUTO_ENAB;
272 info->pendregs[3] |= AUTO_ENAB;
273 write_zsreg(info->m68k_channel, 3, info->curregs[3]);
275 } else {
276 if((info->curregs[3] & AUTO_ENAB)) {
277 info->curregs[3] &= ~AUTO_ENAB;
278 info->pendregs[3] &= ~AUTO_ENAB;
279 write_zsreg(info->m68k_channel, 3, info->curregs[3]);
282 #endif
283 /* If this is console input and this is a
284 * 'break asserted' status change interrupt
285 * see if we can drop into the debugger
287 if((status & URX_BREAK) && info->break_abort)
288 batten_down_hatches();
289 return;
292 static _INLINE_ void receive_chars(struct m68k_serial *info, struct pt_regs *regs, unsigned short rx)
294 struct tty_struct *tty = info->tty;
295 m68328_uart *uart = &uart_addr[info->line];
296 unsigned char ch, flag;
299 * This do { } while() loop will get ALL chars out of Rx FIFO
301 #ifndef CONFIG_XCOPILOT_BUGS
302 do {
303 #endif
304 ch = GET_FIELD(rx, URX_RXDATA);
306 if(info->is_cons) {
307 if(URX_BREAK & rx) { /* whee, break received */
308 status_handle(info, rx);
309 return;
310 #ifdef CONFIG_MAGIC_SYSRQ
311 } else if (ch == 0x10) { /* ^P */
312 show_state();
313 show_free_areas();
314 show_buffers();
315 /* show_net_buffers(); */
316 return;
317 } else if (ch == 0x12) { /* ^R */
318 emergency_restart();
319 return;
320 #endif /* CONFIG_MAGIC_SYSRQ */
322 /* It is a 'keyboard interrupt' ;-) */
323 #ifdef CONFIG_CONSOLE
324 wake_up(&keypress_wait);
325 #endif
328 if(!tty)
329 goto clear_and_exit;
332 * Make sure that we do not overflow the buffer
334 if (tty_request_buffer_room(tty, 1) == 0) {
335 tty_schedule_flip(tty);
336 return;
339 flag = TTY_NORMAL;
341 if(rx & URX_PARITY_ERROR) {
342 flag = TTY_PARITY;
343 status_handle(info, rx);
344 } else if(rx & URX_OVRUN) {
345 flag = TTY_OVERRUN;
346 status_handle(info, rx);
347 } else if(rx & URX_FRAME_ERROR) {
348 flag = TTY_FRAME;
349 status_handle(info, rx);
351 tty_insert_flip_char(tty, ch, flag);
352 #ifndef CONFIG_XCOPILOT_BUGS
353 } while((rx = uart->urx.w) & URX_DATA_READY);
354 #endif
356 tty_schedule_flip(tty);
358 clear_and_exit:
359 return;
362 static _INLINE_ void transmit_chars(struct m68k_serial *info)
364 m68328_uart *uart = &uart_addr[info->line];
366 if (info->x_char) {
367 /* Send next char */
368 uart->utx.b.txdata = info->x_char;
369 info->x_char = 0;
370 goto clear_and_return;
373 if((info->xmit_cnt <= 0) || info->tty->stopped) {
374 /* That's peculiar... TX ints off */
375 uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
376 goto clear_and_return;
379 /* Send char */
380 uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
381 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
382 info->xmit_cnt--;
384 if (info->xmit_cnt < WAKEUP_CHARS)
385 schedule_work(&info->tqueue);
387 if(info->xmit_cnt <= 0) {
388 /* All done for now... TX ints off */
389 uart->ustcnt &= ~USTCNT_TX_INTR_MASK;
390 goto clear_and_return;
393 clear_and_return:
394 /* Clear interrupt (should be auto)*/
395 return;
399 * This is the serial driver's generic interrupt routine
401 irqreturn_t rs_interrupt(int irq, void *dev_id, struct pt_regs * regs)
403 struct m68k_serial * info;
404 m68328_uart *uart;
405 unsigned short rx;
406 unsigned short tx;
408 info = IRQ_ports[irq];
409 if(!info)
410 return IRQ_NONE;
412 uart = &uart_addr[info->line];
413 rx = uart->urx.w;
415 #ifdef USE_INTS
416 tx = uart->utx.w;
418 if (rx & URX_DATA_READY) receive_chars(info, regs, rx);
419 if (tx & UTX_TX_AVAIL) transmit_chars(info);
420 #else
421 receive_chars(info, regs, rx);
422 #endif
423 return IRQ_HANDLED;
426 static void do_softint(void *private)
428 struct m68k_serial *info = (struct m68k_serial *) private;
429 struct tty_struct *tty;
431 tty = info->tty;
432 if (!tty)
433 return;
434 #if 0
435 if (clear_bit(RS_EVENT_WRITE_WAKEUP, &info->event)) {
436 tty_wakeup(tty);
438 #endif
442 * This routine is called from the scheduler tqueue when the interrupt
443 * routine has signalled that a hangup has occurred. The path of
444 * hangup processing is:
446 * serial interrupt routine -> (scheduler tqueue) ->
447 * do_serial_hangup() -> tty->hangup() -> rs_hangup()
450 static void do_serial_hangup(void *private)
452 struct m68k_serial *info = (struct m68k_serial *) private;
453 struct tty_struct *tty;
455 tty = info->tty;
456 if (!tty)
457 return;
459 tty_hangup(tty);
463 static int startup(struct m68k_serial * info)
465 m68328_uart *uart = &uart_addr[info->line];
466 unsigned long flags;
468 if (info->flags & S_INITIALIZED)
469 return 0;
471 if (!info->xmit_buf) {
472 info->xmit_buf = (unsigned char *) __get_free_page(GFP_KERNEL);
473 if (!info->xmit_buf)
474 return -ENOMEM;
477 save_flags(flags); cli();
480 * Clear the FIFO buffers and disable them
481 * (they will be reenabled in change_speed())
484 uart->ustcnt = USTCNT_UEN;
485 info->xmit_fifo_size = 1;
486 uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_TXEN;
487 (void)uart->urx.w;
490 * Finally, enable sequencing and interrupts
492 #ifdef USE_INTS
493 uart->ustcnt = USTCNT_UEN | USTCNT_RXEN |
494 USTCNT_RX_INTR_MASK | USTCNT_TX_INTR_MASK;
495 #else
496 uart->ustcnt = USTCNT_UEN | USTCNT_RXEN | USTCNT_RX_INTR_MASK;
497 #endif
499 if (info->tty)
500 clear_bit(TTY_IO_ERROR, &info->tty->flags);
501 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
504 * and set the speed of the serial port
507 change_speed(info);
509 info->flags |= S_INITIALIZED;
510 restore_flags(flags);
511 return 0;
515 * This routine will shutdown a serial port; interrupts are disabled, and
516 * DTR is dropped if the hangup on close termio flag is on.
518 static void shutdown(struct m68k_serial * info)
520 m68328_uart *uart = &uart_addr[info->line];
521 unsigned long flags;
523 uart->ustcnt = 0; /* All off! */
524 if (!(info->flags & S_INITIALIZED))
525 return;
527 save_flags(flags); cli(); /* Disable interrupts */
529 if (info->xmit_buf) {
530 free_page((unsigned long) info->xmit_buf);
531 info->xmit_buf = 0;
534 if (info->tty)
535 set_bit(TTY_IO_ERROR, &info->tty->flags);
537 info->flags &= ~S_INITIALIZED;
538 restore_flags(flags);
541 struct {
542 int divisor, prescale;
544 #ifndef CONFIG_M68VZ328
545 hw_baud_table[18] = {
546 {0,0}, /* 0 */
547 {0,0}, /* 50 */
548 {0,0}, /* 75 */
549 {0,0}, /* 110 */
550 {0,0}, /* 134 */
551 {0,0}, /* 150 */
552 {0,0}, /* 200 */
553 {7,0x26}, /* 300 */
554 {6,0x26}, /* 600 */
555 {5,0x26}, /* 1200 */
556 {0,0}, /* 1800 */
557 {4,0x26}, /* 2400 */
558 {3,0x26}, /* 4800 */
559 {2,0x26}, /* 9600 */
560 {1,0x26}, /* 19200 */
561 {0,0x26}, /* 38400 */
562 {1,0x38}, /* 57600 */
563 {0,0x38}, /* 115200 */
565 #else
566 hw_baud_table[18] = {
567 {0,0}, /* 0 */
568 {0,0}, /* 50 */
569 {0,0}, /* 75 */
570 {0,0}, /* 110 */
571 {0,0}, /* 134 */
572 {0,0}, /* 150 */
573 {0,0}, /* 200 */
574 {0,0}, /* 300 */
575 {7,0x26}, /* 600 */
576 {6,0x26}, /* 1200 */
577 {0,0}, /* 1800 */
578 {5,0x26}, /* 2400 */
579 {4,0x26}, /* 4800 */
580 {3,0x26}, /* 9600 */
581 {2,0x26}, /* 19200 */
582 {1,0x26}, /* 38400 */
583 {0,0x26}, /* 57600 */
584 {1,0x38}, /* 115200 */
586 #endif
587 /* rate = 1036800 / ((65 - prescale) * (1<<divider)) */
590 * This routine is called to set the UART divisor registers to match
591 * the specified baud rate for a serial port.
593 static void change_speed(struct m68k_serial *info)
595 m68328_uart *uart = &uart_addr[info->line];
596 unsigned short port;
597 unsigned short ustcnt;
598 unsigned cflag;
599 int i;
601 if (!info->tty || !info->tty->termios)
602 return;
603 cflag = info->tty->termios->c_cflag;
604 if (!(port = info->port))
605 return;
607 ustcnt = uart->ustcnt;
608 uart->ustcnt = ustcnt & ~USTCNT_TXEN;
610 i = cflag & CBAUD;
611 if (i & CBAUDEX) {
612 i = (i & ~CBAUDEX) + B38400;
615 info->baud = baud_table[i];
616 uart->ubaud = PUT_FIELD(UBAUD_DIVIDE, hw_baud_table[i].divisor) |
617 PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
619 ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
621 if ((cflag & CSIZE) == CS8)
622 ustcnt |= USTCNT_8_7;
624 if (cflag & CSTOPB)
625 ustcnt |= USTCNT_STOP;
627 if (cflag & PARENB)
628 ustcnt |= USTCNT_PARITYEN;
629 if (cflag & PARODD)
630 ustcnt |= USTCNT_ODD_EVEN;
632 #ifdef CONFIG_SERIAL_68328_RTS_CTS
633 if (cflag & CRTSCTS) {
634 uart->utx.w &= ~ UTX_NOCTS;
635 } else {
636 uart->utx.w |= UTX_NOCTS;
638 #endif
640 ustcnt |= USTCNT_TXEN;
642 uart->ustcnt = ustcnt;
643 return;
647 * Fair output driver allows a process to speak.
649 static void rs_fair_output(void)
651 int left; /* Output no more than that */
652 unsigned long flags;
653 struct m68k_serial *info = &m68k_soft[0];
654 char c;
656 if (info == 0) return;
657 if (info->xmit_buf == 0) return;
659 save_flags(flags); cli();
660 left = info->xmit_cnt;
661 while (left != 0) {
662 c = info->xmit_buf[info->xmit_tail];
663 info->xmit_tail = (info->xmit_tail+1) & (SERIAL_XMIT_SIZE-1);
664 info->xmit_cnt--;
665 restore_flags(flags);
667 rs_put_char(c);
669 save_flags(flags); cli();
670 left = min(info->xmit_cnt, left-1);
673 /* Last character is being transmitted now (hopefully). */
674 udelay(5);
676 restore_flags(flags);
677 return;
681 * m68k_console_print is registered for printk.
683 void console_print_68328(const char *p)
685 char c;
687 while((c=*(p++)) != 0) {
688 if(c == '\n')
689 rs_put_char('\r');
690 rs_put_char(c);
693 /* Comment this if you want to have a strict interrupt-driven output */
694 rs_fair_output();
696 return;
699 static void rs_set_ldisc(struct tty_struct *tty)
701 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
703 if (serial_paranoia_check(info, tty->name, "rs_set_ldisc"))
704 return;
706 info->is_cons = (tty->termios->c_line == N_TTY);
708 printk("ttyS%d console mode %s\n", info->line, info->is_cons ? "on" : "off");
711 static void rs_flush_chars(struct tty_struct *tty)
713 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
714 m68328_uart *uart = &uart_addr[info->line];
715 unsigned long flags;
717 if (serial_paranoia_check(info, tty->name, "rs_flush_chars"))
718 return;
719 #ifndef USE_INTS
720 for(;;) {
721 #endif
723 /* Enable transmitter */
724 save_flags(flags); cli();
726 if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped ||
727 !info->xmit_buf) {
728 restore_flags(flags);
729 return;
732 #ifdef USE_INTS
733 uart->ustcnt |= USTCNT_TXEN | USTCNT_TX_INTR_MASK;
734 #else
735 uart->ustcnt |= USTCNT_TXEN;
736 #endif
738 #ifdef USE_INTS
739 if (uart->utx.w & UTX_TX_AVAIL) {
740 #else
741 if (1) {
742 #endif
743 /* Send char */
744 uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
745 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
746 info->xmit_cnt--;
749 #ifndef USE_INTS
750 while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
752 #endif
753 restore_flags(flags);
756 extern void console_printn(const char * b, int count);
758 static int rs_write(struct tty_struct * tty,
759 const unsigned char *buf, int count)
761 int c, total = 0;
762 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
763 m68328_uart *uart = &uart_addr[info->line];
764 unsigned long flags;
766 if (serial_paranoia_check(info, tty->name, "rs_write"))
767 return 0;
769 if (!tty || !info->xmit_buf)
770 return 0;
772 save_flags(flags);
773 while (1) {
774 cli();
775 c = min_t(int, count, min(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
776 SERIAL_XMIT_SIZE - info->xmit_head));
777 if (c <= 0)
778 break;
780 memcpy(info->xmit_buf + info->xmit_head, buf, c);
781 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
782 info->xmit_cnt += c;
783 restore_flags(flags);
784 buf += c;
785 count -= c;
786 total += c;
789 if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) {
790 /* Enable transmitter */
791 cli();
792 #ifndef USE_INTS
793 while(info->xmit_cnt) {
794 #endif
796 uart->ustcnt |= USTCNT_TXEN;
797 #ifdef USE_INTS
798 uart->ustcnt |= USTCNT_TX_INTR_MASK;
799 #else
800 while (!(uart->utx.w & UTX_TX_AVAIL)) udelay(5);
801 #endif
802 if (uart->utx.w & UTX_TX_AVAIL) {
803 uart->utx.b.txdata = info->xmit_buf[info->xmit_tail++];
804 info->xmit_tail = info->xmit_tail & (SERIAL_XMIT_SIZE-1);
805 info->xmit_cnt--;
808 #ifndef USE_INTS
810 #endif
811 restore_flags(flags);
813 restore_flags(flags);
814 return total;
817 static int rs_write_room(struct tty_struct *tty)
819 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
820 int ret;
822 if (serial_paranoia_check(info, tty->name, "rs_write_room"))
823 return 0;
824 ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1;
825 if (ret < 0)
826 ret = 0;
827 return ret;
830 static int rs_chars_in_buffer(struct tty_struct *tty)
832 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
834 if (serial_paranoia_check(info, tty->name, "rs_chars_in_buffer"))
835 return 0;
836 return info->xmit_cnt;
839 static void rs_flush_buffer(struct tty_struct *tty)
841 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
843 if (serial_paranoia_check(info, tty->name, "rs_flush_buffer"))
844 return;
845 cli();
846 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
847 sti();
848 tty_wakeup(tty);
852 * ------------------------------------------------------------
853 * rs_throttle()
855 * This routine is called by the upper-layer tty layer to signal that
856 * incoming characters should be throttled.
857 * ------------------------------------------------------------
859 static void rs_throttle(struct tty_struct * tty)
861 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
863 if (serial_paranoia_check(info, tty->name, "rs_throttle"))
864 return;
866 if (I_IXOFF(tty))
867 info->x_char = STOP_CHAR(tty);
869 /* Turn off RTS line (do this atomic) */
872 static void rs_unthrottle(struct tty_struct * tty)
874 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
876 if (serial_paranoia_check(info, tty->name, "rs_unthrottle"))
877 return;
879 if (I_IXOFF(tty)) {
880 if (info->x_char)
881 info->x_char = 0;
882 else
883 info->x_char = START_CHAR(tty);
886 /* Assert RTS line (do this atomic) */
890 * ------------------------------------------------------------
891 * rs_ioctl() and friends
892 * ------------------------------------------------------------
895 static int get_serial_info(struct m68k_serial * info,
896 struct serial_struct * retinfo)
898 struct serial_struct tmp;
900 if (!retinfo)
901 return -EFAULT;
902 memset(&tmp, 0, sizeof(tmp));
903 tmp.type = info->type;
904 tmp.line = info->line;
905 tmp.port = info->port;
906 tmp.irq = info->irq;
907 tmp.flags = info->flags;
908 tmp.baud_base = info->baud_base;
909 tmp.close_delay = info->close_delay;
910 tmp.closing_wait = info->closing_wait;
911 tmp.custom_divisor = info->custom_divisor;
912 copy_to_user(retinfo,&tmp,sizeof(*retinfo));
913 return 0;
916 static int set_serial_info(struct m68k_serial * info,
917 struct serial_struct * new_info)
919 struct serial_struct new_serial;
920 struct m68k_serial old_info;
921 int retval = 0;
923 if (!new_info)
924 return -EFAULT;
925 copy_from_user(&new_serial,new_info,sizeof(new_serial));
926 old_info = *info;
928 if (!capable(CAP_SYS_ADMIN)) {
929 if ((new_serial.baud_base != info->baud_base) ||
930 (new_serial.type != info->type) ||
931 (new_serial.close_delay != info->close_delay) ||
932 ((new_serial.flags & ~S_USR_MASK) !=
933 (info->flags & ~S_USR_MASK)))
934 return -EPERM;
935 info->flags = ((info->flags & ~S_USR_MASK) |
936 (new_serial.flags & S_USR_MASK));
937 info->custom_divisor = new_serial.custom_divisor;
938 goto check_and_exit;
941 if (info->count > 1)
942 return -EBUSY;
945 * OK, past this point, all the error checking has been done.
946 * At this point, we start making changes.....
949 info->baud_base = new_serial.baud_base;
950 info->flags = ((info->flags & ~S_FLAGS) |
951 (new_serial.flags & S_FLAGS));
952 info->type = new_serial.type;
953 info->close_delay = new_serial.close_delay;
954 info->closing_wait = new_serial.closing_wait;
956 check_and_exit:
957 retval = startup(info);
958 return retval;
962 * get_lsr_info - get line status register info
964 * Purpose: Let user call ioctl() to get info when the UART physically
965 * is emptied. On bus types like RS485, the transmitter must
966 * release the bus after transmitting. This must be done when
967 * the transmit shift register is empty, not be done when the
968 * transmit holding register is empty. This functionality
969 * allows an RS485 driver to be written in user space.
971 static int get_lsr_info(struct m68k_serial * info, unsigned int *value)
973 #ifdef CONFIG_SERIAL_68328_RTS_CTS
974 m68328_uart *uart = &uart_addr[info->line];
975 #endif
976 unsigned char status;
978 cli();
979 #ifdef CONFIG_SERIAL_68328_RTS_CTS
980 status = (uart->utx.w & UTX_CTS_STAT) ? 1 : 0;
981 #else
982 status = 0;
983 #endif
984 sti();
985 put_user(status,value);
986 return 0;
990 * This routine sends a break character out the serial port.
992 static void send_break(struct m68k_serial * info, unsigned int duration)
994 m68328_uart *uart = &uart_addr[info->line];
995 unsigned long flags;
996 if (!info->port)
997 return;
998 save_flags(flags);
999 cli();
1000 #ifdef USE_INTS
1001 uart->utx.w |= UTX_SEND_BREAK;
1002 msleep_interruptible(duration);
1003 uart->utx.w &= ~UTX_SEND_BREAK;
1004 #endif
1005 restore_flags(flags);
1008 static int rs_ioctl(struct tty_struct *tty, struct file * file,
1009 unsigned int cmd, unsigned long arg)
1011 int error;
1012 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
1013 int retval;
1015 if (serial_paranoia_check(info, tty->name, "rs_ioctl"))
1016 return -ENODEV;
1018 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
1019 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGWILD) &&
1020 (cmd != TIOCSERSWILD) && (cmd != TIOCSERGSTRUCT)) {
1021 if (tty->flags & (1 << TTY_IO_ERROR))
1022 return -EIO;
1025 switch (cmd) {
1026 case TCSBRK: /* SVID version: non-zero arg --> no break */
1027 retval = tty_check_change(tty);
1028 if (retval)
1029 return retval;
1030 tty_wait_until_sent(tty, 0);
1031 if (!arg)
1032 send_break(info, 250); /* 1/4 second */
1033 return 0;
1034 case TCSBRKP: /* support for POSIX tcsendbreak() */
1035 retval = tty_check_change(tty);
1036 if (retval)
1037 return retval;
1038 tty_wait_until_sent(tty, 0);
1039 send_break(info, arg ? arg*(100) : 250);
1040 return 0;
1041 case TIOCGSOFTCAR:
1042 error = put_user(C_CLOCAL(tty) ? 1 : 0,
1043 (unsigned long *) arg);
1044 if (error)
1045 return error;
1046 return 0;
1047 case TIOCSSOFTCAR:
1048 get_user(arg, (unsigned long *) arg);
1049 tty->termios->c_cflag =
1050 ((tty->termios->c_cflag & ~CLOCAL) |
1051 (arg ? CLOCAL : 0));
1052 return 0;
1053 case TIOCGSERIAL:
1054 if (access_ok(VERIFY_WRITE, (void *) arg,
1055 sizeof(struct serial_struct)))
1056 return get_serial_info(info,
1057 (struct serial_struct *) arg);
1058 return -EFAULT;
1059 case TIOCSSERIAL:
1060 return set_serial_info(info,
1061 (struct serial_struct *) arg);
1062 case TIOCSERGETLSR: /* Get line status register */
1063 if (access_ok(VERIFY_WRITE, (void *) arg,
1064 sizeof(unsigned int));
1065 return get_lsr_info(info, (unsigned int *) arg);
1066 return -EFAULT;
1067 case TIOCSERGSTRUCT:
1068 if (!access_ok(VERIFY_WRITE, (void *) arg,
1069 sizeof(struct m68k_serial)))
1070 return -EFAULT;
1071 copy_to_user((struct m68k_serial *) arg,
1072 info, sizeof(struct m68k_serial));
1073 return 0;
1075 default:
1076 return -ENOIOCTLCMD;
1078 return 0;
1081 static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
1083 struct m68k_serial *info = (struct m68k_serial *)tty->driver_data;
1085 if (tty->termios->c_cflag == old_termios->c_cflag)
1086 return;
1088 change_speed(info);
1090 if ((old_termios->c_cflag & CRTSCTS) &&
1091 !(tty->termios->c_cflag & CRTSCTS)) {
1092 tty->hw_stopped = 0;
1093 rs_start(tty);
1099 * ------------------------------------------------------------
1100 * rs_close()
1102 * This routine is called when the serial port gets closed. First, we
1103 * wait for the last remaining data to be sent. Then, we unlink its
1104 * S structure from the interrupt chain if necessary, and we free
1105 * that IRQ if nothing is left in the chain.
1106 * ------------------------------------------------------------
1108 static void rs_close(struct tty_struct *tty, struct file * filp)
1110 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
1111 m68328_uart *uart = &uart_addr[info->line];
1112 unsigned long flags;
1114 if (!info || serial_paranoia_check(info, tty->name, "rs_close"))
1115 return;
1117 save_flags(flags); cli();
1119 if (tty_hung_up_p(filp)) {
1120 restore_flags(flags);
1121 return;
1124 if ((tty->count == 1) && (info->count != 1)) {
1126 * Uh, oh. tty->count is 1, which means that the tty
1127 * structure will be freed. Info->count should always
1128 * be one in these conditions. If it's greater than
1129 * one, we've got real problems, since it means the
1130 * serial port won't be shutdown.
1132 printk("rs_close: bad serial port count; tty->count is 1, "
1133 "info->count is %d\n", info->count);
1134 info->count = 1;
1136 if (--info->count < 0) {
1137 printk("rs_close: bad serial port count for ttyS%d: %d\n",
1138 info->line, info->count);
1139 info->count = 0;
1141 if (info->count) {
1142 restore_flags(flags);
1143 return;
1145 info->flags |= S_CLOSING;
1147 * Now we wait for the transmit buffer to clear; and we notify
1148 * the line discipline to only process XON/XOFF characters.
1150 tty->closing = 1;
1151 if (info->closing_wait != S_CLOSING_WAIT_NONE)
1152 tty_wait_until_sent(tty, info->closing_wait);
1154 * At this point we stop accepting input. To do this, we
1155 * disable the receive line status interrupts, and tell the
1156 * interrupt driver to stop checking the data ready bit in the
1157 * line status register.
1160 uart->ustcnt &= ~USTCNT_RXEN;
1161 uart->ustcnt &= ~(USTCNT_RXEN | USTCNT_RX_INTR_MASK);
1163 shutdown(info);
1164 if (tty->driver->flush_buffer)
1165 tty->driver->flush_buffer(tty);
1167 tty_ldisc_flush(tty);
1168 tty->closing = 0;
1169 info->event = 0;
1170 info->tty = 0;
1171 #warning "This is not and has never been valid so fix it"
1172 #if 0
1173 if (tty->ldisc.num != ldiscs[N_TTY].num) {
1174 if (tty->ldisc.close)
1175 (tty->ldisc.close)(tty);
1176 tty->ldisc = ldiscs[N_TTY];
1177 tty->termios->c_line = N_TTY;
1178 if (tty->ldisc.open)
1179 (tty->ldisc.open)(tty);
1181 #endif
1182 if (info->blocked_open) {
1183 if (info->close_delay) {
1184 msleep_interruptible(jiffies_to_msecs(info->close_delay));
1186 wake_up_interruptible(&info->open_wait);
1188 info->flags &= ~(S_NORMAL_ACTIVE|S_CLOSING);
1189 wake_up_interruptible(&info->close_wait);
1190 restore_flags(flags);
1194 * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
1196 void rs_hangup(struct tty_struct *tty)
1198 struct m68k_serial * info = (struct m68k_serial *)tty->driver_data;
1200 if (serial_paranoia_check(info, tty->name, "rs_hangup"))
1201 return;
1203 rs_flush_buffer(tty);
1204 shutdown(info);
1205 info->event = 0;
1206 info->count = 0;
1207 info->flags &= ~S_NORMAL_ACTIVE;
1208 info->tty = 0;
1209 wake_up_interruptible(&info->open_wait);
1213 * ------------------------------------------------------------
1214 * rs_open() and friends
1215 * ------------------------------------------------------------
1217 static int block_til_ready(struct tty_struct *tty, struct file * filp,
1218 struct m68k_serial *info)
1220 DECLARE_WAITQUEUE(wait, current);
1221 int retval;
1222 int do_clocal = 0;
1225 * If the device is in the middle of being closed, then block
1226 * until it's done, and then try again.
1228 if (info->flags & S_CLOSING) {
1229 interruptible_sleep_on(&info->close_wait);
1230 #ifdef SERIAL_DO_RESTART
1231 if (info->flags & S_HUP_NOTIFY)
1232 return -EAGAIN;
1233 else
1234 return -ERESTARTSYS;
1235 #else
1236 return -EAGAIN;
1237 #endif
1241 * If non-blocking mode is set, or the port is not enabled,
1242 * then make the check up front and then exit.
1244 if ((filp->f_flags & O_NONBLOCK) ||
1245 (tty->flags & (1 << TTY_IO_ERROR))) {
1246 info->flags |= S_NORMAL_ACTIVE;
1247 return 0;
1250 if (tty->termios->c_cflag & CLOCAL)
1251 do_clocal = 1;
1254 * Block waiting for the carrier detect and the line to become
1255 * free (i.e., not in use by the callout). While we are in
1256 * this loop, info->count is dropped by one, so that
1257 * rs_close() knows when to free things. We restore it upon
1258 * exit, either normal or abnormal.
1260 retval = 0;
1261 add_wait_queue(&info->open_wait, &wait);
1263 info->count--;
1264 info->blocked_open++;
1265 while (1) {
1266 cli();
1267 m68k_rtsdtr(info, 1);
1268 sti();
1269 current->state = TASK_INTERRUPTIBLE;
1270 if (tty_hung_up_p(filp) ||
1271 !(info->flags & S_INITIALIZED)) {
1272 #ifdef SERIAL_DO_RESTART
1273 if (info->flags & S_HUP_NOTIFY)
1274 retval = -EAGAIN;
1275 else
1276 retval = -ERESTARTSYS;
1277 #else
1278 retval = -EAGAIN;
1279 #endif
1280 break;
1282 if (!(info->flags & S_CLOSING) && do_clocal)
1283 break;
1284 if (signal_pending(current)) {
1285 retval = -ERESTARTSYS;
1286 break;
1288 schedule();
1290 current->state = TASK_RUNNING;
1291 remove_wait_queue(&info->open_wait, &wait);
1292 if (!tty_hung_up_p(filp))
1293 info->count++;
1294 info->blocked_open--;
1296 if (retval)
1297 return retval;
1298 info->flags |= S_NORMAL_ACTIVE;
1299 return 0;
1303 * This routine is called whenever a serial port is opened. It
1304 * enables interrupts for a serial port, linking in its S structure into
1305 * the IRQ chain. It also performs the serial-specific
1306 * initialization for the tty structure.
1308 int rs_open(struct tty_struct *tty, struct file * filp)
1310 struct m68k_serial *info;
1311 int retval, line;
1313 line = tty->index;
1315 if (line >= NR_PORTS || line < 0) /* we have exactly one */
1316 return -ENODEV;
1318 info = &m68k_soft[line];
1320 if (serial_paranoia_check(info, tty->name, "rs_open"))
1321 return -ENODEV;
1323 info->count++;
1324 tty->driver_data = info;
1325 info->tty = tty;
1328 * Start up serial port
1330 retval = startup(info);
1331 if (retval)
1332 return retval;
1334 return block_til_ready(tty, filp, info);
1337 /* Finally, routines used to initialize the serial driver. */
1339 static void show_serial_version(void)
1341 printk("MC68328 serial driver version 1.00\n");
1344 #ifdef CONFIG_PM_LEGACY
1345 /* Serial Power management
1346 * The console (currently fixed at line 0) is a special case for power
1347 * management because the kernel is so chatty. The console will be
1348 * explicitly disabled my our power manager as the last minute, so we won't
1349 * mess with it here.
1351 static struct pm_dev *serial_pm[NR_PORTS];
1353 static int serial_pm_callback(struct pm_dev *dev, pm_request_t request, void *data)
1355 struct m68k_serial *info = (struct m68k_serial *)dev->data;
1357 if(info == NULL)
1358 return -1;
1360 /* special case for line 0 - pm restores it */
1361 if(info->line == 0)
1362 return 0;
1364 switch (request) {
1365 case PM_SUSPEND:
1366 shutdown(info);
1367 break;
1369 case PM_RESUME:
1370 startup(info);
1371 break;
1373 return 0;
1376 void shutdown_console(void)
1378 struct m68k_serial *info = &m68k_soft[0];
1380 /* HACK: wait a bit for any pending printk's to be dumped */
1382 int i = 10000;
1383 while(i--);
1386 shutdown(info);
1389 void startup_console(void)
1391 struct m68k_serial *info = &m68k_soft[0];
1392 startup(info);
1394 #endif /* CONFIG_PM_LEGACY */
1397 static struct tty_operations rs_ops = {
1398 .open = rs_open,
1399 .close = rs_close,
1400 .write = rs_write,
1401 .flush_chars = rs_flush_chars,
1402 .write_room = rs_write_room,
1403 .chars_in_buffer = rs_chars_in_buffer,
1404 .flush_buffer = rs_flush_buffer,
1405 .ioctl = rs_ioctl,
1406 .throttle = rs_throttle,
1407 .unthrottle = rs_unthrottle,
1408 .set_termios = rs_set_termios,
1409 .stop = rs_stop,
1410 .start = rs_start,
1411 .hangup = rs_hangup,
1412 .set_ldisc = rs_set_ldisc,
1415 /* rs_init inits the driver */
1416 static int __init
1417 rs68328_init(void)
1419 int flags, i;
1420 struct m68k_serial *info;
1422 serial_driver = alloc_tty_driver(NR_PORTS);
1423 if (!serial_driver)
1424 return -ENOMEM;
1426 show_serial_version();
1428 /* Initialize the tty_driver structure */
1429 /* SPARC: Not all of this is exactly right for us. */
1431 serial_driver->name = "ttyS";
1432 serial_driver->major = TTY_MAJOR;
1433 serial_driver->minor_start = 64;
1434 serial_driver->type = TTY_DRIVER_TYPE_SERIAL;
1435 serial_driver->subtype = SERIAL_TYPE_NORMAL;
1436 serial_driver->init_termios = tty_std_termios;
1437 serial_driver->init_termios.c_cflag =
1438 m68328_console_cbaud | CS8 | CREAD | HUPCL | CLOCAL;
1439 serial_driver->flags = TTY_DRIVER_REAL_RAW;
1440 tty_set_operations(serial_driver, &rs_ops);
1442 if (tty_register_driver(serial_driver)) {
1443 put_tty_driver(serial_driver);
1444 printk(KERN_ERR "Couldn't register serial driver\n");
1445 return -ENOMEM;
1448 save_flags(flags); cli();
1450 for(i=0;i<NR_PORTS;i++) {
1452 info = &m68k_soft[i];
1453 info->magic = SERIAL_MAGIC;
1454 info->port = (int) &uart_addr[i];
1455 info->tty = 0;
1456 info->irq = uart_irqs[i];
1457 info->custom_divisor = 16;
1458 info->close_delay = 50;
1459 info->closing_wait = 3000;
1460 info->x_char = 0;
1461 info->event = 0;
1462 info->count = 0;
1463 info->blocked_open = 0;
1464 INIT_WORK(&info->tqueue, do_softint, info);
1465 INIT_WORK(&info->tqueue_hangup, do_serial_hangup, info);
1466 init_waitqueue_head(&info->open_wait);
1467 init_waitqueue_head(&info->close_wait);
1468 info->line = i;
1469 info->is_cons = 1; /* Means shortcuts work */
1471 printk("%s%d at 0x%08x (irq = %d)", serial_driver->name, info->line,
1472 info->port, info->irq);
1473 printk(" is a builtin MC68328 UART\n");
1475 IRQ_ports[info->irq] = info; /* waste of space */
1477 #ifdef CONFIG_M68VZ328
1478 if (i > 0 )
1479 PJSEL &= 0xCF; /* PSW enable second port output */
1480 #endif
1482 if (request_irq(uart_irqs[i],
1483 rs_interrupt,
1484 IRQ_FLG_STD,
1485 "M68328_UART", NULL))
1486 panic("Unable to attach 68328 serial interrupt\n");
1487 #ifdef CONFIG_PM_LEGACY
1488 serial_pm[i] = pm_register(PM_SYS_DEV, PM_SYS_COM, serial_pm_callback);
1489 if (serial_pm[i])
1490 serial_pm[i]->data = info;
1491 #endif
1493 restore_flags(flags);
1494 return 0;
1497 module_init(rs68328_init);
1501 static void m68328_set_baud(void)
1503 unsigned short ustcnt;
1504 int i;
1506 ustcnt = USTCNT;
1507 USTCNT = ustcnt & ~USTCNT_TXEN;
1509 again:
1510 for (i = 0; i < sizeof(baud_table) / sizeof(baud_table[0]); i++)
1511 if (baud_table[i] == m68328_console_baud)
1512 break;
1513 if (i >= sizeof(baud_table) / sizeof(baud_table[0])) {
1514 m68328_console_baud = 9600;
1515 goto again;
1518 UBAUD = PUT_FIELD(UBAUD_DIVIDE, hw_baud_table[i].divisor) |
1519 PUT_FIELD(UBAUD_PRESCALER, hw_baud_table[i].prescale);
1520 ustcnt &= ~(USTCNT_PARITYEN | USTCNT_ODD_EVEN | USTCNT_STOP | USTCNT_8_7);
1521 ustcnt |= USTCNT_8_7;
1522 ustcnt |= USTCNT_TXEN;
1523 USTCNT = ustcnt;
1524 m68328_console_initted = 1;
1525 return;
1529 int m68328_console_setup(struct console *cp, char *arg)
1531 int i, n = CONSOLE_BAUD_RATE;
1533 if (!cp)
1534 return(-1);
1536 if (arg)
1537 n = simple_strtoul(arg,NULL,0);
1539 for (i = 0; i < BAUD_TABLE_SIZE; i++)
1540 if (baud_table[i] == n)
1541 break;
1542 if (i < BAUD_TABLE_SIZE) {
1543 m68328_console_baud = n;
1544 m68328_console_cbaud = 0;
1545 if (i > 15) {
1546 m68328_console_cbaud |= CBAUDEX;
1547 i -= 15;
1549 m68328_console_cbaud |= i;
1552 m68328_set_baud(); /* make sure baud rate changes */
1553 return(0);
1557 static struct tty_driver *m68328_console_device(struct console *c, int *index)
1559 *index = c->index;
1560 return serial_driver;
1564 void m68328_console_write (struct console *co, const char *str,
1565 unsigned int count)
1567 if (!m68328_console_initted)
1568 m68328_set_baud();
1569 while (count--) {
1570 if (*str == '\n')
1571 rs_put_char('\r');
1572 rs_put_char( *str++ );
1577 static struct console m68328_driver = {
1578 .name = "ttyS",
1579 .write = m68328_console_write,
1580 .device = m68328_console_device,
1581 .setup = m68328_console_setup,
1582 .flags = CON_PRINTBUFFER,
1583 .index = -1,
1587 static int __init m68328_console_init(void)
1589 register_console(&m68328_driver);
1590 return 0;
1593 console_initcall(m68328_console_init);