Home | History | Annotate | Line # | Download | only in ic
      1 /*	$NetBSD: z8530sc.h,v 1.26 2009/05/22 03:51:30 mrg Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 1992, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  *
      7  * This software was developed by the Computer Systems Engineering group
      8  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
      9  * contributed to Berkeley.
     10  *
     11  * All advertising materials mentioning features or use of this software
     12  * must display the following acknowledgement:
     13  *	This product includes software developed by the University of
     14  *	California, Lawrence Berkeley Laboratory.
     15  *
     16  * Redistribution and use in source and binary forms, with or without
     17  * modification, are permitted provided that the following conditions
     18  * are met:
     19  * 1. Redistributions of source code must retain the above copyright
     20  *    notice, this list of conditions and the following disclaimer.
     21  * 2. Redistributions in binary form must reproduce the above copyright
     22  *    notice, this list of conditions and the following disclaimer in the
     23  *    documentation and/or other materials provided with the distribution.
     24  * 3. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *	@(#)zsvar.h	8.1 (Berkeley) 6/11/93
     41  */
     42 
     43 /*
     44  * Copyright (c) 1994 Gordon W. Ross
     45  *
     46  * This software was developed by the Computer Systems Engineering group
     47  * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and
     48  * contributed to Berkeley.
     49  *
     50  * All advertising materials mentioning features or use of this software
     51  * must display the following acknowledgement:
     52  *	This product includes software developed by the University of
     53  *	California, Lawrence Berkeley Laboratory.
     54  *
     55  * Redistribution and use in source and binary forms, with or without
     56  * modification, are permitted provided that the following conditions
     57  * are met:
     58  * 1. Redistributions of source code must retain the above copyright
     59  *    notice, this list of conditions and the following disclaimer.
     60  * 2. Redistributions in binary form must reproduce the above copyright
     61  *    notice, this list of conditions and the following disclaimer in the
     62  *    documentation and/or other materials provided with the distribution.
     63  * 3. All advertising materials mentioning features or use of this software
     64  *    must display the following acknowledgement:
     65  *	This product includes software developed by the University of
     66  *	California, Berkeley and its contributors.
     67  * 4. Neither the name of the University nor the names of its contributors
     68  *    may be used to endorse or promote products derived from this software
     69  *    without specific prior written permission.
     70  *
     71  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     72  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     73  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     74  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     75  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     76  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     77  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     78  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     79  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     80  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     81  * SUCH DAMAGE.
     82  *
     83  *	@(#)zsvar.h	8.1 (Berkeley) 6/11/93
     84  */
     85 
     86 #ifdef _KERNEL_OPT
     87 #include "locators.h"
     88 #endif
     89 
     90 /*
     91  * Function vector - per channel
     92  */
     93 struct zs_chanstate;
     94 struct zsops {
     95 	void	(*zsop_rxint)(struct zs_chanstate *);
     96 					/* receive char available */
     97 	void	(*zsop_stint)(struct zs_chanstate *, int);
     98 					/* external/status */
     99 	void	(*zsop_txint)(struct zs_chanstate *);
    100 					/* xmit buffer empty */
    101 	void	(*zsop_softint)(struct zs_chanstate *);
    102 					/* process software interrupt */
    103 };
    104 
    105 extern struct zsops zsops_null;
    106 
    107 
    108 /*
    109  * Software state, per zs channel.
    110  */
    111 struct zs_chanstate {
    112 
    113 	/* Pointers to the device registers. */
    114 	volatile uint8_t *cs_reg_csr; 	/* ctrl, status, and reg. number. */
    115 	volatile uint8_t *cs_reg_data;	/* data or numbered register */
    116 
    117 	int	cs_channel;		/* sub-unit number */
    118 	void   *cs_private;		/* sub-driver data pointer */
    119 	struct zsops *cs_ops;
    120 
    121 	kmutex_t cs_lock;		/* per channel lock */
    122 
    123 	int	cs_brg_clk;		/* BAUD Rate Generator clock
    124 					 * (usually PCLK / 16) */
    125 	int	cs_defspeed;		/* default baud rate */
    126 	int	cs_defcflag;		/* default cflag */
    127 
    128 	/*
    129 	 * We must keep a copy of the write registers as they are
    130 	 * mostly write-only and we sometimes need to set and clear
    131 	 * individual bits (e.g., in WR3).  Not all of these are
    132 	 * needed but 16 bytes is cheap and this makes the addressing
    133 	 * simpler.  Unfortunately, we can only write to some registers
    134 	 * when the chip is not actually transmitting, so whenever
    135 	 * we are expecting a `transmit done' interrupt the preg array
    136 	 * is allowed to `get ahead' of the current values.  In a
    137 	 * few places we must change the current value of a register,
    138 	 * rather than (or in addition to) the pending value; for these
    139 	 * cs_creg[] contains the current value.
    140 	 */
    141 	uint8_t	cs_creg[16];		/* current values */
    142 	uint8_t	cs_preg[16];		/* pending values */
    143 	int 	cs_heldchange;		/* change pending (creg != preg) */
    144 
    145 	uint8_t	cs_rr0;			/* last rr0 processed */
    146 	uint8_t	cs_rr0_delta;		/* rr0 changes at status intr. */
    147 	uint8_t	cs_rr0_mask;		/* rr0 bits that stop output */
    148 	uint8_t	cs_rr0_dcd;		/* which bit to read as DCD */
    149 	uint8_t	cs_rr0_cts;		/* which bit to read as CTS */
    150 	uint8_t	cs_rr0_pps;		/* which bit to use for PPS */
    151 	/* the above is set only while CRTSCTS is enabled. */
    152 
    153 	uint8_t	cs_wr5_dtr;		/* which bit to write as DTR */
    154 	uint8_t	cs_wr5_rts;		/* which bit to write as RTS */
    155 	/* the above is set only while CRTSCTS is enabled. */
    156 
    157 	volatile uint8_t cs_softreq;	/* need soft interrupt call */
    158 	char	cs_spare1;  	/* (for skippy :) */
    159 
    160 	/*
    161 	 * For strange systems that have oddly wired serial ports, we
    162 	 * provide a pointer to the channel state of the port that has
    163 	 * our status lines on it.
    164 	 */
    165 	struct  zs_chanstate *cs_ctl_chan;
    166 
    167 	/* power management hooks */
    168 	int	(*enable)(struct zs_chanstate *);
    169 	void	(*disable)(struct zs_chanstate *);
    170 	int	enabled;
    171 
    172 	/* MD code might define a larger variant of this. */
    173 };
    174 
    175 struct consdev;
    176 struct zsc_attach_args {
    177 	int channel;		/* two serial channels per zsc */
    178 	int hwflags;		/* see definitions below */
    179 	/* `consdev' is only valid if ZS_HWFLAG_USE_CONSDEV is set */
    180 	struct consdev *consdev;
    181 };
    182 
    183 #define	zsccf_channel		cf_loc[ZSCCF_CHANNEL]
    184 
    185 /* In case of split console devices, use these: */
    186 #define ZS_HWFLAG_CONSOLE_INPUT		1
    187 #define ZS_HWFLAG_CONSOLE_OUTPUT	2
    188 #define ZS_HWFLAG_CONSOLE		\
    189 	(ZS_HWFLAG_CONSOLE_INPUT | ZS_HWFLAG_CONSOLE_OUTPUT)
    190 #define ZS_HWFLAG_NO_DCD	4	/* Ignore the DCD bit */
    191 #define ZS_HWFLAG_NO_CTS	8	/* Ignore the CTS bit */
    192 #define ZS_HWFLAG_RAW   	16	/* advise raw mode */
    193 #define ZS_HWFLAG_USE_CONSDEV  	32	/* Use console ops from `consdev' */
    194 #define	ZS_HWFLAG_NORESET	64	/* Don't reset at attach time */
    195 
    196 int 	zsc_intr_soft(void *);
    197 int 	zsc_intr_hard(void *);
    198 
    199 void	zs_abort(struct zs_chanstate *);
    200 void	zs_break(struct zs_chanstate *, int);
    201 void	zs_iflush(struct zs_chanstate *);
    202 void	zs_loadchannelregs(struct zs_chanstate *);
    203 int 	zs_set_speed(struct zs_chanstate *, int);
    204 int 	zs_set_modes(struct zs_chanstate *, int);
    205 void	zs_lock_init(struct zs_chanstate *);
    206 void	zs_lock_chan(struct zs_chanstate *);
    207 void	zs_unlock_chan(struct zs_chanstate *);
    208 
    209 int zs_check_kgdb(struct zs_chanstate *, int);
    210 
    211