Home | History | Annotate | Line # | Download | only in dev
sbjcnvar.h revision 1.6.18.1
      1  1.6.18.1  christos /* $NetBSD: sbjcnvar.h,v 1.6.18.1 2019/06/10 22:06:30 christos Exp $ */
      2       1.1    simonb 
      3       1.1    simonb /*
      4       1.1    simonb  * Copyright 2000, 2001
      5       1.1    simonb  * Broadcom Corporation. All rights reserved.
      6       1.1    simonb  *
      7       1.1    simonb  * This software is furnished under license and may be used and copied only
      8       1.1    simonb  * in accordance with the following terms and conditions.  Subject to these
      9       1.1    simonb  * conditions, you may download, copy, install, use, modify and distribute
     10       1.1    simonb  * modified or unmodified copies of this software in source and/or binary
     11       1.1    simonb  * form. No title or ownership is transferred hereby.
     12       1.1    simonb  *
     13       1.1    simonb  * 1) Any source code used, modified or distributed must reproduce and
     14       1.1    simonb  *    retain this copyright notice and list of conditions as they appear in
     15       1.1    simonb  *    the source file.
     16       1.1    simonb  *
     17       1.1    simonb  * 2) No right is granted to use any trade name, trademark, or logo of
     18       1.2       cgd  *    Broadcom Corporation.  The "Broadcom Corporation" name may not be
     19       1.2       cgd  *    used to endorse or promote products derived from this software
     20       1.2       cgd  *    without the prior written permission of Broadcom Corporation.
     21       1.1    simonb  *
     22       1.1    simonb  * 3) THIS SOFTWARE IS PROVIDED "AS-IS" AND ANY EXPRESS OR IMPLIED
     23       1.1    simonb  *    WARRANTIES, INCLUDING BUT NOT LIMITED TO, ANY IMPLIED WARRANTIES OF
     24       1.1    simonb  *    MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR
     25       1.1    simonb  *    NON-INFRINGEMENT ARE DISCLAIMED. IN NO EVENT SHALL BROADCOM BE LIABLE
     26       1.1    simonb  *    FOR ANY DAMAGES WHATSOEVER, AND IN PARTICULAR, BROADCOM SHALL NOT BE
     27       1.1    simonb  *    LIABLE FOR DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     28       1.1    simonb  *    CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     29       1.1    simonb  *    SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
     30       1.1    simonb  *    BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
     31       1.1    simonb  *    WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     32       1.1    simonb  *    OR OTHERWISE), EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     33       1.1    simonb  */
     34       1.1    simonb 
     35       1.1    simonb /* from: $NetBSD: comvar.h,v 1.32 2000/03/23 07:01:30 thorpej Exp */
     36       1.1    simonb 
     37       1.1    simonb /*
     38       1.1    simonb  * Copyright (c) 1996 Christopher G. Demetriou.  All rights reserved.
     39       1.1    simonb  *
     40       1.1    simonb  * Redistribution and use in source and binary forms, with or without
     41       1.1    simonb  * modification, are permitted provided that the following conditions
     42       1.1    simonb  * are met:
     43       1.1    simonb  * 1. Redistributions of source code must retain the above copyright
     44       1.1    simonb  *    notice, this list of conditions and the following disclaimer.
     45       1.1    simonb  * 2. Redistributions in binary form must reproduce the above copyright
     46       1.1    simonb  *    notice, this list of conditions and the following disclaimer in the
     47       1.1    simonb  *    documentation and/or other materials provided with the distribution.
     48       1.1    simonb  * 3. All advertising materials mentioning features or use of this software
     49       1.1    simonb  *    must display the following acknowledgement:
     50       1.1    simonb  *      This product includes software developed by Christopher G. Demetriou
     51       1.1    simonb  *	for the NetBSD Project.
     52       1.1    simonb  * 4. The name of the author may not be used to endorse or promote products
     53       1.1    simonb  *    derived from this software without specific prior written permission
     54       1.1    simonb  *
     55       1.1    simonb  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
     56       1.1    simonb  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
     57       1.1    simonb  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
     58       1.1    simonb  * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
     59       1.1    simonb  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
     60       1.1    simonb  * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     61       1.1    simonb  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
     62       1.1    simonb  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
     63       1.1    simonb  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
     64       1.1    simonb  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     65       1.1    simonb  */
     66       1.1    simonb 
     67       1.4       tls #ifdef RND_SBJCN
     68       1.6  riastrad #include <sys/rndsource.h>
     69       1.1    simonb #endif
     70       1.1    simonb 
     71       1.1    simonb #include <sys/callout.h>
     72       1.1    simonb 
     73       1.5  christos #define	SBJCN_CHAN(x)		(TTUNIT(x) & 1)
     74       1.5  christos #define	SBJCN_UNIT(x)		(TTUNIT(x) >> 1)
     75       1.5  christos #define	SBJCN_DIALOUT(x)	TTDIALOUT(x)
     76       1.1    simonb 
     77       1.1    simonb #define	SBJCN_TOLERANCE	30	/* baud rate tolerance, in 0.1% units */
     78       1.1    simonb 
     79       1.1    simonb int	sbjcn_cnattach(u_long addr, int chan, int rate,
     80       1.1    simonb 	    tcflag_t cflag);
     81       1.1    simonb #ifdef KGDB
     82       1.1    simonb int	sbjcn_kgdb_attach(u_long addr, int chan, int rate,
     83       1.1    simonb 	    tcflag_t cflag);
     84       1.1    simonb #endif
     85       1.1    simonb int	sbjcn_is_console(u_long addr, int chan);
     86       1.1    simonb 
     87       1.1    simonb /* Hardware flag masks */
     88       1.1    simonb #define	SBJCN_HW_CONSOLE		0x01
     89       1.1    simonb #define	SBJCN_HW_KGDB			0x02
     90       1.1    simonb #define	SBJCN_HW_DEV_OK			0x04
     91       1.1    simonb 
     92       1.1    simonb /* Buffer size for character buffer */
     93       1.1    simonb #define	SBJCN_RING_SIZE		2048
     94       1.1    simonb 
     95       1.1    simonb struct sbjcn_channel {
     96       1.1    simonb 	int		ch_num;
     97       1.1    simonb 	struct sbjcn_softc *ch_sc;
     98       1.1    simonb 	struct tty	*ch_tty;	/* tty struct */
     99       1.1    simonb 	struct callout	ch_diag_callout; /* callout for diagnostic msgs */
    100       1.1    simonb 	struct callout	ch_callout;	/* callout for channel processing */
    101       1.1    simonb 
    102       1.1    simonb 	volatile char	*ch_input_reg;	/* kseg1 addr of input reg */
    103       1.1    simonb 	volatile char	*ch_output_reg;	/* kseg1 addr of outpu reg */
    104       1.1    simonb 	volatile char	*ch_control_reg;/* kseg1 addr of control reg */
    105       1.1    simonb 
    106       1.1    simonb 	volatile int	ch_waiting_input; /*  */
    107       1.1    simonb 	volatile uint64_t ch_input_buf; /* up to 7 buffered bytes */
    108       1.1    simonb 
    109       1.1    simonb 	volatile char	*ch_base;	/* kseg1 addr of channel regs */
    110       1.1    simonb 	volatile char	*ch_isr_base;	/* kseg1 addr of channel ISR */
    111       1.1    simonb 	volatile char	*ch_imr_base;	/* kseg1 addr of channel IMR */
    112       1.1    simonb #ifdef XXXCGDnotyet
    113       1.1    simonb 	volatile char	*ch_inchg_base;	/* kseg1 addr of channel inport-chg */
    114       1.1    simonb #endif
    115       1.1    simonb 
    116       1.1    simonb 	u_int		ch_overflows;
    117       1.1    simonb 	u_int		ch_floods;
    118       1.1    simonb 	u_int		ch_errors;
    119       1.1    simonb 
    120       1.1    simonb 	u_int		ch_hwflags;
    121       1.1    simonb 	u_int		ch_swflags;
    122       1.1    simonb 
    123       1.1    simonb 	u_int		ch_r_hiwat;
    124       1.1    simonb 	u_int		ch_r_lowat;
    125       1.1    simonb 
    126       1.1    simonb 	/* receive ring buffer management */
    127       1.1    simonb 	u_char *volatile ch_rbget;
    128       1.1    simonb 	u_char *volatile ch_rbput;
    129       1.1    simonb  	volatile u_int	ch_rbavail;
    130       1.1    simonb 	u_char		*ch_rbuf;
    131       1.1    simonb 	u_char		*ch_ebuf;
    132       1.1    simonb 
    133       1.1    simonb 	/* transmit buffer management */
    134       1.1    simonb 	u_char		*ch_tba;
    135       1.1    simonb 	u_int		ch_tbc;
    136       1.1    simonb 	u_int		ch_heldtbc;
    137       1.1    simonb 
    138       1.1    simonb 	volatile u_int ch_rx_flags;
    139       1.1    simonb #define	RX_TTY_BLOCKED		0x01
    140       1.1    simonb #define	RX_TTY_OVERFLOWED	0x02
    141       1.1    simonb #define	RX_IBUF_BLOCKED		0x04
    142       1.1    simonb #define	RX_IBUF_OVERFLOWED	0x08
    143       1.1    simonb #define	RX_ANY_BLOCK		0x0f
    144       1.1    simonb 	volatile u_int	ch_tx_busy;
    145       1.1    simonb 	volatile u_int	ch_tx_done;
    146       1.1    simonb 	volatile u_int	ch_tx_stopped;
    147       1.1    simonb 	volatile u_int	ch_rx_ready;
    148       1.1    simonb 
    149       1.1    simonb 	volatile u_char ch_heldchange;
    150       1.1    simonb 
    151       1.1    simonb 	volatile u_int	ch_brc;
    152       1.1    simonb 	volatile u_char	ch_imr;
    153       1.1    simonb 	volatile u_char	ch_iports, ch_iports_delta;
    154       1.1    simonb 	volatile u_char	ch_oports, ch_oports_active;
    155       1.1    simonb 	volatile u_char	ch_mode1, ch_mode2;
    156       1.1    simonb 
    157       1.1    simonb 	u_char		ch_i_dcd, ch_i_cts, ch_i_dsr, ch_i_ri, ch_i_mask;
    158       1.1    simonb 	u_char		ch_o_dtr, ch_o_rts, ch_o_mask;
    159       1.1    simonb 
    160       1.1    simonb 	u_char		ch_i_dcd_pin, ch_i_cts_pin, ch_i_dsr_pin, ch_i_ri_pin;
    161       1.1    simonb 	u_char		ch_o_dtr_pin, ch_o_rts_pin;
    162       1.1    simonb };
    163       1.1    simonb 
    164       1.1    simonb struct sbjcn_softc {
    165       1.3      matt 	device_t	sc_dev;		/* base device */
    166       1.1    simonb 
    167       1.1    simonb 	/* shared data structures */
    168       1.1    simonb 	u_long		sc_addr;	/* phys addr of JTAG console bus_space */
    169       1.1    simonb 
    170       1.1    simonb 	struct sbjcn_channel sc_channels[1];
    171       1.1    simonb };
    172