2 * Simulated Serial Driver (fake serial)
4 * This driver is mostly used for bringup purposes and will go away.
5 * It has a strong dependency on the system console. All outputs
6 * are rerouted to the same facility as the one used by printk which, in our
7 * case means sys_sim.c console (goes via the simulator). The code hereafter
8 * is completely leveraged from the serial.c driver.
10 * Copyright (C) 1999-2000, 2002-2003 Hewlett-Packard Co
11 * Stephane Eranian <eranian@hpl.hp.com>
12 * David Mosberger-Tang <davidm@hpl.hp.com>
14 * 02/04/00 D. Mosberger Merged in serial.c bug fixes in rs_close().
15 * 02/25/00 D. Mosberger Synced up with 2.3.99pre-5 version of serial.c.
16 * 07/30/02 D. Mosberger Replace sti()/cli() with explicit spinlocks & local irq masking
19 #include <linux/config.h>
20 #include <linux/init.h>
21 #include <linux/errno.h>
22 #include <linux/sched.h>
23 #include <linux/tty.h>
24 #include <linux/tty_flip.h>
25 #include <linux/major.h>
26 #include <linux/fcntl.h>
28 #include <linux/slab.h>
29 #include <linux/console.h>
30 #include <linux/module.h>
31 #include <linux/serial.h>
32 #include <linux/serialP.h>
35 #include <asm/hw_irq.h>
36 #include <asm/uaccess.h>
39 # include <linux/kdb.h>
42 #undef SIMSERIAL_DEBUG /* define this to get some debug information */
44 #define KEYBOARD_INTR 3 /* must match with simulator! */
46 #define NR_PORTS 1 /* only one port for now */
47 #define SERIAL_INLINE 1
50 #define _INLINE_ inline
54 #define MIN(a,b) ((a) < (b) ? (a) : (b))
57 #define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? SA_SHIRQ : SA_INTERRUPT)
59 #define SSC_GETCHAR 21
61 extern long ia64_ssc (long, long, long, long, int);
62 extern void ia64_ssc_connect_irq (long intr, long irq);
64 static char *serial_name = "SimSerial driver";
65 static char *serial_version = "0.6";
68 * This has been extracted from asm/serial.h. We need one eventually but
69 * I don't know exactly what we're going to put in it so just fake one
72 #define BASE_BAUD ( 1843200 / 16 )
74 #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
77 * Most of the values here are meaningless to this particular driver.
78 * However some values must be preserved for the code (leveraged from serial.c
81 * type must not be UNKNOWN
82 * So I picked arbitrary (guess from where?) values instead
84 static struct serial_state rs_table[NR_PORTS]={
85 /* UART CLK PORT IRQ FLAGS */
86 { 0, BASE_BAUD, 0x3F8, 0, STD_COM_FLAGS,0,PORT_16550 } /* ttyS0 */
90 * Just for the fun of it !
92 static struct serial_uart_config uart_config[] = {
97 { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
99 { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH },
100 { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO |
102 { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO},
106 struct tty_driver *hp_simserial_driver;
108 static struct async_struct *IRQ_ports[NR_IRQS];
110 static struct console *console;
112 static unsigned char *tmp_buf;
113 static DECLARE_MUTEX(tmp_buf_sem);
115 extern struct console *console_drivers; /* from kernel/printk.c */
118 * ------------------------------------------------------------
119 * rs_stop() and rs_start()
121 * This routines are called before setting or resetting tty->stopped.
122 * They enable or disable transmitter interrupts, as necessary.
123 * ------------------------------------------------------------
125 static void rs_stop(struct tty_struct *tty)
127 #ifdef SIMSERIAL_DEBUG
128 printk("rs_stop: tty->stopped=%d tty->hw_stopped=%d tty->flow_stopped=%d\n",
129 tty->stopped, tty->hw_stopped, tty->flow_stopped);
134 static void rs_start(struct tty_struct *tty)
137 printk("rs_start: tty->stopped=%d tty->hw_stopped=%d tty->flow_stopped=%d\n",
138 tty->stopped, tty->hw_stopped, tty->flow_stopped);
142 static void receive_chars(struct tty_struct *tty, struct pt_regs *regs)
145 static unsigned char seen_esc = 0;
147 while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) {
148 if ( ch == 27 && seen_esc == 0 ) {
152 if ( seen_esc==1 && ch == 'O' ) {
155 } else if ( seen_esc == 2 ) {
156 if ( ch == 'P' ) show_state(); /* F1 key */
159 kdb(KDB_REASON_KEYBOARD, 0, (kdb_eframe_t) regs);
167 if (tty->flip.count >= TTY_FLIPBUF_SIZE) break;
169 *tty->flip.char_buf_ptr = ch;
171 *tty->flip.flag_buf_ptr = 0;
173 tty->flip.flag_buf_ptr++;
174 tty->flip.char_buf_ptr++;
177 tty_flip_buffer_push(tty);
181 * This is the serial driver's interrupt routine for a single port
183 static irqreturn_t rs_interrupt_single(int irq, void *dev_id, struct pt_regs * regs)
185 struct async_struct * info;
188 * I don't know exactly why they don't use the dev_id opaque data
189 * pointer instead of this extra lookup table
191 info = IRQ_ports[irq];
192 if (!info || !info->tty) {
193 printk(KERN_INFO "simrs_interrupt_single: info|tty=0 info=%p problem\n", info);
197 * pretty simple in our case, because we only get interrupts
200 receive_chars(info->tty, regs);
205 * -------------------------------------------------------------------
206 * Here ends the serial interrupt routines.
207 * -------------------------------------------------------------------
212 * not really used in our situation so keep them commented out for now
214 static DECLARE_TASK_QUEUE(tq_serial); /* used to be at the top of the file */
215 static void do_serial_bh(void)
217 run_task_queue(&tq_serial);
218 printk(KERN_ERR "do_serial_bh: called\n");
222 static void do_softint(void *private_)
224 printk(KERN_ERR "simserial: do_softint called\n");
227 static void rs_put_char(struct tty_struct *tty, unsigned char ch)
229 struct async_struct *info = (struct async_struct *)tty->driver_data;
232 if (!tty || !info->xmit.buf) return;
234 local_irq_save(flags);
235 if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) {
236 local_irq_restore(flags);
239 info->xmit.buf[info->xmit.head] = ch;
240 info->xmit.head = (info->xmit.head + 1) & (SERIAL_XMIT_SIZE-1);
241 local_irq_restore(flags);
244 static _INLINE_ void transmit_chars(struct async_struct *info, int *intr_done)
250 local_irq_save(flags);
253 char c = info->x_char;
255 console->write(console, &c, 1);
257 info->state->icount.tx++;
263 if (info->xmit.head == info->xmit.tail || info->tty->stopped || info->tty->hw_stopped) {
264 #ifdef SIMSERIAL_DEBUG
265 printk("transmit_chars: head=%d, tail=%d, stopped=%d\n",
266 info->xmit.head, info->xmit.tail, info->tty->stopped);
271 * We removed the loop and try to do it in to chunks. We need
272 * 2 operations maximum because it's a ring buffer.
274 * First from current to tail if possible.
275 * Then from the beginning of the buffer until necessary
278 count = MIN(CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE),
279 SERIAL_XMIT_SIZE - info->xmit.tail);
280 console->write(console, info->xmit.buf+info->xmit.tail, count);
282 info->xmit.tail = (info->xmit.tail+count) & (SERIAL_XMIT_SIZE-1);
285 * We have more at the beginning of the buffer
287 count = CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
289 console->write(console, info->xmit.buf, count);
290 info->xmit.tail += count;
293 local_irq_restore(flags);
296 static void rs_flush_chars(struct tty_struct *tty)
298 struct async_struct *info = (struct async_struct *)tty->driver_data;
300 if (info->xmit.head == info->xmit.tail || tty->stopped || tty->hw_stopped ||
304 transmit_chars(info, NULL);
308 static int rs_write(struct tty_struct * tty, int from_user,
309 const unsigned char *buf, int count)
312 struct async_struct *info = (struct async_struct *)tty->driver_data;
315 if (!tty || !info->xmit.buf || !tmp_buf) return 0;
321 c = CIRC_SPACE_TO_END(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
327 c -= copy_from_user(tmp_buf, buf, c);
334 local_irq_save(flags);
336 c1 = CIRC_SPACE_TO_END(info->xmit.head, info->xmit.tail,
340 memcpy(info->xmit.buf + info->xmit.head, tmp_buf, c);
341 info->xmit.head = ((info->xmit.head + c) &
342 (SERIAL_XMIT_SIZE-1));
344 local_irq_restore(flags);
352 local_irq_save(flags);
354 c = CIRC_SPACE_TO_END(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
360 memcpy(info->xmit.buf + info->xmit.head, buf, c);
361 info->xmit.head = ((info->xmit.head + c) &
362 (SERIAL_XMIT_SIZE-1));
367 local_irq_restore(flags);
370 * Hey, we transmit directly from here in our case
372 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE)
373 && !tty->stopped && !tty->hw_stopped) {
374 transmit_chars(info, NULL);
379 static int rs_write_room(struct tty_struct *tty)
381 struct async_struct *info = (struct async_struct *)tty->driver_data;
383 return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
386 static int rs_chars_in_buffer(struct tty_struct *tty)
388 struct async_struct *info = (struct async_struct *)tty->driver_data;
390 return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
393 static void rs_flush_buffer(struct tty_struct *tty)
395 struct async_struct *info = (struct async_struct *)tty->driver_data;
398 local_irq_save(flags);
399 info->xmit.head = info->xmit.tail = 0;
400 local_irq_restore(flags);
402 wake_up_interruptible(&tty->write_wait);
404 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
405 tty->ldisc.write_wakeup)
406 (tty->ldisc.write_wakeup)(tty);
410 * This function is used to send a high-priority XON/XOFF character to
413 static void rs_send_xchar(struct tty_struct *tty, char ch)
415 struct async_struct *info = (struct async_struct *)tty->driver_data;
420 * I guess we could call console->write() directly but
421 * let's do that for now.
423 transmit_chars(info, NULL);
428 * ------------------------------------------------------------
431 * This routine is called by the upper-layer tty layer to signal that
432 * incoming characters should be throttled.
433 * ------------------------------------------------------------
435 static void rs_throttle(struct tty_struct * tty)
437 if (I_IXOFF(tty)) rs_send_xchar(tty, STOP_CHAR(tty));
439 printk(KERN_INFO "simrs_throttle called\n");
442 static void rs_unthrottle(struct tty_struct * tty)
444 struct async_struct *info = (struct async_struct *)tty->driver_data;
450 rs_send_xchar(tty, START_CHAR(tty));
452 printk(KERN_INFO "simrs_unthrottle called\n");
456 * rs_break() --- routine which turns the break handling on or off
458 static void rs_break(struct tty_struct *tty, int break_state)
462 static int rs_ioctl(struct tty_struct *tty, struct file * file,
463 unsigned int cmd, unsigned long arg)
465 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
466 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
467 (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
468 if (tty->flags & (1 << TTY_IO_ERROR))
474 printk(KERN_INFO "rs_ioctl: TIOCMGET called\n");
479 printk(KERN_INFO "rs_ioctl: TIOCMBIS/BIC/SET called\n");
482 printk(KERN_INFO "simrs_ioctl TIOCGSERIAL called\n");
485 printk(KERN_INFO "simrs_ioctl TIOCSSERIAL called\n");
488 printk(KERN_INFO "rs_ioctl: TIOCSERCONFIG called\n");
491 case TIOCSERGETLSR: /* Get line status register */
492 printk(KERN_INFO "rs_ioctl: TIOCSERGETLSR called\n");
496 printk(KERN_INFO "rs_ioctl: TIOCSERGSTRUCT called\n");
498 if (copy_to_user((struct async_struct *) arg,
499 info, sizeof(struct async_struct)))
505 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
506 * - mask passed in arg for lines of interest
507 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
508 * Caller should use TIOCGICOUNT to see which one it was
511 printk(KERN_INFO "rs_ioctl: TIOCMIWAIT: called\n");
514 * Get counter of input serial line interrupts (DCD,RI,DSR,CTS)
515 * Return: write counters to the user passed counter struct
516 * NB: both 1->0 and 0->1 transitions are counted except for
517 * RI where only 0->1 is counted.
520 printk(KERN_INFO "rs_ioctl: TIOCGICOUNT called\n");
525 /* "setserial -W" is called in Debian boot */
526 printk (KERN_INFO "TIOCSER?WILD ioctl obsolete, ignored.\n");
535 #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
537 static void rs_set_termios(struct tty_struct *tty, struct termios *old_termios)
539 unsigned int cflag = tty->termios->c_cflag;
541 if ( (cflag == old_termios->c_cflag)
542 && ( RELEVANT_IFLAG(tty->termios->c_iflag)
543 == RELEVANT_IFLAG(old_termios->c_iflag)))
547 /* Handle turning off CRTSCTS */
548 if ((old_termios->c_cflag & CRTSCTS) &&
549 !(tty->termios->c_cflag & CRTSCTS)) {
555 * This routine will shutdown a serial port; interrupts are disabled, and
556 * DTR is dropped if the hangup on close termio flag is on.
558 static void shutdown(struct async_struct * info)
561 struct serial_state *state;
564 if (!(info->flags & ASYNC_INITIALIZED)) return;
568 #ifdef SIMSERIAL_DEBUG
569 printk("Shutting down serial port %d (irq %d)....", info->line,
573 local_irq_save(flags);
576 * First unlink the serial port from the IRQ chain...
579 info->next_port->prev_port = info->prev_port;
581 info->prev_port->next_port = info->next_port;
583 IRQ_ports[state->irq] = info->next_port;
586 * Free the IRQ, if necessary
588 if (state->irq && (!IRQ_ports[state->irq] ||
589 !IRQ_ports[state->irq]->next_port)) {
590 if (IRQ_ports[state->irq]) {
591 free_irq(state->irq, NULL);
592 retval = request_irq(state->irq, rs_interrupt_single,
593 IRQ_T(info), "serial", NULL);
596 printk(KERN_ERR "serial shutdown: request_irq: error %d"
597 " Couldn't reacquire IRQ.\n", retval);
599 free_irq(state->irq, NULL);
602 if (info->xmit.buf) {
603 free_page((unsigned long) info->xmit.buf);
607 if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
609 info->flags &= ~ASYNC_INITIALIZED;
611 local_irq_restore(flags);
615 * ------------------------------------------------------------
618 * This routine is called when the serial port gets closed. First, we
619 * wait for the last remaining data to be sent. Then, we unlink its
620 * async structure from the interrupt chain if necessary, and we free
621 * that IRQ if nothing is left in the chain.
622 * ------------------------------------------------------------
624 static void rs_close(struct tty_struct *tty, struct file * filp)
626 struct async_struct * info = (struct async_struct *)tty->driver_data;
627 struct serial_state *state;
634 local_irq_save(flags);
635 if (tty_hung_up_p(filp)) {
636 #ifdef SIMSERIAL_DEBUG
637 printk("rs_close: hung_up\n");
639 local_irq_restore(flags);
642 #ifdef SIMSERIAL_DEBUG
643 printk("rs_close ttys%d, count = %d\n", info->line, state->count);
645 if ((tty->count == 1) && (state->count != 1)) {
647 * Uh, oh. tty->count is 1, which means that the tty
648 * structure will be freed. state->count should always
649 * be one in these conditions. If it's greater than
650 * one, we've got real problems, since it means the
651 * serial port won't be shutdown.
653 printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
654 "state->count is %d\n", state->count);
657 if (--state->count < 0) {
658 printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
659 info->line, state->count);
663 local_irq_restore(flags);
666 info->flags |= ASYNC_CLOSING;
667 local_irq_restore(flags);
670 * Now we wait for the transmit buffer to clear; and we notify
671 * the line discipline to only process XON/XOFF characters.
674 if (tty->driver->flush_buffer) tty->driver->flush_buffer(tty);
675 if (tty->ldisc.flush_buffer) tty->ldisc.flush_buffer(tty);
678 if (info->blocked_open) {
679 if (info->close_delay) {
680 current->state = TASK_INTERRUPTIBLE;
681 schedule_timeout(info->close_delay);
683 wake_up_interruptible(&info->open_wait);
685 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
686 wake_up_interruptible(&info->close_wait);
690 * rs_wait_until_sent() --- wait until the transmitter is empty
692 static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
698 * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
700 static void rs_hangup(struct tty_struct *tty)
702 struct async_struct * info = (struct async_struct *)tty->driver_data;
703 struct serial_state *state = info->state;
705 #ifdef SIMSERIAL_DEBUG
706 printk("rs_hangup: called\n");
711 rs_flush_buffer(tty);
712 if (info->flags & ASYNC_CLOSING)
718 info->flags &= ~ASYNC_NORMAL_ACTIVE;
720 wake_up_interruptible(&info->open_wait);
724 static int get_async_struct(int line, struct async_struct **ret_info)
726 struct async_struct *info;
727 struct serial_state *sstate;
729 sstate = rs_table + line;
732 *ret_info = sstate->info;
735 info = kmalloc(sizeof(struct async_struct), GFP_KERNEL);
740 memset(info, 0, sizeof(struct async_struct));
741 init_waitqueue_head(&info->open_wait);
742 init_waitqueue_head(&info->close_wait);
743 init_waitqueue_head(&info->delta_msr_wait);
744 info->magic = SERIAL_MAGIC;
745 info->port = sstate->port;
746 info->flags = sstate->flags;
747 info->xmit_fifo_size = sstate->xmit_fifo_size;
749 INIT_WORK(&info->work, do_softint, info);
750 info->state = sstate;
753 *ret_info = sstate->info;
756 *ret_info = sstate->info = info;
761 startup(struct async_struct *info)
765 irqreturn_t (*handler)(int, void *, struct pt_regs *);
766 struct serial_state *state= info->state;
769 page = get_zeroed_page(GFP_KERNEL);
773 local_irq_save(flags);
775 if (info->flags & ASYNC_INITIALIZED) {
780 if (!state->port || !state->type) {
781 if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
788 info->xmit.buf = (unsigned char *) page;
790 #ifdef SIMSERIAL_DEBUG
791 printk("startup: ttys%d (irq %d)...", info->line, state->irq);
795 * Allocate the IRQ if necessary
797 if (state->irq && (!IRQ_ports[state->irq] ||
798 !IRQ_ports[state->irq]->next_port)) {
799 if (IRQ_ports[state->irq]) {
803 handler = rs_interrupt_single;
805 retval = request_irq(state->irq, handler, IRQ_T(info), "simserial", NULL);
807 if (capable(CAP_SYS_ADMIN)) {
809 set_bit(TTY_IO_ERROR,
818 * Insert serial port into IRQ chain.
821 info->next_port = IRQ_ports[state->irq];
823 info->next_port->prev_port = info;
824 IRQ_ports[state->irq] = info;
826 if (info->tty) clear_bit(TTY_IO_ERROR, &info->tty->flags);
828 info->xmit.head = info->xmit.tail = 0;
832 * Set up serial timers...
834 timer_table[RS_TIMER].expires = jiffies + 2*HZ/100;
835 timer_active |= 1 << RS_TIMER;
839 * Set up the tty->alt_speed kludge
842 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
843 info->tty->alt_speed = 57600;
844 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
845 info->tty->alt_speed = 115200;
846 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
847 info->tty->alt_speed = 230400;
848 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
849 info->tty->alt_speed = 460800;
852 info->flags |= ASYNC_INITIALIZED;
853 local_irq_restore(flags);
857 local_irq_restore(flags);
863 * This routine is called whenever a serial port is opened. It
864 * enables interrupts for a serial port, linking in its async structure into
865 * the IRQ chain. It also performs the serial-specific
866 * initialization for the tty structure.
868 static int rs_open(struct tty_struct *tty, struct file * filp)
870 struct async_struct *info;
875 if ((line < 0) || (line >= NR_PORTS))
877 retval = get_async_struct(line, &info);
880 tty->driver_data = info;
883 #ifdef SIMSERIAL_DEBUG
884 printk("rs_open %s, count = %d\n", tty->name, info->state->count);
886 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
889 page = get_zeroed_page(GFP_KERNEL);
895 tmp_buf = (unsigned char *) page;
899 * If the port is the middle of closing, bail out now
901 if (tty_hung_up_p(filp) ||
902 (info->flags & ASYNC_CLOSING)) {
903 if (info->flags & ASYNC_CLOSING)
904 interruptible_sleep_on(&info->close_wait);
905 #ifdef SERIAL_DO_RESTART
906 return ((info->flags & ASYNC_HUP_NOTIFY) ?
907 -EAGAIN : -ERESTARTSYS);
914 * Start up serial port
916 retval = startup(info);
922 * figure out which console to use (should be one already)
924 console = console_drivers;
926 if ((console->flags & CON_ENABLED) && console->write) break;
927 console = console->next;
930 #ifdef SIMSERIAL_DEBUG
931 printk("rs_open ttys%d successful\n", info->line);
937 * /proc fs routines....
940 static inline int line_info(char *buf, struct serial_state *state)
942 return sprintf(buf, "%d: uart:%s port:%lX irq:%d\n",
943 state->line, uart_config[state->type].name,
944 state->port, state->irq);
947 static int rs_read_proc(char *page, char **start, off_t off, int count,
948 int *eof, void *data)
953 len += sprintf(page, "simserinfo:1.0 driver:%s\n", serial_version);
954 for (i = 0; i < NR_PORTS && len < 4000; i++) {
955 l = line_info(page + len, &rs_table[i]);
957 if (len+begin > off+count)
959 if (len+begin < off) {
966 if (off >= len+begin)
968 *start = page + (begin-off);
969 return ((count < begin+len-off) ? count : begin+len-off);
973 * ---------------------------------------------------------------------
974 * rs_init() and friends
976 * rs_init() is called at boot-time to initialize the serial driver.
977 * ---------------------------------------------------------------------
981 * This routine prints out the appropriate serial driver version
982 * number, and identifies which options were configured into this
985 static inline void show_serial_version(void)
987 printk(KERN_INFO "%s version %s with", serial_name, serial_version);
988 printk(KERN_INFO " no serial options enabled\n");
991 static struct tty_operations hp_ops = {
995 .put_char = rs_put_char,
996 .flush_chars = rs_flush_chars,
997 .write_room = rs_write_room,
998 .chars_in_buffer = rs_chars_in_buffer,
999 .flush_buffer = rs_flush_buffer,
1001 .throttle = rs_throttle,
1002 .unthrottle = rs_unthrottle,
1003 .send_xchar = rs_send_xchar,
1004 .set_termios = rs_set_termios,
1007 .hangup = rs_hangup,
1008 .break_ctl = rs_break,
1009 .wait_until_sent = rs_wait_until_sent,
1010 .read_proc = rs_read_proc,
1014 * The serial driver boot-time initialization code!
1020 struct serial_state *state;
1022 if (!ia64_platform_is("hpsim"))
1025 hp_simserial_driver = alloc_tty_driver(1);
1026 if (!hp_simserial_driver)
1029 show_serial_version();
1031 /* Initialize the tty_driver structure */
1033 hp_simserial_driver->owner = THIS_MODULE;
1034 hp_simserial_driver->driver_name = "simserial";
1035 hp_simserial_driver->name = "ttyS";
1036 hp_simserial_driver->major = TTY_MAJOR;
1037 hp_simserial_driver->minor_start = 64;
1038 hp_simserial_driver->type = TTY_DRIVER_TYPE_SERIAL;
1039 hp_simserial_driver->subtype = SERIAL_TYPE_NORMAL;
1040 hp_simserial_driver->init_termios = tty_std_termios;
1041 hp_simserial_driver->init_termios.c_cflag =
1042 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
1043 hp_simserial_driver->flags = TTY_DRIVER_REAL_RAW;
1044 tty_set_operations(hp_simserial_driver, &hp_ops);
1047 * Let's have a little bit of fun !
1049 for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
1051 if (state->type == PORT_UNKNOWN) continue;
1054 state->irq = assign_irq_vector(AUTO_ASSIGN);
1055 ia64_ssc_connect_irq(KEYBOARD_INTR, state->irq);
1058 printk(KERN_INFO "ttyS%02d at 0x%04lx (irq = %d) is a %s\n",
1060 state->port, state->irq,
1061 uart_config[state->type].name);
1064 if (tty_register_driver(hp_simserial_driver))
1065 panic("Couldn't register simserial driver\n");
1071 __initcall(simrs_init);