Home | History | Annotate | Line # | Download | only in dev
scnvar.h revision 1.1.18.1
      1  1.1.18.1    yamt /*	$NetBSD: scnvar.h,v 1.1.18.1 2012/10/30 17:20:17 yamt Exp $	*/
      2       1.1  rumble 
      3       1.1  rumble /*
      4       1.1  rumble  * Copyright (c) 1996, 1997 Philip L. Budne.
      5       1.1  rumble  * Copyright (c) 1993 Philip A. Nelson.
      6       1.1  rumble  * All rights reserved.
      7       1.1  rumble  *
      8       1.1  rumble  * Redistribution and use in source and binary forms, with or without
      9       1.1  rumble  * modification, are permitted provided that the following conditions
     10       1.1  rumble  * are met:
     11       1.1  rumble  * 1. Redistributions of source code must retain the above copyright
     12       1.1  rumble  *    notice, this list of conditions and the following disclaimer.
     13       1.1  rumble  * 2. Redistributions in binary form must reproduce the above copyright
     14       1.1  rumble  *    notice, this list of conditions and the following disclaimer in the
     15       1.1  rumble  *    documentation and/or other materials provided with the distribution.
     16       1.1  rumble  * 3. All advertising materials mentioning features or use of this software
     17       1.1  rumble  *    must display the following acknowledgement:
     18       1.1  rumble  *	This product includes software developed by Philip A. Nelson.
     19       1.1  rumble  * 4. The name of Philip A. Nelson may not be used to endorse or promote
     20       1.1  rumble  *    products derived from this software without specific prior written
     21       1.1  rumble  *    permission.
     22       1.1  rumble  *
     23       1.1  rumble  * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``AS IS'' AND ANY EXPRESS OR
     24       1.1  rumble  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     25       1.1  rumble  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     26       1.1  rumble  * IN NO EVENT SHALL PHILIP NELSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
     27       1.1  rumble  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
     28       1.1  rumble  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
     29       1.1  rumble  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     30       1.1  rumble  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
     31       1.1  rumble  * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     32       1.1  rumble  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33       1.1  rumble  *
     34       1.1  rumble  *	scnvar.h: definitions for pc532 2681/2692/26c96 duart driver
     35       1.1  rumble  */
     36       1.1  rumble 
     37       1.1  rumble /* Constants. */
     38       1.1  rumble #ifdef COMDEF_SPEED
     39       1.1  rumble #undef  TTYDEF_SPEED
     40       1.1  rumble #define TTYDEF_SPEED    COMDEF_SPEED	/* default baud rate */
     41       1.1  rumble #endif
     42       1.1  rumble 
     43       1.1  rumble #define SCN_SIZE	         0x8	/* address space for port */
     44       1.1  rumble 
     45       1.1  rumble #define SCN_CONSOLE		   0	/* minor number of console */
     46       1.1  rumble #define SCN_CONSDUART		   0
     47       1.1  rumble #define SCN_CONSCHAN		   0
     48       1.1  rumble 
     49       1.1  rumble /* output port bits */
     50       1.1  rumble #define OP_RTSA		OP_OP0
     51       1.1  rumble #define OP_RTSB		OP_OP1
     52       1.1  rumble #define OP_DTRA		OP_OP2
     53       1.1  rumble #define OP_DTRB		OP_OP3
     54       1.1  rumble /* OP4-7 not connected */
     55       1.1  rumble 
     56       1.1  rumble /* input port bits */
     57       1.1  rumble #define IP_CTSA		IP_IP0
     58       1.1  rumble #define IP_CTSB		IP_IP1
     59       1.1  rumble #define IP_DCDB		IP_IP2
     60       1.1  rumble #define IP_DCDA		IP_IP3
     61       1.1  rumble /* IP4-6 not connected */
     62       1.1  rumble 
     63       1.1  rumble #define ACR_DELTA_CTSA	ACR_DELTA_IP0
     64       1.1  rumble #define ACR_DELTA_CTSB	ACR_DELTA_IP1
     65       1.1  rumble #define ACR_DELTA_DCDB	ACR_DELTA_IP2
     66       1.1  rumble #define ACR_DELTA_DCDA	ACR_DELTA_IP3
     67       1.1  rumble 
     68       1.1  rumble #define IPCR_CTSA	IPCR_IP0
     69       1.1  rumble #define IPCR_CTSB	IPCR_IP1
     70       1.1  rumble #define IPCR_DCDB	IPCR_IP2
     71       1.1  rumble #define IPCR_DCDA	IPCR_IP3
     72       1.1  rumble #define IPCR_DELTA_CTSA	IPCR_DELTA_IP0
     73       1.1  rumble #define IPCR_DELTA_CTSB	IPCR_DELTA_IP1
     74       1.1  rumble #define IPCR_DELTA_DCDB	IPCR_DELTA_IP2
     75       1.1  rumble #define IPCR_DELTA_DCDA	IPCR_DELTA_IP3
     76       1.1  rumble 
     77       1.1  rumble #define SCN_OP_BIS(SC,VAL) ((SC)->sc_duart->base[DU_OPSET] = (VAL))
     78       1.1  rumble #define SCN_OP_BIC(SC,VAL) ((SC)->sc_duart->base[DU_OPCLR] = (VAL))
     79       1.1  rumble 
     80       1.1  rumble #define SCN_DCD(SC) (((SC)->sc_duart->base[DU_IP] & (SC)->sc_ip_dcd) == 0)
     81       1.1  rumble 
     82       1.1  rumble /* pc532 duarts are auto-sized to byte-wide */
     83       1.1  rumble #define CH_SZ		8
     84       1.1  rumble #define DUART_SZ	16
     85       1.1  rumble #define SCN_REG(n)	(n << 4)		/* 15 byte pad after each reg */
     86       1.1  rumble 
     87       1.1  rumble /* The DUART description struct; for data common to both channels */
     88       1.1  rumble struct duart {
     89       1.1  rumble 	volatile u_char *base;
     90       1.1  rumble 	struct chan {
     91       1.1  rumble 		struct scn_softc *sc;
     92       1.1  rumble 		struct tty *tty;
     93       1.1  rumble 		int32_t ispeed, ospeed;
     94       1.1  rumble 		u_char icode, ocode;
     95       1.1  rumble 		u_char mr0;			/* MR0[7:3] */
     96       1.1  rumble 		u_char new_mr1;		/* held changes */
     97       1.1  rumble 		u_char new_mr2;		/* held changes */
     98       1.1  rumble 	} chan[2];
     99       1.1  rumble 	enum scntype { SCNUNK, SCN2681, SCN2692, SC26C92 } type;
    100       1.1  rumble 	uint16_t counter;		/* C/T generated bps, or zero */
    101       1.1  rumble 	uint16_t ocounter;		/* last C/T generated bps, or zero */
    102       1.1  rumble 	u_char	mode;			/* ACR[7] + MR0[2:0] */
    103       1.1  rumble 	u_char	acr;			/* ACR[6:0]*/
    104       1.1  rumble 	u_char	imr;			/* IMR bits */
    105       1.1  rumble 	u_char	opcr;			/* OPCR bits */
    106       1.1  rumble };
    107       1.1  rumble 
    108       1.1  rumble #define SCN_RING_BITS	9	/* 512 byte buffers */
    109       1.1  rumble #define SCN_RING_SIZE	(1<<SCN_RING_BITS)	/* must be a power of two */
    110       1.1  rumble #define SCN_RING_MASK	(SCN_RING_SIZE-1)
    111       1.1  rumble #define SCN_RING_THRESH	(SCN_RING_SIZE/2)
    112       1.1  rumble #define SCN_RING_HIWAT  (SCN_RING_SIZE - (SCN_RING_SIZE >> 2))
    113       1.1  rumble 
    114       1.1  rumble /* scn channel state */
    115       1.1  rumble struct scn_softc {
    116       1.1  rumble 	struct tty *sc_tty;
    117       1.1  rumble 	int     sc_unit;		/* unit number of this line (base 0) */
    118       1.1  rumble 	int	sc_channel;
    119       1.1  rumble 	int	sc_isconsole;
    120       1.1  rumble 	int	sc_iskgdb;
    121       1.1  rumble 	struct duart *sc_duart;	/* pointer to duart struct */
    122       1.1  rumble 	volatile u_char *sc_chbase;	/* per-channel registers (CH_xxx) */
    123       1.1  rumble 	u_char	sc_swflags;		/* from config / TIOCxFLAGS */
    124       1.1  rumble #define SCN_SW_SOFTCAR	0x01
    125       1.1  rumble #define SCN_SW_CLOCAL	0x02
    126       1.1  rumble #define SCN_SW_CRTSCTS	0x04
    127       1.1  rumble #define SCN_SW_MDMBUF	0x08		/* not implemented */
    128       1.1  rumble 
    129       1.1  rumble /* I wish there was a TS_DIALOUT flag! */
    130       1.1  rumble 	u_char  sc_dialout;		/* set if open for dialout */
    131       1.1  rumble #define SCN_DIALOUT(SCN) ((SCN)->sc_dialout)
    132       1.1  rumble #define SCN_SETDIALOUT(SCN) (SCN)->sc_dialout = 1
    133       1.1  rumble #define SCN_CLRDIALOUT(SCN) (SCN)->sc_dialout = 0
    134       1.1  rumble 
    135       1.1  rumble 	u_char	sc_heldchanges;		/* waiting for output done */
    136       1.1  rumble 
    137       1.1  rumble /* bits in input port register */
    138       1.1  rumble 	u_char  sc_ip_dcd;
    139       1.1  rumble 	u_char  sc_ip_cts;
    140       1.1  rumble 
    141       1.1  rumble /* bits in output port registers */
    142       1.1  rumble 	u_char  sc_op_rts;
    143       1.1  rumble 	u_char  sc_op_dtr;
    144       1.1  rumble 
    145       1.1  rumble /* interrupt mask bits */
    146       1.1  rumble 	u_char  sc_tx_int;
    147       1.1  rumble 	u_char  sc_rx_int;
    148       1.1  rumble 
    149       1.1  rumble /* counters */
    150       1.1  rumble 	u_long	sc_framing_errors;
    151       1.1  rumble 	u_long	sc_parity_errors;
    152       1.1  rumble 	u_long	sc_fifo_overruns;
    153       1.1  rumble 	u_long  sc_breaks;
    154       1.1  rumble 
    155       1.1  rumble /* ring buffer for rxrdy interrupt */
    156       1.1  rumble 	u_int	sc_rbget;		/* ring buffer `get' index */
    157       1.1  rumble 	volatile u_int sc_rbput;	/* ring buffer `put' index */
    158       1.1  rumble 	int	sc_rbhiwat;
    159       1.1  rumble 	short   sc_rbuf[SCN_RING_SIZE];	/* status + data */
    160       1.1  rumble 	long	sc_fotime;		/* last fifo overrun message */
    161       1.1  rumble 	long	sc_rotime;		/* last ring overrun message */
    162       1.1  rumble 	u_long	sc_ring_overruns;	/* number of ring buffer overruns */
    163       1.1  rumble 	/* Flags to communicate with scntty_softint() */
    164       1.1  rumble 	volatile char sc_rx_blocked;	/* input block at ring */
    165       1.1  rumble };
    166