1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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>
26#include <linux/mm.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>
35
36#include <asm/irq.h>
37#include <asm/hw_irq.h>
38#include <asm/uaccess.h>
39
40#undef SIMSERIAL_DEBUG
41
42#define KEYBOARD_INTR 3
43
44#define NR_PORTS 1
45
46#define IRQ_T(info) ((info->flags & ASYNC_SHARE_IRQ) ? IRQF_SHARED : IRQF_DISABLED)
47
48#define SSC_GETCHAR 21
49
50extern long ia64_ssc (long, long, long, long, int);
51extern void ia64_ssc_connect_irq (long intr, long irq);
52
53static char *serial_name = "SimSerial driver";
54static char *serial_version = "0.6";
55
56
57
58
59
60
61#define BASE_BAUD ( 1843200 / 16 )
62
63#define STD_COM_FLAGS (ASYNC_BOOT_AUTOCONF | ASYNC_SKIP_TEST)
64
65
66
67
68
69
70
71
72
73static struct serial_state rs_table[NR_PORTS]={
74
75 { 0, BASE_BAUD, 0x3F8, 0, STD_COM_FLAGS,0,PORT_16550 }
76};
77
78
79
80
81static struct serial_uart_config uart_config[] = {
82 { "unknown", 1, 0 },
83 { "8250", 1, 0 },
84 { "16450", 1, 0 },
85 { "16550", 1, 0 },
86 { "16550A", 16, UART_CLEAR_FIFO | UART_USE_FIFO },
87 { "cirrus", 1, 0 },
88 { "ST16650", 1, UART_CLEAR_FIFO | UART_STARTECH },
89 { "ST16650V2", 32, UART_CLEAR_FIFO | UART_USE_FIFO |
90 UART_STARTECH },
91 { "TI16750", 64, UART_CLEAR_FIFO | UART_USE_FIFO},
92 { NULL, 0}
93};
94
95struct tty_driver *hp_simserial_driver;
96
97static struct async_struct *IRQ_ports[NR_IRQS];
98
99static struct console *console;
100
101static unsigned char *tmp_buf;
102
103extern struct console *console_drivers;
104
105
106
107
108
109
110
111
112
113static void rs_stop(struct tty_struct *tty)
114{
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);
118#endif
119
120}
121
122static void rs_start(struct tty_struct *tty)
123{
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);
127#endif
128}
129
130static void receive_chars(struct tty_struct *tty)
131{
132 unsigned char ch;
133 static unsigned char seen_esc = 0;
134
135 while ( (ch = ia64_ssc(0, 0, 0, 0, SSC_GETCHAR)) ) {
136 if ( ch == 27 && seen_esc == 0 ) {
137 seen_esc = 1;
138 continue;
139 } else {
140 if ( seen_esc==1 && ch == 'O' ) {
141 seen_esc = 2;
142 continue;
143 } else if ( seen_esc == 2 ) {
144 if ( ch == 'P' )
145 show_state();
146#ifdef CONFIG_MAGIC_SYSRQ
147 if ( ch == 'S' ) {
148 do
149 ch = ia64_ssc(0, 0, 0, 0,
150 SSC_GETCHAR);
151 while (!ch);
152 handle_sysrq(ch, NULL);
153 }
154#endif
155 seen_esc = 0;
156 continue;
157 }
158 }
159 seen_esc = 0;
160
161 if (tty_insert_flip_char(tty, ch, TTY_NORMAL) == 0)
162 break;
163 }
164 tty_flip_buffer_push(tty);
165}
166
167
168
169
170static irqreturn_t rs_interrupt_single(int irq, void *dev_id)
171{
172 struct async_struct * info;
173
174
175
176
177
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);
181 return IRQ_NONE;
182 }
183
184
185
186
187 receive_chars(info->tty);
188 return IRQ_HANDLED;
189}
190
191
192
193
194
195
196
197static void do_softint(struct work_struct *private_)
198{
199 printk(KERN_ERR "simserial: do_softint called\n");
200}
201
202static int rs_put_char(struct tty_struct *tty, unsigned char ch)
203{
204 struct async_struct *info = (struct async_struct *)tty->driver_data;
205 unsigned long flags;
206
207 if (!tty || !info->xmit.buf)
208 return 0;
209
210 local_irq_save(flags);
211 if (CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE) == 0) {
212 local_irq_restore(flags);
213 return 0;
214 }
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);
218 return 1;
219}
220
221static void transmit_chars(struct async_struct *info, int *intr_done)
222{
223 int count;
224 unsigned long flags;
225
226
227 local_irq_save(flags);
228
229 if (info->x_char) {
230 char c = info->x_char;
231
232 console->write(console, &c, 1);
233
234 info->state->icount.tx++;
235 info->x_char = 0;
236
237 goto out;
238 }
239
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);
244#endif
245 goto out;
246 }
247
248
249
250
251
252
253
254
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);
258
259 info->xmit.tail = (info->xmit.tail+count) & (SERIAL_XMIT_SIZE-1);
260
261
262
263
264 count = CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
265 if (count) {
266 console->write(console, info->xmit.buf, count);
267 info->xmit.tail += count;
268 }
269out:
270 local_irq_restore(flags);
271}
272
273static void rs_flush_chars(struct tty_struct *tty)
274{
275 struct async_struct *info = (struct async_struct *)tty->driver_data;
276
277 if (info->xmit.head == info->xmit.tail || tty->stopped || tty->hw_stopped ||
278 !info->xmit.buf)
279 return;
280
281 transmit_chars(info, NULL);
282}
283
284
285static int rs_write(struct tty_struct * tty,
286 const unsigned char *buf, int count)
287{
288 int c, ret = 0;
289 struct async_struct *info = (struct async_struct *)tty->driver_data;
290 unsigned long flags;
291
292 if (!tty || !info->xmit.buf || !tmp_buf) return 0;
293
294 local_irq_save(flags);
295 while (1) {
296 c = CIRC_SPACE_TO_END(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
297 if (count < c)
298 c = count;
299 if (c <= 0) {
300 break;
301 }
302 memcpy(info->xmit.buf + info->xmit.head, buf, c);
303 info->xmit.head = ((info->xmit.head + c) &
304 (SERIAL_XMIT_SIZE-1));
305 buf += c;
306 count -= c;
307 ret += c;
308 }
309 local_irq_restore(flags);
310
311
312
313 if (CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE)
314 && !tty->stopped && !tty->hw_stopped) {
315 transmit_chars(info, NULL);
316 }
317 return ret;
318}
319
320static int rs_write_room(struct tty_struct *tty)
321{
322 struct async_struct *info = (struct async_struct *)tty->driver_data;
323
324 return CIRC_SPACE(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
325}
326
327static int rs_chars_in_buffer(struct tty_struct *tty)
328{
329 struct async_struct *info = (struct async_struct *)tty->driver_data;
330
331 return CIRC_CNT(info->xmit.head, info->xmit.tail, SERIAL_XMIT_SIZE);
332}
333
334static void rs_flush_buffer(struct tty_struct *tty)
335{
336 struct async_struct *info = (struct async_struct *)tty->driver_data;
337 unsigned long flags;
338
339 local_irq_save(flags);
340 info->xmit.head = info->xmit.tail = 0;
341 local_irq_restore(flags);
342
343 tty_wakeup(tty);
344}
345
346
347
348
349
350static void rs_send_xchar(struct tty_struct *tty, char ch)
351{
352 struct async_struct *info = (struct async_struct *)tty->driver_data;
353
354 info->x_char = ch;
355 if (ch) {
356
357
358
359
360 transmit_chars(info, NULL);
361 }
362}
363
364
365
366
367
368
369
370
371
372static void rs_throttle(struct tty_struct * tty)
373{
374 if (I_IXOFF(tty)) rs_send_xchar(tty, STOP_CHAR(tty));
375
376 printk(KERN_INFO "simrs_throttle called\n");
377}
378
379static void rs_unthrottle(struct tty_struct * tty)
380{
381 struct async_struct *info = (struct async_struct *)tty->driver_data;
382
383 if (I_IXOFF(tty)) {
384 if (info->x_char)
385 info->x_char = 0;
386 else
387 rs_send_xchar(tty, START_CHAR(tty));
388 }
389 printk(KERN_INFO "simrs_unthrottle called\n");
390}
391
392
393static int rs_ioctl(struct tty_struct *tty, struct file * file,
394 unsigned int cmd, unsigned long arg)
395{
396 if ((cmd != TIOCGSERIAL) && (cmd != TIOCSSERIAL) &&
397 (cmd != TIOCSERCONFIG) && (cmd != TIOCSERGSTRUCT) &&
398 (cmd != TIOCMIWAIT) && (cmd != TIOCGICOUNT)) {
399 if (tty->flags & (1 << TTY_IO_ERROR))
400 return -EIO;
401 }
402
403 switch (cmd) {
404 case TIOCGSERIAL:
405 printk(KERN_INFO "simrs_ioctl TIOCGSERIAL called\n");
406 return 0;
407 case TIOCSSERIAL:
408 printk(KERN_INFO "simrs_ioctl TIOCSSERIAL called\n");
409 return 0;
410 case TIOCSERCONFIG:
411 printk(KERN_INFO "rs_ioctl: TIOCSERCONFIG called\n");
412 return -EINVAL;
413
414 case TIOCSERGETLSR:
415 printk(KERN_INFO "rs_ioctl: TIOCSERGETLSR called\n");
416 return -EINVAL;
417
418 case TIOCSERGSTRUCT:
419 printk(KERN_INFO "rs_ioctl: TIOCSERGSTRUCT called\n");
420#if 0
421 if (copy_to_user((struct async_struct *) arg,
422 info, sizeof(struct async_struct)))
423 return -EFAULT;
424#endif
425 return 0;
426
427
428
429
430
431
432
433 case TIOCMIWAIT:
434 printk(KERN_INFO "rs_ioctl: TIOCMIWAIT: called\n");
435 return 0;
436
437
438
439
440
441
442 case TIOCGICOUNT:
443 printk(KERN_INFO "rs_ioctl: TIOCGICOUNT called\n");
444 return 0;
445
446 case TIOCSERGWILD:
447 case TIOCSERSWILD:
448
449 printk (KERN_INFO "TIOCSER?WILD ioctl obsolete, ignored.\n");
450 return 0;
451
452 default:
453 return -ENOIOCTLCMD;
454 }
455 return 0;
456}
457
458#define RELEVANT_IFLAG(iflag) (iflag & (IGNBRK|BRKINT|IGNPAR|PARMRK|INPCK))
459
460static void rs_set_termios(struct tty_struct *tty, struct ktermios *old_termios)
461{
462
463 if ((old_termios->c_cflag & CRTSCTS) &&
464 !(tty->termios->c_cflag & CRTSCTS)) {
465 tty->hw_stopped = 0;
466 rs_start(tty);
467 }
468}
469
470
471
472
473static void shutdown(struct async_struct * info)
474{
475 unsigned long flags;
476 struct serial_state *state;
477 int retval;
478
479 if (!(info->flags & ASYNC_INITIALIZED)) return;
480
481 state = info->state;
482
483#ifdef SIMSERIAL_DEBUG
484 printk("Shutting down serial port %d (irq %d)....", info->line,
485 state->irq);
486#endif
487
488 local_irq_save(flags);
489 {
490
491
492
493 if (info->next_port)
494 info->next_port->prev_port = info->prev_port;
495 if (info->prev_port)
496 info->prev_port->next_port = info->next_port;
497 else
498 IRQ_ports[state->irq] = info->next_port;
499
500
501
502
503 if (state->irq && (!IRQ_ports[state->irq] ||
504 !IRQ_ports[state->irq]->next_port)) {
505 if (IRQ_ports[state->irq]) {
506 free_irq(state->irq, NULL);
507 retval = request_irq(state->irq, rs_interrupt_single,
508 IRQ_T(info), "serial", NULL);
509
510 if (retval)
511 printk(KERN_ERR "serial shutdown: request_irq: error %d"
512 " Couldn't reacquire IRQ.\n", retval);
513 } else
514 free_irq(state->irq, NULL);
515 }
516
517 if (info->xmit.buf) {
518 free_page((unsigned long) info->xmit.buf);
519 info->xmit.buf = NULL;
520 }
521
522 if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
523
524 info->flags &= ~ASYNC_INITIALIZED;
525 }
526 local_irq_restore(flags);
527}
528
529
530
531
532
533
534
535
536
537
538
539static void rs_close(struct tty_struct *tty, struct file * filp)
540{
541 struct async_struct * info = (struct async_struct *)tty->driver_data;
542 struct serial_state *state;
543 unsigned long flags;
544
545 if (!info ) return;
546
547 state = info->state;
548
549 local_irq_save(flags);
550 if (tty_hung_up_p(filp)) {
551#ifdef SIMSERIAL_DEBUG
552 printk("rs_close: hung_up\n");
553#endif
554 local_irq_restore(flags);
555 return;
556 }
557#ifdef SIMSERIAL_DEBUG
558 printk("rs_close ttys%d, count = %d\n", info->line, state->count);
559#endif
560 if ((tty->count == 1) && (state->count != 1)) {
561
562
563
564
565
566
567
568 printk(KERN_ERR "rs_close: bad serial port count; tty->count is 1, "
569 "state->count is %d\n", state->count);
570 state->count = 1;
571 }
572 if (--state->count < 0) {
573 printk(KERN_ERR "rs_close: bad serial port count for ttys%d: %d\n",
574 info->line, state->count);
575 state->count = 0;
576 }
577 if (state->count) {
578 local_irq_restore(flags);
579 return;
580 }
581 info->flags |= ASYNC_CLOSING;
582 local_irq_restore(flags);
583
584
585
586
587
588 shutdown(info);
589 rs_flush_buffer(tty);
590 tty_ldisc_flush(tty);
591 info->event = 0;
592 info->tty = NULL;
593 if (info->blocked_open) {
594 if (info->close_delay)
595 schedule_timeout_interruptible(info->close_delay);
596 wake_up_interruptible(&info->open_wait);
597 }
598 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING);
599 wake_up_interruptible(&info->close_wait);
600}
601
602
603
604
605static void rs_wait_until_sent(struct tty_struct *tty, int timeout)
606{
607}
608
609
610
611
612
613static void rs_hangup(struct tty_struct *tty)
614{
615 struct async_struct * info = (struct async_struct *)tty->driver_data;
616 struct serial_state *state = info->state;
617
618#ifdef SIMSERIAL_DEBUG
619 printk("rs_hangup: called\n");
620#endif
621
622 state = info->state;
623
624 rs_flush_buffer(tty);
625 if (info->flags & ASYNC_CLOSING)
626 return;
627 shutdown(info);
628
629 info->event = 0;
630 state->count = 0;
631 info->flags &= ~ASYNC_NORMAL_ACTIVE;
632 info->tty = NULL;
633 wake_up_interruptible(&info->open_wait);
634}
635
636
637static int get_async_struct(int line, struct async_struct **ret_info)
638{
639 struct async_struct *info;
640 struct serial_state *sstate;
641
642 sstate = rs_table + line;
643 sstate->count++;
644 if (sstate->info) {
645 *ret_info = sstate->info;
646 return 0;
647 }
648 info = kzalloc(sizeof(struct async_struct), GFP_KERNEL);
649 if (!info) {
650 sstate->count--;
651 return -ENOMEM;
652 }
653 init_waitqueue_head(&info->open_wait);
654 init_waitqueue_head(&info->close_wait);
655 init_waitqueue_head(&info->delta_msr_wait);
656 info->magic = SERIAL_MAGIC;
657 info->port = sstate->port;
658 info->flags = sstate->flags;
659 info->xmit_fifo_size = sstate->xmit_fifo_size;
660 info->line = line;
661 INIT_WORK(&info->work, do_softint);
662 info->state = sstate;
663 if (sstate->info) {
664 kfree(info);
665 *ret_info = sstate->info;
666 return 0;
667 }
668 *ret_info = sstate->info = info;
669 return 0;
670}
671
672static int
673startup(struct async_struct *info)
674{
675 unsigned long flags;
676 int retval=0;
677 irq_handler_t handler;
678 struct serial_state *state= info->state;
679 unsigned long page;
680
681 page = get_zeroed_page(GFP_KERNEL);
682 if (!page)
683 return -ENOMEM;
684
685 local_irq_save(flags);
686
687 if (info->flags & ASYNC_INITIALIZED) {
688 free_page(page);
689 goto errout;
690 }
691
692 if (!state->port || !state->type) {
693 if (info->tty) set_bit(TTY_IO_ERROR, &info->tty->flags);
694 free_page(page);
695 goto errout;
696 }
697 if (info->xmit.buf)
698 free_page(page);
699 else
700 info->xmit.buf = (unsigned char *) page;
701
702#ifdef SIMSERIAL_DEBUG
703 printk("startup: ttys%d (irq %d)...", info->line, state->irq);
704#endif
705
706
707
708
709 if (state->irq && (!IRQ_ports[state->irq] ||
710 !IRQ_ports[state->irq]->next_port)) {
711 if (IRQ_ports[state->irq]) {
712 retval = -EBUSY;
713 goto errout;
714 } else
715 handler = rs_interrupt_single;
716
717 retval = request_irq(state->irq, handler, IRQ_T(info), "simserial", NULL);
718 if (retval) {
719 if (capable(CAP_SYS_ADMIN)) {
720 if (info->tty)
721 set_bit(TTY_IO_ERROR,
722 &info->tty->flags);
723 retval = 0;
724 }
725 goto errout;
726 }
727 }
728
729
730
731
732 info->prev_port = NULL;
733 info->next_port = IRQ_ports[state->irq];
734 if (info->next_port)
735 info->next_port->prev_port = info;
736 IRQ_ports[state->irq] = info;
737
738 if (info->tty) clear_bit(TTY_IO_ERROR, &info->tty->flags);
739
740 info->xmit.head = info->xmit.tail = 0;
741
742#if 0
743
744
745
746 timer_table[RS_TIMER].expires = jiffies + 2*HZ/100;
747 timer_active |= 1 << RS_TIMER;
748#endif
749
750
751
752
753 if (info->tty) {
754 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
755 info->tty->alt_speed = 57600;
756 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
757 info->tty->alt_speed = 115200;
758 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI)
759 info->tty->alt_speed = 230400;
760 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP)
761 info->tty->alt_speed = 460800;
762 }
763
764 info->flags |= ASYNC_INITIALIZED;
765 local_irq_restore(flags);
766 return 0;
767
768errout:
769 local_irq_restore(flags);
770 return retval;
771}
772
773
774
775
776
777
778
779
780static int rs_open(struct tty_struct *tty, struct file * filp)
781{
782 struct async_struct *info;
783 int retval, line;
784 unsigned long page;
785
786 line = tty->index;
787 if ((line < 0) || (line >= NR_PORTS))
788 return -ENODEV;
789 retval = get_async_struct(line, &info);
790 if (retval)
791 return retval;
792 tty->driver_data = info;
793 info->tty = tty;
794
795#ifdef SIMSERIAL_DEBUG
796 printk("rs_open %s, count = %d\n", tty->name, info->state->count);
797#endif
798 info->tty->low_latency = (info->flags & ASYNC_LOW_LATENCY) ? 1 : 0;
799
800 if (!tmp_buf) {
801 page = get_zeroed_page(GFP_KERNEL);
802 if (!page)
803 return -ENOMEM;
804 if (tmp_buf)
805 free_page(page);
806 else
807 tmp_buf = (unsigned char *) page;
808 }
809
810
811
812
813 if (tty_hung_up_p(filp) ||
814 (info->flags & ASYNC_CLOSING)) {
815 if (info->flags & ASYNC_CLOSING)
816 interruptible_sleep_on(&info->close_wait);
817#ifdef SERIAL_DO_RESTART
818 return ((info->flags & ASYNC_HUP_NOTIFY) ?
819 -EAGAIN : -ERESTARTSYS);
820#else
821 return -EAGAIN;
822#endif
823 }
824
825
826
827
828 retval = startup(info);
829 if (retval) {
830 return retval;
831 }
832
833
834
835
836 console = console_drivers;
837 while (console) {
838 if ((console->flags & CON_ENABLED) && console->write) break;
839 console = console->next;
840 }
841
842#ifdef SIMSERIAL_DEBUG
843 printk("rs_open ttys%d successful\n", info->line);
844#endif
845 return 0;
846}
847
848
849
850
851
852static inline void line_info(struct seq_file *m, struct serial_state *state)
853{
854 seq_printf(m, "%d: uart:%s port:%lX irq:%d\n",
855 state->line, uart_config[state->type].name,
856 state->port, state->irq);
857}
858
859static int rs_proc_show(struct seq_file *m, void *v)
860{
861 int i;
862
863 seq_printf(m, "simserinfo:1.0 driver:%s\n", serial_version);
864 for (i = 0; i < NR_PORTS; i++)
865 line_info(m, &rs_table[i]);
866 return 0;
867}
868
869static int rs_proc_open(struct inode *inode, struct file *file)
870{
871 return single_open(file, rs_proc_show, NULL);
872}
873
874static const struct file_operations rs_proc_fops = {
875 .owner = THIS_MODULE,
876 .open = rs_proc_open,
877 .read = seq_read,
878 .llseek = seq_lseek,
879 .release = single_release,
880};
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895static inline void show_serial_version(void)
896{
897 printk(KERN_INFO "%s version %s with", serial_name, serial_version);
898 printk(KERN_INFO " no serial options enabled\n");
899}
900
901static const struct tty_operations hp_ops = {
902 .open = rs_open,
903 .close = rs_close,
904 .write = rs_write,
905 .put_char = rs_put_char,
906 .flush_chars = rs_flush_chars,
907 .write_room = rs_write_room,
908 .chars_in_buffer = rs_chars_in_buffer,
909 .flush_buffer = rs_flush_buffer,
910 .ioctl = rs_ioctl,
911 .throttle = rs_throttle,
912 .unthrottle = rs_unthrottle,
913 .send_xchar = rs_send_xchar,
914 .set_termios = rs_set_termios,
915 .stop = rs_stop,
916 .start = rs_start,
917 .hangup = rs_hangup,
918 .wait_until_sent = rs_wait_until_sent,
919 .proc_fops = &rs_proc_fops,
920};
921
922
923
924
925static int __init
926simrs_init (void)
927{
928 int i, rc;
929 struct serial_state *state;
930
931 if (!ia64_platform_is("hpsim"))
932 return -ENODEV;
933
934 hp_simserial_driver = alloc_tty_driver(1);
935 if (!hp_simserial_driver)
936 return -ENOMEM;
937
938 show_serial_version();
939
940
941
942 hp_simserial_driver->owner = THIS_MODULE;
943 hp_simserial_driver->driver_name = "simserial";
944 hp_simserial_driver->name = "ttyS";
945 hp_simserial_driver->major = TTY_MAJOR;
946 hp_simserial_driver->minor_start = 64;
947 hp_simserial_driver->type = TTY_DRIVER_TYPE_SERIAL;
948 hp_simserial_driver->subtype = SERIAL_TYPE_NORMAL;
949 hp_simserial_driver->init_termios = tty_std_termios;
950 hp_simserial_driver->init_termios.c_cflag =
951 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
952 hp_simserial_driver->flags = TTY_DRIVER_REAL_RAW;
953 tty_set_operations(hp_simserial_driver, &hp_ops);
954
955
956
957
958 for (i = 0, state = rs_table; i < NR_PORTS; i++,state++) {
959
960 if (state->type == PORT_UNKNOWN) continue;
961
962 if (!state->irq) {
963 if ((rc = assign_irq_vector(AUTO_ASSIGN)) < 0)
964 panic("%s: out of interrupt vectors!\n",
965 __func__);
966 state->irq = rc;
967 ia64_ssc_connect_irq(KEYBOARD_INTR, state->irq);
968 }
969
970 printk(KERN_INFO "ttyS%d at 0x%04lx (irq = %d) is a %s\n",
971 state->line,
972 state->port, state->irq,
973 uart_config[state->type].name);
974 }
975
976 if (tty_register_driver(hp_simserial_driver))
977 panic("Couldn't register simserial driver\n");
978
979 return 0;
980}
981
982#ifndef MODULE
983__initcall(simrs_init);
984#endif
985