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/init.h>
20 #include <linux/errno.h>
21 #include <linux/sched.h>
22 #include <linux/tty.h>
23 #include <linux/tty_flip.h>
24 #include <linux/major.h>
25 #include <linux/fcntl.h>
27 #include <linux/seq_file.h>
28 #include <linux/slab.h>
29 #include <linux/capability.h>
30 #include <linux/console.h>
31 #include <linux/module.h>
32 #include <linux/serial.h>
33 #include <linux/serialP.h>
34 #include <linux/sysrq.h>
37 #include <asm/hw_irq.h>
38 #include <asm/uaccess.h>
40 #undef SIMSERIAL_DEBUG /* define this to get some debug information */
42 #define KEYBOARD_INTR 3 /* must match with simulator! */
44 #define NR_PORTS 1 /* only one port for now */
46 #define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
48 #define SSC_GETCHAR 21
50 extern long ia64_ssc (long, long, long, long, int);
51 extern void ia64_ssc_connect_irq (long intr
, long irq
);
53 static char *serial_name
= "SimSerial driver";
54 static char *serial_version
= "0.6";
57 * This has been extracted from asm/serial.h. We need one eventually but
58 * I don't know exactly what we're going to put in it so just fake one
61 #define BASE_BAUD ( 1843200 / 16 )
63 #define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
66 * Most of the values here are meaningless to this particular driver.
67 * However some values must be preserved for the code (leveraged from serial.c
70 * type must not be UNKNOWN
71 * So I picked arbitrary (guess from where?) values instead
73 static struct serial_state rs_table
[NR_PORTS
]={
74 /* UART CLK PORT IRQ FLAGS */
75 { 0, BASE_BAUD
, 0x3F8, 0, STD_COM_FLAGS
,0,PORT_16550
} /* ttyS0 */
79 * Just for the fun of it !
81 static struct serial_uart_config uart_config
[] = {
86 { "16550A", 16, UART_CLEAR_FIFO
| UART_USE_FIFO
},
88 { "ST16650", 1, UART_CLEAR_FIFO
| UART_STARTECH
},
89 { "ST16650V2", 32, UART_CLEAR_FIFO
| UART_USE_FIFO
|
91 { "TI16750", 64, UART_CLEAR_FIFO
| UART_USE_FIFO
},
95 struct tty_driver
*hp_simserial_driver
;
97 static struct async_struct
*IRQ_ports
[NR_IRQS
];
99 static struct console
*console
;
101 static unsigned char *tmp_buf
;
103 extern struct console
*console_drivers
; /* from kernel/printk.c */
106 * ------------------------------------------------------------
107 * rs_stop() and rs_start()
109 * This routines are called before setting or resetting tty->stopped.
110 * They enable or disable transmitter interrupts, as necessary.
111 * ------------------------------------------------------------
113 static void rs_stop(struct tty_struct
*tty
)
115 #ifdef SIMSERIAL_DEBUG
116 printk("rs_stop: tty->stopped=%d tty->hw_stopped=%d tty->flow_stopped=%d\n",
117 tty
->stopped
, tty
->hw_stopped
, tty
->flow_stopped
);
122 static void rs_start(struct tty_struct
*tty
)
124 #ifdef SIMSERIAL_DEBUG
125 printk("rs_start: tty->stopped=%d tty->hw_stopped=%d tty->flow_stopped=%d\n",
126 tty
->stopped
, tty
->hw_stopped
, tty
->flow_stopped
);
130 static void receive_chars(struct tty_struct
*tty
)
133 static unsigned char seen_esc
= 0;
135 while ( (ch
= ia64_ssc(0, 0, 0, 0, SSC_GETCHAR
)) ) {
136 if ( ch
== 27 && seen_esc
== 0 ) {
140 if ( seen_esc
==1 && ch
== 'O' ) {
143 } else if ( seen_esc
== 2 ) {
144 if ( ch
== 'P' ) /* F1 */
146 #ifdef CONFIG_MAGIC_SYSRQ
147 if ( ch
== 'S' ) { /* F4 */
149 ch
= ia64_ssc(0, 0, 0, 0,
161 if (tty_insert_flip_char(tty
, ch
, TTY_NORMAL
) == 0)
164 tty_flip_buffer_push(tty
);
168 * This is the serial driver's interrupt routine for a single port
170 static irqreturn_t
rs_interrupt_single(int irq
, void *dev_id
)
172 struct async_struct
* info
;
175 * I don't know exactly why they don't use the dev_id opaque data
176 * pointer instead of this extra lookup table
178 info
= IRQ_ports
[irq
];
179 if (!info
|| !info
->tty
) {
180 printk(KERN_INFO
"simrs_interrupt_single: info|tty=0 info=%p problem\n", info
);
184 * pretty simple in our case, because we only get interrupts
187 receive_chars(info
->tty
);
192 * -------------------------------------------------------------------
193 * Here ends the serial interrupt routines.
194 * -------------------------------------------------------------------
197 static void do_softint(struct work_struct
*private_
)
199 printk(KERN_ERR
"simserial: do_softint called\n");
202 static int rs_put_char(struct tty_struct
*tty
, unsigned char ch
)
204 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
207 if (!tty
|| !info
->xmit
.buf
)
210 local_irq_save(flags
);
211 if (CIRC_SPACE(info
->xmit
.head
, info
->xmit
.tail
, SERIAL_XMIT_SIZE
) == 0) {
212 local_irq_restore(flags
);
215 info
->xmit
.buf
[info
->xmit
.head
] = ch
;
216 info
->xmit
.head
= (info
->xmit
.head
+ 1) & (SERIAL_XMIT_SIZE
-1);
217 local_irq_restore(flags
);
221 static void transmit_chars(struct async_struct
*info
, int *intr_done
)
227 local_irq_save(flags
);
230 char c
= info
->x_char
;
232 console
->write(console
, &c
, 1);
234 info
->state
->icount
.tx
++;
240 if (info
->xmit
.head
== info
->xmit
.tail
|| info
->tty
->stopped
|| info
->tty
->hw_stopped
) {
241 #ifdef SIMSERIAL_DEBUG
242 printk("transmit_chars: head=%d, tail=%d, stopped=%d\n",
243 info
->xmit
.head
, info
->xmit
.tail
, info
->tty
->stopped
);
248 * We removed the loop and try to do it in to chunks. We need
249 * 2 operations maximum because it's a ring buffer.
251 * First from current to tail if possible.
252 * Then from the beginning of the buffer until necessary
255 count
= min(CIRC_CNT(info
->xmit
.head
, info
->xmit
.tail
, SERIAL_XMIT_SIZE
),
256 SERIAL_XMIT_SIZE
- info
->xmit
.tail
);
257 console
->write(console
, info
->xmit
.buf
+info
->xmit
.tail
, count
);
259 info
->xmit
.tail
= (info
->xmit
.tail
+count
) & (SERIAL_XMIT_SIZE
-1);
262 * We have more at the beginning of the buffer
264 count
= CIRC_CNT(info
->xmit
.head
, info
->xmit
.tail
, SERIAL_XMIT_SIZE
);
266 console
->write(console
, info
->xmit
.buf
, count
);
267 info
->xmit
.tail
+= count
;
270 local_irq_restore(flags
);
273 static void rs_flush_chars(struct tty_struct
*tty
)
275 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
277 if (info
->xmit
.head
== info
->xmit
.tail
|| tty
->stopped
|| tty
->hw_stopped
||
281 transmit_chars(info
, NULL
);
285 static int rs_write(struct tty_struct
* tty
,
286 const unsigned char *buf
, int count
)
289 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
292 if (!tty
|| !info
->xmit
.buf
|| !tmp_buf
) return 0;
294 local_irq_save(flags
);
296 c
= CIRC_SPACE_TO_END(info
->xmit
.head
, info
->xmit
.tail
, SERIAL_XMIT_SIZE
);
302 memcpy(info
->xmit
.buf
+ info
->xmit
.head
, buf
, c
);
303 info
->xmit
.head
= ((info
->xmit
.head
+ c
) &
304 (SERIAL_XMIT_SIZE
-1));
309 local_irq_restore(flags
);
311 * Hey, we transmit directly from here in our case
313 if (CIRC_CNT(info
->xmit
.head
, info
->xmit
.tail
, SERIAL_XMIT_SIZE
)
314 && !tty
->stopped
&& !tty
->hw_stopped
) {
315 transmit_chars(info
, NULL
);
320 static int rs_write_room(struct tty_struct
*tty
)
322 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
324 return CIRC_SPACE(info
->xmit
.head
, info
->xmit
.tail
, SERIAL_XMIT_SIZE
);
327 static int rs_chars_in_buffer(struct tty_struct
*tty
)
329 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
331 return CIRC_CNT(info
->xmit
.head
, info
->xmit
.tail
, SERIAL_XMIT_SIZE
);
334 static void rs_flush_buffer(struct tty_struct
*tty
)
336 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
339 local_irq_save(flags
);
340 info
->xmit
.head
= info
->xmit
.tail
= 0;
341 local_irq_restore(flags
);
347 * This function is used to send a high-priority XON/XOFF character to
350 static void rs_send_xchar(struct tty_struct
*tty
, char ch
)
352 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
357 * I guess we could call console->write() directly but
358 * let's do that for now.
360 transmit_chars(info
, NULL
);
365 * ------------------------------------------------------------
368 * This routine is called by the upper-layer tty layer to signal that
369 * incoming characters should be throttled.
370 * ------------------------------------------------------------
372 static void rs_throttle(struct tty_struct
* tty
)
374 if (I_IXOFF(tty
)) rs_send_xchar(tty
, STOP_CHAR(tty
));
376 printk(KERN_INFO
"simrs_throttle called\n");
379 static void rs_unthrottle(struct tty_struct
* tty
)
381 struct async_struct
*info
= (struct async_struct
*)tty
->driver_data
;
387 rs_send_xchar(tty
, START_CHAR(tty
));
389 printk(KERN_INFO
"simrs_unthrottle called\n");
393 static int rs_ioctl(struct tty_struct
*tty
, unsigned int cmd
, unsigned long arg
)
395 if ((cmd
!= TIOCGSERIAL
) && (cmd
!= TIOCSSERIAL
) &&
396 (cmd
!= TIOCSERCONFIG
) && (cmd
!= TIOCSERGSTRUCT
) &&
397 (cmd
!= TIOCMIWAIT
)) {
398 if (tty
->flags
& (1 << TTY_IO_ERROR
))
404 printk(KERN_INFO
"simrs_ioctl TIOCGSERIAL called\n");
407 printk(KERN_INFO
"simrs_ioctl TIOCSSERIAL called\n");
410 printk(KERN_INFO
"rs_ioctl: TIOCSERCONFIG called\n");
413 case TIOCSERGETLSR
: /* Get line status register */
414 printk(KERN_INFO
"rs_ioctl: TIOCSERGETLSR called\n");
418 printk(KERN_INFO
"rs_ioctl: TIOCSERGSTRUCT called\n");
420 if (copy_to_user((struct async_struct
*) arg
,
421 info
, sizeof(struct async_struct
)))
427 * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change
428 * - mask passed in arg for lines of interest
429 * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking)
430 * Caller should use TIOCGICOUNT to see which one it was
433 printk(KERN_INFO
"rs_ioctl: TIOCMIWAIT: called\n");
437 /* "setserial -W" is called in Debian boot */
438 printk (KERN_INFO
"TIOCSER?WILD ioctl obsolete, ignored.\n");
447 #define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
449 static void rs_set_termios(struct tty_struct
*tty
, struct ktermios
*old_termios
)
451 /* Handle turning off CRTSCTS */
452 if ((old_termios
->c_cflag
& CRTSCTS
) &&
453 !(tty
->termios
->c_cflag
& CRTSCTS
)) {
459 * This routine will shutdown a serial port; interrupts are disabled, and
460 * DTR is dropped if the hangup on close termio flag is on.
462 static void shutdown(struct async_struct
* info
)
465 struct serial_state
*state
;
468 if (!(info
->flags
& ASYNC_INITIALIZED
)) return;
472 #ifdef SIMSERIAL_DEBUG
473 printk("Shutting down serial port %d (irq %d)....", info
->line
,
477 local_irq_save(flags
);
480 * First unlink the serial port from the IRQ chain...
483 info
->next_port
->prev_port
= info
->prev_port
;
485 info
->prev_port
->next_port
= info
->next_port
;
487 IRQ_ports
[state
->irq
] = info
->next_port
;
490 * Free the IRQ, if necessary
492 if (state
->irq
&& (!IRQ_ports
[state
->irq
] ||
493 !IRQ_ports
[state
->irq
]->next_port
)) {
494 if (IRQ_ports
[state
->irq
]) {
495 free_irq(state
->irq
, NULL
);
496 retval
= request_irq(state
->irq
, rs_interrupt_single
,
497 IRQ_T(info
), "serial", NULL
);
500 printk(KERN_ERR
"serial shutdown: request_irq: error %d"
501 " Couldn't reacquire IRQ.\n", retval
);
503 free_irq(state
->irq
, NULL
);
506 if (info
->xmit
.buf
) {
507 free_page((unsigned long) info
->xmit
.buf
);
508 info
->xmit
.buf
= NULL
;
511 if (info
->tty
) set_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
513 info
->flags
&= ~ASYNC_INITIALIZED
;
515 local_irq_restore(flags
);
519 * ------------------------------------------------------------
522 * This routine is called when the serial port gets closed. First, we
523 * wait for the last remaining data to be sent. Then, we unlink its
524 * async structure from the interrupt chain if necessary, and we free
525 * that IRQ if nothing is left in the chain.
526 * ------------------------------------------------------------
528 static void rs_close(struct tty_struct
*tty
, struct file
* filp
)
530 struct async_struct
* info
= (struct async_struct
*)tty
->driver_data
;
531 struct serial_state
*state
;
538 local_irq_save(flags
);
539 if (tty_hung_up_p(filp
)) {
540 #ifdef SIMSERIAL_DEBUG
541 printk("rs_close: hung_up\n");
543 local_irq_restore(flags
);
546 #ifdef SIMSERIAL_DEBUG
547 printk("rs_close ttys%d, count = %d\n", info
->line
, state
->count
);
549 if ((tty
->count
== 1) && (state
->count
!= 1)) {
551 * Uh, oh. tty->count is 1, which means that the tty
552 * structure will be freed. state->count should always
553 * be one in these conditions. If it's greater than
554 * one, we've got real problems, since it means the
555 * serial port won't be shutdown.
557 printk(KERN_ERR
"rs_close: bad serial port count; tty->count is 1, "
558 "state->count is %d\n", state
->count
);
561 if (--state
->count
< 0) {
562 printk(KERN_ERR
"rs_close: bad serial port count for ttys%d: %d\n",
563 info
->line
, state
->count
);
567 local_irq_restore(flags
);
570 info
->flags
|= ASYNC_CLOSING
;
571 local_irq_restore(flags
);
574 * Now we wait for the transmit buffer to clear; and we notify
575 * the line discipline to only process XON/XOFF characters.
578 rs_flush_buffer(tty
);
579 tty_ldisc_flush(tty
);
582 if (info
->blocked_open
) {
583 if (info
->close_delay
)
584 schedule_timeout_interruptible(info
->close_delay
);
585 wake_up_interruptible(&info
->open_wait
);
587 info
->flags
&= ~(ASYNC_NORMAL_ACTIVE
|ASYNC_CLOSING
);
588 wake_up_interruptible(&info
->close_wait
);
592 * rs_wait_until_sent() --- wait until the transmitter is empty
594 static void rs_wait_until_sent(struct tty_struct
*tty
, int timeout
)
600 * rs_hangup() --- called by tty_hangup() when a hangup is signaled.
602 static void rs_hangup(struct tty_struct
*tty
)
604 struct async_struct
* info
= (struct async_struct
*)tty
->driver_data
;
605 struct serial_state
*state
= info
->state
;
607 #ifdef SIMSERIAL_DEBUG
608 printk("rs_hangup: called\n");
613 rs_flush_buffer(tty
);
614 if (info
->flags
& ASYNC_CLOSING
)
620 info
->flags
&= ~ASYNC_NORMAL_ACTIVE
;
622 wake_up_interruptible(&info
->open_wait
);
626 static int get_async_struct(int line
, struct async_struct
**ret_info
)
628 struct async_struct
*info
;
629 struct serial_state
*sstate
;
631 sstate
= rs_table
+ line
;
634 *ret_info
= sstate
->info
;
637 info
= kzalloc(sizeof(struct async_struct
), GFP_KERNEL
);
642 init_waitqueue_head(&info
->open_wait
);
643 init_waitqueue_head(&info
->close_wait
);
644 init_waitqueue_head(&info
->delta_msr_wait
);
645 info
->magic
= SERIAL_MAGIC
;
646 info
->port
= sstate
->port
;
647 info
->flags
= sstate
->flags
;
648 info
->xmit_fifo_size
= sstate
->xmit_fifo_size
;
650 INIT_WORK(&info
->work
, do_softint
);
651 info
->state
= sstate
;
654 *ret_info
= sstate
->info
;
657 *ret_info
= sstate
->info
= info
;
662 startup(struct async_struct
*info
)
666 irq_handler_t handler
;
667 struct serial_state
*state
= info
->state
;
670 page
= get_zeroed_page(GFP_KERNEL
);
674 local_irq_save(flags
);
676 if (info
->flags
& ASYNC_INITIALIZED
) {
681 if (!state
->port
|| !state
->type
) {
682 if (info
->tty
) set_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
689 info
->xmit
.buf
= (unsigned char *) page
;
691 #ifdef SIMSERIAL_DEBUG
692 printk("startup: ttys%d (irq %d)...", info
->line
, state
->irq
);
696 * Allocate the IRQ if necessary
698 if (state
->irq
&& (!IRQ_ports
[state
->irq
] ||
699 !IRQ_ports
[state
->irq
]->next_port
)) {
700 if (IRQ_ports
[state
->irq
]) {
704 handler
= rs_interrupt_single
;
706 retval
= request_irq(state
->irq
, handler
, IRQ_T(info
), "simserial", NULL
);
708 if (capable(CAP_SYS_ADMIN
)) {
710 set_bit(TTY_IO_ERROR
,
719 * Insert serial port into IRQ chain.
721 info
->prev_port
= NULL
;
722 info
->next_port
= IRQ_ports
[state
->irq
];
724 info
->next_port
->prev_port
= info
;
725 IRQ_ports
[state
->irq
] = info
;
727 if (info
->tty
) clear_bit(TTY_IO_ERROR
, &info
->tty
->flags
);
729 info
->xmit
.head
= info
->xmit
.tail
= 0;
733 * Set up serial timers...
735 timer_table
[RS_TIMER
].expires
= jiffies
+ 2*HZ
/100;
736 timer_active
|= 1 << RS_TIMER
;
740 * Set up the tty->alt_speed kludge
743 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_HI
)
744 info
->tty
->alt_speed
= 57600;
745 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_VHI
)
746 info
->tty
->alt_speed
= 115200;
747 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_SHI
)
748 info
->tty
->alt_speed
= 230400;
749 if ((info
->flags
& ASYNC_SPD_MASK
) == ASYNC_SPD_WARP
)
750 info
->tty
->alt_speed
= 460800;
753 info
->flags
|= ASYNC_INITIALIZED
;
754 local_irq_restore(flags
);
758 local_irq_restore(flags
);
764 * This routine is called whenever a serial port is opened. It
765 * enables interrupts for a serial port, linking in its async structure into
766 * the IRQ chain. It also performs the serial-specific
767 * initialization for the tty structure.
769 static int rs_open(struct tty_struct
*tty
, struct file
* filp
)
771 struct async_struct
*info
;
776 if ((line
< 0) || (line
>= NR_PORTS
))
778 retval
= get_async_struct(line
, &info
);
781 tty
->driver_data
= info
;
784 #ifdef SIMSERIAL_DEBUG
785 printk("rs_open %s, count = %d\n", tty
->name
, info
->state
->count
);
787 info
->tty
->low_latency
= (info
->flags
& ASYNC_LOW_LATENCY
) ? 1 : 0;
790 page
= get_zeroed_page(GFP_KERNEL
);
796 tmp_buf
= (unsigned char *) page
;
800 * If the port is the middle of closing, bail out now
802 if (tty_hung_up_p(filp
) ||
803 (info
->flags
& ASYNC_CLOSING
)) {
804 if (info
->flags
& ASYNC_CLOSING
)
805 interruptible_sleep_on(&info
->close_wait
);
806 #ifdef SERIAL_DO_RESTART
807 return ((info
->flags
& ASYNC_HUP_NOTIFY
) ?
808 -EAGAIN
: -ERESTARTSYS
);
815 * Start up serial port
817 retval
= startup(info
);
823 * figure out which console to use (should be one already)
825 console
= console_drivers
;
827 if ((console
->flags
& CON_ENABLED
) && console
->write
) break;
828 console
= console
->next
;
831 #ifdef SIMSERIAL_DEBUG
832 printk("rs_open ttys%d successful\n", info
->line
);
838 * /proc fs routines....
841 static inline void line_info(struct seq_file
*m
, struct serial_state
*state
)
843 seq_printf(m
, "%d: uart:%s port:%lX irq:%d\n",
844 state
->line
, uart_config
[state
->type
].name
,
845 state
->port
, state
->irq
);
848 static int rs_proc_show(struct seq_file
*m
, void *v
)
852 seq_printf(m
, "simserinfo:1.0 driver:%s\n", serial_version
);
853 for (i
= 0; i
< NR_PORTS
; i
++)
854 line_info(m
, &rs_table
[i
]);
858 static int rs_proc_open(struct inode
*inode
, struct file
*file
)
860 return single_open(file
, rs_proc_show
, NULL
);
863 static const struct file_operations rs_proc_fops
= {
864 .owner
= THIS_MODULE
,
865 .open
= rs_proc_open
,
868 .release
= single_release
,
872 * ---------------------------------------------------------------------
873 * rs_init() and friends
875 * rs_init() is called at boot-time to initialize the serial driver.
876 * ---------------------------------------------------------------------
880 * This routine prints out the appropriate serial driver version
881 * number, and identifies which options were configured into this
884 static inline void show_serial_version(void)
886 printk(KERN_INFO
"%s version %s with", serial_name
, serial_version
);
887 printk(KERN_INFO
" no serial options enabled\n");
890 static const struct tty_operations hp_ops
= {
894 .put_char
= rs_put_char
,
895 .flush_chars
= rs_flush_chars
,
896 .write_room
= rs_write_room
,
897 .chars_in_buffer
= rs_chars_in_buffer
,
898 .flush_buffer
= rs_flush_buffer
,
900 .throttle
= rs_throttle
,
901 .unthrottle
= rs_unthrottle
,
902 .send_xchar
= rs_send_xchar
,
903 .set_termios
= rs_set_termios
,
907 .wait_until_sent
= rs_wait_until_sent
,
908 .proc_fops
= &rs_proc_fops
,
912 * The serial driver boot-time initialization code!
918 struct serial_state
*state
;
920 if (!ia64_platform_is("hpsim"))
923 hp_simserial_driver
= alloc_tty_driver(1);
924 if (!hp_simserial_driver
)
927 show_serial_version();
929 /* Initialize the tty_driver structure */
931 hp_simserial_driver
->owner
= THIS_MODULE
;
932 hp_simserial_driver
->driver_name
= "simserial";
933 hp_simserial_driver
->name
= "ttyS";
934 hp_simserial_driver
->major
= TTY_MAJOR
;
935 hp_simserial_driver
->minor_start
= 64;
936 hp_simserial_driver
->type
= TTY_DRIVER_TYPE_SERIAL
;
937 hp_simserial_driver
->subtype
= SERIAL_TYPE_NORMAL
;
938 hp_simserial_driver
->init_termios
= tty_std_termios
;
939 hp_simserial_driver
->init_termios
.c_cflag
=
940 B9600
| CS8
| CREAD
| HUPCL
| CLOCAL
;
941 hp_simserial_driver
->flags
= TTY_DRIVER_REAL_RAW
;
942 tty_set_operations(hp_simserial_driver
, &hp_ops
);
945 * Let's have a little bit of fun !
947 for (i
= 0, state
= rs_table
; i
< NR_PORTS
; i
++,state
++) {
949 if (state
->type
== PORT_UNKNOWN
) continue;
952 if ((rc
= assign_irq_vector(AUTO_ASSIGN
)) < 0)
953 panic("%s: out of interrupt vectors!\n",
956 ia64_ssc_connect_irq(KEYBOARD_INTR
, state
->irq
);
959 printk(KERN_INFO
"ttyS%d at 0x%04lx (irq = %d) is a %s\n",
961 state
->port
, state
->irq
,
962 uart_config
[state
->type
].name
);
965 if (tty_register_driver(hp_simserial_driver
))
966 panic("Couldn't register simserial driver\n");
972 __initcall(simrs_init
);