1 /* $Id: su.c,v 1.55 2002/01/08 16:00:16 davem Exp $
2 * su.c: Small serial driver for keyboard/mouse interface on sparc32/PCI
4 * Copyright (C) 1997 Eddie C. Dost (ecd@skynet.be)
5 * Copyright (C) 1998-1999 Pete Zaitcev (zaitcev@yahoo.com)
7 * This is mainly a variation of 8250.c, credits go to authors mentioned
8 * therein. In fact this driver should be merged into the generic 8250.c
9 * infrastructure perhaps using a 8250_sparc.c module.
11 * Fixed to use tty_get_baud_rate().
12 * Theodore Ts'o <tytso@mit.edu>, 2001-Oct-12
14 * Converted to new 2.5.x UART layer.
15 * David S. Miller (davem@redhat.com), 2002-Jul-29
18 #include <linux/config.h>
19 #include <linux/module.h>
20 #include <linux/kernel.h>
21 #include <linux/sched.h>
22 #include <linux/spinlock.h>
23 #include <linux/errno.h>
24 #include <linux/tty.h>
25 #include <linux/tty_flip.h>
26 #include <linux/major.h>
27 #include <linux/string.h>
28 #include <linux/ptrace.h>
29 #include <linux/ioport.h>
30 #include <linux/circ_buf.h>
31 #include <linux/serial.h>
32 #include <linux/sysrq.h>
33 #include <linux/console.h>
35 #include <linux/serio.h>
37 #include <linux/serial_reg.h>
38 #include <linux/init.h>
39 #include <linux/delay.h>
43 #include <asm/oplib.h>
49 #if defined(CONFIG_SERIAL_SUNSU_CONSOLE) && defined(CONFIG_MAGIC_SYSRQ)
53 #include <linux/serial_core.h>
57 /* We are on a NS PC87303 clocked with 24.0 MHz, which results
58 * in a UART clock of 1.8462 MHz.
60 #define SU_BASE_BAUD (1846200 / 16)
62 enum su_type { SU_PORT_NONE, SU_PORT_MS, SU_PORT_KBD, SU_PORT_PORT };
63 static char *su_typev[] = { "su(???)", "su(mouse)", "su(kbd)", "su(serial)" };
66 * Here we define the default xmit fifo size used for each type of UART.
68 static const struct serial_uart_config uart_config[PORT_MAX_8250+1] = {
73 { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
75 { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH },
76 { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
77 { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO },
79 { "16C950/954", 128, UART_CLEAR_FIFO | UART_USE_FIFO },
80 { "ST16654", 64, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
81 { "XR16850", 128, UART_CLEAR_FIFO | UART_USE_FIFO | UART_STARTECH },
82 { "RSA", 2048, UART_CLEAR_FIFO | UART_USE_FIFO }
85 struct uart_sunsu_port {
86 struct uart_port port;
91 unsigned int lsr_break_flag;
94 /* Probing information. */
96 unsigned int type_probed; /* XXX Stupid */
107 static _INLINE_ unsigned int serial_in(struct uart_sunsu_port *up, int offset)
109 offset <<= up->port.regshift;
111 switch (up->port.iotype) {
113 outb(up->port.hub6 - 1 + offset, up->port.iobase);
114 return inb(up->port.iobase + 1);
117 return readb(up->port.membase + offset);
120 return inb(up->port.iobase + offset);
125 serial_out(struct uart_sunsu_port *up, int offset, int value)
127 #ifndef CONFIG_SPARC64
129 * MrCoffee has weird schematics: IRQ4 & P10(?) pins of SuperIO are
130 * connected with a gate then go to SlavIO. When IRQ4 goes tristated
131 * gate outputs a logical one. Since we use level triggered interrupts
132 * we have lockup and watchdog reset. We cannot mask IRQ because
133 * keyboard shares IRQ with us (Word has it as Bob Smelik's design).
134 * This problem is similar to what Alpha people suffer, see serial.c.
136 if (offset == UART_MCR)
137 value |= UART_MCR_OUT2;
139 offset <<= up->port.regshift;
141 switch (up->port.iotype) {
143 outb(up->port.hub6 - 1 + offset, up->port.iobase);
144 outb(value, up->port.iobase + 1);
148 writeb(value, up->port.membase + offset);
152 outb(value, up->port.iobase + offset);
157 * We used to support using pause I/O for certain machines. We
158 * haven't supported this for a while, but just in case it's badly
159 * needed for certain old 386 machines, I've left these #define's
162 #define serial_inp(up, offset) serial_in(up, offset)
163 #define serial_outp(up, offset, value) serial_out(up, offset, value)
169 static void serial_icr_write(struct uart_sunsu_port *up, int offset, int value)
171 serial_out(up, UART_SCR, offset);
172 serial_out(up, UART_ICR, value);
175 #if 0 /* Unused currently */
176 static unsigned int serial_icr_read(struct uart_sunsu_port *up, int offset)
180 serial_icr_write(up, UART_ACR, up->acr | UART_ACR_ICRRD);
181 serial_out(up, UART_SCR, offset);
182 value = serial_in(up, UART_ICR);
183 serial_icr_write(up, UART_ACR, up->acr);
189 #ifdef CONFIG_SERIAL_8250_RSA
191 * Attempts to turn on the RSA FIFO. Returns zero on failure.
192 * We set the port uart clock rate if we succeed.
194 static int __enable_rsa(struct uart_sunsu_port *up)
199 mode = serial_inp(up, UART_RSA_MSR);
200 result = mode & UART_RSA_MSR_FIFO;
203 serial_outp(up, UART_RSA_MSR, mode | UART_RSA_MSR_FIFO);
204 mode = serial_inp(up, UART_RSA_MSR);
205 result = mode & UART_RSA_MSR_FIFO;
209 up->port.uartclk = SERIAL_RSA_BAUD_BASE * 16;
214 static void enable_rsa(struct uart_sunsu_port *up)
216 if (up->port.type == PORT_RSA) {
217 if (up->port.uartclk != SERIAL_RSA_BAUD_BASE * 16) {
218 spin_lock_irq(&up->port.lock);
220 spin_unlock_irq(&up->port.lock);
222 if (up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16)
223 serial_outp(up, UART_RSA_FRR, 0);
228 * Attempts to turn off the RSA FIFO. Returns zero on failure.
229 * It is unknown why interrupts were disabled in here. However,
230 * the caller is expected to preserve this behaviour by grabbing
231 * the spinlock before calling this function.
233 static void disable_rsa(struct uart_sunsu_port *up)
238 if (up->port.type == PORT_RSA &&
239 up->port.uartclk == SERIAL_RSA_BAUD_BASE * 16) {
240 spin_lock_irq(&up->port.lock);
242 mode = serial_inp(up, UART_RSA_MSR);
243 result = !(mode & UART_RSA_MSR_FIFO);
246 serial_outp(up, UART_RSA_MSR, mode & ~UART_RSA_MSR_FIFO);
247 mode = serial_inp(up, UART_RSA_MSR);
248 result = !(mode & UART_RSA_MSR_FIFO);
252 up->port.uartclk = SERIAL_RSA_BAUD_BASE_LO * 16;
253 spin_unlock_irq(&up->port.lock);
256 #endif /* CONFIG_SERIAL_8250_RSA */
258 static void sunsu_stop_tx(struct uart_port *port, unsigned int tty_stop)
260 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
262 if (up->ier & UART_IER_THRI) {
263 up->ier &= ~UART_IER_THRI;
264 serial_out(up, UART_IER, up->ier);
266 if (up->port.type == PORT_16C950 && tty_stop) {
267 up->acr |= UART_ACR_TXDIS;
268 serial_icr_write(up, UART_ACR, up->acr);
272 static void sunsu_start_tx(struct uart_port *port, unsigned int tty_start)
274 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
276 if (!(up->ier & UART_IER_THRI)) {
277 up->ier |= UART_IER_THRI;
278 serial_out(up, UART_IER, up->ier);
281 * We only do this from uart_start
283 if (tty_start && up->port.type == PORT_16C950) {
284 up->acr &= ~UART_ACR_TXDIS;
285 serial_icr_write(up, UART_ACR, up->acr);
289 static void sunsu_stop_rx(struct uart_port *port)
291 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
294 spin_lock_irqsave(&up->port.lock, flags);
295 up->ier &= ~UART_IER_RLSI;
296 up->port.read_status_mask &= ~UART_LSR_DR;
297 serial_out(up, UART_IER, up->ier);
298 spin_unlock_irqrestore(&up->port.lock, flags);
301 static void sunsu_enable_ms(struct uart_port *port)
303 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
306 spin_lock_irqsave(&up->port.lock, flags);
307 up->ier |= UART_IER_MSI;
308 serial_out(up, UART_IER, up->ier);
309 spin_unlock_irqrestore(&up->port.lock, flags);
312 static _INLINE_ struct tty_struct *
313 receive_chars(struct uart_sunsu_port *up, unsigned char *status, struct pt_regs *regs)
315 struct tty_struct *tty = up->port.info->tty;
318 int saw_console_brk = 0;
321 if (unlikely(tty->flip.count >= TTY_FLIPBUF_SIZE)) {
322 tty->flip.work.func((void *)tty);
323 if (tty->flip.count >= TTY_FLIPBUF_SIZE)
324 return tty; // if TTY_DONT_FLIP is set
326 ch = serial_inp(up, UART_RX);
327 *tty->flip.char_buf_ptr = ch;
328 *tty->flip.flag_buf_ptr = TTY_NORMAL;
329 up->port.icount.rx++;
331 if (unlikely(*status & (UART_LSR_BI | UART_LSR_PE |
332 UART_LSR_FE | UART_LSR_OE))) {
334 * For statistics only
336 if (*status & UART_LSR_BI) {
337 *status &= ~(UART_LSR_FE | UART_LSR_PE);
338 up->port.icount.brk++;
339 if (up->port.cons != NULL &&
340 up->port.line == up->port.cons->index)
343 * We do the SysRQ and SAK checking
344 * here because otherwise the break
345 * may get masked by ignore_status_mask
346 * or read_status_mask.
348 if (uart_handle_break(&up->port))
350 } else if (*status & UART_LSR_PE)
351 up->port.icount.parity++;
352 else if (*status & UART_LSR_FE)
353 up->port.icount.frame++;
354 if (*status & UART_LSR_OE)
355 up->port.icount.overrun++;
358 * Mask off conditions which should be ingored.
360 *status &= up->port.read_status_mask;
362 if (up->port.cons != NULL &&
363 up->port.line == up->port.cons->index) {
364 /* Recover the break flag from console xmit */
365 *status |= up->lsr_break_flag;
366 up->lsr_break_flag = 0;
369 if (*status & UART_LSR_BI) {
370 *tty->flip.flag_buf_ptr = TTY_BREAK;
371 } else if (*status & UART_LSR_PE)
372 *tty->flip.flag_buf_ptr = TTY_PARITY;
373 else if (*status & UART_LSR_FE)
374 *tty->flip.flag_buf_ptr = TTY_FRAME;
376 if (uart_handle_sysrq_char(&up->port, ch, regs))
378 if ((*status & up->port.ignore_status_mask) == 0) {
379 tty->flip.flag_buf_ptr++;
380 tty->flip.char_buf_ptr++;
383 if ((*status & UART_LSR_OE) &&
384 tty->flip.count < TTY_FLIPBUF_SIZE) {
386 * Overrun is special, since it's reported
387 * immediately, and doesn't affect the current
390 *tty->flip.flag_buf_ptr = TTY_OVERRUN;
391 tty->flip.flag_buf_ptr++;
392 tty->flip.char_buf_ptr++;
396 *status = serial_inp(up, UART_LSR);
397 } while ((*status & UART_LSR_DR) && (max_count-- > 0));
405 static _INLINE_ void transmit_chars(struct uart_sunsu_port *up)
407 struct circ_buf *xmit = &up->port.info->xmit;
410 if (up->port.x_char) {
411 serial_outp(up, UART_TX, up->port.x_char);
412 up->port.icount.tx++;
416 if (uart_circ_empty(xmit) || uart_tx_stopped(&up->port)) {
417 sunsu_stop_tx(&up->port, 0);
421 count = up->port.fifosize;
423 serial_out(up, UART_TX, xmit->buf[xmit->tail]);
424 xmit->tail = (xmit->tail + 1) & (UART_XMIT_SIZE - 1);
425 up->port.icount.tx++;
426 if (uart_circ_empty(xmit))
428 } while (--count > 0);
430 if (uart_circ_chars_pending(xmit) < WAKEUP_CHARS)
431 uart_write_wakeup(&up->port);
433 if (uart_circ_empty(xmit))
434 sunsu_stop_tx(&up->port, 0);
437 static _INLINE_ void check_modem_status(struct uart_sunsu_port *up)
441 status = serial_in(up, UART_MSR);
443 if ((status & UART_MSR_ANY_DELTA) == 0)
446 if (status & UART_MSR_TERI)
447 up->port.icount.rng++;
448 if (status & UART_MSR_DDSR)
449 up->port.icount.dsr++;
450 if (status & UART_MSR_DDCD)
451 uart_handle_dcd_change(&up->port, status & UART_MSR_DCD);
452 if (status & UART_MSR_DCTS)
453 uart_handle_cts_change(&up->port, status & UART_MSR_CTS);
455 wake_up_interruptible(&up->port.info->delta_msr_wait);
458 static irqreturn_t sunsu_serial_interrupt(int irq, void *dev_id, struct pt_regs *regs)
460 struct uart_sunsu_port *up = dev_id;
462 unsigned char status;
464 spin_lock_irqsave(&up->port.lock, flags);
467 struct tty_struct *tty;
469 status = serial_inp(up, UART_LSR);
471 if (status & UART_LSR_DR)
472 tty = receive_chars(up, &status, regs);
473 check_modem_status(up);
474 if (status & UART_LSR_THRE)
477 spin_unlock_irqrestore(&up->port.lock, flags);
480 tty_flip_buffer_push(tty);
482 spin_lock_irqsave(&up->port.lock, flags);
484 } while (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT));
486 spin_unlock_irqrestore(&up->port.lock, flags);
491 /* Separate interrupt handling path for keyboard/mouse ports. */
494 sunsu_change_speed(struct uart_port *port, unsigned int cflag,
495 unsigned int iflag, unsigned int quot);
497 static void sunsu_change_mouse_baud(struct uart_sunsu_port *up)
499 unsigned int cur_cflag = up->cflag;
503 up->cflag |= suncore_mouse_baud_cflag_next(cur_cflag, &new_baud);
505 quot = up->port.uartclk / (16 * new_baud);
507 spin_unlock(&up->port.lock);
509 sunsu_change_speed(&up->port, up->cflag, 0, quot);
511 spin_lock(&up->port.lock);
514 static void receive_kbd_ms_chars(struct uart_sunsu_port *up, struct pt_regs *regs, int is_break)
517 unsigned char ch = serial_inp(up, UART_RX);
519 /* Stop-A is handled by drivers/char/keyboard.c now. */
520 if (up->su_type == SU_PORT_KBD) {
522 serio_interrupt(up->serio, ch, 0, regs);
524 } else if (up->su_type == SU_PORT_MS) {
525 int ret = suncore_mouse_baud_detection(ch, is_break);
529 sunsu_change_mouse_baud(up);
536 serio_interrupt(up->serio, ch, 0, regs);
541 } while (serial_in(up, UART_LSR) & UART_LSR_DR);
544 static irqreturn_t sunsu_kbd_ms_interrupt(int irq, void *dev_id, struct pt_regs *regs)
546 struct uart_sunsu_port *up = dev_id;
548 if (!(serial_in(up, UART_IIR) & UART_IIR_NO_INT)) {
549 unsigned char status = serial_inp(up, UART_LSR);
551 if ((status & UART_LSR_DR) || (status & UART_LSR_BI))
552 receive_kbd_ms_chars(up, regs,
553 (status & UART_LSR_BI) != 0);
559 static unsigned int sunsu_tx_empty(struct uart_port *port)
561 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
565 spin_lock_irqsave(&up->port.lock, flags);
566 ret = serial_in(up, UART_LSR) & UART_LSR_TEMT ? TIOCSER_TEMT : 0;
567 spin_unlock_irqrestore(&up->port.lock, flags);
572 static unsigned int sunsu_get_mctrl(struct uart_port *port)
574 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
575 unsigned char status;
578 status = serial_in(up, UART_MSR);
581 if (status & UART_MSR_DCD)
583 if (status & UART_MSR_RI)
585 if (status & UART_MSR_DSR)
587 if (status & UART_MSR_CTS)
592 static void sunsu_set_mctrl(struct uart_port *port, unsigned int mctrl)
594 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
595 unsigned char mcr = 0;
597 if (mctrl & TIOCM_RTS)
599 if (mctrl & TIOCM_DTR)
601 if (mctrl & TIOCM_OUT1)
602 mcr |= UART_MCR_OUT1;
603 if (mctrl & TIOCM_OUT2)
604 mcr |= UART_MCR_OUT2;
605 if (mctrl & TIOCM_LOOP)
606 mcr |= UART_MCR_LOOP;
608 serial_out(up, UART_MCR, mcr);
611 static void sunsu_break_ctl(struct uart_port *port, int break_state)
613 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
616 spin_lock_irqsave(&up->port.lock, flags);
617 if (break_state == -1)
618 up->lcr |= UART_LCR_SBC;
620 up->lcr &= ~UART_LCR_SBC;
621 serial_out(up, UART_LCR, up->lcr);
622 spin_unlock_irqrestore(&up->port.lock, flags);
625 static int sunsu_startup(struct uart_port *port)
627 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
631 if (up->port.type == PORT_16C950) {
632 /* Wake up and initialize UART */
634 serial_outp(up, UART_LCR, 0xBF);
635 serial_outp(up, UART_EFR, UART_EFR_ECB);
636 serial_outp(up, UART_IER, 0);
637 serial_outp(up, UART_LCR, 0);
638 serial_icr_write(up, UART_CSR, 0); /* Reset the UART */
639 serial_outp(up, UART_LCR, 0xBF);
640 serial_outp(up, UART_EFR, UART_EFR_ECB);
641 serial_outp(up, UART_LCR, 0);
644 #ifdef CONFIG_SERIAL_8250_RSA
646 * If this is an RSA port, see if we can kick it up to the
647 * higher speed clock.
653 * Clear the FIFO buffers and disable them.
654 * (they will be reeanbled in set_termios())
656 if (uart_config[up->port.type].flags & UART_CLEAR_FIFO) {
657 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
658 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO |
659 UART_FCR_CLEAR_RCVR | UART_FCR_CLEAR_XMIT);
660 serial_outp(up, UART_FCR, 0);
664 * Clear the interrupt registers.
666 (void) serial_inp(up, UART_LSR);
667 (void) serial_inp(up, UART_RX);
668 (void) serial_inp(up, UART_IIR);
669 (void) serial_inp(up, UART_MSR);
672 * At this point, there's no way the LSR could still be 0xff;
673 * if it is, then bail out, because there's likely no UART
676 if (!(up->port.flags & ASYNC_BUGGY_UART) &&
677 (serial_inp(up, UART_LSR) == 0xff)) {
678 printk("ttyS%d: LSR safety check engaged!\n", up->port.line);
682 if (up->su_type != SU_PORT_PORT) {
683 retval = request_irq(up->port.irq, sunsu_kbd_ms_interrupt,
684 SA_SHIRQ, su_typev[up->su_type], up);
686 retval = request_irq(up->port.irq, sunsu_serial_interrupt,
687 SA_SHIRQ, su_typev[up->su_type], up);
690 printk("su: Cannot register IRQ %d\n", up->port.irq);
695 * Now, initialize the UART
697 serial_outp(up, UART_LCR, UART_LCR_WLEN8);
699 spin_lock_irqsave(&up->port.lock, flags);
701 up->port.mctrl |= TIOCM_OUT2;
703 sunsu_set_mctrl(&up->port, up->port.mctrl);
704 spin_unlock_irqrestore(&up->port.lock, flags);
707 * Finally, enable interrupts. Note: Modem status interrupts
708 * are set via set_termios(), which will be occurring imminently
709 * anyway, so we don't enable them here.
711 up->ier = UART_IER_RLSI | UART_IER_RDI;
712 serial_outp(up, UART_IER, up->ier);
714 if (up->port.flags & ASYNC_FOURPORT) {
717 * Enable interrupts on the AST Fourport board
719 icp = (up->port.iobase & 0xfe0) | 0x01f;
725 * And clear the interrupt registers again for luck.
727 (void) serial_inp(up, UART_LSR);
728 (void) serial_inp(up, UART_RX);
729 (void) serial_inp(up, UART_IIR);
730 (void) serial_inp(up, UART_MSR);
735 static void sunsu_shutdown(struct uart_port *port)
737 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
741 * Disable interrupts from this port
744 serial_outp(up, UART_IER, 0);
746 spin_lock_irqsave(&up->port.lock, flags);
747 if (up->port.flags & ASYNC_FOURPORT) {
748 /* reset interrupts on the AST Fourport board */
749 inb((up->port.iobase & 0xfe0) | 0x1f);
750 up->port.mctrl |= TIOCM_OUT1;
752 up->port.mctrl &= ~TIOCM_OUT2;
754 sunsu_set_mctrl(&up->port, up->port.mctrl);
755 spin_unlock_irqrestore(&up->port.lock, flags);
758 * Disable break condition and FIFOs
760 serial_out(up, UART_LCR, serial_inp(up, UART_LCR) & ~UART_LCR_SBC);
761 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO |
762 UART_FCR_CLEAR_RCVR |
763 UART_FCR_CLEAR_XMIT);
764 serial_outp(up, UART_FCR, 0);
766 #ifdef CONFIG_SERIAL_8250_RSA
768 * Reset the RSA board back to 115kbps compat mode.
774 * Read data port to reset things.
776 (void) serial_in(up, UART_RX);
778 free_irq(up->port.irq, up);
782 sunsu_change_speed(struct uart_port *port, unsigned int cflag,
783 unsigned int iflag, unsigned int quot)
785 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
786 unsigned char cval, fcr = 0;
789 switch (cflag & CSIZE) {
808 cval |= UART_LCR_PARITY;
809 if (!(cflag & PARODD))
810 cval |= UART_LCR_EPAR;
813 cval |= UART_LCR_SPAR;
817 * Work around a bug in the Oxford Semiconductor 952 rev B
818 * chip which causes it to seriously miscalculate baud rates
821 if ((quot & 0xff) == 0 && up->port.type == PORT_16C950 &&
825 if (uart_config[up->port.type].flags & UART_USE_FIFO) {
826 if ((up->port.uartclk / quot) < (2400 * 16))
827 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_1;
828 #ifdef CONFIG_SERIAL_8250_RSA
829 else if (up->port.type == PORT_RSA)
830 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_14;
833 fcr = UART_FCR_ENABLE_FIFO | UART_FCR_TRIGGER_8;
835 if (up->port.type == PORT_16750)
836 fcr |= UART_FCR7_64BYTE;
839 * Ok, we're now changing the port state. Do it with
840 * interrupts disabled.
842 spin_lock_irqsave(&up->port.lock, flags);
845 * Update the per-port timeout.
847 uart_update_timeout(port, cflag, (port->uartclk / (16 * quot)));
849 up->port.read_status_mask = UART_LSR_OE | UART_LSR_THRE | UART_LSR_DR;
851 up->port.read_status_mask |= UART_LSR_FE | UART_LSR_PE;
852 if (iflag & (BRKINT | PARMRK))
853 up->port.read_status_mask |= UART_LSR_BI;
856 * Characteres to ignore
858 up->port.ignore_status_mask = 0;
860 up->port.ignore_status_mask |= UART_LSR_PE | UART_LSR_FE;
861 if (iflag & IGNBRK) {
862 up->port.ignore_status_mask |= UART_LSR_BI;
864 * If we're ignoring parity and break indicators,
865 * ignore overruns too (for real raw support).
868 up->port.ignore_status_mask |= UART_LSR_OE;
872 * ignore all characters if CREAD is not set
874 if ((cflag & CREAD) == 0)
875 up->port.ignore_status_mask |= UART_LSR_DR;
878 * CTS flow control flag and modem status interrupts
880 up->ier &= ~UART_IER_MSI;
881 if (UART_ENABLE_MS(&up->port, cflag))
882 up->ier |= UART_IER_MSI;
884 serial_out(up, UART_IER, up->ier);
886 if (uart_config[up->port.type].flags & UART_STARTECH) {
887 serial_outp(up, UART_LCR, 0xBF);
888 serial_outp(up, UART_EFR, cflag & CRTSCTS ? UART_EFR_CTS :0);
890 serial_outp(up, UART_LCR, cval | UART_LCR_DLAB);/* set DLAB */
891 serial_outp(up, UART_DLL, quot & 0xff); /* LS of divisor */
892 serial_outp(up, UART_DLM, quot >> 8); /* MS of divisor */
893 if (up->port.type == PORT_16750)
894 serial_outp(up, UART_FCR, fcr); /* set fcr */
895 serial_outp(up, UART_LCR, cval); /* reset DLAB */
896 up->lcr = cval; /* Save LCR */
897 if (up->port.type != PORT_16750) {
898 if (fcr & UART_FCR_ENABLE_FIFO) {
899 /* emulated UARTs (Lucent Venus 167x) need two steps */
900 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
902 serial_outp(up, UART_FCR, fcr); /* set fcr */
907 spin_unlock_irqrestore(&up->port.lock, flags);
911 sunsu_set_termios(struct uart_port *port, struct termios *termios,
914 unsigned int baud, quot;
917 * Ask the core to calculate the divisor for us.
919 baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk/16);
920 quot = uart_get_divisor(port, baud);
922 sunsu_change_speed(port, termios->c_cflag, termios->c_iflag, quot);
925 static void sunsu_release_port(struct uart_port *port)
929 static int sunsu_request_port(struct uart_port *port)
934 static void sunsu_config_port(struct uart_port *port, int flags)
936 struct uart_sunsu_port *up = (struct uart_sunsu_port *) port;
938 if (flags & UART_CONFIG_TYPE) {
940 * We are supposed to call autoconfig here, but this requires
941 * splitting all the OBP probing crap from the UART probing.
942 * We'll do it when we kill sunsu.c altogether.
944 port->type = up->type_probed; /* XXX */
949 sunsu_verify_port(struct uart_port *port, struct serial_struct *ser)
955 sunsu_type(struct uart_port *port)
957 int type = port->type;
959 if (type >= ARRAY_SIZE(uart_config))
961 return uart_config[type].name;
964 static struct uart_ops sunsu_pops = {
965 .tx_empty = sunsu_tx_empty,
966 .set_mctrl = sunsu_set_mctrl,
967 .get_mctrl = sunsu_get_mctrl,
968 .stop_tx = sunsu_stop_tx,
969 .start_tx = sunsu_start_tx,
970 .stop_rx = sunsu_stop_rx,
971 .enable_ms = sunsu_enable_ms,
972 .break_ctl = sunsu_break_ctl,
973 .startup = sunsu_startup,
974 .shutdown = sunsu_shutdown,
975 .set_termios = sunsu_set_termios,
977 .release_port = sunsu_release_port,
978 .request_port = sunsu_request_port,
979 .config_port = sunsu_config_port,
980 .verify_port = sunsu_verify_port,
985 static struct uart_sunsu_port sunsu_ports[UART_NR];
989 static DEFINE_SPINLOCK(sunsu_serio_lock);
991 static int sunsu_serio_write(struct serio *serio, unsigned char ch)
993 struct uart_sunsu_port *up = serio->port_data;
997 spin_lock_irqsave(&sunsu_serio_lock, flags);
1000 lsr = serial_in(up, UART_LSR);
1001 } while (!(lsr & UART_LSR_THRE));
1003 /* Send the character out. */
1004 serial_out(up, UART_TX, ch);
1006 spin_unlock_irqrestore(&sunsu_serio_lock, flags);
1011 static int sunsu_serio_open(struct serio *serio)
1013 struct uart_sunsu_port *up = serio->port_data;
1014 unsigned long flags;
1017 spin_lock_irqsave(&sunsu_serio_lock, flags);
1018 if (!up->serio_open) {
1023 spin_unlock_irqrestore(&sunsu_serio_lock, flags);
1028 static void sunsu_serio_close(struct serio *serio)
1030 struct uart_sunsu_port *up = serio->port_data;
1031 unsigned long flags;
1033 spin_lock_irqsave(&sunsu_serio_lock, flags);
1035 spin_unlock_irqrestore(&sunsu_serio_lock, flags);
1038 #endif /* CONFIG_SERIO */
1040 static void sunsu_autoconfig(struct uart_sunsu_port *up)
1042 unsigned char status1, status2, scratch, scratch2, scratch3;
1043 unsigned char save_lcr, save_mcr;
1044 struct linux_ebus_device *dev = NULL;
1045 struct linux_ebus *ebus;
1046 #ifdef CONFIG_SPARC64
1047 struct sparc_isa_bridge *isa_br;
1048 struct sparc_isa_device *isa_dev;
1050 #ifndef CONFIG_SPARC64
1051 struct linux_prom_registers reg0;
1053 unsigned long flags;
1055 if (!up->port_node || !up->su_type)
1058 up->type_probed = PORT_UNKNOWN;
1059 up->port.iotype = SERIAL_IO_MEM;
1062 * First we look for Ebus-bases su's
1064 for_each_ebus(ebus) {
1065 for_each_ebusdev(dev, ebus) {
1066 if (dev->prom_node == up->port_node) {
1068 * The EBus is broken on sparc; it delivers
1069 * virtual addresses in resources. Oh well...
1070 * This is correct on sparc64, though.
1072 up->port.membase = (char *) dev->resource[0].start;
1074 * This is correct on both architectures.
1076 up->port.mapbase = dev->resource[0].start;
1077 up->port.irq = dev->irqs[0];
1083 #ifdef CONFIG_SPARC64
1084 for_each_isa(isa_br) {
1085 for_each_isadev(isa_dev, isa_br) {
1086 if (isa_dev->prom_node == up->port_node) {
1087 /* Same on sparc64. Cool architecure... */
1088 up->port.membase = (char *) isa_dev->resource.start;
1089 up->port.mapbase = isa_dev->resource.start;
1090 up->port.irq = isa_dev->irq;
1097 #ifdef CONFIG_SPARC64
1099 * Not on Ebus, bailing.
1104 * Not on Ebus, must be OBIO.
1106 if (prom_getproperty(up->port_node, "reg",
1107 (char *)®0, sizeof(reg0)) == -1) {
1108 prom_printf("sunsu: no \"reg\" property\n");
1111 prom_apply_obio_ranges(®0, 1);
1112 if (reg0.which_io != 0) { /* Just in case... */
1113 prom_printf("sunsu: bus number nonzero: 0x%x:%x\n",
1114 reg0.which_io, reg0.phys_addr);
1117 up->port.mapbase = reg0.phys_addr;
1118 if ((up->port.membase = ioremap(reg0.phys_addr, reg0.reg_size)) == 0) {
1119 prom_printf("sunsu: Cannot map registers.\n");
1124 * 0x20 is sun4m thing, Dave Redman heritage.
1125 * See arch/sparc/kernel/irq.c.
1127 #define IRQ_4M(n) ((n)|0x20)
1130 * There is no intr property on MrCoffee, so hardwire it.
1132 up->port.irq = IRQ_4M(13);
1137 spin_lock_irqsave(&up->port.lock, flags);
1139 if (!(up->port.flags & ASYNC_BUGGY_UART)) {
1141 * Do a simple existence test first; if we fail this, there's
1142 * no point trying anything else.
1144 * 0x80 is used as a nonsense port to prevent against false
1145 * positives due to ISA bus float. The assumption is that
1146 * 0x80 is a non-existent port; which should be safe since
1147 * include/asm/io.h also makes this assumption.
1149 scratch = serial_inp(up, UART_IER);
1150 serial_outp(up, UART_IER, 0);
1154 scratch2 = serial_inp(up, UART_IER);
1155 serial_outp(up, UART_IER, 0x0f);
1159 scratch3 = serial_inp(up, UART_IER);
1160 serial_outp(up, UART_IER, scratch);
1161 if (scratch2 != 0 || scratch3 != 0x0F)
1162 goto out; /* We failed; there's nothing here */
1165 save_mcr = serial_in(up, UART_MCR);
1166 save_lcr = serial_in(up, UART_LCR);
1169 * Check to see if a UART is really there. Certain broken
1170 * internal modems based on the Rockwell chipset fail this
1171 * test, because they apparently don't implement the loopback
1172 * test mode. So this test is skipped on the COM 1 through
1173 * COM 4 ports. This *should* be safe, since no board
1174 * manufacturer would be stupid enough to design a board
1175 * that conflicts with COM 1-4 --- we hope!
1177 if (!(up->port.flags & ASYNC_SKIP_TEST)) {
1178 serial_outp(up, UART_MCR, UART_MCR_LOOP | 0x0A);
1179 status1 = serial_inp(up, UART_MSR) & 0xF0;
1180 serial_outp(up, UART_MCR, save_mcr);
1181 if (status1 != 0x90)
1182 goto out; /* We failed loopback test */
1184 serial_outp(up, UART_LCR, 0xBF); /* set up for StarTech test */
1185 serial_outp(up, UART_EFR, 0); /* EFR is the same as FCR */
1186 serial_outp(up, UART_LCR, 0);
1187 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
1188 scratch = serial_in(up, UART_IIR) >> 6;
1191 up->port.type = PORT_16450;
1194 up->port.type = PORT_UNKNOWN;
1197 up->port.type = PORT_16550;
1200 up->port.type = PORT_16550A;
1203 if (up->port.type == PORT_16550A) {
1204 /* Check for Startech UART's */
1205 serial_outp(up, UART_LCR, UART_LCR_DLAB);
1206 if (serial_in(up, UART_EFR) == 0) {
1207 up->port.type = PORT_16650;
1209 serial_outp(up, UART_LCR, 0xBF);
1210 if (serial_in(up, UART_EFR) == 0)
1211 up->port.type = PORT_16650V2;
1214 if (up->port.type == PORT_16550A) {
1215 /* Check for TI 16750 */
1216 serial_outp(up, UART_LCR, save_lcr | UART_LCR_DLAB);
1217 serial_outp(up, UART_FCR,
1218 UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
1219 scratch = serial_in(up, UART_IIR) >> 5;
1222 * If this is a 16750, and not a cheap UART
1223 * clone, then it should only go into 64 byte
1224 * mode if the UART_FCR7_64BYTE bit was set
1225 * while UART_LCR_DLAB was latched.
1227 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
1228 serial_outp(up, UART_LCR, 0);
1229 serial_outp(up, UART_FCR,
1230 UART_FCR_ENABLE_FIFO | UART_FCR7_64BYTE);
1231 scratch = serial_in(up, UART_IIR) >> 5;
1233 up->port.type = PORT_16750;
1235 serial_outp(up, UART_FCR, UART_FCR_ENABLE_FIFO);
1237 serial_outp(up, UART_LCR, save_lcr);
1238 if (up->port.type == PORT_16450) {
1239 scratch = serial_in(up, UART_SCR);
1240 serial_outp(up, UART_SCR, 0xa5);
1241 status1 = serial_in(up, UART_SCR);
1242 serial_outp(up, UART_SCR, 0x5a);
1243 status2 = serial_in(up, UART_SCR);
1244 serial_outp(up, UART_SCR, scratch);
1246 if ((status1 != 0xa5) || (status2 != 0x5a))
1247 up->port.type = PORT_8250;
1250 up->port.fifosize = uart_config[up->port.type].dfl_xmit_fifo_size;
1252 if (up->port.type == PORT_UNKNOWN)
1254 up->type_probed = up->port.type; /* XXX */
1259 #ifdef CONFIG_SERIAL_8250_RSA
1260 if (up->port.type == PORT_RSA)
1261 serial_outp(up, UART_RSA_FRR, 0);
1263 serial_outp(up, UART_MCR, save_mcr);
1264 serial_outp(up, UART_FCR, (UART_FCR_ENABLE_FIFO |
1265 UART_FCR_CLEAR_RCVR |
1266 UART_FCR_CLEAR_XMIT));
1267 serial_outp(up, UART_FCR, 0);
1268 (void)serial_in(up, UART_RX);
1269 serial_outp(up, UART_IER, 0);
1272 spin_unlock_irqrestore(&up->port.lock, flags);
1275 static struct uart_driver sunsu_reg = {
1276 .owner = THIS_MODULE,
1277 .driver_name = "serial",
1278 .devfs_name = "tts/",
1283 static int __init sunsu_kbd_ms_init(struct uart_sunsu_port *up, int channel)
1287 struct serio *serio;
1290 up->port.line = channel;
1291 up->port.type = PORT_UNKNOWN;
1292 up->port.uartclk = (SU_BASE_BAUD * 16);
1294 if (up->su_type == SU_PORT_KBD) {
1295 up->cflag = B1200 | CS8 | CLOCAL | CREAD;
1298 up->cflag = B4800 | CS8 | CLOCAL | CREAD;
1301 quot = up->port.uartclk / (16 * baud);
1303 sunsu_autoconfig(up);
1304 if (up->port.type == PORT_UNKNOWN)
1307 printk(KERN_INFO "su%d at 0x%p (irq = %s) is a %s\n",
1309 up->port.membase, __irq_itoa(up->port.irq),
1310 sunsu_type(&up->port));
1313 up->serio = serio = kmalloc(sizeof(struct serio), GFP_KERNEL);
1315 memset(serio, 0, sizeof(*serio));
1317 serio->port_data = up;
1319 serio->id.type = SERIO_RS232;
1320 if (up->su_type == SU_PORT_KBD) {
1321 serio->id.proto = SERIO_SUNKBD;
1322 strlcpy(serio->name, "sukbd", sizeof(serio->name));
1324 serio->id.proto = SERIO_SUN;
1325 serio->id.extra = 1;
1326 strlcpy(serio->name, "sums", sizeof(serio->name));
1328 strlcpy(serio->phys, (channel == 0 ? "su/serio0" : "su/serio1"),
1329 sizeof(serio->phys));
1331 serio->write = sunsu_serio_write;
1332 serio->open = sunsu_serio_open;
1333 serio->close = sunsu_serio_close;
1335 serio_register_port(serio);
1337 printk(KERN_WARNING "su%d: not enough memory for serio port\n",
1342 sunsu_change_speed(&up->port, up->cflag, 0, quot);
1344 sunsu_startup(&up->port);
1349 * ------------------------------------------------------------
1350 * Serial console driver
1351 * ------------------------------------------------------------
1354 #ifdef CONFIG_SERIAL_SUNSU_CONSOLE
1356 #define BOTH_EMPTY (UART_LSR_TEMT | UART_LSR_THRE)
1359 * Wait for transmitter & holding register to empty
1361 static __inline__ void wait_for_xmitr(struct uart_sunsu_port *up)
1363 unsigned int status, tmout = 10000;
1365 /* Wait up to 10ms for the character(s) to be sent. */
1367 status = serial_in(up, UART_LSR);
1369 if (status & UART_LSR_BI)
1370 up->lsr_break_flag = UART_LSR_BI;
1375 } while ((status & BOTH_EMPTY) != BOTH_EMPTY);
1377 /* Wait up to 1s for flow control if necessary */
1378 if (up->port.flags & ASYNC_CONS_FLOW) {
1381 ((serial_in(up, UART_MSR) & UART_MSR_CTS) == 0))
1387 * Print a string to the serial port trying not to disturb
1388 * any possible real use of the port...
1390 static void sunsu_console_write(struct console *co, const char *s,
1393 struct uart_sunsu_port *up = &sunsu_ports[co->index];
1398 * First save the UER then disable the interrupts
1400 ier = serial_in(up, UART_IER);
1401 serial_out(up, UART_IER, 0);
1404 * Now, do each character
1406 for (i = 0; i < count; i++, s++) {
1410 * Send the character out.
1411 * If a LF, also do CR...
1413 serial_out(up, UART_TX, *s);
1416 serial_out(up, UART_TX, 13);
1421 * Finally, wait for transmitter to become empty
1422 * and restore the IER
1425 serial_out(up, UART_IER, ier);
1429 * Setup initial baud/bits/parity. We do two things here:
1430 * - construct a cflag setting for the first su_open()
1431 * - initialize the serial port
1432 * Return non-zero if we didn't find a serial port.
1434 static int __init sunsu_console_setup(struct console *co, char *options)
1436 struct uart_port *port;
1442 printk("Console: ttyS%d (SU)\n",
1443 (sunsu_reg.minor - 64) + co->index);
1446 * Check whether an invalid uart number has been specified, and
1447 * if so, search for the first available port that does have
1450 if (co->index >= UART_NR)
1452 port = &sunsu_ports[co->index].port;
1457 spin_lock_init(&port->lock);
1460 uart_parse_options(options, &baud, &parity, &bits, &flow);
1462 return uart_set_options(port, co, baud, parity, bits, flow);
1465 static struct console sunsu_cons = {
1467 .write = sunsu_console_write,
1468 .device = uart_console_device,
1469 .setup = sunsu_console_setup,
1470 .flags = CON_PRINTBUFFER,
1474 #define SUNSU_CONSOLE (&sunsu_cons)
1480 static int __init sunsu_serial_console_init(void)
1484 if (con_is_present())
1487 for (i = 0; i < UART_NR; i++) {
1488 int this_minor = sunsu_reg.minor + i;
1490 if ((this_minor - 64) == (serial_console - 1))
1495 if (sunsu_ports[i].port_node == 0)
1498 sunsu_cons.index = i;
1499 register_console(&sunsu_cons);
1503 #define SUNSU_CONSOLE (NULL)
1504 #define sunsu_serial_console_init() do { } while (0)
1507 static int __init sunsu_serial_init(void)
1509 int instance, ret, i;
1511 /* How many instances do we need? */
1513 for (i = 0; i < UART_NR; i++) {
1514 struct uart_sunsu_port *up = &sunsu_ports[i];
1516 if (up->su_type == SU_PORT_MS ||
1517 up->su_type == SU_PORT_KBD)
1520 up->port.flags |= ASYNC_BOOT_AUTOCONF;
1521 up->port.type = PORT_UNKNOWN;
1522 up->port.uartclk = (SU_BASE_BAUD * 16);
1524 sunsu_autoconfig(up);
1525 if (up->port.type == PORT_UNKNOWN)
1528 up->port.line = instance++;
1529 up->port.ops = &sunsu_pops;
1532 sunsu_reg.minor = sunserial_current_minor;
1533 sunserial_current_minor += instance;
1535 sunsu_reg.nr = instance;
1536 sunsu_reg.cons = SUNSU_CONSOLE;
1538 ret = uart_register_driver(&sunsu_reg);
1542 sunsu_serial_console_init();
1543 for (i = 0; i < UART_NR; i++) {
1544 struct uart_sunsu_port *up = &sunsu_ports[i];
1546 /* Do not register Keyboard/Mouse lines with UART
1549 if (up->su_type == SU_PORT_MS ||
1550 up->su_type == SU_PORT_KBD)
1553 if (up->port.type == PORT_UNKNOWN)
1556 uart_add_one_port(&sunsu_reg, &up->port);
1562 static int su_node_ok(int node, char *name, int namelen)
1564 if (strncmp(name, "su", namelen) == 0 ||
1565 strncmp(name, "su_pnp", namelen) == 0)
1568 if (strncmp(name, "serial", namelen) == 0) {
1572 /* Is it _really_ a 'su' device? */
1573 clen = prom_getproperty(node, "compatible", compat, sizeof(compat));
1575 if (strncmp(compat, "sab82532", 8) == 0) {
1576 /* Nope, Siemens serial, not for us. */
1586 #define SU_PROPSIZE 128
1589 * Scan status structure.
1590 * "prop" is a local variable but it eats stack to keep it in each
1591 * stack frame of a recursive procedure.
1593 struct su_probe_scan {
1594 int msnode, kbnode; /* PROM nodes for mouse and keyboard */
1595 int msx, kbx; /* minors for mouse and keyboard */
1596 int devices; /* scan index */
1597 char prop[SU_PROPSIZE];
1601 * We have several platforms which present 'su' in different parts
1602 * of the device tree. 'su' may be found under obio, ebus, isa and pci.
1603 * We walk over the tree and find them wherever PROM hides them.
1605 static void __init su_probe_any(struct su_probe_scan *t, int sunode)
1607 struct uart_sunsu_port *up;
1610 if (t->devices >= UART_NR)
1613 for (; sunode != 0; sunode = prom_getsibling(sunode)) {
1614 len = prom_getproperty(sunode, "name", t->prop, SU_PROPSIZE);
1616 continue; /* Broken PROM node */
1618 if (su_node_ok(sunode, t->prop, len)) {
1619 up = &sunsu_ports[t->devices];
1620 if (t->kbnode != 0 && sunode == t->kbnode) {
1621 t->kbx = t->devices;
1622 up->su_type = SU_PORT_KBD;
1623 } else if (t->msnode != 0 && sunode == t->msnode) {
1624 t->msx = t->devices;
1625 up->su_type = SU_PORT_MS;
1627 #ifdef CONFIG_SPARC64
1629 * Do not attempt to use the truncated
1630 * keyboard/mouse ports as serial ports
1631 * on Ultras with PC keyboard attached.
1633 if (prom_getbool(sunode, "mouse"))
1635 if (prom_getbool(sunode, "keyboard"))
1638 up->su_type = SU_PORT_PORT;
1640 up->port_node = sunode;
1643 su_probe_any(t, prom_getchild(sunode));
1648 static int __init sunsu_probe(void)
1652 struct su_probe_scan scan;
1655 * First, we scan the tree.
1664 * Get the nodes for keyboard and mouse from 'aliases'...
1666 node = prom_getchild(prom_root_node);
1667 node = prom_searchsiblings(node, "aliases");
1669 len = prom_getproperty(node, "keyboard", scan.prop, SU_PROPSIZE);
1672 scan.kbnode = prom_finddevice(scan.prop);
1675 len = prom_getproperty(node, "mouse", scan.prop, SU_PROPSIZE);
1678 scan.msnode = prom_finddevice(scan.prop);
1682 su_probe_any(&scan, prom_getchild(prom_root_node));
1685 * Second, we process the special case of keyboard and mouse.
1687 * Currently if we got keyboard and mouse hooked to "su" ports
1688 * we do not use any possible remaining "su" as a serial port.
1689 * Thus, we ignore values of .msx and .kbx, then compact ports.
1691 if (scan.msx != -1 && scan.kbx != -1) {
1692 sunsu_ports[0].su_type = SU_PORT_MS;
1693 sunsu_ports[0].port_node = scan.msnode;
1694 sunsu_kbd_ms_init(&sunsu_ports[0], 0);
1696 sunsu_ports[1].su_type = SU_PORT_KBD;
1697 sunsu_ports[1].port_node = scan.kbnode;
1698 sunsu_kbd_ms_init(&sunsu_ports[1], 1);
1703 if (scan.msx != -1 || scan.kbx != -1) {
1704 printk("sunsu_probe: cannot match keyboard and mouse, confused\n");
1708 if (scan.devices == 0)
1712 * Console must be initiated after the generic initialization.
1714 sunsu_serial_init();
1719 static void __exit sunsu_exit(void)
1724 for (i = 0; i < UART_NR; i++) {
1725 struct uart_sunsu_port *up = &sunsu_ports[i];
1727 if (up->su_type == SU_PORT_MS ||
1728 up->su_type == SU_PORT_KBD) {
1731 serio_unregister_port(up->serio);
1735 } else if (up->port.type != PORT_UNKNOWN) {
1736 uart_remove_one_port(&sunsu_reg, &up->port);
1742 uart_unregister_driver(&sunsu_reg);
1745 module_init(sunsu_probe);
1746 module_exit(sunsu_exit);