2 * Copyright (c) 2001 Brian Somers <brian@Awfulhak.org>
3 * based on work by Slawa Olhovchenkov
4 * John Prince <johnp@knight-trosoft.com>
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
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.
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
32 #define W(p) (*(u_int16_t *)(p))
33 #define vW(p) (*(u_int16_t volatile *)(p))
34 #define D(p) (*(u_int32_t *)(p))
35 #define vD(p) (*(u_int32_t volatile *)(p))
38 #define CE_INTERRUPT_BUF_OVERFLOW 1
39 #define CE_TTY_BUF_OVERFLOW 2
41 #define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
43 /*#define DIGI_INTERRUPT*/
50 extern unsigned digi_debug;
51 #define DLOG(level, args) if (digi_debug & (level)) device_printf args
53 #define DLOG(level, args)
59 /* digiboard port structure */
61 struct digi_softc *sc;
65 #define DIGI_DTR_OFF 2
72 volatile struct board_chan *bc;
82 u_char pnum; /* port number */
84 u_char modemfake; /* Modem values to be forced */
86 u_char modem; /* Force values */
88 int active_out; /* nonzero if the callout device is open */
89 u_int wopeners; /* # processes waiting for DCD in open() */
92 * The high level of the driver never reads status registers directly
93 * because there would be too many side effects to handle conveniently.
94 * Instead, it reads copies of the registers stored here by the
97 u_char last_modem_status; /* last MSR read by intr handler */
98 u_char prev_modem_status; /* last MSR handled by high level */
102 struct termios it_in; /* should be in struct tty */
103 struct termios it_out;
106 struct termios lt_in; /* should be in struct tty */
107 struct termios lt_out;
109 u_long bytes_in, bytes_out;
110 u_int delta_error_counts[CE_NTYPES];
113 tcflag_t c_iflag; /* hold true IXON/IXOFF/IXANY */
114 int lcc, lostcc, lbuf;
117 unsigned laltpin : 1; /* Alternate pin settings locked */
118 unsigned ialtpin : 1; /* Initial alternate pin settings */
120 int cd; /* Depends on the altpin setting */
125 * Map TIOCM_* values to digiboard values
127 struct digi_control_signals {
136 enum digi_board_status {
142 /* Digiboard per-board structure */
144 /* struct board_info */
148 enum digi_board_status status;
149 u_short numports; /* number of ports on card */
150 u_int port; /* I/O port */
151 u_int wport; /* window select I/O port */
154 struct resource *mem;
156 struct resource *irq;
165 u_char *vmem; /* virtual memory address */
167 volatile u_char *memevent;
168 long pmem; /* physical memory address */
175 #ifdef DIGI_INTERRUPT
176 struct timeval intr_timestamp;
179 struct digi_p *ports; /* pointer to array of port descriptors */
180 struct tty *ttys; /* pointer to array of TTY structures */
181 volatile struct global_data *gdata;
182 u_char window; /* saved window */
187 enum digi_model model;
188 const struct digi_control_signals *csigs;
190 unsigned pcibus : 1; /* On a PCI bus ? */
192 struct callout_handle callout; /* poll timeout handle */
193 struct callout_handle inttest; /* int test timeout handle */
196 u_char *(*setwin)(struct digi_softc *_sc, unsigned _addr);
197 void (*hidewin)(struct digi_softc *_sc);
198 void (*towin)(struct digi_softc *_sc, int _win);
204 extern devclass_t digi_devclass;
206 extern const struct digi_control_signals digi_xixe_signals;
207 extern const struct digi_control_signals digi_normal_signals;
209 const char *digi_errortxt(int _id);
210 int digi_attach(struct digi_softc *);
211 int digi_detach(device_t _dev);
212 int digi_shutdown(device_t _dev);
213 void digi_delay(struct digi_softc *_sc, const char *_txt,