diff options
Diffstat (limited to 'drivers/char/cyclades.c')
-rw-r--r-- | drivers/char/cyclades.c | 7804 |
1 files changed, 3943 insertions, 3861 deletions
diff --git a/drivers/char/cyclades.c b/drivers/char/cyclades.c index c1c67281750d..3ffa0807754c 100644 --- a/drivers/char/cyclades.c +++ b/drivers/char/cyclades.c | |||
@@ -1,8 +1,6 @@ | |||
1 | #undef BLOCKMOVE | 1 | #undef BLOCKMOVE |
2 | #define Z_WAKE | 2 | #define Z_WAKE |
3 | #undef Z_EXT_CHARS_IN_BUFFER | 3 | #undef Z_EXT_CHARS_IN_BUFFER |
4 | static char rcsid[] = | ||
5 | "$Revision: 2.3.2.20 $$Date: 2004/02/25 18:14:16 $"; | ||
6 | 4 | ||
7 | /* | 5 | /* |
8 | * linux/drivers/char/cyclades.c | 6 | * linux/drivers/char/cyclades.c |
@@ -593,18 +591,20 @@ static char rcsid[] = | |||
593 | * | 591 | * |
594 | */ | 592 | */ |
595 | 593 | ||
594 | #define CY_VERSION "2.4" | ||
595 | |||
596 | /* If you need to install more boards than NR_CARDS, change the constant | 596 | /* If you need to install more boards than NR_CARDS, change the constant |
597 | in the definition below. No other change is necessary to support up to | 597 | in the definition below. No other change is necessary to support up to |
598 | eight boards. Beyond that you'll have to extend cy_isa_addresses. */ | 598 | eight boards. Beyond that you'll have to extend cy_isa_addresses. */ |
599 | 599 | ||
600 | #define NR_CARDS 4 | 600 | #define NR_CARDS 4 |
601 | 601 | ||
602 | /* | 602 | /* |
603 | If the total number of ports is larger than NR_PORTS, change this | 603 | If the total number of ports is larger than NR_PORTS, change this |
604 | constant in the definition below. No other change is necessary to | 604 | constant in the definition below. No other change is necessary to |
605 | support more boards/ports. */ | 605 | support more boards/ports. */ |
606 | 606 | ||
607 | #define NR_PORTS 256 | 607 | #define NR_PORTS 256 |
608 | 608 | ||
609 | #define ZE_V1_NPORTS 64 | 609 | #define ZE_V1_NPORTS 64 |
610 | #define ZO_V1 0 | 610 | #define ZO_V1 0 |
@@ -625,9 +625,9 @@ static char rcsid[] = | |||
625 | #undef CY_PCI_DEBUG | 625 | #undef CY_PCI_DEBUG |
626 | 626 | ||
627 | #if 0 | 627 | #if 0 |
628 | #define PAUSE __asm__("nop"); | 628 | #define PAUSE __asm__("nop") |
629 | #else | 629 | #else |
630 | #define PAUSE ; | 630 | #define PAUSE do {} while (0) |
631 | #endif | 631 | #endif |
632 | 632 | ||
633 | /* | 633 | /* |
@@ -663,7 +663,7 @@ static char rcsid[] = | |||
663 | do { \ | 663 | do { \ |
664 | spin_lock_irqsave(&cy_card[info->card].card_lock, flags); \ | 664 | spin_lock_irqsave(&cy_card[info->card].card_lock, flags); \ |
665 | } while (0) | 665 | } while (0) |
666 | 666 | ||
667 | #define CY_UNLOCK(info,flags) \ | 667 | #define CY_UNLOCK(info,flags) \ |
668 | do { \ | 668 | do { \ |
669 | spin_unlock_irqrestore(&cy_card[info->card].card_lock, flags); \ | 669 | spin_unlock_irqrestore(&cy_card[info->card].card_lock, flags); \ |
@@ -676,14 +676,14 @@ static char rcsid[] = | |||
676 | #include <linux/stat.h> | 676 | #include <linux/stat.h> |
677 | #include <linux/proc_fs.h> | 677 | #include <linux/proc_fs.h> |
678 | 678 | ||
679 | static void cy_throttle (struct tty_struct *tty); | 679 | static void cy_throttle(struct tty_struct *tty); |
680 | static void cy_send_xchar (struct tty_struct *tty, char ch); | 680 | static void cy_send_xchar(struct tty_struct *tty, char ch); |
681 | 681 | ||
682 | #define IS_CYC_Z(card) ((card).num_chips == -1) | 682 | #define IS_CYC_Z(card) ((card).num_chips == -1) |
683 | 683 | ||
684 | #define Z_FPGA_CHECK(card) \ | 684 | #define Z_FPGA_CHECK(card) \ |
685 | ((cy_readl(&((struct RUNTIME_9060 __iomem *) \ | 685 | ((cy_readl(&((struct RUNTIME_9060 __iomem *) \ |
686 | ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0) | 686 | ((card).ctl_addr))->init_ctrl) & (1<<17)) != 0) |
687 | 687 | ||
688 | #define ISZLOADED(card) (((ZO_V1==cy_readl(&((struct RUNTIME_9060 __iomem *) \ | 688 | #define ISZLOADED(card) (((ZO_V1==cy_readl(&((struct RUNTIME_9060 __iomem *) \ |
689 | ((card).ctl_addr))->mail_box_0)) || \ | 689 | ((card).ctl_addr))->mail_box_0)) || \ |
@@ -698,8 +698,6 @@ static void cy_send_xchar (struct tty_struct *tty, char ch); | |||
698 | 698 | ||
699 | #define STD_COM_FLAGS (0) | 699 | #define STD_COM_FLAGS (0) |
700 | 700 | ||
701 | #define JIFFIES_DIFF(n, j) ((j) - (n)) | ||
702 | |||
703 | static struct tty_driver *cy_serial_driver; | 701 | static struct tty_driver *cy_serial_driver; |
704 | 702 | ||
705 | #ifdef CONFIG_ISA | 703 | #ifdef CONFIG_ISA |
@@ -713,27 +711,28 @@ static struct tty_driver *cy_serial_driver; | |||
713 | */ | 711 | */ |
714 | 712 | ||
715 | static unsigned int cy_isa_addresses[] = { | 713 | static unsigned int cy_isa_addresses[] = { |
716 | 0xD0000, | 714 | 0xD0000, |
717 | 0xD2000, | 715 | 0xD2000, |
718 | 0xD4000, | 716 | 0xD4000, |
719 | 0xD6000, | 717 | 0xD6000, |
720 | 0xD8000, | 718 | 0xD8000, |
721 | 0xDA000, | 719 | 0xDA000, |
722 | 0xDC000, | 720 | 0xDC000, |
723 | 0xDE000, | 721 | 0xDE000, |
724 | 0,0,0,0,0,0,0,0 | 722 | 0, 0, 0, 0, 0, 0, 0, 0 |
725 | }; | 723 | }; |
724 | |||
726 | #define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) | 725 | #define NR_ISA_ADDRS ARRAY_SIZE(cy_isa_addresses) |
727 | 726 | ||
728 | #ifdef MODULE | 727 | #ifdef MODULE |
729 | static long maddr[NR_CARDS] = { 0, }; | 728 | static long maddr[NR_CARDS] = { 0, }; |
730 | static int irq[NR_CARDS] = { 0, }; | 729 | static int irq[NR_CARDS] = { 0, }; |
731 | 730 | ||
732 | module_param_array(maddr, long, NULL, 0); | 731 | module_param_array(maddr, long, NULL, 0); |
733 | module_param_array(irq, int, NULL, 0); | 732 | module_param_array(irq, int, NULL, 0); |
734 | #endif | 733 | #endif |
735 | 734 | ||
736 | #endif /* CONFIG_ISA */ | 735 | #endif /* CONFIG_ISA */ |
737 | 736 | ||
738 | /* This is the per-card data structure containing address, irq, number of | 737 | /* This is the per-card data structure containing address, irq, number of |
739 | channels, etc. This driver supports a maximum of NR_CARDS cards. | 738 | channels, etc. This driver supports a maximum of NR_CARDS cards. |
@@ -745,19 +744,7 @@ static struct cyclades_card cy_card[NR_CARDS]; | |||
745 | */ | 744 | */ |
746 | static struct cyclades_port cy_port[NR_PORTS]; | 745 | static struct cyclades_port cy_port[NR_PORTS]; |
747 | 746 | ||
748 | static int cy_next_channel; /* next minor available */ | 747 | static int cy_next_channel; /* next minor available */ |
749 | |||
750 | /* | ||
751 | * tmp_buf is used as a temporary buffer by serial_write. We need to | ||
752 | * lock it in case the copy_from_user blocks while swapping in a page, | ||
753 | * and some other program tries to do a serial write at the same time. | ||
754 | * Since the lock will only come under contention when the system is | ||
755 | * swapping and available memory is low, it makes sense to share one | ||
756 | * buffer across all the serial ports, since it significantly saves | ||
757 | * memory if large numbers of serial ports are open. This buffer is | ||
758 | * allocated when the first cy_open occurs. | ||
759 | */ | ||
760 | static unsigned char *tmp_buf; | ||
761 | 748 | ||
762 | /* | 749 | /* |
763 | * This is used to look up the divisor speeds and the timeouts | 750 | * This is used to look up the divisor speeds and the timeouts |
@@ -769,36 +756,42 @@ static unsigned char *tmp_buf; | |||
769 | * 20 | 756 | * 20 |
770 | */ | 757 | */ |
771 | static int baud_table[] = { | 758 | static int baud_table[] = { |
772 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, | 759 | 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, |
773 | 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800,115200,150000, | 760 | 1800, 2400, 4800, 9600, 19200, 38400, 57600, 76800, 115200, 150000, |
774 | 230400, 0}; | 761 | 230400, 0 |
775 | 762 | }; | |
776 | static char baud_co_25[] = { /* 25 MHz clock option table */ | 763 | |
777 | /* value => 00 01 02 03 04 */ | 764 | static char baud_co_25[] = { /* 25 MHz clock option table */ |
778 | /* divide by 8 32 128 512 2048 */ | 765 | /* value => 00 01 02 03 04 */ |
779 | 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, | 766 | /* divide by 8 32 128 512 2048 */ |
780 | 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; | 767 | 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, 0x03, 0x02, |
781 | 768 | 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 | |
782 | static char baud_bpr_25[] = { /* 25 MHz baud rate period table */ | 769 | }; |
783 | 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3, | 770 | |
784 | 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15}; | 771 | static char baud_bpr_25[] = { /* 25 MHz baud rate period table */ |
785 | 772 | 0x00, 0xf5, 0xa3, 0x6f, 0x5c, 0x51, 0xf5, 0xa3, 0x51, 0xa3, | |
786 | static char baud_co_60[] = { /* 60 MHz clock option table (CD1400 J) */ | 773 | 0x6d, 0x51, 0xa3, 0x51, 0xa3, 0x51, 0x36, 0x29, 0x1b, 0x15 |
787 | /* value => 00 01 02 03 04 */ | 774 | }; |
788 | /* divide by 8 32 128 512 2048 */ | 775 | |
789 | 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, | 776 | static char baud_co_60[] = { /* 60 MHz clock option table (CD1400 J) */ |
790 | 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, | 777 | /* value => 00 01 02 03 04 */ |
791 | 0x00}; | 778 | /* divide by 8 32 128 512 2048 */ |
792 | 779 | 0x00, 0x00, 0x00, 0x04, 0x04, 0x04, 0x04, 0x04, 0x03, 0x03, | |
793 | static char baud_bpr_60[] = { /* 60 MHz baud rate period table (CD1400 J) */ | 780 | 0x03, 0x02, 0x02, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, |
794 | 0x00, 0x82, 0x21, 0xff, 0xdb, 0xc3, 0x92, 0x62, 0xc3, 0x62, | 781 | 0x00 |
795 | 0x41, 0xc3, 0x62, 0xc3, 0x62, 0xc3, 0x82, 0x62, 0x41, 0x32, | 782 | }; |
796 | 0x21}; | 783 | |
797 | 784 | static char baud_bpr_60[] = { /* 60 MHz baud rate period table (CD1400 J) */ | |
798 | static char baud_cor3[] = { /* receive threshold */ | 785 | 0x00, 0x82, 0x21, 0xff, 0xdb, 0xc3, 0x92, 0x62, 0xc3, 0x62, |
799 | 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, | 786 | 0x41, 0xc3, 0x62, 0xc3, 0x62, 0xc3, 0x82, 0x62, 0x41, 0x32, |
800 | 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07, | 787 | 0x21 |
801 | 0x07}; | 788 | }; |
789 | |||
790 | static char baud_cor3[] = { /* receive threshold */ | ||
791 | 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, | ||
792 | 0x0a, 0x0a, 0x0a, 0x09, 0x09, 0x08, 0x08, 0x08, 0x08, 0x07, | ||
793 | 0x07 | ||
794 | }; | ||
802 | 795 | ||
803 | /* | 796 | /* |
804 | * The Cyclades driver implements HW flow control as any serial driver. | 797 | * The Cyclades driver implements HW flow control as any serial driver. |
@@ -811,42 +804,42 @@ static char baud_cor3[] = { /* receive threshold */ | |||
811 | * cables. | 804 | * cables. |
812 | */ | 805 | */ |
813 | 806 | ||
814 | static char rflow_thr[] = { /* rflow threshold */ | 807 | static char rflow_thr[] = { /* rflow threshold */ |
815 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | 808 | 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, |
816 | 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, | 809 | 0x00, 0x00, 0x00, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, 0x0a, |
817 | 0x0a}; | 810 | 0x0a |
811 | }; | ||
818 | 812 | ||
819 | /* The Cyclom-Ye has placed the sequential chips in non-sequential | 813 | /* The Cyclom-Ye has placed the sequential chips in non-sequential |
820 | * address order. This look-up table overcomes that problem. | 814 | * address order. This look-up table overcomes that problem. |
821 | */ | 815 | */ |
822 | static int cy_chip_offset [] = | 816 | static int cy_chip_offset[] = { 0x0000, |
823 | { 0x0000, | 817 | 0x0400, |
824 | 0x0400, | 818 | 0x0800, |
825 | 0x0800, | 819 | 0x0C00, |
826 | 0x0C00, | 820 | 0x0200, |
827 | 0x0200, | 821 | 0x0600, |
828 | 0x0600, | 822 | 0x0A00, |
829 | 0x0A00, | 823 | 0x0E00 |
830 | 0x0E00 | 824 | }; |
831 | }; | ||
832 | 825 | ||
833 | /* PCI related definitions */ | 826 | /* PCI related definitions */ |
834 | 827 | ||
835 | static unsigned short cy_pci_nboard; | 828 | static unsigned short cy_pci_nboard; |
836 | static unsigned short cy_isa_nboard; | 829 | static unsigned short cy_isa_nboard; |
837 | static unsigned short cy_nboard; | 830 | static unsigned short cy_nboard; |
838 | #ifdef CONFIG_PCI | 831 | #ifdef CONFIG_PCI |
839 | static unsigned short cy_pci_dev_id[] = { | 832 | static unsigned short cy_pci_dev_id[] = { |
840 | PCI_DEVICE_ID_CYCLOM_Y_Lo, /* PCI < 1Mb */ | 833 | PCI_DEVICE_ID_CYCLOM_Y_Lo, /* PCI < 1Mb */ |
841 | PCI_DEVICE_ID_CYCLOM_Y_Hi, /* PCI > 1Mb */ | 834 | PCI_DEVICE_ID_CYCLOM_Y_Hi, /* PCI > 1Mb */ |
842 | PCI_DEVICE_ID_CYCLOM_4Y_Lo, /* 4Y PCI < 1Mb */ | 835 | PCI_DEVICE_ID_CYCLOM_4Y_Lo, /* 4Y PCI < 1Mb */ |
843 | PCI_DEVICE_ID_CYCLOM_4Y_Hi, /* 4Y PCI > 1Mb */ | 836 | PCI_DEVICE_ID_CYCLOM_4Y_Hi, /* 4Y PCI > 1Mb */ |
844 | PCI_DEVICE_ID_CYCLOM_8Y_Lo, /* 8Y PCI < 1Mb */ | 837 | PCI_DEVICE_ID_CYCLOM_8Y_Lo, /* 8Y PCI < 1Mb */ |
845 | PCI_DEVICE_ID_CYCLOM_8Y_Hi, /* 8Y PCI > 1Mb */ | 838 | PCI_DEVICE_ID_CYCLOM_8Y_Hi, /* 8Y PCI > 1Mb */ |
846 | PCI_DEVICE_ID_CYCLOM_Z_Lo, /* Z PCI < 1Mb */ | 839 | PCI_DEVICE_ID_CYCLOM_Z_Lo, /* Z PCI < 1Mb */ |
847 | PCI_DEVICE_ID_CYCLOM_Z_Hi, /* Z PCI > 1Mb */ | 840 | PCI_DEVICE_ID_CYCLOM_Z_Hi, /* Z PCI > 1Mb */ |
848 | 0 /* end of table */ | 841 | 0 /* end of table */ |
849 | }; | 842 | }; |
850 | #endif | 843 | #endif |
851 | 844 | ||
852 | static void cy_start(struct tty_struct *); | 845 | static void cy_start(struct tty_struct *); |
@@ -854,9 +847,9 @@ static void set_line_char(struct cyclades_port *); | |||
854 | static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong); | 847 | static int cyz_issue_cmd(struct cyclades_card *, uclong, ucchar, uclong); |
855 | #ifdef CONFIG_ISA | 848 | #ifdef CONFIG_ISA |
856 | static unsigned detect_isa_irq(void __iomem *); | 849 | static unsigned detect_isa_irq(void __iomem *); |
857 | #endif /* CONFIG_ISA */ | 850 | #endif /* CONFIG_ISA */ |
858 | 851 | ||
859 | static int cyclades_get_proc_info(char *, char **, off_t , int , int *, void *); | 852 | static int cyclades_get_proc_info(char *, char **, off_t, int, int *, void *); |
860 | 853 | ||
861 | #ifndef CONFIG_CYZ_INTR | 854 | #ifndef CONFIG_CYZ_INTR |
862 | static void cyz_poll(unsigned long); | 855 | static void cyz_poll(unsigned long); |
@@ -867,41 +860,36 @@ static long cyz_polling_cycle = CZ_DEF_POLL; | |||
867 | static int cyz_timeron = 0; | 860 | static int cyz_timeron = 0; |
868 | static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0); | 861 | static DEFINE_TIMER(cyz_timerlist, cyz_poll, 0, 0); |
869 | 862 | ||
870 | #else /* CONFIG_CYZ_INTR */ | 863 | #else /* CONFIG_CYZ_INTR */ |
871 | static void cyz_rx_restart(unsigned long); | 864 | static void cyz_rx_restart(unsigned long); |
872 | static struct timer_list cyz_rx_full_timer[NR_PORTS]; | 865 | static struct timer_list cyz_rx_full_timer[NR_PORTS]; |
873 | #endif /* CONFIG_CYZ_INTR */ | 866 | #endif /* CONFIG_CYZ_INTR */ |
874 | 867 | ||
875 | static inline int | 868 | static inline int serial_paranoia_check(struct cyclades_port *info, |
876 | serial_paranoia_check(struct cyclades_port *info, | 869 | char *name, const char *routine) |
877 | char *name, const char *routine) | ||
878 | { | 870 | { |
879 | #ifdef SERIAL_PARANOIA_CHECK | 871 | #ifdef SERIAL_PARANOIA_CHECK |
880 | static const char *badmagic = | 872 | if (!info) { |
881 | "cyc Warning: bad magic number for serial struct (%s) in %s\n"; | 873 | printk("cyc Warning: null cyclades_port for (%s) in %s\n", |
882 | static const char *badinfo = | 874 | name, routine); |
883 | "cyc Warning: null cyclades_port for (%s) in %s\n"; | 875 | return 1; |
884 | static const char *badrange = | 876 | } |
885 | "cyc Warning: cyclades_port out of range for (%s) in %s\n"; | 877 | |
886 | 878 | if ((long)info < (long)(&cy_port[0]) || | |
887 | if (!info) { | 879 | (long)(&cy_port[NR_PORTS]) < (long)info) { |
888 | printk(badinfo, name, routine); | 880 | printk("cyc Warning: cyclades_port out of range for (%s) in " |
889 | return 1; | 881 | "%s\n", name, routine); |
890 | } | 882 | return 1; |
891 | 883 | } | |
892 | if( (long)info < (long)(&cy_port[0]) | 884 | |
893 | || (long)(&cy_port[NR_PORTS]) < (long)info ){ | 885 | if (info->magic != CYCLADES_MAGIC) { |
894 | printk(badrange, name, routine); | 886 | printk("cyc Warning: bad magic number for serial struct (%s) " |
895 | return 1; | 887 | "in %s\n", name, routine); |
896 | } | 888 | return 1; |
897 | 889 | } | |
898 | if (info->magic != CYCLADES_MAGIC) { | ||
899 | printk(badmagic, name, routine); | ||
900 | return 1; | ||
901 | } | ||
902 | #endif | 890 | #endif |
903 | return 0; | 891 | return 0; |
904 | } /* serial_paranoia_check */ | 892 | } /* serial_paranoia_check */ |
905 | 893 | ||
906 | /* | 894 | /* |
907 | * This routine is used by the interrupt handler to schedule | 895 | * This routine is used by the interrupt handler to schedule |
@@ -909,13 +897,11 @@ serial_paranoia_check(struct cyclades_port *info, | |||
909 | * (also known as the "bottom half"). This can be called any | 897 | * (also known as the "bottom half"). This can be called any |
910 | * number of times for any channel without harm. | 898 | * number of times for any channel without harm. |
911 | */ | 899 | */ |
912 | static inline void | 900 | static inline void cy_sched_event(struct cyclades_port *info, int event) |
913 | cy_sched_event(struct cyclades_port *info, int event) | ||
914 | { | 901 | { |
915 | info->event |= 1 << event; /* remember what kind of event and who */ | 902 | info->event |= 1 << event; /* remember what kind of event and who */ |
916 | schedule_work(&info->tqueue); | 903 | schedule_work(&info->tqueue); |
917 | } /* cy_sched_event */ | 904 | } /* cy_sched_event */ |
918 | |||
919 | 905 | ||
920 | /* | 906 | /* |
921 | * This routine is used to handle the "bottom half" processing for the | 907 | * This routine is used to handle the "bottom half" processing for the |
@@ -938,44 +924,40 @@ cy_sched_event(struct cyclades_port *info, int event) | |||
938 | * had to poll every port to see if that port needed servicing. | 924 | * had to poll every port to see if that port needed servicing. |
939 | */ | 925 | */ |
940 | static void | 926 | static void |
941 | do_softint(void *private_) | 927 | do_softint(struct work_struct *work) |
942 | { | 928 | { |
943 | struct cyclades_port *info = (struct cyclades_port *) private_; | 929 | struct cyclades_port *info = |
944 | struct tty_struct *tty; | 930 | container_of(work, struct cyclades_port, tqueue); |
945 | 931 | struct tty_struct *tty; | |
946 | tty = info->tty; | 932 | |
947 | if (!tty) | 933 | tty = info->tty; |
948 | return; | 934 | if (!tty) |
949 | 935 | return; | |
950 | if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) { | 936 | |
951 | tty_hangup(info->tty); | 937 | if (test_and_clear_bit(Cy_EVENT_HANGUP, &info->event)) { |
952 | wake_up_interruptible(&info->open_wait); | 938 | tty_hangup(info->tty); |
953 | info->flags &= ~ASYNC_NORMAL_ACTIVE; | 939 | wake_up_interruptible(&info->open_wait); |
954 | } | 940 | info->flags &= ~ASYNC_NORMAL_ACTIVE; |
955 | if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) { | 941 | } |
956 | wake_up_interruptible(&info->open_wait); | 942 | if (test_and_clear_bit(Cy_EVENT_OPEN_WAKEUP, &info->event)) |
957 | } | 943 | wake_up_interruptible(&info->open_wait); |
958 | #ifdef CONFIG_CYZ_INTR | 944 | #ifdef CONFIG_CYZ_INTR |
959 | if (test_and_clear_bit(Cy_EVENT_Z_RX_FULL, &info->event)) { | 945 | if (test_and_clear_bit(Cy_EVENT_Z_RX_FULL, &info->event)) { |
960 | if (cyz_rx_full_timer[info->line].function == NULL) { | 946 | if (cyz_rx_full_timer[info->line].function == NULL) { |
961 | cyz_rx_full_timer[info->line].expires = jiffies + 1; | 947 | cyz_rx_full_timer[info->line].expires = jiffies + 1; |
962 | cyz_rx_full_timer[info->line].function = cyz_rx_restart; | 948 | cyz_rx_full_timer[info->line].function = cyz_rx_restart; |
963 | cyz_rx_full_timer[info->line].data = (unsigned long)info; | 949 | cyz_rx_full_timer[info->line].data = |
964 | add_timer(&cyz_rx_full_timer[info->line]); | 950 | (unsigned long)info; |
951 | add_timer(&cyz_rx_full_timer[info->line]); | ||
952 | } | ||
965 | } | 953 | } |
966 | } | ||
967 | #endif | 954 | #endif |
968 | if (test_and_clear_bit(Cy_EVENT_DELTA_WAKEUP, &info->event)) { | 955 | if (test_and_clear_bit(Cy_EVENT_DELTA_WAKEUP, &info->event)) |
969 | wake_up_interruptible(&info->delta_msr_wait); | 956 | wake_up_interruptible(&info->delta_msr_wait); |
970 | } | 957 | tty_wakeup(tty); |
971 | if (test_and_clear_bit(Cy_EVENT_WRITE_WAKEUP, &info->event)) { | ||
972 | tty_wakeup(tty); | ||
973 | wake_up_interruptible(&tty->write_wait); | ||
974 | } | ||
975 | #ifdef Z_WAKE | 958 | #ifdef Z_WAKE |
976 | if (test_and_clear_bit(Cy_EVENT_SHUTDOWN_WAKEUP, &info->event)) { | 959 | if (test_and_clear_bit(Cy_EVENT_SHUTDOWN_WAKEUP, &info->event)) |
977 | wake_up_interruptible(&info->shutdown_wait); | 960 | wake_up_interruptible(&info->shutdown_wait); |
978 | } | ||
979 | #endif | 961 | #endif |
980 | } /* do_softint */ | 962 | } /* do_softint */ |
981 | 963 | ||
@@ -990,341 +972,339 @@ do_softint(void *private_) | |||
990 | 972 | ||
991 | This function is only called from inside spinlock-protected code. | 973 | This function is only called from inside spinlock-protected code. |
992 | */ | 974 | */ |
993 | static int | 975 | static int cyy_issue_cmd(void __iomem * base_addr, u_char cmd, int index) |
994 | cyy_issue_cmd(void __iomem *base_addr, u_char cmd, int index) | ||
995 | { | 976 | { |
996 | volatile int i; | 977 | volatile int i; |
997 | 978 | ||
998 | /* Check to see that the previous command has completed */ | 979 | /* Check to see that the previous command has completed */ |
999 | for(i = 0 ; i < 100 ; i++){ | 980 | for (i = 0; i < 100; i++) { |
1000 | if (cy_readb(base_addr+(CyCCR<<index)) == 0){ | 981 | if (cy_readb(base_addr + (CyCCR << index)) == 0) { |
1001 | break; | 982 | break; |
983 | } | ||
984 | udelay(10L); | ||
1002 | } | 985 | } |
1003 | udelay(10L); | 986 | /* if the CCR never cleared, the previous command |
1004 | } | 987 | didn't finish within the "reasonable time" */ |
1005 | /* if the CCR never cleared, the previous command | 988 | if (i == 100) |
1006 | didn't finish within the "reasonable time" */ | 989 | return -1; |
1007 | if (i == 100) return (-1); | ||
1008 | 990 | ||
1009 | /* Issue the new command */ | 991 | /* Issue the new command */ |
1010 | cy_writeb(base_addr+(CyCCR<<index), cmd); | 992 | cy_writeb(base_addr + (CyCCR << index), cmd); |
1011 | 993 | ||
1012 | return(0); | 994 | return 0; |
1013 | } /* cyy_issue_cmd */ | 995 | } /* cyy_issue_cmd */ |
1014 | 996 | ||
1015 | #ifdef CONFIG_ISA | 997 | #ifdef CONFIG_ISA |
1016 | /* ISA interrupt detection code */ | 998 | /* ISA interrupt detection code */ |
1017 | static unsigned | 999 | static unsigned detect_isa_irq(void __iomem * address) |
1018 | detect_isa_irq(void __iomem *address) | ||
1019 | { | 1000 | { |
1020 | int irq; | 1001 | int irq; |
1021 | unsigned long irqs, flags; | 1002 | unsigned long irqs, flags; |
1022 | int save_xir, save_car; | 1003 | int save_xir, save_car; |
1023 | int index = 0; /* IRQ probing is only for ISA */ | 1004 | int index = 0; /* IRQ probing is only for ISA */ |
1024 | 1005 | ||
1025 | /* forget possible initially masked and pending IRQ */ | 1006 | /* forget possible initially masked and pending IRQ */ |
1026 | irq = probe_irq_off(probe_irq_on()); | 1007 | irq = probe_irq_off(probe_irq_on()); |
1027 | 1008 | ||
1028 | /* Clear interrupts on the board first */ | 1009 | /* Clear interrupts on the board first */ |
1029 | cy_writeb(address + (Cy_ClrIntr<<index), 0); | 1010 | cy_writeb(address + (Cy_ClrIntr << index), 0); |
1030 | /* Cy_ClrIntr is 0x1800 */ | 1011 | /* Cy_ClrIntr is 0x1800 */ |
1031 | 1012 | ||
1032 | irqs = probe_irq_on(); | 1013 | irqs = probe_irq_on(); |
1033 | /* Wait ... */ | 1014 | /* Wait ... */ |
1034 | udelay(5000L); | 1015 | udelay(5000L); |
1035 | 1016 | ||
1036 | /* Enable the Tx interrupts on the CD1400 */ | 1017 | /* Enable the Tx interrupts on the CD1400 */ |
1037 | local_irq_save(flags); | 1018 | local_irq_save(flags); |
1038 | cy_writeb(address + (CyCAR<<index), 0); | 1019 | cy_writeb(address + (CyCAR << index), 0); |
1039 | cyy_issue_cmd(address, CyCHAN_CTL|CyENB_XMTR, index); | 1020 | cyy_issue_cmd(address, CyCHAN_CTL | CyENB_XMTR, index); |
1040 | 1021 | ||
1041 | cy_writeb(address + (CyCAR<<index), 0); | 1022 | cy_writeb(address + (CyCAR << index), 0); |
1042 | cy_writeb(address + (CySRER<<index), | 1023 | cy_writeb(address + (CySRER << index), |
1043 | cy_readb(address + (CySRER<<index)) | CyTxRdy); | 1024 | cy_readb(address + (CySRER << index)) | CyTxRdy); |
1044 | local_irq_restore(flags); | 1025 | local_irq_restore(flags); |
1045 | 1026 | ||
1046 | /* Wait ... */ | 1027 | /* Wait ... */ |
1047 | udelay(5000L); | 1028 | udelay(5000L); |
1048 | 1029 | ||
1049 | /* Check which interrupt is in use */ | 1030 | /* Check which interrupt is in use */ |
1050 | irq = probe_irq_off(irqs); | 1031 | irq = probe_irq_off(irqs); |
1051 | 1032 | ||
1052 | /* Clean up */ | 1033 | /* Clean up */ |
1053 | save_xir = (u_char) cy_readb(address + (CyTIR<<index)); | 1034 | save_xir = (u_char) cy_readb(address + (CyTIR << index)); |
1054 | save_car = cy_readb(address + (CyCAR<<index)); | 1035 | save_car = cy_readb(address + (CyCAR << index)); |
1055 | cy_writeb(address + (CyCAR<<index), (save_xir & 0x3)); | 1036 | cy_writeb(address + (CyCAR << index), (save_xir & 0x3)); |
1056 | cy_writeb(address + (CySRER<<index), | 1037 | cy_writeb(address + (CySRER << index), |
1057 | cy_readb(address + (CySRER<<index)) & ~CyTxRdy); | 1038 | cy_readb(address + (CySRER << index)) & ~CyTxRdy); |
1058 | cy_writeb(address + (CyTIR<<index), (save_xir & 0x3f)); | 1039 | cy_writeb(address + (CyTIR << index), (save_xir & 0x3f)); |
1059 | cy_writeb(address + (CyCAR<<index), (save_car)); | 1040 | cy_writeb(address + (CyCAR << index), (save_car)); |
1060 | cy_writeb(address + (Cy_ClrIntr<<index), 0); | 1041 | cy_writeb(address + (Cy_ClrIntr << index), 0); |
1061 | /* Cy_ClrIntr is 0x1800 */ | 1042 | /* Cy_ClrIntr is 0x1800 */ |
1062 | 1043 | ||
1063 | return (irq > 0)? irq : 0; | 1044 | return (irq > 0) ? irq : 0; |
1064 | } | 1045 | } |
1065 | #endif /* CONFIG_ISA */ | 1046 | #endif /* CONFIG_ISA */ |
1066 | 1047 | ||
1067 | /* The real interrupt service routine is called | 1048 | static void cyy_intr_chip(struct cyclades_card *cinfo, int chip, |
1068 | whenever the card wants its hand held--chars | 1049 | void __iomem * base_addr, int status, int index) |
1069 | received, out buffer empty, modem change, etc. | ||
1070 | */ | ||
1071 | static irqreturn_t | ||
1072 | cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
1073 | { | 1050 | { |
1074 | struct tty_struct *tty; | 1051 | struct cyclades_port *info; |
1075 | int status; | 1052 | struct tty_struct *tty; |
1076 | struct cyclades_card *cinfo; | 1053 | volatile int char_count; |
1077 | struct cyclades_port *info; | 1054 | int i, j, len, mdm_change, mdm_status, outch; |
1078 | void __iomem *base_addr, *card_base_addr; | 1055 | int save_xir, channel, save_car; |
1079 | int chip; | 1056 | char data; |
1080 | int save_xir, channel, save_car; | 1057 | |
1081 | char data; | 1058 | if (status & CySRReceive) { /* reception interrupt */ |
1082 | volatile int char_count; | ||
1083 | int outch; | ||
1084 | int i,j,index; | ||
1085 | int too_many; | ||
1086 | int had_work; | ||
1087 | int mdm_change; | ||
1088 | int mdm_status; | ||
1089 | int len; | ||
1090 | if((cinfo = (struct cyclades_card *)dev_id) == 0){ | ||
1091 | #ifdef CY_DEBUG_INTERRUPTS | 1059 | #ifdef CY_DEBUG_INTERRUPTS |
1092 | printk("cyy_interrupt: spurious interrupt %d\n\r", irq); | 1060 | printk("cyy_interrupt: rcvd intr, chip %d\n\r", chip); |
1093 | #endif | 1061 | #endif |
1094 | return IRQ_NONE; /* spurious interrupt */ | 1062 | /* determine the channel & change to that context */ |
1095 | } | 1063 | spin_lock(&cinfo->card_lock); |
1096 | 1064 | save_xir = (u_char) cy_readb(base_addr + (CyRIR << index)); | |
1097 | card_base_addr = cinfo->base_addr; | 1065 | channel = (u_short) (save_xir & CyIRChannel); |
1098 | index = cinfo->bus_index; | 1066 | i = channel + chip * 4 + cinfo->first_line; |
1099 | 1067 | info = &cy_port[i]; | |
1100 | 1068 | info->last_active = jiffies; | |
1101 | /* This loop checks all chips in the card. Make a note whenever | 1069 | save_car = cy_readb(base_addr + (CyCAR << index)); |
1102 | _any_ chip had some work to do, as this is considered an | 1070 | cy_writeb(base_addr + (CyCAR << index), save_xir); |
1103 | indication that there will be more to do. Only when no chip | 1071 | |
1104 | has any work does this outermost loop exit. | 1072 | /* if there is nowhere to put the data, discard it */ |
1105 | */ | 1073 | if (info->tty == 0) { |
1106 | do{ | 1074 | j = (cy_readb(base_addr + (CyRIVR << index)) & |
1107 | had_work = 0; | 1075 | CyIVRMask); |
1108 | for ( chip = 0 ; chip < cinfo->num_chips ; chip ++) { | 1076 | if (j == CyIVRRxEx) { /* exception */ |
1109 | base_addr = cinfo->base_addr + (cy_chip_offset[chip]<<index); | 1077 | data = cy_readb(base_addr + (CyRDSR << index)); |
1110 | too_many = 0; | 1078 | } else { /* normal character reception */ |
1111 | while ( (status = cy_readb(base_addr+(CySVRR<<index))) != 0x00) { | 1079 | char_count = cy_readb(base_addr + |
1112 | had_work++; | 1080 | (CyRDCR << index)); |
1113 | /* The purpose of the following test is to ensure that | 1081 | while (char_count--) { |
1114 | no chip can monopolize the driver. This forces the | 1082 | data = cy_readb(base_addr + |
1115 | chips to be checked in a round-robin fashion (after | 1083 | (CyRDSR << index)); |
1116 | draining each of a bunch (1000) of characters). | 1084 | } |
1117 | */ | 1085 | } |
1118 | if(1000<too_many++){ | 1086 | } else { /* there is an open port for this data */ |
1119 | break; | 1087 | tty = info->tty; |
1120 | } | 1088 | j = (cy_readb(base_addr + (CyRIVR << index)) & |
1121 | if (status & CySRReceive) { /* reception interrupt */ | 1089 | CyIVRMask); |
1122 | #ifdef CY_DEBUG_INTERRUPTS | 1090 | if (j == CyIVRRxEx) { /* exception */ |
1123 | printk("cyy_interrupt: rcvd intr, chip %d\n\r", chip); | 1091 | data = cy_readb(base_addr + (CyRDSR << index)); |
1124 | #endif | 1092 | |
1125 | /* determine the channel & change to that context */ | 1093 | /* For statistics only */ |
1126 | spin_lock(&cinfo->card_lock); | 1094 | if (data & CyBREAK) |
1127 | save_xir = (u_char) cy_readb(base_addr+(CyRIR<<index)); | 1095 | info->icount.brk++; |
1128 | channel = (u_short ) (save_xir & CyIRChannel); | 1096 | else if (data & CyFRAME) |
1129 | i = channel + chip * 4 + cinfo->first_line; | 1097 | info->icount.frame++; |
1130 | info = &cy_port[i]; | 1098 | else if (data & CyPARITY) |
1131 | info->last_active = jiffies; | 1099 | info->icount.parity++; |
1132 | save_car = cy_readb(base_addr+(CyCAR<<index)); | 1100 | else if (data & CyOVERRUN) |
1133 | cy_writeb(base_addr+(CyCAR<<index), save_xir); | 1101 | info->icount.overrun++; |
1134 | 1102 | ||
1135 | /* if there is nowhere to put the data, discard it */ | 1103 | if (data & info->ignore_status_mask) { |
1136 | if(info->tty == 0){ | ||
1137 | j = (cy_readb(base_addr+(CyRIVR<<index)) & CyIVRMask); | ||
1138 | if ( j == CyIVRRxEx ) { /* exception */ | ||
1139 | data = cy_readb(base_addr+(CyRDSR<<index)); | ||
1140 | } else { /* normal character reception */ | ||
1141 | char_count = cy_readb(base_addr+(CyRDCR<<index)); | ||
1142 | while(char_count--){ | ||
1143 | data = cy_readb(base_addr+(CyRDSR<<index)); | ||
1144 | } | ||
1145 | } | ||
1146 | }else{ /* there is an open port for this data */ | ||
1147 | tty = info->tty; | ||
1148 | j = (cy_readb(base_addr+(CyRIVR<<index)) & CyIVRMask); | ||
1149 | if ( j == CyIVRRxEx ) { /* exception */ | ||
1150 | data = cy_readb(base_addr+(CyRDSR<<index)); | ||
1151 | |||
1152 | /* For statistics only */ | ||
1153 | if (data & CyBREAK) | ||
1154 | info->icount.brk++; | ||
1155 | else if(data & CyFRAME) | ||
1156 | info->icount.frame++; | ||
1157 | else if(data & CyPARITY) | ||
1158 | info->icount.parity++; | ||
1159 | else if(data & CyOVERRUN) | ||
1160 | info->icount.overrun++; | ||
1161 | |||
1162 | if(data & info->ignore_status_mask){ | ||
1163 | info->icount.rx++; | ||
1164 | continue; | ||
1165 | } | ||
1166 | if (tty_buffer_request_room(tty, 1)) { | ||
1167 | if (data & info->read_status_mask){ | ||
1168 | if(data & CyBREAK){ | ||
1169 | tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_BREAK); | ||
1170 | info->icount.rx++; | ||
1171 | if (info->flags & ASYNC_SAK){ | ||
1172 | do_SAK(tty); | ||
1173 | } | ||
1174 | }else if(data & CyFRAME){ | ||
1175 | tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_FRAME); | ||
1176 | info->icount.rx++; | ||
1177 | info->idle_stats.frame_errs++; | ||
1178 | }else if(data & CyPARITY){ | ||
1179 | /* Pieces of seven... */ | ||
1180 | tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_PARITY); | ||
1181 | info->icount.rx++; | ||
1182 | info->idle_stats.parity_errs++; | ||
1183 | }else if(data & CyOVERRUN){ | ||
1184 | tty_insert_flip_char(tty, 0, TTY_OVERRUN); | ||
1185 | info->icount.rx++; | 1104 | info->icount.rx++; |
1186 | /* If the flip buffer itself is | 1105 | return; |
1187 | overflowing, we still lose | 1106 | } |
1188 | the next incoming character. | 1107 | if (tty_buffer_request_room(tty, 1)) { |
1189 | */ | 1108 | if (data & info->read_status_mask) { |
1190 | tty_insert_flip_char(tty, cy_readb(base_addr+(CyRDSR<<index)), TTY_FRAME); | 1109 | if (data & CyBREAK) { |
1191 | info->icount.rx++; | 1110 | tty_insert_flip_char( |
1111 | tty, | ||
1112 | cy_readb( | ||
1113 | base_addr + | ||
1114 | (CyRDSR << | ||
1115 | index)), | ||
1116 | TTY_BREAK); | ||
1117 | info->icount.rx++; | ||
1118 | if (info->flags & | ||
1119 | ASYNC_SAK) { | ||
1120 | do_SAK(tty); | ||
1121 | } | ||
1122 | } else if (data & CyFRAME) { | ||
1123 | tty_insert_flip_char( | ||
1124 | tty, | ||
1125 | cy_readb( | ||
1126 | base_addr + | ||
1127 | (CyRDSR << | ||
1128 | index)), | ||
1129 | TTY_FRAME); | ||
1130 | info->icount.rx++; | ||
1131 | info->idle_stats. | ||
1132 | frame_errs++; | ||
1133 | } else if (data & CyPARITY) { | ||
1134 | /* Pieces of seven... */ | ||
1135 | tty_insert_flip_char( | ||
1136 | tty, | ||
1137 | cy_readb( | ||
1138 | base_addr + | ||
1139 | (CyRDSR << | ||
1140 | index)), | ||
1141 | TTY_PARITY); | ||
1142 | info->icount.rx++; | ||
1143 | info->idle_stats. | ||
1144 | parity_errs++; | ||
1145 | } else if (data & CyOVERRUN) { | ||
1146 | tty_insert_flip_char( | ||
1147 | tty, 0, | ||
1148 | TTY_OVERRUN); | ||
1149 | info->icount.rx++; | ||
1150 | /* If the flip buffer itself is | ||
1151 | overflowing, we still lose | ||
1152 | the next incoming character. | ||
1153 | */ | ||
1154 | tty_insert_flip_char( | ||
1155 | tty, | ||
1156 | cy_readb( | ||
1157 | base_addr + | ||
1158 | (CyRDSR << | ||
1159 | index)), | ||
1160 | TTY_FRAME); | ||
1161 | info->icount.rx++; | ||
1162 | info->idle_stats. | ||
1163 | overruns++; | ||
1164 | /* These two conditions may imply */ | ||
1165 | /* a normal read should be done. */ | ||
1166 | /* }else if(data & CyTIMEOUT){ */ | ||
1167 | /* }else if(data & CySPECHAR){ */ | ||
1168 | } else { | ||
1169 | tty_insert_flip_char( | ||
1170 | tty, 0, | ||
1171 | TTY_NORMAL); | ||
1172 | info->icount.rx++; | ||
1173 | } | ||
1174 | } else { | ||
1175 | tty_insert_flip_char(tty, 0, | ||
1176 | TTY_NORMAL); | ||
1177 | info->icount.rx++; | ||
1178 | } | ||
1179 | } else { | ||
1180 | /* there was a software buffer | ||
1181 | overrun and nothing could be | ||
1182 | done about it!!! */ | ||
1183 | info->icount.buf_overrun++; | ||
1192 | info->idle_stats.overruns++; | 1184 | info->idle_stats.overruns++; |
1193 | /* These two conditions may imply */ | 1185 | } |
1194 | /* a normal read should be done. */ | 1186 | } else { /* normal character reception */ |
1195 | /* }else if(data & CyTIMEOUT){ */ | 1187 | /* load # chars available from the chip */ |
1196 | /* }else if(data & CySPECHAR){ */ | 1188 | char_count = cy_readb(base_addr + |
1197 | }else { | 1189 | (CyRDCR << index)); |
1198 | tty_insert_flip_char(tty, 0, TTY_NORMAL); | ||
1199 | info->icount.rx++; | ||
1200 | } | ||
1201 | }else{ | ||
1202 | tty_insert_flip_char(tty, 0, TTY_NORMAL); | ||
1203 | info->icount.rx++; | ||
1204 | } | ||
1205 | }else{ | ||
1206 | /* there was a software buffer | ||
1207 | overrun and nothing could be | ||
1208 | done about it!!! */ | ||
1209 | info->icount.buf_overrun++; | ||
1210 | info->idle_stats.overruns++; | ||
1211 | } | ||
1212 | } else { /* normal character reception */ | ||
1213 | /* load # chars available from the chip */ | ||
1214 | char_count = cy_readb(base_addr+(CyRDCR<<index)); | ||
1215 | 1190 | ||
1216 | #ifdef CY_ENABLE_MONITORING | 1191 | #ifdef CY_ENABLE_MONITORING |
1217 | ++info->mon.int_count; | 1192 | ++info->mon.int_count; |
1218 | info->mon.char_count += char_count; | 1193 | info->mon.char_count += char_count; |
1219 | if (char_count > info->mon.char_max) | 1194 | if (char_count > info->mon.char_max) |
1220 | info->mon.char_max = char_count; | 1195 | info->mon.char_max = char_count; |
1221 | info->mon.char_last = char_count; | 1196 | info->mon.char_last = char_count; |
1222 | #endif | 1197 | #endif |
1223 | len = tty_buffer_request_room(tty, char_count); | 1198 | len = tty_buffer_request_room(tty, char_count); |
1224 | while(len--){ | 1199 | while (len--) { |
1225 | data = cy_readb(base_addr+(CyRDSR<<index)); | 1200 | data = cy_readb(base_addr + |
1226 | tty_insert_flip_char(tty, data, TTY_NORMAL); | 1201 | (CyRDSR << index)); |
1227 | info->idle_stats.recv_bytes++; | 1202 | tty_insert_flip_char(tty, data, |
1228 | info->icount.rx++; | 1203 | TTY_NORMAL); |
1204 | info->idle_stats.recv_bytes++; | ||
1205 | info->icount.rx++; | ||
1229 | #ifdef CY_16Y_HACK | 1206 | #ifdef CY_16Y_HACK |
1230 | udelay(10L); | 1207 | udelay(10L); |
1231 | #endif | 1208 | #endif |
1232 | } | 1209 | } |
1233 | info->idle_stats.recv_idle = jiffies; | 1210 | info->idle_stats.recv_idle = jiffies; |
1234 | } | 1211 | } |
1235 | tty_schedule_flip(tty); | 1212 | tty_schedule_flip(tty); |
1236 | } | 1213 | } |
1237 | /* end of service */ | 1214 | /* end of service */ |
1238 | cy_writeb(base_addr+(CyRIR<<index), (save_xir & 0x3f)); | 1215 | cy_writeb(base_addr + (CyRIR << index), (save_xir & 0x3f)); |
1239 | cy_writeb(base_addr+(CyCAR<<index), (save_car)); | 1216 | cy_writeb(base_addr + (CyCAR << index), (save_car)); |
1240 | spin_unlock(&cinfo->card_lock); | 1217 | spin_unlock(&cinfo->card_lock); |
1241 | } | 1218 | } |
1242 | 1219 | ||
1243 | 1220 | if (status & CySRTransmit) { /* transmission interrupt */ | |
1244 | if (status & CySRTransmit) { /* transmission interrupt */ | 1221 | /* Since we only get here when the transmit buffer |
1245 | /* Since we only get here when the transmit buffer | 1222 | is empty, we know we can always stuff a dozen |
1246 | is empty, we know we can always stuff a dozen | 1223 | characters. */ |
1247 | characters. */ | ||
1248 | #ifdef CY_DEBUG_INTERRUPTS | 1224 | #ifdef CY_DEBUG_INTERRUPTS |
1249 | printk("cyy_interrupt: xmit intr, chip %d\n\r", chip); | 1225 | printk("cyy_interrupt: xmit intr, chip %d\n\r", chip); |
1250 | #endif | 1226 | #endif |
1251 | 1227 | ||
1252 | /* determine the channel & change to that context */ | 1228 | /* determine the channel & change to that context */ |
1253 | spin_lock(&cinfo->card_lock); | 1229 | spin_lock(&cinfo->card_lock); |
1254 | save_xir = (u_char) cy_readb(base_addr+(CyTIR<<index)); | 1230 | save_xir = (u_char) cy_readb(base_addr + (CyTIR << index)); |
1255 | channel = (u_short ) (save_xir & CyIRChannel); | 1231 | channel = (u_short) (save_xir & CyIRChannel); |
1256 | i = channel + chip * 4 + cinfo->first_line; | 1232 | i = channel + chip * 4 + cinfo->first_line; |
1257 | save_car = cy_readb(base_addr+(CyCAR<<index)); | 1233 | save_car = cy_readb(base_addr + (CyCAR << index)); |
1258 | cy_writeb(base_addr+(CyCAR<<index), save_xir); | 1234 | cy_writeb(base_addr + (CyCAR << index), save_xir); |
1259 | 1235 | ||
1260 | /* validate the port# (as configured and open) */ | 1236 | /* validate the port# (as configured and open) */ |
1261 | if( (i < 0) || (NR_PORTS <= i) ){ | 1237 | if ((i < 0) || (NR_PORTS <= i)) { |
1262 | cy_writeb(base_addr+(CySRER<<index), | 1238 | cy_writeb(base_addr + (CySRER << index), |
1263 | cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy); | 1239 | cy_readb(base_addr + (CySRER << index)) & |
1264 | goto txend; | 1240 | ~CyTxRdy); |
1265 | } | 1241 | goto txend; |
1266 | info = &cy_port[i]; | 1242 | } |
1267 | info->last_active = jiffies; | 1243 | info = &cy_port[i]; |
1268 | if(info->tty == 0){ | 1244 | info->last_active = jiffies; |
1269 | cy_writeb(base_addr+(CySRER<<index), | 1245 | if (info->tty == 0) { |
1270 | cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy); | 1246 | cy_writeb(base_addr + (CySRER << index), |
1271 | goto txdone; | 1247 | cy_readb(base_addr + (CySRER << index)) & |
1272 | } | 1248 | ~CyTxRdy); |
1273 | 1249 | goto txdone; | |
1274 | /* load the on-chip space for outbound data */ | 1250 | } |
1275 | char_count = info->xmit_fifo_size; | 1251 | |
1276 | 1252 | /* load the on-chip space for outbound data */ | |
1277 | if(info->x_char) { /* send special char */ | 1253 | char_count = info->xmit_fifo_size; |
1278 | outch = info->x_char; | 1254 | |
1279 | cy_writeb(base_addr+(CyTDR<<index), outch); | 1255 | if (info->x_char) { /* send special char */ |
1280 | char_count--; | 1256 | outch = info->x_char; |
1257 | cy_writeb(base_addr + (CyTDR << index), outch); | ||
1258 | char_count--; | ||
1281 | info->icount.tx++; | 1259 | info->icount.tx++; |
1282 | info->x_char = 0; | 1260 | info->x_char = 0; |
1283 | } | 1261 | } |
1284 | 1262 | ||
1285 | if (info->breakon || info->breakoff) { | 1263 | if (info->breakon || info->breakoff) { |
1286 | if (info->breakon) { | 1264 | if (info->breakon) { |
1287 | cy_writeb(base_addr + (CyTDR<<index), 0); | 1265 | cy_writeb(base_addr + (CyTDR << index), 0); |
1288 | cy_writeb(base_addr + (CyTDR<<index), 0x81); | 1266 | cy_writeb(base_addr + (CyTDR << index), 0x81); |
1289 | info->breakon = 0; | 1267 | info->breakon = 0; |
1290 | char_count -= 2; | 1268 | char_count -= 2; |
1291 | } | 1269 | } |
1292 | if (info->breakoff) { | 1270 | if (info->breakoff) { |
1293 | cy_writeb(base_addr + (CyTDR<<index), 0); | 1271 | cy_writeb(base_addr + (CyTDR << index), 0); |
1294 | cy_writeb(base_addr + (CyTDR<<index), 0x83); | 1272 | cy_writeb(base_addr + (CyTDR << index), 0x83); |
1295 | info->breakoff = 0; | 1273 | info->breakoff = 0; |
1296 | char_count -= 2; | 1274 | char_count -= 2; |
1297 | } | 1275 | } |
1298 | } | 1276 | } |
1299 | 1277 | ||
1300 | while (char_count-- > 0){ | 1278 | while (char_count-- > 0) { |
1301 | if (!info->xmit_cnt){ | 1279 | if (!info->xmit_cnt) { |
1302 | if (cy_readb(base_addr+(CySRER<<index))&CyTxMpty) { | 1280 | if (cy_readb(base_addr + (CySRER << index)) & |
1303 | cy_writeb(base_addr+(CySRER<<index), | 1281 | CyTxMpty) { |
1304 | cy_readb(base_addr+(CySRER<<index)) & | 1282 | cy_writeb(base_addr + (CySRER << index), |
1305 | ~CyTxMpty); | 1283 | cy_readb(base_addr + |
1306 | } else { | 1284 | (CySRER << index)) & |
1307 | cy_writeb(base_addr+(CySRER<<index), | 1285 | ~CyTxMpty); |
1308 | ((cy_readb(base_addr+(CySRER<<index)) | 1286 | } else { |
1309 | & ~CyTxRdy) | 1287 | cy_writeb(base_addr + (CySRER << index), |
1310 | | CyTxMpty)); | 1288 | (cy_readb(base_addr + |
1311 | } | 1289 | (CySRER << index)) & |
1312 | goto txdone; | 1290 | ~CyTxRdy) | CyTxMpty); |
1291 | } | ||
1292 | goto txdone; | ||
1313 | } | 1293 | } |
1314 | if (info->xmit_buf == 0){ | 1294 | if (info->xmit_buf == 0) { |
1315 | cy_writeb(base_addr+(CySRER<<index), | 1295 | cy_writeb(base_addr + (CySRER << index), |
1316 | cy_readb(base_addr+(CySRER<<index)) & | 1296 | cy_readb(base_addr + (CySRER << index))& |
1317 | ~CyTxRdy); | 1297 | ~CyTxRdy); |
1318 | goto txdone; | 1298 | goto txdone; |
1319 | } | 1299 | } |
1320 | if (info->tty->stopped || info->tty->hw_stopped){ | 1300 | if (info->tty->stopped || info->tty->hw_stopped) { |
1321 | cy_writeb(base_addr+(CySRER<<index), | 1301 | cy_writeb(base_addr + (CySRER << index), |
1322 | cy_readb(base_addr+(CySRER<<index)) & | 1302 | cy_readb(base_addr + (CySRER << index))& |
1323 | ~CyTxRdy); | 1303 | ~CyTxRdy); |
1324 | goto txdone; | 1304 | goto txdone; |
1325 | } | 1305 | } |
1326 | /* Because the Embedded Transmit Commands have | 1306 | /* Because the Embedded Transmit Commands have |
1327 | been enabled, we must check to see if the | 1307 | been enabled, we must check to see if the |
1328 | escape character, NULL, is being sent. If it | 1308 | escape character, NULL, is being sent. If it |
1329 | is, we must ensure that there is room for it | 1309 | is, we must ensure that there is room for it |
1330 | to be doubled in the output stream. Therefore | 1310 | to be doubled in the output stream. Therefore |
@@ -1333,125 +1313,182 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
1333 | after the check for a NULL output character. | 1313 | after the check for a NULL output character. |
1334 | This is necessary because there may not be | 1314 | This is necessary because there may not be |
1335 | room for the two chars needed to send a NULL.) | 1315 | room for the two chars needed to send a NULL.) |
1336 | */ | 1316 | */ |
1337 | outch = info->xmit_buf[info->xmit_tail]; | 1317 | outch = info->xmit_buf[info->xmit_tail]; |
1338 | if( outch ){ | 1318 | if (outch) { |
1339 | info->xmit_cnt--; | 1319 | info->xmit_cnt--; |
1340 | info->xmit_tail = (info->xmit_tail + 1) | 1320 | info->xmit_tail = (info->xmit_tail + 1) & |
1341 | & (SERIAL_XMIT_SIZE - 1); | 1321 | (SERIAL_XMIT_SIZE - 1); |
1342 | cy_writeb(base_addr+(CyTDR<<index), outch); | 1322 | cy_writeb(base_addr + (CyTDR << index), outch); |
1343 | info->icount.tx++; | ||
1344 | }else{ | ||
1345 | if(char_count > 1){ | ||
1346 | info->xmit_cnt--; | ||
1347 | info->xmit_tail = (info->xmit_tail + 1) | ||
1348 | & (SERIAL_XMIT_SIZE - 1); | ||
1349 | cy_writeb(base_addr+(CyTDR<<index), | ||
1350 | outch); | ||
1351 | cy_writeb(base_addr+(CyTDR<<index), 0); | ||
1352 | info->icount.tx++; | 1323 | info->icount.tx++; |
1353 | char_count--; | 1324 | } else { |
1354 | }else{ | 1325 | if (char_count > 1) { |
1355 | } | 1326 | info->xmit_cnt--; |
1356 | } | 1327 | info->xmit_tail = (info->xmit_tail + 1)& |
1357 | } | 1328 | (SERIAL_XMIT_SIZE - 1); |
1358 | 1329 | cy_writeb(base_addr + (CyTDR << index), | |
1359 | txdone: | 1330 | outch); |
1360 | if (info->xmit_cnt < WAKEUP_CHARS) { | 1331 | cy_writeb(base_addr + (CyTDR << index), |
1361 | cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); | 1332 | 0); |
1362 | } | 1333 | info->icount.tx++; |
1363 | txend: | 1334 | char_count--; |
1364 | /* end of service */ | 1335 | } else { |
1365 | cy_writeb(base_addr+(CyTIR<<index), | 1336 | } |
1366 | (save_xir & 0x3f)); | 1337 | } |
1367 | cy_writeb(base_addr+(CyCAR<<index), (save_car)); | 1338 | } |
1368 | spin_unlock(&cinfo->card_lock); | 1339 | |
1369 | } | 1340 | txdone: |
1370 | 1341 | if (info->xmit_cnt < WAKEUP_CHARS) { | |
1371 | if (status & CySRModem) { /* modem interrupt */ | 1342 | cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); |
1372 | 1343 | } | |
1373 | /* determine the channel & change to that context */ | 1344 | txend: |
1374 | spin_lock(&cinfo->card_lock); | 1345 | /* end of service */ |
1375 | save_xir = (u_char) cy_readb(base_addr+(CyMIR<<index)); | 1346 | cy_writeb(base_addr + (CyTIR << index), (save_xir & 0x3f)); |
1376 | channel = (u_short ) (save_xir & CyIRChannel); | 1347 | cy_writeb(base_addr + (CyCAR << index), (save_car)); |
1377 | info = &cy_port[channel + chip * 4 | 1348 | spin_unlock(&cinfo->card_lock); |
1378 | + cinfo->first_line]; | 1349 | } |
1379 | info->last_active = jiffies; | 1350 | |
1380 | save_car = cy_readb(base_addr+(CyCAR<<index)); | 1351 | if (status & CySRModem) { /* modem interrupt */ |
1381 | cy_writeb(base_addr+(CyCAR<<index), save_xir); | 1352 | |
1382 | 1353 | /* determine the channel & change to that context */ | |
1383 | mdm_change = cy_readb(base_addr+(CyMISR<<index)); | 1354 | spin_lock(&cinfo->card_lock); |
1384 | mdm_status = cy_readb(base_addr+(CyMSVR1<<index)); | 1355 | save_xir = (u_char) cy_readb(base_addr + (CyMIR << index)); |
1385 | 1356 | channel = (u_short) (save_xir & CyIRChannel); | |
1386 | if(info->tty == 0){/* no place for data, ignore it*/ | 1357 | info = &cy_port[channel + chip * 4 + cinfo->first_line]; |
1387 | ; | 1358 | info->last_active = jiffies; |
1388 | }else{ | 1359 | save_car = cy_readb(base_addr + (CyCAR << index)); |
1360 | cy_writeb(base_addr + (CyCAR << index), save_xir); | ||
1361 | |||
1362 | mdm_change = cy_readb(base_addr + (CyMISR << index)); | ||
1363 | mdm_status = cy_readb(base_addr + (CyMSVR1 << index)); | ||
1364 | |||
1365 | if (info->tty == 0) { /* no place for data, ignore it */ | ||
1366 | ; | ||
1367 | } else { | ||
1389 | if (mdm_change & CyANY_DELTA) { | 1368 | if (mdm_change & CyANY_DELTA) { |
1390 | /* For statistics only */ | 1369 | /* For statistics only */ |
1391 | if (mdm_change & CyDCD) info->icount.dcd++; | 1370 | if (mdm_change & CyDCD) |
1392 | if (mdm_change & CyCTS) info->icount.cts++; | 1371 | info->icount.dcd++; |
1393 | if (mdm_change & CyDSR) info->icount.dsr++; | 1372 | if (mdm_change & CyCTS) |
1394 | if (mdm_change & CyRI) info->icount.rng++; | 1373 | info->icount.cts++; |
1374 | if (mdm_change & CyDSR) | ||
1375 | info->icount.dsr++; | ||
1376 | if (mdm_change & CyRI) | ||
1377 | info->icount.rng++; | ||
1378 | |||
1379 | cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); | ||
1380 | } | ||
1381 | |||
1382 | if ((mdm_change & CyDCD) && | ||
1383 | (info->flags & ASYNC_CHECK_CD)) { | ||
1384 | if (mdm_status & CyDCD) { | ||
1385 | cy_sched_event(info, | ||
1386 | Cy_EVENT_OPEN_WAKEUP); | ||
1387 | } else { | ||
1388 | cy_sched_event(info, Cy_EVENT_HANGUP); | ||
1389 | } | ||
1390 | } | ||
1391 | if ((mdm_change & CyCTS) && | ||
1392 | (info->flags & ASYNC_CTS_FLOW)) { | ||
1393 | if (info->tty->hw_stopped) { | ||
1394 | if (mdm_status & CyCTS) { | ||
1395 | /* cy_start isn't used | ||
1396 | because... !!! */ | ||
1397 | info->tty->hw_stopped = 0; | ||
1398 | cy_writeb(base_addr + | ||
1399 | (CySRER << index), | ||
1400 | cy_readb(base_addr + | ||
1401 | (CySRER << | ||
1402 | index))| | ||
1403 | CyTxRdy); | ||
1404 | cy_sched_event(info, | ||
1405 | Cy_EVENT_WRITE_WAKEUP); | ||
1406 | } | ||
1407 | } else { | ||
1408 | if (!(mdm_status & CyCTS)) { | ||
1409 | /* cy_stop isn't used | ||
1410 | because ... !!! */ | ||
1411 | info->tty->hw_stopped = 1; | ||
1412 | cy_writeb(base_addr + | ||
1413 | (CySRER << index), | ||
1414 | cy_readb(base_addr + | ||
1415 | (CySRER << | ||
1416 | index)) & | ||
1417 | ~CyTxRdy); | ||
1418 | } | ||
1419 | } | ||
1420 | } | ||
1421 | if (mdm_change & CyDSR) { | ||
1422 | } | ||
1423 | if (mdm_change & CyRI) { | ||
1424 | } | ||
1425 | } | ||
1426 | /* end of service */ | ||
1427 | cy_writeb(base_addr + (CyMIR << index), (save_xir & 0x3f)); | ||
1428 | cy_writeb(base_addr + (CyCAR << index), save_car); | ||
1429 | spin_unlock(&cinfo->card_lock); | ||
1430 | } | ||
1431 | } | ||
1432 | |||
1433 | /* The real interrupt service routine is called | ||
1434 | whenever the card wants its hand held--chars | ||
1435 | received, out buffer empty, modem change, etc. | ||
1436 | */ | ||
1437 | static irqreturn_t cyy_interrupt(int irq, void *dev_id) | ||
1438 | { | ||
1439 | int status; | ||
1440 | struct cyclades_card *cinfo; | ||
1441 | void __iomem *base_addr, *card_base_addr; | ||
1442 | int chip; | ||
1443 | int index; | ||
1444 | int too_many; | ||
1445 | int had_work; | ||
1446 | |||
1447 | if ((cinfo = (struct cyclades_card *)dev_id) == 0) { | ||
1448 | #ifdef CY_DEBUG_INTERRUPTS | ||
1449 | printk("cyy_interrupt: spurious interrupt %d\n\r", irq); | ||
1450 | #endif | ||
1451 | return IRQ_NONE; /* spurious interrupt */ | ||
1452 | } | ||
1453 | |||
1454 | card_base_addr = cinfo->base_addr; | ||
1455 | index = cinfo->bus_index; | ||
1395 | 1456 | ||
1396 | cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); | 1457 | /* This loop checks all chips in the card. Make a note whenever |
1458 | _any_ chip had some work to do, as this is considered an | ||
1459 | indication that there will be more to do. Only when no chip | ||
1460 | has any work does this outermost loop exit. | ||
1461 | */ | ||
1462 | do { | ||
1463 | had_work = 0; | ||
1464 | for (chip = 0; chip < cinfo->num_chips; chip++) { | ||
1465 | base_addr = cinfo->base_addr + | ||
1466 | (cy_chip_offset[chip] << index); | ||
1467 | too_many = 0; | ||
1468 | while ((status = cy_readb(base_addr + | ||
1469 | (CySVRR << index))) != 0x00) { | ||
1470 | had_work++; | ||
1471 | /* The purpose of the following test is to ensure that | ||
1472 | no chip can monopolize the driver. This forces the | ||
1473 | chips to be checked in a round-robin fashion (after | ||
1474 | draining each of a bunch (1000) of characters). | ||
1475 | */ | ||
1476 | if (1000 < too_many++) { | ||
1477 | break; | ||
1478 | } | ||
1479 | cyy_intr_chip(cinfo, chip, base_addr, status, | ||
1480 | index); | ||
1397 | } | 1481 | } |
1482 | } | ||
1483 | } while (had_work); | ||
1398 | 1484 | ||
1399 | if((mdm_change & CyDCD) | 1485 | /* clear interrupts */ |
1400 | && (info->flags & ASYNC_CHECK_CD)){ | 1486 | spin_lock(&cinfo->card_lock); |
1401 | if(mdm_status & CyDCD){ | 1487 | cy_writeb(card_base_addr + (Cy_ClrIntr << index), 0); |
1402 | cy_sched_event(info, | 1488 | /* Cy_ClrIntr is 0x1800 */ |
1403 | Cy_EVENT_OPEN_WAKEUP); | 1489 | spin_unlock(&cinfo->card_lock); |
1404 | }else{ | 1490 | return IRQ_HANDLED; |
1405 | cy_sched_event(info, | 1491 | } /* cyy_interrupt */ |
1406 | Cy_EVENT_HANGUP); | ||
1407 | } | ||
1408 | } | ||
1409 | if((mdm_change & CyCTS) | ||
1410 | && (info->flags & ASYNC_CTS_FLOW)){ | ||
1411 | if(info->tty->hw_stopped){ | ||
1412 | if(mdm_status & CyCTS){ | ||
1413 | /* cy_start isn't used | ||
1414 | because... !!! */ | ||
1415 | info->tty->hw_stopped = 0; | ||
1416 | cy_writeb(base_addr+(CySRER<<index), | ||
1417 | cy_readb(base_addr+(CySRER<<index)) | | ||
1418 | CyTxRdy); | ||
1419 | cy_sched_event(info, | ||
1420 | Cy_EVENT_WRITE_WAKEUP); | ||
1421 | } | ||
1422 | }else{ | ||
1423 | if(!(mdm_status & CyCTS)){ | ||
1424 | /* cy_stop isn't used | ||
1425 | because ... !!! */ | ||
1426 | info->tty->hw_stopped = 1; | ||
1427 | cy_writeb(base_addr+(CySRER<<index), | ||
1428 | cy_readb(base_addr+(CySRER<<index)) & | ||
1429 | ~CyTxRdy); | ||
1430 | } | ||
1431 | } | ||
1432 | } | ||
1433 | if(mdm_change & CyDSR){ | ||
1434 | } | ||
1435 | if(mdm_change & CyRI){ | ||
1436 | } | ||
1437 | } | ||
1438 | /* end of service */ | ||
1439 | cy_writeb(base_addr+(CyMIR<<index), | ||
1440 | (save_xir & 0x3f)); | ||
1441 | cy_writeb(base_addr+(CyCAR<<index), save_car); | ||
1442 | spin_unlock(&cinfo->card_lock); | ||
1443 | } | ||
1444 | } /* end while status != 0 */ | ||
1445 | } /* end loop for chips... */ | ||
1446 | } while(had_work); | ||
1447 | |||
1448 | /* clear interrupts */ | ||
1449 | spin_lock(&cinfo->card_lock); | ||
1450 | cy_writeb(card_base_addr + (Cy_ClrIntr<<index), 0); | ||
1451 | /* Cy_ClrIntr is 0x1800 */ | ||
1452 | spin_unlock(&cinfo->card_lock); | ||
1453 | return IRQ_HANDLED; | ||
1454 | } /* cyy_interrupt */ | ||
1455 | 1492 | ||
1456 | /***********************************************************/ | 1493 | /***********************************************************/ |
1457 | /********* End of block of Cyclom-Y specific code **********/ | 1494 | /********* End of block of Cyclom-Y specific code **********/ |
@@ -1459,643 +1496,655 @@ cyy_interrupt(int irq, void *dev_id, struct pt_regs *regs) | |||
1459 | /***********************************************************/ | 1496 | /***********************************************************/ |
1460 | 1497 | ||
1461 | static int | 1498 | static int |
1462 | cyz_fetch_msg( struct cyclades_card *cinfo, | 1499 | cyz_fetch_msg(struct cyclades_card *cinfo, |
1463 | uclong *channel, ucchar *cmd, uclong *param) | 1500 | uclong * channel, ucchar * cmd, uclong * param) |
1464 | { | 1501 | { |
1465 | struct FIRM_ID __iomem *firm_id; | 1502 | struct FIRM_ID __iomem *firm_id; |
1466 | struct ZFW_CTRL __iomem *zfw_ctrl; | 1503 | struct ZFW_CTRL __iomem *zfw_ctrl; |
1467 | struct BOARD_CTRL __iomem *board_ctrl; | 1504 | struct BOARD_CTRL __iomem *board_ctrl; |
1468 | unsigned long loc_doorbell; | 1505 | unsigned long loc_doorbell; |
1469 | 1506 | ||
1470 | firm_id = cinfo->base_addr + ID_ADDRESS; | 1507 | firm_id = cinfo->base_addr + ID_ADDRESS; |
1471 | if (!ISZLOADED(*cinfo)){ | 1508 | if (!ISZLOADED(*cinfo)) { |
1472 | return (-1); | 1509 | return -1; |
1473 | } | 1510 | } |
1474 | zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1511 | zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & |
1475 | board_ctrl = &zfw_ctrl->board_ctrl; | 1512 | 0xfffff); |
1476 | 1513 | board_ctrl = &zfw_ctrl->board_ctrl; | |
1477 | loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *) | 1514 | |
1478 | (cinfo->ctl_addr))->loc_doorbell); | 1515 | loc_doorbell = cy_readl(&((struct RUNTIME_9060 __iomem *) |
1479 | if (loc_doorbell){ | 1516 | (cinfo->ctl_addr))->loc_doorbell); |
1480 | *cmd = (char)(0xff & loc_doorbell); | 1517 | if (loc_doorbell) { |
1481 | *channel = cy_readl(&board_ctrl->fwcmd_channel); | 1518 | *cmd = (char)(0xff & loc_doorbell); |
1482 | *param = (uclong)cy_readl(&board_ctrl->fwcmd_param); | 1519 | *channel = cy_readl(&board_ctrl->fwcmd_channel); |
1483 | cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->loc_doorbell, | 1520 | *param = (uclong) cy_readl(&board_ctrl->fwcmd_param); |
1484 | 0xffffffff); | 1521 | cy_writel(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))-> |
1485 | return 1; | 1522 | loc_doorbell, 0xffffffff); |
1486 | } | 1523 | return 1; |
1487 | return 0; | 1524 | } |
1488 | } /* cyz_fetch_msg */ | 1525 | return 0; |
1526 | } /* cyz_fetch_msg */ | ||
1489 | 1527 | ||
1490 | static int | 1528 | static int |
1491 | cyz_issue_cmd( struct cyclades_card *cinfo, | 1529 | cyz_issue_cmd(struct cyclades_card *cinfo, |
1492 | uclong channel, ucchar cmd, uclong param) | 1530 | uclong channel, ucchar cmd, uclong param) |
1493 | { | 1531 | { |
1494 | struct FIRM_ID __iomem *firm_id; | 1532 | struct FIRM_ID __iomem *firm_id; |
1495 | struct ZFW_CTRL __iomem *zfw_ctrl; | 1533 | struct ZFW_CTRL __iomem *zfw_ctrl; |
1496 | struct BOARD_CTRL __iomem *board_ctrl; | 1534 | struct BOARD_CTRL __iomem *board_ctrl; |
1497 | unsigned long __iomem *pci_doorbell; | 1535 | unsigned long __iomem *pci_doorbell; |
1498 | int index; | 1536 | int index; |
1499 | 1537 | ||
1500 | firm_id = cinfo->base_addr + ID_ADDRESS; | 1538 | firm_id = cinfo->base_addr + ID_ADDRESS; |
1501 | if (!ISZLOADED(*cinfo)){ | 1539 | if (!ISZLOADED(*cinfo)) { |
1502 | return (-1); | 1540 | return -1; |
1503 | } | 1541 | } |
1504 | zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1542 | zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & |
1505 | board_ctrl = &zfw_ctrl->board_ctrl; | 1543 | 0xfffff); |
1506 | 1544 | board_ctrl = &zfw_ctrl->board_ctrl; | |
1507 | index = 0; | 1545 | |
1508 | pci_doorbell = &((struct RUNTIME_9060 __iomem *) (cinfo->ctl_addr))->pci_doorbell; | 1546 | index = 0; |
1509 | while( (cy_readl(pci_doorbell) & 0xff) != 0){ | 1547 | pci_doorbell = |
1510 | if (index++ == 1000){ | 1548 | &((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->pci_doorbell; |
1511 | return((int)(cy_readl(pci_doorbell) & 0xff)); | 1549 | while ((cy_readl(pci_doorbell) & 0xff) != 0) { |
1512 | } | 1550 | if (index++ == 1000) { |
1513 | udelay(50L); | 1551 | return (int)(cy_readl(pci_doorbell) & 0xff); |
1514 | } | 1552 | } |
1515 | cy_writel(&board_ctrl->hcmd_channel, channel); | 1553 | udelay(50L); |
1516 | cy_writel(&board_ctrl->hcmd_param , param); | 1554 | } |
1517 | cy_writel(pci_doorbell, (long)cmd); | 1555 | cy_writel(&board_ctrl->hcmd_channel, channel); |
1518 | 1556 | cy_writel(&board_ctrl->hcmd_param, param); | |
1519 | return(0); | 1557 | cy_writel(pci_doorbell, (long)cmd); |
1520 | } /* cyz_issue_cmd */ | 1558 | |
1559 | return 0; | ||
1560 | } /* cyz_issue_cmd */ | ||
1521 | 1561 | ||
1522 | static void | 1562 | static void |
1523 | cyz_handle_rx(struct cyclades_port *info, | 1563 | cyz_handle_rx(struct cyclades_port *info, |
1524 | volatile struct CH_CTRL __iomem *ch_ctrl, | 1564 | volatile struct CH_CTRL __iomem * ch_ctrl, |
1525 | volatile struct BUF_CTRL __iomem *buf_ctrl) | 1565 | volatile struct BUF_CTRL __iomem * buf_ctrl) |
1526 | { | 1566 | { |
1527 | struct cyclades_card *cinfo = &cy_card[info->card]; | 1567 | struct cyclades_card *cinfo = &cy_card[info->card]; |
1528 | struct tty_struct *tty = info->tty; | 1568 | struct tty_struct *tty = info->tty; |
1529 | volatile int char_count; | 1569 | volatile int char_count; |
1530 | int len; | 1570 | int len; |
1531 | #ifdef BLOCKMOVE | 1571 | #ifdef BLOCKMOVE |
1532 | int small_count; | 1572 | int small_count; |
1533 | #else | 1573 | #else |
1534 | char data; | 1574 | char data; |
1535 | #endif | 1575 | #endif |
1536 | volatile uclong rx_put, rx_get, new_rx_get, rx_bufsize, rx_bufaddr; | 1576 | volatile uclong rx_put, rx_get, new_rx_get, rx_bufsize, rx_bufaddr; |
1537 | 1577 | ||
1538 | rx_get = new_rx_get = cy_readl(&buf_ctrl->rx_get); | 1578 | rx_get = new_rx_get = cy_readl(&buf_ctrl->rx_get); |
1539 | rx_put = cy_readl(&buf_ctrl->rx_put); | 1579 | rx_put = cy_readl(&buf_ctrl->rx_put); |
1540 | rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize); | 1580 | rx_bufsize = cy_readl(&buf_ctrl->rx_bufsize); |
1541 | rx_bufaddr = cy_readl(&buf_ctrl->rx_bufaddr); | 1581 | rx_bufaddr = cy_readl(&buf_ctrl->rx_bufaddr); |
1542 | if (rx_put >= rx_get) | 1582 | if (rx_put >= rx_get) |
1543 | char_count = rx_put - rx_get; | 1583 | char_count = rx_put - rx_get; |
1544 | else | 1584 | else |
1545 | char_count = rx_put - rx_get + rx_bufsize; | 1585 | char_count = rx_put - rx_get + rx_bufsize; |
1546 | 1586 | ||
1547 | if ( char_count ) { | 1587 | if (char_count) { |
1548 | info->last_active = jiffies; | 1588 | info->last_active = jiffies; |
1549 | info->jiffies[1] = jiffies; | 1589 | info->jiffies[1] = jiffies; |
1550 | 1590 | ||
1551 | #ifdef CY_ENABLE_MONITORING | 1591 | #ifdef CY_ENABLE_MONITORING |
1552 | info->mon.int_count++; | 1592 | info->mon.int_count++; |
1553 | info->mon.char_count += char_count; | 1593 | info->mon.char_count += char_count; |
1554 | if (char_count > info->mon.char_max) | 1594 | if (char_count > info->mon.char_max) |
1555 | info->mon.char_max = char_count; | 1595 | info->mon.char_max = char_count; |
1556 | info->mon.char_last = char_count; | 1596 | info->mon.char_last = char_count; |
1557 | #endif | 1597 | #endif |
1558 | if(tty == 0){ | 1598 | if (tty == 0) { |
1559 | /* flush received characters */ | 1599 | /* flush received characters */ |
1560 | new_rx_get = (new_rx_get + char_count) & (rx_bufsize - 1); | 1600 | new_rx_get = (new_rx_get + char_count) & |
1561 | info->rflush_count++; | 1601 | (rx_bufsize - 1); |
1562 | }else{ | 1602 | info->rflush_count++; |
1603 | } else { | ||
1563 | #ifdef BLOCKMOVE | 1604 | #ifdef BLOCKMOVE |
1564 | /* we'd like to use memcpy(t, f, n) and memset(s, c, count) | 1605 | /* we'd like to use memcpy(t, f, n) and memset(s, c, count) |
1565 | for performance, but because of buffer boundaries, there | 1606 | for performance, but because of buffer boundaries, there |
1566 | may be several steps to the operation */ | 1607 | may be several steps to the operation */ |
1567 | while(0 < (small_count = | 1608 | while (0 < (small_count = min_t(unsigned int, |
1568 | min_t(unsigned int, (rx_bufsize - new_rx_get), | 1609 | rx_bufsize - new_rx_get, |
1569 | min_t(unsigned int, (TTY_FLIPBUF_SIZE - tty->flip.count), char_count)) | 1610 | min_t(unsigned int, TTY_FLIPBUF_SIZE - |
1570 | )) { | 1611 | tty->flip.count, char_count)))){ |
1571 | memcpy_fromio(tty->flip.char_buf_ptr, | 1612 | memcpy_fromio(tty->flip.char_buf_ptr, |
1572 | (char *)(cinfo->base_addr | 1613 | (char *)(cinfo->base_addr + rx_bufaddr + |
1573 | + rx_bufaddr + new_rx_get), | 1614 | new_rx_get), |
1574 | small_count); | 1615 | small_count); |
1575 | 1616 | ||
1576 | tty->flip.char_buf_ptr += small_count; | 1617 | tty->flip.char_buf_ptr += small_count; |
1577 | memset(tty->flip.flag_buf_ptr, TTY_NORMAL, small_count); | 1618 | memset(tty->flip.flag_buf_ptr, TTY_NORMAL, |
1578 | tty->flip.flag_buf_ptr += small_count; | 1619 | small_count); |
1579 | new_rx_get = (new_rx_get + small_count) & (rx_bufsize - 1); | 1620 | tty->flip.flag_buf_ptr += small_count; |
1580 | char_count -= small_count; | 1621 | new_rx_get = (new_rx_get + small_count) & |
1581 | info->icount.rx += small_count; | 1622 | (rx_bufsize - 1); |
1582 | info->idle_stats.recv_bytes += small_count; | 1623 | char_count -= small_count; |
1583 | tty->flip.count += small_count; | 1624 | info->icount.rx += small_count; |
1584 | } | 1625 | info->idle_stats.recv_bytes += small_count; |
1626 | tty->flip.count += small_count; | ||
1627 | } | ||
1585 | #else | 1628 | #else |
1586 | len = tty_buffer_request_room(tty, char_count); | 1629 | len = tty_buffer_request_room(tty, char_count); |
1587 | while(len--){ | 1630 | while (len--) { |
1588 | data = cy_readb(cinfo->base_addr + rx_bufaddr + new_rx_get); | 1631 | data = cy_readb(cinfo->base_addr + rx_bufaddr + |
1589 | new_rx_get = (new_rx_get + 1) & (rx_bufsize - 1); | 1632 | new_rx_get); |
1590 | tty_insert_flip_char(tty, data, TTY_NORMAL); | 1633 | new_rx_get = (new_rx_get + 1)& (rx_bufsize - 1); |
1591 | info->idle_stats.recv_bytes++; | 1634 | tty_insert_flip_char(tty, data, TTY_NORMAL); |
1592 | info->icount.rx++; | 1635 | info->idle_stats.recv_bytes++; |
1593 | } | 1636 | info->icount.rx++; |
1637 | } | ||
1594 | #endif | 1638 | #endif |
1595 | #ifdef CONFIG_CYZ_INTR | 1639 | #ifdef CONFIG_CYZ_INTR |
1596 | /* Recalculate the number of chars in the RX buffer and issue | 1640 | /* Recalculate the number of chars in the RX buffer and issue |
1597 | a cmd in case it's higher than the RX high water mark */ | 1641 | a cmd in case it's higher than the RX high water mark */ |
1598 | rx_put = cy_readl(&buf_ctrl->rx_put); | 1642 | rx_put = cy_readl(&buf_ctrl->rx_put); |
1599 | if (rx_put >= rx_get) | 1643 | if (rx_put >= rx_get) |
1600 | char_count = rx_put - rx_get; | 1644 | char_count = rx_put - rx_get; |
1601 | else | 1645 | else |
1602 | char_count = rx_put - rx_get + rx_bufsize; | 1646 | char_count = rx_put - rx_get + rx_bufsize; |
1603 | if(char_count >= cy_readl(&buf_ctrl->rx_threshold)) { | 1647 | if (char_count >= (int)cy_readl(&buf_ctrl-> |
1604 | cy_sched_event(info, Cy_EVENT_Z_RX_FULL); | 1648 | rx_threshold)) { |
1605 | } | 1649 | cy_sched_event(info, Cy_EVENT_Z_RX_FULL); |
1650 | } | ||
1606 | #endif | 1651 | #endif |
1607 | info->idle_stats.recv_idle = jiffies; | 1652 | info->idle_stats.recv_idle = jiffies; |
1608 | tty_schedule_flip(tty); | 1653 | tty_schedule_flip(tty); |
1654 | } | ||
1655 | /* Update rx_get */ | ||
1656 | cy_writel(&buf_ctrl->rx_get, new_rx_get); | ||
1609 | } | 1657 | } |
1610 | /* Update rx_get */ | ||
1611 | cy_writel(&buf_ctrl->rx_get, new_rx_get); | ||
1612 | } | ||
1613 | } | 1658 | } |
1614 | 1659 | ||
1615 | static void | 1660 | static void |
1616 | cyz_handle_tx(struct cyclades_port *info, | 1661 | cyz_handle_tx(struct cyclades_port *info, |
1617 | volatile struct CH_CTRL __iomem *ch_ctrl, | 1662 | volatile struct CH_CTRL __iomem * ch_ctrl, |
1618 | volatile struct BUF_CTRL __iomem *buf_ctrl) | 1663 | volatile struct BUF_CTRL __iomem * buf_ctrl) |
1619 | { | 1664 | { |
1620 | struct cyclades_card *cinfo = &cy_card[info->card]; | 1665 | struct cyclades_card *cinfo = &cy_card[info->card]; |
1621 | struct tty_struct *tty = info->tty; | 1666 | struct tty_struct *tty = info->tty; |
1622 | char data; | 1667 | char data; |
1623 | volatile int char_count; | 1668 | volatile int char_count; |
1624 | #ifdef BLOCKMOVE | 1669 | #ifdef BLOCKMOVE |
1625 | int small_count; | 1670 | int small_count; |
1626 | #endif | 1671 | #endif |
1627 | volatile uclong tx_put, tx_get, tx_bufsize, tx_bufaddr; | 1672 | volatile uclong tx_put, tx_get, tx_bufsize, tx_bufaddr; |
1628 | 1673 | ||
1629 | if (info->xmit_cnt <= 0) /* Nothing to transmit */ | 1674 | if (info->xmit_cnt <= 0) /* Nothing to transmit */ |
1630 | return; | 1675 | return; |
1631 | 1676 | ||
1632 | tx_get = cy_readl(&buf_ctrl->tx_get); | 1677 | tx_get = cy_readl(&buf_ctrl->tx_get); |
1633 | tx_put = cy_readl(&buf_ctrl->tx_put); | 1678 | tx_put = cy_readl(&buf_ctrl->tx_put); |
1634 | tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize); | 1679 | tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize); |
1635 | tx_bufaddr = cy_readl(&buf_ctrl->tx_bufaddr); | 1680 | tx_bufaddr = cy_readl(&buf_ctrl->tx_bufaddr); |
1636 | if (tx_put >= tx_get) | 1681 | if (tx_put >= tx_get) |
1637 | char_count = tx_get - tx_put - 1 + tx_bufsize; | 1682 | char_count = tx_get - tx_put - 1 + tx_bufsize; |
1638 | else | 1683 | else |
1639 | char_count = tx_get - tx_put - 1; | 1684 | char_count = tx_get - tx_put - 1; |
1640 | 1685 | ||
1641 | if ( char_count ) { | 1686 | if (char_count) { |
1642 | 1687 | ||
1643 | if( tty == 0 ){ | 1688 | if (tty == 0) { |
1644 | goto ztxdone; | 1689 | goto ztxdone; |
1645 | } | 1690 | } |
1646 | 1691 | ||
1647 | if(info->x_char) { /* send special char */ | 1692 | if (info->x_char) { /* send special char */ |
1648 | data = info->x_char; | 1693 | data = info->x_char; |
1649 | 1694 | ||
1650 | cy_writeb((cinfo->base_addr + tx_bufaddr + tx_put), data); | 1695 | cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); |
1651 | tx_put = (tx_put + 1) & (tx_bufsize - 1); | 1696 | tx_put = (tx_put + 1) & (tx_bufsize - 1); |
1652 | info->x_char = 0; | 1697 | info->x_char = 0; |
1653 | char_count--; | 1698 | char_count--; |
1654 | info->icount.tx++; | 1699 | info->icount.tx++; |
1655 | info->last_active = jiffies; | 1700 | info->last_active = jiffies; |
1656 | info->jiffies[2] = jiffies; | 1701 | info->jiffies[2] = jiffies; |
1657 | } | 1702 | } |
1658 | #ifdef BLOCKMOVE | 1703 | #ifdef BLOCKMOVE |
1659 | while(0 < (small_count = | 1704 | while (0 < (small_count = min_t(unsigned int, |
1660 | min_t(unsigned int, (tx_bufsize - tx_put), | 1705 | tx_bufsize - tx_put, min_t(unsigned int, |
1661 | min_t(unsigned int, (SERIAL_XMIT_SIZE - info->xmit_tail), | 1706 | (SERIAL_XMIT_SIZE - info->xmit_tail), |
1662 | min_t(unsigned int, info->xmit_cnt, char_count))))) { | 1707 | min_t(unsigned int, info->xmit_cnt, |
1663 | 1708 | char_count))))) { | |
1664 | memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + tx_put), | 1709 | |
1665 | &info->xmit_buf[info->xmit_tail], | 1710 | memcpy_toio((char *)(cinfo->base_addr + tx_bufaddr + |
1666 | small_count); | 1711 | tx_put), |
1667 | 1712 | &info->xmit_buf[info->xmit_tail], | |
1668 | tx_put = (tx_put + small_count) & (tx_bufsize - 1); | 1713 | small_count); |
1669 | char_count -= small_count; | 1714 | |
1670 | info->icount.tx += small_count; | 1715 | tx_put = (tx_put + small_count) & (tx_bufsize - 1); |
1671 | info->xmit_cnt -= small_count; | 1716 | char_count -= small_count; |
1672 | info->xmit_tail = | 1717 | info->icount.tx += small_count; |
1673 | (info->xmit_tail + small_count) & (SERIAL_XMIT_SIZE - 1); | 1718 | info->xmit_cnt -= small_count; |
1674 | info->last_active = jiffies; | 1719 | info->xmit_tail = (info->xmit_tail + small_count) & |
1675 | info->jiffies[2] = jiffies; | 1720 | (SERIAL_XMIT_SIZE - 1); |
1676 | } | 1721 | info->last_active = jiffies; |
1722 | info->jiffies[2] = jiffies; | ||
1723 | } | ||
1677 | #else | 1724 | #else |
1678 | while (info->xmit_cnt && char_count){ | 1725 | while (info->xmit_cnt && char_count) { |
1679 | data = info->xmit_buf[info->xmit_tail]; | 1726 | data = info->xmit_buf[info->xmit_tail]; |
1680 | info->xmit_cnt--; | 1727 | info->xmit_cnt--; |
1681 | info->xmit_tail = (info->xmit_tail + 1) & (SERIAL_XMIT_SIZE - 1); | 1728 | info->xmit_tail = (info->xmit_tail + 1) & |
1682 | 1729 | (SERIAL_XMIT_SIZE - 1); | |
1683 | cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); | 1730 | |
1684 | tx_put = (tx_put + 1) & (tx_bufsize - 1); | 1731 | cy_writeb(cinfo->base_addr + tx_bufaddr + tx_put, data); |
1685 | char_count--; | 1732 | tx_put = (tx_put + 1) & (tx_bufsize - 1); |
1686 | info->icount.tx++; | 1733 | char_count--; |
1687 | info->last_active = jiffies; | 1734 | info->icount.tx++; |
1688 | info->jiffies[2] = jiffies; | 1735 | info->last_active = jiffies; |
1689 | } | 1736 | info->jiffies[2] = jiffies; |
1737 | } | ||
1690 | #endif | 1738 | #endif |
1691 | ztxdone: | 1739 | ztxdone: |
1692 | if (info->xmit_cnt < WAKEUP_CHARS) { | 1740 | if (info->xmit_cnt < WAKEUP_CHARS) { |
1693 | cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); | 1741 | cy_sched_event(info, Cy_EVENT_WRITE_WAKEUP); |
1742 | } | ||
1743 | /* Update tx_put */ | ||
1744 | cy_writel(&buf_ctrl->tx_put, tx_put); | ||
1694 | } | 1745 | } |
1695 | /* Update tx_put */ | ||
1696 | cy_writel(&buf_ctrl->tx_put, tx_put); | ||
1697 | } | ||
1698 | } | 1746 | } |
1699 | 1747 | ||
1700 | static void | 1748 | static void cyz_handle_cmd(struct cyclades_card *cinfo) |
1701 | cyz_handle_cmd(struct cyclades_card *cinfo) | ||
1702 | { | 1749 | { |
1703 | struct tty_struct *tty; | 1750 | struct tty_struct *tty; |
1704 | struct cyclades_port *info; | 1751 | struct cyclades_port *info; |
1705 | static volatile struct FIRM_ID __iomem *firm_id; | 1752 | static volatile struct FIRM_ID __iomem *firm_id; |
1706 | static volatile struct ZFW_CTRL __iomem *zfw_ctrl; | 1753 | static volatile struct ZFW_CTRL __iomem *zfw_ctrl; |
1707 | static volatile struct BOARD_CTRL __iomem *board_ctrl; | 1754 | static volatile struct BOARD_CTRL __iomem *board_ctrl; |
1708 | static volatile struct CH_CTRL __iomem *ch_ctrl; | 1755 | static volatile struct CH_CTRL __iomem *ch_ctrl; |
1709 | static volatile struct BUF_CTRL __iomem *buf_ctrl; | 1756 | static volatile struct BUF_CTRL __iomem *buf_ctrl; |
1710 | uclong channel; | 1757 | uclong channel; |
1711 | ucchar cmd; | 1758 | ucchar cmd; |
1712 | uclong param; | 1759 | uclong param; |
1713 | uclong hw_ver, fw_ver; | 1760 | uclong hw_ver, fw_ver; |
1714 | int special_count; | 1761 | int special_count; |
1715 | int delta_count; | 1762 | int delta_count; |
1716 | 1763 | ||
1717 | firm_id = cinfo->base_addr + ID_ADDRESS; | 1764 | firm_id = cinfo->base_addr + ID_ADDRESS; |
1718 | zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1765 | zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & |
1719 | board_ctrl = &zfw_ctrl->board_ctrl; | 1766 | 0xfffff); |
1720 | fw_ver = cy_readl(&board_ctrl->fw_version); | 1767 | board_ctrl = &zfw_ctrl->board_ctrl; |
1721 | hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))->mail_box_0); | 1768 | fw_ver = cy_readl(&board_ctrl->fw_version); |
1722 | 1769 | hw_ver = cy_readl(&((struct RUNTIME_9060 __iomem *)(cinfo->ctl_addr))-> | |
1723 | 1770 | mail_box_0); | |
1724 | while(cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1) { | 1771 | |
1725 | special_count = 0; | 1772 | while (cyz_fetch_msg(cinfo, &channel, &cmd, ¶m) == 1) { |
1726 | delta_count = 0; | 1773 | special_count = 0; |
1727 | info = &cy_port[channel + cinfo->first_line]; | 1774 | delta_count = 0; |
1728 | if((tty = info->tty) == 0) { | 1775 | info = &cy_port[channel + cinfo->first_line]; |
1729 | continue; | 1776 | if ((tty = info->tty) == 0) { |
1730 | } | 1777 | continue; |
1731 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); | ||
1732 | buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); | ||
1733 | |||
1734 | switch(cmd) { | ||
1735 | case C_CM_PR_ERROR: | ||
1736 | tty_insert_flip_char(tty, 0, TTY_PARITY); | ||
1737 | info->icount.rx++; | ||
1738 | special_count++; | ||
1739 | break; | ||
1740 | case C_CM_FR_ERROR: | ||
1741 | tty_insert_flip_char(tty, 0, TTY_FRAME); | ||
1742 | info->icount.rx++; | ||
1743 | special_count++; | ||
1744 | break; | ||
1745 | case C_CM_RXBRK: | ||
1746 | tty_insert_flip_char(tty, 0, TTY_BREAK); | ||
1747 | info->icount.rx++; | ||
1748 | special_count++; | ||
1749 | break; | ||
1750 | case C_CM_MDCD: | ||
1751 | info->icount.dcd++; | ||
1752 | delta_count++; | ||
1753 | if (info->flags & ASYNC_CHECK_CD){ | ||
1754 | if ((fw_ver > 241 ? | ||
1755 | ((u_long)param) : | ||
1756 | cy_readl(&ch_ctrl->rs_status)) & C_RS_DCD) { | ||
1757 | cy_sched_event(info, Cy_EVENT_OPEN_WAKEUP); | ||
1758 | }else{ | ||
1759 | cy_sched_event(info, Cy_EVENT_HANGUP); | ||
1760 | } | ||
1761 | } | 1778 | } |
1762 | break; | 1779 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); |
1763 | case C_CM_MCTS: | 1780 | buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); |
1764 | info->icount.cts++; | 1781 | |
1765 | delta_count++; | 1782 | switch (cmd) { |
1766 | break; | 1783 | case C_CM_PR_ERROR: |
1767 | case C_CM_MRI: | 1784 | tty_insert_flip_char(tty, 0, TTY_PARITY); |
1768 | info->icount.rng++; | 1785 | info->icount.rx++; |
1769 | delta_count++; | 1786 | special_count++; |
1770 | break; | 1787 | break; |
1771 | case C_CM_MDSR: | 1788 | case C_CM_FR_ERROR: |
1772 | info->icount.dsr++; | 1789 | tty_insert_flip_char(tty, 0, TTY_FRAME); |
1773 | delta_count++; | 1790 | info->icount.rx++; |
1774 | break; | 1791 | special_count++; |
1792 | break; | ||
1793 | case C_CM_RXBRK: | ||
1794 | tty_insert_flip_char(tty, 0, TTY_BREAK); | ||
1795 | info->icount.rx++; | ||
1796 | special_count++; | ||
1797 | break; | ||
1798 | case C_CM_MDCD: | ||
1799 | info->icount.dcd++; | ||
1800 | delta_count++; | ||
1801 | if (info->flags & ASYNC_CHECK_CD) { | ||
1802 | if ((fw_ver > 241 ? ((u_long) param) : | ||
1803 | cy_readl(&ch_ctrl->rs_status)) & | ||
1804 | C_RS_DCD) { | ||
1805 | cy_sched_event(info, | ||
1806 | Cy_EVENT_OPEN_WAKEUP); | ||
1807 | } else { | ||
1808 | cy_sched_event(info, Cy_EVENT_HANGUP); | ||
1809 | } | ||
1810 | } | ||
1811 | break; | ||
1812 | case C_CM_MCTS: | ||
1813 | info->icount.cts++; | ||
1814 | delta_count++; | ||
1815 | break; | ||
1816 | case C_CM_MRI: | ||
1817 | info->icount.rng++; | ||
1818 | delta_count++; | ||
1819 | break; | ||
1820 | case C_CM_MDSR: | ||
1821 | info->icount.dsr++; | ||
1822 | delta_count++; | ||
1823 | break; | ||
1775 | #ifdef Z_WAKE | 1824 | #ifdef Z_WAKE |
1776 | case C_CM_IOCTLW: | 1825 | case C_CM_IOCTLW: |
1777 | cy_sched_event(info, Cy_EVENT_SHUTDOWN_WAKEUP); | 1826 | cy_sched_event(info, Cy_EVENT_SHUTDOWN_WAKEUP); |
1778 | break; | 1827 | break; |
1779 | #endif | 1828 | #endif |
1780 | #ifdef CONFIG_CYZ_INTR | 1829 | #ifdef CONFIG_CYZ_INTR |
1781 | case C_CM_RXHIWM: | 1830 | case C_CM_RXHIWM: |
1782 | case C_CM_RXNNDT: | 1831 | case C_CM_RXNNDT: |
1783 | case C_CM_INTBACK2: | 1832 | case C_CM_INTBACK2: |
1784 | /* Reception Interrupt */ | 1833 | /* Reception Interrupt */ |
1785 | #ifdef CY_DEBUG_INTERRUPTS | 1834 | #ifdef CY_DEBUG_INTERRUPTS |
1786 | printk("cyz_interrupt: rcvd intr, card %d, port %ld\n\r", | 1835 | printk("cyz_interrupt: rcvd intr, card %d, " |
1787 | info->card, channel); | 1836 | "port %ld\n\r", info->card, channel); |
1788 | #endif | 1837 | #endif |
1789 | cyz_handle_rx(info, ch_ctrl, buf_ctrl); | 1838 | cyz_handle_rx(info, ch_ctrl, buf_ctrl); |
1790 | break; | 1839 | break; |
1791 | case C_CM_TXBEMPTY: | 1840 | case C_CM_TXBEMPTY: |
1792 | case C_CM_TXLOWWM: | 1841 | case C_CM_TXLOWWM: |
1793 | case C_CM_INTBACK: | 1842 | case C_CM_INTBACK: |
1794 | /* Transmission Interrupt */ | 1843 | /* Transmission Interrupt */ |
1795 | #ifdef CY_DEBUG_INTERRUPTS | 1844 | #ifdef CY_DEBUG_INTERRUPTS |
1796 | printk("cyz_interrupt: xmit intr, card %d, port %ld\n\r", | 1845 | printk("cyz_interrupt: xmit intr, card %d, " |
1797 | info->card, channel); | 1846 | "port %ld\n\r", info->card, channel); |
1798 | #endif | 1847 | #endif |
1799 | cyz_handle_tx(info, ch_ctrl, buf_ctrl); | 1848 | cyz_handle_tx(info, ch_ctrl, buf_ctrl); |
1800 | break; | 1849 | break; |
1801 | #endif /* CONFIG_CYZ_INTR */ | 1850 | #endif /* CONFIG_CYZ_INTR */ |
1802 | case C_CM_FATAL: | 1851 | case C_CM_FATAL: |
1803 | /* should do something with this !!! */ | 1852 | /* should do something with this !!! */ |
1804 | break; | 1853 | break; |
1805 | default: | 1854 | default: |
1806 | break; | 1855 | break; |
1856 | } | ||
1857 | if (delta_count) | ||
1858 | cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); | ||
1859 | if (special_count) | ||
1860 | tty_schedule_flip(tty); | ||
1807 | } | 1861 | } |
1808 | if(delta_count) | ||
1809 | cy_sched_event(info, Cy_EVENT_DELTA_WAKEUP); | ||
1810 | if(special_count) | ||
1811 | tty_schedule_flip(tty); | ||
1812 | } | ||
1813 | } | 1862 | } |
1814 | 1863 | ||
1815 | #ifdef CONFIG_CYZ_INTR | 1864 | #ifdef CONFIG_CYZ_INTR |
1816 | static irqreturn_t | 1865 | static irqreturn_t cyz_interrupt(int irq, void *dev_id) |
1817 | cyz_interrupt(int irq, void *dev_id, struct pt_regs *regs) | ||
1818 | { | 1866 | { |
1819 | struct cyclades_card *cinfo; | 1867 | struct cyclades_card *cinfo; |
1820 | 1868 | ||
1821 | if((cinfo = (struct cyclades_card *)dev_id) == 0){ | 1869 | if ((cinfo = (struct cyclades_card *)dev_id) == 0) { |
1822 | #ifdef CY_DEBUG_INTERRUPTS | 1870 | #ifdef CY_DEBUG_INTERRUPTS |
1823 | printk("cyz_interrupt: spurious interrupt %d\n\r", irq); | 1871 | printk("cyz_interrupt: spurious interrupt %d\n\r", irq); |
1824 | #endif | 1872 | #endif |
1825 | return IRQ_NONE; /* spurious interrupt */ | 1873 | return IRQ_NONE; /* spurious interrupt */ |
1826 | } | 1874 | } |
1827 | 1875 | ||
1828 | if (!ISZLOADED(*cinfo)) { | 1876 | if (!ISZLOADED(*cinfo)) { |
1829 | #ifdef CY_DEBUG_INTERRUPTS | 1877 | #ifdef CY_DEBUG_INTERRUPTS |
1830 | printk("cyz_interrupt: board not yet loaded (IRQ%d).\n\r", irq); | 1878 | printk("cyz_interrupt: board not yet loaded (IRQ%d).\n\r", irq); |
1831 | #endif | 1879 | #endif |
1832 | return IRQ_NONE; | 1880 | return IRQ_NONE; |
1833 | } | 1881 | } |
1834 | 1882 | ||
1835 | /* Handle the interrupts */ | 1883 | /* Handle the interrupts */ |
1836 | cyz_handle_cmd(cinfo); | 1884 | cyz_handle_cmd(cinfo); |
1837 | 1885 | ||
1838 | return IRQ_HANDLED; | 1886 | return IRQ_HANDLED; |
1839 | } /* cyz_interrupt */ | 1887 | } /* cyz_interrupt */ |
1840 | 1888 | ||
1841 | static void | 1889 | static void cyz_rx_restart(unsigned long arg) |
1842 | cyz_rx_restart(unsigned long arg) | ||
1843 | { | 1890 | { |
1844 | struct cyclades_port *info = (struct cyclades_port *)arg; | 1891 | struct cyclades_port *info = (struct cyclades_port *)arg; |
1845 | int retval; | 1892 | int retval; |
1846 | int card = info->card; | 1893 | int card = info->card; |
1847 | uclong channel = (info->line) - (cy_card[card].first_line); | 1894 | uclong channel = (info->line) - (cy_card[card].first_line); |
1848 | unsigned long flags; | 1895 | unsigned long flags; |
1849 | 1896 | ||
1850 | CY_LOCK(info, flags); | 1897 | CY_LOCK(info, flags); |
1851 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK2, 0L); | 1898 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK2, 0L); |
1852 | if (retval != 0){ | 1899 | if (retval != 0) { |
1853 | printk("cyc:cyz_rx_restart retval on ttyC%d was %x\n", | 1900 | printk("cyc:cyz_rx_restart retval on ttyC%d was %x\n", |
1854 | info->line, retval); | 1901 | info->line, retval); |
1855 | } | 1902 | } |
1856 | cyz_rx_full_timer[info->line].function = NULL; | 1903 | cyz_rx_full_timer[info->line].function = NULL; |
1857 | CY_UNLOCK(info, flags); | 1904 | CY_UNLOCK(info, flags); |
1858 | } | 1905 | } |
1859 | 1906 | ||
1860 | #else /* CONFIG_CYZ_INTR */ | 1907 | #else /* CONFIG_CYZ_INTR */ |
1861 | 1908 | ||
1862 | static void | 1909 | static void cyz_poll(unsigned long arg) |
1863 | cyz_poll(unsigned long arg) | ||
1864 | { | 1910 | { |
1865 | struct cyclades_card *cinfo; | 1911 | struct cyclades_card *cinfo; |
1866 | struct cyclades_port *info; | 1912 | struct cyclades_port *info; |
1867 | struct tty_struct *tty; | 1913 | struct tty_struct *tty; |
1868 | static volatile struct FIRM_ID *firm_id; | 1914 | static volatile struct FIRM_ID *firm_id; |
1869 | static volatile struct ZFW_CTRL *zfw_ctrl; | 1915 | static volatile struct ZFW_CTRL *zfw_ctrl; |
1870 | static volatile struct BOARD_CTRL *board_ctrl; | 1916 | static volatile struct BOARD_CTRL *board_ctrl; |
1871 | static volatile struct CH_CTRL *ch_ctrl; | 1917 | static volatile struct CH_CTRL *ch_ctrl; |
1872 | static volatile struct BUF_CTRL *buf_ctrl; | 1918 | static volatile struct BUF_CTRL *buf_ctrl; |
1873 | int card, port; | 1919 | int card, port; |
1874 | |||
1875 | cyz_timerlist.expires = jiffies + (HZ); | ||
1876 | for (card = 0 ; card < NR_CARDS ; card++){ | ||
1877 | cinfo = &cy_card[card]; | ||
1878 | |||
1879 | if (!IS_CYC_Z(*cinfo)) continue; | ||
1880 | if (!ISZLOADED(*cinfo)) continue; | ||
1881 | 1920 | ||
1882 | firm_id = cinfo->base_addr + ID_ADDRESS; | 1921 | cyz_timerlist.expires = jiffies + (HZ); |
1883 | zfw_ctrl = cinfo->base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 1922 | for (card = 0; card < NR_CARDS; card++) { |
1884 | board_ctrl = &(zfw_ctrl->board_ctrl); | 1923 | cinfo = &cy_card[card]; |
1924 | |||
1925 | if (!IS_CYC_Z(*cinfo)) | ||
1926 | continue; | ||
1927 | if (!ISZLOADED(*cinfo)) | ||
1928 | continue; | ||
1929 | |||
1930 | firm_id = cinfo->base_addr + ID_ADDRESS; | ||
1931 | zfw_ctrl = cinfo->base_addr + | ||
1932 | (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | ||
1933 | board_ctrl = &(zfw_ctrl->board_ctrl); | ||
1885 | 1934 | ||
1886 | /* Skip first polling cycle to avoid racing conditions with the FW */ | 1935 | /* Skip first polling cycle to avoid racing conditions with the FW */ |
1887 | if (!cinfo->intr_enabled) { | 1936 | if (!cinfo->intr_enabled) { |
1888 | cinfo->nports = (int) cy_readl(&board_ctrl->n_channel); | 1937 | cinfo->nports = (int)cy_readl(&board_ctrl->n_channel); |
1889 | cinfo->intr_enabled = 1; | 1938 | cinfo->intr_enabled = 1; |
1890 | continue; | 1939 | continue; |
1891 | } | 1940 | } |
1892 | 1941 | ||
1893 | cyz_handle_cmd(cinfo); | 1942 | cyz_handle_cmd(cinfo); |
1894 | 1943 | ||
1895 | for (port = 0 ; port < cinfo->nports ; port++) { | 1944 | for (port = 0; port < cinfo->nports; port++) { |
1896 | info = &cy_port[ port + cinfo->first_line ]; | 1945 | info = &cy_port[port + cinfo->first_line]; |
1897 | tty = info->tty; | 1946 | tty = info->tty; |
1898 | ch_ctrl = &(zfw_ctrl->ch_ctrl[port]); | 1947 | ch_ctrl = &(zfw_ctrl->ch_ctrl[port]); |
1899 | buf_ctrl = &(zfw_ctrl->buf_ctrl[port]); | 1948 | buf_ctrl = &(zfw_ctrl->buf_ctrl[port]); |
1900 | 1949 | ||
1901 | if (!info->throttle) | 1950 | if (!info->throttle) |
1902 | cyz_handle_rx(info, ch_ctrl, buf_ctrl); | 1951 | cyz_handle_rx(info, ch_ctrl, buf_ctrl); |
1903 | cyz_handle_tx(info, ch_ctrl, buf_ctrl); | 1952 | cyz_handle_tx(info, ch_ctrl, buf_ctrl); |
1953 | } | ||
1954 | /* poll every 'cyz_polling_cycle' period */ | ||
1955 | cyz_timerlist.expires = jiffies + cyz_polling_cycle; | ||
1904 | } | 1956 | } |
1905 | /* poll every 'cyz_polling_cycle' period */ | 1957 | add_timer(&cyz_timerlist); |
1906 | cyz_timerlist.expires = jiffies + cyz_polling_cycle; | 1958 | } /* cyz_poll */ |
1907 | } | ||
1908 | add_timer(&cyz_timerlist); | ||
1909 | |||
1910 | return; | ||
1911 | } /* cyz_poll */ | ||
1912 | 1959 | ||
1913 | #endif /* CONFIG_CYZ_INTR */ | 1960 | #endif /* CONFIG_CYZ_INTR */ |
1914 | 1961 | ||
1915 | /********** End of block of Cyclades-Z specific code *********/ | 1962 | /********** End of block of Cyclades-Z specific code *********/ |
1916 | /***********************************************************/ | 1963 | /***********************************************************/ |
1917 | 1964 | ||
1918 | |||
1919 | /* This is called whenever a port becomes active; | 1965 | /* This is called whenever a port becomes active; |
1920 | interrupts are enabled and DTR & RTS are turned on. | 1966 | interrupts are enabled and DTR & RTS are turned on. |
1921 | */ | 1967 | */ |
1922 | static int | 1968 | static int startup(struct cyclades_port *info) |
1923 | startup(struct cyclades_port * info) | ||
1924 | { | 1969 | { |
1925 | unsigned long flags; | 1970 | unsigned long flags; |
1926 | int retval = 0; | 1971 | int retval = 0; |
1927 | void __iomem *base_addr; | 1972 | void __iomem *base_addr; |
1928 | int card,chip,channel,index; | 1973 | int card, chip, channel, index; |
1929 | unsigned long page; | 1974 | unsigned long page; |
1930 | 1975 | ||
1931 | card = info->card; | 1976 | card = info->card; |
1932 | channel = (info->line) - (cy_card[card].first_line); | 1977 | channel = (info->line) - (cy_card[card].first_line); |
1933 | 1978 | ||
1934 | page = get_zeroed_page(GFP_KERNEL); | 1979 | page = get_zeroed_page(GFP_KERNEL); |
1935 | if (!page) | 1980 | if (!page) |
1936 | return -ENOMEM; | 1981 | return -ENOMEM; |
1937 | 1982 | ||
1938 | CY_LOCK(info, flags); | 1983 | CY_LOCK(info, flags); |
1939 | 1984 | ||
1940 | if (info->flags & ASYNC_INITIALIZED){ | 1985 | if (info->flags & ASYNC_INITIALIZED) { |
1941 | free_page(page); | 1986 | free_page(page); |
1942 | goto errout; | 1987 | goto errout; |
1943 | } | 1988 | } |
1944 | 1989 | ||
1945 | if (!info->type){ | 1990 | if (!info->type) { |
1946 | if (info->tty){ | 1991 | if (info->tty) { |
1947 | set_bit(TTY_IO_ERROR, &info->tty->flags); | 1992 | set_bit(TTY_IO_ERROR, &info->tty->flags); |
1948 | } | 1993 | } |
1949 | free_page(page); | 1994 | free_page(page); |
1950 | goto errout; | 1995 | goto errout; |
1951 | } | 1996 | } |
1952 | 1997 | ||
1953 | if (info->xmit_buf) | 1998 | if (info->xmit_buf) |
1954 | free_page(page); | 1999 | free_page(page); |
1955 | else | 2000 | else |
1956 | info->xmit_buf = (unsigned char *) page; | 2001 | info->xmit_buf = (unsigned char *)page; |
1957 | 2002 | ||
1958 | CY_UNLOCK(info, flags); | 2003 | CY_UNLOCK(info, flags); |
1959 | 2004 | ||
1960 | set_line_char(info); | 2005 | set_line_char(info); |
1961 | 2006 | ||
1962 | if (!IS_CYC_Z(cy_card[card])) { | 2007 | if (!IS_CYC_Z(cy_card[card])) { |
1963 | chip = channel>>2; | 2008 | chip = channel >> 2; |
1964 | channel &= 0x03; | 2009 | channel &= 0x03; |
1965 | index = cy_card[card].bus_index; | 2010 | index = cy_card[card].bus_index; |
1966 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | 2011 | base_addr = cy_card[card].base_addr + |
2012 | (cy_chip_offset[chip] << index); | ||
1967 | 2013 | ||
1968 | #ifdef CY_DEBUG_OPEN | 2014 | #ifdef CY_DEBUG_OPEN |
1969 | printk("cyc startup card %d, chip %d, channel %d, base_addr %lx\n", | 2015 | printk("cyc startup card %d, chip %d, channel %d, " |
1970 | card, chip, channel, (long)base_addr);/**/ | 2016 | "base_addr %lx\n", |
2017 | card, chip, channel, (long)base_addr); | ||
2018 | /**/ | ||
1971 | #endif | 2019 | #endif |
2020 | CY_LOCK(info, flags); | ||
1972 | 2021 | ||
1973 | CY_LOCK(info, flags); | 2022 | cy_writeb(base_addr + (CyCAR << index), (u_char) channel); |
1974 | |||
1975 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | ||
1976 | 2023 | ||
1977 | cy_writeb(base_addr+(CyRTPR<<index), (info->default_timeout | 2024 | cy_writeb(base_addr + (CyRTPR << index), |
1978 | ? info->default_timeout : 0x02)); /* 10ms rx timeout */ | 2025 | (info->default_timeout ? info->default_timeout : 0x02)); |
2026 | /* 10ms rx timeout */ | ||
1979 | 2027 | ||
1980 | cyy_issue_cmd(base_addr,CyCHAN_CTL|CyENB_RCVR|CyENB_XMTR,index); | 2028 | cyy_issue_cmd(base_addr, CyCHAN_CTL | CyENB_RCVR | CyENB_XMTR, |
2029 | index); | ||
1981 | 2030 | ||
1982 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 2031 | cy_writeb(base_addr + (CyCAR << index), (u_char) channel); |
1983 | cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); | 2032 | cy_writeb(base_addr + (CyMSVR1 << index), CyRTS); |
1984 | cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); | 2033 | cy_writeb(base_addr + (CyMSVR2 << index), CyDTR); |
1985 | 2034 | ||
1986 | #ifdef CY_DEBUG_DTR | 2035 | #ifdef CY_DEBUG_DTR |
1987 | printk("cyc:startup raising DTR\n"); | 2036 | printk("cyc:startup raising DTR\n"); |
1988 | printk(" status: 0x%x, 0x%x\n", | 2037 | printk(" status: 0x%x, 0x%x\n", |
1989 | cy_readb(base_addr+(CyMSVR1<<index)), | 2038 | cy_readb(base_addr + (CyMSVR1 << index)), |
1990 | cy_readb(base_addr+(CyMSVR2<<index))); | 2039 | cy_readb(base_addr + (CyMSVR2 << index))); |
1991 | #endif | 2040 | #endif |
1992 | 2041 | ||
1993 | cy_writeb(base_addr+(CySRER<<index), | 2042 | cy_writeb(base_addr + (CySRER << index), |
1994 | cy_readb(base_addr+(CySRER<<index)) | CyRxData); | 2043 | cy_readb(base_addr + (CySRER << index)) | CyRxData); |
1995 | info->flags |= ASYNC_INITIALIZED; | 2044 | info->flags |= ASYNC_INITIALIZED; |
1996 | 2045 | ||
1997 | if (info->tty){ | 2046 | if (info->tty) { |
1998 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | 2047 | clear_bit(TTY_IO_ERROR, &info->tty->flags); |
1999 | } | 2048 | } |
2000 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | 2049 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; |
2001 | info->breakon = info->breakoff = 0; | 2050 | info->breakon = info->breakoff = 0; |
2002 | memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); | 2051 | memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); |
2003 | info->idle_stats.in_use = | 2052 | info->idle_stats.in_use = |
2004 | info->idle_stats.recv_idle = | 2053 | info->idle_stats.recv_idle = |
2005 | info->idle_stats.xmit_idle = jiffies; | 2054 | info->idle_stats.xmit_idle = jiffies; |
2006 | 2055 | ||
2007 | CY_UNLOCK(info, flags); | 2056 | CY_UNLOCK(info, flags); |
2008 | 2057 | ||
2009 | } else { | 2058 | } else { |
2010 | struct FIRM_ID __iomem *firm_id; | 2059 | struct FIRM_ID __iomem *firm_id; |
2011 | struct ZFW_CTRL __iomem *zfw_ctrl; | 2060 | struct ZFW_CTRL __iomem *zfw_ctrl; |
2012 | struct BOARD_CTRL __iomem *board_ctrl; | 2061 | struct BOARD_CTRL __iomem *board_ctrl; |
2013 | struct CH_CTRL __iomem *ch_ctrl; | 2062 | struct CH_CTRL __iomem *ch_ctrl; |
2014 | int retval; | 2063 | int retval; |
2015 | 2064 | ||
2016 | base_addr = cy_card[card].base_addr; | 2065 | base_addr = cy_card[card].base_addr; |
2017 | 2066 | ||
2018 | firm_id = base_addr + ID_ADDRESS; | 2067 | firm_id = base_addr + ID_ADDRESS; |
2019 | if (!ISZLOADED(cy_card[card])){ | 2068 | if (!ISZLOADED(cy_card[card])) { |
2020 | return -ENODEV; | 2069 | return -ENODEV; |
2021 | } | 2070 | } |
2022 | 2071 | ||
2023 | zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 2072 | zfw_ctrl = cy_card[card].base_addr + |
2024 | board_ctrl = &zfw_ctrl->board_ctrl; | 2073 | (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); |
2025 | ch_ctrl = zfw_ctrl->ch_ctrl; | 2074 | board_ctrl = &zfw_ctrl->board_ctrl; |
2075 | ch_ctrl = zfw_ctrl->ch_ctrl; | ||
2026 | 2076 | ||
2027 | #ifdef CY_DEBUG_OPEN | 2077 | #ifdef CY_DEBUG_OPEN |
2028 | printk("cyc startup Z card %d, channel %d, base_addr %lx\n", | 2078 | printk("cyc startup Z card %d, channel %d, base_addr %lx\n", |
2029 | card, channel, (long)base_addr);/**/ | 2079 | card, channel, (long)base_addr); |
2080 | /**/ | ||
2030 | #endif | 2081 | #endif |
2082 | CY_LOCK(info, flags); | ||
2031 | 2083 | ||
2032 | CY_LOCK(info, flags); | 2084 | cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE); |
2033 | |||
2034 | cy_writel(&ch_ctrl[channel].op_mode, C_CH_ENABLE); | ||
2035 | #ifdef Z_WAKE | 2085 | #ifdef Z_WAKE |
2036 | #ifdef CONFIG_CYZ_INTR | 2086 | #ifdef CONFIG_CYZ_INTR |
2037 | cy_writel(&ch_ctrl[channel].intr_enable, | 2087 | cy_writel(&ch_ctrl[channel].intr_enable, |
2038 | C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT| | 2088 | C_IN_TXBEMPTY | C_IN_TXLOWWM | C_IN_RXHIWM | |
2039 | C_IN_IOCTLW| | 2089 | C_IN_RXNNDT | C_IN_IOCTLW | C_IN_MDCD); |
2040 | C_IN_MDCD); | ||
2041 | #else | 2090 | #else |
2042 | cy_writel(&ch_ctrl[channel].intr_enable, | 2091 | cy_writel(&ch_ctrl[channel].intr_enable, |
2043 | C_IN_IOCTLW| | 2092 | C_IN_IOCTLW | C_IN_MDCD); |
2044 | C_IN_MDCD); | 2093 | #endif /* CONFIG_CYZ_INTR */ |
2045 | #endif /* CONFIG_CYZ_INTR */ | ||
2046 | #else | 2094 | #else |
2047 | #ifdef CONFIG_CYZ_INTR | 2095 | #ifdef CONFIG_CYZ_INTR |
2048 | cy_writel(&ch_ctrl[channel].intr_enable, | 2096 | cy_writel(&ch_ctrl[channel].intr_enable, |
2049 | C_IN_TXBEMPTY|C_IN_TXLOWWM|C_IN_RXHIWM|C_IN_RXNNDT| | 2097 | C_IN_TXBEMPTY | C_IN_TXLOWWM | C_IN_RXHIWM | |
2050 | C_IN_MDCD); | 2098 | C_IN_RXNNDT | C_IN_MDCD); |
2051 | #else | 2099 | #else |
2052 | cy_writel(&ch_ctrl[channel].intr_enable, | 2100 | cy_writel(&ch_ctrl[channel].intr_enable, C_IN_MDCD); |
2053 | C_IN_MDCD); | 2101 | #endif /* CONFIG_CYZ_INTR */ |
2054 | #endif /* CONFIG_CYZ_INTR */ | 2102 | #endif /* Z_WAKE */ |
2055 | #endif /* Z_WAKE */ | 2103 | |
2056 | 2104 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L); | |
2057 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L); | 2105 | if (retval != 0) { |
2058 | if (retval != 0){ | 2106 | printk("cyc:startup(1) retval on ttyC%d was %x\n", |
2059 | printk("cyc:startup(1) retval on ttyC%d was %x\n", | 2107 | info->line, retval); |
2060 | info->line, retval); | 2108 | } |
2061 | } | ||
2062 | 2109 | ||
2063 | /* Flush RX buffers before raising DTR and RTS */ | 2110 | /* Flush RX buffers before raising DTR and RTS */ |
2064 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_RX, 0L); | 2111 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_RX, |
2065 | if (retval != 0){ | 2112 | 0L); |
2066 | printk("cyc:startup(2) retval on ttyC%d was %x\n", | 2113 | if (retval != 0) { |
2067 | info->line, retval); | 2114 | printk("cyc:startup(2) retval on ttyC%d was %x\n", |
2068 | } | 2115 | info->line, retval); |
2116 | } | ||
2069 | 2117 | ||
2070 | /* set timeout !!! */ | 2118 | /* set timeout !!! */ |
2071 | /* set RTS and DTR !!! */ | 2119 | /* set RTS and DTR !!! */ |
2072 | cy_writel(&ch_ctrl[channel].rs_control, | 2120 | cy_writel(&ch_ctrl[channel].rs_control, |
2073 | cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS | C_RS_DTR) ; | 2121 | cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS | |
2074 | retval = cyz_issue_cmd(&cy_card[info->card], | 2122 | C_RS_DTR); |
2075 | channel, C_CM_IOCTLM, 0L); | 2123 | retval = cyz_issue_cmd(&cy_card[info->card], channel, |
2076 | if (retval != 0){ | 2124 | C_CM_IOCTLM, 0L); |
2077 | printk("cyc:startup(3) retval on ttyC%d was %x\n", | 2125 | if (retval != 0) { |
2078 | info->line, retval); | 2126 | printk("cyc:startup(3) retval on ttyC%d was %x\n", |
2079 | } | 2127 | info->line, retval); |
2128 | } | ||
2080 | #ifdef CY_DEBUG_DTR | 2129 | #ifdef CY_DEBUG_DTR |
2081 | printk("cyc:startup raising Z DTR\n"); | 2130 | printk("cyc:startup raising Z DTR\n"); |
2082 | #endif | 2131 | #endif |
2083 | 2132 | ||
2084 | /* enable send, recv, modem !!! */ | 2133 | /* enable send, recv, modem !!! */ |
2085 | 2134 | ||
2086 | info->flags |= ASYNC_INITIALIZED; | 2135 | info->flags |= ASYNC_INITIALIZED; |
2087 | if (info->tty){ | 2136 | if (info->tty) { |
2088 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | 2137 | clear_bit(TTY_IO_ERROR, &info->tty->flags); |
2089 | } | 2138 | } |
2090 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | 2139 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; |
2091 | info->breakon = info->breakoff = 0; | 2140 | info->breakon = info->breakoff = 0; |
2092 | memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); | 2141 | memset((char *)&info->idle_stats, 0, sizeof(info->idle_stats)); |
2093 | info->idle_stats.in_use = | 2142 | info->idle_stats.in_use = |
2094 | info->idle_stats.recv_idle = | 2143 | info->idle_stats.recv_idle = |
2095 | info->idle_stats.xmit_idle = jiffies; | 2144 | info->idle_stats.xmit_idle = jiffies; |
2096 | 2145 | ||
2097 | CY_UNLOCK(info, flags); | 2146 | CY_UNLOCK(info, flags); |
2098 | } | 2147 | } |
2099 | 2148 | ||
2100 | #ifdef CY_DEBUG_OPEN | 2149 | #ifdef CY_DEBUG_OPEN |
2101 | printk(" cyc startup done\n"); | 2150 | printk(" cyc startup done\n"); |
@@ -2105,165 +2154,165 @@ startup(struct cyclades_port * info) | |||
2105 | errout: | 2154 | errout: |
2106 | CY_UNLOCK(info, flags); | 2155 | CY_UNLOCK(info, flags); |
2107 | return retval; | 2156 | return retval; |
2108 | } /* startup */ | 2157 | } /* startup */ |
2109 | 2158 | ||
2110 | 2159 | static void start_xmit(struct cyclades_port *info) | |
2111 | static void | ||
2112 | start_xmit( struct cyclades_port *info ) | ||
2113 | { | 2160 | { |
2114 | unsigned long flags; | 2161 | unsigned long flags; |
2115 | void __iomem *base_addr; | 2162 | void __iomem *base_addr; |
2116 | int card,chip,channel,index; | 2163 | int card, chip, channel, index; |
2117 | |||
2118 | card = info->card; | ||
2119 | channel = (info->line) - (cy_card[card].first_line); | ||
2120 | if (!IS_CYC_Z(cy_card[card])) { | ||
2121 | chip = channel>>2; | ||
2122 | channel &= 0x03; | ||
2123 | index = cy_card[card].bus_index; | ||
2124 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
2125 | 2164 | ||
2126 | CY_LOCK(info, flags); | 2165 | card = info->card; |
2127 | cy_writeb(base_addr+(CyCAR<<index), channel); | 2166 | channel = (info->line) - (cy_card[card].first_line); |
2128 | cy_writeb(base_addr+(CySRER<<index), | 2167 | if (!IS_CYC_Z(cy_card[card])) { |
2129 | cy_readb(base_addr+(CySRER<<index)) | CyTxRdy); | 2168 | chip = channel >> 2; |
2130 | CY_UNLOCK(info, flags); | 2169 | channel &= 0x03; |
2131 | } else { | 2170 | index = cy_card[card].bus_index; |
2171 | base_addr = cy_card[card].base_addr + | ||
2172 | (cy_chip_offset[chip] << index); | ||
2173 | |||
2174 | CY_LOCK(info, flags); | ||
2175 | cy_writeb(base_addr + (CyCAR << index), channel); | ||
2176 | cy_writeb(base_addr + (CySRER << index), | ||
2177 | cy_readb(base_addr + (CySRER << index)) | CyTxRdy); | ||
2178 | CY_UNLOCK(info, flags); | ||
2179 | } else { | ||
2132 | #ifdef CONFIG_CYZ_INTR | 2180 | #ifdef CONFIG_CYZ_INTR |
2133 | int retval; | 2181 | int retval; |
2134 | 2182 | ||
2135 | CY_LOCK(info, flags); | 2183 | CY_LOCK(info, flags); |
2136 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK, 0L); | 2184 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_INTBACK, |
2137 | if (retval != 0){ | 2185 | 0L); |
2138 | printk("cyc:start_xmit retval on ttyC%d was %x\n", | 2186 | if (retval != 0) { |
2139 | info->line, retval); | 2187 | printk("cyc:start_xmit retval on ttyC%d was %x\n", |
2140 | } | 2188 | info->line, retval); |
2141 | CY_UNLOCK(info, flags); | 2189 | } |
2142 | #else /* CONFIG_CYZ_INTR */ | 2190 | CY_UNLOCK(info, flags); |
2143 | /* Don't have to do anything at this time */ | 2191 | #else /* CONFIG_CYZ_INTR */ |
2144 | #endif /* CONFIG_CYZ_INTR */ | 2192 | /* Don't have to do anything at this time */ |
2145 | } | 2193 | #endif /* CONFIG_CYZ_INTR */ |
2146 | } /* start_xmit */ | 2194 | } |
2195 | } /* start_xmit */ | ||
2147 | 2196 | ||
2148 | /* | 2197 | /* |
2149 | * This routine shuts down a serial port; interrupts are disabled, | 2198 | * This routine shuts down a serial port; interrupts are disabled, |
2150 | * and DTR is dropped if the hangup on close termio flag is on. | 2199 | * and DTR is dropped if the hangup on close termio flag is on. |
2151 | */ | 2200 | */ |
2152 | static void | 2201 | static void shutdown(struct cyclades_port *info) |
2153 | shutdown(struct cyclades_port * info) | ||
2154 | { | 2202 | { |
2155 | unsigned long flags; | 2203 | unsigned long flags; |
2156 | void __iomem *base_addr; | 2204 | void __iomem *base_addr; |
2157 | int card,chip,channel,index; | 2205 | int card, chip, channel, index; |
2158 | 2206 | ||
2159 | if (!(info->flags & ASYNC_INITIALIZED)){ | 2207 | if (!(info->flags & ASYNC_INITIALIZED)) { |
2160 | return; | 2208 | return; |
2161 | } | 2209 | } |
2162 | 2210 | ||
2163 | card = info->card; | 2211 | card = info->card; |
2164 | channel = info->line - cy_card[card].first_line; | 2212 | channel = info->line - cy_card[card].first_line; |
2165 | if (!IS_CYC_Z(cy_card[card])) { | 2213 | if (!IS_CYC_Z(cy_card[card])) { |
2166 | chip = channel>>2; | 2214 | chip = channel >> 2; |
2167 | channel &= 0x03; | 2215 | channel &= 0x03; |
2168 | index = cy_card[card].bus_index; | 2216 | index = cy_card[card].bus_index; |
2169 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | 2217 | base_addr = cy_card[card].base_addr + |
2218 | (cy_chip_offset[chip] << index); | ||
2170 | 2219 | ||
2171 | #ifdef CY_DEBUG_OPEN | 2220 | #ifdef CY_DEBUG_OPEN |
2172 | printk("cyc shutdown Y card %d, chip %d, channel %d, base_addr %lx\n", | 2221 | printk("cyc shutdown Y card %d, chip %d, channel %d, " |
2173 | card, chip, channel, (long)base_addr); | 2222 | "base_addr %lx\n", |
2223 | card, chip, channel, (long)base_addr); | ||
2174 | #endif | 2224 | #endif |
2175 | 2225 | ||
2176 | CY_LOCK(info, flags); | 2226 | CY_LOCK(info, flags); |
2177 | 2227 | ||
2178 | /* Clear delta_msr_wait queue to avoid mem leaks. */ | 2228 | /* Clear delta_msr_wait queue to avoid mem leaks. */ |
2179 | wake_up_interruptible(&info->delta_msr_wait); | 2229 | wake_up_interruptible(&info->delta_msr_wait); |
2180 | 2230 | ||
2181 | if (info->xmit_buf){ | 2231 | if (info->xmit_buf) { |
2182 | unsigned char * temp; | 2232 | unsigned char *temp; |
2183 | temp = info->xmit_buf; | 2233 | temp = info->xmit_buf; |
2184 | info->xmit_buf = NULL; | 2234 | info->xmit_buf = NULL; |
2185 | free_page((unsigned long) temp); | 2235 | free_page((unsigned long)temp); |
2186 | } | 2236 | } |
2187 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 2237 | cy_writeb(base_addr + (CyCAR << index), (u_char) channel); |
2188 | if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { | 2238 | if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { |
2189 | cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); | 2239 | cy_writeb(base_addr + (CyMSVR1 << index), ~CyRTS); |
2190 | cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); | 2240 | cy_writeb(base_addr + (CyMSVR2 << index), ~CyDTR); |
2191 | #ifdef CY_DEBUG_DTR | 2241 | #ifdef CY_DEBUG_DTR |
2192 | printk("cyc shutdown dropping DTR\n"); | 2242 | printk("cyc shutdown dropping DTR\n"); |
2193 | printk(" status: 0x%x, 0x%x\n", | 2243 | printk(" status: 0x%x, 0x%x\n", |
2194 | cy_readb(base_addr+(CyMSVR1<<index)), | 2244 | cy_readb(base_addr + (CyMSVR1 << index)), |
2195 | cy_readb(base_addr+(CyMSVR2<<index))); | 2245 | cy_readb(base_addr + (CyMSVR2 << index))); |
2196 | #endif | 2246 | #endif |
2197 | } | 2247 | } |
2198 | cyy_issue_cmd(base_addr,CyCHAN_CTL|CyDIS_RCVR,index); | 2248 | cyy_issue_cmd(base_addr, CyCHAN_CTL | CyDIS_RCVR, index); |
2199 | /* it may be appropriate to clear _XMIT at | 2249 | /* it may be appropriate to clear _XMIT at |
2200 | some later date (after testing)!!! */ | 2250 | some later date (after testing)!!! */ |
2201 | 2251 | ||
2202 | if (info->tty){ | 2252 | if (info->tty) { |
2203 | set_bit(TTY_IO_ERROR, &info->tty->flags); | 2253 | set_bit(TTY_IO_ERROR, &info->tty->flags); |
2204 | } | 2254 | } |
2205 | info->flags &= ~ASYNC_INITIALIZED; | 2255 | info->flags &= ~ASYNC_INITIALIZED; |
2206 | CY_UNLOCK(info, flags); | 2256 | CY_UNLOCK(info, flags); |
2207 | } else { | 2257 | } else { |
2208 | struct FIRM_ID __iomem *firm_id; | 2258 | struct FIRM_ID __iomem *firm_id; |
2209 | struct ZFW_CTRL __iomem *zfw_ctrl; | 2259 | struct ZFW_CTRL __iomem *zfw_ctrl; |
2210 | struct BOARD_CTRL __iomem *board_ctrl; | 2260 | struct BOARD_CTRL __iomem *board_ctrl; |
2211 | struct CH_CTRL __iomem *ch_ctrl; | 2261 | struct CH_CTRL __iomem *ch_ctrl; |
2212 | int retval; | 2262 | int retval; |
2213 | 2263 | ||
2214 | base_addr = cy_card[card].base_addr; | 2264 | base_addr = cy_card[card].base_addr; |
2215 | #ifdef CY_DEBUG_OPEN | 2265 | #ifdef CY_DEBUG_OPEN |
2216 | printk("cyc shutdown Z card %d, channel %d, base_addr %lx\n", | 2266 | printk("cyc shutdown Z card %d, channel %d, base_addr %lx\n", |
2217 | card, channel, (long)base_addr); | 2267 | card, channel, (long)base_addr); |
2218 | #endif | 2268 | #endif |
2219 | 2269 | ||
2220 | firm_id = base_addr + ID_ADDRESS; | 2270 | firm_id = base_addr + ID_ADDRESS; |
2221 | if (!ISZLOADED(cy_card[card])) { | 2271 | if (!ISZLOADED(cy_card[card])) { |
2222 | return; | 2272 | return; |
2223 | } | 2273 | } |
2224 | 2274 | ||
2225 | zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 2275 | zfw_ctrl = cy_card[card].base_addr + |
2226 | board_ctrl = &zfw_ctrl->board_ctrl; | 2276 | (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); |
2227 | ch_ctrl = zfw_ctrl->ch_ctrl; | 2277 | board_ctrl = &zfw_ctrl->board_ctrl; |
2278 | ch_ctrl = zfw_ctrl->ch_ctrl; | ||
2228 | 2279 | ||
2229 | CY_LOCK(info, flags); | 2280 | CY_LOCK(info, flags); |
2230 | 2281 | ||
2231 | if (info->xmit_buf){ | 2282 | if (info->xmit_buf) { |
2232 | unsigned char * temp; | 2283 | unsigned char *temp; |
2233 | temp = info->xmit_buf; | 2284 | temp = info->xmit_buf; |
2234 | info->xmit_buf = NULL; | 2285 | info->xmit_buf = NULL; |
2235 | free_page((unsigned long) temp); | 2286 | free_page((unsigned long)temp); |
2236 | } | ||
2237 | |||
2238 | if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { | ||
2239 | cy_writel(&ch_ctrl[channel].rs_control, | ||
2240 | (uclong)(cy_readl(&ch_ctrl[channel].rs_control) & | ||
2241 | ~(C_RS_RTS | C_RS_DTR))); | ||
2242 | retval = cyz_issue_cmd(&cy_card[info->card], | ||
2243 | channel, C_CM_IOCTLM, 0L); | ||
2244 | if (retval != 0){ | ||
2245 | printk("cyc:shutdown retval on ttyC%d was %x\n", | ||
2246 | info->line, retval); | ||
2247 | } | 2287 | } |
2288 | |||
2289 | if (!info->tty || (info->tty->termios->c_cflag & HUPCL)) { | ||
2290 | cy_writel(&ch_ctrl[channel].rs_control, | ||
2291 | (uclong)(cy_readl(&ch_ctrl[channel].rs_control)& | ||
2292 | ~(C_RS_RTS | C_RS_DTR))); | ||
2293 | retval = cyz_issue_cmd(&cy_card[info->card], channel, | ||
2294 | C_CM_IOCTLM, 0L); | ||
2295 | if (retval != 0) { | ||
2296 | printk("cyc:shutdown retval on ttyC%d was %x\n", | ||
2297 | info->line, retval); | ||
2298 | } | ||
2248 | #ifdef CY_DEBUG_DTR | 2299 | #ifdef CY_DEBUG_DTR |
2249 | printk("cyc:shutdown dropping Z DTR\n"); | 2300 | printk("cyc:shutdown dropping Z DTR\n"); |
2250 | #endif | 2301 | #endif |
2251 | } | 2302 | } |
2252 | |||
2253 | if (info->tty){ | ||
2254 | set_bit(TTY_IO_ERROR, &info->tty->flags); | ||
2255 | } | ||
2256 | info->flags &= ~ASYNC_INITIALIZED; | ||
2257 | 2303 | ||
2258 | CY_UNLOCK(info, flags); | 2304 | if (info->tty) { |
2259 | } | 2305 | set_bit(TTY_IO_ERROR, &info->tty->flags); |
2306 | } | ||
2307 | info->flags &= ~ASYNC_INITIALIZED; | ||
2308 | |||
2309 | CY_UNLOCK(info, flags); | ||
2310 | } | ||
2260 | 2311 | ||
2261 | #ifdef CY_DEBUG_OPEN | 2312 | #ifdef CY_DEBUG_OPEN |
2262 | printk(" cyc shutdown done\n"); | 2313 | printk(" cyc shutdown done\n"); |
2263 | #endif | 2314 | #endif |
2264 | return; | 2315 | } /* shutdown */ |
2265 | } /* shutdown */ | ||
2266 | |||
2267 | 2316 | ||
2268 | /* | 2317 | /* |
2269 | * ------------------------------------------------------------ | 2318 | * ------------------------------------------------------------ |
@@ -2272,537 +2321,546 @@ shutdown(struct cyclades_port * info) | |||
2272 | */ | 2321 | */ |
2273 | 2322 | ||
2274 | static int | 2323 | static int |
2275 | block_til_ready(struct tty_struct *tty, struct file * filp, | 2324 | block_til_ready(struct tty_struct *tty, struct file *filp, |
2276 | struct cyclades_port *info) | 2325 | struct cyclades_port *info) |
2277 | { | 2326 | { |
2278 | DECLARE_WAITQUEUE(wait, current); | 2327 | DECLARE_WAITQUEUE(wait, current); |
2279 | struct cyclades_card *cinfo; | 2328 | struct cyclades_card *cinfo; |
2280 | unsigned long flags; | 2329 | unsigned long flags; |
2281 | int chip, channel,index; | 2330 | int chip, channel, index; |
2282 | int retval; | 2331 | int retval; |
2283 | void __iomem *base_addr; | 2332 | void __iomem *base_addr; |
2284 | 2333 | ||
2285 | cinfo = &cy_card[info->card]; | 2334 | cinfo = &cy_card[info->card]; |
2286 | channel = info->line - cinfo->first_line; | 2335 | channel = info->line - cinfo->first_line; |
2287 | 2336 | ||
2288 | /* | 2337 | /* |
2289 | * If the device is in the middle of being closed, then block | 2338 | * If the device is in the middle of being closed, then block |
2290 | * until it's done, and then try again. | 2339 | * until it's done, and then try again. |
2291 | */ | 2340 | */ |
2292 | if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { | 2341 | if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { |
2293 | if (info->flags & ASYNC_CLOSING) { | 2342 | if (info->flags & ASYNC_CLOSING) { |
2294 | interruptible_sleep_on(&info->close_wait); | 2343 | interruptible_sleep_on(&info->close_wait); |
2344 | } | ||
2345 | return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS; | ||
2346 | } | ||
2347 | |||
2348 | /* | ||
2349 | * If non-blocking mode is set, then make the check up front | ||
2350 | * and then exit. | ||
2351 | */ | ||
2352 | if ((filp->f_flags & O_NONBLOCK) || (tty->flags & (1 << TTY_IO_ERROR))) { | ||
2353 | info->flags |= ASYNC_NORMAL_ACTIVE; | ||
2354 | return 0; | ||
2295 | } | 2355 | } |
2296 | return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); | 2356 | |
2297 | } | 2357 | /* |
2298 | 2358 | * Block waiting for the carrier detect and the line to become | |
2299 | /* | 2359 | * free (i.e., not in use by the callout). While we are in |
2300 | * If non-blocking mode is set, then make the check up front | 2360 | * this loop, info->count is dropped by one, so that |
2301 | * and then exit. | 2361 | * cy_close() knows when to free things. We restore it upon |
2302 | */ | 2362 | * exit, either normal or abnormal. |
2303 | if ((filp->f_flags & O_NONBLOCK) || | 2363 | */ |
2304 | (tty->flags & (1 << TTY_IO_ERROR))) { | 2364 | retval = 0; |
2305 | info->flags |= ASYNC_NORMAL_ACTIVE; | 2365 | add_wait_queue(&info->open_wait, &wait); |
2306 | return 0; | ||
2307 | } | ||
2308 | |||
2309 | /* | ||
2310 | * Block waiting for the carrier detect and the line to become | ||
2311 | * free (i.e., not in use by the callout). While we are in | ||
2312 | * this loop, info->count is dropped by one, so that | ||
2313 | * cy_close() knows when to free things. We restore it upon | ||
2314 | * exit, either normal or abnormal. | ||
2315 | */ | ||
2316 | retval = 0; | ||
2317 | add_wait_queue(&info->open_wait, &wait); | ||
2318 | #ifdef CY_DEBUG_OPEN | 2366 | #ifdef CY_DEBUG_OPEN |
2319 | printk("cyc block_til_ready before block: ttyC%d, count = %d\n", | 2367 | printk("cyc block_til_ready before block: ttyC%d, count = %d\n", |
2320 | info->line, info->count);/**/ | 2368 | info->line, info->count); |
2369 | /**/ | ||
2321 | #endif | 2370 | #endif |
2322 | CY_LOCK(info, flags); | 2371 | CY_LOCK(info, flags); |
2323 | if (!tty_hung_up_p(filp)) | 2372 | if (!tty_hung_up_p(filp)) |
2324 | info->count--; | 2373 | info->count--; |
2325 | CY_UNLOCK(info, flags); | 2374 | CY_UNLOCK(info, flags); |
2326 | #ifdef CY_DEBUG_COUNT | 2375 | #ifdef CY_DEBUG_COUNT |
2327 | printk("cyc block_til_ready: (%d): decrementing count to %d\n", | 2376 | printk("cyc block_til_ready: (%d): decrementing count to %d\n", |
2328 | current->pid, info->count); | 2377 | current->pid, info->count); |
2329 | #endif | 2378 | #endif |
2330 | info->blocked_open++; | 2379 | info->blocked_open++; |
2331 | 2380 | ||
2332 | if (!IS_CYC_Z(*cinfo)) { | 2381 | if (!IS_CYC_Z(*cinfo)) { |
2333 | chip = channel>>2; | 2382 | chip = channel >> 2; |
2334 | channel &= 0x03; | 2383 | channel &= 0x03; |
2335 | index = cinfo->bus_index; | 2384 | index = cinfo->bus_index; |
2336 | base_addr = cinfo->base_addr + (cy_chip_offset[chip]<<index); | 2385 | base_addr = cinfo->base_addr + (cy_chip_offset[chip] << index); |
2337 | 2386 | ||
2338 | while (1) { | 2387 | while (1) { |
2339 | CY_LOCK(info, flags); | 2388 | CY_LOCK(info, flags); |
2340 | if ((tty->termios->c_cflag & CBAUD)){ | 2389 | if ((tty->termios->c_cflag & CBAUD)) { |
2341 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 2390 | cy_writeb(base_addr + (CyCAR << index), |
2342 | cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); | 2391 | (u_char) channel); |
2343 | cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); | 2392 | cy_writeb(base_addr + (CyMSVR1 << index), |
2393 | CyRTS); | ||
2394 | cy_writeb(base_addr + (CyMSVR2 << index), | ||
2395 | CyDTR); | ||
2344 | #ifdef CY_DEBUG_DTR | 2396 | #ifdef CY_DEBUG_DTR |
2345 | printk("cyc:block_til_ready raising DTR\n"); | 2397 | printk("cyc:block_til_ready raising DTR\n"); |
2346 | printk(" status: 0x%x, 0x%x\n", | 2398 | printk(" status: 0x%x, 0x%x\n", |
2347 | cy_readb(base_addr+(CyMSVR1<<index)), | 2399 | cy_readb(base_addr + |
2348 | cy_readb(base_addr+(CyMSVR2<<index))); | 2400 | (CyMSVR1 << index)), |
2401 | cy_readb(base_addr + | ||
2402 | (CyMSVR2 << index))); | ||
2349 | #endif | 2403 | #endif |
2350 | } | 2404 | } |
2351 | CY_UNLOCK(info, flags); | 2405 | CY_UNLOCK(info, flags); |
2352 | 2406 | ||
2353 | set_current_state(TASK_INTERRUPTIBLE); | 2407 | set_current_state(TASK_INTERRUPTIBLE); |
2354 | if (tty_hung_up_p(filp) | 2408 | if (tty_hung_up_p(filp) || |
2355 | || !(info->flags & ASYNC_INITIALIZED) ){ | 2409 | !(info->flags & ASYNC_INITIALIZED)) { |
2356 | retval = ((info->flags & ASYNC_HUP_NOTIFY) ? | 2410 | retval = ((info->flags & ASYNC_HUP_NOTIFY) ? |
2357 | -EAGAIN : -ERESTARTSYS); | 2411 | -EAGAIN : -ERESTARTSYS); |
2358 | break; | 2412 | break; |
2359 | } | 2413 | } |
2360 | 2414 | ||
2361 | CY_LOCK(info, flags); | 2415 | CY_LOCK(info, flags); |
2362 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 2416 | cy_writeb(base_addr + (CyCAR << index), |
2363 | if (!(info->flags & ASYNC_CLOSING) | 2417 | (u_char) channel); |
2364 | && (C_CLOCAL(tty) | 2418 | if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) || |
2365 | || (cy_readb(base_addr+(CyMSVR1<<index)) & CyDCD))) { | 2419 | (cy_readb(base_addr + |
2420 | (CyMSVR1 << index)) & CyDCD))) { | ||
2421 | CY_UNLOCK(info, flags); | ||
2422 | break; | ||
2423 | } | ||
2366 | CY_UNLOCK(info, flags); | 2424 | CY_UNLOCK(info, flags); |
2367 | break; | ||
2368 | } | ||
2369 | CY_UNLOCK(info, flags); | ||
2370 | 2425 | ||
2371 | if (signal_pending(current)) { | 2426 | if (signal_pending(current)) { |
2372 | retval = -ERESTARTSYS; | 2427 | retval = -ERESTARTSYS; |
2373 | break; | 2428 | break; |
2374 | } | 2429 | } |
2375 | #ifdef CY_DEBUG_OPEN | 2430 | #ifdef CY_DEBUG_OPEN |
2376 | printk("cyc block_til_ready blocking: ttyC%d, count = %d\n", | 2431 | printk("cyc block_til_ready blocking: ttyC%d, " |
2377 | info->line, info->count);/**/ | 2432 | "count = %d\n", |
2433 | info->line, info->count); | ||
2434 | /**/ | ||
2378 | #endif | 2435 | #endif |
2379 | schedule(); | 2436 | schedule(); |
2380 | } | 2437 | } |
2381 | } else { | 2438 | } else { |
2382 | struct FIRM_ID __iomem *firm_id; | 2439 | struct FIRM_ID __iomem *firm_id; |
2383 | struct ZFW_CTRL __iomem *zfw_ctrl; | 2440 | struct ZFW_CTRL __iomem *zfw_ctrl; |
2384 | struct BOARD_CTRL __iomem *board_ctrl; | 2441 | struct BOARD_CTRL __iomem *board_ctrl; |
2385 | struct CH_CTRL __iomem *ch_ctrl; | 2442 | struct CH_CTRL __iomem *ch_ctrl; |
2386 | int retval; | 2443 | int retval; |
2387 | 2444 | ||
2388 | base_addr = cinfo->base_addr; | 2445 | base_addr = cinfo->base_addr; |
2389 | firm_id = base_addr + ID_ADDRESS; | 2446 | firm_id = base_addr + ID_ADDRESS; |
2390 | if (!ISZLOADED(*cinfo)){ | 2447 | if (!ISZLOADED(*cinfo)) { |
2391 | current->state = TASK_RUNNING; | 2448 | current->state = TASK_RUNNING; |
2392 | remove_wait_queue(&info->open_wait, &wait); | 2449 | remove_wait_queue(&info->open_wait, &wait); |
2393 | return -EINVAL; | 2450 | return -EINVAL; |
2394 | } | ||
2395 | |||
2396 | zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | ||
2397 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
2398 | ch_ctrl = zfw_ctrl->ch_ctrl; | ||
2399 | |||
2400 | while (1) { | ||
2401 | if ((tty->termios->c_cflag & CBAUD)){ | ||
2402 | cy_writel(&ch_ctrl[channel].rs_control, | ||
2403 | cy_readl(&ch_ctrl[channel].rs_control) | | ||
2404 | (C_RS_RTS | C_RS_DTR)); | ||
2405 | retval = cyz_issue_cmd(&cy_card[info->card], | ||
2406 | channel, C_CM_IOCTLM, 0L); | ||
2407 | if (retval != 0){ | ||
2408 | printk("cyc:block_til_ready retval on ttyC%d was %x\n", | ||
2409 | info->line, retval); | ||
2410 | } | 2451 | } |
2452 | |||
2453 | zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & | ||
2454 | 0xfffff); | ||
2455 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
2456 | ch_ctrl = zfw_ctrl->ch_ctrl; | ||
2457 | |||
2458 | while (1) { | ||
2459 | if ((tty->termios->c_cflag & CBAUD)) { | ||
2460 | cy_writel(&ch_ctrl[channel].rs_control, | ||
2461 | cy_readl(&ch_ctrl[channel]. | ||
2462 | rs_control) | (C_RS_RTS | | ||
2463 | C_RS_DTR)); | ||
2464 | retval = cyz_issue_cmd(&cy_card[info->card], | ||
2465 | channel, C_CM_IOCTLM, 0L); | ||
2466 | if (retval != 0) { | ||
2467 | printk("cyc:block_til_ready retval on " | ||
2468 | "ttyC%d was %x\n", | ||
2469 | info->line, retval); | ||
2470 | } | ||
2411 | #ifdef CY_DEBUG_DTR | 2471 | #ifdef CY_DEBUG_DTR |
2412 | printk("cyc:block_til_ready raising Z DTR\n"); | 2472 | printk("cyc:block_til_ready raising Z DTR\n"); |
2413 | #endif | 2473 | #endif |
2414 | } | 2474 | } |
2415 | 2475 | ||
2416 | set_current_state(TASK_INTERRUPTIBLE); | 2476 | set_current_state(TASK_INTERRUPTIBLE); |
2417 | if (tty_hung_up_p(filp) | 2477 | if (tty_hung_up_p(filp) || |
2418 | || !(info->flags & ASYNC_INITIALIZED) ){ | 2478 | !(info->flags & ASYNC_INITIALIZED)) { |
2419 | retval = ((info->flags & ASYNC_HUP_NOTIFY) ? | 2479 | retval = ((info->flags & ASYNC_HUP_NOTIFY) ? |
2420 | -EAGAIN : -ERESTARTSYS); | 2480 | -EAGAIN : -ERESTARTSYS); |
2421 | break; | 2481 | break; |
2422 | } | 2482 | } |
2423 | if (!(info->flags & ASYNC_CLOSING) | 2483 | if (!(info->flags & ASYNC_CLOSING) && (C_CLOCAL(tty) || |
2424 | && (C_CLOCAL(tty) | 2484 | (cy_readl(&ch_ctrl[channel].rs_status) & |
2425 | || (cy_readl(&ch_ctrl[channel].rs_status) & C_RS_DCD))) { | 2485 | C_RS_DCD))) { |
2426 | break; | 2486 | break; |
2427 | } | 2487 | } |
2428 | if (signal_pending(current)) { | 2488 | if (signal_pending(current)) { |
2429 | retval = -ERESTARTSYS; | 2489 | retval = -ERESTARTSYS; |
2430 | break; | 2490 | break; |
2431 | } | 2491 | } |
2432 | #ifdef CY_DEBUG_OPEN | 2492 | #ifdef CY_DEBUG_OPEN |
2433 | printk("cyc block_til_ready blocking: ttyC%d, count = %d\n", | 2493 | printk("cyc block_til_ready blocking: ttyC%d, " |
2434 | info->line, info->count);/**/ | 2494 | "count = %d\n", |
2495 | info->line, info->count); | ||
2496 | /**/ | ||
2435 | #endif | 2497 | #endif |
2436 | schedule(); | 2498 | schedule(); |
2499 | } | ||
2437 | } | 2500 | } |
2438 | } | 2501 | current->state = TASK_RUNNING; |
2439 | current->state = TASK_RUNNING; | 2502 | remove_wait_queue(&info->open_wait, &wait); |
2440 | remove_wait_queue(&info->open_wait, &wait); | 2503 | if (!tty_hung_up_p(filp)) { |
2441 | if (!tty_hung_up_p(filp)){ | 2504 | info->count++; |
2442 | info->count++; | ||
2443 | #ifdef CY_DEBUG_COUNT | 2505 | #ifdef CY_DEBUG_COUNT |
2444 | printk("cyc:block_til_ready (%d): incrementing count to %d\n", | 2506 | printk("cyc:block_til_ready (%d): incrementing count to %d\n", |
2445 | current->pid, info->count); | 2507 | current->pid, info->count); |
2446 | #endif | 2508 | #endif |
2447 | } | 2509 | } |
2448 | info->blocked_open--; | 2510 | info->blocked_open--; |
2449 | #ifdef CY_DEBUG_OPEN | 2511 | #ifdef CY_DEBUG_OPEN |
2450 | printk("cyc:block_til_ready after blocking: ttyC%d, count = %d\n", | 2512 | printk("cyc:block_til_ready after blocking: ttyC%d, count = %d\n", |
2451 | info->line, info->count);/**/ | 2513 | info->line, info->count); |
2514 | /**/ | ||
2452 | #endif | 2515 | #endif |
2453 | if (retval) | 2516 | if (retval) |
2454 | return retval; | 2517 | return retval; |
2455 | info->flags |= ASYNC_NORMAL_ACTIVE; | 2518 | info->flags |= ASYNC_NORMAL_ACTIVE; |
2456 | return 0; | 2519 | return 0; |
2457 | } /* block_til_ready */ | 2520 | } /* block_til_ready */ |
2458 | |||
2459 | 2521 | ||
2460 | /* | 2522 | /* |
2461 | * This routine is called whenever a serial port is opened. It | 2523 | * This routine is called whenever a serial port is opened. It |
2462 | * performs the serial-specific initialization for the tty structure. | 2524 | * performs the serial-specific initialization for the tty structure. |
2463 | */ | 2525 | */ |
2464 | static int | 2526 | static int cy_open(struct tty_struct *tty, struct file *filp) |
2465 | cy_open(struct tty_struct *tty, struct file * filp) | ||
2466 | { | 2527 | { |
2467 | struct cyclades_port *info; | 2528 | struct cyclades_port *info; |
2468 | int retval, line; | 2529 | int retval, line; |
2469 | unsigned long page; | ||
2470 | |||
2471 | line = tty->index; | ||
2472 | if ((line < 0) || (NR_PORTS <= line)){ | ||
2473 | return -ENODEV; | ||
2474 | } | ||
2475 | info = &cy_port[line]; | ||
2476 | if (info->line < 0){ | ||
2477 | return -ENODEV; | ||
2478 | } | ||
2479 | |||
2480 | /* If the card's firmware hasn't been loaded, | ||
2481 | treat it as absent from the system. This | ||
2482 | will make the user pay attention. | ||
2483 | */ | ||
2484 | if (IS_CYC_Z(cy_card[info->card])) { | ||
2485 | struct cyclades_card *cinfo = &cy_card[info->card]; | ||
2486 | struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; | ||
2487 | |||
2488 | if (!ISZLOADED(*cinfo)) { | ||
2489 | if (((ZE_V1 ==cy_readl(&((struct RUNTIME_9060 __iomem *) | ||
2490 | (cinfo->ctl_addr))->mail_box_0)) && | ||
2491 | Z_FPGA_CHECK (*cinfo)) && | ||
2492 | (ZFIRM_HLT == cy_readl (&firm_id->signature))) | ||
2493 | { | ||
2494 | printk ("cyc:Cyclades-Z Error: you need an external power supply for this number of ports.\n\rFirmware halted.\r\n"); | ||
2495 | } else { | ||
2496 | printk("cyc:Cyclades-Z firmware not yet loaded\n"); | ||
2497 | } | ||
2498 | return -ENODEV; | ||
2499 | } | ||
2500 | #ifdef CONFIG_CYZ_INTR | ||
2501 | else { | ||
2502 | /* In case this Z board is operating in interrupt mode, its | ||
2503 | interrupts should be enabled as soon as the first open happens | ||
2504 | to one of its ports. */ | ||
2505 | if (!cinfo->intr_enabled) { | ||
2506 | struct ZFW_CTRL __iomem *zfw_ctrl; | ||
2507 | struct BOARD_CTRL __iomem *board_ctrl; | ||
2508 | |||
2509 | zfw_ctrl = cinfo->base_addr + (cy_readl (&firm_id->zfwctrl_addr) & 0xfffff); | ||
2510 | 2530 | ||
2511 | board_ctrl = &zfw_ctrl->board_ctrl; | 2531 | line = tty->index; |
2532 | if ((line < 0) || (NR_PORTS <= line)) { | ||
2533 | return -ENODEV; | ||
2534 | } | ||
2535 | info = &cy_port[line]; | ||
2536 | if (info->line < 0) { | ||
2537 | return -ENODEV; | ||
2538 | } | ||
2512 | 2539 | ||
2513 | /* Enable interrupts on the PLX chip */ | 2540 | /* If the card's firmware hasn't been loaded, |
2514 | cy_writew(cinfo->ctl_addr+0x68, | 2541 | treat it as absent from the system. This |
2515 | cy_readw(cinfo->ctl_addr+0x68)|0x0900); | 2542 | will make the user pay attention. |
2516 | /* Enable interrupts on the FW */ | 2543 | */ |
2517 | retval = cyz_issue_cmd(cinfo, | 2544 | if (IS_CYC_Z(cy_card[info->card])) { |
2518 | 0, C_CM_IRQ_ENBL, 0L); | 2545 | struct cyclades_card *cinfo = &cy_card[info->card]; |
2519 | if (retval != 0){ | 2546 | struct FIRM_ID __iomem *firm_id = cinfo->base_addr + ID_ADDRESS; |
2520 | printk("cyc:IRQ enable retval was %x\n", retval); | 2547 | |
2548 | if (!ISZLOADED(*cinfo)) { | ||
2549 | if (((ZE_V1 == cy_readl( | ||
2550 | &((struct RUNTIME_9060 __iomem *) | ||
2551 | (cinfo->ctl_addr))->mail_box_0)) && | ||
2552 | Z_FPGA_CHECK(*cinfo)) && | ||
2553 | (ZFIRM_HLT == cy_readl( | ||
2554 | &firm_id->signature))) { | ||
2555 | printk("cyc:Cyclades-Z Error: you need an " | ||
2556 | "external power supply for this number " | ||
2557 | "of ports.\n\rFirmware halted.\r\n"); | ||
2558 | } else { | ||
2559 | printk("cyc:Cyclades-Z firmware not yet " | ||
2560 | "loaded\n"); | ||
2561 | } | ||
2562 | return -ENODEV; | ||
2563 | } | ||
2564 | #ifdef CONFIG_CYZ_INTR | ||
2565 | else { | ||
2566 | /* In case this Z board is operating in interrupt mode, its | ||
2567 | interrupts should be enabled as soon as the first open | ||
2568 | happens to one of its ports. */ | ||
2569 | if (!cinfo->intr_enabled) { | ||
2570 | struct ZFW_CTRL __iomem *zfw_ctrl; | ||
2571 | struct BOARD_CTRL __iomem *board_ctrl; | ||
2572 | |||
2573 | zfw_ctrl = cinfo->base_addr + | ||
2574 | (cy_readl(&firm_id->zfwctrl_addr) & | ||
2575 | 0xfffff); | ||
2576 | |||
2577 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
2578 | |||
2579 | /* Enable interrupts on the PLX chip */ | ||
2580 | cy_writew(cinfo->ctl_addr + 0x68, | ||
2581 | cy_readw(cinfo->ctl_addr + | ||
2582 | 0x68) | 0x0900); | ||
2583 | /* Enable interrupts on the FW */ | ||
2584 | retval = cyz_issue_cmd(cinfo, 0, | ||
2585 | C_CM_IRQ_ENBL, 0L); | ||
2586 | if (retval != 0) { | ||
2587 | printk("cyc:IRQ enable retval was %x\n", | ||
2588 | retval); | ||
2589 | } | ||
2590 | cinfo->nports = | ||
2591 | (int)cy_readl(&board_ctrl->n_channel); | ||
2592 | cinfo->intr_enabled = 1; | ||
2593 | } | ||
2521 | } | 2594 | } |
2522 | cinfo->nports = (int) cy_readl (&board_ctrl->n_channel); | 2595 | #endif /* CONFIG_CYZ_INTR */ |
2523 | cinfo->intr_enabled = 1; | 2596 | /* Make sure this Z port really exists in hardware */ |
2524 | } | 2597 | if (info->line > (cinfo->first_line + cinfo->nports - 1)) |
2598 | return -ENODEV; | ||
2525 | } | 2599 | } |
2526 | #endif /* CONFIG_CYZ_INTR */ | ||
2527 | /* Make sure this Z port really exists in hardware */ | ||
2528 | if (info->line > (cinfo->first_line + cinfo->nports - 1)) | ||
2529 | return -ENODEV; | ||
2530 | } | ||
2531 | #ifdef CY_DEBUG_OTHER | 2600 | #ifdef CY_DEBUG_OTHER |
2532 | printk("cyc:cy_open ttyC%d\n", info->line); /* */ | 2601 | printk("cyc:cy_open ttyC%d\n", info->line); /* */ |
2533 | #endif | 2602 | #endif |
2534 | tty->driver_data = info; | 2603 | tty->driver_data = info; |
2535 | info->tty = tty; | 2604 | info->tty = tty; |
2536 | if (serial_paranoia_check(info, tty->name, "cy_open")){ | 2605 | if (serial_paranoia_check(info, tty->name, "cy_open")) { |
2537 | return -ENODEV; | 2606 | return -ENODEV; |
2538 | } | 2607 | } |
2539 | #ifdef CY_DEBUG_OPEN | 2608 | #ifdef CY_DEBUG_OPEN |
2540 | printk("cyc:cy_open ttyC%d, count = %d\n", | 2609 | printk("cyc:cy_open ttyC%d, count = %d\n", info->line, info->count); |
2541 | info->line, info->count);/**/ | 2610 | /**/ |
2542 | #endif | 2611 | #endif |
2543 | info->count++; | 2612 | info->count++; |
2544 | #ifdef CY_DEBUG_COUNT | 2613 | #ifdef CY_DEBUG_COUNT |
2545 | printk("cyc:cy_open (%d): incrementing count to %d\n", | 2614 | printk("cyc:cy_open (%d): incrementing count to %d\n", |
2546 | current->pid, info->count); | 2615 | current->pid, info->count); |
2547 | #endif | 2616 | #endif |
2548 | if (!tmp_buf) { | ||
2549 | page = get_zeroed_page(GFP_KERNEL); | ||
2550 | if (!page) | ||
2551 | return -ENOMEM; | ||
2552 | if (tmp_buf) | ||
2553 | free_page(page); | ||
2554 | else | ||
2555 | tmp_buf = (unsigned char *) page; | ||
2556 | } | ||
2557 | |||
2558 | /* | ||
2559 | * If the port is the middle of closing, bail out now | ||
2560 | */ | ||
2561 | if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { | ||
2562 | if (info->flags & ASYNC_CLOSING) | ||
2563 | interruptible_sleep_on(&info->close_wait); | ||
2564 | return ((info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN : -ERESTARTSYS); | ||
2565 | } | ||
2566 | |||
2567 | /* | ||
2568 | * Start up serial port | ||
2569 | */ | ||
2570 | retval = startup(info); | ||
2571 | if (retval){ | ||
2572 | return retval; | ||
2573 | } | ||
2574 | |||
2575 | retval = block_til_ready(tty, filp, info); | ||
2576 | if (retval) { | ||
2577 | #ifdef CY_DEBUG_OPEN | ||
2578 | printk("cyc:cy_open returning after block_til_ready with %d\n", | ||
2579 | retval); | ||
2580 | #endif | ||
2581 | return retval; | ||
2582 | } | ||
2583 | 2617 | ||
2584 | info->throttle = 0; | 2618 | /* |
2619 | * If the port is the middle of closing, bail out now | ||
2620 | */ | ||
2621 | if (tty_hung_up_p(filp) || (info->flags & ASYNC_CLOSING)) { | ||
2622 | if (info->flags & ASYNC_CLOSING) | ||
2623 | interruptible_sleep_on(&info->close_wait); | ||
2624 | return (info->flags & ASYNC_HUP_NOTIFY) ? -EAGAIN: -ERESTARTSYS; | ||
2625 | } | ||
2626 | |||
2627 | /* | ||
2628 | * Start up serial port | ||
2629 | */ | ||
2630 | retval = startup(info); | ||
2631 | if (retval) { | ||
2632 | return retval; | ||
2633 | } | ||
2585 | 2634 | ||
2635 | retval = block_til_ready(tty, filp, info); | ||
2636 | if (retval) { | ||
2586 | #ifdef CY_DEBUG_OPEN | 2637 | #ifdef CY_DEBUG_OPEN |
2587 | printk(" cyc:cy_open done\n");/**/ | 2638 | printk("cyc:cy_open returning after block_til_ready with %d\n", |
2639 | retval); | ||
2588 | #endif | 2640 | #endif |
2641 | return retval; | ||
2642 | } | ||
2589 | 2643 | ||
2590 | return 0; | 2644 | info->throttle = 0; |
2591 | } /* cy_open */ | ||
2592 | 2645 | ||
2646 | #ifdef CY_DEBUG_OPEN | ||
2647 | printk(" cyc:cy_open done\n"); | ||
2648 | /**/ | ||
2649 | #endif | ||
2650 | return 0; | ||
2651 | } /* cy_open */ | ||
2593 | 2652 | ||
2594 | /* | 2653 | /* |
2595 | * cy_wait_until_sent() --- wait until the transmitter is empty | 2654 | * cy_wait_until_sent() --- wait until the transmitter is empty |
2596 | */ | 2655 | */ |
2597 | static void | 2656 | static void cy_wait_until_sent(struct tty_struct *tty, int timeout) |
2598 | cy_wait_until_sent(struct tty_struct *tty, int timeout) | ||
2599 | { | 2657 | { |
2600 | struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; | 2658 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
2601 | void __iomem *base_addr; | 2659 | void __iomem *base_addr; |
2602 | int card,chip,channel,index; | 2660 | int card, chip, channel, index; |
2603 | unsigned long orig_jiffies; | 2661 | unsigned long orig_jiffies; |
2604 | int char_time; | 2662 | int char_time; |
2605 | 2663 | ||
2606 | if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent")) | 2664 | if (serial_paranoia_check(info, tty->name, "cy_wait_until_sent")) |
2607 | return; | 2665 | return; |
2608 | 2666 | ||
2609 | if (info->xmit_fifo_size == 0) | 2667 | if (info->xmit_fifo_size == 0) |
2610 | return; /* Just in case.... */ | 2668 | return; /* Just in case.... */ |
2611 | 2669 | ||
2612 | 2670 | orig_jiffies = jiffies; | |
2613 | orig_jiffies = jiffies; | 2671 | /* |
2614 | /* | 2672 | * Set the check interval to be 1/5 of the estimated time to |
2615 | * Set the check interval to be 1/5 of the estimated time to | 2673 | * send a single character, and make it at least 1. The check |
2616 | * send a single character, and make it at least 1. The check | 2674 | * interval should also be less than the timeout. |
2617 | * interval should also be less than the timeout. | 2675 | * |
2618 | * | 2676 | * Note: we have to use pretty tight timings here to satisfy |
2619 | * Note: we have to use pretty tight timings here to satisfy | 2677 | * the NIST-PCTS. |
2620 | * the NIST-PCTS. | 2678 | */ |
2621 | */ | 2679 | char_time = (info->timeout - HZ / 50) / info->xmit_fifo_size; |
2622 | char_time = (info->timeout - HZ/50) / info->xmit_fifo_size; | 2680 | char_time = char_time / 5; |
2623 | char_time = char_time / 5; | 2681 | if (char_time <= 0) |
2624 | if (char_time <= 0) | 2682 | char_time = 1; |
2625 | char_time = 1; | 2683 | if (timeout < 0) |
2626 | if (timeout < 0) | 2684 | timeout = 0; |
2627 | timeout = 0; | 2685 | if (timeout) |
2628 | if (timeout) | 2686 | char_time = min(char_time, timeout); |
2629 | char_time = min(char_time, timeout); | 2687 | /* |
2630 | /* | 2688 | * If the transmitter hasn't cleared in twice the approximate |
2631 | * If the transmitter hasn't cleared in twice the approximate | 2689 | * amount of time to send the entire FIFO, it probably won't |
2632 | * amount of time to send the entire FIFO, it probably won't | 2690 | * ever clear. This assumes the UART isn't doing flow |
2633 | * ever clear. This assumes the UART isn't doing flow | 2691 | * control, which is currently the case. Hence, if it ever |
2634 | * control, which is currently the case. Hence, if it ever | 2692 | * takes longer than info->timeout, this is probably due to a |
2635 | * takes longer than info->timeout, this is probably due to a | 2693 | * UART bug of some kind. So, we clamp the timeout parameter at |
2636 | * UART bug of some kind. So, we clamp the timeout parameter at | 2694 | * 2*info->timeout. |
2637 | * 2*info->timeout. | 2695 | */ |
2638 | */ | 2696 | if (!timeout || timeout > 2 * info->timeout) |
2639 | if (!timeout || timeout > 2*info->timeout) | 2697 | timeout = 2 * info->timeout; |
2640 | timeout = 2*info->timeout; | ||
2641 | #ifdef CY_DEBUG_WAIT_UNTIL_SENT | 2698 | #ifdef CY_DEBUG_WAIT_UNTIL_SENT |
2642 | printk("In cy_wait_until_sent(%d) check=%lu...", timeout, char_time); | 2699 | printk("In cy_wait_until_sent(%d) check=%lu...", timeout, char_time); |
2643 | printk("jiff=%lu...", jiffies); | 2700 | printk("jiff=%lu...", jiffies); |
2644 | #endif | 2701 | #endif |
2645 | card = info->card; | 2702 | card = info->card; |
2646 | channel = (info->line) - (cy_card[card].first_line); | 2703 | channel = (info->line) - (cy_card[card].first_line); |
2647 | if (!IS_CYC_Z(cy_card[card])) { | 2704 | if (!IS_CYC_Z(cy_card[card])) { |
2648 | chip = channel>>2; | 2705 | chip = channel >> 2; |
2649 | channel &= 0x03; | 2706 | channel &= 0x03; |
2650 | index = cy_card[card].bus_index; | 2707 | index = cy_card[card].bus_index; |
2651 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | 2708 | base_addr = |
2652 | while (cy_readb(base_addr+(CySRER<<index)) & CyTxRdy) { | 2709 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); |
2710 | while (cy_readb(base_addr + (CySRER << index)) & CyTxRdy) { | ||
2653 | #ifdef CY_DEBUG_WAIT_UNTIL_SENT | 2711 | #ifdef CY_DEBUG_WAIT_UNTIL_SENT |
2654 | printk("Not clean (jiff=%lu)...", jiffies); | 2712 | printk("Not clean (jiff=%lu)...", jiffies); |
2655 | #endif | 2713 | #endif |
2656 | if (msleep_interruptible(jiffies_to_msecs(char_time))) | 2714 | if (msleep_interruptible(jiffies_to_msecs(char_time))) |
2657 | break; | 2715 | break; |
2658 | if (timeout && time_after(jiffies, orig_jiffies + timeout)) | 2716 | if (timeout && time_after(jiffies, orig_jiffies + |
2659 | break; | 2717 | timeout)) |
2718 | break; | ||
2719 | } | ||
2720 | } else { | ||
2721 | /* Nothing to do! */ | ||
2660 | } | 2722 | } |
2661 | } else { | 2723 | /* Run one more char cycle */ |
2662 | // Nothing to do! | 2724 | msleep_interruptible(jiffies_to_msecs(char_time * 5)); |
2663 | } | ||
2664 | /* Run one more char cycle */ | ||
2665 | msleep_interruptible(jiffies_to_msecs(char_time * 5)); | ||
2666 | #ifdef CY_DEBUG_WAIT_UNTIL_SENT | 2725 | #ifdef CY_DEBUG_WAIT_UNTIL_SENT |
2667 | printk("Clean (jiff=%lu)...done\n", jiffies); | 2726 | printk("Clean (jiff=%lu)...done\n", jiffies); |
2668 | #endif | 2727 | #endif |
2669 | } | 2728 | } |
2670 | 2729 | ||
2671 | /* | 2730 | /* |
2672 | * This routine is called when a particular tty device is closed. | 2731 | * This routine is called when a particular tty device is closed. |
2673 | */ | 2732 | */ |
2674 | static void | 2733 | static void cy_close(struct tty_struct *tty, struct file *filp) |
2675 | cy_close(struct tty_struct *tty, struct file *filp) | ||
2676 | { | 2734 | { |
2677 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 2735 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
2678 | unsigned long flags; | 2736 | unsigned long flags; |
2679 | 2737 | ||
2680 | #ifdef CY_DEBUG_OTHER | 2738 | #ifdef CY_DEBUG_OTHER |
2681 | printk("cyc:cy_close ttyC%d\n", info->line); | 2739 | printk("cyc:cy_close ttyC%d\n", info->line); |
2682 | #endif | 2740 | #endif |
2683 | 2741 | ||
2684 | if (!info || serial_paranoia_check(info, tty->name, "cy_close")){ | 2742 | if (!info || serial_paranoia_check(info, tty->name, "cy_close")) { |
2685 | return; | 2743 | return; |
2686 | } | 2744 | } |
2687 | 2745 | ||
2688 | CY_LOCK(info, flags); | 2746 | CY_LOCK(info, flags); |
2689 | /* If the TTY is being hung up, nothing to do */ | 2747 | /* If the TTY is being hung up, nothing to do */ |
2690 | if (tty_hung_up_p(filp)) { | 2748 | if (tty_hung_up_p(filp)) { |
2691 | CY_UNLOCK(info, flags); | 2749 | CY_UNLOCK(info, flags); |
2692 | return; | 2750 | return; |
2693 | } | 2751 | } |
2694 | |||
2695 | #ifdef CY_DEBUG_OPEN | 2752 | #ifdef CY_DEBUG_OPEN |
2696 | printk("cyc:cy_close ttyC%d, count = %d\n", info->line, info->count); | 2753 | printk("cyc:cy_close ttyC%d, count = %d\n", info->line, info->count); |
2697 | #endif | 2754 | #endif |
2698 | if ((tty->count == 1) && (info->count != 1)) { | 2755 | if ((tty->count == 1) && (info->count != 1)) { |
2699 | /* | 2756 | /* |
2700 | * Uh, oh. tty->count is 1, which means that the tty | 2757 | * Uh, oh. tty->count is 1, which means that the tty |
2701 | * structure will be freed. Info->count should always | 2758 | * structure will be freed. Info->count should always |
2702 | * be one in these conditions. If it's greater than | 2759 | * be one in these conditions. If it's greater than |
2703 | * one, we've got real problems, since it means the | 2760 | * one, we've got real problems, since it means the |
2704 | * serial port won't be shutdown. | 2761 | * serial port won't be shutdown. |
2705 | */ | 2762 | */ |
2706 | printk("cyc:cy_close: bad serial port count; tty->count is 1, " | 2763 | printk("cyc:cy_close: bad serial port count; tty->count is 1, " |
2707 | "info->count is %d\n", info->count); | 2764 | "info->count is %d\n", info->count); |
2708 | info->count = 1; | 2765 | info->count = 1; |
2709 | } | 2766 | } |
2710 | #ifdef CY_DEBUG_COUNT | 2767 | #ifdef CY_DEBUG_COUNT |
2711 | printk("cyc:cy_close at (%d): decrementing count to %d\n", | 2768 | printk("cyc:cy_close at (%d): decrementing count to %d\n", |
2712 | current->pid, info->count - 1); | 2769 | current->pid, info->count - 1); |
2713 | #endif | 2770 | #endif |
2714 | if (--info->count < 0) { | 2771 | if (--info->count < 0) { |
2715 | #ifdef CY_DEBUG_COUNT | 2772 | #ifdef CY_DEBUG_COUNT |
2716 | printk("cyc:cyc_close setting count to 0\n"); | 2773 | printk("cyc:cyc_close setting count to 0\n"); |
2717 | #endif | 2774 | #endif |
2718 | info->count = 0; | 2775 | info->count = 0; |
2719 | } | ||
2720 | if (info->count) { | ||
2721 | CY_UNLOCK(info, flags); | ||
2722 | return; | ||
2723 | } | ||
2724 | info->flags |= ASYNC_CLOSING; | ||
2725 | |||
2726 | /* | ||
2727 | * Now we wait for the transmit buffer to clear; and we notify | ||
2728 | * the line discipline to only process XON/XOFF characters. | ||
2729 | */ | ||
2730 | tty->closing = 1; | ||
2731 | CY_UNLOCK(info, flags); | ||
2732 | if (info->closing_wait != CY_CLOSING_WAIT_NONE) { | ||
2733 | tty_wait_until_sent(tty, info->closing_wait); | ||
2734 | } | ||
2735 | CY_LOCK(info, flags); | ||
2736 | |||
2737 | if (!IS_CYC_Z(cy_card[info->card])) { | ||
2738 | int channel = info->line - cy_card[info->card].first_line; | ||
2739 | int index = cy_card[info->card].bus_index; | ||
2740 | void __iomem *base_addr = cy_card[info->card].base_addr + (cy_chip_offset[channel>>2] << index); | ||
2741 | /* Stop accepting input */ | ||
2742 | channel &= 0x03; | ||
2743 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | ||
2744 | cy_writeb(base_addr+(CySRER<<index), | ||
2745 | cy_readb(base_addr+(CySRER<<index)) & ~CyRxData); | ||
2746 | if (info->flags & ASYNC_INITIALIZED) { | ||
2747 | /* Waiting for on-board buffers to be empty before closing | ||
2748 | the port */ | ||
2749 | CY_UNLOCK(info, flags); | ||
2750 | cy_wait_until_sent(tty, info->timeout); | ||
2751 | CY_LOCK(info, flags); | ||
2752 | } | 2776 | } |
2753 | } else { | 2777 | if (info->count) { |
2754 | #ifdef Z_WAKE | 2778 | CY_UNLOCK(info, flags); |
2755 | /* Waiting for on-board buffers to be empty before closing the port */ | 2779 | return; |
2756 | void __iomem *base_addr = cy_card[info->card].base_addr; | 2780 | } |
2757 | struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS; | 2781 | info->flags |= ASYNC_CLOSING; |
2758 | struct ZFW_CTRL __iomem *zfw_ctrl = base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | ||
2759 | struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl; | ||
2760 | int channel = info->line - cy_card[info->card].first_line; | ||
2761 | int retval; | ||
2762 | 2782 | ||
2763 | if (cy_readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) { | 2783 | /* |
2764 | retval = cyz_issue_cmd(&cy_card[info->card], channel, | 2784 | * Now we wait for the transmit buffer to clear; and we notify |
2765 | C_CM_IOCTLW, 0L); | 2785 | * the line discipline to only process XON/XOFF characters. |
2766 | if (retval != 0){ | 2786 | */ |
2767 | printk("cyc:cy_close retval on ttyC%d was %x\n", | 2787 | tty->closing = 1; |
2768 | info->line, retval); | 2788 | CY_UNLOCK(info, flags); |
2769 | } | 2789 | if (info->closing_wait != CY_CLOSING_WAIT_NONE) { |
2770 | CY_UNLOCK(info, flags); | 2790 | tty_wait_until_sent(tty, info->closing_wait); |
2771 | interruptible_sleep_on(&info->shutdown_wait); | ||
2772 | CY_LOCK(info, flags); | ||
2773 | } | 2791 | } |
2792 | CY_LOCK(info, flags); | ||
2793 | |||
2794 | if (!IS_CYC_Z(cy_card[info->card])) { | ||
2795 | int channel = info->line - cy_card[info->card].first_line; | ||
2796 | int index = cy_card[info->card].bus_index; | ||
2797 | void __iomem *base_addr = cy_card[info->card].base_addr + | ||
2798 | (cy_chip_offset[channel >> 2] << index); | ||
2799 | /* Stop accepting input */ | ||
2800 | channel &= 0x03; | ||
2801 | cy_writeb(base_addr + (CyCAR << index), (u_char) channel); | ||
2802 | cy_writeb(base_addr + (CySRER << index), | ||
2803 | cy_readb(base_addr + (CySRER << index)) & ~CyRxData); | ||
2804 | if (info->flags & ASYNC_INITIALIZED) { | ||
2805 | /* Waiting for on-board buffers to be empty before closing | ||
2806 | the port */ | ||
2807 | CY_UNLOCK(info, flags); | ||
2808 | cy_wait_until_sent(tty, info->timeout); | ||
2809 | CY_LOCK(info, flags); | ||
2810 | } | ||
2811 | } else { | ||
2812 | #ifdef Z_WAKE | ||
2813 | /* Waiting for on-board buffers to be empty before closing the port */ | ||
2814 | void __iomem *base_addr = cy_card[info->card].base_addr; | ||
2815 | struct FIRM_ID __iomem *firm_id = base_addr + ID_ADDRESS; | ||
2816 | struct ZFW_CTRL __iomem *zfw_ctrl = | ||
2817 | base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | ||
2818 | struct CH_CTRL __iomem *ch_ctrl = zfw_ctrl->ch_ctrl; | ||
2819 | int channel = info->line - cy_card[info->card].first_line; | ||
2820 | int retval; | ||
2821 | |||
2822 | if (cy_readl(&ch_ctrl[channel].flow_status) != C_FS_TXIDLE) { | ||
2823 | retval = cyz_issue_cmd(&cy_card[info->card], channel, | ||
2824 | C_CM_IOCTLW, 0L); | ||
2825 | if (retval != 0) { | ||
2826 | printk("cyc:cy_close retval on ttyC%d was %x\n", | ||
2827 | info->line, retval); | ||
2828 | } | ||
2829 | CY_UNLOCK(info, flags); | ||
2830 | interruptible_sleep_on(&info->shutdown_wait); | ||
2831 | CY_LOCK(info, flags); | ||
2832 | } | ||
2774 | #endif | 2833 | #endif |
2775 | } | 2834 | } |
2776 | 2835 | ||
2777 | CY_UNLOCK(info, flags); | ||
2778 | shutdown(info); | ||
2779 | if (tty->driver->flush_buffer) | ||
2780 | tty->driver->flush_buffer(tty); | ||
2781 | tty_ldisc_flush(tty); | ||
2782 | CY_LOCK(info, flags); | ||
2783 | |||
2784 | tty->closing = 0; | ||
2785 | info->event = 0; | ||
2786 | info->tty = NULL; | ||
2787 | if (info->blocked_open) { | ||
2788 | CY_UNLOCK(info, flags); | 2836 | CY_UNLOCK(info, flags); |
2789 | if (info->close_delay) { | 2837 | shutdown(info); |
2790 | msleep_interruptible(jiffies_to_msecs(info->close_delay)); | 2838 | if (tty->driver->flush_buffer) |
2791 | } | 2839 | tty->driver->flush_buffer(tty); |
2792 | wake_up_interruptible(&info->open_wait); | 2840 | tty_ldisc_flush(tty); |
2793 | CY_LOCK(info, flags); | 2841 | CY_LOCK(info, flags); |
2794 | } | 2842 | |
2795 | info->flags &= ~(ASYNC_NORMAL_ACTIVE|ASYNC_CLOSING); | 2843 | tty->closing = 0; |
2796 | wake_up_interruptible(&info->close_wait); | 2844 | info->event = 0; |
2845 | info->tty = NULL; | ||
2846 | if (info->blocked_open) { | ||
2847 | CY_UNLOCK(info, flags); | ||
2848 | if (info->close_delay) { | ||
2849 | msleep_interruptible(jiffies_to_msecs | ||
2850 | (info->close_delay)); | ||
2851 | } | ||
2852 | wake_up_interruptible(&info->open_wait); | ||
2853 | CY_LOCK(info, flags); | ||
2854 | } | ||
2855 | info->flags &= ~(ASYNC_NORMAL_ACTIVE | ASYNC_CLOSING); | ||
2856 | wake_up_interruptible(&info->close_wait); | ||
2797 | 2857 | ||
2798 | #ifdef CY_DEBUG_OTHER | 2858 | #ifdef CY_DEBUG_OTHER |
2799 | printk(" cyc:cy_close done\n"); | 2859 | printk(" cyc:cy_close done\n"); |
2800 | #endif | 2860 | #endif |
2801 | 2861 | ||
2802 | CY_UNLOCK(info, flags); | 2862 | CY_UNLOCK(info, flags); |
2803 | return; | 2863 | } /* cy_close */ |
2804 | } /* cy_close */ | ||
2805 | |||
2806 | 2864 | ||
2807 | /* This routine gets called when tty_write has put something into | 2865 | /* This routine gets called when tty_write has put something into |
2808 | * the write_queue. The characters may come from user space or | 2866 | * the write_queue. The characters may come from user space or |
@@ -2817,50 +2875,49 @@ cy_close(struct tty_struct *tty, struct file *filp) | |||
2817 | * If the port is already active, there is no need to kick it. | 2875 | * If the port is already active, there is no need to kick it. |
2818 | * | 2876 | * |
2819 | */ | 2877 | */ |
2820 | static int | 2878 | static int cy_write(struct tty_struct *tty, const unsigned char *buf, int count) |
2821 | cy_write(struct tty_struct * tty, const unsigned char *buf, int count) | ||
2822 | { | 2879 | { |
2823 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 2880 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
2824 | unsigned long flags; | 2881 | unsigned long flags; |
2825 | int c, ret = 0; | 2882 | int c, ret = 0; |
2826 | 2883 | ||
2827 | #ifdef CY_DEBUG_IO | 2884 | #ifdef CY_DEBUG_IO |
2828 | printk("cyc:cy_write ttyC%d\n", info->line); /* */ | 2885 | printk("cyc:cy_write ttyC%d\n", info->line); /* */ |
2829 | #endif | 2886 | #endif |
2830 | 2887 | ||
2831 | if (serial_paranoia_check(info, tty->name, "cy_write")){ | 2888 | if (serial_paranoia_check(info, tty->name, "cy_write")) { |
2832 | return 0; | 2889 | return 0; |
2833 | } | 2890 | } |
2834 | 2891 | ||
2835 | if (!info->xmit_buf || !tmp_buf) | 2892 | if (!info->xmit_buf) |
2836 | return 0; | 2893 | return 0; |
2837 | 2894 | ||
2838 | CY_LOCK(info, flags); | 2895 | CY_LOCK(info, flags); |
2839 | while (1) { | 2896 | while (1) { |
2840 | c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1), | 2897 | c = min(count, min((int)(SERIAL_XMIT_SIZE - info->xmit_cnt - 1), |
2841 | (int)(SERIAL_XMIT_SIZE - info->xmit_head))); | 2898 | (int)(SERIAL_XMIT_SIZE - info->xmit_head))); |
2842 | |||
2843 | if (c <= 0) | ||
2844 | break; | ||
2845 | |||
2846 | memcpy(info->xmit_buf + info->xmit_head, buf, c); | ||
2847 | info->xmit_head = (info->xmit_head + c) & (SERIAL_XMIT_SIZE-1); | ||
2848 | info->xmit_cnt += c; | ||
2849 | buf += c; | ||
2850 | count -= c; | ||
2851 | ret += c; | ||
2852 | } | ||
2853 | CY_UNLOCK(info, flags); | ||
2854 | |||
2855 | info->idle_stats.xmit_bytes += ret; | ||
2856 | info->idle_stats.xmit_idle = jiffies; | ||
2857 | |||
2858 | if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { | ||
2859 | start_xmit(info); | ||
2860 | } | ||
2861 | return ret; | ||
2862 | } /* cy_write */ | ||
2863 | 2899 | ||
2900 | if (c <= 0) | ||
2901 | break; | ||
2902 | |||
2903 | memcpy(info->xmit_buf + info->xmit_head, buf, c); | ||
2904 | info->xmit_head = (info->xmit_head + c) & | ||
2905 | (SERIAL_XMIT_SIZE - 1); | ||
2906 | info->xmit_cnt += c; | ||
2907 | buf += c; | ||
2908 | count -= c; | ||
2909 | ret += c; | ||
2910 | } | ||
2911 | CY_UNLOCK(info, flags); | ||
2912 | |||
2913 | info->idle_stats.xmit_bytes += ret; | ||
2914 | info->idle_stats.xmit_idle = jiffies; | ||
2915 | |||
2916 | if (info->xmit_cnt && !tty->stopped && !tty->hw_stopped) { | ||
2917 | start_xmit(info); | ||
2918 | } | ||
2919 | return ret; | ||
2920 | } /* cy_write */ | ||
2864 | 2921 | ||
2865 | /* | 2922 | /* |
2866 | * This routine is called by the kernel to write a single | 2923 | * This routine is called by the kernel to write a single |
@@ -2869,60 +2926,56 @@ cy_write(struct tty_struct * tty, const unsigned char *buf, int count) | |||
2869 | * done stuffing characters into the driver. If there is no room | 2926 | * done stuffing characters into the driver. If there is no room |
2870 | * in the queue, the character is ignored. | 2927 | * in the queue, the character is ignored. |
2871 | */ | 2928 | */ |
2872 | static void | 2929 | static void cy_put_char(struct tty_struct *tty, unsigned char ch) |
2873 | cy_put_char(struct tty_struct *tty, unsigned char ch) | ||
2874 | { | 2930 | { |
2875 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 2931 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
2876 | unsigned long flags; | 2932 | unsigned long flags; |
2877 | 2933 | ||
2878 | #ifdef CY_DEBUG_IO | 2934 | #ifdef CY_DEBUG_IO |
2879 | printk("cyc:cy_put_char ttyC%d\n", info->line); | 2935 | printk("cyc:cy_put_char ttyC%d\n", info->line); |
2880 | #endif | 2936 | #endif |
2881 | 2937 | ||
2882 | if (serial_paranoia_check(info, tty->name, "cy_put_char")) | 2938 | if (serial_paranoia_check(info, tty->name, "cy_put_char")) |
2883 | return; | 2939 | return; |
2884 | 2940 | ||
2885 | if (!info->xmit_buf) | 2941 | if (!info->xmit_buf) |
2886 | return; | 2942 | return; |
2887 | 2943 | ||
2888 | CY_LOCK(info, flags); | 2944 | CY_LOCK(info, flags); |
2889 | if (info->xmit_cnt >= SERIAL_XMIT_SIZE - 1) { | 2945 | if (info->xmit_cnt >= (int)(SERIAL_XMIT_SIZE - 1)) { |
2890 | CY_UNLOCK(info, flags); | 2946 | CY_UNLOCK(info, flags); |
2891 | return; | 2947 | return; |
2892 | } | 2948 | } |
2893 | 2949 | ||
2894 | info->xmit_buf[info->xmit_head++] = ch; | 2950 | info->xmit_buf[info->xmit_head++] = ch; |
2895 | info->xmit_head &= SERIAL_XMIT_SIZE - 1; | 2951 | info->xmit_head &= SERIAL_XMIT_SIZE - 1; |
2896 | info->xmit_cnt++; | 2952 | info->xmit_cnt++; |
2897 | info->idle_stats.xmit_bytes++; | 2953 | info->idle_stats.xmit_bytes++; |
2898 | info->idle_stats.xmit_idle = jiffies; | 2954 | info->idle_stats.xmit_idle = jiffies; |
2899 | CY_UNLOCK(info, flags); | 2955 | CY_UNLOCK(info, flags); |
2900 | } /* cy_put_char */ | 2956 | } /* cy_put_char */ |
2901 | |||
2902 | 2957 | ||
2903 | /* | 2958 | /* |
2904 | * This routine is called by the kernel after it has written a | 2959 | * This routine is called by the kernel after it has written a |
2905 | * series of characters to the tty device using put_char(). | 2960 | * series of characters to the tty device using put_char(). |
2906 | */ | 2961 | */ |
2907 | static void | 2962 | static void cy_flush_chars(struct tty_struct *tty) |
2908 | cy_flush_chars(struct tty_struct *tty) | ||
2909 | { | 2963 | { |
2910 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 2964 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
2911 | 2965 | ||
2912 | #ifdef CY_DEBUG_IO | 2966 | #ifdef CY_DEBUG_IO |
2913 | printk("cyc:cy_flush_chars ttyC%d\n", info->line); /* */ | 2967 | printk("cyc:cy_flush_chars ttyC%d\n", info->line); /* */ |
2914 | #endif | 2968 | #endif |
2915 | 2969 | ||
2916 | if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) | 2970 | if (serial_paranoia_check(info, tty->name, "cy_flush_chars")) |
2917 | return; | 2971 | return; |
2918 | |||
2919 | if (info->xmit_cnt <= 0 || tty->stopped | ||
2920 | || tty->hw_stopped || !info->xmit_buf) | ||
2921 | return; | ||
2922 | 2972 | ||
2923 | start_xmit(info); | 2973 | if (info->xmit_cnt <= 0 || tty->stopped || tty->hw_stopped || |
2924 | } /* cy_flush_chars */ | 2974 | !info->xmit_buf) |
2975 | return; | ||
2925 | 2976 | ||
2977 | start_xmit(info); | ||
2978 | } /* cy_flush_chars */ | ||
2926 | 2979 | ||
2927 | /* | 2980 | /* |
2928 | * This routine returns the numbers of characters the tty driver | 2981 | * This routine returns the numbers of characters the tty driver |
@@ -2930,75 +2983,70 @@ cy_flush_chars(struct tty_struct *tty) | |||
2930 | * to change as output buffers get emptied, or if the output flow | 2983 | * to change as output buffers get emptied, or if the output flow |
2931 | * control is activated. | 2984 | * control is activated. |
2932 | */ | 2985 | */ |
2933 | static int | 2986 | static int cy_write_room(struct tty_struct *tty) |
2934 | cy_write_room(struct tty_struct *tty) | ||
2935 | { | 2987 | { |
2936 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 2988 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
2937 | int ret; | 2989 | int ret; |
2938 | 2990 | ||
2939 | #ifdef CY_DEBUG_IO | 2991 | #ifdef CY_DEBUG_IO |
2940 | printk("cyc:cy_write_room ttyC%d\n", info->line); /* */ | 2992 | printk("cyc:cy_write_room ttyC%d\n", info->line); /* */ |
2941 | #endif | 2993 | #endif |
2942 | 2994 | ||
2943 | if (serial_paranoia_check(info, tty->name, "cy_write_room")) | 2995 | if (serial_paranoia_check(info, tty->name, "cy_write_room")) |
2944 | return 0; | 2996 | return 0; |
2945 | ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; | 2997 | ret = SERIAL_XMIT_SIZE - info->xmit_cnt - 1; |
2946 | if (ret < 0) | 2998 | if (ret < 0) |
2947 | ret = 0; | 2999 | ret = 0; |
2948 | return ret; | 3000 | return ret; |
2949 | } /* cy_write_room */ | 3001 | } /* cy_write_room */ |
2950 | 3002 | ||
2951 | 3003 | static int cy_chars_in_buffer(struct tty_struct *tty) | |
2952 | static int | ||
2953 | cy_chars_in_buffer(struct tty_struct *tty) | ||
2954 | { | 3004 | { |
2955 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 3005 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
2956 | int card, channel; | 3006 | int card, channel; |
2957 | 3007 | ||
2958 | if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer")) | 3008 | if (serial_paranoia_check(info, tty->name, "cy_chars_in_buffer")) |
2959 | return 0; | 3009 | return 0; |
2960 | 3010 | ||
2961 | card = info->card; | 3011 | card = info->card; |
2962 | channel = (info->line) - (cy_card[card].first_line); | 3012 | channel = (info->line) - (cy_card[card].first_line); |
2963 | 3013 | ||
2964 | #ifdef Z_EXT_CHARS_IN_BUFFER | 3014 | #ifdef Z_EXT_CHARS_IN_BUFFER |
2965 | if (!IS_CYC_Z(cy_card[card])) { | 3015 | if (!IS_CYC_Z(cy_card[card])) { |
2966 | #endif /* Z_EXT_CHARS_IN_BUFFER */ | 3016 | #endif /* Z_EXT_CHARS_IN_BUFFER */ |
2967 | #ifdef CY_DEBUG_IO | 3017 | #ifdef CY_DEBUG_IO |
2968 | printk("cyc:cy_chars_in_buffer ttyC%d %d\n", | 3018 | printk("cyc:cy_chars_in_buffer ttyC%d %d\n", info->line, info->xmit_cnt); /* */ |
2969 | info->line, info->xmit_cnt); /* */ | ||
2970 | #endif | 3019 | #endif |
2971 | return info->xmit_cnt; | 3020 | return info->xmit_cnt; |
2972 | #ifdef Z_EXT_CHARS_IN_BUFFER | 3021 | #ifdef Z_EXT_CHARS_IN_BUFFER |
2973 | } else { | 3022 | } else { |
2974 | static volatile struct FIRM_ID *firm_id; | 3023 | static volatile struct FIRM_ID *firm_id; |
2975 | static volatile struct ZFW_CTRL *zfw_ctrl; | 3024 | static volatile struct ZFW_CTRL *zfw_ctrl; |
2976 | static volatile struct CH_CTRL *ch_ctrl; | 3025 | static volatile struct CH_CTRL *ch_ctrl; |
2977 | static volatile struct BUF_CTRL *buf_ctrl; | 3026 | static volatile struct BUF_CTRL *buf_ctrl; |
2978 | int char_count; | 3027 | int char_count; |
2979 | volatile uclong tx_put, tx_get, tx_bufsize; | 3028 | volatile uclong tx_put, tx_get, tx_bufsize; |
2980 | 3029 | ||
2981 | firm_id = cy_card[card].base_addr + ID_ADDRESS; | 3030 | firm_id = cy_card[card].base_addr + ID_ADDRESS; |
2982 | zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 3031 | zfw_ctrl = cy_card[card].base_addr + |
2983 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); | 3032 | (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); |
2984 | buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); | 3033 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); |
2985 | 3034 | buf_ctrl = &(zfw_ctrl->buf_ctrl[channel]); | |
2986 | tx_get = cy_readl(&buf_ctrl->tx_get); | 3035 | |
2987 | tx_put = cy_readl(&buf_ctrl->tx_put); | 3036 | tx_get = cy_readl(&buf_ctrl->tx_get); |
2988 | tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize); | 3037 | tx_put = cy_readl(&buf_ctrl->tx_put); |
2989 | if (tx_put >= tx_get) | 3038 | tx_bufsize = cy_readl(&buf_ctrl->tx_bufsize); |
2990 | char_count = tx_put - tx_get; | 3039 | if (tx_put >= tx_get) |
2991 | else | 3040 | char_count = tx_put - tx_get; |
2992 | char_count = tx_put - tx_get + tx_bufsize; | 3041 | else |
3042 | char_count = tx_put - tx_get + tx_bufsize; | ||
2993 | #ifdef CY_DEBUG_IO | 3043 | #ifdef CY_DEBUG_IO |
2994 | printk("cyc:cy_chars_in_buffer ttyC%d %d\n", | 3044 | printk("cyc:cy_chars_in_buffer ttyC%d %d\n", info->line, info->xmit_cnt + char_count); /* */ |
2995 | info->line, info->xmit_cnt + char_count); /* */ | ||
2996 | #endif | 3045 | #endif |
2997 | return (info->xmit_cnt + char_count); | 3046 | return info->xmit_cnt + char_count; |
2998 | } | 3047 | } |
2999 | #endif /* Z_EXT_CHARS_IN_BUFFER */ | 3048 | #endif /* Z_EXT_CHARS_IN_BUFFER */ |
3000 | } /* cy_chars_in_buffer */ | 3049 | } /* cy_chars_in_buffer */ |
3001 | |||
3002 | 3050 | ||
3003 | /* | 3051 | /* |
3004 | * ------------------------------------------------------------ | 3052 | * ------------------------------------------------------------ |
@@ -3006,178 +3054,179 @@ cy_chars_in_buffer(struct tty_struct *tty) | |||
3006 | * ------------------------------------------------------------ | 3054 | * ------------------------------------------------------------ |
3007 | */ | 3055 | */ |
3008 | 3056 | ||
3009 | static void | 3057 | static void cyy_baud_calc(struct cyclades_port *info, uclong baud) |
3010 | cyy_baud_calc(struct cyclades_port *info, uclong baud) | ||
3011 | { | 3058 | { |
3012 | int co, co_val, bpr; | 3059 | int co, co_val, bpr; |
3013 | uclong cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 : 25000000); | 3060 | uclong cy_clock = ((info->chip_rev >= CD1400_REV_J) ? 60000000 : |
3014 | 3061 | 25000000); | |
3015 | if (baud == 0) { | 3062 | |
3016 | info->tbpr = info->tco = info->rbpr = info->rco = 0; | 3063 | if (baud == 0) { |
3017 | return; | 3064 | info->tbpr = info->tco = info->rbpr = info->rco = 0; |
3018 | } | 3065 | return; |
3019 | 3066 | } | |
3020 | /* determine which prescaler to use */ | 3067 | |
3021 | for (co = 4, co_val = 2048; co; co--, co_val >>= 2) { | 3068 | /* determine which prescaler to use */ |
3022 | if (cy_clock / co_val / baud > 63) | 3069 | for (co = 4, co_val = 2048; co; co--, co_val >>= 2) { |
3023 | break; | 3070 | if (cy_clock / co_val / baud > 63) |
3024 | } | 3071 | break; |
3025 | 3072 | } | |
3026 | bpr = (cy_clock / co_val * 2 / baud + 1) / 2; | 3073 | |
3027 | if (bpr > 255) | 3074 | bpr = (cy_clock / co_val * 2 / baud + 1) / 2; |
3028 | bpr = 255; | 3075 | if (bpr > 255) |
3029 | 3076 | bpr = 255; | |
3030 | info->tbpr = info->rbpr = bpr; | 3077 | |
3031 | info->tco = info->rco = co; | 3078 | info->tbpr = info->rbpr = bpr; |
3079 | info->tco = info->rco = co; | ||
3032 | } | 3080 | } |
3033 | 3081 | ||
3034 | /* | 3082 | /* |
3035 | * This routine finds or computes the various line characteristics. | 3083 | * This routine finds or computes the various line characteristics. |
3036 | * It used to be called config_setup | 3084 | * It used to be called config_setup |
3037 | */ | 3085 | */ |
3038 | static void | 3086 | static void set_line_char(struct cyclades_port *info) |
3039 | set_line_char(struct cyclades_port * info) | ||
3040 | { | 3087 | { |
3041 | unsigned long flags; | 3088 | unsigned long flags; |
3042 | void __iomem *base_addr; | 3089 | void __iomem *base_addr; |
3043 | int card,chip,channel,index; | 3090 | int card, chip, channel, index; |
3044 | unsigned cflag, iflag; | 3091 | unsigned cflag, iflag; |
3045 | unsigned short chip_number; | 3092 | unsigned short chip_number; |
3046 | int baud, baud_rate = 0; | 3093 | int baud, baud_rate = 0; |
3047 | int i; | 3094 | int i; |
3048 | 3095 | ||
3049 | 3096 | if (!info->tty || !info->tty->termios) { | |
3050 | if (!info->tty || !info->tty->termios){ | 3097 | return; |
3051 | return; | ||
3052 | } | ||
3053 | if (info->line == -1){ | ||
3054 | return; | ||
3055 | } | ||
3056 | cflag = info->tty->termios->c_cflag; | ||
3057 | iflag = info->tty->termios->c_iflag; | ||
3058 | |||
3059 | /* | ||
3060 | * Set up the tty->alt_speed kludge | ||
3061 | */ | ||
3062 | if (info->tty) { | ||
3063 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) | ||
3064 | info->tty->alt_speed = 57600; | ||
3065 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) | ||
3066 | info->tty->alt_speed = 115200; | ||
3067 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) | ||
3068 | info->tty->alt_speed = 230400; | ||
3069 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) | ||
3070 | info->tty->alt_speed = 460800; | ||
3071 | } | ||
3072 | |||
3073 | card = info->card; | ||
3074 | channel = (info->line) - (cy_card[card].first_line); | ||
3075 | chip_number = channel / 4; | ||
3076 | |||
3077 | if (!IS_CYC_Z(cy_card[card])) { | ||
3078 | |||
3079 | index = cy_card[card].bus_index; | ||
3080 | |||
3081 | /* baud rate */ | ||
3082 | baud = tty_get_baud_rate(info->tty); | ||
3083 | if ((baud == 38400) && | ||
3084 | ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { | ||
3085 | if (info->custom_divisor) | ||
3086 | baud_rate = info->baud / info->custom_divisor; | ||
3087 | else | ||
3088 | baud_rate = info->baud; | ||
3089 | } else if (baud > CD1400_MAX_SPEED) { | ||
3090 | baud = CD1400_MAX_SPEED; | ||
3091 | } | 3098 | } |
3092 | /* find the baud index */ | 3099 | if (info->line == -1) { |
3093 | for (i = 0; i < 20; i++) { | 3100 | return; |
3094 | if (baud == baud_table[i]) { | ||
3095 | break; | ||
3096 | } | ||
3097 | } | 3101 | } |
3098 | if (i == 20) { | 3102 | cflag = info->tty->termios->c_cflag; |
3099 | i = 19; /* CD1400_MAX_SPEED */ | 3103 | iflag = info->tty->termios->c_iflag; |
3100 | } | ||
3101 | 3104 | ||
3102 | if ((baud == 38400) && | 3105 | /* |
3103 | ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { | 3106 | * Set up the tty->alt_speed kludge |
3104 | cyy_baud_calc(info, baud_rate); | 3107 | */ |
3105 | } else { | 3108 | if (info->tty) { |
3106 | if(info->chip_rev >= CD1400_REV_J) { | 3109 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_HI) |
3107 | /* It is a CD1400 rev. J or later */ | 3110 | info->tty->alt_speed = 57600; |
3108 | info->tbpr = baud_bpr_60[i]; /* Tx BPR */ | 3111 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_VHI) |
3109 | info->tco = baud_co_60[i]; /* Tx CO */ | 3112 | info->tty->alt_speed = 115200; |
3110 | info->rbpr = baud_bpr_60[i]; /* Rx BPR */ | 3113 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_SHI) |
3111 | info->rco = baud_co_60[i]; /* Rx CO */ | 3114 | info->tty->alt_speed = 230400; |
3112 | } else { | 3115 | if ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_WARP) |
3113 | info->tbpr = baud_bpr_25[i]; /* Tx BPR */ | 3116 | info->tty->alt_speed = 460800; |
3114 | info->tco = baud_co_25[i]; /* Tx CO */ | ||
3115 | info->rbpr = baud_bpr_25[i]; /* Rx BPR */ | ||
3116 | info->rco = baud_co_25[i]; /* Rx CO */ | ||
3117 | } | ||
3118 | } | ||
3119 | if (baud_table[i] == 134) { | ||
3120 | /* get it right for 134.5 baud */ | ||
3121 | info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2; | ||
3122 | } else if ((baud == 38400) && | ||
3123 | ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { | ||
3124 | info->timeout = (info->xmit_fifo_size*HZ*15/baud_rate) + 2; | ||
3125 | } else if (baud_table[i]) { | ||
3126 | info->timeout = (info->xmit_fifo_size*HZ*15/baud_table[i]) + 2; | ||
3127 | /* this needs to be propagated into the card info */ | ||
3128 | } else { | ||
3129 | info->timeout = 0; | ||
3130 | } | ||
3131 | /* By tradition (is it a standard?) a baud rate of zero | ||
3132 | implies the line should be/has been closed. A bit | ||
3133 | later in this routine such a test is performed. */ | ||
3134 | |||
3135 | /* byte size and parity */ | ||
3136 | info->cor5 = 0; | ||
3137 | info->cor4 = 0; | ||
3138 | info->cor3 = (info->default_threshold | ||
3139 | ? info->default_threshold | ||
3140 | : baud_cor3[i]); /* receive threshold */ | ||
3141 | info->cor2 = CyETC; | ||
3142 | switch(cflag & CSIZE){ | ||
3143 | case CS5: | ||
3144 | info->cor1 = Cy_5_BITS; | ||
3145 | break; | ||
3146 | case CS6: | ||
3147 | info->cor1 = Cy_6_BITS; | ||
3148 | break; | ||
3149 | case CS7: | ||
3150 | info->cor1 = Cy_7_BITS; | ||
3151 | break; | ||
3152 | case CS8: | ||
3153 | info->cor1 = Cy_8_BITS; | ||
3154 | break; | ||
3155 | } | ||
3156 | if(cflag & CSTOPB){ | ||
3157 | info->cor1 |= Cy_2_STOP; | ||
3158 | } | ||
3159 | if (cflag & PARENB){ | ||
3160 | if (cflag & PARODD){ | ||
3161 | info->cor1 |= CyPARITY_O; | ||
3162 | }else{ | ||
3163 | info->cor1 |= CyPARITY_E; | ||
3164 | } | ||
3165 | }else{ | ||
3166 | info->cor1 |= CyPARITY_NONE; | ||
3167 | } | ||
3168 | |||
3169 | /* CTS flow control flag */ | ||
3170 | if (cflag & CRTSCTS){ | ||
3171 | info->flags |= ASYNC_CTS_FLOW; | ||
3172 | info->cor2 |= CyCtsAE; | ||
3173 | }else{ | ||
3174 | info->flags &= ~ASYNC_CTS_FLOW; | ||
3175 | info->cor2 &= ~CyCtsAE; | ||
3176 | } | 3117 | } |
3177 | if (cflag & CLOCAL) | 3118 | |
3178 | info->flags &= ~ASYNC_CHECK_CD; | 3119 | card = info->card; |
3179 | else | 3120 | channel = (info->line) - (cy_card[card].first_line); |
3180 | info->flags |= ASYNC_CHECK_CD; | 3121 | chip_number = channel / 4; |
3122 | |||
3123 | if (!IS_CYC_Z(cy_card[card])) { | ||
3124 | |||
3125 | index = cy_card[card].bus_index; | ||
3126 | |||
3127 | /* baud rate */ | ||
3128 | baud = tty_get_baud_rate(info->tty); | ||
3129 | if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) == | ||
3130 | ASYNC_SPD_CUST) { | ||
3131 | if (info->custom_divisor) | ||
3132 | baud_rate = info->baud / info->custom_divisor; | ||
3133 | else | ||
3134 | baud_rate = info->baud; | ||
3135 | } else if (baud > CD1400_MAX_SPEED) { | ||
3136 | baud = CD1400_MAX_SPEED; | ||
3137 | } | ||
3138 | /* find the baud index */ | ||
3139 | for (i = 0; i < 20; i++) { | ||
3140 | if (baud == baud_table[i]) { | ||
3141 | break; | ||
3142 | } | ||
3143 | } | ||
3144 | if (i == 20) { | ||
3145 | i = 19; /* CD1400_MAX_SPEED */ | ||
3146 | } | ||
3147 | |||
3148 | if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) == | ||
3149 | ASYNC_SPD_CUST) { | ||
3150 | cyy_baud_calc(info, baud_rate); | ||
3151 | } else { | ||
3152 | if (info->chip_rev >= CD1400_REV_J) { | ||
3153 | /* It is a CD1400 rev. J or later */ | ||
3154 | info->tbpr = baud_bpr_60[i]; /* Tx BPR */ | ||
3155 | info->tco = baud_co_60[i]; /* Tx CO */ | ||
3156 | info->rbpr = baud_bpr_60[i]; /* Rx BPR */ | ||
3157 | info->rco = baud_co_60[i]; /* Rx CO */ | ||
3158 | } else { | ||
3159 | info->tbpr = baud_bpr_25[i]; /* Tx BPR */ | ||
3160 | info->tco = baud_co_25[i]; /* Tx CO */ | ||
3161 | info->rbpr = baud_bpr_25[i]; /* Rx BPR */ | ||
3162 | info->rco = baud_co_25[i]; /* Rx CO */ | ||
3163 | } | ||
3164 | } | ||
3165 | if (baud_table[i] == 134) { | ||
3166 | /* get it right for 134.5 baud */ | ||
3167 | info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) + | ||
3168 | 2; | ||
3169 | } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) == | ||
3170 | ASYNC_SPD_CUST) { | ||
3171 | info->timeout = (info->xmit_fifo_size * HZ * 15 / | ||
3172 | baud_rate) + 2; | ||
3173 | } else if (baud_table[i]) { | ||
3174 | info->timeout = (info->xmit_fifo_size * HZ * 15 / | ||
3175 | baud_table[i]) + 2; | ||
3176 | /* this needs to be propagated into the card info */ | ||
3177 | } else { | ||
3178 | info->timeout = 0; | ||
3179 | } | ||
3180 | /* By tradition (is it a standard?) a baud rate of zero | ||
3181 | implies the line should be/has been closed. A bit | ||
3182 | later in this routine such a test is performed. */ | ||
3183 | |||
3184 | /* byte size and parity */ | ||
3185 | info->cor5 = 0; | ||
3186 | info->cor4 = 0; | ||
3187 | /* receive threshold */ | ||
3188 | info->cor3 = (info->default_threshold ? | ||
3189 | info->default_threshold : baud_cor3[i]); | ||
3190 | info->cor2 = CyETC; | ||
3191 | switch (cflag & CSIZE) { | ||
3192 | case CS5: | ||
3193 | info->cor1 = Cy_5_BITS; | ||
3194 | break; | ||
3195 | case CS6: | ||
3196 | info->cor1 = Cy_6_BITS; | ||
3197 | break; | ||
3198 | case CS7: | ||
3199 | info->cor1 = Cy_7_BITS; | ||
3200 | break; | ||
3201 | case CS8: | ||
3202 | info->cor1 = Cy_8_BITS; | ||
3203 | break; | ||
3204 | } | ||
3205 | if (cflag & CSTOPB) { | ||
3206 | info->cor1 |= Cy_2_STOP; | ||
3207 | } | ||
3208 | if (cflag & PARENB) { | ||
3209 | if (cflag & PARODD) { | ||
3210 | info->cor1 |= CyPARITY_O; | ||
3211 | } else { | ||
3212 | info->cor1 |= CyPARITY_E; | ||
3213 | } | ||
3214 | } else { | ||
3215 | info->cor1 |= CyPARITY_NONE; | ||
3216 | } | ||
3217 | |||
3218 | /* CTS flow control flag */ | ||
3219 | if (cflag & CRTSCTS) { | ||
3220 | info->flags |= ASYNC_CTS_FLOW; | ||
3221 | info->cor2 |= CyCtsAE; | ||
3222 | } else { | ||
3223 | info->flags &= ~ASYNC_CTS_FLOW; | ||
3224 | info->cor2 &= ~CyCtsAE; | ||
3225 | } | ||
3226 | if (cflag & CLOCAL) | ||
3227 | info->flags &= ~ASYNC_CHECK_CD; | ||
3228 | else | ||
3229 | info->flags |= ASYNC_CHECK_CD; | ||
3181 | 3230 | ||
3182 | /*********************************************** | 3231 | /*********************************************** |
3183 | The hardware option, CyRtsAO, presents RTS when | 3232 | The hardware option, CyRtsAO, presents RTS when |
@@ -3189,300 +3238,319 @@ set_line_char(struct cyclades_port * info) | |||
3189 | cable. Contact Marcio Saito for details. | 3238 | cable. Contact Marcio Saito for details. |
3190 | ***********************************************/ | 3239 | ***********************************************/ |
3191 | 3240 | ||
3192 | chip = channel>>2; | 3241 | chip = channel >> 2; |
3193 | channel &= 0x03; | 3242 | channel &= 0x03; |
3194 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | 3243 | base_addr = cy_card[card].base_addr + |
3244 | (cy_chip_offset[chip] << index); | ||
3195 | 3245 | ||
3196 | CY_LOCK(info, flags); | 3246 | CY_LOCK(info, flags); |
3197 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 3247 | cy_writeb(base_addr + (CyCAR << index), (u_char) channel); |
3198 | 3248 | ||
3199 | /* tx and rx baud rate */ | 3249 | /* tx and rx baud rate */ |
3200 | 3250 | ||
3201 | cy_writeb(base_addr+(CyTCOR<<index), info->tco); | 3251 | cy_writeb(base_addr + (CyTCOR << index), info->tco); |
3202 | cy_writeb(base_addr+(CyTBPR<<index), info->tbpr); | 3252 | cy_writeb(base_addr + (CyTBPR << index), info->tbpr); |
3203 | cy_writeb(base_addr+(CyRCOR<<index), info->rco); | 3253 | cy_writeb(base_addr + (CyRCOR << index), info->rco); |
3204 | cy_writeb(base_addr+(CyRBPR<<index), info->rbpr); | 3254 | cy_writeb(base_addr + (CyRBPR << index), info->rbpr); |
3205 | 3255 | ||
3206 | /* set line characteristics according configuration */ | 3256 | /* set line characteristics according configuration */ |
3207 | 3257 | ||
3208 | cy_writeb(base_addr+(CySCHR1<<index), | 3258 | cy_writeb(base_addr + (CySCHR1 << index), |
3209 | START_CHAR(info->tty)); | 3259 | START_CHAR(info->tty)); |
3210 | cy_writeb(base_addr+(CySCHR2<<index), | 3260 | cy_writeb(base_addr + (CySCHR2 << index), STOP_CHAR(info->tty)); |
3211 | STOP_CHAR(info->tty)); | 3261 | cy_writeb(base_addr + (CyCOR1 << index), info->cor1); |
3212 | cy_writeb(base_addr+(CyCOR1<<index), info->cor1); | 3262 | cy_writeb(base_addr + (CyCOR2 << index), info->cor2); |
3213 | cy_writeb(base_addr+(CyCOR2<<index), info->cor2); | 3263 | cy_writeb(base_addr + (CyCOR3 << index), info->cor3); |
3214 | cy_writeb(base_addr+(CyCOR3<<index), info->cor3); | 3264 | cy_writeb(base_addr + (CyCOR4 << index), info->cor4); |
3215 | cy_writeb(base_addr+(CyCOR4<<index), info->cor4); | 3265 | cy_writeb(base_addr + (CyCOR5 << index), info->cor5); |
3216 | cy_writeb(base_addr+(CyCOR5<<index), info->cor5); | 3266 | |
3217 | 3267 | cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR1ch | CyCOR2ch | | |
3218 | cyy_issue_cmd(base_addr, | 3268 | CyCOR3ch, index); |
3219 | CyCOR_CHANGE|CyCOR1ch|CyCOR2ch|CyCOR3ch,index); | 3269 | |
3220 | 3270 | cy_writeb(base_addr + (CyCAR << index), (u_char) channel); /* !!! Is this needed? */ | |
3221 | cy_writeb(base_addr+(CyCAR<<index), | 3271 | cy_writeb(base_addr + (CyRTPR << index), |
3222 | (u_char)channel); /* !!! Is this needed? */ | 3272 | (info->default_timeout ? info->default_timeout : 0x02)); |
3223 | cy_writeb(base_addr+(CyRTPR<<index), (info->default_timeout | 3273 | /* 10ms rx timeout */ |
3224 | ? info->default_timeout | 3274 | |
3225 | : 0x02)); /* 10ms rx timeout */ | 3275 | if (C_CLOCAL(info->tty)) { |
3226 | 3276 | /* without modem intr */ | |
3227 | if (C_CLOCAL(info->tty)) { | 3277 | cy_writeb(base_addr + (CySRER << index), |
3228 | /* without modem intr */ | 3278 | cy_readb(base_addr + |
3229 | cy_writeb(base_addr+(CySRER<<index), | 3279 | (CySRER << index)) | CyMdmCh); |
3230 | cy_readb(base_addr+(CySRER<<index)) | CyMdmCh); | 3280 | /* act on 1->0 modem transitions */ |
3231 | /* act on 1->0 modem transitions */ | 3281 | if ((cflag & CRTSCTS) && info->rflow) { |
3232 | if ((cflag & CRTSCTS) && info->rflow) { | 3282 | cy_writeb(base_addr + (CyMCOR1 << index), |
3233 | cy_writeb(base_addr+(CyMCOR1<<index), | 3283 | (CyCTS | rflow_thr[i])); |
3234 | (CyCTS|rflow_thr[i])); | 3284 | } else { |
3235 | } else { | 3285 | cy_writeb(base_addr + (CyMCOR1 << index), |
3236 | cy_writeb(base_addr+(CyMCOR1<<index), CyCTS); | 3286 | CyCTS); |
3237 | } | 3287 | } |
3238 | /* act on 0->1 modem transitions */ | 3288 | /* act on 0->1 modem transitions */ |
3239 | cy_writeb(base_addr+(CyMCOR2<<index), CyCTS); | 3289 | cy_writeb(base_addr + (CyMCOR2 << index), CyCTS); |
3240 | } else { | ||
3241 | /* without modem intr */ | ||
3242 | cy_writeb(base_addr+(CySRER<<index), | ||
3243 | cy_readb(base_addr+(CySRER<<index)) | CyMdmCh); | ||
3244 | /* act on 1->0 modem transitions */ | ||
3245 | if ((cflag & CRTSCTS) && info->rflow) { | ||
3246 | cy_writeb(base_addr+(CyMCOR1<<index), | ||
3247 | (CyDSR|CyCTS|CyRI|CyDCD|rflow_thr[i])); | ||
3248 | } else { | ||
3249 | cy_writeb(base_addr+(CyMCOR1<<index), | ||
3250 | CyDSR|CyCTS|CyRI|CyDCD); | ||
3251 | } | ||
3252 | /* act on 0->1 modem transitions */ | ||
3253 | cy_writeb(base_addr+(CyMCOR2<<index), | ||
3254 | CyDSR|CyCTS|CyRI|CyDCD); | ||
3255 | } | ||
3256 | |||
3257 | if(i == 0){ /* baud rate is zero, turn off line */ | ||
3258 | if (info->rtsdtr_inv) { | ||
3259 | cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); | ||
3260 | } else { | 3290 | } else { |
3261 | cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); | 3291 | /* without modem intr */ |
3292 | cy_writeb(base_addr + (CySRER << index), | ||
3293 | cy_readb(base_addr + | ||
3294 | (CySRER << index)) | CyMdmCh); | ||
3295 | /* act on 1->0 modem transitions */ | ||
3296 | if ((cflag & CRTSCTS) && info->rflow) { | ||
3297 | cy_writeb(base_addr + (CyMCOR1 << index), | ||
3298 | (CyDSR | CyCTS | CyRI | CyDCD | | ||
3299 | rflow_thr[i])); | ||
3300 | } else { | ||
3301 | cy_writeb(base_addr + (CyMCOR1 << index), | ||
3302 | CyDSR | CyCTS | CyRI | CyDCD); | ||
3303 | } | ||
3304 | /* act on 0->1 modem transitions */ | ||
3305 | cy_writeb(base_addr + (CyMCOR2 << index), | ||
3306 | CyDSR | CyCTS | CyRI | CyDCD); | ||
3262 | } | 3307 | } |
3308 | |||
3309 | if (i == 0) { /* baud rate is zero, turn off line */ | ||
3310 | if (info->rtsdtr_inv) { | ||
3311 | cy_writeb(base_addr + (CyMSVR1 << index), | ||
3312 | ~CyRTS); | ||
3313 | } else { | ||
3314 | cy_writeb(base_addr + (CyMSVR2 << index), | ||
3315 | ~CyDTR); | ||
3316 | } | ||
3263 | #ifdef CY_DEBUG_DTR | 3317 | #ifdef CY_DEBUG_DTR |
3264 | printk("cyc:set_line_char dropping DTR\n"); | 3318 | printk("cyc:set_line_char dropping DTR\n"); |
3265 | printk(" status: 0x%x, 0x%x\n", | 3319 | printk(" status: 0x%x, 0x%x\n", |
3266 | cy_readb(base_addr+(CyMSVR1<<index)), | 3320 | cy_readb(base_addr + (CyMSVR1 << index)), |
3267 | cy_readb(base_addr+(CyMSVR2<<index))); | 3321 | cy_readb(base_addr + (CyMSVR2 << index))); |
3268 | #endif | 3322 | #endif |
3269 | }else{ | 3323 | } else { |
3270 | if (info->rtsdtr_inv) { | 3324 | if (info->rtsdtr_inv) { |
3271 | cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); | 3325 | cy_writeb(base_addr + (CyMSVR1 << index), |
3272 | } else { | 3326 | CyRTS); |
3273 | cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); | 3327 | } else { |
3274 | } | 3328 | cy_writeb(base_addr + (CyMSVR2 << index), |
3329 | CyDTR); | ||
3330 | } | ||
3275 | #ifdef CY_DEBUG_DTR | 3331 | #ifdef CY_DEBUG_DTR |
3276 | printk("cyc:set_line_char raising DTR\n"); | 3332 | printk("cyc:set_line_char raising DTR\n"); |
3277 | printk(" status: 0x%x, 0x%x\n", | 3333 | printk(" status: 0x%x, 0x%x\n", |
3278 | cy_readb(base_addr+(CyMSVR1<<index)), | 3334 | cy_readb(base_addr + (CyMSVR1 << index)), |
3279 | cy_readb(base_addr+(CyMSVR2<<index))); | 3335 | cy_readb(base_addr + (CyMSVR2 << index))); |
3280 | #endif | 3336 | #endif |
3281 | } | 3337 | } |
3282 | |||
3283 | if (info->tty){ | ||
3284 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | ||
3285 | } | ||
3286 | CY_UNLOCK(info, flags); | ||
3287 | 3338 | ||
3288 | } else { | 3339 | if (info->tty) { |
3289 | struct FIRM_ID __iomem *firm_id; | 3340 | clear_bit(TTY_IO_ERROR, &info->tty->flags); |
3290 | struct ZFW_CTRL __iomem *zfw_ctrl; | 3341 | } |
3291 | struct BOARD_CTRL __iomem *board_ctrl; | 3342 | CY_UNLOCK(info, flags); |
3292 | struct CH_CTRL __iomem *ch_ctrl; | ||
3293 | struct BUF_CTRL __iomem *buf_ctrl; | ||
3294 | uclong sw_flow; | ||
3295 | int retval; | ||
3296 | |||
3297 | firm_id = cy_card[card].base_addr + ID_ADDRESS; | ||
3298 | if (!ISZLOADED(cy_card[card])) { | ||
3299 | return; | ||
3300 | } | ||
3301 | 3343 | ||
3302 | zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | ||
3303 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
3304 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); | ||
3305 | buf_ctrl = &zfw_ctrl->buf_ctrl[channel]; | ||
3306 | |||
3307 | /* baud rate */ | ||
3308 | baud = tty_get_baud_rate(info->tty); | ||
3309 | if ((baud == 38400) && | ||
3310 | ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { | ||
3311 | if (info->custom_divisor) | ||
3312 | baud_rate = info->baud / info->custom_divisor; | ||
3313 | else | ||
3314 | baud_rate = info->baud; | ||
3315 | } else if (baud > CYZ_MAX_SPEED) { | ||
3316 | baud = CYZ_MAX_SPEED; | ||
3317 | } | ||
3318 | cy_writel(&ch_ctrl->comm_baud , baud); | ||
3319 | |||
3320 | if (baud == 134) { | ||
3321 | /* get it right for 134.5 baud */ | ||
3322 | info->timeout = (info->xmit_fifo_size*HZ*30/269) + 2; | ||
3323 | } else if ((baud == 38400) && | ||
3324 | ((info->flags & ASYNC_SPD_MASK) == ASYNC_SPD_CUST)) { | ||
3325 | info->timeout = (info->xmit_fifo_size*HZ*15/baud_rate) + 2; | ||
3326 | } else if (baud) { | ||
3327 | info->timeout = (info->xmit_fifo_size*HZ*15/baud) + 2; | ||
3328 | /* this needs to be propagated into the card info */ | ||
3329 | } else { | 3344 | } else { |
3330 | info->timeout = 0; | 3345 | struct FIRM_ID __iomem *firm_id; |
3331 | } | 3346 | struct ZFW_CTRL __iomem *zfw_ctrl; |
3347 | struct BOARD_CTRL __iomem *board_ctrl; | ||
3348 | struct CH_CTRL __iomem *ch_ctrl; | ||
3349 | struct BUF_CTRL __iomem *buf_ctrl; | ||
3350 | uclong sw_flow; | ||
3351 | int retval; | ||
3352 | |||
3353 | firm_id = cy_card[card].base_addr + ID_ADDRESS; | ||
3354 | if (!ISZLOADED(cy_card[card])) { | ||
3355 | return; | ||
3356 | } | ||
3332 | 3357 | ||
3333 | /* byte size and parity */ | 3358 | zfw_ctrl = cy_card[card].base_addr + |
3334 | switch(cflag & CSIZE){ | 3359 | (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); |
3335 | case CS5: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS5); break; | 3360 | board_ctrl = &zfw_ctrl->board_ctrl; |
3336 | case CS6: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS6); break; | 3361 | ch_ctrl = &(zfw_ctrl->ch_ctrl[channel]); |
3337 | case CS7: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS7); break; | 3362 | buf_ctrl = &zfw_ctrl->buf_ctrl[channel]; |
3338 | case CS8: cy_writel(&ch_ctrl->comm_data_l , C_DL_CS8); break; | 3363 | |
3339 | } | 3364 | /* baud rate */ |
3340 | if(cflag & CSTOPB){ | 3365 | baud = tty_get_baud_rate(info->tty); |
3341 | cy_writel(&ch_ctrl->comm_data_l, | 3366 | if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) == |
3342 | cy_readl(&ch_ctrl->comm_data_l) | C_DL_2STOP); | 3367 | ASYNC_SPD_CUST) { |
3343 | }else{ | 3368 | if (info->custom_divisor) |
3344 | cy_writel(&ch_ctrl->comm_data_l, | 3369 | baud_rate = info->baud / info->custom_divisor; |
3345 | cy_readl(&ch_ctrl->comm_data_l) | C_DL_1STOP); | 3370 | else |
3346 | } | 3371 | baud_rate = info->baud; |
3347 | if (cflag & PARENB){ | 3372 | } else if (baud > CYZ_MAX_SPEED) { |
3348 | if (cflag & PARODD){ | 3373 | baud = CYZ_MAX_SPEED; |
3349 | cy_writel(&ch_ctrl->comm_parity , C_PR_ODD); | 3374 | } |
3350 | }else{ | 3375 | cy_writel(&ch_ctrl->comm_baud, baud); |
3351 | cy_writel(&ch_ctrl->comm_parity , C_PR_EVEN); | 3376 | |
3352 | } | 3377 | if (baud == 134) { |
3353 | }else{ | 3378 | /* get it right for 134.5 baud */ |
3354 | cy_writel(&ch_ctrl->comm_parity , C_PR_NONE); | 3379 | info->timeout = (info->xmit_fifo_size * HZ * 30 / 269) + |
3355 | } | 3380 | 2; |
3381 | } else if (baud == 38400 && (info->flags & ASYNC_SPD_MASK) == | ||
3382 | ASYNC_SPD_CUST) { | ||
3383 | info->timeout = (info->xmit_fifo_size * HZ * 15 / | ||
3384 | baud_rate) + 2; | ||
3385 | } else if (baud) { | ||
3386 | info->timeout = (info->xmit_fifo_size * HZ * 15 / | ||
3387 | baud) + 2; | ||
3388 | /* this needs to be propagated into the card info */ | ||
3389 | } else { | ||
3390 | info->timeout = 0; | ||
3391 | } | ||
3356 | 3392 | ||
3357 | /* CTS flow control flag */ | 3393 | /* byte size and parity */ |
3358 | if (cflag & CRTSCTS){ | 3394 | switch (cflag & CSIZE) { |
3359 | cy_writel(&ch_ctrl->hw_flow, | 3395 | case CS5: |
3360 | cy_readl(&ch_ctrl->hw_flow) | C_RS_CTS | C_RS_RTS); | 3396 | cy_writel(&ch_ctrl->comm_data_l, C_DL_CS5); |
3361 | }else{ | 3397 | break; |
3362 | cy_writel(&ch_ctrl->hw_flow, | 3398 | case CS6: |
3363 | cy_readl(&ch_ctrl->hw_flow) & ~(C_RS_CTS | C_RS_RTS)); | 3399 | cy_writel(&ch_ctrl->comm_data_l, C_DL_CS6); |
3364 | } | 3400 | break; |
3365 | /* As the HW flow control is done in firmware, the driver doesn't | 3401 | case CS7: |
3366 | need to care about it */ | 3402 | cy_writel(&ch_ctrl->comm_data_l, C_DL_CS7); |
3367 | info->flags &= ~ASYNC_CTS_FLOW; | 3403 | break; |
3368 | 3404 | case CS8: | |
3369 | /* XON/XOFF/XANY flow control flags */ | 3405 | cy_writel(&ch_ctrl->comm_data_l, C_DL_CS8); |
3370 | sw_flow = 0; | 3406 | break; |
3371 | if (iflag & IXON){ | 3407 | } |
3372 | sw_flow |= C_FL_OXX; | 3408 | if (cflag & CSTOPB) { |
3373 | if (iflag & IXANY) | 3409 | cy_writel(&ch_ctrl->comm_data_l, |
3374 | sw_flow |= C_FL_OIXANY; | 3410 | cy_readl(&ch_ctrl->comm_data_l) | C_DL_2STOP); |
3375 | } | 3411 | } else { |
3376 | cy_writel(&ch_ctrl->sw_flow, sw_flow); | 3412 | cy_writel(&ch_ctrl->comm_data_l, |
3413 | cy_readl(&ch_ctrl->comm_data_l) | C_DL_1STOP); | ||
3414 | } | ||
3415 | if (cflag & PARENB) { | ||
3416 | if (cflag & PARODD) { | ||
3417 | cy_writel(&ch_ctrl->comm_parity, C_PR_ODD); | ||
3418 | } else { | ||
3419 | cy_writel(&ch_ctrl->comm_parity, C_PR_EVEN); | ||
3420 | } | ||
3421 | } else { | ||
3422 | cy_writel(&ch_ctrl->comm_parity, C_PR_NONE); | ||
3423 | } | ||
3377 | 3424 | ||
3378 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L); | 3425 | /* CTS flow control flag */ |
3379 | if (retval != 0){ | 3426 | if (cflag & CRTSCTS) { |
3380 | printk("cyc:set_line_char retval on ttyC%d was %x\n", | 3427 | cy_writel(&ch_ctrl->hw_flow, |
3381 | info->line, retval); | 3428 | cy_readl(&ch_ctrl-> |
3382 | } | 3429 | hw_flow) | C_RS_CTS | C_RS_RTS); |
3430 | } else { | ||
3431 | cy_writel(&ch_ctrl->hw_flow, | ||
3432 | cy_readl(&ch_ctrl-> | ||
3433 | hw_flow) & ~(C_RS_CTS | C_RS_RTS)); | ||
3434 | } | ||
3435 | /* As the HW flow control is done in firmware, the driver | ||
3436 | doesn't need to care about it */ | ||
3437 | info->flags &= ~ASYNC_CTS_FLOW; | ||
3438 | |||
3439 | /* XON/XOFF/XANY flow control flags */ | ||
3440 | sw_flow = 0; | ||
3441 | if (iflag & IXON) { | ||
3442 | sw_flow |= C_FL_OXX; | ||
3443 | if (iflag & IXANY) | ||
3444 | sw_flow |= C_FL_OIXANY; | ||
3445 | } | ||
3446 | cy_writel(&ch_ctrl->sw_flow, sw_flow); | ||
3383 | 3447 | ||
3384 | /* CD sensitivity */ | 3448 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTL, 0L); |
3385 | if (cflag & CLOCAL){ | 3449 | if (retval != 0) { |
3386 | info->flags &= ~ASYNC_CHECK_CD; | 3450 | printk("cyc:set_line_char retval on ttyC%d was %x\n", |
3387 | }else{ | 3451 | info->line, retval); |
3388 | info->flags |= ASYNC_CHECK_CD; | 3452 | } |
3389 | } | ||
3390 | 3453 | ||
3391 | if(baud == 0){ /* baud rate is zero, turn off line */ | 3454 | /* CD sensitivity */ |
3392 | cy_writel(&ch_ctrl->rs_control, | 3455 | if (cflag & CLOCAL) { |
3393 | cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR); | 3456 | info->flags &= ~ASYNC_CHECK_CD; |
3457 | } else { | ||
3458 | info->flags |= ASYNC_CHECK_CD; | ||
3459 | } | ||
3460 | |||
3461 | if (baud == 0) { /* baud rate is zero, turn off line */ | ||
3462 | cy_writel(&ch_ctrl->rs_control, | ||
3463 | cy_readl(&ch_ctrl->rs_control) & ~C_RS_DTR); | ||
3394 | #ifdef CY_DEBUG_DTR | 3464 | #ifdef CY_DEBUG_DTR |
3395 | printk("cyc:set_line_char dropping Z DTR\n"); | 3465 | printk("cyc:set_line_char dropping Z DTR\n"); |
3396 | #endif | 3466 | #endif |
3397 | }else{ | 3467 | } else { |
3398 | cy_writel(&ch_ctrl->rs_control, | 3468 | cy_writel(&ch_ctrl->rs_control, |
3399 | cy_readl(&ch_ctrl->rs_control) | C_RS_DTR); | 3469 | cy_readl(&ch_ctrl->rs_control) | C_RS_DTR); |
3400 | #ifdef CY_DEBUG_DTR | 3470 | #ifdef CY_DEBUG_DTR |
3401 | printk("cyc:set_line_char raising Z DTR\n"); | 3471 | printk("cyc:set_line_char raising Z DTR\n"); |
3402 | #endif | 3472 | #endif |
3403 | } | 3473 | } |
3404 | 3474 | ||
3405 | retval = cyz_issue_cmd( &cy_card[card], channel, C_CM_IOCTLM, 0L); | 3475 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_IOCTLM,0L); |
3406 | if (retval != 0){ | 3476 | if (retval != 0) { |
3407 | printk("cyc:set_line_char(2) retval on ttyC%d was %x\n", | 3477 | printk("cyc:set_line_char(2) retval on ttyC%d was %x\n", |
3408 | info->line, retval); | 3478 | info->line, retval); |
3409 | } | 3479 | } |
3410 | 3480 | ||
3411 | if (info->tty){ | 3481 | if (info->tty) { |
3412 | clear_bit(TTY_IO_ERROR, &info->tty->flags); | 3482 | clear_bit(TTY_IO_ERROR, &info->tty->flags); |
3483 | } | ||
3413 | } | 3484 | } |
3414 | } | 3485 | } /* set_line_char */ |
3415 | } /* set_line_char */ | ||
3416 | |||
3417 | 3486 | ||
3418 | static int | 3487 | static int |
3419 | get_serial_info(struct cyclades_port * info, | 3488 | get_serial_info(struct cyclades_port *info, |
3420 | struct serial_struct __user * retinfo) | 3489 | struct serial_struct __user * retinfo) |
3421 | { | 3490 | { |
3422 | struct serial_struct tmp; | 3491 | struct serial_struct tmp; |
3423 | struct cyclades_card *cinfo = &cy_card[info->card]; | 3492 | struct cyclades_card *cinfo = &cy_card[info->card]; |
3424 | |||
3425 | if (!retinfo) | ||
3426 | return -EFAULT; | ||
3427 | memset(&tmp, 0, sizeof(tmp)); | ||
3428 | tmp.type = info->type; | ||
3429 | tmp.line = info->line; | ||
3430 | tmp.port = info->card * 0x100 + info->line - cinfo->first_line; | ||
3431 | tmp.irq = cinfo->irq; | ||
3432 | tmp.flags = info->flags; | ||
3433 | tmp.close_delay = info->close_delay; | ||
3434 | tmp.baud_base = info->baud; | ||
3435 | tmp.custom_divisor = info->custom_divisor; | ||
3436 | tmp.hub6 = 0; /*!!!*/ | ||
3437 | return copy_to_user(retinfo,&tmp,sizeof(*retinfo))?-EFAULT:0; | ||
3438 | } /* get_serial_info */ | ||
3439 | 3493 | ||
3494 | if (!retinfo) | ||
3495 | return -EFAULT; | ||
3496 | memset(&tmp, 0, sizeof(tmp)); | ||
3497 | tmp.type = info->type; | ||
3498 | tmp.line = info->line; | ||
3499 | tmp.port = info->card * 0x100 + info->line - cinfo->first_line; | ||
3500 | tmp.irq = cinfo->irq; | ||
3501 | tmp.flags = info->flags; | ||
3502 | tmp.close_delay = info->close_delay; | ||
3503 | tmp.baud_base = info->baud; | ||
3504 | tmp.custom_divisor = info->custom_divisor; | ||
3505 | tmp.hub6 = 0; /*!!! */ | ||
3506 | return copy_to_user(retinfo, &tmp, sizeof(*retinfo)) ? -EFAULT : 0; | ||
3507 | } /* get_serial_info */ | ||
3440 | 3508 | ||
3441 | static int | 3509 | static int |
3442 | set_serial_info(struct cyclades_port * info, | 3510 | set_serial_info(struct cyclades_port *info, |
3443 | struct serial_struct __user * new_info) | 3511 | struct serial_struct __user * new_info) |
3444 | { | 3512 | { |
3445 | struct serial_struct new_serial; | 3513 | struct serial_struct new_serial; |
3446 | struct cyclades_port old_info; | 3514 | struct cyclades_port old_info; |
3447 | 3515 | ||
3448 | if (copy_from_user(&new_serial,new_info,sizeof(new_serial))) | 3516 | if (copy_from_user(&new_serial, new_info, sizeof(new_serial))) |
3449 | return -EFAULT; | 3517 | return -EFAULT; |
3450 | old_info = *info; | 3518 | old_info = *info; |
3451 | 3519 | ||
3452 | if (!capable(CAP_SYS_ADMIN)) { | 3520 | if (!capable(CAP_SYS_ADMIN)) { |
3453 | if ((new_serial.close_delay != info->close_delay) || | 3521 | if (new_serial.close_delay != info->close_delay || |
3454 | (new_serial.baud_base != info->baud) || | 3522 | new_serial.baud_base != info->baud || |
3455 | ((new_serial.flags & ASYNC_FLAGS & ~ASYNC_USR_MASK) != | 3523 | (new_serial.flags & ASYNC_FLAGS & |
3456 | (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK))) | 3524 | ~ASYNC_USR_MASK) != |
3457 | return -EPERM; | 3525 | (info->flags & ASYNC_FLAGS & ~ASYNC_USR_MASK)) |
3458 | info->flags = ((info->flags & ~ASYNC_USR_MASK) | | 3526 | return -EPERM; |
3459 | (new_serial.flags & ASYNC_USR_MASK)); | 3527 | info->flags = (info->flags & ~ASYNC_USR_MASK) | |
3460 | info->baud = new_serial.baud_base; | 3528 | (new_serial.flags & ASYNC_USR_MASK); |
3461 | info->custom_divisor = new_serial.custom_divisor; | 3529 | info->baud = new_serial.baud_base; |
3462 | goto check_and_exit; | 3530 | info->custom_divisor = new_serial.custom_divisor; |
3463 | } | 3531 | goto check_and_exit; |
3464 | 3532 | } | |
3465 | 3533 | ||
3466 | /* | 3534 | /* |
3467 | * OK, past this point, all the error checking has been done. | 3535 | * OK, past this point, all the error checking has been done. |
3468 | * At this point, we start making changes..... | 3536 | * At this point, we start making changes..... |
3469 | */ | 3537 | */ |
3470 | 3538 | ||
3471 | info->baud = new_serial.baud_base; | 3539 | info->baud = new_serial.baud_base; |
3472 | info->custom_divisor = new_serial.custom_divisor; | 3540 | info->custom_divisor = new_serial.custom_divisor; |
3473 | info->flags = ((info->flags & ~ASYNC_FLAGS) | | 3541 | info->flags = (info->flags & ~ASYNC_FLAGS) | |
3474 | (new_serial.flags & ASYNC_FLAGS)); | 3542 | (new_serial.flags & ASYNC_FLAGS); |
3475 | info->close_delay = new_serial.close_delay * HZ/100; | 3543 | info->close_delay = new_serial.close_delay * HZ / 100; |
3476 | info->closing_wait = new_serial.closing_wait * HZ/100; | 3544 | info->closing_wait = new_serial.closing_wait * HZ / 100; |
3477 | 3545 | ||
3478 | check_and_exit: | 3546 | check_and_exit: |
3479 | if (info->flags & ASYNC_INITIALIZED){ | 3547 | if (info->flags & ASYNC_INITIALIZED) { |
3480 | set_line_char(info); | 3548 | set_line_char(info); |
3481 | return 0; | 3549 | return 0; |
3482 | }else{ | 3550 | } else { |
3483 | return startup(info); | 3551 | return startup(info); |
3484 | } | 3552 | } |
3485 | } /* set_serial_info */ | 3553 | } /* set_serial_info */ |
3486 | 3554 | ||
3487 | /* | 3555 | /* |
3488 | * get_lsr_info - get line status register info | 3556 | * get_lsr_info - get line status register info |
@@ -3494,441 +3562,452 @@ check_and_exit: | |||
3494 | * transmit holding register is empty. This functionality | 3562 | * transmit holding register is empty. This functionality |
3495 | * allows an RS485 driver to be written in user space. | 3563 | * allows an RS485 driver to be written in user space. |
3496 | */ | 3564 | */ |
3497 | static int get_lsr_info(struct cyclades_port *info, unsigned int __user *value) | 3565 | static int get_lsr_info(struct cyclades_port *info, unsigned int __user * value) |
3498 | { | 3566 | { |
3499 | int card, chip, channel, index; | 3567 | int card, chip, channel, index; |
3500 | unsigned char status; | 3568 | unsigned char status; |
3501 | unsigned int result; | 3569 | unsigned int result; |
3502 | unsigned long flags; | 3570 | unsigned long flags; |
3503 | void __iomem *base_addr; | 3571 | void __iomem *base_addr; |
3504 | |||
3505 | card = info->card; | ||
3506 | channel = (info->line) - (cy_card[card].first_line); | ||
3507 | if (!IS_CYC_Z(cy_card[card])) { | ||
3508 | chip = channel>>2; | ||
3509 | channel &= 0x03; | ||
3510 | index = cy_card[card].bus_index; | ||
3511 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
3512 | 3572 | ||
3513 | CY_LOCK(info, flags); | 3573 | card = info->card; |
3514 | status = cy_readb(base_addr+(CySRER<<index)) & (CyTxRdy|CyTxMpty); | 3574 | channel = (info->line) - (cy_card[card].first_line); |
3515 | CY_UNLOCK(info, flags); | 3575 | if (!IS_CYC_Z(cy_card[card])) { |
3516 | result = (status ? 0 : TIOCSER_TEMT); | 3576 | chip = channel >> 2; |
3517 | } else { | 3577 | channel &= 0x03; |
3518 | /* Not supported yet */ | 3578 | index = cy_card[card].bus_index; |
3519 | return -EINVAL; | 3579 | base_addr = |
3520 | } | 3580 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); |
3521 | return put_user(result, (unsigned long __user *) value); | 3581 | |
3582 | CY_LOCK(info, flags); | ||
3583 | status = cy_readb(base_addr + (CySRER << index)) & | ||
3584 | (CyTxRdy | CyTxMpty); | ||
3585 | CY_UNLOCK(info, flags); | ||
3586 | result = (status ? 0 : TIOCSER_TEMT); | ||
3587 | } else { | ||
3588 | /* Not supported yet */ | ||
3589 | return -EINVAL; | ||
3590 | } | ||
3591 | return put_user(result, (unsigned long __user *)value); | ||
3522 | } | 3592 | } |
3523 | 3593 | ||
3524 | static int | 3594 | static int cy_tiocmget(struct tty_struct *tty, struct file *file) |
3525 | cy_tiocmget(struct tty_struct *tty, struct file *file) | ||
3526 | { | 3595 | { |
3527 | struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; | 3596 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
3528 | int card,chip,channel,index; | 3597 | int card, chip, channel, index; |
3529 | void __iomem *base_addr; | 3598 | void __iomem *base_addr; |
3530 | unsigned long flags; | 3599 | unsigned long flags; |
3531 | unsigned char status; | 3600 | unsigned char status; |
3532 | unsigned long lstatus; | 3601 | unsigned long lstatus; |
3533 | unsigned int result; | 3602 | unsigned int result; |
3534 | struct FIRM_ID __iomem *firm_id; | 3603 | struct FIRM_ID __iomem *firm_id; |
3535 | struct ZFW_CTRL __iomem *zfw_ctrl; | 3604 | struct ZFW_CTRL __iomem *zfw_ctrl; |
3536 | struct BOARD_CTRL __iomem *board_ctrl; | 3605 | struct BOARD_CTRL __iomem *board_ctrl; |
3537 | struct CH_CTRL __iomem *ch_ctrl; | 3606 | struct CH_CTRL __iomem *ch_ctrl; |
3538 | 3607 | ||
3539 | if (serial_paranoia_check(info, tty->name, __FUNCTION__)) | 3608 | if (serial_paranoia_check(info, tty->name, __FUNCTION__)) |
3540 | return -ENODEV; | 3609 | return -ENODEV; |
3541 | |||
3542 | card = info->card; | ||
3543 | channel = (info->line) - (cy_card[card].first_line); | ||
3544 | if (!IS_CYC_Z(cy_card[card])) { | ||
3545 | chip = channel>>2; | ||
3546 | channel &= 0x03; | ||
3547 | index = cy_card[card].bus_index; | ||
3548 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
3549 | 3610 | ||
3550 | CY_LOCK(info, flags); | 3611 | card = info->card; |
3551 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 3612 | channel = (info->line) - (cy_card[card].first_line); |
3552 | status = cy_readb(base_addr+(CyMSVR1<<index)); | 3613 | if (!IS_CYC_Z(cy_card[card])) { |
3553 | status |= cy_readb(base_addr+(CyMSVR2<<index)); | 3614 | chip = channel >> 2; |
3554 | CY_UNLOCK(info, flags); | 3615 | channel &= 0x03; |
3616 | index = cy_card[card].bus_index; | ||
3617 | base_addr = | ||
3618 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); | ||
3619 | |||
3620 | CY_LOCK(info, flags); | ||
3621 | cy_writeb(base_addr + (CyCAR << index), (u_char) channel); | ||
3622 | status = cy_readb(base_addr + (CyMSVR1 << index)); | ||
3623 | status |= cy_readb(base_addr + (CyMSVR2 << index)); | ||
3624 | CY_UNLOCK(info, flags); | ||
3555 | 3625 | ||
3556 | if (info->rtsdtr_inv) { | 3626 | if (info->rtsdtr_inv) { |
3557 | result = ((status & CyRTS) ? TIOCM_DTR : 0) | 3627 | result = ((status & CyRTS) ? TIOCM_DTR : 0) | |
3558 | | ((status & CyDTR) ? TIOCM_RTS : 0); | 3628 | ((status & CyDTR) ? TIOCM_RTS : 0); |
3629 | } else { | ||
3630 | result = ((status & CyRTS) ? TIOCM_RTS : 0) | | ||
3631 | ((status & CyDTR) ? TIOCM_DTR : 0); | ||
3632 | } | ||
3633 | result |= ((status & CyDCD) ? TIOCM_CAR : 0) | | ||
3634 | ((status & CyRI) ? TIOCM_RNG : 0) | | ||
3635 | ((status & CyDSR) ? TIOCM_DSR : 0) | | ||
3636 | ((status & CyCTS) ? TIOCM_CTS : 0); | ||
3559 | } else { | 3637 | } else { |
3560 | result = ((status & CyRTS) ? TIOCM_RTS : 0) | 3638 | base_addr = cy_card[card].base_addr; |
3561 | | ((status & CyDTR) ? TIOCM_DTR : 0); | ||
3562 | } | ||
3563 | result |= ((status & CyDCD) ? TIOCM_CAR : 0) | ||
3564 | | ((status & CyRI) ? TIOCM_RNG : 0) | ||
3565 | | ((status & CyDSR) ? TIOCM_DSR : 0) | ||
3566 | | ((status & CyCTS) ? TIOCM_CTS : 0); | ||
3567 | } else { | ||
3568 | base_addr = cy_card[card].base_addr; | ||
3569 | |||
3570 | if (cy_card[card].num_chips != -1){ | ||
3571 | return -EINVAL; | ||
3572 | } | ||
3573 | 3639 | ||
3574 | firm_id = cy_card[card].base_addr + ID_ADDRESS; | 3640 | if (cy_card[card].num_chips != -1) { |
3575 | if (ISZLOADED(cy_card[card])) { | 3641 | return -EINVAL; |
3576 | zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 3642 | } |
3577 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
3578 | ch_ctrl = zfw_ctrl->ch_ctrl; | ||
3579 | lstatus = cy_readl(&ch_ctrl[channel].rs_status); | ||
3580 | result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) | ||
3581 | | ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) | ||
3582 | | ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) | ||
3583 | | ((lstatus & C_RS_RI) ? TIOCM_RNG : 0) | ||
3584 | | ((lstatus & C_RS_DSR) ? TIOCM_DSR : 0) | ||
3585 | | ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0); | ||
3586 | }else{ | ||
3587 | result = 0; | ||
3588 | return -ENODEV; | ||
3589 | } | ||
3590 | 3643 | ||
3591 | } | 3644 | firm_id = cy_card[card].base_addr + ID_ADDRESS; |
3592 | return result; | 3645 | if (ISZLOADED(cy_card[card])) { |
3593 | } /* cy_tiomget */ | 3646 | zfw_ctrl = cy_card[card].base_addr + |
3647 | (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | ||
3648 | board_ctrl = &zfw_ctrl->board_ctrl; | ||
3649 | ch_ctrl = zfw_ctrl->ch_ctrl; | ||
3650 | lstatus = cy_readl(&ch_ctrl[channel].rs_status); | ||
3651 | result = ((lstatus & C_RS_RTS) ? TIOCM_RTS : 0) | | ||
3652 | ((lstatus & C_RS_DTR) ? TIOCM_DTR : 0) | | ||
3653 | ((lstatus & C_RS_DCD) ? TIOCM_CAR : 0) | | ||
3654 | ((lstatus & C_RS_RI) ? TIOCM_RNG : 0) | | ||
3655 | ((lstatus & C_RS_DSR) ? TIOCM_DSR : 0) | | ||
3656 | ((lstatus & C_RS_CTS) ? TIOCM_CTS : 0); | ||
3657 | } else { | ||
3658 | result = 0; | ||
3659 | return -ENODEV; | ||
3660 | } | ||
3594 | 3661 | ||
3662 | } | ||
3663 | return result; | ||
3664 | } /* cy_tiomget */ | ||
3595 | 3665 | ||
3596 | static int | 3666 | static int |
3597 | cy_tiocmset(struct tty_struct *tty, struct file *file, | 3667 | cy_tiocmset(struct tty_struct *tty, struct file *file, |
3598 | unsigned int set, unsigned int clear) | 3668 | unsigned int set, unsigned int clear) |
3599 | { | 3669 | { |
3600 | struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; | 3670 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
3601 | int card,chip,channel,index; | 3671 | int card, chip, channel, index; |
3602 | void __iomem *base_addr; | 3672 | void __iomem *base_addr; |
3603 | unsigned long flags; | 3673 | unsigned long flags; |
3604 | struct FIRM_ID __iomem *firm_id; | 3674 | struct FIRM_ID __iomem *firm_id; |
3605 | struct ZFW_CTRL __iomem *zfw_ctrl; | 3675 | struct ZFW_CTRL __iomem *zfw_ctrl; |
3606 | struct BOARD_CTRL __iomem *board_ctrl; | 3676 | struct BOARD_CTRL __iomem *board_ctrl; |
3607 | struct CH_CTRL __iomem *ch_ctrl; | 3677 | struct CH_CTRL __iomem *ch_ctrl; |
3608 | int retval; | 3678 | int retval; |
3609 | 3679 | ||
3610 | if (serial_paranoia_check(info, tty->name, __FUNCTION__)) | 3680 | if (serial_paranoia_check(info, tty->name, __FUNCTION__)) |
3611 | return -ENODEV; | 3681 | return -ENODEV; |
3612 | 3682 | ||
3613 | card = info->card; | 3683 | card = info->card; |
3614 | channel = (info->line) - (cy_card[card].first_line); | 3684 | channel = (info->line) - (cy_card[card].first_line); |
3615 | if (!IS_CYC_Z(cy_card[card])) { | 3685 | if (!IS_CYC_Z(cy_card[card])) { |
3616 | chip = channel>>2; | 3686 | chip = channel >> 2; |
3617 | channel &= 0x03; | 3687 | channel &= 0x03; |
3618 | index = cy_card[card].bus_index; | 3688 | index = cy_card[card].bus_index; |
3619 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | 3689 | base_addr = |
3620 | 3690 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); | |
3621 | if (set & TIOCM_RTS){ | 3691 | |
3622 | CY_LOCK(info, flags); | 3692 | if (set & TIOCM_RTS) { |
3623 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 3693 | CY_LOCK(info, flags); |
3624 | if (info->rtsdtr_inv) { | 3694 | cy_writeb(base_addr + (CyCAR << index), |
3625 | cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); | 3695 | (u_char) channel); |
3626 | } else { | 3696 | if (info->rtsdtr_inv) { |
3627 | cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); | 3697 | cy_writeb(base_addr + (CyMSVR2 << index), |
3628 | } | 3698 | CyDTR); |
3629 | CY_UNLOCK(info, flags); | 3699 | } else { |
3630 | } | 3700 | cy_writeb(base_addr + (CyMSVR1 << index), |
3631 | if (clear & TIOCM_RTS) { | 3701 | CyRTS); |
3632 | CY_LOCK(info, flags); | 3702 | } |
3633 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 3703 | CY_UNLOCK(info, flags); |
3634 | if (info->rtsdtr_inv) { | 3704 | } |
3635 | cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); | 3705 | if (clear & TIOCM_RTS) { |
3636 | } else { | 3706 | CY_LOCK(info, flags); |
3637 | cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); | 3707 | cy_writeb(base_addr + (CyCAR << index), |
3638 | } | 3708 | (u_char) channel); |
3639 | CY_UNLOCK(info, flags); | 3709 | if (info->rtsdtr_inv) { |
3640 | } | 3710 | cy_writeb(base_addr + (CyMSVR2 << index), |
3641 | if (set & TIOCM_DTR){ | 3711 | ~CyDTR); |
3642 | CY_LOCK(info, flags); | 3712 | } else { |
3643 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 3713 | cy_writeb(base_addr + (CyMSVR1 << index), |
3644 | if (info->rtsdtr_inv) { | 3714 | ~CyRTS); |
3645 | cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); | 3715 | } |
3646 | } else { | 3716 | CY_UNLOCK(info, flags); |
3647 | cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); | 3717 | } |
3648 | } | 3718 | if (set & TIOCM_DTR) { |
3719 | CY_LOCK(info, flags); | ||
3720 | cy_writeb(base_addr + (CyCAR << index), | ||
3721 | (u_char) channel); | ||
3722 | if (info->rtsdtr_inv) { | ||
3723 | cy_writeb(base_addr + (CyMSVR1 << index), | ||
3724 | CyRTS); | ||
3725 | } else { | ||
3726 | cy_writeb(base_addr + (CyMSVR2 << index), | ||
3727 | CyDTR); | ||
3728 | } | ||
3649 | #ifdef CY_DEBUG_DTR | 3729 | #ifdef CY_DEBUG_DTR |
3650 | printk("cyc:set_modem_info raising DTR\n"); | 3730 | printk("cyc:set_modem_info raising DTR\n"); |
3651 | printk(" status: 0x%x, 0x%x\n", | 3731 | printk(" status: 0x%x, 0x%x\n", |
3652 | cy_readb(base_addr+(CyMSVR1<<index)), | 3732 | cy_readb(base_addr + (CyMSVR1 << index)), |
3653 | cy_readb(base_addr+(CyMSVR2<<index))); | 3733 | cy_readb(base_addr + (CyMSVR2 << index))); |
3654 | #endif | 3734 | #endif |
3655 | CY_UNLOCK(info, flags); | 3735 | CY_UNLOCK(info, flags); |
3656 | } | 3736 | } |
3657 | if (clear & TIOCM_DTR) { | 3737 | if (clear & TIOCM_DTR) { |
3658 | CY_LOCK(info, flags); | 3738 | CY_LOCK(info, flags); |
3659 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | 3739 | cy_writeb(base_addr + (CyCAR << index), |
3660 | if (info->rtsdtr_inv) { | 3740 | (u_char) channel); |
3661 | cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); | 3741 | if (info->rtsdtr_inv) { |
3662 | } else { | 3742 | cy_writeb(base_addr + (CyMSVR1 << index), |
3663 | cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); | 3743 | ~CyRTS); |
3664 | } | 3744 | } else { |
3745 | cy_writeb(base_addr + (CyMSVR2 << index), | ||
3746 | ~CyDTR); | ||
3747 | } | ||
3665 | 3748 | ||
3666 | #ifdef CY_DEBUG_DTR | 3749 | #ifdef CY_DEBUG_DTR |
3667 | printk("cyc:set_modem_info dropping DTR\n"); | 3750 | printk("cyc:set_modem_info dropping DTR\n"); |
3668 | printk(" status: 0x%x, 0x%x\n", | 3751 | printk(" status: 0x%x, 0x%x\n", |
3669 | cy_readb(base_addr+(CyMSVR1<<index)), | 3752 | cy_readb(base_addr + (CyMSVR1 << index)), |
3670 | cy_readb(base_addr+(CyMSVR2<<index))); | 3753 | cy_readb(base_addr + (CyMSVR2 << index))); |
3671 | #endif | 3754 | #endif |
3672 | CY_UNLOCK(info, flags); | 3755 | CY_UNLOCK(info, flags); |
3673 | } | 3756 | } |
3674 | } else { | 3757 | } else { |
3675 | base_addr = cy_card[card].base_addr; | 3758 | base_addr = cy_card[card].base_addr; |
3676 | 3759 | ||
3677 | firm_id = cy_card[card].base_addr + ID_ADDRESS; | 3760 | firm_id = cy_card[card].base_addr + ID_ADDRESS; |
3678 | if (ISZLOADED(cy_card[card])) { | 3761 | if (ISZLOADED(cy_card[card])) { |
3679 | zfw_ctrl = cy_card[card].base_addr + (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); | 3762 | zfw_ctrl = cy_card[card].base_addr + |
3680 | board_ctrl = &zfw_ctrl->board_ctrl; | 3763 | (cy_readl(&firm_id->zfwctrl_addr) & 0xfffff); |
3681 | ch_ctrl = zfw_ctrl->ch_ctrl; | 3764 | board_ctrl = &zfw_ctrl->board_ctrl; |
3682 | 3765 | ch_ctrl = zfw_ctrl->ch_ctrl; | |
3683 | if (set & TIOCM_RTS){ | 3766 | |
3684 | CY_LOCK(info, flags); | 3767 | if (set & TIOCM_RTS) { |
3685 | cy_writel(&ch_ctrl[channel].rs_control, | 3768 | CY_LOCK(info, flags); |
3686 | cy_readl(&ch_ctrl[channel].rs_control) | C_RS_RTS); | 3769 | cy_writel(&ch_ctrl[channel].rs_control, |
3687 | CY_UNLOCK(info, flags); | 3770 | cy_readl(&ch_ctrl[channel]. |
3688 | } | 3771 | rs_control) | C_RS_RTS); |
3689 | if (clear & TIOCM_RTS) { | 3772 | CY_UNLOCK(info, flags); |
3690 | CY_LOCK(info, flags); | 3773 | } |
3691 | cy_writel(&ch_ctrl[channel].rs_control, | 3774 | if (clear & TIOCM_RTS) { |
3692 | cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_RTS); | 3775 | CY_LOCK(info, flags); |
3693 | CY_UNLOCK(info, flags); | 3776 | cy_writel(&ch_ctrl[channel].rs_control, |
3694 | } | 3777 | cy_readl(&ch_ctrl[channel]. |
3695 | if (set & TIOCM_DTR){ | 3778 | rs_control) & ~C_RS_RTS); |
3696 | CY_LOCK(info, flags); | 3779 | CY_UNLOCK(info, flags); |
3697 | cy_writel(&ch_ctrl[channel].rs_control, | 3780 | } |
3698 | cy_readl(&ch_ctrl[channel].rs_control) | C_RS_DTR); | 3781 | if (set & TIOCM_DTR) { |
3782 | CY_LOCK(info, flags); | ||
3783 | cy_writel(&ch_ctrl[channel].rs_control, | ||
3784 | cy_readl(&ch_ctrl[channel]. | ||
3785 | rs_control) | C_RS_DTR); | ||
3699 | #ifdef CY_DEBUG_DTR | 3786 | #ifdef CY_DEBUG_DTR |
3700 | printk("cyc:set_modem_info raising Z DTR\n"); | 3787 | printk("cyc:set_modem_info raising Z DTR\n"); |
3701 | #endif | 3788 | #endif |
3702 | CY_UNLOCK(info, flags); | 3789 | CY_UNLOCK(info, flags); |
3703 | } | 3790 | } |
3704 | if (clear & TIOCM_DTR) { | 3791 | if (clear & TIOCM_DTR) { |
3705 | CY_LOCK(info, flags); | 3792 | CY_LOCK(info, flags); |
3706 | cy_writel(&ch_ctrl[channel].rs_control, | 3793 | cy_writel(&ch_ctrl[channel].rs_control, |
3707 | cy_readl(&ch_ctrl[channel].rs_control) & ~C_RS_DTR); | 3794 | cy_readl(&ch_ctrl[channel]. |
3795 | rs_control) & ~C_RS_DTR); | ||
3708 | #ifdef CY_DEBUG_DTR | 3796 | #ifdef CY_DEBUG_DTR |
3709 | printk("cyc:set_modem_info clearing Z DTR\n"); | 3797 | printk("cyc:set_modem_info clearing Z DTR\n"); |
3710 | #endif | 3798 | #endif |
3711 | CY_UNLOCK(info, flags); | 3799 | CY_UNLOCK(info, flags); |
3712 | } | 3800 | } |
3713 | }else{ | 3801 | } else { |
3714 | return -ENODEV; | 3802 | return -ENODEV; |
3715 | } | 3803 | } |
3716 | CY_LOCK(info, flags); | 3804 | CY_LOCK(info, flags); |
3717 | retval = cyz_issue_cmd(&cy_card[info->card], | 3805 | retval = cyz_issue_cmd(&cy_card[info->card], |
3718 | channel, C_CM_IOCTLM,0L); | 3806 | channel, C_CM_IOCTLM, 0L); |
3719 | if (retval != 0){ | 3807 | if (retval != 0) { |
3720 | printk("cyc:set_modem_info retval on ttyC%d was %x\n", | 3808 | printk("cyc:set_modem_info retval on ttyC%d was %x\n", |
3721 | info->line, retval); | 3809 | info->line, retval); |
3810 | } | ||
3811 | CY_UNLOCK(info, flags); | ||
3722 | } | 3812 | } |
3723 | CY_UNLOCK(info, flags); | 3813 | return 0; |
3724 | } | 3814 | } /* cy_tiocmset */ |
3725 | return 0; | ||
3726 | } /* cy_tiocmset */ | ||
3727 | 3815 | ||
3728 | /* | 3816 | /* |
3729 | * cy_break() --- routine which turns the break handling on or off | 3817 | * cy_break() --- routine which turns the break handling on or off |
3730 | */ | 3818 | */ |
3731 | static void | 3819 | static void cy_break(struct tty_struct *tty, int break_state) |
3732 | cy_break(struct tty_struct *tty, int break_state) | ||
3733 | { | 3820 | { |
3734 | struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; | 3821 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
3735 | unsigned long flags; | 3822 | unsigned long flags; |
3736 | 3823 | ||
3737 | if (serial_paranoia_check(info, tty->name, "cy_break")) | 3824 | if (serial_paranoia_check(info, tty->name, "cy_break")) |
3738 | return; | 3825 | return; |
3739 | 3826 | ||
3740 | CY_LOCK(info, flags); | 3827 | CY_LOCK(info, flags); |
3741 | if (!IS_CYC_Z(cy_card[info->card])) { | 3828 | if (!IS_CYC_Z(cy_card[info->card])) { |
3742 | /* Let the transmit ISR take care of this (since it | 3829 | /* Let the transmit ISR take care of this (since it |
3743 | requires stuffing characters into the output stream). | 3830 | requires stuffing characters into the output stream). |
3744 | */ | 3831 | */ |
3745 | if (break_state == -1) { | 3832 | if (break_state == -1) { |
3746 | if (!info->breakon) { | 3833 | if (!info->breakon) { |
3747 | info->breakon = 1; | 3834 | info->breakon = 1; |
3748 | if (!info->xmit_cnt) { | 3835 | if (!info->xmit_cnt) { |
3749 | CY_UNLOCK(info, flags); | 3836 | CY_UNLOCK(info, flags); |
3750 | start_xmit(info); | 3837 | start_xmit(info); |
3751 | CY_LOCK(info, flags); | 3838 | CY_LOCK(info, flags); |
3839 | } | ||
3840 | } | ||
3841 | } else { | ||
3842 | if (!info->breakoff) { | ||
3843 | info->breakoff = 1; | ||
3844 | if (!info->xmit_cnt) { | ||
3845 | CY_UNLOCK(info, flags); | ||
3846 | start_xmit(info); | ||
3847 | CY_LOCK(info, flags); | ||
3848 | } | ||
3849 | } | ||
3752 | } | 3850 | } |
3753 | } | ||
3754 | } else { | 3851 | } else { |
3755 | if (!info->breakoff) { | 3852 | int retval; |
3756 | info->breakoff = 1; | 3853 | |
3757 | if (!info->xmit_cnt) { | 3854 | if (break_state == -1) { |
3758 | CY_UNLOCK(info, flags); | 3855 | retval = cyz_issue_cmd(&cy_card[info->card], |
3759 | start_xmit(info); | 3856 | info->line - cy_card[info->card].first_line, |
3760 | CY_LOCK(info, flags); | 3857 | C_CM_SET_BREAK, 0L); |
3858 | if (retval != 0) { | ||
3859 | printk("cyc:cy_break (set) retval on ttyC%d " | ||
3860 | "was %x\n", info->line, retval); | ||
3861 | } | ||
3862 | } else { | ||
3863 | retval = cyz_issue_cmd(&cy_card[info->card], | ||
3864 | info->line - cy_card[info->card].first_line, | ||
3865 | C_CM_CLR_BREAK, 0L); | ||
3866 | if (retval != 0) { | ||
3867 | printk("cyc:cy_break (clr) retval on ttyC%d " | ||
3868 | "was %x\n", info->line, retval); | ||
3869 | } | ||
3761 | } | 3870 | } |
3762 | } | ||
3763 | } | ||
3764 | } else { | ||
3765 | int retval; | ||
3766 | |||
3767 | if (break_state == -1) { | ||
3768 | retval = cyz_issue_cmd(&cy_card[info->card], | ||
3769 | (info->line) - (cy_card[info->card].first_line), | ||
3770 | C_CM_SET_BREAK, 0L); | ||
3771 | if (retval != 0) { | ||
3772 | printk("cyc:cy_break (set) retval on ttyC%d was %x\n", | ||
3773 | info->line, retval); | ||
3774 | } | ||
3775 | } else { | ||
3776 | retval = cyz_issue_cmd(&cy_card[info->card], | ||
3777 | (info->line) - (cy_card[info->card].first_line), | ||
3778 | C_CM_CLR_BREAK, 0L); | ||
3779 | if (retval != 0) { | ||
3780 | printk("cyc:cy_break (clr) retval on ttyC%d was %x\n", | ||
3781 | info->line, retval); | ||
3782 | } | ||
3783 | } | 3871 | } |
3784 | } | 3872 | CY_UNLOCK(info, flags); |
3785 | CY_UNLOCK(info, flags); | 3873 | } /* cy_break */ |
3786 | } /* cy_break */ | ||
3787 | 3874 | ||
3788 | static int | 3875 | static int |
3789 | get_mon_info(struct cyclades_port * info, struct cyclades_monitor __user * mon) | 3876 | get_mon_info(struct cyclades_port *info, struct cyclades_monitor __user * mon) |
3790 | { | 3877 | { |
3791 | 3878 | ||
3792 | if(copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) | 3879 | if (copy_to_user(mon, &info->mon, sizeof(struct cyclades_monitor))) |
3793 | return -EFAULT; | 3880 | return -EFAULT; |
3794 | info->mon.int_count = 0; | 3881 | info->mon.int_count = 0; |
3795 | info->mon.char_count = 0; | 3882 | info->mon.char_count = 0; |
3796 | info->mon.char_max = 0; | 3883 | info->mon.char_max = 0; |
3797 | info->mon.char_last = 0; | 3884 | info->mon.char_last = 0; |
3798 | return 0; | 3885 | return 0; |
3799 | }/* get_mon_info */ | 3886 | } /* get_mon_info */ |
3800 | |||
3801 | 3887 | ||
3802 | static int | 3888 | static int set_threshold(struct cyclades_port *info, unsigned long value) |
3803 | set_threshold(struct cyclades_port * info, unsigned long value) | ||
3804 | { | 3889 | { |
3805 | void __iomem *base_addr; | 3890 | void __iomem *base_addr; |
3806 | int card,channel,chip,index; | 3891 | int card, channel, chip, index; |
3807 | unsigned long flags; | 3892 | unsigned long flags; |
3808 | |||
3809 | card = info->card; | ||
3810 | channel = info->line - cy_card[card].first_line; | ||
3811 | if (!IS_CYC_Z(cy_card[card])) { | ||
3812 | chip = channel>>2; | ||
3813 | channel &= 0x03; | ||
3814 | index = cy_card[card].bus_index; | ||
3815 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
3816 | |||
3817 | info->cor3 &= ~CyREC_FIFO; | ||
3818 | info->cor3 |= value & CyREC_FIFO; | ||
3819 | 3893 | ||
3820 | CY_LOCK(info, flags); | 3894 | card = info->card; |
3821 | cy_writeb(base_addr+(CyCOR3<<index), info->cor3); | 3895 | channel = info->line - cy_card[card].first_line; |
3822 | cyy_issue_cmd(base_addr,CyCOR_CHANGE|CyCOR3ch,index); | 3896 | if (!IS_CYC_Z(cy_card[card])) { |
3823 | CY_UNLOCK(info, flags); | 3897 | chip = channel >> 2; |
3824 | } else { | 3898 | channel &= 0x03; |
3825 | // Nothing to do! | 3899 | index = cy_card[card].bus_index; |
3826 | } | 3900 | base_addr = |
3827 | return 0; | 3901 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); |
3828 | }/* set_threshold */ | ||
3829 | 3902 | ||
3903 | info->cor3 &= ~CyREC_FIFO; | ||
3904 | info->cor3 |= value & CyREC_FIFO; | ||
3830 | 3905 | ||
3831 | static int | 3906 | CY_LOCK(info, flags); |
3832 | get_threshold(struct cyclades_port * info, unsigned long __user *value) | 3907 | cy_writeb(base_addr + (CyCOR3 << index), info->cor3); |
3833 | { | 3908 | cyy_issue_cmd(base_addr, CyCOR_CHANGE | CyCOR3ch, index); |
3834 | void __iomem *base_addr; | 3909 | CY_UNLOCK(info, flags); |
3835 | int card,channel,chip,index; | 3910 | } else { |
3836 | unsigned long tmp; | 3911 | /* Nothing to do! */ |
3837 | 3912 | } | |
3838 | card = info->card; | ||
3839 | channel = info->line - cy_card[card].first_line; | ||
3840 | if (!IS_CYC_Z(cy_card[card])) { | ||
3841 | chip = channel>>2; | ||
3842 | channel &= 0x03; | ||
3843 | index = cy_card[card].bus_index; | ||
3844 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
3845 | |||
3846 | tmp = cy_readb(base_addr+(CyCOR3<<index)) & CyREC_FIFO; | ||
3847 | return put_user(tmp,value); | ||
3848 | } else { | ||
3849 | // Nothing to do! | ||
3850 | return 0; | 3913 | return 0; |
3851 | } | 3914 | } /* set_threshold */ |
3852 | }/* get_threshold */ | ||
3853 | |||
3854 | 3915 | ||
3855 | static int | 3916 | static int |
3856 | set_default_threshold(struct cyclades_port * info, unsigned long value) | 3917 | get_threshold(struct cyclades_port *info, unsigned long __user * value) |
3857 | { | 3918 | { |
3858 | info->default_threshold = value & 0x0f; | 3919 | void __iomem *base_addr; |
3859 | return 0; | 3920 | int card, channel, chip, index; |
3860 | }/* set_default_threshold */ | 3921 | unsigned long tmp; |
3861 | 3922 | ||
3923 | card = info->card; | ||
3924 | channel = info->line - cy_card[card].first_line; | ||
3925 | if (!IS_CYC_Z(cy_card[card])) { | ||
3926 | chip = channel >> 2; | ||
3927 | channel &= 0x03; | ||
3928 | index = cy_card[card].bus_index; | ||
3929 | base_addr = | ||
3930 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); | ||
3931 | |||
3932 | tmp = cy_readb(base_addr + (CyCOR3 << index)) & CyREC_FIFO; | ||
3933 | return put_user(tmp, value); | ||
3934 | } else { | ||
3935 | /* Nothing to do! */ | ||
3936 | return 0; | ||
3937 | } | ||
3938 | } /* get_threshold */ | ||
3862 | 3939 | ||
3863 | static int | 3940 | static int |
3864 | get_default_threshold(struct cyclades_port * info, unsigned long __user *value) | 3941 | set_default_threshold(struct cyclades_port *info, unsigned long value) |
3865 | { | 3942 | { |
3866 | return put_user(info->default_threshold,value); | 3943 | info->default_threshold = value & 0x0f; |
3867 | }/* get_default_threshold */ | 3944 | return 0; |
3868 | 3945 | } /* set_default_threshold */ | |
3869 | 3946 | ||
3870 | static int | 3947 | static int |
3871 | set_timeout(struct cyclades_port * info, unsigned long value) | 3948 | get_default_threshold(struct cyclades_port *info, unsigned long __user * value) |
3872 | { | 3949 | { |
3873 | void __iomem *base_addr; | 3950 | return put_user(info->default_threshold, value); |
3874 | int card,channel,chip,index; | 3951 | } /* get_default_threshold */ |
3875 | unsigned long flags; | ||
3876 | |||
3877 | card = info->card; | ||
3878 | channel = info->line - cy_card[card].first_line; | ||
3879 | if (!IS_CYC_Z(cy_card[card])) { | ||
3880 | chip = channel>>2; | ||
3881 | channel &= 0x03; | ||
3882 | index = cy_card[card].bus_index; | ||
3883 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
3884 | 3952 | ||
3885 | CY_LOCK(info, flags); | 3953 | static int set_timeout(struct cyclades_port *info, unsigned long value) |
3886 | cy_writeb(base_addr+(CyRTPR<<index), value & 0xff); | 3954 | { |
3887 | CY_UNLOCK(info, flags); | 3955 | void __iomem *base_addr; |
3888 | } else { | 3956 | int card, channel, chip, index; |
3889 | // Nothing to do! | 3957 | unsigned long flags; |
3890 | } | ||
3891 | return 0; | ||
3892 | }/* set_timeout */ | ||
3893 | 3958 | ||
3959 | card = info->card; | ||
3960 | channel = info->line - cy_card[card].first_line; | ||
3961 | if (!IS_CYC_Z(cy_card[card])) { | ||
3962 | chip = channel >> 2; | ||
3963 | channel &= 0x03; | ||
3964 | index = cy_card[card].bus_index; | ||
3965 | base_addr = | ||
3966 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); | ||
3894 | 3967 | ||
3895 | static int | 3968 | CY_LOCK(info, flags); |
3896 | get_timeout(struct cyclades_port * info, unsigned long __user *value) | 3969 | cy_writeb(base_addr + (CyRTPR << index), value & 0xff); |
3897 | { | 3970 | CY_UNLOCK(info, flags); |
3898 | void __iomem *base_addr; | 3971 | } else { |
3899 | int card,channel,chip,index; | 3972 | /* Nothing to do! */ |
3900 | unsigned long tmp; | 3973 | } |
3901 | |||
3902 | card = info->card; | ||
3903 | channel = info->line - cy_card[card].first_line; | ||
3904 | if (!IS_CYC_Z(cy_card[card])) { | ||
3905 | chip = channel>>2; | ||
3906 | channel &= 0x03; | ||
3907 | index = cy_card[card].bus_index; | ||
3908 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
3909 | |||
3910 | tmp = cy_readb(base_addr+(CyRTPR<<index)); | ||
3911 | return put_user(tmp,value); | ||
3912 | } else { | ||
3913 | // Nothing to do! | ||
3914 | return 0; | 3974 | return 0; |
3915 | } | 3975 | } /* set_timeout */ |
3916 | }/* get_timeout */ | ||
3917 | |||
3918 | 3976 | ||
3919 | static int | 3977 | static int get_timeout(struct cyclades_port *info, unsigned long __user * value) |
3920 | set_default_timeout(struct cyclades_port * info, unsigned long value) | ||
3921 | { | 3978 | { |
3922 | info->default_timeout = value & 0xff; | 3979 | void __iomem *base_addr; |
3923 | return 0; | 3980 | int card, channel, chip, index; |
3924 | }/* set_default_timeout */ | 3981 | unsigned long tmp; |
3925 | 3982 | ||
3983 | card = info->card; | ||
3984 | channel = info->line - cy_card[card].first_line; | ||
3985 | if (!IS_CYC_Z(cy_card[card])) { | ||
3986 | chip = channel >> 2; | ||
3987 | channel &= 0x03; | ||
3988 | index = cy_card[card].bus_index; | ||
3989 | base_addr = | ||
3990 | cy_card[card].base_addr + (cy_chip_offset[chip] << index); | ||
3991 | |||
3992 | tmp = cy_readb(base_addr + (CyRTPR << index)); | ||
3993 | return put_user(tmp, value); | ||
3994 | } else { | ||
3995 | /* Nothing to do! */ | ||
3996 | return 0; | ||
3997 | } | ||
3998 | } /* get_timeout */ | ||
3999 | |||
4000 | static int set_default_timeout(struct cyclades_port *info, unsigned long value) | ||
4001 | { | ||
4002 | info->default_timeout = value & 0xff; | ||
4003 | return 0; | ||
4004 | } /* set_default_timeout */ | ||
3926 | 4005 | ||
3927 | static int | 4006 | static int |
3928 | get_default_timeout(struct cyclades_port * info, unsigned long __user *value) | 4007 | get_default_timeout(struct cyclades_port *info, unsigned long __user * value) |
3929 | { | 4008 | { |
3930 | return put_user(info->default_timeout,value); | 4009 | return put_user(info->default_timeout, value); |
3931 | }/* get_default_timeout */ | 4010 | } /* get_default_timeout */ |
3932 | 4011 | ||
3933 | /* | 4012 | /* |
3934 | * This routine allows the tty driver to implement device- | 4013 | * This routine allows the tty driver to implement device- |
@@ -3936,184 +4015,193 @@ get_default_timeout(struct cyclades_port * info, unsigned long __user *value) | |||
3936 | * not recognized by the driver, it should return ENOIOCTLCMD. | 4015 | * not recognized by the driver, it should return ENOIOCTLCMD. |
3937 | */ | 4016 | */ |
3938 | static int | 4017 | static int |
3939 | cy_ioctl(struct tty_struct *tty, struct file * file, | 4018 | cy_ioctl(struct tty_struct *tty, struct file *file, |
3940 | unsigned int cmd, unsigned long arg) | 4019 | unsigned int cmd, unsigned long arg) |
3941 | { | 4020 | { |
3942 | struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; | 4021 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
3943 | struct cyclades_icount cprev, cnow; /* kernel counter temps */ | 4022 | struct cyclades_icount cprev, cnow; /* kernel counter temps */ |
3944 | struct serial_icounter_struct __user *p_cuser; /* user space */ | 4023 | struct serial_icounter_struct __user *p_cuser; /* user space */ |
3945 | int ret_val = 0; | 4024 | int ret_val = 0; |
3946 | unsigned long flags; | 4025 | unsigned long flags; |
3947 | void __user *argp = (void __user *)arg; | 4026 | void __user *argp = (void __user *)arg; |
3948 | 4027 | ||
3949 | if (serial_paranoia_check(info, tty->name, "cy_ioctl")) | 4028 | if (serial_paranoia_check(info, tty->name, "cy_ioctl")) |
3950 | return -ENODEV; | 4029 | return -ENODEV; |
3951 | 4030 | ||
3952 | #ifdef CY_DEBUG_OTHER | 4031 | #ifdef CY_DEBUG_OTHER |
3953 | printk("cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n", | 4032 | printk("cyc:cy_ioctl ttyC%d, cmd = %x arg = %lx\n", info->line, cmd, arg); /* */ |
3954 | info->line, cmd, arg); /* */ | ||
3955 | #endif | 4033 | #endif |
3956 | 4034 | ||
3957 | switch (cmd) { | 4035 | switch (cmd) { |
3958 | case CYGETMON: | 4036 | case CYGETMON: |
3959 | ret_val = get_mon_info(info, argp); | 4037 | ret_val = get_mon_info(info, argp); |
3960 | break; | 4038 | break; |
3961 | case CYGETTHRESH: | 4039 | case CYGETTHRESH: |
3962 | ret_val = get_threshold(info, argp); | 4040 | ret_val = get_threshold(info, argp); |
3963 | break; | 4041 | break; |
3964 | case CYSETTHRESH: | 4042 | case CYSETTHRESH: |
3965 | ret_val = set_threshold(info, arg); | 4043 | ret_val = set_threshold(info, arg); |
3966 | break; | 4044 | break; |
3967 | case CYGETDEFTHRESH: | 4045 | case CYGETDEFTHRESH: |
3968 | ret_val = get_default_threshold(info, argp); | 4046 | ret_val = get_default_threshold(info, argp); |
3969 | break; | 4047 | break; |
3970 | case CYSETDEFTHRESH: | 4048 | case CYSETDEFTHRESH: |
3971 | ret_val = set_default_threshold(info, arg); | 4049 | ret_val = set_default_threshold(info, arg); |
3972 | break; | 4050 | break; |
3973 | case CYGETTIMEOUT: | 4051 | case CYGETTIMEOUT: |
3974 | ret_val = get_timeout(info, argp); | 4052 | ret_val = get_timeout(info, argp); |
3975 | break; | 4053 | break; |
3976 | case CYSETTIMEOUT: | 4054 | case CYSETTIMEOUT: |
3977 | ret_val = set_timeout(info, arg); | 4055 | ret_val = set_timeout(info, arg); |
3978 | break; | 4056 | break; |
3979 | case CYGETDEFTIMEOUT: | 4057 | case CYGETDEFTIMEOUT: |
3980 | ret_val = get_default_timeout(info, argp); | 4058 | ret_val = get_default_timeout(info, argp); |
3981 | break; | 4059 | break; |
3982 | case CYSETDEFTIMEOUT: | 4060 | case CYSETDEFTIMEOUT: |
3983 | ret_val = set_default_timeout(info, arg); | 4061 | ret_val = set_default_timeout(info, arg); |
3984 | break; | 4062 | break; |
3985 | case CYSETRFLOW: | 4063 | case CYSETRFLOW: |
3986 | info->rflow = (int)arg; | 4064 | info->rflow = (int)arg; |
3987 | ret_val = 0; | 4065 | ret_val = 0; |
3988 | break; | 4066 | break; |
3989 | case CYGETRFLOW: | 4067 | case CYGETRFLOW: |
3990 | ret_val = info->rflow; | 4068 | ret_val = info->rflow; |
3991 | break; | 4069 | break; |
3992 | case CYSETRTSDTR_INV: | 4070 | case CYSETRTSDTR_INV: |
3993 | info->rtsdtr_inv = (int)arg; | 4071 | info->rtsdtr_inv = (int)arg; |
3994 | ret_val = 0; | 4072 | ret_val = 0; |
3995 | break; | 4073 | break; |
3996 | case CYGETRTSDTR_INV: | 4074 | case CYGETRTSDTR_INV: |
3997 | ret_val = info->rtsdtr_inv; | 4075 | ret_val = info->rtsdtr_inv; |
3998 | break; | 4076 | break; |
3999 | case CYGETCARDINFO: | 4077 | case CYGETCARDINFO: |
4000 | if (copy_to_user(argp, &cy_card[info->card], | 4078 | if (copy_to_user(argp, &cy_card[info->card], |
4001 | sizeof (struct cyclades_card))) { | 4079 | sizeof(struct cyclades_card))) { |
4002 | ret_val = -EFAULT; | 4080 | ret_val = -EFAULT; |
4081 | break; | ||
4082 | } | ||
4083 | ret_val = 0; | ||
4003 | break; | 4084 | break; |
4004 | } | ||
4005 | ret_val = 0; | ||
4006 | break; | ||
4007 | case CYGETCD1400VER: | 4085 | case CYGETCD1400VER: |
4008 | ret_val = info->chip_rev; | 4086 | ret_val = info->chip_rev; |
4009 | break; | 4087 | break; |
4010 | #ifndef CONFIG_CYZ_INTR | 4088 | #ifndef CONFIG_CYZ_INTR |
4011 | case CYZSETPOLLCYCLE: | 4089 | case CYZSETPOLLCYCLE: |
4012 | cyz_polling_cycle = (arg * HZ) / 1000; | 4090 | cyz_polling_cycle = (arg * HZ) / 1000; |
4013 | ret_val = 0; | 4091 | ret_val = 0; |
4014 | break; | 4092 | break; |
4015 | case CYZGETPOLLCYCLE: | 4093 | case CYZGETPOLLCYCLE: |
4016 | ret_val = (cyz_polling_cycle * 1000) / HZ; | 4094 | ret_val = (cyz_polling_cycle * 1000) / HZ; |
4017 | break; | 4095 | break; |
4018 | #endif /* CONFIG_CYZ_INTR */ | 4096 | #endif /* CONFIG_CYZ_INTR */ |
4019 | case CYSETWAIT: | 4097 | case CYSETWAIT: |
4020 | info->closing_wait = (unsigned short)arg * HZ/100; | 4098 | info->closing_wait = (unsigned short)arg *HZ / 100; |
4021 | ret_val = 0; | 4099 | ret_val = 0; |
4022 | break; | 4100 | break; |
4023 | case CYGETWAIT: | 4101 | case CYGETWAIT: |
4024 | ret_val = info->closing_wait / (HZ/100); | 4102 | ret_val = info->closing_wait / (HZ / 100); |
4025 | break; | 4103 | break; |
4026 | case TIOCGSERIAL: | 4104 | case TIOCGSERIAL: |
4027 | ret_val = get_serial_info(info, argp); | 4105 | ret_val = get_serial_info(info, argp); |
4028 | break; | 4106 | break; |
4029 | case TIOCSSERIAL: | 4107 | case TIOCSSERIAL: |
4030 | ret_val = set_serial_info(info, argp); | 4108 | ret_val = set_serial_info(info, argp); |
4031 | break; | 4109 | break; |
4032 | case TIOCSERGETLSR: /* Get line status register */ | 4110 | case TIOCSERGETLSR: /* Get line status register */ |
4033 | ret_val = get_lsr_info(info, argp); | 4111 | ret_val = get_lsr_info(info, argp); |
4034 | break; | 4112 | break; |
4035 | /* | 4113 | /* |
4036 | * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change | 4114 | * Wait for any of the 4 modem inputs (DCD,RI,DSR,CTS) to change |
4037 | * - mask passed in arg for lines of interest | 4115 | * - mask passed in arg for lines of interest |
4038 | * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) | 4116 | * (use |'ed TIOCM_RNG/DSR/CD/CTS for masking) |
4039 | * Caller should use TIOCGICOUNT to see which one it was | 4117 | * Caller should use TIOCGICOUNT to see which one it was |
4040 | */ | 4118 | */ |
4041 | case TIOCMIWAIT: | 4119 | case TIOCMIWAIT: |
4042 | CY_LOCK(info, flags); | ||
4043 | /* note the counters on entry */ | ||
4044 | cprev = info->icount; | ||
4045 | CY_UNLOCK(info, flags); | ||
4046 | while (1) { | ||
4047 | interruptible_sleep_on(&info->delta_msr_wait); | ||
4048 | /* see if a signal did it */ | ||
4049 | if (signal_pending(current)) { | ||
4050 | return -ERESTARTSYS; | ||
4051 | } | ||
4052 | |||
4053 | CY_LOCK(info, flags); | 4120 | CY_LOCK(info, flags); |
4054 | cnow = info->icount; /* atomic copy */ | 4121 | /* note the counters on entry */ |
4122 | cprev = info->icount; | ||
4055 | CY_UNLOCK(info, flags); | 4123 | CY_UNLOCK(info, flags); |
4124 | while (1) { | ||
4125 | interruptible_sleep_on(&info->delta_msr_wait); | ||
4126 | /* see if a signal did it */ | ||
4127 | if (signal_pending(current)) { | ||
4128 | return -ERESTARTSYS; | ||
4129 | } | ||
4056 | 4130 | ||
4057 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && | 4131 | CY_LOCK(info, flags); |
4058 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { | 4132 | cnow = info->icount; /* atomic copy */ |
4059 | return -EIO; /* no change => error */ | 4133 | CY_UNLOCK(info, flags); |
4060 | } | ||
4061 | if ( ((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || | ||
4062 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || | ||
4063 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | ||
4064 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts)) ) { | ||
4065 | return 0; | ||
4066 | } | ||
4067 | cprev = cnow; | ||
4068 | } | ||
4069 | /* NOTREACHED */ | ||
4070 | 4134 | ||
4071 | /* | 4135 | if (cnow.rng == cprev.rng && cnow.dsr == cprev.dsr && |
4072 | * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) | 4136 | cnow.dcd == cprev.dcd && cnow.cts == cprev.cts) { |
4073 | * Return: write counters to the user passed counter struct | 4137 | return -EIO; /* no change => error */ |
4074 | * NB: both 1->0 and 0->1 transitions are counted except for | 4138 | } |
4075 | * RI where only 0->1 is counted. | 4139 | if (((arg & TIOCM_RNG) && (cnow.rng != cprev.rng)) || |
4076 | */ | 4140 | ((arg & TIOCM_DSR) && (cnow.dsr != cprev.dsr)) || |
4141 | ((arg & TIOCM_CD) && (cnow.dcd != cprev.dcd)) || | ||
4142 | ((arg & TIOCM_CTS) && (cnow.cts != cprev.cts))) { | ||
4143 | return 0; | ||
4144 | } | ||
4145 | cprev = cnow; | ||
4146 | } | ||
4147 | /* NOTREACHED */ | ||
4148 | |||
4149 | /* | ||
4150 | * Get counter of input serial line interrupts (DCD,RI,DSR,CTS) | ||
4151 | * Return: write counters to the user passed counter struct | ||
4152 | * NB: both 1->0 and 0->1 transitions are counted except for | ||
4153 | * RI where only 0->1 is counted. | ||
4154 | */ | ||
4077 | case TIOCGICOUNT: | 4155 | case TIOCGICOUNT: |
4078 | CY_LOCK(info, flags); | 4156 | CY_LOCK(info, flags); |
4079 | cnow = info->icount; | 4157 | cnow = info->icount; |
4080 | CY_UNLOCK(info, flags); | 4158 | CY_UNLOCK(info, flags); |
4081 | p_cuser = argp; | 4159 | p_cuser = argp; |
4082 | ret_val = put_user(cnow.cts, &p_cuser->cts); | 4160 | ret_val = put_user(cnow.cts, &p_cuser->cts); |
4083 | if (ret_val) return ret_val; | 4161 | if (ret_val) |
4084 | ret_val = put_user(cnow.dsr, &p_cuser->dsr); | 4162 | return ret_val; |
4085 | if (ret_val) return ret_val; | 4163 | ret_val = put_user(cnow.dsr, &p_cuser->dsr); |
4086 | ret_val = put_user(cnow.rng, &p_cuser->rng); | 4164 | if (ret_val) |
4087 | if (ret_val) return ret_val; | 4165 | return ret_val; |
4088 | ret_val = put_user(cnow.dcd, &p_cuser->dcd); | 4166 | ret_val = put_user(cnow.rng, &p_cuser->rng); |
4089 | if (ret_val) return ret_val; | 4167 | if (ret_val) |
4090 | ret_val = put_user(cnow.rx, &p_cuser->rx); | 4168 | return ret_val; |
4091 | if (ret_val) return ret_val; | 4169 | ret_val = put_user(cnow.dcd, &p_cuser->dcd); |
4092 | ret_val = put_user(cnow.tx, &p_cuser->tx); | 4170 | if (ret_val) |
4093 | if (ret_val) return ret_val; | 4171 | return ret_val; |
4094 | ret_val = put_user(cnow.frame, &p_cuser->frame); | 4172 | ret_val = put_user(cnow.rx, &p_cuser->rx); |
4095 | if (ret_val) return ret_val; | 4173 | if (ret_val) |
4096 | ret_val = put_user(cnow.overrun, &p_cuser->overrun); | 4174 | return ret_val; |
4097 | if (ret_val) return ret_val; | 4175 | ret_val = put_user(cnow.tx, &p_cuser->tx); |
4098 | ret_val = put_user(cnow.parity, &p_cuser->parity); | 4176 | if (ret_val) |
4099 | if (ret_val) return ret_val; | 4177 | return ret_val; |
4100 | ret_val = put_user(cnow.brk, &p_cuser->brk); | 4178 | ret_val = put_user(cnow.frame, &p_cuser->frame); |
4101 | if (ret_val) return ret_val; | 4179 | if (ret_val) |
4102 | ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun); | 4180 | return ret_val; |
4103 | if (ret_val) return ret_val; | 4181 | ret_val = put_user(cnow.overrun, &p_cuser->overrun); |
4104 | ret_val = 0; | 4182 | if (ret_val) |
4105 | break; | 4183 | return ret_val; |
4106 | default: | 4184 | ret_val = put_user(cnow.parity, &p_cuser->parity); |
4107 | ret_val = -ENOIOCTLCMD; | 4185 | if (ret_val) |
4108 | } | 4186 | return ret_val; |
4187 | ret_val = put_user(cnow.brk, &p_cuser->brk); | ||
4188 | if (ret_val) | ||
4189 | return ret_val; | ||
4190 | ret_val = put_user(cnow.buf_overrun, &p_cuser->buf_overrun); | ||
4191 | if (ret_val) | ||
4192 | return ret_val; | ||
4193 | ret_val = 0; | ||
4194 | break; | ||
4195 | default: | ||
4196 | ret_val = -ENOIOCTLCMD; | ||
4197 | } | ||
4109 | 4198 | ||
4110 | #ifdef CY_DEBUG_OTHER | 4199 | #ifdef CY_DEBUG_OTHER |
4111 | printk(" cyc:cy_ioctl done\n"); | 4200 | printk(" cyc:cy_ioctl done\n"); |
4112 | #endif | 4201 | #endif |
4113 | 4202 | ||
4114 | return ret_val; | 4203 | return ret_val; |
4115 | } /* cy_ioctl */ | 4204 | } /* cy_ioctl */ |
4116 | |||
4117 | 4205 | ||
4118 | /* | 4206 | /* |
4119 | * This routine allows the tty driver to be notified when | 4207 | * This routine allows the tty driver to be notified when |
@@ -4121,66 +4209,64 @@ cy_ioctl(struct tty_struct *tty, struct file * file, | |||
4121 | * well-designed tty driver should be prepared to accept the case | 4209 | * well-designed tty driver should be prepared to accept the case |
4122 | * where old == NULL, and try to do something rational. | 4210 | * where old == NULL, and try to do something rational. |
4123 | */ | 4211 | */ |
4124 | static void | 4212 | static void cy_set_termios(struct tty_struct *tty, struct ktermios *old_termios) |
4125 | cy_set_termios(struct tty_struct *tty, struct termios * old_termios) | ||
4126 | { | 4213 | { |
4127 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 4214 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4128 | 4215 | ||
4129 | #ifdef CY_DEBUG_OTHER | 4216 | #ifdef CY_DEBUG_OTHER |
4130 | printk("cyc:cy_set_termios ttyC%d\n", info->line); | 4217 | printk("cyc:cy_set_termios ttyC%d\n", info->line); |
4131 | #endif | 4218 | #endif |
4132 | 4219 | ||
4133 | if ((tty->termios->c_cflag == old_termios->c_cflag) && | 4220 | if (tty->termios->c_cflag == old_termios->c_cflag && |
4134 | ((tty->termios->c_iflag & (IXON|IXANY)) == | 4221 | (tty->termios->c_iflag & (IXON | IXANY)) == |
4135 | (old_termios->c_iflag & (IXON|IXANY)))) | 4222 | (old_termios->c_iflag & (IXON | IXANY))) |
4136 | return; | 4223 | return; |
4137 | set_line_char(info); | 4224 | set_line_char(info); |
4138 | 4225 | ||
4139 | if ((old_termios->c_cflag & CRTSCTS) && | 4226 | if ((old_termios->c_cflag & CRTSCTS) && |
4140 | !(tty->termios->c_cflag & CRTSCTS)) { | 4227 | !(tty->termios->c_cflag & CRTSCTS)) { |
4141 | tty->hw_stopped = 0; | 4228 | tty->hw_stopped = 0; |
4142 | cy_start(tty); | 4229 | cy_start(tty); |
4143 | } | 4230 | } |
4144 | #if 0 | 4231 | #if 0 |
4145 | /* | 4232 | /* |
4146 | * No need to wake up processes in open wait, since they | 4233 | * No need to wake up processes in open wait, since they |
4147 | * sample the CLOCAL flag once, and don't recheck it. | 4234 | * sample the CLOCAL flag once, and don't recheck it. |
4148 | * XXX It's not clear whether the current behavior is correct | 4235 | * XXX It's not clear whether the current behavior is correct |
4149 | * or not. Hence, this may change..... | 4236 | * or not. Hence, this may change..... |
4150 | */ | 4237 | */ |
4151 | if (!(old_termios->c_cflag & CLOCAL) && | 4238 | if (!(old_termios->c_cflag & CLOCAL) && |
4152 | (tty->termios->c_cflag & CLOCAL)) | 4239 | (tty->termios->c_cflag & CLOCAL)) |
4153 | wake_up_interruptible(&info->open_wait); | 4240 | wake_up_interruptible(&info->open_wait); |
4154 | #endif | 4241 | #endif |
4155 | 4242 | } /* cy_set_termios */ | |
4156 | return; | ||
4157 | } /* cy_set_termios */ | ||
4158 | 4243 | ||
4159 | /* This function is used to send a high-priority XON/XOFF character to | 4244 | /* This function is used to send a high-priority XON/XOFF character to |
4160 | the device. | 4245 | the device. |
4161 | */ | 4246 | */ |
4162 | static void | 4247 | static void cy_send_xchar(struct tty_struct *tty, char ch) |
4163 | cy_send_xchar (struct tty_struct *tty, char ch) | ||
4164 | { | 4248 | { |
4165 | struct cyclades_port *info = (struct cyclades_port *) tty->driver_data; | 4249 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4166 | int card, channel; | 4250 | int card, channel; |
4167 | 4251 | ||
4168 | if (serial_paranoia_check (info, tty->name, "cy_send_xchar")) | 4252 | if (serial_paranoia_check(info, tty->name, "cy_send_xchar")) |
4169 | return; | 4253 | return; |
4170 | 4254 | ||
4171 | info->x_char = ch; | 4255 | info->x_char = ch; |
4172 | 4256 | ||
4173 | if (ch) | 4257 | if (ch) |
4174 | cy_start (tty); | 4258 | cy_start(tty); |
4175 | 4259 | ||
4176 | card = info->card; | 4260 | card = info->card; |
4177 | channel = info->line - cy_card[card].first_line; | 4261 | channel = info->line - cy_card[card].first_line; |
4178 | 4262 | ||
4179 | if (IS_CYC_Z (cy_card[card])) { | 4263 | if (IS_CYC_Z(cy_card[card])) { |
4180 | if (ch == STOP_CHAR (tty)) | 4264 | if (ch == STOP_CHAR(tty)) |
4181 | cyz_issue_cmd (&cy_card[card], channel, C_CM_SENDXOFF, 0L); | 4265 | cyz_issue_cmd(&cy_card[card], channel, C_CM_SENDXOFF, |
4182 | else if (ch == START_CHAR (tty)) | 4266 | 0L); |
4183 | cyz_issue_cmd (&cy_card[card], channel, C_CM_SENDXON, 0L); | 4267 | else if (ch == START_CHAR(tty)) |
4268 | cyz_issue_cmd(&cy_card[card], channel, C_CM_SENDXON, | ||
4269 | 0L); | ||
4184 | } | 4270 | } |
4185 | } | 4271 | } |
4186 | 4272 | ||
@@ -4188,260 +4274,248 @@ cy_send_xchar (struct tty_struct *tty, char ch) | |||
4188 | that incoming characters should be throttled because the input | 4274 | that incoming characters should be throttled because the input |
4189 | buffers are close to full. | 4275 | buffers are close to full. |
4190 | */ | 4276 | */ |
4191 | static void | 4277 | static void cy_throttle(struct tty_struct *tty) |
4192 | cy_throttle(struct tty_struct * tty) | ||
4193 | { | 4278 | { |
4194 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 4279 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4195 | unsigned long flags; | 4280 | unsigned long flags; |
4196 | void __iomem *base_addr; | 4281 | void __iomem *base_addr; |
4197 | int card,chip,channel,index; | 4282 | int card, chip, channel, index; |
4198 | 4283 | ||
4199 | #ifdef CY_DEBUG_THROTTLE | 4284 | #ifdef CY_DEBUG_THROTTLE |
4200 | char buf[64]; | 4285 | char buf[64]; |
4201 | 4286 | ||
4202 | printk("cyc:throttle %s: %d....ttyC%d\n", | 4287 | printk("cyc:throttle %s: %d....ttyC%d\n", tty_name(tty, buf), |
4203 | tty_name(tty, buf), | 4288 | tty->ldisc.chars_in_buffer(tty), info->line); |
4204 | tty->ldisc.chars_in_buffer(tty), info->line); | ||
4205 | #endif | 4289 | #endif |
4206 | 4290 | ||
4207 | if (serial_paranoia_check(info, tty->name, "cy_throttle")){ | 4291 | if (serial_paranoia_check(info, tty->name, "cy_throttle")) { |
4208 | return; | 4292 | return; |
4209 | } | 4293 | } |
4210 | 4294 | ||
4211 | card = info->card; | 4295 | card = info->card; |
4212 | |||
4213 | if (I_IXOFF(tty)) { | ||
4214 | if (!IS_CYC_Z (cy_card[card])) | ||
4215 | cy_send_xchar (tty, STOP_CHAR (tty)); | ||
4216 | else | ||
4217 | info->throttle = 1; | ||
4218 | } | ||
4219 | |||
4220 | if (tty->termios->c_cflag & CRTSCTS) { | ||
4221 | channel = info->line - cy_card[card].first_line; | ||
4222 | if (!IS_CYC_Z(cy_card[card])) { | ||
4223 | chip = channel>>2; | ||
4224 | channel &= 0x03; | ||
4225 | index = cy_card[card].bus_index; | ||
4226 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
4227 | |||
4228 | CY_LOCK(info, flags); | ||
4229 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | ||
4230 | if (info->rtsdtr_inv) { | ||
4231 | cy_writeb(base_addr+(CyMSVR2<<index), ~CyDTR); | ||
4232 | } else { | ||
4233 | cy_writeb(base_addr+(CyMSVR1<<index), ~CyRTS); | ||
4234 | } | ||
4235 | CY_UNLOCK(info, flags); | ||
4236 | } else { | ||
4237 | info->throttle = 1; | ||
4238 | } | ||
4239 | } | ||
4240 | 4296 | ||
4241 | return; | 4297 | if (I_IXOFF(tty)) { |
4242 | } /* cy_throttle */ | 4298 | if (!IS_CYC_Z(cy_card[card])) |
4299 | cy_send_xchar(tty, STOP_CHAR(tty)); | ||
4300 | else | ||
4301 | info->throttle = 1; | ||
4302 | } | ||
4243 | 4303 | ||
4304 | if (tty->termios->c_cflag & CRTSCTS) { | ||
4305 | channel = info->line - cy_card[card].first_line; | ||
4306 | if (!IS_CYC_Z(cy_card[card])) { | ||
4307 | chip = channel >> 2; | ||
4308 | channel &= 0x03; | ||
4309 | index = cy_card[card].bus_index; | ||
4310 | base_addr = cy_card[card].base_addr + | ||
4311 | (cy_chip_offset[chip] << index); | ||
4312 | |||
4313 | CY_LOCK(info, flags); | ||
4314 | cy_writeb(base_addr + (CyCAR << index), | ||
4315 | (u_char) channel); | ||
4316 | if (info->rtsdtr_inv) { | ||
4317 | cy_writeb(base_addr + (CyMSVR2 << index), | ||
4318 | ~CyDTR); | ||
4319 | } else { | ||
4320 | cy_writeb(base_addr + (CyMSVR1 << index), | ||
4321 | ~CyRTS); | ||
4322 | } | ||
4323 | CY_UNLOCK(info, flags); | ||
4324 | } else { | ||
4325 | info->throttle = 1; | ||
4326 | } | ||
4327 | } | ||
4328 | } /* cy_throttle */ | ||
4244 | 4329 | ||
4245 | /* | 4330 | /* |
4246 | * This routine notifies the tty driver that it should signal | 4331 | * This routine notifies the tty driver that it should signal |
4247 | * that characters can now be sent to the tty without fear of | 4332 | * that characters can now be sent to the tty without fear of |
4248 | * overrunning the input buffers of the line disciplines. | 4333 | * overrunning the input buffers of the line disciplines. |
4249 | */ | 4334 | */ |
4250 | static void | 4335 | static void cy_unthrottle(struct tty_struct *tty) |
4251 | cy_unthrottle(struct tty_struct * tty) | ||
4252 | { | 4336 | { |
4253 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 4337 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4254 | unsigned long flags; | 4338 | unsigned long flags; |
4255 | void __iomem *base_addr; | 4339 | void __iomem *base_addr; |
4256 | int card,chip,channel,index; | 4340 | int card, chip, channel, index; |
4257 | 4341 | ||
4258 | #ifdef CY_DEBUG_THROTTLE | 4342 | #ifdef CY_DEBUG_THROTTLE |
4259 | char buf[64]; | 4343 | char buf[64]; |
4260 | |||
4261 | printk("cyc:unthrottle %s: %d....ttyC%d\n", | ||
4262 | tty_name(tty, buf), | ||
4263 | tty->ldisc.chars_in_buffer(tty), info->line); | ||
4264 | #endif | ||
4265 | 4344 | ||
4266 | if (serial_paranoia_check(info, tty->name, "cy_unthrottle")){ | 4345 | printk("cyc:unthrottle %s: %d....ttyC%d\n", tty_name(tty, buf), |
4267 | return; | 4346 | tty->ldisc.chars_in_buffer(tty), info->line); |
4268 | } | 4347 | #endif |
4269 | 4348 | ||
4270 | if (I_IXOFF(tty)) { | 4349 | if (serial_paranoia_check(info, tty->name, "cy_unthrottle")) { |
4271 | if (info->x_char) | 4350 | return; |
4272 | info->x_char = 0; | ||
4273 | else | ||
4274 | cy_send_xchar (tty, START_CHAR (tty)); | ||
4275 | } | ||
4276 | |||
4277 | if (tty->termios->c_cflag & CRTSCTS) { | ||
4278 | card = info->card; | ||
4279 | channel = info->line - cy_card[card].first_line; | ||
4280 | if (!IS_CYC_Z(cy_card[card])) { | ||
4281 | chip = channel>>2; | ||
4282 | channel &= 0x03; | ||
4283 | index = cy_card[card].bus_index; | ||
4284 | base_addr = cy_card[card].base_addr + (cy_chip_offset[chip]<<index); | ||
4285 | |||
4286 | CY_LOCK(info, flags); | ||
4287 | cy_writeb(base_addr+(CyCAR<<index), (u_char)channel); | ||
4288 | if (info->rtsdtr_inv) { | ||
4289 | cy_writeb(base_addr+(CyMSVR2<<index), CyDTR); | ||
4290 | } else { | ||
4291 | cy_writeb(base_addr+(CyMSVR1<<index), CyRTS); | ||
4292 | } | ||
4293 | CY_UNLOCK(info, flags); | ||
4294 | } else { | ||
4295 | info->throttle = 0; | ||
4296 | } | 4351 | } |
4297 | } | ||
4298 | 4352 | ||
4299 | return; | 4353 | if (I_IXOFF(tty)) { |
4300 | } /* cy_unthrottle */ | 4354 | if (info->x_char) |
4355 | info->x_char = 0; | ||
4356 | else | ||
4357 | cy_send_xchar(tty, START_CHAR(tty)); | ||
4358 | } | ||
4301 | 4359 | ||
4360 | if (tty->termios->c_cflag & CRTSCTS) { | ||
4361 | card = info->card; | ||
4362 | channel = info->line - cy_card[card].first_line; | ||
4363 | if (!IS_CYC_Z(cy_card[card])) { | ||
4364 | chip = channel >> 2; | ||
4365 | channel &= 0x03; | ||
4366 | index = cy_card[card].bus_index; | ||
4367 | base_addr = cy_card[card].base_addr + | ||
4368 | (cy_chip_offset[chip] << index); | ||
4369 | |||
4370 | CY_LOCK(info, flags); | ||
4371 | cy_writeb(base_addr + (CyCAR << index), | ||
4372 | (u_char) channel); | ||
4373 | if (info->rtsdtr_inv) { | ||
4374 | cy_writeb(base_addr + (CyMSVR2 << index), | ||
4375 | CyDTR); | ||
4376 | } else { | ||
4377 | cy_writeb(base_addr + (CyMSVR1 << index), | ||
4378 | CyRTS); | ||
4379 | } | ||
4380 | CY_UNLOCK(info, flags); | ||
4381 | } else { | ||
4382 | info->throttle = 0; | ||
4383 | } | ||
4384 | } | ||
4385 | } /* cy_unthrottle */ | ||
4302 | 4386 | ||
4303 | /* cy_start and cy_stop provide software output flow control as a | 4387 | /* cy_start and cy_stop provide software output flow control as a |
4304 | function of XON/XOFF, software CTS, and other such stuff. | 4388 | function of XON/XOFF, software CTS, and other such stuff. |
4305 | */ | 4389 | */ |
4306 | static void | 4390 | static void cy_stop(struct tty_struct *tty) |
4307 | cy_stop(struct tty_struct *tty) | ||
4308 | { | 4391 | { |
4309 | struct cyclades_card *cinfo; | 4392 | struct cyclades_card *cinfo; |
4310 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 4393 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4311 | void __iomem *base_addr; | 4394 | void __iomem *base_addr; |
4312 | int chip,channel,index; | 4395 | int chip, channel, index; |
4313 | unsigned long flags; | 4396 | unsigned long flags; |
4314 | 4397 | ||
4315 | #ifdef CY_DEBUG_OTHER | 4398 | #ifdef CY_DEBUG_OTHER |
4316 | printk("cyc:cy_stop ttyC%d\n", info->line); /* */ | 4399 | printk("cyc:cy_stop ttyC%d\n", info->line); /* */ |
4317 | #endif | 4400 | #endif |
4318 | 4401 | ||
4319 | if (serial_paranoia_check(info, tty->name, "cy_stop")) | 4402 | if (serial_paranoia_check(info, tty->name, "cy_stop")) |
4320 | return; | 4403 | return; |
4321 | |||
4322 | cinfo = &cy_card[info->card]; | ||
4323 | channel = info->line - cinfo->first_line; | ||
4324 | if (!IS_CYC_Z(*cinfo)) { | ||
4325 | index = cinfo->bus_index; | ||
4326 | chip = channel>>2; | ||
4327 | channel &= 0x03; | ||
4328 | base_addr = cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index); | ||
4329 | |||
4330 | CY_LOCK(info, flags); | ||
4331 | cy_writeb(base_addr+(CyCAR<<index), | ||
4332 | (u_char)(channel & 0x0003)); /* index channel */ | ||
4333 | cy_writeb(base_addr+(CySRER<<index), | ||
4334 | cy_readb(base_addr+(CySRER<<index)) & ~CyTxRdy); | ||
4335 | CY_UNLOCK(info, flags); | ||
4336 | } else { | ||
4337 | // Nothing to do! | ||
4338 | } | ||
4339 | 4404 | ||
4340 | return; | 4405 | cinfo = &cy_card[info->card]; |
4341 | } /* cy_stop */ | 4406 | channel = info->line - cinfo->first_line; |
4407 | if (!IS_CYC_Z(*cinfo)) { | ||
4408 | index = cinfo->bus_index; | ||
4409 | chip = channel >> 2; | ||
4410 | channel &= 0x03; | ||
4411 | base_addr = cy_card[info->card].base_addr + | ||
4412 | (cy_chip_offset[chip] << index); | ||
4342 | 4413 | ||
4414 | CY_LOCK(info, flags); | ||
4415 | cy_writeb(base_addr + (CyCAR << index), | ||
4416 | (u_char)(channel & 0x0003)); /* index channel */ | ||
4417 | cy_writeb(base_addr + (CySRER << index), | ||
4418 | cy_readb(base_addr + (CySRER << index)) & ~CyTxRdy); | ||
4419 | CY_UNLOCK(info, flags); | ||
4420 | } else { | ||
4421 | /* Nothing to do! */ | ||
4422 | } | ||
4423 | } /* cy_stop */ | ||
4343 | 4424 | ||
4344 | static void | 4425 | static void cy_start(struct tty_struct *tty) |
4345 | cy_start(struct tty_struct *tty) | ||
4346 | { | 4426 | { |
4347 | struct cyclades_card *cinfo; | 4427 | struct cyclades_card *cinfo; |
4348 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 4428 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4349 | void __iomem *base_addr; | 4429 | void __iomem *base_addr; |
4350 | int chip,channel,index; | 4430 | int chip, channel, index; |
4351 | unsigned long flags; | 4431 | unsigned long flags; |
4352 | 4432 | ||
4353 | #ifdef CY_DEBUG_OTHER | 4433 | #ifdef CY_DEBUG_OTHER |
4354 | printk("cyc:cy_start ttyC%d\n", info->line); /* */ | 4434 | printk("cyc:cy_start ttyC%d\n", info->line); /* */ |
4355 | #endif | 4435 | #endif |
4356 | 4436 | ||
4357 | if (serial_paranoia_check(info, tty->name, "cy_start")) | 4437 | if (serial_paranoia_check(info, tty->name, "cy_start")) |
4358 | return; | 4438 | return; |
4359 | |||
4360 | cinfo = &cy_card[info->card]; | ||
4361 | channel = info->line - cinfo->first_line; | ||
4362 | index = cinfo->bus_index; | ||
4363 | if (!IS_CYC_Z(*cinfo)) { | ||
4364 | chip = channel>>2; | ||
4365 | channel &= 0x03; | ||
4366 | base_addr = cy_card[info->card].base_addr + (cy_chip_offset[chip]<<index); | ||
4367 | |||
4368 | CY_LOCK(info, flags); | ||
4369 | cy_writeb(base_addr+(CyCAR<<index), | ||
4370 | (u_char)(channel & 0x0003)); /* index channel */ | ||
4371 | cy_writeb(base_addr+(CySRER<<index), | ||
4372 | cy_readb(base_addr+(CySRER<<index)) | CyTxRdy); | ||
4373 | CY_UNLOCK(info, flags); | ||
4374 | } else { | ||
4375 | // Nothing to do! | ||
4376 | } | ||
4377 | 4439 | ||
4378 | return; | 4440 | cinfo = &cy_card[info->card]; |
4379 | } /* cy_start */ | 4441 | channel = info->line - cinfo->first_line; |
4442 | index = cinfo->bus_index; | ||
4443 | if (!IS_CYC_Z(*cinfo)) { | ||
4444 | chip = channel >> 2; | ||
4445 | channel &= 0x03; | ||
4446 | base_addr = cy_card[info->card].base_addr + | ||
4447 | (cy_chip_offset[chip] << index); | ||
4380 | 4448 | ||
4449 | CY_LOCK(info, flags); | ||
4450 | cy_writeb(base_addr + (CyCAR << index), (u_char) (channel & 0x0003)); /* index channel */ | ||
4451 | cy_writeb(base_addr + (CySRER << index), | ||
4452 | cy_readb(base_addr + (CySRER << index)) | CyTxRdy); | ||
4453 | CY_UNLOCK(info, flags); | ||
4454 | } else { | ||
4455 | /* Nothing to do! */ | ||
4456 | } | ||
4457 | } /* cy_start */ | ||
4381 | 4458 | ||
4382 | static void | 4459 | static void cy_flush_buffer(struct tty_struct *tty) |
4383 | cy_flush_buffer(struct tty_struct *tty) | ||
4384 | { | 4460 | { |
4385 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; | 4461 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4386 | int card, channel, retval; | 4462 | int card, channel, retval; |
4387 | unsigned long flags; | 4463 | unsigned long flags; |
4388 | 4464 | ||
4389 | #ifdef CY_DEBUG_IO | 4465 | #ifdef CY_DEBUG_IO |
4390 | printk("cyc:cy_flush_buffer ttyC%d\n", info->line); /* */ | 4466 | printk("cyc:cy_flush_buffer ttyC%d\n", info->line); /* */ |
4391 | #endif | 4467 | #endif |
4392 | 4468 | ||
4393 | if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) | 4469 | if (serial_paranoia_check(info, tty->name, "cy_flush_buffer")) |
4394 | return; | 4470 | return; |
4395 | |||
4396 | card = info->card; | ||
4397 | channel = (info->line) - (cy_card[card].first_line); | ||
4398 | 4471 | ||
4399 | CY_LOCK(info, flags); | 4472 | card = info->card; |
4400 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; | 4473 | channel = (info->line) - (cy_card[card].first_line); |
4401 | CY_UNLOCK(info, flags); | ||
4402 | 4474 | ||
4403 | if (IS_CYC_Z(cy_card[card])) { /* If it is a Z card, flush the on-board | ||
4404 | buffers as well */ | ||
4405 | CY_LOCK(info, flags); | 4475 | CY_LOCK(info, flags); |
4406 | retval = cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_TX, 0L); | 4476 | info->xmit_cnt = info->xmit_head = info->xmit_tail = 0; |
4407 | if (retval != 0) { | ||
4408 | printk("cyc: flush_buffer retval on ttyC%d was %x\n", | ||
4409 | info->line, retval); | ||
4410 | } | ||
4411 | CY_UNLOCK(info, flags); | 4477 | CY_UNLOCK(info, flags); |
4412 | } | ||
4413 | tty_wakeup(tty); | ||
4414 | wake_up_interruptible(&tty->write_wait); | ||
4415 | } /* cy_flush_buffer */ | ||
4416 | 4478 | ||
4479 | if (IS_CYC_Z(cy_card[card])) { /* If it is a Z card, flush the on-board | ||
4480 | buffers as well */ | ||
4481 | CY_LOCK(info, flags); | ||
4482 | retval = | ||
4483 | cyz_issue_cmd(&cy_card[card], channel, C_CM_FLUSH_TX, 0L); | ||
4484 | if (retval != 0) { | ||
4485 | printk("cyc: flush_buffer retval on ttyC%d was %x\n", | ||
4486 | info->line, retval); | ||
4487 | } | ||
4488 | CY_UNLOCK(info, flags); | ||
4489 | } | ||
4490 | tty_wakeup(tty); | ||
4491 | wake_up_interruptible(&tty->write_wait); | ||
4492 | } /* cy_flush_buffer */ | ||
4417 | 4493 | ||
4418 | /* | 4494 | /* |
4419 | * cy_hangup() --- called by tty_hangup() when a hangup is signaled. | 4495 | * cy_hangup() --- called by tty_hangup() when a hangup is signaled. |
4420 | */ | 4496 | */ |
4421 | static void | 4497 | static void cy_hangup(struct tty_struct *tty) |
4422 | cy_hangup(struct tty_struct *tty) | ||
4423 | { | 4498 | { |
4424 | struct cyclades_port * info = (struct cyclades_port *)tty->driver_data; | 4499 | struct cyclades_port *info = (struct cyclades_port *)tty->driver_data; |
4425 | 4500 | ||
4426 | #ifdef CY_DEBUG_OTHER | 4501 | #ifdef CY_DEBUG_OTHER |
4427 | printk("cyc:cy_hangup ttyC%d\n", info->line); /* */ | 4502 | printk("cyc:cy_hangup ttyC%d\n", info->line); /* */ |
4428 | #endif | 4503 | #endif |
4429 | 4504 | ||
4430 | if (serial_paranoia_check(info, tty->name, "cy_hangup")) | 4505 | if (serial_paranoia_check(info, tty->name, "cy_hangup")) |
4431 | return; | 4506 | return; |
4432 | 4507 | ||
4433 | cy_flush_buffer(tty); | 4508 | cy_flush_buffer(tty); |
4434 | shutdown(info); | 4509 | shutdown(info); |
4435 | info->event = 0; | 4510 | info->event = 0; |
4436 | info->count = 0; | 4511 | info->count = 0; |
4437 | #ifdef CY_DEBUG_COUNT | 4512 | #ifdef CY_DEBUG_COUNT |
4438 | printk("cyc:cy_hangup (%d): setting count to 0\n", current->pid); | 4513 | printk("cyc:cy_hangup (%d): setting count to 0\n", current->pid); |
4439 | #endif | 4514 | #endif |
4440 | info->tty = NULL; | 4515 | info->tty = NULL; |
4441 | info->flags &= ~ASYNC_NORMAL_ACTIVE; | 4516 | info->flags &= ~ASYNC_NORMAL_ACTIVE; |
4442 | wake_up_interruptible(&info->open_wait); | 4517 | wake_up_interruptible(&info->open_wait); |
4443 | } /* cy_hangup */ | 4518 | } /* cy_hangup */ |
4444 | |||
4445 | 4519 | ||
4446 | /* | 4520 | /* |
4447 | * --------------------------------------------------------------------- | 4521 | * --------------------------------------------------------------------- |
@@ -4454,82 +4528,84 @@ cy_hangup(struct tty_struct *tty) | |||
4454 | /* initialize chips on Cyclom-Y card -- return number of valid | 4528 | /* initialize chips on Cyclom-Y card -- return number of valid |
4455 | chips (which is number of ports/4) */ | 4529 | chips (which is number of ports/4) */ |
4456 | static unsigned short __init | 4530 | static unsigned short __init |
4457 | cyy_init_card(void __iomem *true_base_addr,int index) | 4531 | cyy_init_card(void __iomem * true_base_addr, int index) |
4458 | { | 4532 | { |
4459 | unsigned int chip_number; | 4533 | unsigned int chip_number; |
4460 | void __iomem *base_addr; | 4534 | void __iomem *base_addr; |
4461 | 4535 | ||
4462 | cy_writeb(true_base_addr+(Cy_HwReset<<index), 0); | 4536 | cy_writeb(true_base_addr + (Cy_HwReset << index), 0); |
4463 | /* Cy_HwReset is 0x1400 */ | 4537 | /* Cy_HwReset is 0x1400 */ |
4464 | cy_writeb(true_base_addr+(Cy_ClrIntr<<index), 0); | 4538 | cy_writeb(true_base_addr + (Cy_ClrIntr << index), 0); |
4465 | /* Cy_ClrIntr is 0x1800 */ | 4539 | /* Cy_ClrIntr is 0x1800 */ |
4466 | udelay(500L); | 4540 | udelay(500L); |
4467 | 4541 | ||
4468 | for(chip_number=0; chip_number<CyMAX_CHIPS_PER_CARD; chip_number++){ | 4542 | for (chip_number = 0; chip_number < CyMAX_CHIPS_PER_CARD; chip_number++) { |
4469 | base_addr = true_base_addr + (cy_chip_offset[chip_number]<<index); | 4543 | base_addr = |
4470 | mdelay(1); | 4544 | true_base_addr + (cy_chip_offset[chip_number] << index); |
4471 | if(cy_readb(base_addr+(CyCCR<<index)) != 0x00){ | 4545 | mdelay(1); |
4472 | /************* | 4546 | if (cy_readb(base_addr + (CyCCR << index)) != 0x00) { |
4473 | printk(" chip #%d at %#6lx is never idle (CCR != 0)\n", | 4547 | /************* |
4474 | chip_number, (unsigned long)base_addr); | 4548 | printk(" chip #%d at %#6lx is never idle (CCR != 0)\n", |
4475 | *************/ | 4549 | chip_number, (unsigned long)base_addr); |
4476 | return chip_number; | 4550 | *************/ |
4477 | } | 4551 | return chip_number; |
4478 | 4552 | } | |
4479 | cy_writeb(base_addr+(CyGFRCR<<index), 0); | 4553 | |
4480 | udelay(10L); | 4554 | cy_writeb(base_addr + (CyGFRCR << index), 0); |
4481 | 4555 | udelay(10L); | |
4482 | /* The Cyclom-16Y does not decode address bit 9 and therefore | 4556 | |
4483 | cannot distinguish between references to chip 0 and a non- | 4557 | /* The Cyclom-16Y does not decode address bit 9 and therefore |
4484 | existent chip 4. If the preceding clearing of the supposed | 4558 | cannot distinguish between references to chip 0 and a non- |
4485 | chip 4 GFRCR register appears at chip 0, there is no chip 4 | 4559 | existent chip 4. If the preceding clearing of the supposed |
4486 | and this must be a Cyclom-16Y, not a Cyclom-32Ye. | 4560 | chip 4 GFRCR register appears at chip 0, there is no chip 4 |
4487 | */ | 4561 | and this must be a Cyclom-16Y, not a Cyclom-32Ye. |
4488 | if (chip_number == 4 | 4562 | */ |
4489 | && cy_readb(true_base_addr | 4563 | if (chip_number == 4 && cy_readb(true_base_addr + |
4490 | + (cy_chip_offset[0]<<index) | 4564 | (cy_chip_offset[0] << index) + |
4491 | + (CyGFRCR<<index)) == 0){ | 4565 | (CyGFRCR << index)) == 0) { |
4492 | return chip_number; | 4566 | return chip_number; |
4493 | } | 4567 | } |
4494 | 4568 | ||
4495 | cy_writeb(base_addr+(CyCCR<<index), CyCHIP_RESET); | 4569 | cy_writeb(base_addr + (CyCCR << index), CyCHIP_RESET); |
4496 | mdelay(1); | 4570 | mdelay(1); |
4497 | |||
4498 | if(cy_readb(base_addr+(CyGFRCR<<index)) == 0x00){ | ||
4499 | /* | ||
4500 | printk(" chip #%d at %#6lx is not responding ", | ||
4501 | chip_number, (unsigned long)base_addr); | ||
4502 | printk("(GFRCR stayed 0)\n", | ||
4503 | */ | ||
4504 | return chip_number; | ||
4505 | } | ||
4506 | if((0xf0 & (cy_readb(base_addr+(CyGFRCR<<index)))) != 0x40){ | ||
4507 | /* | ||
4508 | printk(" chip #%d at %#6lx is not valid (GFRCR == %#2x)\n", | ||
4509 | chip_number, (unsigned long)base_addr, | ||
4510 | base_addr[CyGFRCR<<index]); | ||
4511 | */ | ||
4512 | return chip_number; | ||
4513 | } | ||
4514 | cy_writeb(base_addr+(CyGCR<<index), CyCH0_SERIAL); | ||
4515 | if (cy_readb(base_addr+(CyGFRCR<<index)) >= CD1400_REV_J){ | ||
4516 | /* It is a CD1400 rev. J or later */ | ||
4517 | /* Impossible to reach 5ms with this chip. | ||
4518 | Changed to 2ms instead (f = 500 Hz). */ | ||
4519 | cy_writeb(base_addr+(CyPPR<<index), CyCLOCK_60_2MS); | ||
4520 | } else { | ||
4521 | /* f = 200 Hz */ | ||
4522 | cy_writeb(base_addr+(CyPPR<<index), CyCLOCK_25_5MS); | ||
4523 | } | ||
4524 | 4571 | ||
4525 | /* | 4572 | if (cy_readb(base_addr + (CyGFRCR << index)) == 0x00) { |
4526 | printk(" chip #%d at %#6lx is rev 0x%2x\n", | 4573 | /* |
4527 | chip_number, (unsigned long)base_addr, | 4574 | printk(" chip #%d at %#6lx is not responding ", |
4528 | cy_readb(base_addr+(CyGFRCR<<index))); | 4575 | chip_number, (unsigned long)base_addr); |
4529 | */ | 4576 | printk("(GFRCR stayed 0)\n", |
4530 | } | 4577 | */ |
4531 | return chip_number; | 4578 | return chip_number; |
4532 | } /* cyy_init_card */ | 4579 | } |
4580 | if ((0xf0 & (cy_readb(base_addr + (CyGFRCR << index)))) != | ||
4581 | 0x40) { | ||
4582 | /* | ||
4583 | printk(" chip #%d at %#6lx is not valid (GFRCR == " | ||
4584 | "%#2x)\n", | ||
4585 | chip_number, (unsigned long)base_addr, | ||
4586 | base_addr[CyGFRCR<<index]); | ||
4587 | */ | ||
4588 | return chip_number; | ||
4589 | } | ||
4590 | cy_writeb(base_addr + (CyGCR << index), CyCH0_SERIAL); | ||
4591 | if (cy_readb(base_addr + (CyGFRCR << index)) >= CD1400_REV_J) { | ||
4592 | /* It is a CD1400 rev. J or later */ | ||
4593 | /* Impossible to reach 5ms with this chip. | ||
4594 | Changed to 2ms instead (f = 500 Hz). */ | ||
4595 | cy_writeb(base_addr + (CyPPR << index), CyCLOCK_60_2MS); | ||
4596 | } else { | ||
4597 | /* f = 200 Hz */ | ||
4598 | cy_writeb(base_addr + (CyPPR << index), CyCLOCK_25_5MS); | ||
4599 | } | ||
4600 | |||
4601 | /* | ||
4602 | printk(" chip #%d at %#6lx is rev 0x%2x\n", | ||
4603 | chip_number, (unsigned long)base_addr, | ||
4604 | cy_readb(base_addr+(CyGFRCR<<index))); | ||
4605 | */ | ||
4606 | } | ||
4607 | return chip_number; | ||
4608 | } /* cyy_init_card */ | ||
4533 | 4609 | ||
4534 | /* | 4610 | /* |
4535 | * --------------------------------------------------------------------- | 4611 | * --------------------------------------------------------------------- |
@@ -4537,126 +4613,124 @@ cyy_init_card(void __iomem *true_base_addr,int index) | |||
4537 | * sets global variables and return the number of ISA boards found. | 4613 | * sets global variables and return the number of ISA boards found. |
4538 | * --------------------------------------------------------------------- | 4614 | * --------------------------------------------------------------------- |
4539 | */ | 4615 | */ |
4540 | static int __init | 4616 | static int __init cy_detect_isa(void) |
4541 | cy_detect_isa(void) | ||
4542 | { | 4617 | { |
4543 | #ifdef CONFIG_ISA | 4618 | #ifdef CONFIG_ISA |
4544 | unsigned short cy_isa_irq,nboard; | 4619 | unsigned short cy_isa_irq, nboard; |
4545 | void __iomem *cy_isa_address; | 4620 | void __iomem *cy_isa_address; |
4546 | unsigned short i,j,cy_isa_nchan; | 4621 | unsigned short i, j, cy_isa_nchan; |
4547 | #ifdef MODULE | 4622 | #ifdef MODULE |
4548 | int isparam = 0; | 4623 | int isparam = 0; |
4549 | #endif | 4624 | #endif |
4550 | 4625 | ||
4551 | nboard = 0; | 4626 | nboard = 0; |
4552 | 4627 | ||
4553 | #ifdef MODULE | 4628 | #ifdef MODULE |
4554 | /* Check for module parameters */ | 4629 | /* Check for module parameters */ |
4555 | for(i = 0 ; i < NR_CARDS; i++) { | 4630 | for (i = 0; i < NR_CARDS; i++) { |
4556 | if (maddr[i] || i) { | 4631 | if (maddr[i] || i) { |
4557 | isparam = 1; | 4632 | isparam = 1; |
4558 | cy_isa_addresses[i] = maddr[i]; | 4633 | cy_isa_addresses[i] = maddr[i]; |
4559 | } | 4634 | } |
4560 | if (!maddr[i]) | 4635 | if (!maddr[i]) |
4561 | break; | 4636 | break; |
4562 | } | 4637 | } |
4563 | #endif | 4638 | #endif |
4564 | 4639 | ||
4565 | /* scan the address table probing for Cyclom-Y/ISA boards */ | 4640 | /* scan the address table probing for Cyclom-Y/ISA boards */ |
4566 | for (i = 0 ; i < NR_ISA_ADDRS ; i++) { | 4641 | for (i = 0; i < NR_ISA_ADDRS; i++) { |
4567 | unsigned int isa_address = cy_isa_addresses[i]; | 4642 | unsigned int isa_address = cy_isa_addresses[i]; |
4568 | if (isa_address == 0x0000) { | 4643 | if (isa_address == 0x0000) { |
4569 | return(nboard); | 4644 | return nboard; |
4570 | } | 4645 | } |
4571 | 4646 | ||
4572 | /* probe for CD1400... */ | 4647 | /* probe for CD1400... */ |
4573 | cy_isa_address = ioremap(isa_address, CyISA_Ywin); | 4648 | cy_isa_address = ioremap(isa_address, CyISA_Ywin); |
4574 | cy_isa_nchan = CyPORTS_PER_CHIP * | 4649 | cy_isa_nchan = CyPORTS_PER_CHIP * |
4575 | cyy_init_card(cy_isa_address,0); | 4650 | cyy_init_card(cy_isa_address, 0); |
4576 | if (cy_isa_nchan == 0) { | 4651 | if (cy_isa_nchan == 0) { |
4577 | continue; | 4652 | continue; |
4578 | } | 4653 | } |
4579 | |||
4580 | #ifdef MODULE | 4654 | #ifdef MODULE |
4581 | if (isparam && irq[i]) | 4655 | if (isparam && irq[i]) |
4582 | cy_isa_irq = irq[i]; | 4656 | cy_isa_irq = irq[i]; |
4583 | else | 4657 | else |
4584 | #endif | 4658 | #endif |
4585 | /* find out the board's irq by probing */ | 4659 | /* find out the board's irq by probing */ |
4586 | cy_isa_irq = detect_isa_irq(cy_isa_address); | 4660 | cy_isa_irq = detect_isa_irq(cy_isa_address); |
4587 | if (cy_isa_irq == 0) { | 4661 | if (cy_isa_irq == 0) { |
4588 | printk("Cyclom-Y/ISA found at 0x%lx ", | 4662 | printk("Cyclom-Y/ISA found at 0x%lx ", |
4589 | (unsigned long) cy_isa_address); | 4663 | (unsigned long)cy_isa_address); |
4590 | printk("but the IRQ could not be detected.\n"); | 4664 | printk("but the IRQ could not be detected.\n"); |
4591 | continue; | 4665 | continue; |
4592 | } | 4666 | } |
4593 | 4667 | ||
4594 | if((cy_next_channel+cy_isa_nchan) > NR_PORTS) { | 4668 | if ((cy_next_channel + cy_isa_nchan) > NR_PORTS) { |
4595 | printk("Cyclom-Y/ISA found at 0x%lx ", | 4669 | printk("Cyclom-Y/ISA found at 0x%lx ", |
4596 | (unsigned long) cy_isa_address); | 4670 | (unsigned long)cy_isa_address); |
4597 | printk("but no more channels are available.\n"); | 4671 | printk("but no more channels are available.\n"); |
4598 | printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); | 4672 | printk("Change NR_PORTS in cyclades.c and recompile " |
4599 | return(nboard); | 4673 | "kernel.\n"); |
4600 | } | 4674 | return nboard; |
4601 | /* fill the next cy_card structure available */ | 4675 | } |
4602 | for (j = 0 ; j < NR_CARDS ; j++) { | 4676 | /* fill the next cy_card structure available */ |
4603 | if (cy_card[j].base_addr == 0) break; | 4677 | for (j = 0; j < NR_CARDS; j++) { |
4604 | } | 4678 | if (cy_card[j].base_addr == 0) |
4605 | if (j == NR_CARDS) { /* no more cy_cards available */ | 4679 | break; |
4606 | printk("Cyclom-Y/ISA found at 0x%lx ", | 4680 | } |
4607 | (unsigned long) cy_isa_address); | 4681 | if (j == NR_CARDS) { /* no more cy_cards available */ |
4608 | printk("but no more cards can be used .\n"); | 4682 | printk("Cyclom-Y/ISA found at 0x%lx ", |
4609 | printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); | 4683 | (unsigned long)cy_isa_address); |
4610 | return(nboard); | 4684 | printk("but no more cards can be used .\n"); |
4611 | } | 4685 | printk("Change NR_CARDS in cyclades.c and recompile " |
4612 | 4686 | "kernel.\n"); | |
4613 | /* allocate IRQ */ | 4687 | return nboard; |
4614 | if(request_irq(cy_isa_irq, cyy_interrupt, | 4688 | } |
4615 | IRQF_DISABLED, "Cyclom-Y", &cy_card[j])) | 4689 | |
4616 | { | 4690 | /* allocate IRQ */ |
4617 | printk("Cyclom-Y/ISA found at 0x%lx ", | 4691 | if (request_irq(cy_isa_irq, cyy_interrupt, |
4618 | (unsigned long) cy_isa_address); | 4692 | IRQF_DISABLED, "Cyclom-Y", &cy_card[j])) { |
4619 | printk("but could not allocate IRQ#%d.\n", | 4693 | printk("Cyclom-Y/ISA found at 0x%lx ", |
4620 | cy_isa_irq); | 4694 | (unsigned long)cy_isa_address); |
4621 | return(nboard); | 4695 | printk("but could not allocate IRQ#%d.\n", cy_isa_irq); |
4622 | } | 4696 | return nboard; |
4623 | 4697 | } | |
4624 | /* set cy_card */ | 4698 | |
4625 | cy_card[j].base_addr = cy_isa_address; | 4699 | /* set cy_card */ |
4626 | cy_card[j].ctl_addr = NULL; | 4700 | cy_card[j].base_addr = cy_isa_address; |
4627 | cy_card[j].irq = (int) cy_isa_irq; | 4701 | cy_card[j].ctl_addr = NULL; |
4628 | cy_card[j].bus_index = 0; | 4702 | cy_card[j].irq = (int)cy_isa_irq; |
4629 | cy_card[j].first_line = cy_next_channel; | 4703 | cy_card[j].bus_index = 0; |
4630 | cy_card[j].num_chips = cy_isa_nchan/4; | 4704 | cy_card[j].first_line = cy_next_channel; |
4631 | nboard++; | 4705 | cy_card[j].num_chips = cy_isa_nchan / 4; |
4632 | 4706 | nboard++; | |
4633 | /* print message */ | 4707 | |
4634 | printk("Cyclom-Y/ISA #%d: 0x%lx-0x%lx, IRQ%d, ", | 4708 | /* print message */ |
4635 | j+1, (unsigned long) cy_isa_address, | 4709 | printk("Cyclom-Y/ISA #%d: 0x%lx-0x%lx, IRQ%d, ", |
4636 | (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)), | 4710 | j + 1, (unsigned long)cy_isa_address, |
4637 | cy_isa_irq); | 4711 | (unsigned long)(cy_isa_address + (CyISA_Ywin - 1)), |
4638 | printk("%d channels starting from port %d.\n", | 4712 | cy_isa_irq); |
4639 | cy_isa_nchan, cy_next_channel); | 4713 | printk("%d channels starting from port %d.\n", |
4640 | cy_next_channel += cy_isa_nchan; | 4714 | cy_isa_nchan, cy_next_channel); |
4641 | } | 4715 | cy_next_channel += cy_isa_nchan; |
4642 | return(nboard); | 4716 | } |
4717 | return nboard; | ||
4643 | #else | 4718 | #else |
4644 | return(0); | 4719 | return 0; |
4645 | #endif /* CONFIG_ISA */ | 4720 | #endif /* CONFIG_ISA */ |
4646 | } /* cy_detect_isa */ | 4721 | } /* cy_detect_isa */ |
4647 | 4722 | ||
4648 | static void | 4723 | static void plx_init(void __iomem * addr, uclong initctl) |
4649 | plx_init(void __iomem *addr, uclong initctl) | ||
4650 | { | 4724 | { |
4651 | /* Reset PLX */ | 4725 | /* Reset PLX */ |
4652 | cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000); | 4726 | cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x40000000); |
4653 | udelay(100L); | 4727 | udelay(100L); |
4654 | cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x40000000); | 4728 | cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x40000000); |
4655 | 4729 | ||
4656 | /* Reload Config. Registers from EEPROM */ | 4730 | /* Reload Config. Registers from EEPROM */ |
4657 | cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x20000000); | 4731 | cy_writel(addr + initctl, cy_readl(addr + initctl) | 0x20000000); |
4658 | udelay(100L); | 4732 | udelay(100L); |
4659 | cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x20000000); | 4733 | cy_writel(addr + initctl, cy_readl(addr + initctl) & ~0x20000000); |
4660 | } | 4734 | } |
4661 | 4735 | ||
4662 | /* | 4736 | /* |
@@ -4665,43 +4739,42 @@ plx_init(void __iomem *addr, uclong initctl) | |||
4665 | * sets global variables and return the number of PCI boards found. | 4739 | * sets global variables and return the number of PCI boards found. |
4666 | * --------------------------------------------------------------------- | 4740 | * --------------------------------------------------------------------- |
4667 | */ | 4741 | */ |
4668 | static int __init | 4742 | static int __init cy_detect_pci(void) |
4669 | cy_detect_pci(void) | ||
4670 | { | 4743 | { |
4671 | #ifdef CONFIG_PCI | 4744 | #ifdef CONFIG_PCI |
4672 | 4745 | ||
4673 | struct pci_dev *pdev = NULL; | 4746 | struct pci_dev *pdev = NULL; |
4674 | unsigned char cyy_rev_id; | 4747 | unsigned char cyy_rev_id; |
4675 | unsigned char cy_pci_irq = 0; | 4748 | unsigned char cy_pci_irq = 0; |
4676 | uclong cy_pci_phys0, cy_pci_phys2; | 4749 | uclong cy_pci_phys0, cy_pci_phys2; |
4677 | void __iomem *cy_pci_addr0, *cy_pci_addr2; | 4750 | void __iomem *cy_pci_addr0, *cy_pci_addr2; |
4678 | unsigned short i,j,cy_pci_nchan, plx_ver; | 4751 | unsigned short i, j, cy_pci_nchan, plx_ver; |
4679 | unsigned short device_id,dev_index = 0; | 4752 | unsigned short device_id, dev_index = 0; |
4680 | uclong mailbox; | 4753 | uclong mailbox; |
4681 | uclong ZeIndex = 0; | 4754 | uclong ZeIndex = 0; |
4682 | void __iomem *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS]; | 4755 | void __iomem *Ze_addr0[NR_CARDS], *Ze_addr2[NR_CARDS]; |
4683 | uclong Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS]; | 4756 | uclong Ze_phys0[NR_CARDS], Ze_phys2[NR_CARDS]; |
4684 | unsigned char Ze_irq[NR_CARDS]; | 4757 | unsigned char Ze_irq[NR_CARDS]; |
4685 | struct pci_dev *Ze_pdev[NR_CARDS]; | 4758 | struct pci_dev *Ze_pdev[NR_CARDS]; |
4686 | 4759 | ||
4687 | for (i = 0; i < NR_CARDS; i++) { | 4760 | for (i = 0; i < NR_CARDS; i++) { |
4688 | /* look for a Cyclades card by vendor and device id */ | 4761 | /* look for a Cyclades card by vendor and device id */ |
4689 | while((device_id = cy_pci_dev_id[dev_index]) != 0) { | 4762 | while ((device_id = cy_pci_dev_id[dev_index]) != 0) { |
4690 | if((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES, | 4763 | if ((pdev = pci_get_device(PCI_VENDOR_ID_CYCLADES, |
4691 | device_id, pdev)) == NULL) { | 4764 | device_id, pdev)) == NULL) { |
4692 | dev_index++; /* try next device id */ | 4765 | dev_index++; /* try next device id */ |
4693 | } else { | 4766 | } else { |
4694 | break; /* found a board */ | 4767 | break; /* found a board */ |
4695 | } | 4768 | } |
4696 | } | 4769 | } |
4697 | 4770 | ||
4698 | if (device_id == 0) | 4771 | if (device_id == 0) |
4699 | break; | 4772 | break; |
4700 | 4773 | ||
4701 | if (pci_enable_device(pdev)) | 4774 | if (pci_enable_device(pdev)) |
4702 | continue; | 4775 | continue; |
4703 | 4776 | ||
4704 | /* read PCI configuration area */ | 4777 | /* read PCI configuration area */ |
4705 | cy_pci_irq = pdev->irq; | 4778 | cy_pci_irq = pdev->irq; |
4706 | cy_pci_phys0 = pci_resource_start(pdev, 0); | 4779 | cy_pci_phys0 = pci_resource_start(pdev, 0); |
4707 | cy_pci_phys2 = pci_resource_start(pdev, 2); | 4780 | cy_pci_phys2 = pci_resource_start(pdev, 2); |
@@ -4709,482 +4782,497 @@ cy_detect_pci(void) | |||
4709 | 4782 | ||
4710 | device_id &= ~PCI_DEVICE_ID_MASK; | 4783 | device_id &= ~PCI_DEVICE_ID_MASK; |
4711 | 4784 | ||
4712 | if ((device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) | 4785 | if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo || |
4713 | || (device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi)){ | 4786 | device_id == PCI_DEVICE_ID_CYCLOM_Y_Hi) { |
4714 | #ifdef CY_PCI_DEBUG | 4787 | #ifdef CY_PCI_DEBUG |
4715 | printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ", | 4788 | printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ", |
4716 | pdev->bus->number, pdev->devfn); | 4789 | pdev->bus->number, pdev->devfn); |
4717 | printk("rev_id=%d) IRQ%d\n", | 4790 | printk("rev_id=%d) IRQ%d\n", |
4718 | cyy_rev_id, (int)cy_pci_irq); | 4791 | cyy_rev_id, (int)cy_pci_irq); |
4719 | printk("Cyclom-Y/PCI:found winaddr=0x%lx ctladdr=0x%lx\n", | 4792 | printk("Cyclom-Y/PCI:found winaddr=0x%lx " |
4720 | (ulong)cy_pci_phys2, (ulong)cy_pci_phys0); | 4793 | "ctladdr=0x%lx\n", |
4794 | (ulong)cy_pci_phys2, (ulong)cy_pci_phys0); | ||
4721 | #endif | 4795 | #endif |
4722 | 4796 | ||
4723 | if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { | 4797 | if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { |
4724 | printk(" Warning: PCI I/O bit incorrectly set. " | 4798 | printk(" Warning: PCI I/O bit incorrectly " |
4725 | "Ignoring it...\n"); | 4799 | "set. Ignoring it...\n"); |
4726 | pdev->resource[2].flags &= ~IORESOURCE_IO; | 4800 | pdev->resource[2].flags &= ~IORESOURCE_IO; |
4727 | } | 4801 | } |
4728 | |||
4729 | /* Although we don't use this I/O region, we should | ||
4730 | request it from the kernel anyway, to avoid problems | ||
4731 | with other drivers accessing it. */ | ||
4732 | if (pci_request_regions(pdev, "Cyclom-Y") != 0) { | ||
4733 | printk(KERN_ERR "cyclades: failed to reserve PCI resources\n"); | ||
4734 | continue; | ||
4735 | } | ||
4736 | 4802 | ||
4803 | /* Although we don't use this I/O region, we should | ||
4804 | request it from the kernel anyway, to avoid problems | ||
4805 | with other drivers accessing it. */ | ||
4806 | if (pci_request_regions(pdev, "Cyclom-Y") != 0) { | ||
4807 | printk(KERN_ERR "cyclades: failed to reserve " | ||
4808 | "PCI resources\n"); | ||
4809 | continue; | ||
4810 | } | ||
4737 | #if defined(__alpha__) | 4811 | #if defined(__alpha__) |
4738 | if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */ | 4812 | if (device_id == PCI_DEVICE_ID_CYCLOM_Y_Lo) { /* below 1M? */ |
4739 | printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ", | 4813 | printk("Cyclom-Y/PCI (bus=0x0%x, pci_id=0x%x, ", |
4740 | pdev->bus->number, pdev->devfn); | 4814 | pdev->bus->number, pdev->devfn); |
4741 | printk("rev_id=%d) IRQ%d\n", | 4815 | printk("rev_id=%d) IRQ%d\n", |
4742 | cyy_rev_id, (int)cy_pci_irq); | 4816 | cyy_rev_id, (int)cy_pci_irq); |
4743 | printk("Cyclom-Y/PCI:found winaddr=0x%lx ctladdr=0x%lx\n", | 4817 | printk("Cyclom-Y/PCI:found winaddr=0x%lx " |
4744 | (ulong)cy_pci_phys2, (ulong)cy_pci_phys0); | 4818 | "ctladdr=0x%lx\n", |
4745 | printk("Cyclom-Y/PCI not supported for low addresses in " | 4819 | (ulong)cy_pci_phys2, |
4746 | "Alpha systems.\n"); | 4820 | (ulong)cy_pci_phys0); |
4747 | i--; | 4821 | printk("Cyclom-Y/PCI not supported for low " |
4748 | continue; | 4822 | "addresses in Alpha systems.\n"); |
4749 | } | 4823 | i--; |
4824 | continue; | ||
4825 | } | ||
4750 | #endif | 4826 | #endif |
4751 | cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Yctl); | 4827 | cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Yctl); |
4752 | cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin); | 4828 | cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ywin); |
4753 | 4829 | ||
4754 | #ifdef CY_PCI_DEBUG | 4830 | #ifdef CY_PCI_DEBUG |
4755 | printk("Cyclom-Y/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", | 4831 | printk("Cyclom-Y/PCI: relocate winaddr=0x%lx " |
4756 | (u_long)cy_pci_addr2, (u_long)cy_pci_addr0); | 4832 | "ctladdr=0x%lx\n", |
4833 | (u_long)cy_pci_addr2, (u_long)cy_pci_addr0); | ||
4757 | #endif | 4834 | #endif |
4758 | cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP * | 4835 | cy_pci_nchan = (unsigned short)(CyPORTS_PER_CHIP * |
4759 | cyy_init_card(cy_pci_addr2, 1)); | 4836 | cyy_init_card(cy_pci_addr2, 1)); |
4760 | if(cy_pci_nchan == 0) { | 4837 | if (cy_pci_nchan == 0) { |
4761 | printk("Cyclom-Y PCI host card with "); | 4838 | printk("Cyclom-Y PCI host card with "); |
4762 | printk("no Serial-Modules at 0x%lx.\n", | 4839 | printk("no Serial-Modules at 0x%lx.\n", |
4763 | (ulong) cy_pci_phys2); | 4840 | (ulong) cy_pci_phys2); |
4764 | i--; | 4841 | i--; |
4765 | continue; | 4842 | continue; |
4766 | } | 4843 | } |
4767 | if((cy_next_channel+cy_pci_nchan) > NR_PORTS) { | 4844 | if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) { |
4768 | printk("Cyclom-Y/PCI found at 0x%lx ", | 4845 | printk("Cyclom-Y/PCI found at 0x%lx ", |
4769 | (ulong) cy_pci_phys2); | 4846 | (ulong) cy_pci_phys2); |
4770 | printk("but no channels are available.\n"); | 4847 | printk("but no channels are available.\n"); |
4771 | printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); | 4848 | printk("Change NR_PORTS in cyclades.c and " |
4772 | return(i); | 4849 | "recompile kernel.\n"); |
4773 | } | 4850 | return i; |
4774 | /* fill the next cy_card structure available */ | 4851 | } |
4775 | for (j = 0 ; j < NR_CARDS ; j++) { | 4852 | /* fill the next cy_card structure available */ |
4776 | if (cy_card[j].base_addr == 0) break; | 4853 | for (j = 0; j < NR_CARDS; j++) { |
4777 | } | 4854 | if (cy_card[j].base_addr == 0) |
4778 | if (j == NR_CARDS) { /* no more cy_cards available */ | 4855 | break; |
4779 | printk("Cyclom-Y/PCI found at 0x%lx ", | 4856 | } |
4780 | (ulong) cy_pci_phys2); | 4857 | if (j == NR_CARDS) { /* no more cy_cards available */ |
4781 | printk("but no more cards can be used.\n"); | 4858 | printk("Cyclom-Y/PCI found at 0x%lx ", |
4782 | printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); | 4859 | (ulong) cy_pci_phys2); |
4783 | return(i); | 4860 | printk("but no more cards can be used.\n"); |
4784 | } | 4861 | printk("Change NR_CARDS in cyclades.c and " |
4785 | 4862 | "recompile kernel.\n"); | |
4786 | /* allocate IRQ */ | 4863 | return i; |
4787 | if(request_irq(cy_pci_irq, cyy_interrupt, | 4864 | } |
4788 | IRQF_SHARED, "Cyclom-Y", &cy_card[j])) | 4865 | |
4789 | { | 4866 | /* allocate IRQ */ |
4790 | printk("Cyclom-Y/PCI found at 0x%lx ", | 4867 | if (request_irq(cy_pci_irq, cyy_interrupt, |
4791 | (ulong) cy_pci_phys2); | 4868 | IRQF_SHARED, "Cyclom-Y", &cy_card[j])) { |
4792 | printk("but could not allocate IRQ%d.\n", | 4869 | printk("Cyclom-Y/PCI found at 0x%lx ", |
4793 | cy_pci_irq); | 4870 | (ulong) cy_pci_phys2); |
4794 | return(i); | 4871 | printk("but could not allocate IRQ%d.\n", |
4795 | } | 4872 | cy_pci_irq); |
4796 | 4873 | return i; | |
4797 | /* set cy_card */ | 4874 | } |
4798 | cy_card[j].base_phys = (ulong)cy_pci_phys2; | 4875 | |
4799 | cy_card[j].ctl_phys = (ulong)cy_pci_phys0; | 4876 | /* set cy_card */ |
4800 | cy_card[j].base_addr = cy_pci_addr2; | 4877 | cy_card[j].base_phys = (ulong) cy_pci_phys2; |
4801 | cy_card[j].ctl_addr = cy_pci_addr0; | 4878 | cy_card[j].ctl_phys = (ulong) cy_pci_phys0; |
4802 | cy_card[j].irq = (int) cy_pci_irq; | 4879 | cy_card[j].base_addr = cy_pci_addr2; |
4803 | cy_card[j].bus_index = 1; | 4880 | cy_card[j].ctl_addr = cy_pci_addr0; |
4804 | cy_card[j].first_line = cy_next_channel; | 4881 | cy_card[j].irq = (int)cy_pci_irq; |
4805 | cy_card[j].num_chips = cy_pci_nchan/4; | 4882 | cy_card[j].bus_index = 1; |
4806 | cy_card[j].pdev = pdev; | 4883 | cy_card[j].first_line = cy_next_channel; |
4807 | 4884 | cy_card[j].num_chips = cy_pci_nchan / 4; | |
4808 | /* enable interrupts in the PCI interface */ | 4885 | cy_card[j].pdev = pdev; |
4809 | plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f; | 4886 | |
4810 | switch (plx_ver) { | 4887 | /* enable interrupts in the PCI interface */ |
4811 | case PLX_9050: | 4888 | plx_ver = cy_readb(cy_pci_addr2 + CyPLX_VER) & 0x0f; |
4812 | 4889 | switch (plx_ver) { | |
4813 | cy_writeb(cy_pci_addr0+0x4c, 0x43); | 4890 | case PLX_9050: |
4814 | break; | 4891 | |
4815 | 4892 | cy_writeb(cy_pci_addr0 + 0x4c, 0x43); | |
4816 | case PLX_9060: | 4893 | break; |
4817 | case PLX_9080: | 4894 | |
4818 | default: /* Old boards, use PLX_9060 */ | 4895 | case PLX_9060: |
4819 | 4896 | case PLX_9080: | |
4820 | plx_init(cy_pci_addr0, 0x6c); | 4897 | default: /* Old boards, use PLX_9060 */ |
4821 | /* For some yet unknown reason, once the PLX9060 reloads | 4898 | |
4822 | the EEPROM, the IRQ is lost and, thus, we have to | 4899 | plx_init(cy_pci_addr0, 0x6c); |
4823 | re-write it to the PCI config. registers. | 4900 | /* For some yet unknown reason, once the PLX9060 reloads |
4824 | This will remain here until we find a permanent fix. */ | 4901 | the EEPROM, the IRQ is lost and, thus, we have to |
4825 | pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, cy_pci_irq); | 4902 | re-write it to the PCI config. registers. |
4826 | 4903 | This will remain here until we find a permanent | |
4827 | cy_writew(cy_pci_addr0+0x68, | 4904 | fix. */ |
4828 | cy_readw(cy_pci_addr0+0x68)|0x0900); | 4905 | pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, |
4829 | break; | 4906 | cy_pci_irq); |
4830 | } | 4907 | |
4908 | cy_writew(cy_pci_addr0 + 0x68, | ||
4909 | cy_readw(cy_pci_addr0 + | ||
4910 | 0x68) | 0x0900); | ||
4911 | break; | ||
4912 | } | ||
4831 | 4913 | ||
4832 | /* print message */ | 4914 | /* print message */ |
4833 | printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", | 4915 | printk("Cyclom-Y/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", |
4834 | j+1, | 4916 | j + 1, (ulong)cy_pci_phys2, |
4835 | (ulong)cy_pci_phys2, | 4917 | (ulong) (cy_pci_phys2 + CyPCI_Ywin - 1), |
4836 | (ulong)(cy_pci_phys2 + CyPCI_Ywin - 1), | 4918 | (int)cy_pci_irq); |
4837 | (int)cy_pci_irq); | 4919 | printk("%d channels starting from port %d.\n", |
4838 | printk("%d channels starting from port %d.\n", | 4920 | cy_pci_nchan, cy_next_channel); |
4839 | cy_pci_nchan, cy_next_channel); | 4921 | |
4840 | 4922 | cy_next_channel += cy_pci_nchan; | |
4841 | cy_next_channel += cy_pci_nchan; | 4923 | } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo) { |
4842 | }else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Lo){ | 4924 | /* print message */ |
4843 | /* print message */ | 4925 | printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ", |
4844 | printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ", | 4926 | pdev->bus->number, pdev->devfn); |
4845 | pdev->bus->number, pdev->devfn); | 4927 | printk("rev_id=%d) IRQ%d\n", |
4846 | printk("rev_id=%d) IRQ%d\n", | 4928 | cyy_rev_id, (int)cy_pci_irq); |
4847 | cyy_rev_id, (int)cy_pci_irq); | 4929 | printk("Cyclades-Z/PCI: found winaddr=0x%lx " |
4848 | printk("Cyclades-Z/PCI: found winaddr=0x%lx ctladdr=0x%lx\n", | 4930 | "ctladdr=0x%lx\n", |
4849 | (ulong)cy_pci_phys2, (ulong)cy_pci_phys0); | 4931 | (ulong)cy_pci_phys2, (ulong)cy_pci_phys0); |
4850 | printk("Cyclades-Z/PCI not supported for low addresses\n"); | 4932 | printk("Cyclades-Z/PCI not supported for low " |
4851 | break; | 4933 | "addresses\n"); |
4852 | }else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi){ | 4934 | break; |
4935 | } else if (device_id == PCI_DEVICE_ID_CYCLOM_Z_Hi) { | ||
4853 | #ifdef CY_PCI_DEBUG | 4936 | #ifdef CY_PCI_DEBUG |
4854 | printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ", | 4937 | printk("Cyclades-Z/PCI (bus=0x0%x, pci_id=0x%x, ", |
4855 | pdev->bus->number, pdev->devfn); | 4938 | pdev->bus->number, pdev->devfn); |
4856 | printk("rev_id=%d) IRQ%d\n", | 4939 | printk("rev_id=%d) IRQ%d\n", |
4857 | cyy_rev_id, (int)cy_pci_irq); | 4940 | cyy_rev_id, (int)cy_pci_irq); |
4858 | printk("Cyclades-Z/PCI: found winaddr=0x%lx ctladdr=0x%lx\n", | 4941 | printk("Cyclades-Z/PCI: found winaddr=0x%lx " |
4859 | (ulong)cy_pci_phys2, (ulong)cy_pci_phys0); | 4942 | "ctladdr=0x%lx\n", |
4943 | (ulong) cy_pci_phys2, (ulong) cy_pci_phys0); | ||
4860 | #endif | 4944 | #endif |
4861 | cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl); | 4945 | cy_pci_addr0 = ioremap(cy_pci_phys0, CyPCI_Zctl); |
4862 | 4946 | ||
4863 | /* Disable interrupts on the PLX before resetting it */ | 4947 | /* Disable interrupts on the PLX before resetting it */ |
4864 | cy_writew(cy_pci_addr0+0x68, | 4948 | cy_writew(cy_pci_addr0 + 0x68, |
4865 | cy_readw(cy_pci_addr0+0x68) & ~0x0900); | 4949 | cy_readw(cy_pci_addr0 + 0x68) & ~0x0900); |
4866 | 4950 | ||
4867 | plx_init(cy_pci_addr0, 0x6c); | 4951 | plx_init(cy_pci_addr0, 0x6c); |
4868 | /* For some yet unknown reason, once the PLX9060 reloads | 4952 | /* For some yet unknown reason, once the PLX9060 reloads |
4869 | the EEPROM, the IRQ is lost and, thus, we have to | 4953 | the EEPROM, the IRQ is lost and, thus, we have to |
4870 | re-write it to the PCI config. registers. | 4954 | re-write it to the PCI config. registers. |
4871 | This will remain here until we find a permanent fix. */ | 4955 | This will remain here until we find a permanent |
4872 | pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, cy_pci_irq); | 4956 | fix. */ |
4873 | 4957 | pci_write_config_byte(pdev, PCI_INTERRUPT_LINE, | |
4874 | mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) | 4958 | cy_pci_irq); |
4875 | cy_pci_addr0)->mail_box_0); | 4959 | |
4876 | 4960 | mailbox = | |
4877 | if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { | 4961 | (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) |
4878 | printk(" Warning: PCI I/O bit incorrectly set. " | 4962 | cy_pci_addr0)->mail_box_0); |
4879 | "Ignoring it...\n"); | 4963 | |
4880 | pdev->resource[2].flags &= ~IORESOURCE_IO; | 4964 | if (pci_resource_flags(pdev, 2) & IORESOURCE_IO) { |
4881 | } | 4965 | printk(" Warning: PCI I/O bit incorrectly " |
4966 | "set. Ignoring it...\n"); | ||
4967 | pdev->resource[2].flags &= ~IORESOURCE_IO; | ||
4968 | } | ||
4882 | 4969 | ||
4883 | /* Although we don't use this I/O region, we should | 4970 | /* Although we don't use this I/O region, we should |
4884 | request it from the kernel anyway, to avoid problems | 4971 | request it from the kernel anyway, to avoid problems |
4885 | with other drivers accessing it. */ | 4972 | with other drivers accessing it. */ |
4886 | if (pci_request_regions(pdev, "Cyclades-Z") != 0) { | 4973 | if (pci_request_regions(pdev, "Cyclades-Z") != 0) { |
4887 | printk(KERN_ERR "cyclades: failed to reserve PCI resources\n"); | 4974 | printk(KERN_ERR "cyclades: failed to reserve " |
4888 | continue; | 4975 | "PCI resources\n"); |
4889 | } | 4976 | continue; |
4890 | 4977 | } | |
4891 | if (mailbox == ZE_V1) { | 4978 | |
4892 | cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Ze_win); | 4979 | if (mailbox == ZE_V1) { |
4893 | if (ZeIndex == NR_CARDS) { | 4980 | cy_pci_addr2 = ioremap(cy_pci_phys2, |
4894 | printk("Cyclades-Ze/PCI found at 0x%lx ", | 4981 | CyPCI_Ze_win); |
4895 | (ulong)cy_pci_phys2); | 4982 | if (ZeIndex == NR_CARDS) { |
4896 | printk("but no more cards can be used.\n"); | 4983 | printk("Cyclades-Ze/PCI found at " |
4897 | printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); | 4984 | "0x%lx but no more cards can " |
4898 | } else { | 4985 | "be used.\nChange NR_CARDS in " |
4899 | Ze_phys0[ZeIndex] = cy_pci_phys0; | 4986 | "cyclades.c and recompile " |
4900 | Ze_phys2[ZeIndex] = cy_pci_phys2; | 4987 | "kernel.\n", |
4901 | Ze_addr0[ZeIndex] = cy_pci_addr0; | 4988 | (ulong)cy_pci_phys2); |
4902 | Ze_addr2[ZeIndex] = cy_pci_addr2; | 4989 | } else { |
4903 | Ze_irq[ZeIndex] = cy_pci_irq; | 4990 | Ze_phys0[ZeIndex] = cy_pci_phys0; |
4904 | Ze_pdev[ZeIndex] = pdev; | 4991 | Ze_phys2[ZeIndex] = cy_pci_phys2; |
4905 | ZeIndex++; | 4992 | Ze_addr0[ZeIndex] = cy_pci_addr0; |
4906 | } | 4993 | Ze_addr2[ZeIndex] = cy_pci_addr2; |
4907 | i--; | 4994 | Ze_irq[ZeIndex] = cy_pci_irq; |
4908 | continue; | 4995 | Ze_pdev[ZeIndex] = pdev; |
4909 | } else { | 4996 | ZeIndex++; |
4910 | cy_pci_addr2 = ioremap(cy_pci_phys2, CyPCI_Zwin); | 4997 | } |
4911 | } | 4998 | i--; |
4999 | continue; | ||
5000 | } else { | ||
5001 | cy_pci_addr2 = ioremap(cy_pci_phys2,CyPCI_Zwin); | ||
5002 | } | ||
4912 | 5003 | ||
4913 | #ifdef CY_PCI_DEBUG | 5004 | #ifdef CY_PCI_DEBUG |
4914 | printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", | 5005 | printk("Cyclades-Z/PCI: relocate winaddr=0x%lx " |
4915 | (ulong)cy_pci_addr2, (ulong)cy_pci_addr0); | 5006 | "ctladdr=0x%lx\n", |
4916 | if (mailbox == ZO_V1) { | 5007 | (ulong) cy_pci_addr2, (ulong) cy_pci_addr0); |
4917 | cy_writel(&((struct RUNTIME_9060 *) | 5008 | if (mailbox == ZO_V1) { |
4918 | (cy_pci_addr0))->loc_addr_base, WIN_CREG); | 5009 | cy_writel(&((struct RUNTIME_9060 *) |
4919 | PAUSE | 5010 | (cy_pci_addr0))->loc_addr_base, |
4920 | printk("Cyclades-8Zo/PCI: FPGA id %lx, ver %lx\n", | 5011 | WIN_CREG); |
4921 | (ulong)(0xff & cy_readl(&((struct CUSTOM_REG *) | 5012 | PAUSE; |
4922 | (cy_pci_addr2))->fpga_id)), | 5013 | printk("Cyclades-8Zo/PCI: FPGA id %lx, ver " |
4923 | (ulong)(0xff & cy_readl(&((struct CUSTOM_REG *) | 5014 | "%lx\n", (ulong) (0xff & |
4924 | (cy_pci_addr2))->fpga_version))); | 5015 | cy_readl(&((struct CUSTOM_REG *) |
4925 | cy_writel(&((struct RUNTIME_9060 *) | 5016 | (cy_pci_addr2))->fpga_id)), |
4926 | (cy_pci_addr0))->loc_addr_base, WIN_RAM); | 5017 | (ulong)(0xff & |
4927 | } else { | 5018 | cy_readl(&((struct CUSTOM_REG *) |
4928 | printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not loaded\n"); | 5019 | (cy_pci_addr2))-> |
4929 | } | 5020 | fpga_version))); |
5021 | cy_writel(&((struct RUNTIME_9060 *) | ||
5022 | (cy_pci_addr0))->loc_addr_base, | ||
5023 | WIN_RAM); | ||
5024 | } else { | ||
5025 | printk("Cyclades-Z/PCI: New Cyclades-Z board. " | ||
5026 | "FPGA not loaded\n"); | ||
5027 | } | ||
4930 | #endif | 5028 | #endif |
4931 | /* The following clears the firmware id word. This ensures | 5029 | /* The following clears the firmware id word. This |
4932 | that the driver will not attempt to talk to the board | 5030 | ensures that the driver will not attempt to talk to |
4933 | until it has been properly initialized. | 5031 | the board until it has been properly initialized. |
4934 | */ | 5032 | */ |
4935 | PAUSE | 5033 | PAUSE; |
4936 | if ((mailbox == ZO_V1) || (mailbox == ZO_V2)) | 5034 | if ((mailbox == ZO_V1) || (mailbox == ZO_V2)) |
4937 | cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L); | 5035 | cy_writel(cy_pci_addr2 + ID_ADDRESS, 0L); |
4938 | 5036 | ||
4939 | /* This must be a Cyclades-8Zo/PCI. The extendable | 5037 | /* This must be a Cyclades-8Zo/PCI. The extendable |
4940 | version will have a different device_id and will | 5038 | version will have a different device_id and will |
4941 | be allocated its maximum number of ports. */ | 5039 | be allocated its maximum number of ports. */ |
4942 | cy_pci_nchan = 8; | 5040 | cy_pci_nchan = 8; |
4943 | 5041 | ||
4944 | if((cy_next_channel+cy_pci_nchan) > NR_PORTS) { | 5042 | if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) { |
4945 | printk("Cyclades-8Zo/PCI found at 0x%lx ", | 5043 | printk("Cyclades-8Zo/PCI found at 0x%lx but" |
4946 | (ulong)cy_pci_phys2); | 5044 | "no channels are available.\nChange " |
4947 | printk("but no channels are available.\n"); | 5045 | "NR_PORTS in cyclades.c and recompile " |
4948 | printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); | 5046 | "kernel.\n", (ulong)cy_pci_phys2); |
4949 | return(i); | 5047 | return i; |
4950 | } | 5048 | } |
4951 | |||
4952 | /* fill the next cy_card structure available */ | ||
4953 | for (j = 0 ; j < NR_CARDS ; j++) { | ||
4954 | if (cy_card[j].base_addr == 0) break; | ||
4955 | } | ||
4956 | if (j == NR_CARDS) { /* no more cy_cards available */ | ||
4957 | printk("Cyclades-8Zo/PCI found at 0x%lx ", | ||
4958 | (ulong)cy_pci_phys2); | ||
4959 | printk("but no more cards can be used.\n"); | ||
4960 | printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); | ||
4961 | return(i); | ||
4962 | } | ||
4963 | 5049 | ||
5050 | /* fill the next cy_card structure available */ | ||
5051 | for (j = 0; j < NR_CARDS; j++) { | ||
5052 | if (cy_card[j].base_addr == 0) | ||
5053 | break; | ||
5054 | } | ||
5055 | if (j == NR_CARDS) { /* no more cy_cards available */ | ||
5056 | printk("Cyclades-8Zo/PCI found at 0x%lx but" | ||
5057 | "no more cards can be used.\nChange " | ||
5058 | "NR_CARDS in cyclades.c and recompile " | ||
5059 | "kernel.\n", (ulong)cy_pci_phys2); | ||
5060 | return i; | ||
5061 | } | ||
5062 | #ifdef CONFIG_CYZ_INTR | ||
5063 | /* allocate IRQ only if board has an IRQ */ | ||
5064 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) { | ||
5065 | if (request_irq(cy_pci_irq, cyz_interrupt, | ||
5066 | IRQF_SHARED, "Cyclades-Z", | ||
5067 | &cy_card[j])) { | ||
5068 | printk("Cyclom-8Zo/PCI found at 0x%lx " | ||
5069 | "but could not allocate " | ||
5070 | "IRQ%d.\n", (ulong)cy_pci_phys2, | ||
5071 | cy_pci_irq); | ||
5072 | return i; | ||
5073 | } | ||
5074 | } | ||
5075 | #endif /* CONFIG_CYZ_INTR */ | ||
5076 | |||
5077 | /* set cy_card */ | ||
5078 | cy_card[j].base_phys = cy_pci_phys2; | ||
5079 | cy_card[j].ctl_phys = cy_pci_phys0; | ||
5080 | cy_card[j].base_addr = cy_pci_addr2; | ||
5081 | cy_card[j].ctl_addr = cy_pci_addr0; | ||
5082 | cy_card[j].irq = (int)cy_pci_irq; | ||
5083 | cy_card[j].bus_index = 1; | ||
5084 | cy_card[j].first_line = cy_next_channel; | ||
5085 | cy_card[j].num_chips = -1; | ||
5086 | cy_card[j].pdev = pdev; | ||
5087 | |||
5088 | /* print message */ | ||
4964 | #ifdef CONFIG_CYZ_INTR | 5089 | #ifdef CONFIG_CYZ_INTR |
4965 | /* allocate IRQ only if board has an IRQ */ | 5090 | /* don't report IRQ if board is no IRQ */ |
4966 | if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) { | 5091 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) |
4967 | if(request_irq(cy_pci_irq, cyz_interrupt, | 5092 | printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, " |
4968 | IRQF_SHARED, "Cyclades-Z", &cy_card[j])) | 5093 | "IRQ%d, ", j + 1, (ulong)cy_pci_phys2, |
4969 | { | 5094 | (ulong) (cy_pci_phys2 + CyPCI_Zwin - 1), |
4970 | printk("Cyclom-8Zo/PCI found at 0x%lx ", | 5095 | (int)cy_pci_irq); |
4971 | (ulong) cy_pci_phys2); | 5096 | else |
4972 | printk("but could not allocate IRQ%d.\n", | 5097 | #endif /* CONFIG_CYZ_INTR */ |
4973 | cy_pci_irq); | 5098 | printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ", |
4974 | return(i); | 5099 | j + 1, (ulong)cy_pci_phys2, |
4975 | } | 5100 | (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1)); |
5101 | |||
5102 | printk("%d channels starting from port %d.\n", | ||
5103 | cy_pci_nchan, cy_next_channel); | ||
5104 | cy_next_channel += cy_pci_nchan; | ||
4976 | } | 5105 | } |
4977 | #endif /* CONFIG_CYZ_INTR */ | 5106 | } |
4978 | |||
4979 | |||
4980 | /* set cy_card */ | ||
4981 | cy_card[j].base_phys = cy_pci_phys2; | ||
4982 | cy_card[j].ctl_phys = cy_pci_phys0; | ||
4983 | cy_card[j].base_addr = cy_pci_addr2; | ||
4984 | cy_card[j].ctl_addr = cy_pci_addr0; | ||
4985 | cy_card[j].irq = (int) cy_pci_irq; | ||
4986 | cy_card[j].bus_index = 1; | ||
4987 | cy_card[j].first_line = cy_next_channel; | ||
4988 | cy_card[j].num_chips = -1; | ||
4989 | cy_card[j].pdev = pdev; | ||
4990 | 5107 | ||
4991 | /* print message */ | 5108 | for (; ZeIndex != 0 && i < NR_CARDS; i++) { |
4992 | #ifdef CONFIG_CYZ_INTR | 5109 | cy_pci_phys0 = Ze_phys0[0]; |
4993 | /* don't report IRQ if board is no IRQ */ | 5110 | cy_pci_phys2 = Ze_phys2[0]; |
4994 | if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) | 5111 | cy_pci_addr0 = Ze_addr0[0]; |
4995 | printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", | 5112 | cy_pci_addr2 = Ze_addr2[0]; |
4996 | j+1,(ulong)cy_pci_phys2, | 5113 | cy_pci_irq = Ze_irq[0]; |
4997 | (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1), | 5114 | pdev = Ze_pdev[0]; |
4998 | (int)cy_pci_irq); | 5115 | for (j = 0; j < ZeIndex - 1; j++) { |
4999 | else | 5116 | Ze_phys0[j] = Ze_phys0[j + 1]; |
5000 | #endif /* CONFIG_CYZ_INTR */ | 5117 | Ze_phys2[j] = Ze_phys2[j + 1]; |
5001 | printk("Cyclades-8Zo/PCI #%d: 0x%lx-0x%lx, ", | 5118 | Ze_addr0[j] = Ze_addr0[j + 1]; |
5002 | j+1,(ulong)cy_pci_phys2, | 5119 | Ze_addr2[j] = Ze_addr2[j + 1]; |
5003 | (ulong)(cy_pci_phys2 + CyPCI_Zwin - 1)); | 5120 | Ze_irq[j] = Ze_irq[j + 1]; |
5004 | 5121 | Ze_pdev[j] = Ze_pdev[j + 1]; | |
5005 | printk("%d channels starting from port %d.\n", | 5122 | } |
5006 | cy_pci_nchan,cy_next_channel); | 5123 | ZeIndex--; |
5007 | cy_next_channel += cy_pci_nchan; | 5124 | mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) |
5008 | } | 5125 | cy_pci_addr0)->mail_box_0); |
5009 | } | ||
5010 | |||
5011 | for (; ZeIndex != 0 && i < NR_CARDS; i++) { | ||
5012 | cy_pci_phys0 = Ze_phys0[0]; | ||
5013 | cy_pci_phys2 = Ze_phys2[0]; | ||
5014 | cy_pci_addr0 = Ze_addr0[0]; | ||
5015 | cy_pci_addr2 = Ze_addr2[0]; | ||
5016 | cy_pci_irq = Ze_irq[0]; | ||
5017 | pdev = Ze_pdev[0]; | ||
5018 | for (j = 0 ; j < ZeIndex-1 ; j++) { | ||
5019 | Ze_phys0[j] = Ze_phys0[j+1]; | ||
5020 | Ze_phys2[j] = Ze_phys2[j+1]; | ||
5021 | Ze_addr0[j] = Ze_addr0[j+1]; | ||
5022 | Ze_addr2[j] = Ze_addr2[j+1]; | ||
5023 | Ze_irq[j] = Ze_irq[j+1]; | ||
5024 | Ze_pdev[j] = Ze_pdev[j+1]; | ||
5025 | } | ||
5026 | ZeIndex--; | ||
5027 | mailbox = (uclong)cy_readl(&((struct RUNTIME_9060 __iomem *) | ||
5028 | cy_pci_addr0)->mail_box_0); | ||
5029 | #ifdef CY_PCI_DEBUG | 5126 | #ifdef CY_PCI_DEBUG |
5030 | printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", | 5127 | printk("Cyclades-Z/PCI: relocate winaddr=0x%lx ctladdr=0x%lx\n", |
5031 | (ulong)cy_pci_addr2, (ulong)cy_pci_addr0); | 5128 | (ulong)cy_pci_addr2, (ulong)cy_pci_addr0); |
5032 | printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not loaded\n"); | 5129 | printk("Cyclades-Z/PCI: New Cyclades-Z board. FPGA not " |
5130 | "loaded\n"); | ||
5033 | #endif | 5131 | #endif |
5034 | PAUSE | 5132 | PAUSE; |
5035 | /* This must be the new Cyclades-Ze/PCI. */ | 5133 | /* This must be the new Cyclades-Ze/PCI. */ |
5036 | cy_pci_nchan = ZE_V1_NPORTS; | 5134 | cy_pci_nchan = ZE_V1_NPORTS; |
5037 | 5135 | ||
5038 | if((cy_next_channel+cy_pci_nchan) > NR_PORTS) { | 5136 | if ((cy_next_channel + cy_pci_nchan) > NR_PORTS) { |
5039 | printk("Cyclades-Ze/PCI found at 0x%lx ", | 5137 | printk("Cyclades-Ze/PCI found at 0x%lx but no channels " |
5040 | (ulong)cy_pci_phys2); | 5138 | "are available.\nChange NR_PORTS in cyclades.c " |
5041 | printk("but no channels are available.\n"); | 5139 | "and recompile kernel.\n", |
5042 | printk("Change NR_PORTS in cyclades.c and recompile kernel.\n"); | 5140 | (ulong) cy_pci_phys2); |
5043 | return(i); | 5141 | return i; |
5044 | } | 5142 | } |
5045 | |||
5046 | /* fill the next cy_card structure available */ | ||
5047 | for (j = 0 ; j < NR_CARDS ; j++) { | ||
5048 | if (cy_card[j].base_addr == 0) break; | ||
5049 | } | ||
5050 | if (j == NR_CARDS) { /* no more cy_cards available */ | ||
5051 | printk("Cyclades-Ze/PCI found at 0x%lx ", | ||
5052 | (ulong)cy_pci_phys2); | ||
5053 | printk("but no more cards can be used.\n"); | ||
5054 | printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); | ||
5055 | return(i); | ||
5056 | } | ||
5057 | 5143 | ||
5144 | /* fill the next cy_card structure available */ | ||
5145 | for (j = 0; j < NR_CARDS; j++) { | ||
5146 | if (cy_card[j].base_addr == 0) | ||
5147 | break; | ||
5148 | } | ||
5149 | if (j == NR_CARDS) { /* no more cy_cards available */ | ||
5150 | printk("Cyclades-Ze/PCI found at 0x%lx but no more " | ||
5151 | "cards can be used.\nChange NR_CARDS in " | ||
5152 | "cyclades.c and recompile kernel.\n", | ||
5153 | (ulong) cy_pci_phys2); | ||
5154 | return i; | ||
5155 | } | ||
5058 | #ifdef CONFIG_CYZ_INTR | 5156 | #ifdef CONFIG_CYZ_INTR |
5059 | /* allocate IRQ only if board has an IRQ */ | 5157 | /* allocate IRQ only if board has an IRQ */ |
5060 | if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) { | 5158 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) { |
5061 | if(request_irq(cy_pci_irq, cyz_interrupt, | 5159 | if (request_irq(cy_pci_irq, cyz_interrupt, |
5062 | IRQF_SHARED, "Cyclades-Z", &cy_card[j])) | 5160 | IRQF_SHARED, "Cyclades-Z", |
5063 | { | 5161 | &cy_card[j])) { |
5064 | printk("Cyclom-Ze/PCI found at 0x%lx ", | 5162 | printk("Cyclom-Ze/PCI found at 0x%lx ", |
5065 | (ulong) cy_pci_phys2); | 5163 | (ulong) cy_pci_phys2); |
5066 | printk("but could not allocate IRQ%d.\n", | 5164 | printk("but could not allocate IRQ%d.\n", |
5067 | cy_pci_irq); | 5165 | cy_pci_irq); |
5068 | return(i); | 5166 | return i; |
5069 | } | 5167 | } |
5070 | } | 5168 | } |
5071 | #endif /* CONFIG_CYZ_INTR */ | 5169 | #endif /* CONFIG_CYZ_INTR */ |
5072 | 5170 | ||
5073 | /* set cy_card */ | 5171 | /* set cy_card */ |
5074 | cy_card[j].base_phys = cy_pci_phys2; | 5172 | cy_card[j].base_phys = cy_pci_phys2; |
5075 | cy_card[j].ctl_phys = cy_pci_phys0; | 5173 | cy_card[j].ctl_phys = cy_pci_phys0; |
5076 | cy_card[j].base_addr = cy_pci_addr2; | 5174 | cy_card[j].base_addr = cy_pci_addr2; |
5077 | cy_card[j].ctl_addr = cy_pci_addr0; | 5175 | cy_card[j].ctl_addr = cy_pci_addr0; |
5078 | cy_card[j].irq = (int) cy_pci_irq; | 5176 | cy_card[j].irq = (int)cy_pci_irq; |
5079 | cy_card[j].bus_index = 1; | 5177 | cy_card[j].bus_index = 1; |
5080 | cy_card[j].first_line = cy_next_channel; | 5178 | cy_card[j].first_line = cy_next_channel; |
5081 | cy_card[j].num_chips = -1; | 5179 | cy_card[j].num_chips = -1; |
5082 | cy_card[j].pdev = pdev; | 5180 | cy_card[j].pdev = pdev; |
5083 | 5181 | ||
5084 | /* print message */ | 5182 | /* print message */ |
5085 | #ifdef CONFIG_CYZ_INTR | 5183 | #ifdef CONFIG_CYZ_INTR |
5086 | /* don't report IRQ if board is no IRQ */ | 5184 | /* don't report IRQ if board is no IRQ */ |
5087 | if( (cy_pci_irq != 0) && (cy_pci_irq != 255) ) | 5185 | if ((cy_pci_irq != 0) && (cy_pci_irq != 255)) |
5088 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", | 5186 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, IRQ%d, ", |
5089 | j+1,(ulong)cy_pci_phys2, | 5187 | j + 1, (ulong) cy_pci_phys2, |
5090 | (ulong)(cy_pci_phys2 + CyPCI_Ze_win - 1), | 5188 | (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1), |
5091 | (int)cy_pci_irq); | 5189 | (int)cy_pci_irq); |
5092 | else | 5190 | else |
5093 | #endif /* CONFIG_CYZ_INTR */ | 5191 | #endif /* CONFIG_CYZ_INTR */ |
5094 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ", | 5192 | printk("Cyclades-Ze/PCI #%d: 0x%lx-0x%lx, ", |
5095 | j+1,(ulong)cy_pci_phys2, | 5193 | j + 1, (ulong) cy_pci_phys2, |
5096 | (ulong)(cy_pci_phys2 + CyPCI_Ze_win - 1)); | 5194 | (ulong) (cy_pci_phys2 + CyPCI_Ze_win - 1)); |
5097 | 5195 | ||
5098 | printk("%d channels starting from port %d.\n", | 5196 | printk("%d channels starting from port %d.\n", |
5099 | cy_pci_nchan,cy_next_channel); | 5197 | cy_pci_nchan, cy_next_channel); |
5100 | cy_next_channel += cy_pci_nchan; | 5198 | cy_next_channel += cy_pci_nchan; |
5101 | } | 5199 | } |
5102 | if (ZeIndex != 0) { | 5200 | if (ZeIndex != 0) { |
5103 | printk("Cyclades-Ze/PCI found at 0x%x ", | 5201 | printk("Cyclades-Ze/PCI found at 0x%x but no more cards can be " |
5104 | (unsigned int) Ze_phys2[0]); | 5202 | "used.\nChange NR_CARDS in cyclades.c and recompile " |
5105 | printk("but no more cards can be used.\n"); | 5203 | "kernel.\n", (unsigned int)Ze_phys2[0]); |
5106 | printk("Change NR_CARDS in cyclades.c and recompile kernel.\n"); | ||
5107 | } | 5204 | } |
5108 | return(i); | 5205 | return i; |
5109 | #else | 5206 | #else |
5110 | return(0); | 5207 | return 0; |
5111 | #endif /* ifdef CONFIG_PCI */ | 5208 | #endif /* ifdef CONFIG_PCI */ |
5112 | } /* cy_detect_pci */ | 5209 | } /* cy_detect_pci */ |
5113 | |||
5114 | 5210 | ||
5115 | /* | 5211 | /* |
5116 | * This routine prints out the appropriate serial driver version number | 5212 | * This routine prints out the appropriate serial driver version number |
5117 | * and identifies which options were configured into this driver. | 5213 | * and identifies which options were configured into this driver. |
5118 | */ | 5214 | */ |
5119 | static inline void | 5215 | static inline void show_version(void) |
5120 | show_version(void) | ||
5121 | { | 5216 | { |
5122 | char *rcsvers, *rcsdate, *tmp; | 5217 | printk("Cyclades driver " CY_VERSION "\n"); |
5123 | rcsvers = strchr(rcsid, ' '); rcsvers++; | 5218 | printk(" built %s %s\n", __DATE__, __TIME__); |
5124 | tmp = strchr(rcsvers, ' '); *tmp++ = '\0'; | 5219 | } /* show_version */ |
5125 | rcsdate = strchr(tmp, ' '); rcsdate++; | 5220 | |
5126 | tmp = strrchr(rcsdate, ' '); *tmp = '\0'; | 5221 | static int |
5127 | printk("Cyclades driver %s %s\n", | ||
5128 | rcsvers, rcsdate); | ||
5129 | printk(" built %s %s\n", | ||
5130 | __DATE__, __TIME__); | ||
5131 | } /* show_version */ | ||
5132 | |||
5133 | static int | ||
5134 | cyclades_get_proc_info(char *buf, char **start, off_t offset, int length, | 5222 | cyclades_get_proc_info(char *buf, char **start, off_t offset, int length, |
5135 | int *eof, void *data) | 5223 | int *eof, void *data) |
5136 | { | 5224 | { |
5137 | struct cyclades_port *info; | 5225 | struct cyclades_port *info; |
5138 | int i; | 5226 | int i; |
5139 | int len=0; | 5227 | int len = 0; |
5140 | off_t begin=0; | 5228 | off_t begin = 0; |
5141 | off_t pos=0; | 5229 | off_t pos = 0; |
5142 | int size; | 5230 | int size; |
5143 | __u32 cur_jifs = jiffies; | 5231 | __u32 cur_jifs = jiffies; |
5144 | 5232 | ||
5145 | size = sprintf(buf, "Dev TimeOpen BytesOut IdleOut BytesIn IdleIn Overruns Ldisc\n"); | 5233 | size = sprintf(buf, "Dev TimeOpen BytesOut IdleOut BytesIn " |
5146 | 5234 | "IdleIn Overruns Ldisc\n"); | |
5147 | pos += size; | 5235 | |
5148 | len += size; | 5236 | pos += size; |
5149 | |||
5150 | /* Output one line for each known port */ | ||
5151 | for (i = 0; i < NR_PORTS && cy_port[i].line >= 0; i++) { | ||
5152 | info = &cy_port[i]; | ||
5153 | |||
5154 | if (info->count) | ||
5155 | size = sprintf(buf+len, | ||
5156 | "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", | ||
5157 | info->line, | ||
5158 | JIFFIES_DIFF(info->idle_stats.in_use, cur_jifs) / HZ, | ||
5159 | info->idle_stats.xmit_bytes, | ||
5160 | JIFFIES_DIFF(info->idle_stats.xmit_idle, cur_jifs) / HZ, | ||
5161 | info->idle_stats.recv_bytes, | ||
5162 | JIFFIES_DIFF(info->idle_stats.recv_idle, cur_jifs) / HZ, | ||
5163 | info->idle_stats.overruns, | ||
5164 | (long) info->tty->ldisc.num); | ||
5165 | else | ||
5166 | size = sprintf(buf+len, | ||
5167 | "%3d %8lu %10lu %8lu %10lu %8lu %9lu %6ld\n", | ||
5168 | info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L); | ||
5169 | len += size; | 5237 | len += size; |
5170 | pos = begin + len; | ||
5171 | 5238 | ||
5172 | if (pos < offset) { | 5239 | /* Output one line for each known port */ |
5173 | len = 0; | 5240 | for (i = 0; i < NR_PORTS && cy_port[i].line >= 0; i++) { |
5174 | begin = pos; | 5241 | info = &cy_port[i]; |
5242 | |||
5243 | if (info->count) | ||
5244 | size = sprintf(buf + len, "%3d %8lu %10lu %8lu %10lu " | ||
5245 | "%8lu %9lu %6ld\n", info->line, | ||
5246 | (cur_jifs - info->idle_stats.in_use) / HZ, | ||
5247 | info->idle_stats.xmit_bytes, | ||
5248 | (cur_jifs - info->idle_stats.xmit_idle) / HZ, | ||
5249 | info->idle_stats.recv_bytes, | ||
5250 | (cur_jifs - info->idle_stats.recv_idle) / HZ, | ||
5251 | info->idle_stats.overruns, | ||
5252 | (long)info->tty->ldisc.num); | ||
5253 | else | ||
5254 | size = sprintf(buf + len, "%3d %8lu %10lu %8lu %10lu " | ||
5255 | "%8lu %9lu %6ld\n", | ||
5256 | info->line, 0L, 0L, 0L, 0L, 0L, 0L, 0L); | ||
5257 | len += size; | ||
5258 | pos = begin + len; | ||
5259 | |||
5260 | if (pos < offset) { | ||
5261 | len = 0; | ||
5262 | begin = pos; | ||
5263 | } | ||
5264 | if (pos > offset + length) | ||
5265 | goto done; | ||
5175 | } | 5266 | } |
5176 | if (pos > offset + length) | 5267 | *eof = 1; |
5177 | goto done; | ||
5178 | } | ||
5179 | *eof = 1; | ||
5180 | done: | 5268 | done: |
5181 | *start = buf + (offset - begin); /* Start of wanted data */ | 5269 | *start = buf + (offset - begin); /* Start of wanted data */ |
5182 | len -= (offset - begin); /* Start slop */ | 5270 | len -= (offset - begin); /* Start slop */ |
5183 | if (len > length) | 5271 | if (len > length) |
5184 | len = length; /* Ending slop */ | 5272 | len = length; /* Ending slop */ |
5185 | if (len < 0) | 5273 | if (len < 0) |
5186 | len = 0; | 5274 | len = 0; |
5187 | return len; | 5275 | return len; |
5188 | } | 5276 | } |
5189 | 5277 | ||
5190 | /* The serial driver boot-time initialization code! | 5278 | /* The serial driver boot-time initialization code! |
@@ -5205,295 +5293,289 @@ done: | |||
5205 | extra ports are ignored. | 5293 | extra ports are ignored. |
5206 | */ | 5294 | */ |
5207 | 5295 | ||
5208 | static struct tty_operations cy_ops = { | 5296 | static const struct tty_operations cy_ops = { |
5209 | .open = cy_open, | 5297 | .open = cy_open, |
5210 | .close = cy_close, | 5298 | .close = cy_close, |
5211 | .write = cy_write, | 5299 | .write = cy_write, |
5212 | .put_char = cy_put_char, | 5300 | .put_char = cy_put_char, |
5213 | .flush_chars = cy_flush_chars, | 5301 | .flush_chars = cy_flush_chars, |
5214 | .write_room = cy_write_room, | 5302 | .write_room = cy_write_room, |
5215 | .chars_in_buffer = cy_chars_in_buffer, | 5303 | .chars_in_buffer = cy_chars_in_buffer, |
5216 | .flush_buffer = cy_flush_buffer, | 5304 | .flush_buffer = cy_flush_buffer, |
5217 | .ioctl = cy_ioctl, | 5305 | .ioctl = cy_ioctl, |
5218 | .throttle = cy_throttle, | 5306 | .throttle = cy_throttle, |
5219 | .unthrottle = cy_unthrottle, | 5307 | .unthrottle = cy_unthrottle, |
5220 | .set_termios = cy_set_termios, | 5308 | .set_termios = cy_set_termios, |
5221 | .stop = cy_stop, | 5309 | .stop = cy_stop, |
5222 | .start = cy_start, | 5310 | .start = cy_start, |
5223 | .hangup = cy_hangup, | 5311 | .hangup = cy_hangup, |
5224 | .break_ctl = cy_break, | 5312 | .break_ctl = cy_break, |
5225 | .wait_until_sent = cy_wait_until_sent, | 5313 | .wait_until_sent = cy_wait_until_sent, |
5226 | .read_proc = cyclades_get_proc_info, | 5314 | .read_proc = cyclades_get_proc_info, |
5227 | .tiocmget = cy_tiocmget, | 5315 | .tiocmget = cy_tiocmget, |
5228 | .tiocmset = cy_tiocmset, | 5316 | .tiocmset = cy_tiocmset, |
5229 | }; | 5317 | }; |
5230 | 5318 | ||
5231 | static int __init | 5319 | static int __init cy_init(void) |
5232 | cy_init(void) | ||
5233 | { | 5320 | { |
5234 | struct cyclades_port *info; | 5321 | struct cyclades_port *info; |
5235 | struct cyclades_card *cinfo; | 5322 | struct cyclades_card *cinfo; |
5236 | int number_z_boards = 0; | 5323 | int number_z_boards = 0; |
5237 | int board,port,i,index; | 5324 | int board, port, i, index; |
5238 | unsigned long mailbox; | 5325 | unsigned long mailbox; |
5239 | unsigned short chip_number; | 5326 | unsigned short chip_number; |
5240 | int nports; | 5327 | int nports; |
5241 | 5328 | ||
5242 | cy_serial_driver = alloc_tty_driver(NR_PORTS); | 5329 | cy_serial_driver = alloc_tty_driver(NR_PORTS); |
5243 | if (!cy_serial_driver) | 5330 | if (!cy_serial_driver) |
5244 | return -ENOMEM; | 5331 | return -ENOMEM; |
5245 | show_version(); | 5332 | show_version(); |
5246 | 5333 | ||
5247 | /* Initialize the tty_driver structure */ | 5334 | /* Initialize the tty_driver structure */ |
5248 | 5335 | ||
5249 | cy_serial_driver->owner = THIS_MODULE; | 5336 | cy_serial_driver->owner = THIS_MODULE; |
5250 | cy_serial_driver->driver_name = "cyclades"; | 5337 | cy_serial_driver->driver_name = "cyclades"; |
5251 | cy_serial_driver->name = "ttyC"; | 5338 | cy_serial_driver->name = "ttyC"; |
5252 | cy_serial_driver->major = CYCLADES_MAJOR; | 5339 | cy_serial_driver->major = CYCLADES_MAJOR; |
5253 | cy_serial_driver->minor_start = 0; | 5340 | cy_serial_driver->minor_start = 0; |
5254 | cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; | 5341 | cy_serial_driver->type = TTY_DRIVER_TYPE_SERIAL; |
5255 | cy_serial_driver->subtype = SERIAL_TYPE_NORMAL; | 5342 | cy_serial_driver->subtype = SERIAL_TYPE_NORMAL; |
5256 | cy_serial_driver->init_termios = tty_std_termios; | 5343 | cy_serial_driver->init_termios = tty_std_termios; |
5257 | cy_serial_driver->init_termios.c_cflag = | 5344 | cy_serial_driver->init_termios.c_cflag = |
5258 | B9600 | CS8 | CREAD | HUPCL | CLOCAL; | 5345 | B9600 | CS8 | CREAD | HUPCL | CLOCAL; |
5259 | cy_serial_driver->flags = TTY_DRIVER_REAL_RAW; | 5346 | cy_serial_driver->flags = TTY_DRIVER_REAL_RAW; |
5260 | tty_set_operations(cy_serial_driver, &cy_ops); | 5347 | tty_set_operations(cy_serial_driver, &cy_ops); |
5261 | 5348 | ||
5262 | if (tty_register_driver(cy_serial_driver)) | 5349 | if (tty_register_driver(cy_serial_driver)) |
5263 | panic("Couldn't register Cyclades serial driver\n"); | 5350 | panic("Couldn't register Cyclades serial driver\n"); |
5264 | 5351 | ||
5265 | for (i = 0; i < NR_CARDS; i++) { | 5352 | for (i = 0; i < NR_CARDS; i++) { |
5266 | /* base_addr=0 indicates board not found */ | 5353 | /* base_addr=0 indicates board not found */ |
5267 | cy_card[i].base_addr = NULL; | 5354 | cy_card[i].base_addr = NULL; |
5268 | } | 5355 | } |
5269 | 5356 | ||
5270 | /* the code below is responsible to find the boards. Each different | 5357 | /* the code below is responsible to find the boards. Each different |
5271 | type of board has its own detection routine. If a board is found, | 5358 | type of board has its own detection routine. If a board is found, |
5272 | the next cy_card structure available is set by the detection | 5359 | the next cy_card structure available is set by the detection |
5273 | routine. These functions are responsible for checking the | 5360 | routine. These functions are responsible for checking the |
5274 | availability of cy_card and cy_port data structures and updating | 5361 | availability of cy_card and cy_port data structures and updating |
5275 | the cy_next_channel. */ | 5362 | the cy_next_channel. */ |
5276 | 5363 | ||
5277 | /* look for isa boards */ | 5364 | /* look for isa boards */ |
5278 | cy_isa_nboard = cy_detect_isa(); | 5365 | cy_isa_nboard = cy_detect_isa(); |
5279 | 5366 | ||
5280 | /* look for pci boards */ | 5367 | /* look for pci boards */ |
5281 | cy_pci_nboard = cy_detect_pci(); | 5368 | cy_pci_nboard = cy_detect_pci(); |
5282 | 5369 | ||
5283 | cy_nboard = cy_isa_nboard + cy_pci_nboard; | 5370 | cy_nboard = cy_isa_nboard + cy_pci_nboard; |
5284 | 5371 | ||
5285 | /* invalidate remaining cy_card structures */ | 5372 | /* invalidate remaining cy_card structures */ |
5286 | for (i = 0 ; i < NR_CARDS ; i++) { | 5373 | for (i = 0; i < NR_CARDS; i++) { |
5287 | if (cy_card[i].base_addr == 0) { | 5374 | if (cy_card[i].base_addr == 0) { |
5288 | cy_card[i].first_line = -1; | 5375 | cy_card[i].first_line = -1; |
5289 | cy_card[i].ctl_addr = NULL; | 5376 | cy_card[i].ctl_addr = NULL; |
5290 | cy_card[i].irq = 0; | 5377 | cy_card[i].irq = 0; |
5291 | cy_card[i].bus_index = 0; | 5378 | cy_card[i].bus_index = 0; |
5292 | cy_card[i].first_line = 0; | 5379 | cy_card[i].first_line = 0; |
5293 | cy_card[i].num_chips = 0; | 5380 | cy_card[i].num_chips = 0; |
5294 | } | 5381 | } |
5295 | } | 5382 | } |
5296 | /* invalidate remaining cy_port structures */ | 5383 | /* invalidate remaining cy_port structures */ |
5297 | for (i = cy_next_channel ; i < NR_PORTS ; i++) { | 5384 | for (i = cy_next_channel; i < NR_PORTS; i++) { |
5298 | cy_port[i].line = -1; | 5385 | cy_port[i].line = -1; |
5299 | cy_port[i].magic = -1; | 5386 | cy_port[i].magic = -1; |
5300 | } | 5387 | } |
5301 | 5388 | ||
5302 | /* initialize per-port data structures for each valid board found */ | 5389 | /* initialize per-port data structures for each valid board found */ |
5303 | for (board = 0 ; board < cy_nboard ; board++) { | 5390 | for (board = 0; board < cy_nboard; board++) { |
5304 | cinfo = &cy_card[board]; | 5391 | cinfo = &cy_card[board]; |
5305 | if (cinfo->num_chips == -1) { /* Cyclades-Z */ | 5392 | if (cinfo->num_chips == -1) { /* Cyclades-Z */ |
5306 | number_z_boards++; | 5393 | number_z_boards++; |
5307 | mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *) | 5394 | mailbox = cy_readl(&((struct RUNTIME_9060 __iomem *) |
5308 | cy_card[board].ctl_addr)->mail_box_0); | 5395 | cy_card[board].ctl_addr)-> |
5309 | nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8; | 5396 | mail_box_0); |
5310 | cinfo->intr_enabled = 0; | 5397 | nports = (mailbox == ZE_V1) ? ZE_V1_NPORTS : 8; |
5311 | cinfo->nports = 0; /* Will be correctly set later, after | 5398 | cinfo->intr_enabled = 0; |
5312 | Z FW is loaded */ | 5399 | cinfo->nports = 0; /* Will be correctly set later, after |
5313 | spin_lock_init(&cinfo->card_lock); | 5400 | Z FW is loaded */ |
5314 | for (port = cinfo->first_line ; | 5401 | spin_lock_init(&cinfo->card_lock); |
5315 | port < cinfo->first_line + nports; | 5402 | for (port = cinfo->first_line; |
5316 | port++) | 5403 | port < cinfo->first_line + nports; port++) { |
5317 | { | 5404 | info = &cy_port[port]; |
5318 | info = &cy_port[port]; | 5405 | info->magic = CYCLADES_MAGIC; |
5319 | info->magic = CYCLADES_MAGIC; | 5406 | info->type = PORT_STARTECH; |
5320 | info->type = PORT_STARTECH; | 5407 | info->card = board; |
5321 | info->card = board; | 5408 | info->line = port; |
5322 | info->line = port; | 5409 | info->chip_rev = 0; |
5323 | info->chip_rev = 0; | 5410 | info->flags = STD_COM_FLAGS; |
5324 | info->flags = STD_COM_FLAGS; | 5411 | info->tty = NULL; |
5325 | info->tty = NULL; | 5412 | if (mailbox == ZO_V1) |
5326 | if (mailbox == ZO_V1) | 5413 | info->xmit_fifo_size = CYZ_FIFO_SIZE; |
5327 | info->xmit_fifo_size = CYZ_FIFO_SIZE; | 5414 | else |
5328 | else | 5415 | info->xmit_fifo_size = |
5329 | info->xmit_fifo_size = 4 * CYZ_FIFO_SIZE; | 5416 | 4 * CYZ_FIFO_SIZE; |
5330 | info->cor1 = 0; | 5417 | info->cor1 = 0; |
5331 | info->cor2 = 0; | 5418 | info->cor2 = 0; |
5332 | info->cor3 = 0; | 5419 | info->cor3 = 0; |
5333 | info->cor4 = 0; | 5420 | info->cor4 = 0; |
5334 | info->cor5 = 0; | 5421 | info->cor5 = 0; |
5335 | info->tbpr = 0; | 5422 | info->tbpr = 0; |
5336 | info->tco = 0; | 5423 | info->tco = 0; |
5337 | info->rbpr = 0; | 5424 | info->rbpr = 0; |
5338 | info->rco = 0; | 5425 | info->rco = 0; |
5339 | info->custom_divisor = 0; | 5426 | info->custom_divisor = 0; |
5340 | info->close_delay = 5*HZ/10; | 5427 | info->close_delay = 5 * HZ / 10; |
5341 | info->closing_wait = CLOSING_WAIT_DELAY; | 5428 | info->closing_wait = CLOSING_WAIT_DELAY; |
5342 | info->icount.cts = info->icount.dsr = | 5429 | info->icount.cts = info->icount.dsr = |
5343 | info->icount.rng = info->icount.dcd = 0; | 5430 | info->icount.rng = info->icount.dcd = 0; |
5344 | info->icount.rx = info->icount.tx = 0; | 5431 | info->icount.rx = info->icount.tx = 0; |
5345 | info->icount.frame = info->icount.parity = 0; | 5432 | info->icount.frame = info->icount.parity = 0; |
5346 | info->icount.overrun = info->icount.brk = 0; | 5433 | info->icount.overrun = info->icount.brk = 0; |
5347 | info->x_char = 0; | 5434 | info->x_char = 0; |
5348 | info->event = 0; | 5435 | info->event = 0; |
5349 | info->count = 0; | 5436 | info->count = 0; |
5350 | info->blocked_open = 0; | 5437 | info->blocked_open = 0; |
5351 | info->default_threshold = 0; | 5438 | info->default_threshold = 0; |
5352 | info->default_timeout = 0; | 5439 | info->default_timeout = 0; |
5353 | INIT_WORK(&info->tqueue, do_softint, info); | 5440 | INIT_WORK(&info->tqueue, do_softint); |
5354 | init_waitqueue_head(&info->open_wait); | 5441 | init_waitqueue_head(&info->open_wait); |
5355 | init_waitqueue_head(&info->close_wait); | 5442 | init_waitqueue_head(&info->close_wait); |
5356 | init_waitqueue_head(&info->shutdown_wait); | 5443 | init_waitqueue_head(&info->shutdown_wait); |
5357 | init_waitqueue_head(&info->delta_msr_wait); | 5444 | init_waitqueue_head(&info->delta_msr_wait); |
5358 | /* info->session */ | 5445 | /* info->session */ |
5359 | /* info->pgrp */ | 5446 | /* info->pgrp */ |
5360 | info->read_status_mask = 0; | 5447 | info->read_status_mask = 0; |
5361 | /* info->timeout */ | 5448 | /* info->timeout */ |
5362 | /* Bentson's vars */ | 5449 | /* Bentson's vars */ |
5363 | info->jiffies[0] = 0; | 5450 | info->jiffies[0] = 0; |
5364 | info->jiffies[1] = 0; | 5451 | info->jiffies[1] = 0; |
5365 | info->jiffies[2] = 0; | 5452 | info->jiffies[2] = 0; |
5366 | info->rflush_count = 0; | 5453 | info->rflush_count = 0; |
5367 | #ifdef CONFIG_CYZ_INTR | 5454 | #ifdef CONFIG_CYZ_INTR |
5368 | init_timer(&cyz_rx_full_timer[port]); | 5455 | init_timer(&cyz_rx_full_timer[port]); |
5369 | cyz_rx_full_timer[port].function = NULL; | 5456 | cyz_rx_full_timer[port].function = NULL; |
5370 | #endif | 5457 | #endif |
5371 | } | 5458 | } |
5372 | continue; | 5459 | continue; |
5373 | }else{ /* Cyclom-Y of some kind*/ | 5460 | } else { /* Cyclom-Y of some kind */ |
5374 | index = cinfo->bus_index; | 5461 | index = cinfo->bus_index; |
5375 | spin_lock_init(&cinfo->card_lock); | 5462 | spin_lock_init(&cinfo->card_lock); |
5376 | cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips; | 5463 | cinfo->nports = CyPORTS_PER_CHIP * cinfo->num_chips; |
5377 | for (port = cinfo->first_line ; | 5464 | for (port = cinfo->first_line; |
5378 | port < cinfo->first_line + cinfo->nports ; | 5465 | port < cinfo->first_line + cinfo->nports; port++) { |
5379 | port++) | 5466 | info = &cy_port[port]; |
5380 | { | 5467 | info->magic = CYCLADES_MAGIC; |
5381 | info = &cy_port[port]; | 5468 | info->type = PORT_CIRRUS; |
5382 | info->magic = CYCLADES_MAGIC; | 5469 | info->card = board; |
5383 | info->type = PORT_CIRRUS; | 5470 | info->line = port; |
5384 | info->card = board; | 5471 | info->flags = STD_COM_FLAGS; |
5385 | info->line = port; | 5472 | info->tty = NULL; |
5386 | info->flags = STD_COM_FLAGS; | 5473 | info->xmit_fifo_size = CyMAX_CHAR_FIFO; |
5387 | info->tty = NULL; | 5474 | info->cor1 = |
5388 | info->xmit_fifo_size = CyMAX_CHAR_FIFO; | 5475 | CyPARITY_NONE | Cy_1_STOP | Cy_8_BITS; |
5389 | info->cor1 = CyPARITY_NONE|Cy_1_STOP|Cy_8_BITS; | 5476 | info->cor2 = CyETC; |
5390 | info->cor2 = CyETC; | 5477 | info->cor3 = 0x08; /* _very_ small rcv threshold */ |
5391 | info->cor3 = 0x08; /* _very_ small rcv threshold */ | 5478 | info->cor4 = 0; |
5392 | info->cor4 = 0; | 5479 | info->cor5 = 0; |
5393 | info->cor5 = 0; | 5480 | info->custom_divisor = 0; |
5394 | info->custom_divisor = 0; | 5481 | info->close_delay = 5 * HZ / 10; |
5395 | info->close_delay = 5*HZ/10; | 5482 | info->closing_wait = CLOSING_WAIT_DELAY; |
5396 | info->closing_wait = CLOSING_WAIT_DELAY; | 5483 | info->icount.cts = info->icount.dsr = |
5397 | info->icount.cts = info->icount.dsr = | 5484 | info->icount.rng = info->icount.dcd = 0; |
5398 | info->icount.rng = info->icount.dcd = 0; | 5485 | info->icount.rx = info->icount.tx = 0; |
5399 | info->icount.rx = info->icount.tx = 0; | 5486 | info->icount.frame = info->icount.parity = 0; |
5400 | info->icount.frame = info->icount.parity = 0; | 5487 | info->icount.overrun = info->icount.brk = 0; |
5401 | info->icount.overrun = info->icount.brk = 0; | 5488 | chip_number = (port - cinfo->first_line) / 4; |
5402 | chip_number = (port - cinfo->first_line) / 4; | 5489 | if ((info->chip_rev = |
5403 | if ((info->chip_rev = | 5490 | cy_readb(cinfo->base_addr + |
5404 | cy_readb(cinfo->base_addr + | 5491 | (cy_chip_offset[chip_number] << |
5405 | (cy_chip_offset[chip_number]<<index) + | 5492 | index) + (CyGFRCR << index))) >= |
5406 | (CyGFRCR<<index))) >= CD1400_REV_J) { | 5493 | CD1400_REV_J) { |
5407 | /* It is a CD1400 rev. J or later */ | 5494 | /* It is a CD1400 rev. J or later */ |
5408 | info->tbpr = baud_bpr_60[13]; /* Tx BPR */ | 5495 | info->tbpr = baud_bpr_60[13]; /* Tx BPR */ |
5409 | info->tco = baud_co_60[13]; /* Tx CO */ | 5496 | info->tco = baud_co_60[13]; /* Tx CO */ |
5410 | info->rbpr = baud_bpr_60[13]; /* Rx BPR */ | 5497 | info->rbpr = baud_bpr_60[13]; /* Rx BPR */ |
5411 | info->rco = baud_co_60[13]; /* Rx CO */ | 5498 | info->rco = baud_co_60[13]; /* Rx CO */ |
5412 | info->rflow = 0; | 5499 | info->rflow = 0; |
5413 | info->rtsdtr_inv = 1; | 5500 | info->rtsdtr_inv = 1; |
5414 | } else { | 5501 | } else { |
5415 | info->tbpr = baud_bpr_25[13]; /* Tx BPR */ | 5502 | info->tbpr = baud_bpr_25[13]; /* Tx BPR */ |
5416 | info->tco = baud_co_25[13]; /* Tx CO */ | 5503 | info->tco = baud_co_25[13]; /* Tx CO */ |
5417 | info->rbpr = baud_bpr_25[13]; /* Rx BPR */ | 5504 | info->rbpr = baud_bpr_25[13]; /* Rx BPR */ |
5418 | info->rco = baud_co_25[13]; /* Rx CO */ | 5505 | info->rco = baud_co_25[13]; /* Rx CO */ |
5419 | info->rflow = 0; | 5506 | info->rflow = 0; |
5420 | info->rtsdtr_inv = 0; | 5507 | info->rtsdtr_inv = 0; |
5421 | } | 5508 | } |
5422 | info->x_char = 0; | 5509 | info->x_char = 0; |
5423 | info->event = 0; | 5510 | info->event = 0; |
5424 | info->count = 0; | 5511 | info->count = 0; |
5425 | info->blocked_open = 0; | 5512 | info->blocked_open = 0; |
5426 | info->default_threshold = 0; | 5513 | info->default_threshold = 0; |
5427 | info->default_timeout = 0; | 5514 | info->default_timeout = 0; |
5428 | INIT_WORK(&info->tqueue, do_softint, info); | 5515 | INIT_WORK(&info->tqueue, do_softint); |
5429 | init_waitqueue_head(&info->open_wait); | 5516 | init_waitqueue_head(&info->open_wait); |
5430 | init_waitqueue_head(&info->close_wait); | 5517 | init_waitqueue_head(&info->close_wait); |
5431 | init_waitqueue_head(&info->shutdown_wait); | 5518 | init_waitqueue_head(&info->shutdown_wait); |
5432 | init_waitqueue_head(&info->delta_msr_wait); | 5519 | init_waitqueue_head(&info->delta_msr_wait); |
5433 | /* info->session */ | 5520 | /* info->session */ |
5434 | /* info->pgrp */ | 5521 | /* info->pgrp */ |
5435 | info->read_status_mask = | 5522 | info->read_status_mask = |
5436 | CyTIMEOUT| CySPECHAR| CyBREAK | 5523 | CyTIMEOUT | CySPECHAR | CyBREAK |
5437 | | CyPARITY| CyFRAME| CyOVERRUN; | 5524 | | CyPARITY | CyFRAME | CyOVERRUN; |
5438 | /* info->timeout */ | 5525 | /* info->timeout */ |
5439 | } | 5526 | } |
5440 | } | 5527 | } |
5441 | } | 5528 | } |
5442 | 5529 | ||
5443 | #ifndef CONFIG_CYZ_INTR | 5530 | #ifndef CONFIG_CYZ_INTR |
5444 | if (number_z_boards && !cyz_timeron){ | 5531 | if (number_z_boards && !cyz_timeron) { |
5445 | cyz_timeron++; | 5532 | cyz_timeron++; |
5446 | cyz_timerlist.expires = jiffies + 1; | 5533 | cyz_timerlist.expires = jiffies + 1; |
5447 | add_timer(&cyz_timerlist); | 5534 | add_timer(&cyz_timerlist); |
5448 | #ifdef CY_PCI_DEBUG | 5535 | #ifdef CY_PCI_DEBUG |
5449 | printk("Cyclades-Z polling initialized\n"); | 5536 | printk("Cyclades-Z polling initialized\n"); |
5450 | #endif | 5537 | #endif |
5451 | } | 5538 | } |
5452 | #endif /* CONFIG_CYZ_INTR */ | 5539 | #endif /* CONFIG_CYZ_INTR */ |
5540 | |||
5541 | return 0; | ||
5453 | 5542 | ||
5454 | return 0; | 5543 | } /* cy_init */ |
5455 | |||
5456 | } /* cy_init */ | ||
5457 | 5544 | ||
5458 | static void __exit | 5545 | static void __exit cy_cleanup_module(void) |
5459 | cy_cleanup_module(void) | ||
5460 | { | 5546 | { |
5461 | int i, e1; | 5547 | int i, e1; |
5462 | 5548 | ||
5463 | #ifndef CONFIG_CYZ_INTR | 5549 | #ifndef CONFIG_CYZ_INTR |
5464 | if (cyz_timeron){ | 5550 | if (cyz_timeron){ |
5465 | cyz_timeron = 0; | 5551 | cyz_timeron = 0; |
5466 | del_timer(&cyz_timerlist); | 5552 | del_timer(&cyz_timerlist); |
5467 | } | 5553 | } |
5468 | #endif /* CONFIG_CYZ_INTR */ | 5554 | #endif /* CONFIG_CYZ_INTR */ |
5469 | 5555 | ||
5470 | if ((e1 = tty_unregister_driver(cy_serial_driver))) | 5556 | if ((e1 = tty_unregister_driver(cy_serial_driver))) |
5471 | printk("cyc: failed to unregister Cyclades serial driver(%d)\n", | 5557 | printk("cyc: failed to unregister Cyclades serial driver(%d)\n", |
5472 | e1); | 5558 | e1); |
5473 | 5559 | ||
5474 | put_tty_driver(cy_serial_driver); | 5560 | put_tty_driver(cy_serial_driver); |
5475 | 5561 | ||
5476 | for (i = 0; i < NR_CARDS; i++) { | 5562 | for (i = 0; i < NR_CARDS; i++) { |
5477 | if (cy_card[i].base_addr) { | 5563 | if (cy_card[i].base_addr) { |
5478 | iounmap(cy_card[i].base_addr); | 5564 | iounmap(cy_card[i].base_addr); |
5479 | if (cy_card[i].ctl_addr) | 5565 | if (cy_card[i].ctl_addr) |
5480 | iounmap(cy_card[i].ctl_addr); | 5566 | iounmap(cy_card[i].ctl_addr); |
5481 | if (cy_card[i].irq | 5567 | if (cy_card[i].irq |
5482 | #ifndef CONFIG_CYZ_INTR | 5568 | #ifndef CONFIG_CYZ_INTR |
5483 | && cy_card[i].num_chips != -1 /* not a Z card */ | 5569 | && cy_card[i].num_chips != -1 /* not a Z card */ |
5484 | #endif /* CONFIG_CYZ_INTR */ | 5570 | #endif /* CONFIG_CYZ_INTR */ |
5485 | ) | 5571 | ) |
5486 | free_irq(cy_card[i].irq, &cy_card[i]); | 5572 | free_irq(cy_card[i].irq, &cy_card[i]); |
5487 | #ifdef CONFIG_PCI | 5573 | #ifdef CONFIG_PCI |
5488 | if (cy_card[i].pdev) | 5574 | if (cy_card[i].pdev) |
5489 | pci_release_regions(cy_card[i].pdev); | 5575 | pci_release_regions(cy_card[i].pdev); |
5490 | #endif | 5576 | #endif |
5491 | } | 5577 | } |
5492 | } | 5578 | } |
5493 | if (tmp_buf) { | ||
5494 | free_page((unsigned long) tmp_buf); | ||
5495 | tmp_buf = NULL; | ||
5496 | } | ||
5497 | } /* cy_cleanup_module */ | 5579 | } /* cy_cleanup_module */ |
5498 | 5580 | ||
5499 | module_init(cy_init); | 5581 | module_init(cy_init); |