This source file includes following definitions.
- serial_paranoia_check
- SP
- CP
- CP1
- CP2
- CP4
- CP8
- write_cy_cmd
- cy_stop
- cy_start
- cy_sched_event
- cy_probe
- cy_interrupt
- do_cyclades_bh
- do_softint
- grab_all_interrupts
- free_all_interrupts
- check_wild_interrupts
- get_auto_irq
- do_auto_irq
- startup
- start_xmit
- shutdown
- config_setup
- cy_put_char
- cy_flush_chars
- cy_write
- cy_write_room
- cy_chars_in_buffer
- cy_flush_buffer
- cy_throttle
- cy_unthrottle
- get_serial_info
- set_serial_info
- get_modem_info
- set_modem_info
- send_break
- get_mon_info
- set_threshold
- get_threshold
- set_default_threshold
- get_default_threshold
- set_timeout
- get_timeout
- set_default_timeout
- get_default_timeout
- cy_ioctl
- cy_set_termios
- cy_close
- cy_hangup
- block_til_ready
- cy_open
- show_version
- cy_init_card
- cy_init
- init_module
- cleanup_module
- cy_detect_isa
- cy_detect_pci
- show_status
1 static char rcsid[] =
2 "$Revision: 1.36.3.4 $$Date: 1995/11/13 20:45:10 $";
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239 #include <linux/module.h>
240
241 #include <linux/errno.h>
242 #include <linux/signal.h>
243 #include <linux/sched.h>
244 #include <linux/timer.h>
245 #include <linux/tty.h>
246 #include <linux/serial.h>
247 #include <linux/interrupt.h>
248 #include <linux/string.h>
249 #include <linux/fcntl.h>
250 #include <linux/ptrace.h>
251 #include <linux/cyclades.h>
252 #include <linux/delay.h>
253 #include <linux/major.h>
254 #include <linux/mm.h>
255
256 #include <asm/system.h>
257 #include <asm/io.h>
258 #include <asm/segment.h>
259 #include <asm/bitops.h>
260
261 #include <linux/config.h>
262 #include <linux/types.h>
263 #include <linux/kernel.h>
264 #include <linux/bios32.h>
265 #include <linux/pci.h>
266
267 #define small_delay(x) for(j=0;j<x;j++)k++;
268
269
270 #define SERIAL_PARANOIA_CHECK
271 #undef SERIAL_DEBUG_OPEN
272 #undef SERIAL_DEBUG_THROTTLE
273 #undef SERIAL_DEBUG_OTHER
274 #undef SERIAL_DEBUG_IO
275 #undef SERIAL_DEBUG_COUNT
276 #undef SERIAL_DEBUG_DTR
277 #undef CYCLOM_16Y_HACK
278 #undef CYCLOM_ENABLE_MONITORING
279
280 #ifndef MIN
281 #define MIN(a,b) ((a) < (b) ? (a) : (b))
282 #endif
283
284 #define WAKEUP_CHARS 256
285
286 #define STD_COM_FLAGS (0)
287
288 #define SERIAL_TYPE_NORMAL 1
289 #define SERIAL_TYPE_CALLOUT 2
290
291
292 DECLARE_TASK_QUEUE(tq_cyclades);
293
294 struct tty_driver cy_serial_driver, cy_callout_driver;
295
296 static volatile int cy_irq_triggered;
297 static volatile int cy_triggered;
298 static int cy_wild_int_mask;
299 static unsigned char *intr_base_addr;
300
301
302
303
304
305
306
307
308 static unsigned char *cy_isa_addresses[] = {
309 (unsigned char *) 0xD0000,
310 (unsigned char *) 0xD2000,
311 (unsigned char *) 0xD4000,
312 (unsigned char *) 0xD6000,
313 (unsigned char *) 0xD8000,
314 (unsigned char *) 0xDA000,
315 (unsigned char *) 0xDC000,
316 (unsigned char *) 0xDE000,
317 };
318 #define NR_ISA_ADDRESSES (sizeof(cy_isa_addresses)/sizeof(unsigned char *))
319
320
321
322
323
324
325 #define NR_CARDS 4
326
327 static struct cyclades_card cy_card[NR_CARDS];
328
329
330
331
332
333
334
335 #define NR_PORTS 64
336
337 static struct cyclades_port cy_port[NR_PORTS];
338
339
340
341
342 static int cy_chip_offset [] =
343 { 0x0000,
344 0x0400,
345 0x0800,
346 0x0C00,
347 0x0200,
348 0x0600,
349 0x0A00,
350 0x0E00
351 };
352
353
354
355 static unsigned short cy_pci_nboard = 0;
356 static unsigned short cy_isa_nboard = 0;
357 static unsigned short cy_nboard = 0;
358
359 int cy_detect_isa(void);
360 int cy_detect_pci(void);
361
362 static int cy_next_channel = 0;
363
364 static int serial_refcount;
365
366 static struct tty_struct *serial_table[NR_PORTS];
367 static struct termios *serial_termios[NR_PORTS];
368 static struct termios *serial_termios_locked[NR_PORTS];
369
370
371
372
373 struct cyclades_card *IRQ_cards[16];
374
375
376
377
378
379
380
381
382
383
384
385 static unsigned char *tmp_buf = 0;
386 static struct semaphore tmp_buf_sem = MUTEX;
387
388
389
390
391
392
393
394
395
396 static int baud_table[] = {
397 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
398 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000,
399 0};
400
401 static char baud_co[] = {
402
403
404 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02,
405 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
406
407 static char baud_bpr[] = {
408 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3,
409 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15};
410
411 static char baud_cor3[] = {
412 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a,
413 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07};
414
415
416
417 static void shutdown(struct cyclades_port *);
418 static int startup (struct cyclades_port *);
419 static void cy_throttle(struct tty_struct *);
420 static void cy_unthrottle(struct tty_struct *);
421 static void config_setup(struct cyclades_port *);
422 #ifdef CYCLOM_SHOW_STATUS
423 static void show_status(int);
424 #endif
425
426
427 static inline int
428 serial_paranoia_check(struct cyclades_port *info,
429 kdev_t device, const char *routine)
430 {
431 #ifdef SERIAL_PARANOIA_CHECK
432 static const char *badmagic =
433 "Warning: bad magic number for serial struct (%s) in %s\n";
434 static const char *badinfo =
435 "Warning: null cyclades_port for (%s) in %s\n";
436 static const char *badrange =
437 "Warning: cyclades_port out of range for (%s) in %s\n";
438
439 if (!info) {
440 printk(badinfo, kdevname(device), routine);
441 return 1;
442 }
443
444 if( (long)info < (long)(&cy_port[0])
445 || (long)(&cy_port[NR_PORTS]) < (long)info ){
446 printk(badrange, kdevname(device), routine);
447 return 1;
448 }
449
450 if (info->magic != CYCLADES_MAGIC) {
451 printk(badmagic, kdevname(device), routine);
452 return 1;
453 }
454 #endif
455 return 0;
456 }
457
458
459
460
461 void
462 SP(char *data){
463 unsigned long flags;
464 save_flags(flags); cli();
465 console_print(data);
466 restore_flags(flags);
467 }
468 void
469 CP(char data){
470 unsigned long flags;
471 char scrn[2];
472 save_flags(flags); cli();
473 scrn[0] = data;
474 scrn[1] = '\0';
475 console_print(scrn);
476 restore_flags(flags);
477 }
478
479 void CP1(int data) { (data<10)? CP(data+'0'): CP(data+'A'-10); }
480 void CP2(int data) { CP1((data>>4) & 0x0f); CP1( data & 0x0f); }
481 void CP4(int data) { CP2((data>>8) & 0xff); CP2(data & 0xff); }
482 void CP8(long data) { CP4((data>>16) & 0xffff); CP4(data & 0xffff); }
483
484
485
486
487
488
489 u_short
490 write_cy_cmd(u_char *base_addr, u_char cmd, int index)
491 {
492 unsigned long flags;
493 volatile int i;
494
495 save_flags(flags); cli();
496
497 for(i = 0 ; i < 100 ; i++){
498 if (base_addr[CyCCR<<index] == 0){
499 break;
500 }
501 udelay(10L);
502 }
503
504
505 if ( i == 100 ) {
506 restore_flags(flags);
507 return (-1);
508 }
509
510
511 base_addr[CyCCR<<index] = cmd;
512 restore_flags(flags);
513 return(0);
514 }
515
516
517
518
519
520 static void
521 cy_stop(struct tty_struct *tty)
522 {
523 struct cyclades_card *cinfo;
524 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
525 unsigned char *base_addr;
526 int chip,channel,index;
527 unsigned long flags;
528
529 #ifdef SERIAL_DEBUG_OTHER
530 printk("cy_stop ttyC%d\n", info->line);
531 #endif
532
533 if (serial_paranoia_check(info, tty->device, "cy_stop"))
534 return;
535
536 cinfo = &cy_card[info->card];
537 index = cinfo->bus_index;
538 channel = info->line - cinfo->first_line;
539 chip = channel>>2;
540 channel &= 0x03;
541 base_addr = (unsigned char*)
542 (cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index));
543
544 save_flags(flags); cli();
545 base_addr[CyCAR<<index] = (u_char)(channel & 0x0003);
546 base_addr[CySRER<<index] &= ~CyTxMpty;
547 restore_flags(flags);
548
549 return;
550 }
551
552 static void
553 cy_start(struct tty_struct *tty)
554 {
555 struct cyclades_card *cinfo;
556 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
557 unsigned char *base_addr;
558 int chip,channel,index;
559 unsigned long flags;
560
561 #ifdef SERIAL_DEBUG_OTHER
562 printk("cy_start ttyC%d\n", info->line);
563 #endif
564
565 if (serial_paranoia_check(info, tty->device, "cy_start"))
566 return;
567
568 cinfo = &cy_card[info->card];
569 index = cinfo->bus_index;
570 channel = info->line - cinfo->first_line;
571 chip = channel>>2;
572 channel &= 0x03;
573 base_addr = (unsigned char*)
574 (cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index));
575
576 save_flags(flags); cli();
577 base_addr[CyCAR<<index] = (u_char)(channel & 0x0003);
578 base_addr[CySRER<<index] |= CyTxMpty;
579 restore_flags(flags);
580
581 return;
582 }
583
584
585
586
587
588
589
590
591 static inline void
592 cy_sched_event(struct cyclades_port *info, int event)
593 {
594 info->event |= 1 << event;
595 queue_task_irq_off(&info->tqueue, &tq_cyclades);
596 mark_bh(CYCLADES_BH);
597 }
598
599
600 static int probe_ready;
601
602
603
604
605
606 static void
607 cy_probe(int irq, struct pt_regs *regs)
608 {
609 int save_xir, save_car;
610 int index = 0;
611
612 if (!probe_ready)
613 return;
614
615 cy_irq_triggered = irq;
616 cy_triggered |= 1 << irq;
617
618 if(intr_base_addr[CySVRR<<index] != 0) {
619 save_xir = (u_char) intr_base_addr[CyTIR<<index];
620 save_car = intr_base_addr[CyCAR<<index];
621 if ((save_xir & 0x3) != 0){
622 SP("channel ");
623 CP2(save_xir);
624 SP(" requesting unexpected interrupt\n");
625 }
626 intr_base_addr[CyCAR<<index] = (save_xir & 0x3);
627 intr_base_addr[CySRER<<index] &= ~CyTxMpty;
628 intr_base_addr[CyTIR<<index] = (save_xir & 0x3f);
629 intr_base_addr[CyCAR<<index] = (save_car);
630 *(intr_base_addr + (Cy_ClrIntr<<index)) = 0;
631 }
632 return;
633 }
634
635
636
637
638
639 static void
640 cy_interrupt(int irq, struct pt_regs *regs)
641 {
642 struct tty_struct *tty;
643 int status;
644 struct cyclades_card *cinfo;
645 struct cyclades_port *info;
646 volatile unsigned char *base_addr, *card_base_addr;
647 int chip;
648 int save_xir, channel, save_car;
649 char data;
650 int char_count;
651 int outch;
652 int i,j,index;
653 int too_many;
654 int had_work;
655 int mdm_change;
656 int mdm_status;
657
658 if((cinfo = IRQ_cards[irq]) == 0){
659 return;
660 }
661
662 card_base_addr = (unsigned char *)cinfo->base_addr;
663 index = cinfo->bus_index;
664
665
666
667
668
669
670 do{
671 had_work = 0;
672 for ( chip = 0 ; chip < cinfo->num_chips ; chip ++) {
673 base_addr = (unsigned char *)
674 (cinfo->base_addr + (cy_chip_offset[chip]<<index));
675 too_many = 0;
676 while ( (status = base_addr[CySVRR<<index]) != 0x00) {
677 had_work++;
678
679
680
681
682
683 if(1000<too_many++){
684 break;
685 }
686 if (status & CySRReceive) {
687
688 save_xir = (u_char) base_addr[CyRIR<<index];
689 channel = (u_short ) (save_xir & CyIRChannel);
690 i = channel + chip * 4 + cinfo->first_line;
691 info = &cy_port[i];
692 info->last_active = jiffies;
693 save_car = base_addr[CyCAR<<index];
694 base_addr[CyCAR<<index] = save_xir;
695
696
697 if(info->tty == 0){
698 j = (base_addr[CyRIVR<<index] & CyIVRMask);
699 if ( j == CyIVRRxEx ) {
700 data = base_addr[CyRDSR<<index];
701 } else {
702 char_count = base_addr[CyRDCR<<index];
703 while(char_count--){
704 data = base_addr[CyRDSR<<index];
705 }
706 }
707 }else{
708 tty = info->tty;
709 j = (base_addr[CyRIVR<<index] & CyIVRMask);
710 if ( j == CyIVRRxEx ) {
711 data = base_addr[CyRDSR<<index];
712 if(data & info->ignore_status_mask){
713 continue;
714 }
715 if (tty->flip.count < TTY_FLIPBUF_SIZE){
716 tty->flip.count++;
717 if (data & info->read_status_mask){
718 if(data & CyBREAK){
719 *tty->flip.flag_buf_ptr++ =
720 TTY_BREAK;
721 *tty->flip.char_buf_ptr++ =
722 base_addr[CyRDSR<<index];
723 if (info->flags & ASYNC_SAK){
724 do_SAK(tty);
725 }
726 }else if(data & CyFRAME){
727 *tty->flip.flag_buf_ptr++ =
728 TTY_FRAME;
729 *tty->flip.char_buf_ptr++ =
730 base_addr[CyRDSR<<index];
731 }else if(data & CyPARITY){
732 *tty->flip.flag_buf_ptr++ =
733 TTY_PARITY;
734 *tty->flip.char_buf_ptr++ =
735 base_addr[CyRDSR<<index];
736 }else if(data & CyOVERRUN){
737 *tty->flip.flag_buf_ptr++ =
738 TTY_OVERRUN;
739 *tty->flip.char_buf_ptr++ = 0;
740
741
742
743
744 if(tty->flip.count < TTY_FLIPBUF_SIZE){
745 tty->flip.count++;
746 *tty->flip.flag_buf_ptr++ =
747 TTY_NORMAL;
748 *tty->flip.char_buf_ptr++ =
749 base_addr[CyRDSR<<index];
750 }
751
752
753
754
755 }else{
756 *tty->flip.flag_buf_ptr++ = 0;
757 *tty->flip.char_buf_ptr++ = 0;
758 }
759 }else{
760 *tty->flip.flag_buf_ptr++ = 0;
761 *tty->flip.char_buf_ptr++ = 0;
762 }
763 }else{
764
765
766 }
767 } else {
768
769 char_count = base_addr[CyRDCR<<index];
770
771 #ifdef CYCLOM_ENABLE_MONITORING
772 ++info->mon.int_count;
773 info->mon.char_count += char_count;
774 if (char_count > info->mon.char_max)
775 info->mon.char_max = char_count;
776 info->mon.char_last = char_count;
777 #endif
778 while(char_count--){
779 if (tty->flip.count >= TTY_FLIPBUF_SIZE){
780 break;
781 }
782 tty->flip.count++;
783 data = base_addr[CyRDSR<<index];
784 *tty->flip.flag_buf_ptr++ = TTY_NORMAL;
785 *tty->flip.char_buf_ptr++ = data;
786 #ifdef CYCLOM_16Y_HACK
787 udelay(10L);
788 #endif
789 }
790 }
791 queue_task_irq_off(&tty->flip.tqueue, &tq_timer);
792 }
793
794 base_addr[CyRIR<<index] = (save_xir & 0x3f);
795 base_addr[CyCAR<<index] = (save_car);
796 }
797
798
799 if (status & CySRTransmit) {
800
801
802
803
804 save_xir = (u_char) base_addr[CyTIR<<index];
805 channel = (u_short ) (save_xir & CyIRChannel);
806 i = channel + chip * 4 + cinfo->first_line;
807 save_car = base_addr[CyCAR<<index];
808 base_addr[CyCAR<<index] = save_xir;
809
810
811 if( (i < 0) || (NR_PORTS <= i) ){
812 base_addr[CySRER<<index] &= ~CyTxMpty;
813 goto txend;
814 }
815 info = &cy_port[i];
816 info->last_active = jiffies;
817 if(info->tty == 0){
818 base_addr[CySRER<<index] &= ~CyTxMpty;
819 goto txdone;
820 }
821
822
823 char_count = info->xmit_fifo_size;
824
825
826 if(info->x_char) {
827 outch = info->x_char;
828 base_addr[CyTDR<<index] = outch;
829 char_count--;
830 info->x_char = 0;
831 }
832
833 if (info->x_break){
834
835
836
837
838
839
840
841
842 base_addr[CyTDR<<index] = 0;
843 base_addr[CyTDR<<index] = 0x81;
844 base_addr[CyTDR<<index] = 0;
845 base_addr[CyTDR<<index] = 0x82;
846 base_addr[CyTDR<<index] = info->x_break*200/HZ;
847 base_addr[CyTDR<<index] = 0;
848 base_addr[CyTDR<<index] = 0x83;
849 char_count -= 7;
850 info->x_break = 0;
851 }
852
853 while (char_count-- > 0){
854 if (!info->xmit_cnt){
855 base_addr[CySRER<<index] &= ~CyTxMpty;
856 goto txdone;
857 }
858 if (info->xmit_buf == 0){
859 base_addr[CySRER<<index] &= ~CyTxMpty;
860 goto txdone;
861 }
862 if (info->tty->stopped || info->tty->hw_stopped){
863 base_addr[CySRER<<index] &= ~CyTxMpty;
864 goto txdone;
865 }
866
867
868
869
870
871
872
873
874
875
876
877 outch = info->xmit_buf[info->xmit_tail];
878 if( outch ){
879 info->xmit_cnt--;
880 info->xmit_tail = (info->xmit_tail + 1)
881 & (PAGE_SIZE - 1);
882 base_addr[CyTDR<<index] = outch;
883 }else{
884 if(char_count > 1){
885 info->xmit_cnt--;
886 info->xmit_tail = (info->xmit_tail + 1)
887 & (PAGE_SIZE - 1);
888 base_addr[CyTDR<<index] = outch;
889 base_addr[CyTDR<<index] = 0;
890 char_count--;
891 }else{
892 }
893 }
894 }
895
896 txdone:
897 if (info->xmit_cnt < WAKEUP_CHARS) {
898 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
899 }
900
901 txend:
902
903 base_addr[CyTIR<<index] = (save_xir & 0x3f);
904 base_addr[CyCAR<<index] = (save_car);
905 }
906
907 if (status & CySRModem) {
908
909
910 save_xir = (u_char) base_addr[CyMIR<<index];
911 channel = (u_short ) (save_xir & CyIRChannel);
912 info = &cy_port[channel + chip * 4 + cinfo->first_line];
913 info->last_active = jiffies;
914 save_car = base_addr[CyCAR<<index];
915 base_addr[CyCAR<<index] = save_xir;
916
917 mdm_change = base_addr[CyMISR<<index];
918 mdm_status = base_addr[CyMSVR1<<index];
919
920 if(info->tty == 0){
921 ;
922 }else{
923 if((mdm_change & CyDCD)
924 && (info->flags & ASYNC_CHECK_CD)){
925 if(mdm_status & CyDCD){
926
927 cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP);
928 }else if(!((info->flags & ASYNC_CALLOUT_ACTIVE)
929 &&(info->flags & ASYNC_CALLOUT_NOHUP))){
930
931 cy_sched_event(info, Cy_EVENT_HANGUP);
932 }
933 }
934 if((mdm_change & CyCTS)
935 && (info->flags & ASYNC_CTS_FLOW)){
936 if(info->tty->stopped){
937 if(mdm_status & CyCTS){
938
939 info->tty->stopped = 0;
940 base_addr[CySRER<<index] |= CyTxMpty;
941 cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP);
942 }
943 }else{
944 if(!(mdm_status & CyCTS)){
945
946 info->tty->stopped = 1;
947 base_addr[CySRER<<index] &= ~CyTxMpty;
948 }
949 }
950 }
951 if(mdm_status & CyDSR){
952 }
953 if(mdm_status & CyRI){
954 }
955 }
956
957 base_addr[CyMIR<<index] = (save_xir & 0x3f);
958 base_addr[CyCAR<<index] = save_car;
959 }
960 }
961 }
962 } while(had_work);
963
964
965 *(card_base_addr + (Cy_ClrIntr<<index)) = 0;
966
967 }
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991 static void
992 do_cyclades_bh(void *unused)
993 {
994 run_task_queue(&tq_cyclades);
995 }
996
997 static void
998 do_softint(void *private_)
999 {
1000 struct cyclades_port *info = (struct cyclades_port *) private_;
1001 struct tty_struct *tty;
1002
1003 tty = info->tty;
1004 if (!tty)
1005 return;
1006
1007 if (clear_bit(Cy_EVENT_HANGUP, &info->event)) {
1008 tty_hangup(info->tty);
1009 wake_up_interruptible(&info->open_wait);
1010 info->flags &= ~(ASYNC_NORMAL_ACTIVE|
1011 ASYNC_CALLOUT_ACTIVE);
1012 }
1013 if (clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) {
1014 wake_up_interruptible(&info->open_wait);
1015 }
1016 if (clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) {
1017 if((tty->flags & (1<< TTY_DO_WRITE_WAKEUP))
1018 && tty->ldisc.write_wakeup){
1019 (tty->ldisc.write_wakeup)(tty);
1020 }
1021 wake_up_interruptible(&tty->write_wait);
1022 }
1023 }
1024
1025
1026
1027
1028
1029
1030
1031
1032 static int
1033 grab_all_interrupts(int dontgrab)
1034 {
1035 int irq_lines = 0;
1036 int i, mask;
1037
1038 for (i = 0, mask = 1; i < 16; i++, mask <<= 1) {
1039 if (!(mask & dontgrab)
1040 && !request_irq(i, cy_probe, SA_INTERRUPT, "serial probe")) {
1041 irq_lines |= mask;
1042 }
1043 }
1044 return irq_lines;
1045 }
1046
1047
1048
1049
1050 static void
1051 free_all_interrupts(int irq_lines)
1052 {
1053 int i;
1054
1055 for (i = 0; i < 16; i++) {
1056 if (irq_lines & (1 << i))
1057 free_irq(i);
1058 }
1059 }
1060
1061
1062
1063
1064
1065 static int
1066 check_wild_interrupts(void)
1067 {
1068 int i, mask;
1069 int wild_interrupts = 0;
1070 int irq_lines;
1071 unsigned long timeout;
1072 unsigned long flags;
1073
1074
1075 save_flags(flags); sti();
1076
1077 irq_lines = grab_all_interrupts(0);
1078
1079
1080
1081
1082
1083 timeout = jiffies+10;
1084 while (timeout >= jiffies)
1085 ;
1086
1087 cy_triggered = 0;
1088
1089 timeout = jiffies+10;
1090 while (timeout >= jiffies)
1091 ;
1092
1093 for (i = 0, mask = 1; i < 16; i++, mask <<= 1) {
1094 if ((cy_triggered & (1 << i)) &&
1095 (irq_lines & (1 << i))) {
1096 wild_interrupts |= mask;
1097 }
1098 }
1099 free_all_interrupts(irq_lines);
1100 restore_flags(flags);
1101 return wild_interrupts;
1102 }
1103
1104
1105
1106
1107
1108
1109 static int
1110 get_auto_irq(unsigned char *address)
1111 {
1112 unsigned long timeout;
1113 unsigned char *base_addr;
1114 int index;
1115
1116 index = 0;
1117 base_addr = address;
1118 intr_base_addr = address;
1119
1120
1121
1122
1123 cy_irq_triggered = 0;
1124 cli();
1125 base_addr[CyCAR<<index] = 0;
1126 write_cy_cmd(base_addr,CyCHAN_CTL|CyENB_XMTR,index);
1127 base_addr[CySRER<<index] |= CyTxMpty;
1128 probe_ready = 1;
1129 sti();
1130
1131 timeout = jiffies+2;
1132 while (timeout >= jiffies) {
1133 if (cy_irq_triggered)
1134 break;
1135 }
1136 probe_ready = 0;
1137 return(cy_irq_triggered);
1138 }
1139
1140
1141
1142
1143
1144 static int
1145 do_auto_irq(unsigned char *address)
1146 {
1147 int irq_lines = 0;
1148 int irq_try_1 = 0, irq_try_2 = 0;
1149 int retries;
1150 unsigned long flags;
1151
1152
1153 save_flags(flags); sti();
1154
1155 probe_ready = 0;
1156
1157 cy_wild_int_mask = check_wild_interrupts();
1158
1159 irq_lines = grab_all_interrupts(cy_wild_int_mask);
1160
1161 for (retries = 0; retries < 5; retries++) {
1162 if (!irq_try_1)
1163 irq_try_1 = get_auto_irq(address);
1164 if (!irq_try_2)
1165 irq_try_2 = get_auto_irq(address);
1166 if (irq_try_1 && irq_try_2) {
1167 if (irq_try_1 == irq_try_2)
1168 break;
1169 irq_try_1 = irq_try_2 = 0;
1170 }
1171 }
1172 restore_flags(flags);
1173 free_all_interrupts(irq_lines);
1174 return (irq_try_1 == irq_try_2) ? irq_try_1 : 0;
1175 }
1176
1177
1178
1179
1180
1181 static int
1182 startup(struct cyclades_port * info)
1183 {
1184 unsigned long flags;
1185 unsigned char *base_addr;
1186 int card,chip,channel,index;
1187
1188 if (info->flags & ASYNC_INITIALIZED){
1189 return 0;
1190 }
1191
1192 if (!info->type){
1193 if (info->tty){
1194 set_bit(TTY_IO_ERROR, &info->tty->flags);
1195 }
1196 return 0;
1197 }
1198 if (!info->xmit_buf){
1199 info->xmit_buf = (unsigned char *) get_free_page (GFP_KERNEL);
1200 if (!info->xmit_buf){
1201 return -ENOMEM;
1202 }
1203 }
1204
1205 config_setup(info);
1206
1207 card = info->card;
1208 channel = (info->line) - (cy_card[card].first_line);
1209 chip = channel>>2;
1210 channel &= 0x03;
1211 index = cy_card[card].bus_index;
1212 base_addr = (unsigned char*)
1213 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1214
1215 #ifdef SERIAL_DEBUG_OPEN
1216 printk("startup card %d, chip %d, channel %d, base_addr %lx",
1217 card, chip, channel, (long)base_addr);
1218 #endif
1219
1220 save_flags(flags); cli();
1221 base_addr[CyCAR<<index] = (u_char)channel;
1222
1223 base_addr[CyRTPR<<index] = (info->default_timeout
1224 ? info->default_timeout
1225 : 0x02);
1226
1227 write_cy_cmd(base_addr,CyCHAN_CTL|CyENB_RCVR|CyENB_XMTR,index);
1228
1229 base_addr[CyCAR<<index] = (u_char)channel;
1230 base_addr[CyMSVR1<<index] = CyRTS;
1231
1232 base_addr[CyMSVR2<<index] = CyDTR;
1233
1234 #ifdef SERIAL_DEBUG_DTR
1235 printk("cyc: %d: raising DTR\n", __LINE__);
1236 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1237 #endif
1238
1239 base_addr[CySRER<<index] |= CyRxData;
1240 info->flags |= ASYNC_INITIALIZED;
1241
1242 if (info->tty){
1243 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1244 }
1245 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1246
1247 restore_flags(flags);
1248
1249 #ifdef SERIAL_DEBUG_OPEN
1250 printk(" done\n");
1251 #endif
1252 return 0;
1253 }
1254
1255 void
1256 start_xmit( struct cyclades_port *info )
1257 {
1258 unsigned long flags;
1259 unsigned char *base_addr;
1260 int card,chip,channel,index;
1261
1262 card = info->card;
1263 channel = (info->line) - (cy_card[card].first_line);
1264 chip = channel>>2;
1265 channel &= 0x03;
1266 index = cy_card[card].bus_index;
1267 base_addr = (unsigned char*)
1268 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1269
1270 save_flags(flags); cli();
1271 base_addr[CyCAR<<index] = channel;
1272 base_addr[CySRER<<index] |= CyTxMpty;
1273 restore_flags(flags);
1274 }
1275
1276
1277
1278
1279
1280 static void
1281 shutdown(struct cyclades_port * info)
1282 {
1283 unsigned long flags;
1284 unsigned char *base_addr;
1285 int card,chip,channel,index;
1286
1287 if (!(info->flags & ASYNC_INITIALIZED)){
1288
1289 return;
1290 }
1291
1292 card = info->card;
1293 channel = info->line - cy_card[card].first_line;
1294 chip = channel>>2;
1295 channel &= 0x03;
1296 index = cy_card[card].bus_index;
1297 base_addr = (unsigned char*)
1298 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1299
1300 #ifdef SERIAL_DEBUG_OPEN
1301 printk("shutdown card %d, chip %d, channel %d, base_addr %lx\n",
1302 card, chip, channel, (long)base_addr);
1303 #endif
1304
1305
1306
1307
1308
1309
1310
1311 save_flags(flags); cli();
1312 if (info->xmit_buf){
1313 unsigned long temp;
1314 temp = info->xmit_buf;
1315 info->xmit_buf = 0;
1316 free_page((unsigned long) temp);
1317 }
1318
1319 base_addr[CyCAR<<index] = (u_char)channel;
1320 if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) {
1321 base_addr[CyMSVR1<<index] = ~CyRTS;
1322 base_addr[CyMSVR2<<index] = ~CyDTR;
1323 #ifdef SERIAL_DEBUG_DTR
1324 printk("cyc: %d: dropping DTR\n", __LINE__);
1325 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1326 #endif
1327 }
1328 write_cy_cmd(base_addr,CyCHAN_CTL|CyDIS_RCVR,index);
1329
1330
1331
1332 if (info->tty){
1333 set_bit(TTY_IO_ERROR, &info->tty->flags);
1334 }
1335 info->flags &= ~ASYNC_INITIALIZED;
1336 restore_flags(flags);
1337
1338 #ifdef SERIAL_DEBUG_OPEN
1339 printk(" done\n");
1340 #endif
1341 return;
1342 }
1343
1344
1345
1346
1347 static void
1348 config_setup(struct cyclades_port * info)
1349 {
1350 unsigned long flags;
1351 unsigned char *base_addr;
1352 int card,chip,channel,index;
1353 unsigned cflag;
1354 int i;
1355
1356 if (!info->tty || !info->tty->termios){
1357 return;
1358 }
1359 if (info->line == -1){
1360 return;
1361 }
1362 cflag = info->tty->termios->c_cflag;
1363
1364
1365 i = cflag & CBAUD;
1366 #ifdef CBAUDEX
1367
1368
1369
1370
1371
1372
1373
1374
1375 if (i & CBAUDEX) {
1376 if (i == B57600)
1377 i = 16;
1378 else if(i == B115200)
1379 i = 18;
1380 #ifdef B78600
1381 else if(i == B78600)
1382 i = 17;
1383 #endif
1384 else
1385 info->tty->termios->c_cflag &= ~CBAUDEX;
1386 }
1387 #endif
1388 if (i == 15) {
1389 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI)
1390 i += 1;
1391 if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI)
1392 i += 3;
1393 }
1394 info->tbpr = baud_bpr[i];
1395 info->tco = baud_co[i];
1396 info->rbpr = baud_bpr[i];
1397 info->rco = baud_co[i];
1398 if (baud_table[i] == 134) {
1399 info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2;
1400
1401 } else if (baud_table[i]) {
1402 info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2;
1403
1404 } else {
1405 info->timeout = 0;
1406 }
1407
1408
1409
1410
1411
1412 info->cor5 = 0;
1413 info->cor4 = 0;
1414 info->cor3 = (info->default_threshold
1415 ? info->default_threshold
1416 : baud_cor3[i]);
1417 info->cor2 = CyETC;
1418 switch(cflag & CSIZE){
1419 case CS5:
1420 info->cor1 = Cy_5_BITS;
1421 break;
1422 case CS6:
1423 info->cor1 = Cy_6_BITS;
1424 break;
1425 case CS7:
1426 info->cor1 = Cy_7_BITS;
1427 break;
1428 case CS8:
1429 info->cor1 = Cy_8_BITS;
1430 break;
1431 }
1432 if(cflag & CSTOPB){
1433 info->cor1 |= Cy_2_STOP;
1434 }
1435 if (cflag & PARENB){
1436 if (cflag & PARODD){
1437 info->cor1 |= CyPARITY_O;
1438 }else{
1439 info->cor1 |= CyPARITY_E;
1440 }
1441 }else{
1442 info->cor1 |= CyPARITY_NONE;
1443 }
1444
1445
1446 if (cflag & CRTSCTS){
1447 info->flags |= ASYNC_CTS_FLOW;
1448 info->cor2 |= CyCtsAE;
1449 }else{
1450 info->flags &= ~ASYNC_CTS_FLOW;
1451 info->cor2 &= ~CyCtsAE;
1452 }
1453 if (cflag & CLOCAL)
1454 info->flags &= ~ASYNC_CHECK_CD;
1455 else
1456 info->flags |= ASYNC_CHECK_CD;
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468 card = info->card;
1469 channel = (info->line) - (cy_card[card].first_line);
1470 chip = channel>>2;
1471 channel &= 0x03;
1472 index = cy_card[card].bus_index;
1473 base_addr = (unsigned char*)
1474 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1475
1476 save_flags(flags); cli();
1477 base_addr[CyCAR<<index] = (u_char)channel;
1478
1479
1480
1481 base_addr[CyTCOR<<index] = info->tco;
1482 base_addr[CyTBPR<<index] = info->tbpr;
1483 base_addr[CyRCOR<<index] = info->rco;
1484 base_addr[CyRBPR<<index] = info->rbpr;
1485
1486
1487
1488 base_addr[CySCHR1<<index] = START_CHAR(info->tty);
1489 base_addr[CySCHR2<<index] = STOP_CHAR(info->tty);
1490 base_addr[CyCOR1<<index] = info->cor1;
1491 base_addr[CyCOR2<<index] = info->cor2;
1492 base_addr[CyCOR3<<index] = info->cor3;
1493 base_addr[CyCOR4<<index] = info->cor4;
1494 base_addr[CyCOR5<<index] = info->cor5;
1495
1496 write_cy_cmd(base_addr,CyCOR_CHANGE|CyCOR1ch|CyCOR2ch|CyCOR3ch,index);
1497
1498 base_addr[CyCAR<<index] = (u_char)channel;
1499
1500 base_addr[CyRTPR<<index] = (info->default_timeout
1501 ? info->default_timeout
1502 : 0x02);
1503
1504 if (C_CLOCAL(info->tty)) {
1505 base_addr[CySRER<<index] |= 0;
1506
1507 base_addr[CyMCOR1<<index] = 0x0;
1508
1509 base_addr[CyMCOR2<<index] = 0x0;
1510 } else {
1511 base_addr[CySRER<<index] |= CyMdmCh;
1512
1513 base_addr[CyMCOR1<<index] = CyDSR|CyCTS|CyRI|CyDCD;
1514
1515 base_addr[CyMCOR2<<index] = CyDSR|CyCTS|CyRI|CyDCD;
1516 }
1517
1518 if(i == 0){
1519 base_addr[CyMSVR2<<index] = ~CyDTR;
1520 #ifdef SERIAL_DEBUG_DTR
1521 printk("cyc: %d: dropping DTR\n", __LINE__);
1522 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1523 #endif
1524 }else{
1525 base_addr[CyMSVR2<<index] = CyDTR;
1526 #ifdef SERIAL_DEBUG_DTR
1527 printk("cyc: %d: raising DTR\n", __LINE__);
1528 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1529 #endif
1530 }
1531
1532 if (info->tty){
1533 clear_bit(TTY_IO_ERROR, &info->tty->flags);
1534 }
1535
1536 restore_flags(flags);
1537
1538 }
1539
1540
1541 static void
1542 cy_put_char(struct tty_struct *tty, unsigned char ch)
1543 {
1544 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1545 unsigned long flags;
1546
1547 #ifdef SERIAL_DEBUG_IO
1548 printk("cy_put_char ttyC%d\n", info->line);
1549 #endif
1550
1551 if (serial_paranoia_check(info, tty->device, "cy_put_char"))
1552 return;
1553
1554 if (!tty || !info->xmit_buf)
1555 return;
1556
1557 save_flags(flags); cli();
1558 if (info->xmit_cnt >= PAGE_SIZE - 1) {
1559 restore_flags(flags);
1560 return;
1561 }
1562
1563 info->xmit_buf[info->xmit_head++] = ch;
1564 info->xmit_head &= PAGE_SIZE - 1;
1565 info->xmit_cnt++;
1566 restore_flags(flags);
1567 }
1568
1569
1570 static void
1571 cy_flush_chars(struct tty_struct *tty)
1572 {
1573 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1574 unsigned long flags;
1575 unsigned char *base_addr;
1576 int card,chip,channel,index;
1577
1578 #ifdef SERIAL_DEBUG_IO
1579 printk("cy_flush_chars ttyC%d\n", info->line);
1580 #endif
1581
1582 if (serial_paranoia_check(info, tty->device, "cy_flush_chars"))
1583 return;
1584
1585 if (info->xmit_cnt <= 0 || tty->stopped
1586 || tty->hw_stopped || !info->xmit_buf)
1587 return;
1588
1589 card = info->card;
1590 channel = info->line - cy_card[card].first_line;
1591 chip = channel>>2;
1592 channel &= 0x03;
1593 index = cy_card[card].bus_index;
1594 base_addr = (unsigned char*)
1595 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1596
1597 save_flags(flags); cli();
1598 base_addr[CyCAR<<index] = channel;
1599 base_addr[CySRER<<index] |= CyTxMpty;
1600 restore_flags(flags);
1601 }
1602
1603
1604
1605
1606
1607
1608
1609
1610 static int
1611 cy_write(struct tty_struct * tty, int from_user,
1612 const unsigned char *buf, int count)
1613 {
1614 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1615 unsigned long flags;
1616 int c, total = 0;
1617
1618 #ifdef SERIAL_DEBUG_IO
1619 printk("cy_write ttyC%d\n", info->line);
1620 #endif
1621
1622 if (serial_paranoia_check(info, tty->device, "cy_write")){
1623 return 0;
1624 }
1625
1626 if (!tty || !info->xmit_buf || !tmp_buf){
1627 return 0;
1628 }
1629
1630 while (1) {
1631 save_flags(flags); cli();
1632 c = MIN(count, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1633 SERIAL_XMIT_SIZE - info->xmit_head));
1634 if (c <= 0){
1635 restore_flags(flags);
1636 break;
1637 }
1638
1639 if (from_user) {
1640 down(&tmp_buf_sem);
1641 memcpy_fromfs(tmp_buf, buf, c);
1642 c = MIN(c, MIN(SERIAL_XMIT_SIZE - info->xmit_cnt - 1,
1643 SERIAL_XMIT_SIZE - info->xmit_head));
1644 memcpy(info->xmit_buf + info->xmit_head, tmp_buf, c);
1645 up(&tmp_buf_sem);
1646 } else
1647 memcpy(info->xmit_buf + info->xmit_head, buf, c);
1648 info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1);
1649 info->xmit_cnt += c;
1650 restore_flags(flags);
1651 buf += c;
1652 count -= c;
1653 total += c;
1654 }
1655
1656
1657 if (info->xmit_cnt
1658 && !tty->stopped
1659 && !tty->hw_stopped ) {
1660 start_xmit(info);
1661 }
1662 return total;
1663 }
1664
1665
1666 static int
1667 cy_write_room(struct tty_struct *tty)
1668 {
1669 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1670 int ret;
1671
1672 #ifdef SERIAL_DEBUG_IO
1673 printk("cy_write_room ttyC%d\n", info->line);
1674 #endif
1675
1676 if (serial_paranoia_check(info, tty->device, "cy_write_room"))
1677 return 0;
1678 ret = PAGE_SIZE - info->xmit_cnt - 1;
1679 if (ret < 0)
1680 ret = 0;
1681 return ret;
1682 }
1683
1684
1685 static int
1686 cy_chars_in_buffer(struct tty_struct *tty)
1687 {
1688 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1689
1690 #ifdef SERIAL_DEBUG_IO
1691 printk("cy_chars_in_buffer ttyC%d %d\n", info->line, info->xmit_cnt);
1692 #endif
1693
1694 if (serial_paranoia_check(info, tty->device, "cy_chars_in_buffer"))
1695 return 0;
1696
1697 return info->xmit_cnt;
1698 }
1699
1700
1701 static void
1702 cy_flush_buffer(struct tty_struct *tty)
1703 {
1704 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1705 unsigned long flags;
1706
1707 #ifdef SERIAL_DEBUG_IO
1708 printk("cy_flush_buffer ttyC%d\n", info->line);
1709 #endif
1710
1711 if (serial_paranoia_check(info, tty->device, "cy_flush_buffer"))
1712 return;
1713 save_flags(flags); cli();
1714 info->xmit_cnt = info->xmit_head = info->xmit_tail = 0;
1715 restore_flags(flags);
1716 wake_up_interruptible(&tty->write_wait);
1717 if ((tty->flags & (1 << TTY_DO_WRITE_WAKEUP))
1718 && tty->ldisc.write_wakeup)
1719 (tty->ldisc.write_wakeup)(tty);
1720 }
1721
1722
1723
1724
1725
1726
1727 static void
1728 cy_throttle(struct tty_struct * tty)
1729 {
1730 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1731 unsigned long flags;
1732 unsigned char *base_addr;
1733 int card,chip,channel,index;
1734
1735 #ifdef SERIAL_DEBUG_THROTTLE
1736 char buf[64];
1737
1738 printk("throttle %s: %d....\n", _tty_name(tty, buf),
1739 tty->ldisc.chars_in_buffer(tty));
1740 printk("cy_throttle ttyC%d\n", info->line);
1741 #endif
1742
1743 if (serial_paranoia_check(info, tty->device, "cy_nthrottle")){
1744 return;
1745 }
1746
1747 if (I_IXOFF(tty)) {
1748 info->x_char = STOP_CHAR(tty);
1749
1750 }
1751
1752 card = info->card;
1753 channel = info->line - cy_card[card].first_line;
1754 chip = channel>>2;
1755 channel &= 0x03;
1756 index = cy_card[card].bus_index;
1757 base_addr = (unsigned char*)
1758 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1759
1760 save_flags(flags); cli();
1761 base_addr[CyCAR<<index] = (u_char)channel;
1762 base_addr[CyMSVR1<<index] = ~CyRTS;
1763 restore_flags(flags);
1764
1765 return;
1766 }
1767
1768
1769 static void
1770 cy_unthrottle(struct tty_struct * tty)
1771 {
1772 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
1773 unsigned long flags;
1774 unsigned char *base_addr;
1775 int card,chip,channel,index;
1776
1777 #ifdef SERIAL_DEBUG_THROTTLE
1778 char buf[64];
1779
1780 printk("throttle %s: %d....\n", _tty_name(tty, buf),
1781 tty->ldisc.chars_in_buffer(tty));
1782 printk("cy_unthrottle ttyC%d\n", info->line);
1783 #endif
1784
1785 if (serial_paranoia_check(info, tty->device, "cy_nthrottle")){
1786 return;
1787 }
1788
1789 if (I_IXOFF(tty)) {
1790 info->x_char = START_CHAR(tty);
1791
1792 }
1793
1794 card = info->card;
1795 channel = info->line - cy_card[card].first_line;
1796 chip = channel>>2;
1797 channel &= 0x03;
1798 index = cy_card[card].bus_index;
1799 base_addr = (unsigned char*)
1800 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1801
1802 save_flags(flags); cli();
1803 base_addr[CyCAR<<index] = (u_char)channel;
1804 base_addr[CyMSVR1<<index] = CyRTS;
1805 restore_flags(flags);
1806
1807 return;
1808 }
1809
1810 static int
1811 get_serial_info(struct cyclades_port * info,
1812 struct serial_struct * retinfo)
1813 {
1814 struct serial_struct tmp;
1815 struct cyclades_card *cinfo = &cy_card[info->card];
1816
1817
1818 if (!retinfo)
1819 return -EFAULT;
1820 memset(&tmp, 0, sizeof(tmp));
1821 tmp.type = info->type;
1822 tmp.line = info->line;
1823 tmp.port = info->card * 0x100 + info->line - cinfo->first_line;
1824 tmp.irq = cinfo->irq;
1825 tmp.flags = info->flags;
1826 tmp.baud_base = 0;
1827 tmp.close_delay = info->close_delay;
1828 tmp.custom_divisor = 0;
1829 tmp.hub6 = 0;
1830 memcpy_tofs(retinfo,&tmp,sizeof(*retinfo));
1831 return 0;
1832 }
1833
1834 static int
1835 set_serial_info(struct cyclades_port * info,
1836 struct serial_struct * new_info)
1837 {
1838 struct serial_struct new_serial;
1839 struct cyclades_port old_info;
1840
1841
1842 if (!new_info)
1843 return -EFAULT;
1844 memcpy_fromfs(&new_serial,new_info,sizeof(new_serial));
1845 old_info = *info;
1846
1847 if (!suser()) {
1848 if ((new_serial.close_delay != info->close_delay) ||
1849 ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) !=
1850 (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)))
1851 return -EPERM;
1852 info->flags = ((info->flags & ~ASYNC_USR_MASK) |
1853 (new_serial.flags & ASYNC_USR_MASK));
1854 goto check_and_exit;
1855 }
1856
1857
1858
1859
1860
1861
1862
1863 info->flags = ((info->flags & ~ASYNC_FLAGS) |
1864 (new_serial.flags & ASYNC_FLAGS));
1865 info->close_delay = new_serial.close_delay;
1866
1867
1868 check_and_exit:
1869 if (info->flags & ASYNC_INITIALIZED){
1870 config_setup(info);
1871 return 0;
1872 }else{
1873 return startup(info);
1874 }
1875 }
1876
1877 static int
1878 get_modem_info(struct cyclades_port * info, unsigned int *value)
1879 {
1880 int card,chip,channel,index;
1881 unsigned char *base_addr;
1882 unsigned long flags;
1883 unsigned char status;
1884 unsigned int result;
1885
1886 card = info->card;
1887 channel = (info->line) - (cy_card[card].first_line);
1888 chip = channel>>2;
1889 channel &= 0x03;
1890 index = cy_card[card].bus_index;
1891 base_addr = (unsigned char*)
1892 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1893
1894 save_flags(flags); cli();
1895 base_addr[CyCAR<<index] = (u_char)channel;
1896 status = base_addr[CyMSVR1<<index];
1897 status |= base_addr[CyMSVR2<<index];
1898 restore_flags(flags);
1899
1900 result = ((status & CyRTS) ? TIOCM_RTS : 0)
1901 | ((status & CyDTR) ? TIOCM_DTR : 0)
1902 | ((status & CyDCD) ? TIOCM_CAR : 0)
1903 | ((status & CyRI) ? TIOCM_RNG : 0)
1904 | ((status & CyDSR) ? TIOCM_DSR : 0)
1905 | ((status & CyCTS) ? TIOCM_CTS : 0);
1906 put_fs_long(result,(unsigned long *) value);
1907 return 0;
1908 }
1909
1910 static int
1911 set_modem_info(struct cyclades_port * info, unsigned int cmd,
1912 unsigned int *value)
1913 {
1914 int card,chip,channel,index;
1915 unsigned char *base_addr;
1916 unsigned long flags;
1917 unsigned int arg = get_fs_long((unsigned long *) value);
1918
1919 card = info->card;
1920 channel = (info->line) - (cy_card[card].first_line);
1921 chip = channel>>2;
1922 channel &= 0x03;
1923 index = cy_card[card].bus_index;
1924 base_addr = (unsigned char*)
1925 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
1926
1927 switch (cmd) {
1928 case TIOCMBIS:
1929 if (arg & TIOCM_RTS){
1930 save_flags(flags); cli();
1931 base_addr[CyCAR<<index] = (u_char)channel;
1932 base_addr[CyMSVR1<<index] = CyRTS;
1933 restore_flags(flags);
1934 }
1935 if (arg & TIOCM_DTR){
1936 save_flags(flags); cli();
1937 base_addr[CyCAR<<index] = (u_char)channel;
1938
1939 base_addr[CyMSVR2<<index] = CyDTR;
1940 #ifdef SERIAL_DEBUG_DTR
1941 printk("cyc: %d: raising DTR\n", __LINE__);
1942 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1943 #endif
1944 restore_flags(flags);
1945 }
1946 break;
1947 case TIOCMBIC:
1948 if (arg & TIOCM_RTS){
1949 save_flags(flags); cli();
1950 base_addr[CyCAR<<index] = (u_char)channel;
1951 base_addr[CyMSVR1<<index] = ~CyRTS;
1952 restore_flags(flags);
1953 }
1954 if (arg & TIOCM_DTR){
1955 save_flags(flags); cli();
1956 base_addr[CyCAR<<index] = (u_char)channel;
1957
1958 base_addr[CyMSVR2<<index] = ~CyDTR;
1959 #ifdef SERIAL_DEBUG_DTR
1960 printk("cyc: %d: dropping DTR\n", __LINE__);
1961 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1962 #endif
1963 restore_flags(flags);
1964 }
1965 break;
1966 case TIOCMSET:
1967 if (arg & TIOCM_RTS){
1968 save_flags(flags); cli();
1969 base_addr[CyCAR<<index] = (u_char)channel;
1970 base_addr[CyMSVR1<<index] = CyRTS;
1971 restore_flags(flags);
1972 }else{
1973 save_flags(flags); cli();
1974 base_addr[CyCAR<<index] = (u_char)channel;
1975 base_addr[CyMSVR1<<index] = ~CyRTS;
1976 restore_flags(flags);
1977 }
1978 if (arg & TIOCM_DTR){
1979 save_flags(flags); cli();
1980 base_addr[CyCAR<<index] = (u_char)channel;
1981
1982 base_addr[CyMSVR2<<index] = CyDTR;
1983 #ifdef SERIAL_DEBUG_DTR
1984 printk("cyc: %d: raising DTR\n", __LINE__);
1985 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1986 #endif
1987 restore_flags(flags);
1988 }else{
1989 save_flags(flags); cli();
1990 base_addr[CyCAR<<index] = (u_char)channel;
1991
1992 base_addr[CyMSVR2<<index] = ~CyDTR;
1993 #ifdef SERIAL_DEBUG_DTR
1994 printk("cyc: %d: dropping DTR\n", __LINE__);
1995 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
1996 #endif
1997 restore_flags(flags);
1998 }
1999 break;
2000 default:
2001 return -EINVAL;
2002 }
2003 return 0;
2004 }
2005
2006 static void
2007 send_break( struct cyclades_port * info, int duration)
2008 {
2009
2010
2011 info->x_break = duration;
2012 if (!info->xmit_cnt ) {
2013 start_xmit(info);
2014 }
2015 }
2016
2017 static int
2018 get_mon_info(struct cyclades_port * info, struct cyclades_monitor * mon)
2019 {
2020
2021 memcpy_tofs(mon, &info->mon, sizeof(struct cyclades_monitor));
2022 info->mon.int_count = 0;
2023 info->mon.char_count = 0;
2024 info->mon.char_max = 0;
2025 info->mon.char_last = 0;
2026 return 0;
2027 }
2028
2029 static int
2030 set_threshold(struct cyclades_port * info, unsigned long value)
2031 {
2032 unsigned char *base_addr;
2033 int card,channel,chip,index;
2034
2035 card = info->card;
2036 channel = info->line - cy_card[card].first_line;
2037 chip = channel>>2;
2038 channel &= 0x03;
2039 index = cy_card[card].bus_index;
2040 base_addr = (unsigned char*)
2041 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
2042
2043 info->cor3 &= ~CyREC_FIFO;
2044 info->cor3 |= value & CyREC_FIFO;
2045 base_addr[CyCOR3<<index] = info->cor3;
2046 write_cy_cmd(base_addr,CyCOR_CHANGE|CyCOR3ch,index);
2047 return 0;
2048 }
2049
2050 static int
2051 get_threshold(struct cyclades_port * info, unsigned long *value)
2052 {
2053 unsigned char *base_addr;
2054 int card,channel,chip,index;
2055 unsigned long tmp;
2056
2057 card = info->card;
2058 channel = info->line - cy_card[card].first_line;
2059 chip = channel>>2;
2060 channel &= 0x03;
2061 index = cy_card[card].bus_index;
2062 base_addr = (unsigned char*)
2063 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
2064
2065 tmp = base_addr[CyCOR3<<index] & CyREC_FIFO;
2066 put_fs_long(tmp,value);
2067 return 0;
2068 }
2069
2070 static int
2071 set_default_threshold(struct cyclades_port * info, unsigned long value)
2072 {
2073 info->default_threshold = value & 0x0f;
2074 return 0;
2075 }
2076
2077 static int
2078 get_default_threshold(struct cyclades_port * info, unsigned long *value)
2079 {
2080 put_fs_long(info->default_threshold,value);
2081 return 0;
2082 }
2083
2084 static int
2085 set_timeout(struct cyclades_port * info, unsigned long value)
2086 {
2087 unsigned char *base_addr;
2088 int card,channel,chip,index;
2089
2090 card = info->card;
2091 channel = info->line - cy_card[card].first_line;
2092 chip = channel>>2;
2093 channel &= 0x03;
2094 index = cy_card[card].bus_index;
2095 base_addr = (unsigned char*)
2096 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
2097
2098 base_addr[CyRTPR<<index] = value & 0xff;
2099 return 0;
2100 }
2101
2102 static int
2103 get_timeout(struct cyclades_port * info, unsigned long *value)
2104 {
2105 unsigned char *base_addr;
2106 int card,channel,chip,index;
2107 unsigned long tmp;
2108
2109 card = info->card;
2110 channel = info->line - cy_card[card].first_line;
2111 chip = channel>>2;
2112 channel &= 0x03;
2113 index = cy_card[card].bus_index;
2114 base_addr = (unsigned char*)
2115 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
2116
2117 tmp = base_addr[CyRTPR<<index];
2118 put_fs_long(tmp,value);
2119 return 0;
2120 }
2121
2122 static int
2123 set_default_timeout(struct cyclades_port * info, unsigned long value)
2124 {
2125 info->default_timeout = value & 0xff;
2126 return 0;
2127 }
2128
2129 static int
2130 get_default_timeout(struct cyclades_port * info, unsigned long *value)
2131 {
2132 put_fs_long(info->default_timeout,value);
2133 return 0;
2134 }
2135
2136 static int
2137 cy_ioctl(struct tty_struct *tty, struct file * file,
2138 unsigned int cmd, unsigned long arg)
2139 {
2140 int error;
2141 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
2142 int ret_val = 0;
2143
2144 #ifdef SERIAL_DEBUG_OTHER
2145 printk("cy_ioctl ttyC%d, cmd = %x arg = %lx\n", info->line, cmd, arg);
2146 #endif
2147
2148 switch (cmd) {
2149 case CYGETMON:
2150 error = verify_area(VERIFY_WRITE, (void *) arg
2151 ,sizeof(struct cyclades_monitor));
2152 if (error){
2153 ret_val = error;
2154 break;
2155 }
2156 ret_val = get_mon_info(info, (struct cyclades_monitor *)arg);
2157 break;
2158 case CYGETTHRESH:
2159 error = verify_area(VERIFY_WRITE, (void *) arg
2160 ,sizeof(unsigned long));
2161 if (error){
2162 ret_val = error;
2163 break;
2164 }
2165 ret_val = get_threshold(info, (unsigned long *)arg);
2166 break;
2167 case CYSETTHRESH:
2168 ret_val = set_threshold(info, (unsigned long)arg);
2169 break;
2170 case CYGETDEFTHRESH:
2171 error = verify_area(VERIFY_WRITE, (void *) arg
2172 ,sizeof(unsigned long));
2173 if (error){
2174 ret_val = error;
2175 break;
2176 }
2177 ret_val = get_default_threshold(info, (unsigned long *)arg);
2178 break;
2179 case CYSETDEFTHRESH:
2180 ret_val = set_default_threshold(info, (unsigned long)arg);
2181 break;
2182 case CYGETTIMEOUT:
2183 error = verify_area(VERIFY_WRITE, (void *) arg
2184 ,sizeof(unsigned long));
2185 if (error){
2186 ret_val = error;
2187 break;
2188 }
2189 ret_val = get_timeout(info, (unsigned long *)arg);
2190 break;
2191 case CYSETTIMEOUT:
2192 ret_val = set_timeout(info, (unsigned long)arg);
2193 break;
2194 case CYGETDEFTIMEOUT:
2195 error = verify_area(VERIFY_WRITE, (void *) arg
2196 ,sizeof(unsigned long));
2197 if (error){
2198 ret_val = error;
2199 break;
2200 }
2201 ret_val = get_default_timeout(info, (unsigned long *)arg);
2202 break;
2203 case CYSETDEFTIMEOUT:
2204 ret_val = set_default_timeout(info, (unsigned long)arg);
2205 break;
2206 case TCSBRK:
2207 ret_val = tty_check_change(tty);
2208 if (ret_val)
2209 return ret_val;
2210 tty_wait_until_sent(tty,0);
2211 if (!arg)
2212 send_break(info, HZ/4);
2213 break;
2214 case TCSBRKP:
2215 ret_val = tty_check_change(tty);
2216 if (ret_val)
2217 return ret_val;
2218 tty_wait_until_sent(tty,0);
2219 send_break(info, arg ? arg*(HZ/10) : HZ/4);
2220 break;
2221 case TIOCMBIS:
2222 case TIOCMBIC:
2223 case TIOCMSET:
2224 ret_val = set_modem_info(info, cmd, (unsigned int *) arg);
2225 break;
2226
2227
2228 case TIOCGSOFTCAR:
2229 error = verify_area(VERIFY_WRITE, (void *) arg
2230 ,sizeof(unsigned int *));
2231 if (error){
2232 ret_val = error;
2233 break;
2234 }
2235 put_fs_long(C_CLOCAL(tty) ? 1 : 0,
2236 (unsigned long *) arg);
2237 break;
2238 case TIOCSSOFTCAR:
2239 arg = get_fs_long((unsigned long *) arg);
2240 tty->termios->c_cflag =
2241 ((tty->termios->c_cflag & ~CLOCAL) |
2242 (arg ? CLOCAL : 0));
2243 break;
2244 case TIOCMGET:
2245 error = verify_area(VERIFY_WRITE, (void *) arg
2246 ,sizeof(unsigned int *));
2247 if (error){
2248 ret_val = error;
2249 break;
2250 }
2251 ret_val = get_modem_info(info, (unsigned int *) arg);
2252 break;
2253 case TIOCGSERIAL:
2254 error = verify_area(VERIFY_WRITE, (void *) arg
2255 ,sizeof(struct serial_struct));
2256 if (error){
2257 ret_val = error;
2258 break;
2259 }
2260 ret_val = get_serial_info(info,
2261 (struct serial_struct *) arg);
2262 break;
2263 case TIOCSSERIAL:
2264 ret_val = set_serial_info(info,
2265 (struct serial_struct *) arg);
2266 break;
2267 default:
2268 ret_val = -ENOIOCTLCMD;
2269 }
2270
2271 #ifdef SERIAL_DEBUG_OTHER
2272 printk("cy_ioctl done\n");
2273 #endif
2274
2275 return ret_val;
2276 }
2277
2278
2279
2280
2281 static void
2282 cy_set_termios(struct tty_struct *tty, struct termios * old_termios)
2283 {
2284 struct cyclades_port *info = (struct cyclades_port *)tty->driver_data;
2285
2286 #ifdef SERIAL_DEBUG_OTHER
2287 printk("cy_set_termios ttyC%d\n", info->line);
2288 #endif
2289
2290 if (tty->termios->c_cflag == old_termios->c_cflag)
2291 return;
2292 config_setup(info);
2293
2294 if ((old_termios->c_cflag & CRTSCTS) &&
2295 !(tty->termios->c_cflag & CRTSCTS)) {
2296 tty->stopped = 0;
2297 cy_start(tty);
2298 }
2299 #ifdef tytso_patch_94Nov25_1726
2300 if (!(old_termios->c_cflag & CLOCAL) &&
2301 (tty->termios->c_cflag & CLOCAL))
2302 wake_up_interruptible(&info->open_wait);
2303 #endif
2304
2305 return;
2306 }
2307
2308
2309 static void
2310 cy_close(struct tty_struct * tty, struct file * filp)
2311 {
2312 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
2313 unsigned long flags;
2314
2315
2316 #ifdef SERIAL_DEBUG_OTHER
2317 printk("cy_close ttyC%d\n", info->line);
2318 #endif
2319
2320 if (!info
2321 || serial_paranoia_check(info, tty->device, "cy_close")){
2322 return;
2323 }
2324 #ifdef SERIAL_DEBUG_OPEN
2325 printk("cy_close ttyC%d, count = %d\n", info->line, info->count);
2326 #endif
2327
2328 save_flags(flags); cli();
2329
2330
2331 if (tty_hung_up_p(filp)) {
2332 restore_flags(flags);
2333 return;
2334 }
2335
2336 if ((tty->count == 1) && (info->count != 1)) {
2337
2338
2339
2340
2341
2342
2343
2344 printk("cy_close: bad serial port count; tty->count is 1, "
2345 "info->count is %d\n", info->count);
2346 info->count = 1;
2347 }
2348 #ifdef SERIAL_DEBUG_COUNT
2349 printk("cyc: %d(%d): decrementing count to %d\n", __LINE__, current->pid, info->count - 1);
2350 #endif
2351 if (--info->count < 0) {
2352 #ifdef SERIAL_DEBUG_COUNT
2353 printk("cyc: %d: setting count to 0\n", __LINE__);
2354 #endif
2355 info->count = 0;
2356 }
2357 if (info->count)
2358 {
2359 MOD_DEC_USE_COUNT;
2360 restore_flags(flags);
2361 return;
2362 }
2363 info->flags |= ASYNC_CLOSING;
2364
2365
2366
2367
2368 if (info->flags & ASYNC_NORMAL_ACTIVE)
2369 info->normal_termios = *tty->termios;
2370 if (info->flags & ASYNC_CALLOUT_ACTIVE)
2371 info->callout_termios = *tty->termios;
2372 if (info->flags & ASYNC_INITIALIZED)
2373 tty_wait_until_sent(tty, 3000);
2374 shutdown(info);
2375 if (tty->driver.flush_buffer)
2376 tty->driver.flush_buffer(tty);
2377 if (tty->ldisc.flush_buffer)
2378 tty->ldisc.flush_buffer(tty);
2379 info->event = 0;
2380 info->tty = 0;
2381 if (info->blocked_open) {
2382 if (info->close_delay) {
2383 current->state = TASK_INTERRUPTIBLE;
2384 current->timeout = jiffies + info->close_delay;
2385 schedule();
2386 }
2387 wake_up_interruptible(&info->open_wait);
2388 }
2389 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE|
2390 ASYNC_CLOSING);
2391 wake_up_interruptible(&info->close_wait);
2392
2393 #ifdef SERIAL_DEBUG_OTHER
2394 printk("cy_close done\n");
2395 #endif
2396
2397 MOD_DEC_USE_COUNT;
2398 restore_flags(flags);
2399 return;
2400 }
2401
2402
2403
2404
2405 void
2406 cy_hangup(struct tty_struct *tty)
2407 {
2408 struct cyclades_port * info = (struct cyclades_port *)tty->driver_data;
2409
2410 #ifdef SERIAL_DEBUG_OTHER
2411 printk("cy_hangup ttyC%d\n", info->line);
2412 #endif
2413
2414 if (serial_paranoia_check(info, tty->device, "cy_hangup"))
2415 return;
2416
2417 shutdown(info);
2418 info->event = 0;
2419 info->count = 0;
2420 #ifdef SERIAL_DEBUG_COUNT
2421 printk("cyc: %d(%d): setting count to 0\n", __LINE__, current->pid);
2422 #endif
2423 info->tty = 0;
2424 info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CALLOUT_ACTIVE);
2425 wake_up_interruptible(&info->open_wait);
2426 }
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436 static int
2437 block_til_ready(struct tty_struct *tty, struct file * filp,
2438 struct cyclades_port *info)
2439 {
2440 struct wait_queue wait = { current, NULL };
2441 struct cyclades_card *cinfo;
2442 unsigned long flags;
2443 int chip, channel,index;
2444 int retval;
2445 char *base_addr;
2446
2447
2448
2449
2450
2451 if (info->flags & ASYNC_CLOSING) {
2452 interruptible_sleep_on(&info->close_wait);
2453 if (info->flags & ASYNC_HUP_NOTIFY){
2454 return -EAGAIN;
2455 }else{
2456 return -ERESTARTSYS;
2457 }
2458 }
2459
2460
2461
2462
2463
2464 if (tty->driver.subtype == SERIAL_TYPE_CALLOUT) {
2465 if (info->flags & ASYNC_NORMAL_ACTIVE){
2466 return -EBUSY;
2467 }
2468 if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
2469 (info->flags & ASYNC_SESSION_LOCKOUT) &&
2470 (info->session != current->session)){
2471 return -EBUSY;
2472 }
2473 if ((info->flags & ASYNC_CALLOUT_ACTIVE) &&
2474 (info->flags & ASYNC_PGRP_LOCKOUT) &&
2475 (info->pgrp != current->pgrp)){
2476 return -EBUSY;
2477 }
2478 info->flags |= ASYNC_CALLOUT_ACTIVE;
2479 return 0;
2480 }
2481
2482
2483
2484
2485
2486 if (filp->f_flags & O_NONBLOCK) {
2487 if (info->flags & ASYNC_CALLOUT_ACTIVE){
2488 return -EBUSY;
2489 }
2490 info->flags |= ASYNC_NORMAL_ACTIVE;
2491 return 0;
2492 }
2493
2494
2495
2496
2497
2498
2499
2500
2501 retval = 0;
2502 add_wait_queue(&info->open_wait, &wait);
2503 #ifdef SERIAL_DEBUG_OPEN
2504 printk("block_til_ready before block: ttyC%d, count = %d\n",
2505 info->line, info->count);
2506 #endif
2507 info->count--;
2508 #ifdef SERIAL_DEBUG_COUNT
2509 printk("cyc: %d(%d): decrementing count to %d\n", __LINE__, current->pid, info->count);
2510 #endif
2511 info->blocked_open++;
2512
2513 cinfo = &cy_card[info->card];
2514 channel = info->line - cinfo->first_line;
2515 chip = channel>>2;
2516 channel &= 0x03;
2517 index = cinfo->bus_index;
2518 base_addr = (char *) (cinfo->base_addr + (cy_chip_offset[chip]<<index));
2519
2520 while (1) {
2521 save_flags(flags); cli();
2522 if (!(info->flags & ASYNC_CALLOUT_ACTIVE)){
2523 base_addr[CyCAR<<index] = (u_char)channel;
2524 base_addr[CyMSVR1<<index] = CyRTS;
2525
2526 base_addr[CyMSVR2<<index] = CyDTR;
2527 #ifdef SERIAL_DEBUG_DTR
2528 printk("cyc: %d: raising DTR\n", __LINE__);
2529 printk(" status: 0x%x, 0x%x\n", base_addr[CyMSVR1<<index], base_addr[CyMSVR2<<index]);
2530 #endif
2531 }
2532 restore_flags(flags);
2533 current->state = TASK_INTERRUPTIBLE;
2534 if (tty_hung_up_p(filp)
2535 || !(info->flags & ASYNC_INITIALIZED) ){
2536 if (info->flags & ASYNC_HUP_NOTIFY) {
2537 retval = -EAGAIN;
2538 }else{
2539 retval = -ERESTARTSYS;
2540 }
2541 break;
2542 }
2543 save_flags(flags); cli();
2544 base_addr[CyCAR<<index] = (u_char)channel;
2545
2546 if (!(info->flags & ASYNC_CALLOUT_ACTIVE)
2547 && !(info->flags & ASYNC_CLOSING)
2548 && (C_CLOCAL(tty)
2549 || (base_addr[CyMSVR1<<index] & CyDCD))) {
2550 restore_flags(flags);
2551 break;
2552 }
2553 restore_flags(flags);
2554 if (current->signal & ~current->blocked) {
2555 retval = -ERESTARTSYS;
2556 break;
2557 }
2558 #ifdef SERIAL_DEBUG_OPEN
2559 printk("block_til_ready blocking: ttyC%d, count = %d\n",
2560 info->line, info->count);
2561 #endif
2562 schedule();
2563 }
2564 current->state = TASK_RUNNING;
2565 remove_wait_queue(&info->open_wait, &wait);
2566 if (!tty_hung_up_p(filp)){
2567 info->count++;
2568 #ifdef SERIAL_DEBUG_COUNT
2569 printk("cyc: %d(%d): incrementing count to %d\n", __LINE__, current->pid, info->count);
2570 #endif
2571 }
2572 info->blocked_open--;
2573 #ifdef SERIAL_DEBUG_OPEN
2574 printk("block_til_ready after blocking: ttyC%d, count = %d\n",
2575 info->line, info->count);
2576 #endif
2577 if (retval)
2578 return retval;
2579 info->flags |= ASYNC_NORMAL_ACTIVE;
2580 return 0;
2581 }
2582
2583
2584
2585
2586
2587 int
2588 cy_open(struct tty_struct *tty, struct file * filp)
2589 {
2590 struct cyclades_port *info;
2591 int retval, line;
2592
2593
2594 line = MINOR(tty->device) - tty->driver.minor_start;
2595 if ((line < 0) || (NR_PORTS <= line)){
2596 return -ENODEV;
2597 }
2598 info = &cy_port[line];
2599 if (info->line < 0){
2600 return -ENODEV;
2601 }
2602 #ifdef SERIAL_DEBUG_OTHER
2603 printk("cy_open ttyC%d\n", info->line);
2604 #endif
2605 if (serial_paranoia_check(info, tty->device, "cy_open")){
2606 return -ENODEV;
2607 }
2608 #ifdef SERIAL_DEBUG_OPEN
2609 printk("cy_open ttyC%d, count = %d\n", info->line, info->count);
2610 #endif
2611 info->count++;
2612 #ifdef SERIAL_DEBUG_COUNT
2613 printk("cyc: %d(%d): incrementing count to %d\n", __LINE__, current->pid, info->count);
2614 #endif
2615 tty->driver_data = info;
2616 info->tty = tty;
2617
2618 if (!tmp_buf) {
2619 tmp_buf = (unsigned char *) get_free_page(GFP_KERNEL);
2620 if (!tmp_buf){
2621 return -ENOMEM;
2622 }
2623 }
2624
2625 if ((info->count == 1) && (info->flags & ASYNC_SPLIT_TERMIOS)) {
2626 if (tty->driver.subtype == SERIAL_TYPE_NORMAL)
2627 *tty->termios = info->normal_termios;
2628 else
2629 *tty->termios = info->callout_termios;
2630 }
2631
2632
2633
2634 retval = startup(info);
2635 if (retval){
2636 return retval;
2637 }
2638
2639 retval = block_til_ready(tty, filp, info);
2640 if (retval) {
2641 #ifdef SERIAL_DEBUG_OPEN
2642 printk("cy_open returning after block_til_ready with %d\n",
2643 retval);
2644 #endif
2645 return retval;
2646 }
2647
2648 info->session = current->session;
2649 info->pgrp = current->pgrp;
2650
2651 #ifdef SERIAL_DEBUG_OPEN
2652 printk("cy_open done\n");
2653 #endif
2654 MOD_INC_USE_COUNT;
2655 return 0;
2656 }
2657
2658
2659
2660
2661
2662
2663
2664
2665
2666
2667
2668
2669
2670
2671
2672
2673 static void
2674 show_version(void)
2675 {
2676 printk("Cyclom driver %s\n",rcsid);
2677 }
2678
2679
2680
2681 int
2682 cy_init_card(unsigned char *true_base_addr,int index)
2683 {
2684 unsigned int chip_number;
2685 unsigned char* base_addr;
2686
2687 true_base_addr[Cy_HwReset<<index] = 0;
2688 true_base_addr[Cy_ClrIntr<<index] = 0;
2689 udelay(500L);
2690
2691 for(chip_number=0; chip_number<CyMaxChipsPerCard; chip_number++){
2692 base_addr = true_base_addr + (cy_chip_offset[chip_number]<<index);
2693 udelay(1000L);
2694 if(base_addr[CyCCR<<index] != 0x00){
2695
2696
2697
2698
2699 return chip_number;
2700 }
2701
2702 base_addr[CyGFRCR<<index] = 0;
2703 udelay(10L);
2704
2705
2706
2707
2708
2709
2710
2711 if (chip_number == 4
2712 && *(true_base_addr + (cy_chip_offset[0]<<index) + (CyGFRCR<<index)) == 0){
2713 return chip_number;
2714 }
2715
2716 base_addr[CyCCR<<index] = CyCHIP_RESET;
2717 udelay(1000L);
2718
2719 if(base_addr[CyGFRCR<<index] == 0x00){
2720
2721
2722
2723
2724 return chip_number;
2725 }
2726 if((0xf0 & base_addr[CyGFRCR<<index]) != 0x40){
2727
2728
2729
2730
2731 return chip_number;
2732 }
2733 base_addr[CyGCR<<index] = CyCH0_SERIAL;
2734 base_addr[CyPPR<<index] = 244;
2735
2736
2737
2738
2739
2740
2741 }
2742
2743 return chip_number;
2744 }
2745
2746
2747
2748
2749
2750
2751
2752
2753
2754
2755
2756
2757
2758
2759
2760
2761
2762 int
2763 cy_init(void)
2764 {
2765 struct cyclades_port *info;
2766 struct cyclades_card *cinfo;
2767 int board,port,i;
2768
2769 show_version();
2770
2771
2772
2773 memset(&cy_serial_driver, 0, sizeof(struct tty_driver));
2774 cy_serial_driver.magic = TTY_DRIVER_MAGIC;
2775 cy_serial_driver.name = "ttyC";
2776 cy_serial_driver.major = CYCLADES_MAJOR;
2777 cy_serial_driver.minor_start = 32;
2778 cy_serial_driver.num = NR_PORTS;
2779 cy_serial_driver.type = TTY_DRIVER_TYPE_SERIAL;
2780 cy_serial_driver.subtype = SERIAL_TYPE_NORMAL;
2781 cy_serial_driver.init_termios = tty_std_termios;
2782 cy_serial_driver.init_termios.c_cflag =
2783 B9600 | CS8 | CREAD | HUPCL | CLOCAL;
2784 cy_serial_driver.flags = TTY_DRIVER_REAL_RAW;
2785 cy_serial_driver.refcount = &serial_refcount;
2786 cy_serial_driver.table = serial_table;
2787 cy_serial_driver.termios = serial_termios;
2788 cy_serial_driver.termios_locked = serial_termios_locked;
2789 cy_serial_driver.open = cy_open;
2790 cy_serial_driver.close = cy_close;
2791 cy_serial_driver.write = cy_write;
2792 cy_serial_driver.put_char = cy_put_char;
2793 cy_serial_driver.flush_chars = cy_flush_chars;
2794 cy_serial_driver.write_room = cy_write_room;
2795 cy_serial_driver.chars_in_buffer = cy_chars_in_buffer;
2796 cy_serial_driver.flush_buffer = cy_flush_buffer;
2797 cy_serial_driver.ioctl = cy_ioctl;
2798 cy_serial_driver.throttle = cy_throttle;
2799 cy_serial_driver.unthrottle = cy_unthrottle;
2800 cy_serial_driver.set_termios = cy_set_termios;
2801 cy_serial_driver.stop = cy_stop;
2802 cy_serial_driver.start = cy_start;
2803 cy_serial_driver.hangup = cy_hangup;
2804
2805
2806
2807
2808
2809 cy_callout_driver = cy_serial_driver;
2810 cy_callout_driver.name = "cub";
2811 cy_callout_driver.major = CYCLADESAUX_MAJOR;
2812 cy_callout_driver.subtype = SERIAL_TYPE_CALLOUT;
2813
2814 if (tty_register_driver(&cy_serial_driver))
2815 panic("Couldn't register Cyclom serial driver\n");
2816 if (tty_register_driver(&cy_callout_driver))
2817 panic("Couldn't register Cyclom callout driver\n");
2818
2819 bh_base[CYCLADES_BH].routine = do_cyclades_bh;
2820 enable_bh(CYCLADES_BH);
2821
2822 for (i = 0; i < 16; i++) {
2823 IRQ_cards[i] = 0;
2824 }
2825
2826 for (i = 0; i < NR_CARDS; i++) {
2827
2828 cy_card[i].base_addr = 0;
2829 }
2830
2831
2832
2833
2834
2835
2836
2837
2838
2839 cy_isa_nboard = cy_detect_isa();
2840
2841
2842 cy_pci_nboard = cy_detect_pci();
2843
2844 cy_nboard = cy_isa_nboard + cy_pci_nboard;
2845
2846
2847 for (i = 0 ; i < NR_CARDS ; i++) {
2848 if (cy_card[i].base_addr == 0) {
2849 cy_card[i].first_line = -1;
2850 }
2851 }
2852
2853 for (i = cy_next_channel ; i < NR_PORTS ; i++) {
2854 cy_port[i].line = -1;
2855 cy_port[i].magic = -1;
2856 }
2857
2858
2859 for (board = 0 ; board < cy_nboard ; board++) {
2860 cinfo = &cy_card[board];
2861 for (port = cinfo->first_line ;
2862 port < cinfo->first_line + 4*cinfo->num_chips ;
2863 port++)
2864 {
2865 info = &cy_port[port];
2866 info->magic = CYCLADES_MAGIC;
2867 info->type = PORT_CIRRUS;
2868 info->card = board;
2869 info->line = port;
2870 info->flags = STD_COM_FLAGS;
2871 info->tty = 0;
2872 info->xmit_fifo_size = 12;
2873 info->cor1 = CyPARITY_NONE|Cy_1_STOP|Cy_8_BITS;
2874 info->cor2 = CyETC;
2875 info->cor3 = 0x08;
2876 info->cor4 = 0;
2877 info->cor5 = 0;
2878 info->tbpr = baud_bpr[13];
2879 info->tco = baud_co[13];
2880 info->rbpr = baud_bpr[13];
2881 info->rco = baud_co[13];
2882 info->close_delay = 0;
2883 info->x_char = 0;
2884 info->event = 0;
2885 info->count = 0;
2886 #ifdef SERIAL_DEBUG_COUNT
2887 printk("cyc: %d: setting count to 0\n", __LINE__);
2888 #endif
2889 info->blocked_open = 0;
2890 info->default_threshold = 0;
2891 info->default_timeout = 0;
2892 info->tqueue.routine = do_softint;
2893 info->tqueue.data = info;
2894 info->callout_termios =cy_callout_driver.init_termios;
2895 info->normal_termios = cy_serial_driver.init_termios;
2896 info->open_wait = 0;
2897 info->close_wait = 0;
2898
2899
2900 info->read_status_mask = CyTIMEOUT| CySPECHAR| CyBREAK
2901 | CyPARITY| CyFRAME| CyOVERRUN;
2902
2903 }
2904 }
2905 return 0;
2906
2907 }
2908
2909 #ifdef MODULE
2910 int
2911 init_module(void)
2912 {
2913 return(cy_init());
2914 }
2915
2916 void
2917 cleanup_module(void)
2918 {
2919 int i;
2920
2921
2922 if (tty_unregister_driver(&cy_callout_driver))
2923 printk("Couldn't unregister Cyclom callout driver\n");
2924 if (tty_unregister_driver(&cy_serial_driver))
2925 printk("Couldn't unregister Cyclom serial driver\n");
2926
2927 for (i = 0; i < NR_CARDS; i++) {
2928 if (cy_card[i].base_addr != 0)
2929 {
2930 free_irq(cy_card[i].irq);
2931 }
2932 }
2933 }
2934 #endif
2935
2936
2937
2938
2939
2940
2941
2942 int
2943 cy_detect_isa()
2944 {
2945 unsigned int cy_isa_irq,nboard;
2946 unsigned char *cy_isa_address;
2947 unsigned short i,j,cy_isa_nchan;
2948
2949 nboard = 0;
2950
2951
2952 for (i = 0 ; i < NR_ISA_ADDRESSES ; i++) {
2953 cy_isa_address = cy_isa_addresses[i];
2954 if (cy_isa_address == 0x0000) {
2955 return(nboard);
2956 }
2957
2958
2959 cy_isa_nchan = 4 * cy_init_card(cy_isa_address,0);
2960 if (cy_isa_nchan == 0) {
2961 continue;
2962 }
2963
2964
2965 cy_isa_irq = do_auto_irq(cy_isa_address);
2966 if (cy_isa_irq == 0) {
2967 printk("Cyclom-Y/ISA found at 0x%x but the IRQ could not be detected.\n",
2968 (unsigned int) cy_isa_address);
2969 continue;
2970 }
2971
2972 if((cy_next_channel+cy_isa_nchan) > NR_PORTS) {
2973 printk("Cyclom-Y/ISA found at 0x%x but no more channel structures are available.\n",
2974 (unsigned int) cy_isa_address);
2975 return(nboard);
2976 }
2977
2978 for (j = 0 ; j < NR_CARDS ; j++) {
2979 if (cy_card[j].base_addr == 0) break;
2980 }
2981 if (j == NR_CARDS) {
2982 printk("Cyclom-Y/ISA found at 0x%x but no more card structures are available.\n",
2983 (unsigned int) cy_isa_address);
2984 return(nboard);
2985 }
2986
2987
2988 if(request_irq(cy_isa_irq,cy_interrupt,SA_INTERRUPT,"cyclades"))
2989 {
2990 printk("Cyclom-Y/ISA found at 0x%x but could not allocate interrupt IRQ#%d.\n",
2991 (unsigned int) cy_isa_address,cy_isa_irq);
2992 return(nboard);
2993 }
2994
2995
2996 cy_card[j].base_addr = (int) cy_isa_address;
2997 cy_card[j].irq = (int) cy_isa_irq;
2998 cy_card[j].bus_index = 0;
2999 cy_card[j].first_line = cy_next_channel;
3000 cy_card[j].num_chips = cy_isa_nchan/4;
3001 IRQ_cards[cy_isa_irq] = &cy_card[j];
3002 nboard++;
3003
3004
3005 printk("Cyclom-Y/ISA #%d: 0x%x-0x%x, IRQ%d, %d channels starting from port %d.\n",
3006 j+1,(unsigned int) cy_isa_address,
3007 (unsigned int)(cy_isa_address + 0x1fff),
3008 cy_isa_irq,cy_isa_nchan,cy_next_channel);
3009 cy_next_channel += cy_isa_nchan;
3010 }
3011 return(nboard);
3012
3013 }
3014
3015
3016
3017
3018
3019
3020
3021 int
3022 cy_detect_pci()
3023 {
3024 unsigned char cyy_bus, cyy_dev_fn, cyy_rev_id;
3025 unsigned long pci_intr_ctrl;
3026 unsigned char cy_pci_irq;
3027 unsigned int cy_pci_address, cy_pci_io;
3028 unsigned short i,j,cy_pci_nchan;
3029
3030 #ifndef CONFIG_PCI
3031 printk ("Kernel without PCI support.\n");
3032 return(0);
3033 #else
3034 if(pcibios_present() == 0) {
3035 return(0);
3036 }
3037 for (i = 0; i < NR_CARDS; i++) {
3038
3039 if(pcibios_find_device (PCI_VENDOR_ID_CYCLADES,
3040 PCI_DEVICE_ID_CYCLOMY,i,
3041 &cyy_bus, &cyy_dev_fn) != 0)
3042 {
3043 break;
3044 }
3045
3046 pcibios_read_config_byte(cyy_bus, cyy_dev_fn,
3047 PCI_INTERRUPT_LINE, &cy_pci_irq);
3048 pcibios_read_config_dword(cyy_bus, cyy_dev_fn,
3049 PCI_BASE_ADDRESS_1, &cy_pci_io);
3050 pcibios_read_config_dword(cyy_bus, cyy_dev_fn,
3051 PCI_BASE_ADDRESS_2, &cy_pci_address);
3052 pcibios_read_config_byte(cyy_bus, cyy_dev_fn,
3053 PCI_REVISION_ID, &cyy_rev_id);
3054 cy_pci_address &= 0xfffffff0;
3055 cy_pci_io &= 0xfffffffc;
3056 cy_pci_nchan = 4 * cy_init_card((unsigned char *)
3057 cy_pci_address,1);
3058 if(cy_pci_nchan == 0) {
3059 printk("Cyclom-Y PCI host card with no Serial-Modules at 0x%x.\n",
3060 (unsigned int) cy_pci_address);
3061 continue;
3062 }
3063 if((cy_next_channel+cy_pci_nchan) > NR_PORTS) {
3064 printk("Cyclom-Y/PCI found at 0x%x but no more channel structures are available.\n",
3065 (unsigned int) cy_pci_address);
3066 return(i);
3067 }
3068 #ifdef CY_PCI_DEBUG
3069 printk("Cyclom-Ye/PCI #%d (bus=0x0%x, pci_id=0x%x, rev_id=%d).\n",
3070 i+1,cyy_bus,cyy_dev_fn,cyy_rev_id);
3071 printk("Cyclom-Ye/PCI: found at 0x%x, IRQ%d, ioaddr = 0x%lx.\n",
3072 cy_pci_address,(int)cy_pci_irq,cy_pci_io);
3073 #endif
3074
3075 for (j = 0 ; j < NR_CARDS ; j++) {
3076 if (cy_card[j].base_addr == 0) break;
3077 }
3078 if (j == NR_CARDS) {
3079 printk("Cyclom-Y/PCI found at 0x%x but no more card structures are available.\n",
3080 (unsigned int) cy_pci_address);
3081 return(i);
3082 }
3083
3084
3085 if(request_irq(cy_pci_irq,cy_interrupt,SA_INTERRUPT,"cyclades"))
3086 {
3087 printk("Cyclom-Y/PCI found at 0x%x but could not allocate interrupt IRQ%d.\n",
3088 (unsigned int) cy_pci_address,cy_pci_irq);
3089 return(i);
3090 }
3091
3092
3093 cy_card[j].base_addr = (int) cy_pci_address;
3094 cy_card[j].irq = (int) cy_pci_irq;
3095 cy_card[j].bus_index = 1;
3096 cy_card[j].first_line = cy_next_channel;
3097 cy_card[j].num_chips = cy_pci_nchan/4;
3098 IRQ_cards[cy_pci_irq] = &cy_card[j];
3099
3100
3101 outw(inw(cy_pci_io+0x68)|0x0900,cy_pci_io+0x68);
3102 pci_intr_ctrl = (unsigned long)(inw(cy_pci_io+0x68) | inw(cy_pci_io+0x6a)<<16);
3103
3104
3105 printk("Cyclom-Y/PCI #%d: 0x%x-0x%x, IRQ%d, %d channels starting from port %d.\n",
3106 j+1,(unsigned int) cy_pci_address,
3107 (unsigned int)(cy_pci_address + 0x3fff),
3108 (int)cy_pci_irq,cy_pci_nchan,cy_next_channel);
3109
3110 cy_next_channel += cy_pci_nchan;
3111 }
3112 return(i);
3113 #endif
3114 }
3115
3116
3117 #ifdef CYCLOM_SHOW_STATUS
3118 static void
3119 show_status(int line_num)
3120 {
3121 unsigned char *base_addr;
3122 int card,chip,channel,index;
3123 struct cyclades_port * info;
3124 unsigned long flags;
3125
3126 info = &cy_port[line_num];
3127 card = info->card;
3128 index = cy_card[card].bus_index;
3129 channel = (info->line) - (cy_card[card].first_line);
3130 chip = channel>>2;
3131 channel &= 0x03;
3132 printk(" card %d, chip %d, channel %d\n", card, chip, channel);
3133
3134 printk(" cy_card\n");
3135 printk(" irq base_addr num_chips first_line = %d %lx %d %d\n",
3136 cy_card[card].irq, (long)cy_card[card].base_addr,
3137 cy_card[card].num_chips, cy_card[card].first_line);
3138
3139 printk(" cy_port\n");
3140 printk(" card line flags = %d %d %x\n",
3141 info->card, info->line, info->flags);
3142 printk(" *tty read_status_mask timeout xmit_fifo_size = %lx %x %x %x\n",
3143 (long)info->tty, info->read_status_mask,
3144 info->timeout, info->xmit_fifo_size);
3145 printk(" cor1,cor2,cor3,cor4,cor5 = %x %x %x %x %x\n",
3146 info->cor1, info->cor2, info->cor3, info->cor4, info->cor5);
3147 printk(" tbpr,tco,rbpr,rco = %d %d %d %d\n",
3148 info->tbpr, info->tco, info->rbpr, info->rco);
3149 printk(" close_delay event count = %d %d %d\n",
3150 info->close_delay, info->event, info->count);
3151 printk(" x_char blocked_open = %x %x\n",
3152 info->x_char, info->blocked_open);
3153 printk(" session pgrp open_wait = %lx %lx %lx\n",
3154 info->session, info->pgrp, (long)info->open_wait);
3155
3156
3157 save_flags(flags); cli();
3158
3159 base_addr = (unsigned char*)
3160 (cy_card[card].base_addr + (cy_chip_offset[chip]<<index));
3161
3162
3163
3164 printk(" CyGFRCR %x\n", base_addr[CyGFRCR<<index]);
3165 printk(" CyCAR %x\n", base_addr[CyCAR<<index]);
3166 printk(" CyGCR %x\n", base_addr[CyGCR<<index]);
3167 printk(" CySVRR %x\n", base_addr[CySVRR<<index]);
3168 printk(" CyRICR %x\n", base_addr[CyRICR<<index]);
3169 printk(" CyTICR %x\n", base_addr[CyTICR<<index]);
3170 printk(" CyMICR %x\n", base_addr[CyMICR<<index]);
3171 printk(" CyRIR %x\n", base_addr[CyRIR<<index]);
3172 printk(" CyTIR %x\n", base_addr[CyTIR<<index]);
3173 printk(" CyMIR %x\n", base_addr[CyMIR<<index]);
3174 printk(" CyPPR %x\n", base_addr[CyPPR<<index]);
3175
3176 base_addr[CyCAR<<index] = (u_char)channel;
3177
3178
3179
3180 printk(" CyRIVR %x\n", base_addr[CyRIVR<<index]);
3181 printk(" CyTIVR %x\n", base_addr[CyTIVR<<index]);
3182 printk(" CyMIVR %x\n", base_addr[CyMIVR<<index]);
3183 printk(" CyMISR %x\n", base_addr[CyMISR<<index]);
3184
3185
3186
3187 printk(" CyCCR %x\n", base_addr[CyCCR<<index]);
3188 printk(" CySRER %x\n", base_addr[CySRER<<index]);
3189 printk(" CyCOR1 %x\n", base_addr[CyCOR1<<index]);
3190 printk(" CyCOR2 %x\n", base_addr[CyCOR2<<index]);
3191 printk(" CyCOR3 %x\n", base_addr[CyCOR3<<index]);
3192 printk(" CyCOR4 %x\n", base_addr[CyCOR4<<index]);
3193 printk(" CyCOR5 %x\n", base_addr[CyCOR5<<index]);
3194 printk(" CyCCSR %x\n", base_addr[CyCCSR<<index]);
3195 printk(" CyRDCR %x\n", base_addr[CyRDCR<<index]);
3196 printk(" CySCHR1 %x\n", base_addr[CySCHR1<<index]);
3197 printk(" CySCHR2 %x\n", base_addr[CySCHR2<<index]);
3198 printk(" CySCHR3 %x\n", base_addr[CySCHR3<<index]);
3199 printk(" CySCHR4 %x\n", base_addr[CySCHR4<<index]);
3200 printk(" CySCRL %x\n", base_addr[CySCRL<<index]);
3201 printk(" CySCRH %x\n", base_addr[CySCRH<<index]);
3202 printk(" CyLNC %x\n", base_addr[CyLNC<<index]);
3203 printk(" CyMCOR1 %x\n", base_addr[CyMCOR1<<index]);
3204 printk(" CyMCOR2 %x\n", base_addr[CyMCOR2<<index]);
3205 printk(" CyRTPR %x\n", base_addr[CyRTPR<<index]);
3206 printk(" CyMSVR1 %x\n", base_addr[CyMSVR1<<index]);
3207 printk(" CyMSVR2 %x\n", base_addr[CyMSVR2<<index]);
3208 printk(" CyRBPR %x\n", base_addr[CyRBPR<<index]);
3209 printk(" CyRCOR %x\n", base_addr[CyRCOR<<index]);
3210 printk(" CyTBPR %x\n", base_addr[CyTBPR<<index]);
3211 printk(" CyTCOR %x\n", base_addr[CyTCOR<<index]);
3212
3213 restore_flags(flags);
3214 }
3215 #endif
3216