[BACK]Return to scnvar.h CVS log [TXT][DIR] Up to [cvs.NetBSD.org] / src / sys / arch / pc532 / dev

File: [cvs.NetBSD.org] / src / sys / arch / pc532 / dev / Attic / scnvar.h (download)

Revision 1.3, Thu Mar 13 10:24:16 1997 UTC (23 years, 11 months ago) by matthias
Branch: MAIN
CVS Tags: yamt-km-base2, yamt-km-base, wrstuden-devbsize-base, wrstuden-devbsize-19991221, wrstuden-devbsize, thorpej_scsipi_nbase, thorpej_scsipi_beforemerge, thorpej_scsipi_base, thorpej_scsipi, thorpej-signal-base, thorpej-signal, thorpej-mips-cache-base, thorpej-mips-cache, thorpej-devvp-base3, thorpej-devvp-base2, thorpej-devvp-base, thorpej-devvp, pre-chs-ubcperf, post-chs-ubcperf, newlock-base, newlock, netbsd-2-base, netbsd-2-1-RELEASE, netbsd-2-1-RC6, netbsd-2-1-RC5, netbsd-2-1-RC4, netbsd-2-1-RC3, netbsd-2-1-RC2, netbsd-2-1-RC1, netbsd-2-1, netbsd-2-0-base, netbsd-2-0-RELEASE, netbsd-2-0-RC5, netbsd-2-0-RC4, netbsd-2-0-RC3, netbsd-2-0-RC2, netbsd-2-0-RC1, netbsd-2-0-3-RELEASE, netbsd-2-0-2-RELEASE, netbsd-2-0-1-RELEASE, netbsd-2-0, netbsd-2, netbsd-1-6-base, netbsd-1-6-RELEASE, netbsd-1-6-RC3, netbsd-1-6-RC2, netbsd-1-6-RC1, netbsd-1-6-PATCH002-RELEASE, netbsd-1-6-PATCH002-RC4, netbsd-1-6-PATCH002-RC3, netbsd-1-6-PATCH002-RC2, netbsd-1-6-PATCH002-RC1, netbsd-1-6-PATCH002, netbsd-1-6-PATCH001-RELEASE, netbsd-1-6-PATCH001-RC3, netbsd-1-6-PATCH001-RC2, netbsd-1-6-PATCH001-RC1, netbsd-1-6-PATCH001, netbsd-1-6, netbsd-1-5-base, netbsd-1-5-RELEASE, netbsd-1-5-PATCH003, netbsd-1-5-PATCH002, netbsd-1-5-PATCH001, netbsd-1-5-BETA2, netbsd-1-5-BETA, netbsd-1-5-ALPHA2, netbsd-1-5, netbsd-1-4-base, netbsd-1-4-RELEASE, netbsd-1-4-PATCH003, netbsd-1-4-PATCH002, netbsd-1-4-PATCH001, netbsd-1-4, netbsd-1-3-base, netbsd-1-3-RELEASE, netbsd-1-3-PATCH003-CANDIDATE2, netbsd-1-3-PATCH003-CANDIDATE1, netbsd-1-3-PATCH003-CANDIDATE0, netbsd-1-3-PATCH003, netbsd-1-3-PATCH002, netbsd-1-3-PATCH001, netbsd-1-3-BETA, netbsd-1-3, nathanw_sa_before_merge, minoura-xpg4dl-base, minoura-xpg4dl, marc-pcmcia-bp, marc-pcmcia-base, marc-pcmcia, kqueue-beforemerge, kqueue-base, kqueue-aftermerge, kqueue, kent-audio1-beforemerge, kent-audio1-base, kent-audio1, kenh-if-detach-base, kenh-if-detach, kame_14_19990705, kame_14_19990628, kame_141_19991130, kame, ifpoll-base, gmcgarry_ucred_base, gmcgarry_ucred, gmcgarry_ctxsw_base, gmcgarry_ctxsw, gehenna-devsw-base, gehenna-devsw, fvdl_fs64_base, fvdl-softdep-base, fvdl-softdep, eeh-paddr_t-base, eeh-paddr_t, eeh-devprop-base, eeh-devprop, comdex-fall-1999-base, comdex-fall-1999, chs-ubc2-newbase, chs-ubc2-base, chs-ubc2, chs-ubc-base, chs-ubc, bouyer-scsipi
Branch point for: yamt-km, ktrace-lwp, kent-audio2
Changes since 1.2: +39 -38 lines

Integrate Phil Budne's latest changes to the scn driver. From his README:
	* Uses Counter/Timer dynamicly for rate generation; You can
	  have both 19200 and 38400 on one duart, and 57600 on another!
	* Improved scninfo program to dump driver internal information.
	  implemented counters for parity err, framing err, break
	* Delays changes until transmitter idle to avoid "glitches"
	* Cleaned up scn_softc member names
	* Untested support for sc26c92 (I don't yet have any to test with);
	  + Will use alternate rate tables (include 115.2kbps and 230.4kbps)
	  + Will raise FIFO rx interrupt threshold and watchdog timer
	    at higher rates.
	  + Unknown (to me) how fast pc532 MC145406 driver chips can go

	NOTE: It seems like it may be a BAD idea to use a sc26c92 as
	a console port for now; the PROM doesn't know to reset the
	chip back to scn2692 mode!!

/*	$NetBSD: scnvar.h,v 1.3 1997/03/13 10:24:16 matthias Exp $	*/

/*
 * Copyright (c) 1996, 1997 Philip L. Budne.
 * Copyright (c) 1993 Philip A. Nelson.
 * All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 * 3. All advertising materials mentioning features or use of this software
 *    must display the following acknowledgement:
 *	This product includes software developed by Philip A. Nelson.
 * 4. The name of Philip A. Nelson may not be used to endorse or promote
 *    products derived from this software without specific prior written
 *    permission.
 *
 * THIS SOFTWARE IS PROVIDED BY PHILIP NELSON ``AS IS'' AND ANY EXPRESS OR
 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
 * IN NO EVENT SHALL PHILIP NELSON BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 *
 *	scnvar.h: definitions for pc532 2681/2692/26c96 duart driver
 */

/* Constants. */
#ifdef COMDEF_SPEED
#undef  TTYDEF_SPEED
#define TTYDEF_SPEED    COMDEF_SPEED	/* default baud rate */
#endif

#define SCN_FIRST_ADR	  0x28000000	/* address of first RS232 port */
#define SCN_FIRST_MAP_ADR 0xFFC80000	/* mapped address of first port */

#define SCN_SIZE	         0x8	/* address space for port */

#define SCN_CONSOLE 		   0	/* minor number of console */

#define SCN_CON_MAP_STAT  0xFFC80001	/* raw addresses for console */
#define SCN_CON_MAP_DATA  0xFFC80003	/* Mapped .... */
#define SCN_CON_MAP_ISR	  0xFFC80005

#define SCN_CON_STAT 	  0x28000001	/* raw addresses for console */
#define SCN_CON_DATA  	  0x28000003	/* Unmapped .... */
#define SCN_CON_ISR	  0x28000005

/* output port bits */
#define OP_RTSA		OP_OP0
#define OP_RTSB		OP_OP1
#define OP_DTRA		OP_OP2
#define OP_DTRB		OP_OP3
/* OP4-7 not connected */

/* input port bits */
#define IP_CTSA		IP_IP0
#define IP_CTSB		IP_IP1
#define IP_DCDB		IP_IP2
#define IP_DCDA		IP_IP3
/* IP4-6 not connected */

#define ACR_DELTA_CTSA	ACR_DELTA_IP0
#define ACR_DELTA_CTSB	ACR_DELTA_IP1
#define ACR_DELTA_DCDB	ACR_DELTA_IP2
#define ACR_DELTA_DCDA	ACR_DELTA_IP3

#define IPCR_CTSA	IPCR_IP0
#define IPCR_CTSB	IPCR_IP1
#define IPCR_DCDB	IPCR_IP2
#define IPCR_DCDA	IPCR_IP3
#define IPCR_DELTA_CTSA	IPCR_DELTA_IP0
#define IPCR_DELTA_CTSB	IPCR_DELTA_IP1
#define IPCR_DELTA_DCDB	IPCR_DELTA_IP2
#define IPCR_DELTA_DCDA	IPCR_DELTA_IP3

#define SCN_OP_BIS(SC,VAL) ((SC)->sc_duart->base[DU_OPSET] = (VAL))
#define SCN_OP_BIC(SC,VAL) ((SC)->sc_duart->base[DU_OPCLR] = (VAL))

#define SCN_DCD(SC) (((SC)->sc_duart->base[DU_IP] & (SC)->sc_ip_dcd) == 0)

/* pc532 duarts are auto-sized to byte-wide */
#define CH_SZ		8
#define DUART_SZ	16
#define SCN_REG(n)	(n)		/* n'th reg at n'th byte!! */

/* The DUART description struct; for data common to both channels */
struct duart {
	volatile u_char *base;
	struct chan {
	    int32_t ispeed, ospeed;
	    u_char icode, ocode;
	    u_char mr0;			/* MR0[7:3] */
	    u_char new_mr1;		/* held changes */
	    u_char new_mr2;		/* held changes */
	} chan[2];
	enum scntype { SCNUNK, SCN2681, SCN2692, SC26C92 } type;
	u_int16_t counter;		/* C/T generated bps, or zero */
	u_int16_t ocounter;		/* last C/T generated bps, or zero */
	u_char	mode;			/* ACR[7] + MR0[2:0] */
	u_char	acr;			/* ACR[6:0]*/
	u_char	imr;			/* IMR bits */
	u_char	opcr;			/* OPCR bits */
};

#define SCN_RING_BITS	9	/* 512 byte buffers */
#define SCN_RING_SIZE	(1<<SCN_RING_BITS)	/* must be a power of two */
#define SCN_RING_MASK	(SCN_RING_SIZE-1)
#define SCN_RING_THRESH	(SCN_RING_SIZE/2)
#define SCN_RING_HIWAT  (SCN_RING_SIZE - (SCN_RING_SIZE >> 2))

/* scn channel state */
struct scn_softc {
	struct device sc_dev;
	struct tty *sc_tty;
	int     sc_unit;		/* unit number of this line (base 0) */
	struct duart *sc_duart;	/* pointer to duart struct */
	volatile u_char *sc_chbase;	/* per-channel registers (CH_xxx) */
	u_char	sc_swflags;		/* from config / TIOCxFLAGS */
#define SCN_SW_SOFTCAR	0x01
#define SCN_SW_CLOCAL	0x02
#define SCN_SW_CRTSCTS	0x04
#define SCN_SW_MDMBUF	0x08		/* not implemented */

/* I wish there was a TS_DIALOUT flag! */
	u_char  sc_dialout;		/* set if open for dialout */
#define SCN_DIALOUT(SCN) ((SCN)->sc_dialout)
#define SCN_SETDIALOUT(SCN) (SCN)->sc_dialout = 1
#define SCN_CLRDIALOUT(SCN) (SCN)->sc_dialout = 0

	u_char	sc_heldchanges;		/* waiting for output done */

/* bits in input port register */
	u_char  sc_ip_dcd;
	u_char  sc_ip_cts;

/* bits in output port registers */
	u_char  sc_op_rts;
	u_char  sc_op_dtr;

/* interrupt mask bits */
	u_char  sc_tx_int;

/* counters */
	u_long	sc_framing_errors;
	u_long	sc_parity_errors;
	u_long	sc_fifo_overruns;
	u_long  sc_breaks;

/* ring buffer for rxrdy interrupt */
	u_int	sc_rbget;		/* ring buffer `get' index */
	volatile u_int sc_rbput;	/* ring buffer `put' index */
	int	sc_rbhiwat;
	short   sc_rbuf[SCN_RING_SIZE];	/* status + data */
	long	sc_fotime;		/* last fifo overrun message */
	long	sc_rotime;		/* last ring overrun message */
	u_long	sc_ring_overruns;	/* number of ring buffer overruns */
	/* Flags to communicate with scntty_softint() */
	volatile char sc_rx_blocked;	/* input block at ring */
};