1 /*        $NetBSD: spifvar.h,v 1.5 2022/10/31 20:30:23 andvar Exp $   */
2 /*        $OpenBSD: spifvar.h,v 1.3 2003/06/02 18:32:41 jason Exp $   */
3 
4 /*
5  * Copyright (c) 1999-2002 Jason L. Wright (jason@thought.net)
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  * 1. Redistributions of source code must retain the above copyright
12  *    notice, this list of conditions and the following disclaimer.
13  * 2. Redistributions in binary form must reproduce the above copyright
14  *    notice, this list of conditions and the following disclaimer in the
15  *    documentation and/or other materials provided with the distribution.
16  *
17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18  * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
21  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
23  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
25  * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
26  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
27  * POSSIBILITY OF SUCH DAMAGE.
28  *
29  * Effort sponsored in part by the Defense Advanced Research Projects
30  * Agency (DARPA) and Air Force Research Laboratory, Air Force
31  * Materiel Command, USAF, under agreement number F30602-01-2-0537.
32  *
33  */
34 
35 #define   SPIF_MAX_SERIAL     8
36 #define SPIF_MAX_PARALLEL 1
37 
38 struct stty_port {
39           struct tty *sp_tty;           /* tty device */
40           struct spif_softc *sp_sc;     /* pointer back to registers */
41           int sp_channel;                         /* channel number */
42           u_char *sp_rbuf;              /* ring buffer start */
43           u_char *sp_rend;              /* ring buffer end */
44           u_char *sp_rget;              /* ring buffer read pointer */
45           u_char *sp_rput;              /* ring buffer write pointer */
46           u_char *sp_txp;                         /* transmit character pointer */
47           int sp_txc;                             /* transmit character counter */
48 
49           int sp_openflags;             /* open flags */
50           int sp_carrier;                         /* software carrier status */
51           int sp_flags;                           /* software state */
52           char sp_dtr;                            /* software dtr status */
53 };
54 
55 struct stty_softc {
56           device_t sc_dev;
57           int       sc_nports;                    /* number of serial ports */
58           struct    stty_port sc_port[SPIF_MAX_SERIAL];
59 };
60 
61 struct sbpp_softc {
62           int       sc_nports;                    /* number of parallel ports */
63 };
64 
65 struct spif_softc {
66           device_t sc_dev;
67           void *sc_stcih;                         /* stc interrupt vector */
68           void *sc_ppcih;                         /* ppc interrupt vector */
69           void *sc_softih;              /* soft interrupt vector */
70           int       sc_rev;                       /* revision level */
71           int       sc_osc;                       /* oscillator speed (hz) */
72           int       sc_node;            /* which sbus node */
73           int       sc_nser;            /* number of serial ports */
74           int       sc_npar;            /* number of parallel ports */
75           int       sc_rev2;            /* cd180 chip revision */
76           bus_space_tag_t sc_bustag;    /* our bus tag */
77           bus_space_handle_t sc_regh;   /* whole register map */
78           bus_space_handle_t sc_stch;   /* STC registers */
79           bus_space_handle_t sc_istch;  /* IACK STC registers */
80           bus_space_handle_t sc_dtrh;   /* DTR registers */
81           bus_space_handle_t sc_ppch;   /* PPC registers */
82           struct    spifregs *sc_regs;  /* registers */
83           struct    stty_softc *sc_ttys;          /* our ttys */
84           struct    sbpp_softc *sc_bpps;          /* our ttys */
85 };
86