1 /* $NetBSD: cyvar.h,v 1.4 1997/06/17 05:32:46 cgd Exp $ */ 2 3 /* 4 * cy_var.h 5 * 6 * Driver for Cyclades Cyclom-8/16/32 multiport serial cards 7 * (currently not tested with Cyclom-32 cards) 8 * 9 * Timo Rossi, 1996 10 * 11 * Supports both ISA and PCI Cyclom cards 12 */ 13 14 /* #define CY_DEBUG */ 15 #define CY_DEBUG1 16 17 /* 18 * Maximum number of ports per card 19 */ 20 #define CY_MAX_PORTS (CD1400_NO_OF_CHANNELS * CY_MAX_CD1400s) 21 22 #define CY_RX_FIFO_THRESHOLD 6 23 24 /* 25 * Automatic RTS (or actually DTR, the RTS and DTR lines need to be 26 * exchanged) handshake threshold used if CY_HW_RTS is defined 27 */ 28 #define CY_RX_DTR_THRESHOLD 9 29 30 /* 31 * Port number on card encoded in low 5 bits 32 * card number in next 2 bits (only space for 4 cards) 33 * high bit reserved for dialout flag 34 */ 35 #define CY_PORT(x) (minor(x) & 0x1f) 36 #define CY_CARD(x) ((minor(x) >> 5) & 3) 37 #define CY_DIALOUT(x) ((minor(x) & 0x80) != 0) 38 #define CY_DIALIN(x) (!CY_DIALOUT(x)) 39 40 /* 41 * read/write cd1400 registers (when sc_softc-structure is available) 42 */ 43 #define cd_read_reg(sc,chip,reg) bus_space_read_1(sc->sc_memt, \ 44 sc->sc_bsh, sc->sc_cd1400_offs[chip] + \ 45 (((reg << 1)) << sc->sc_bustype)) 46 47 #define cd_write_reg(sc,chip,reg,val) bus_space_write_1(sc->sc_memt, \ 48 sc->sc_bsh, sc->sc_cd1400_offs[chip] + \ 49 (((reg << 1))<< sc->sc_bustype), (val)) 50 51 /* 52 * ibuf is a simple ring buffer. It is always used two 53 * bytes at a time (status and data) 54 */ 55 #define CY_IBUF_SIZE (2*512) 56 57 /* software state for one port */ 58 struct cy_port { 59 int cy_port_num; 60 int cy_chip; 61 struct tty *cy_tty; 62 int cy_openflags; 63 int cy_fifo_overruns; 64 int cy_ibuf_overruns; 65 u_char cy_channel_control; /* last CCR channel control 66 * command bits */ 67 u_char cy_carrier_stat; /* copied from MSVR2 */ 68 u_char cy_flags; 69 u_char *cy_ibuf, *cy_ibuf_end; 70 u_char *cy_ibuf_rd_ptr, *cy_ibuf_wr_ptr; 71 #ifdef CY_DEBUG1 72 int cy_rx_int_count; 73 int cy_tx_int_count; 74 int cy_modem_int_count; 75 int cy_start_count; 76 #endif /* CY_DEBUG1 */ 77 }; 78 79 #define CY_F_CARRIER_CHANGED 0x01 80 #define CY_F_START_BREAK 0x02 81 #define CY_F_END_BREAK 0x04 82 #define CY_F_STOP 0x08 83 #define CY_F_SEND_NUL 0x10 84 #define CY_F_START 0x20 85 86 /* software state for one card */ 87 struct cy_softc { 88 struct device sc_dev; 89 void *sc_ih; 90 bus_space_tag_t sc_memt; 91 bus_space_handle_t sc_bsh; 92 int sc_bustype; 93 int sc_nchips; /* Number of cd1400's on this card */ 94 int sc_cd1400_offs[CY_MAX_CD1400s]; 95 struct cy_port sc_ports[CY_MAX_PORTS]; 96 #ifdef CY_DEBUG1 97 int sc_poll_count1; 98 int sc_poll_count2; 99 #endif 100 }; 101 102 int cy_find __P((struct cy_softc *)); 103 void cy_attach __P((struct device *, struct device *, void *)); 104 int cy_intr __P((void *)); 105