xref: /netbsd-src/sys/dev/ic/clmpccvar.h (revision cbab9cadce21ae72fac13910001079fff214cc29)
1*cbab9cadSchs /*	$NetBSD: clmpccvar.h,v 1.13 2012/10/27 17:18:20 chs Exp $ */
294719c7bSscw 
394719c7bSscw /*-
494719c7bSscw  * Copyright (c) 1999 The NetBSD Foundation, Inc.
594719c7bSscw  * All rights reserved.
694719c7bSscw  *
794719c7bSscw  * This code is derived from software contributed to The NetBSD Foundation
894719c7bSscw  * by Steve C. Woodford.
994719c7bSscw  *
1094719c7bSscw  * Redistribution and use in source and binary forms, with or without
1194719c7bSscw  * modification, are permitted provided that the following conditions
1294719c7bSscw  * are met:
1394719c7bSscw  * 1. Redistributions of source code must retain the above copyright
1494719c7bSscw  *    notice, this list of conditions and the following disclaimer.
1594719c7bSscw  * 2. Redistributions in binary form must reproduce the above copyright
1694719c7bSscw  *    notice, this list of conditions and the following disclaimer in the
1794719c7bSscw  *    documentation and/or other materials provided with the distribution.
1894719c7bSscw  *
1994719c7bSscw  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
2094719c7bSscw  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
2194719c7bSscw  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
2294719c7bSscw  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
2394719c7bSscw  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
2494719c7bSscw  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
2594719c7bSscw  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
2694719c7bSscw  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
2794719c7bSscw  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
2894719c7bSscw  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
2994719c7bSscw  * POSSIBILITY OF SUCH DAMAGE.
3094719c7bSscw  */
3194719c7bSscw 
3294719c7bSscw #ifndef __clmpccvar_h
3394719c7bSscw #define __clmpccvar_h
3494719c7bSscw 
3594719c7bSscw 
3694719c7bSscw /* Buffer size for character buffer */
3794719c7bSscw #define	CLMPCC_RING_SIZE	512
3894719c7bSscw 
3994719c7bSscw /* How many channels per chip */
4094719c7bSscw #define CLMPCC_NUM_CHANS	4
4194719c7bSscw 
4294719c7bSscw /* Reasons for calling the MD code's iack hook function */
4394719c7bSscw #define CLMPCC_IACK_MODEM	0
4494719c7bSscw #define CLMPCC_IACK_RX		1
4594719c7bSscw #define CLMPCC_IACK_TX		2
4694719c7bSscw 
4794719c7bSscw 
4894719c7bSscw struct clmpcc_softc;
4994719c7bSscw 
5094719c7bSscw /*
5194719c7bSscw  * Each channel is represented by one of the following structures
5294719c7bSscw  */
5394719c7bSscw struct clmpcc_chan {
5494719c7bSscw 	struct tty	*ch_tty;	/* This channel's tty structure */
5594719c7bSscw 	struct clmpcc_softc *ch_sc;	/* Pointer to chip's softc structure */
560ed9dc11Sscw 	u_char		ch_car;		/* Channel number (CD2400_REG_CAR) */
57c5670263Swiz 	u_char		ch_openflags;	/* Persistent TIOC flags */
58ba922d31Sscw 	volatile u_short ch_flags;	/* Various channel-specific flags */
590ed9dc11Sscw #define	CLMPCC_FLG_IS_CONSOLE	0x0001	/* Channel is system console */
60ba922d31Sscw #define CLMPCC_FLG_START_BREAK 	0x0002
61ba922d31Sscw #define CLMPCC_FLG_END_BREAK 	0x0004
62ba922d31Sscw #define CLMPCC_FLG_FIFO_CLEAR	0x0008
63ba922d31Sscw #define CLMPCC_FLG_UPDATE_PARMS	0x0010
64ba922d31Sscw #define CLMPCC_FLG_NEED_INIT	0x0020
65ba922d31Sscw 
66ba922d31Sscw 	u_char		ch_tx_done;
6794719c7bSscw 
6894719c7bSscw 	u_char		ch_control;
6994719c7bSscw 
700ed9dc11Sscw 	/* New port parameters wait here until written by the Tx ISR */
710ed9dc11Sscw 	u_char		ch_tcor;
720ed9dc11Sscw 	u_char		ch_tbpr;
730ed9dc11Sscw 	u_char		ch_rcor;
740ed9dc11Sscw 	u_char		ch_rbpr;
750ed9dc11Sscw 	u_char		ch_cor1;
760ed9dc11Sscw 	u_char		ch_cor2;
770ed9dc11Sscw 	u_char		ch_cor3;
780ed9dc11Sscw 	u_char		ch_cor4;	/* Current Rx Fifo threshold */
790ed9dc11Sscw 	u_char		ch_cor5;
800ed9dc11Sscw 
8194719c7bSscw 	u_int8_t	*ch_ibuf;	/* Start of input ring buffer */
8294719c7bSscw 	u_int8_t	*ch_ibuf_end;	/* End of input ring buffer */
8394719c7bSscw 	u_int8_t	*ch_ibuf_rd;	/* Input buffer tail (reader) */
8494719c7bSscw 	u_int8_t	*ch_ibuf_wr;	/* Input buffer head (writer) */
85ba922d31Sscw 
86ba922d31Sscw 	u_int8_t	*ch_obuf_addr;	/* Output buffer address */
87ba922d31Sscw 	u_int		ch_obuf_size;	/* Output buffer size (in bytes) */
8894719c7bSscw };
8994719c7bSscw 
9094719c7bSscw 
9194719c7bSscw struct clmpcc_softc {
92*cbab9cadSchs 	device_t	sc_dev;
9394719c7bSscw 
9494719c7bSscw 	/*
9594719c7bSscw 	 * The bus/MD-specific attachment code must initialise the
96ba922d31Sscw 	 * following fields before calling 'clmpcc_attach_subr()'.
9794719c7bSscw 	 */
9894719c7bSscw 	bus_space_tag_t	sc_iot;		/* Tag for parent bus */
9994719c7bSscw 	bus_space_handle_t sc_ioh;	/* Handle for chip's regs */
10094719c7bSscw 	void		*sc_data;	/* MD-specific data */
10194719c7bSscw 	int		sc_clk;		/* Clock-rate, in Hz */
102737763fdSscw 	struct evcnt	*sc_evcnt;	/* Parent Event Counter (or NULL) */
10394719c7bSscw 	u_char		sc_vector_base;	/* Vector base reg, or 0 for auto */
104c5670263Swiz 	u_char		sc_rpilr;	/* Receive Priority Interrupt Level */
105c5670263Swiz 	u_char		sc_tpilr;	/* Transmit Priority Interrupt Level */
106c5670263Swiz 	u_char		sc_mpilr;	/* Modem Priority Interrupt Level */
10794719c7bSscw 	int		sc_swaprtsdtr;	/* Non-zero if RTS and DTR swapped */
10894719c7bSscw 	u_int		sc_byteswap;	/* One of the following ... */
10994719c7bSscw #define CLMPCC_BYTESWAP_LOW	0x00	/* *byteswap pin is low */
11094719c7bSscw #define CLMPCC_BYTESWAP_HIGH	0x03	/* *byteswap pin is high */
11194719c7bSscw 
112a1b8e79bSscw 	void		*sc_softintr_cookie;
11394719c7bSscw 
11494719c7bSscw 	/* Called when an interrupt has to be acknowledged in polled mode. */
11518db93c7Sperry 	void		(*sc_iackhook)(struct clmpcc_softc *, int);
11694719c7bSscw 
11794719c7bSscw 	/*
11894719c7bSscw 	 * No user-serviceable parts below
11994719c7bSscw 	 */
12094719c7bSscw 	struct clmpcc_chan sc_chans[CLMPCC_NUM_CHANS];
12194719c7bSscw };
12294719c7bSscw 
12318db93c7Sperry extern void	clmpcc_attach(struct clmpcc_softc *);
12418db93c7Sperry extern int	clmpcc_cnattach(struct clmpcc_softc *, int, int);
12518db93c7Sperry extern int	clmpcc_rxintr(void *);
12618db93c7Sperry extern int	clmpcc_txintr(void *);
12718db93c7Sperry extern int	clmpcc_mdintr(void *);
12818db93c7Sperry extern void 	clmpcc_softintr(void *);
12994719c7bSscw 
13094719c7bSscw #endif	/* __clmpccvar_h */
131