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