1*7c478bd9Sstevel@tonic-gate /* 2*7c478bd9Sstevel@tonic-gate * CDDL HEADER START 3*7c478bd9Sstevel@tonic-gate * 4*7c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*7c478bd9Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*7c478bd9Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*7c478bd9Sstevel@tonic-gate * with the License. 8*7c478bd9Sstevel@tonic-gate * 9*7c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*7c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*7c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 12*7c478bd9Sstevel@tonic-gate * and limitations under the License. 13*7c478bd9Sstevel@tonic-gate * 14*7c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*7c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*7c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*7c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*7c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*7c478bd9Sstevel@tonic-gate * 20*7c478bd9Sstevel@tonic-gate * CDDL HEADER END 21*7c478bd9Sstevel@tonic-gate */ 22*7c478bd9Sstevel@tonic-gate /* 23*7c478bd9Sstevel@tonic-gate * Copyright (c) 1991-1998 by Sun Microsystems, Inc. 24*7c478bd9Sstevel@tonic-gate * All rights reserved. 25*7c478bd9Sstevel@tonic-gate */ 26*7c478bd9Sstevel@tonic-gate 27*7c478bd9Sstevel@tonic-gate #ifndef _SYS_SER_ASYNC_H 28*7c478bd9Sstevel@tonic-gate #define _SYS_SER_ASYNC_H 29*7c478bd9Sstevel@tonic-gate 30*7c478bd9Sstevel@tonic-gate #pragma ident "%Z%%M% %I% %E% SMI" 31*7c478bd9Sstevel@tonic-gate 32*7c478bd9Sstevel@tonic-gate /* 33*7c478bd9Sstevel@tonic-gate * Initial port setup parameters for async lines 34*7c478bd9Sstevel@tonic-gate */ 35*7c478bd9Sstevel@tonic-gate 36*7c478bd9Sstevel@tonic-gate #include <sys/ksynch.h> 37*7c478bd9Sstevel@tonic-gate 38*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 39*7c478bd9Sstevel@tonic-gate extern "C" { 40*7c478bd9Sstevel@tonic-gate #endif 41*7c478bd9Sstevel@tonic-gate 42*7c478bd9Sstevel@tonic-gate /* 43*7c478bd9Sstevel@tonic-gate * The following macro can be used to generate the baud rate generator's 44*7c478bd9Sstevel@tonic-gate * time constants. The parameters are the input clock to the BRG (eg, 45*7c478bd9Sstevel@tonic-gate * 5000000 for 5MHz) and the desired baud rate. This macro assumes that 46*7c478bd9Sstevel@tonic-gate * the clock needed is 16x the desired baud rate. 47*7c478bd9Sstevel@tonic-gate */ 48*7c478bd9Sstevel@tonic-gate #define ZSTimeConst(InputClock, BaudRate) \ 49*7c478bd9Sstevel@tonic-gate (ushort_t)((((int)InputClock+(BaudRate*16)) \ 50*7c478bd9Sstevel@tonic-gate / (2*(int)(BaudRate*16))) - 2) 51*7c478bd9Sstevel@tonic-gate 52*7c478bd9Sstevel@tonic-gate #define ZSDelayConst(Hertz, FifoSize, BitsByte, BaudRate) \ 53*7c478bd9Sstevel@tonic-gate (ushort_t)((((int)(Hertz)*(FifoSize)*(BitsByte)) \ 54*7c478bd9Sstevel@tonic-gate / (int)(BaudRate)) + 1) 55*7c478bd9Sstevel@tonic-gate 56*7c478bd9Sstevel@tonic-gate #define ZSPEED(n) ZSTimeConst(PCLK, n) 57*7c478bd9Sstevel@tonic-gate 58*7c478bd9Sstevel@tonic-gate #define ZFIFOSZ 3 59*7c478bd9Sstevel@tonic-gate /* 60*7c478bd9Sstevel@tonic-gate * this macro needs a constant Hertz, but we can now have a hires_tick. 61*7c478bd9Sstevel@tonic-gate * ztdelay in zs_async.c converts to a true delay based on hz so we 62*7c478bd9Sstevel@tonic-gate * can use 100 for Hertz here. 63*7c478bd9Sstevel@tonic-gate */ 64*7c478bd9Sstevel@tonic-gate #define ZDELAY(n) ZSDelayConst(100, ZFIFOSZ, NBBY, n) 65*7c478bd9Sstevel@tonic-gate 66*7c478bd9Sstevel@tonic-gate #define ISPEED B9600 67*7c478bd9Sstevel@tonic-gate #define ISPEED_SVID B300 68*7c478bd9Sstevel@tonic-gate #define IFLAGS (CS7|CREAD|PARENB) 69*7c478bd9Sstevel@tonic-gate #define IFLAGS_SVID (CS8|CREAD|HUPCL) 70*7c478bd9Sstevel@tonic-gate #define I_IFLAGS 0 71*7c478bd9Sstevel@tonic-gate #define I_CFLAGS ((ISPEED << IBSHIFT) | ISPEED | CS8 | CREAD | HUPCL) 72*7c478bd9Sstevel@tonic-gate 73*7c478bd9Sstevel@tonic-gate /* 74*7c478bd9Sstevel@tonic-gate * Ring buffer and async line management definitions for CPU lines: 75*7c478bd9Sstevel@tonic-gate */ 76*7c478bd9Sstevel@tonic-gate #ifdef _KERNEL 77*7c478bd9Sstevel@tonic-gate #ifndef _ASM 78*7c478bd9Sstevel@tonic-gate #define RINGBITS 8 /* # of bits in ring ptrs */ 79*7c478bd9Sstevel@tonic-gate #define RINGSIZE (1<<RINGBITS) /* size of ring */ 80*7c478bd9Sstevel@tonic-gate #define RINGMASK (RINGSIZE-1) 81*7c478bd9Sstevel@tonic-gate #define RINGFRAC 2 /* fraction of ring to force flush */ 82*7c478bd9Sstevel@tonic-gate 83*7c478bd9Sstevel@tonic-gate #define RING_INIT(zap) ((zap)->za_rput = (zap)->za_rget = 0) 84*7c478bd9Sstevel@tonic-gate #define RING_CNT(zap) (((zap)->za_rput - (zap)->za_rget) & RINGMASK) 85*7c478bd9Sstevel@tonic-gate #define RING_FRAC(zap) ((int)RING_CNT(zap) >= (int)(RINGSIZE/RINGFRAC)) 86*7c478bd9Sstevel@tonic-gate #define RING_POK(zap, n) ((int)RING_CNT(zap) < (int)(RINGSIZE-(n))) 87*7c478bd9Sstevel@tonic-gate #define RING_PUT(zap, c) \ 88*7c478bd9Sstevel@tonic-gate ((zap)->za_ring[(zap)->za_rput++ & RINGMASK] = (uchar_t)(c)) 89*7c478bd9Sstevel@tonic-gate #define RING_UNPUT(zap) ((zap)->za_rput--) 90*7c478bd9Sstevel@tonic-gate #define RING_GOK(zap, n) ((int)RING_CNT(zap) >= (int)(n)) 91*7c478bd9Sstevel@tonic-gate #define RING_GET(zap) ((zap)->za_ring[(zap)->za_rget++ & RINGMASK]) 92*7c478bd9Sstevel@tonic-gate #define RING_EAT(zap, n) ((zap)->za_rget += (n)) 93*7c478bd9Sstevel@tonic-gate 94*7c478bd9Sstevel@tonic-gate /* 95*7c478bd9Sstevel@tonic-gate * To process parity errors/breaks in-band 96*7c478bd9Sstevel@tonic-gate */ 97*7c478bd9Sstevel@tonic-gate #define SBITS 8 98*7c478bd9Sstevel@tonic-gate #define S_UNMARK 0x00FF 99*7c478bd9Sstevel@tonic-gate #define S_PARERR (0x01<<SBITS) 100*7c478bd9Sstevel@tonic-gate #define S_BREAK (0x02<<SBITS) 101*7c478bd9Sstevel@tonic-gate #define RING_MARK(zap, c, s) \ 102*7c478bd9Sstevel@tonic-gate ((zap)->za_ring[(zap)->za_rput++ & RINGMASK] = ((uchar_t)(c)|(s))) 103*7c478bd9Sstevel@tonic-gate #define RING_UNMARK(zap) \ 104*7c478bd9Sstevel@tonic-gate ((zap)->za_ring[((zap)->za_rget) & RINGMASK] &= S_UNMARK) 105*7c478bd9Sstevel@tonic-gate #define RING_ERR(zap, c) \ 106*7c478bd9Sstevel@tonic-gate ((zap)->za_ring[((zap)->za_rget) & RINGMASK] & (c)) 107*7c478bd9Sstevel@tonic-gate 108*7c478bd9Sstevel@tonic-gate 109*7c478bd9Sstevel@tonic-gate /* 110*7c478bd9Sstevel@tonic-gate * These flags are shared with mcp_async.c and should be kept in sync. 111*7c478bd9Sstevel@tonic-gate */ 112*7c478bd9Sstevel@tonic-gate #define ZAS_WOPEN 0x00000001 /* waiting for open to complete */ 113*7c478bd9Sstevel@tonic-gate #define ZAS_ISOPEN 0x00000002 /* open is complete */ 114*7c478bd9Sstevel@tonic-gate #define ZAS_OUT 0x00000004 /* line being used for dialout */ 115*7c478bd9Sstevel@tonic-gate #define ZAS_CARR_ON 0x00000008 /* carrier on last time we looked */ 116*7c478bd9Sstevel@tonic-gate #define ZAS_STOPPED 0x00000010 /* output is stopped */ 117*7c478bd9Sstevel@tonic-gate #define ZAS_DELAY 0x00000020 /* waiting for delay to finish */ 118*7c478bd9Sstevel@tonic-gate #define ZAS_BREAK 0x00000040 /* waiting for break to finish */ 119*7c478bd9Sstevel@tonic-gate #define ZAS_BUSY 0x00000080 /* waiting for transmission to finish */ 120*7c478bd9Sstevel@tonic-gate #define ZAS_DRAINING 0x00000100 /* waiting for output to drain */ 121*7c478bd9Sstevel@tonic-gate /* from chip */ 122*7c478bd9Sstevel@tonic-gate #define ZAS_SERVICEIMM 0x00000200 /* queue soft interrupt as soon as */ 123*7c478bd9Sstevel@tonic-gate /* receiver interrupt occurs */ 124*7c478bd9Sstevel@tonic-gate #define ZAS_SOFTC_ATTN 0x00000400 /* check soft carrier state in close */ 125*7c478bd9Sstevel@tonic-gate #define ZAS_PAUSED 0x00000800 /* MCP: dma interrupted and pending */ 126*7c478bd9Sstevel@tonic-gate #define ZAS_LNEXT 0x00001000 /* MCP: next input char is quoted */ 127*7c478bd9Sstevel@tonic-gate #define ZAS_XMIT_ACTIVE 0x00002000 /* MCP: Transmit dma running */ 128*7c478bd9Sstevel@tonic-gate #define ZAS_DMA_DONE 0x00004000 /* MCP: DMA done interrupt received */ 129*7c478bd9Sstevel@tonic-gate #define ZAS_ZSA_START 0x00010000 /* MCP: DMA done interrupt received */ 130*7c478bd9Sstevel@tonic-gate 131*7c478bd9Sstevel@tonic-gate 132*7c478bd9Sstevel@tonic-gate /* 133*7c478bd9Sstevel@tonic-gate * Asynchronous protocol private data structure for ZS and MCP/ALM2 134*7c478bd9Sstevel@tonic-gate */ 135*7c478bd9Sstevel@tonic-gate #define ZSA_MIN_RSTANDBY 12 136*7c478bd9Sstevel@tonic-gate #define ZSA_MAX_RSTANDBY 256 137*7c478bd9Sstevel@tonic-gate 138*7c478bd9Sstevel@tonic-gate #define ZSA_RDONE_MIN 60 139*7c478bd9Sstevel@tonic-gate #define ZSA_RDONE_MAX 350 140*7c478bd9Sstevel@tonic-gate 141*7c478bd9Sstevel@tonic-gate struct asyncline { 142*7c478bd9Sstevel@tonic-gate int za_flags; /* random flags */ 143*7c478bd9Sstevel@tonic-gate kcondvar_t za_flags_cv; /* condition variable for flags */ 144*7c478bd9Sstevel@tonic-gate dev_t za_dev; /* device major/minor numbers */ 145*7c478bd9Sstevel@tonic-gate mblk_t *za_xmitblk; /* transmit: active msg block */ 146*7c478bd9Sstevel@tonic-gate mblk_t *za_rcvblk; /* receive: active msg block */ 147*7c478bd9Sstevel@tonic-gate struct zscom *za_common; /* device common data */ 148*7c478bd9Sstevel@tonic-gate tty_common_t za_ttycommon; /* tty driver common data */ 149*7c478bd9Sstevel@tonic-gate bufcall_id_t za_wbufcid; /* id of pending write-side bufcall */ 150*7c478bd9Sstevel@tonic-gate timeout_id_t za_polltid; /* softint poll timeout id */ 151*7c478bd9Sstevel@tonic-gate 152*7c478bd9Sstevel@tonic-gate /* 153*7c478bd9Sstevel@tonic-gate * The following fields are protected by the zs_excl_hi lock. 154*7c478bd9Sstevel@tonic-gate * Some, such as za_flowc, are set only at the base level and 155*7c478bd9Sstevel@tonic-gate * cleared (without the lock) only by the interrupt level. 156*7c478bd9Sstevel@tonic-gate */ 157*7c478bd9Sstevel@tonic-gate uchar_t *za_optr; /* output pointer */ 158*7c478bd9Sstevel@tonic-gate int za_ocnt; /* output count */ 159*7c478bd9Sstevel@tonic-gate uchar_t za_rput; /* producing pointer for input */ 160*7c478bd9Sstevel@tonic-gate uchar_t za_rget; /* consuming pointer for input */ 161*7c478bd9Sstevel@tonic-gate uchar_t za_flowc; /* flow control char to send */ 162*7c478bd9Sstevel@tonic-gate uchar_t za_rr0; /* status latch for break detection */ 163*7c478bd9Sstevel@tonic-gate /* 164*7c478bd9Sstevel@tonic-gate * Each character stuffed into the ring has two bytes associated 165*7c478bd9Sstevel@tonic-gate * with it. The first byte is used to indicate special conditions 166*7c478bd9Sstevel@tonic-gate * and the second byte is the actual data. The ring buffer 167*7c478bd9Sstevel@tonic-gate * needs to be defined as ushort_t to accomodate this. 168*7c478bd9Sstevel@tonic-gate */ 169*7c478bd9Sstevel@tonic-gate ushort_t za_ring[RINGSIZE]; 170*7c478bd9Sstevel@tonic-gate timeout_id_t za_kick_rcv_id; 171*7c478bd9Sstevel@tonic-gate int za_kick_rcv_count; 172*7c478bd9Sstevel@tonic-gate timeout_id_t za_zsa_restart_id; 173*7c478bd9Sstevel@tonic-gate bufcall_id_t za_bufcid; 174*7c478bd9Sstevel@tonic-gate mblk_t *za_rstandby[ZSA_MAX_RSTANDBY]; 175*7c478bd9Sstevel@tonic-gate /* receive: standby message blocks */ 176*7c478bd9Sstevel@tonic-gate mblk_t *za_rdone[ZSA_RDONE_MAX]; 177*7c478bd9Sstevel@tonic-gate /* complete messages to be sent up */ 178*7c478bd9Sstevel@tonic-gate int za_rdone_wptr; 179*7c478bd9Sstevel@tonic-gate int za_rdone_rptr; 180*7c478bd9Sstevel@tonic-gate int za_bad_count_int; 181*7c478bd9Sstevel@tonic-gate uint_t za_rcv_flags_mask; 182*7c478bd9Sstevel@tonic-gate #ifdef ZSA_DEBUG 183*7c478bd9Sstevel@tonic-gate int za_wr; 184*7c478bd9Sstevel@tonic-gate int za_rd; 185*7c478bd9Sstevel@tonic-gate #endif 186*7c478bd9Sstevel@tonic-gate volatile uchar_t za_soft_active; 187*7c478bd9Sstevel@tonic-gate volatile uchar_t za_kick_active; 188*7c478bd9Sstevel@tonic-gate #define DO_STOPC (1<<8) 189*7c478bd9Sstevel@tonic-gate #define DO_ESC (1<<9) 190*7c478bd9Sstevel@tonic-gate #define DO_SERVICEIMM (1<<10) 191*7c478bd9Sstevel@tonic-gate #define DO_TRANSMIT (1<<11) 192*7c478bd9Sstevel@tonic-gate #define DO_RETRANSMIT (1<<12) 193*7c478bd9Sstevel@tonic-gate /* 194*7c478bd9Sstevel@tonic-gate * ZS exclusive stuff. 195*7c478bd9Sstevel@tonic-gate */ 196*7c478bd9Sstevel@tonic-gate short za_break; /* break count */ 197*7c478bd9Sstevel@tonic-gate union { 198*7c478bd9Sstevel@tonic-gate struct { 199*7c478bd9Sstevel@tonic-gate uchar_t _hw; /* overrun (hw) */ 200*7c478bd9Sstevel@tonic-gate uchar_t _sw; /* overrun (sw) */ 201*7c478bd9Sstevel@tonic-gate } _z; 202*7c478bd9Sstevel@tonic-gate ushort_t uover_overrun; 203*7c478bd9Sstevel@tonic-gate } za_uover; 204*7c478bd9Sstevel@tonic-gate #define za_overrun za_uover.uover_overrun 205*7c478bd9Sstevel@tonic-gate #define za_hw_overrun za_uover._z._hw 206*7c478bd9Sstevel@tonic-gate #define za_sw_overrun za_uover._z._sw 207*7c478bd9Sstevel@tonic-gate short za_ext; /* modem status change count */ 208*7c478bd9Sstevel@tonic-gate short za_work; /* work to do flag */ 209*7c478bd9Sstevel@tonic-gate short za_grace_flow_control; 210*7c478bd9Sstevel@tonic-gate uchar_t za_do_kick_rcv_in_softint; 211*7c478bd9Sstevel@tonic-gate uchar_t za_m_error; 212*7c478bd9Sstevel@tonic-gate /* 213*7c478bd9Sstevel@tonic-gate * MCP exclusive stuff. 214*7c478bd9Sstevel@tonic-gate * These should all be protected by a high priority lock. 215*7c478bd9Sstevel@tonic-gate */ 216*7c478bd9Sstevel@tonic-gate uchar_t *za_xoff; /* xoff char in h/w XOFF buffer */ 217*7c478bd9Sstevel@tonic-gate uchar_t za_lnext; /* treat next char as literal */ 218*7c478bd9Sstevel@tonic-gate uchar_t *za_devctl; /* device control reg for this port */ 219*7c478bd9Sstevel@tonic-gate uchar_t *za_dmabuf; /* dma ram buffer for this port */ 220*7c478bd9Sstevel@tonic-gate int za_breakoff; /* SLAVIO */ 221*7c478bd9Sstevel@tonic-gate int za_slav_break; /* SLAVIO */ 222*7c478bd9Sstevel@tonic-gate /* 223*7c478bd9Sstevel@tonic-gate * NTP PPS exclusive stuff. 224*7c478bd9Sstevel@tonic-gate */ 225*7c478bd9Sstevel@tonic-gate short za_pps; /* PPS on? */ 226*7c478bd9Sstevel@tonic-gate }; 227*7c478bd9Sstevel@tonic-gate 228*7c478bd9Sstevel@tonic-gate #endif /* _ASM */ 229*7c478bd9Sstevel@tonic-gate #endif /* _KERNEL */ 230*7c478bd9Sstevel@tonic-gate 231*7c478bd9Sstevel@tonic-gate #ifdef __cplusplus 232*7c478bd9Sstevel@tonic-gate } 233*7c478bd9Sstevel@tonic-gate #endif 234*7c478bd9Sstevel@tonic-gate 235*7c478bd9Sstevel@tonic-gate #endif /* !_SYS_SER_ASYNC_H */ 236