/*
* Resurrected from the old pc532 port 1/18/2009.
*
* XXX- The locking in this is probably totally broken. I haven't attempted
* to get it right, but it seems to work okay anyhow.
*/
/*
* Copyright (c) 1991, 1992, 1993
* The Regents of the University of California. All rights reserved.
*
* Portions of this software were developed by the Computer Systems
* Engineering group at Lawrence Berkeley Laboratory under DARPA
* contract BG 91-66 and contributed to Berkeley.
*
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratory.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
*/
/*
* Copyright (c) 1996, 1997 Philip L. Budne.
* Copyright (c) 1993 Philip A. Nelson.
*
* Portions of this software were developed by the Computer Systems
* Engineering group at Lawrence Berkeley Laboratory under DARPA
* contract BG 91-66 and contributed to Berkeley.
*
* All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Lawrence Berkeley Laboratory.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* 3. All advertising materials mentioning features or use of this software
* must display the following acknowledgement:
* This product includes software developed by the University of
* California, Berkeley and its contributors.
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
* from: @(#)com.c 7.5 (Berkeley) 5/16/91
*/
#ifdef SCN_TIMING
/*
* Keep timing info on latency of software interrupt used by
* the ringbuf code to empty ring buffer.
* "getinfo" program reads data from /dev/kmem.
*/
static struct timeval tstart;
#define NJITTER 100
int scn_njitter = NJITTER;
int scn_jitter[NJITTER];
#endif
#ifdef KGDB
extern int kgdb_dev;
extern int kgdb_rate;
extern int kgdb_debug_init;
#endif
/* XXXXX - fix this */
#define splrtty() spltty()
/* RS-232 configuration routines */
/*
* set chip parameters, or mark for delayed change.
* called at spltty() or on TxEMPTY interrupt.
*
* Reads current values to avoid glitches from redundant sets.
* Perhaps should save last value set to avoid read/write? NOTE:
* Would still need to do read if write not needed to advance MR
* pointer.
*
* new 2/97 -plb
*/
/* input rate high enough so 64 bit time watchdog not
* onerous? */
if (dp->chan[chan].ispeed >= 1200) {
/* set FIFO threshold at 6 for other
* thresholds we could have to set MR1_FFULL
*/
dp->chan[chan].mr0 |= MR0_RXWD | MR0_RXINT;
} else {
dp->chan[chan].mr0 &= ~(MR0_RXWD | MR0_RXINT);
}
/* set speed codes */
csr = (dp->chan[chan].icode<<4) | dp->chan[chan].ocode;
if (sc->sc_chbase[CH_CSR] != csr) {
sc->sc_chbase[CH_CSR] = csr;
}
/* see if counter/timer in use */
if (dp->counter &&
(dp->chan[0].icode == USE_CT || dp->chan[0].ocode == USE_CT ||
dp->chan[1].icode == USE_CT || dp->chan[1].ocode == USE_CT)) {
/* program counter/timer only if necessary */
if (dp->counter != dp->ocounter) {
uint16_t div;
#ifdef DIVS
int i;
/* look for precalculated rate, for minimum error */
for (i = 0; i < DIVS && divs[i].speed <= dp->counter; i++) {
if (divs[i].speed == dp->counter) {
div = divs[i].div;
goto found;
}
}
#endif
/* not found in table; calculate a value (rounding up) */
div = ((long)SCN_CLOCK/16/2 + dp->counter/2) / dp->counter;
found:
/* halt before loading? may ALWAYS glitch?
* reload race may only sometimes glitch??
*/
dp->base[DU_CTUR] = div >> 8;
dp->base[DU_CTLR] = div & 255;
if (dp->ocounter == 0) {
/* not previously used? */
u_char temp;
/* start C/T running */
temp = dp->base[DU_CSTRT];
__USE(temp);
}
dp->ocounter = dp->counter;
}
} else {
/* counter not in use; mark as free */
dp->counter = 0;
}
sc->sc_heldchanges = 0;
/*
* delay a tiny bit to try and avoid tx glitching.
* I know we're at spltty(), but this is much better than the
* old version used DELAY((96000 / out_speed) * 10000)
* -plb
*/
DELAY(10);
}
/*
* iterator function for speeds.
* (could be called "findnextcode")
* Returns sequence of possible speed codes for a given rate.
* should set index to zero before first call.
*
* Could be implemented as a "checkspeed()" function called
* to evaluate table entries, BUT this allows more variety in
* use of C/T with fewer table entries.
*/
static int
scniter(int *index, int wanted, int *counter, int *mode, struct chan *other,
int c92)
{
while (*index < TABENTRIES) {
struct tabent *tp;
tp = table + (*index)++;
if (tp->speed != wanted)
continue;
/* if not a 26C92 only look at MODE0 entries */
if (!c92 && (tp->mode & MR0_MODE) != MR0_MODE_0)
continue;
/*
* check mode;
* OK if this table entry for current mode, or mode not
* yet set, or other channel's rates are available in both
* A and B groups.
*/
/* here after returning all applicable table entries */
/* XXX return sequence of USE_CT with all possible modes?? */
if ((*index)++ == TABENTRIES) {
/* Max C/T rate (even on 26C92?) is 57600 */
if (wanted <= 57600 && (*counter == wanted || *counter == 0)) {
*counter = wanted;
return USE_CT;
}
}
return -1; /* FAIL */
}
/*
* calculate configuration
* rewritten 2/97 -plb
*/
static int
scn_config(int unit, int chan, int ispeed, int ospeed, u_char mr1, u_char mr2)
{
struct scn_softc *sc;
struct duart *dp;
int other; /* opposite of chan */
int mode;
int counter;
int i, o; /* input, output iterator indexes */
int ic, oc; /* input, output codes */
struct chan *ocp; /* other duart channel */
struct tty *otp; /* other channel tty struct */
int c92; /* true if duart is sc26c92 */
int s;
/* Set up softc pointer. */
if (unit >= scn_cd.cd_ndevs)
return ENXIO;
sc = SOFTC(unit);
chan = sc->sc_channel;
other = chan ^ 1;
dp = sc->sc_duart;
ocp = &dp->chan[other];
otp = ocp->tty;
c92 = (dp->type == SC26C92);
/*
* Right now the first combination that works is used.
* Perhaps it should search entire solution space for "best"
* combination. For example, use heuristic weighting of mode
* preferences, and use of counter timer?
*
* For example right now with 2681/2692 when default rate is
* 9600 and other channel is closed setting 19200 will pick
* mode 0a and use counter/timer. Better solution might be
* mode 0b, leaving counter/timer free!
*
* When other channel is open might want to prefer
* leaving counter timer free, or not flipping A/B group?
*/
if (otp && (otp->t_state & TS_ISOPEN)) {
/*
* Other channel open;
* Find speed codes compatible with current mode/counter.
*/
i = 0;
for (;;) {
mode = dp->mode;
counter = dp->counter;
/* NOTE: pass other chan pointer to allow group flipping */
ic = scniter(&i, ispeed, &counter, &mode, ocp, c92);
if (ic == -1)
break;
o = 0;
if ((oc = scniter(&o, ospeed, &counter,
&mode, NULL, c92)) != -1) {
/*
* take first match
*
* Perhaps calculate heuristic "score",
* save score,codes,mode,counter if score
* better than previous best?
*/
goto gotit;
}
}
/* XXX try looping for ospeed? */
} else {
/* other channel closed */
int oo, oi; /* other input, output iterators */
int oic, ooc; /* other input, output codes */
/*
* Here when other channel closed. Finds first
* combination that will allow other channel to be opened
* (with defaults) and fits our needs.
*/
oi = 0;
for (;;) {
mode = ANYMODE;
counter = 0;
/*
* No need to make scn_rx{en,dis}able too efficient,
* they're only called on setup, open & close!
*/
static inline void
scn_rxenable(struct scn_softc *sc)
{
struct duart *dp;
int channel;
dp = sc->sc_duart;
channel = sc->sc_channel;
/* Outputs wire-ored and connected to ICU input for fast rx interrupt. */
if (channel == 0)
dp->opcr |= OPCR_OP4_RXRDYA;
else
dp->opcr |= OPCR_OP5_RXRDYB;
dp->base[DU_OPCR] = dp->opcr;
dp->imr |= sc->sc_rx_int;
dp->base[DU_IMR] = dp->imr;
}
/* If a 2681, the CR_CMD_MR0 is interpreted as a TX_RESET */
if (console) {
ch_base[CH_CR] = CR_ENA_TX;
RECOVER();
}
ch_base[CH_CR] = CR_CMD_MR1;
RECOVER();
ch_base[CH_MR] = mr1;
ch_base[CH_MR] = mr2;
splx(s);
/*
* On IP6 the console chip is duart1. The keyboard/mouse
* is duart0. Each chip has two channels and the channels
* share an interrupt. Duart0 is interrupt 0, duart1 is
* interrupt 1.
*/
if (duartno != 0 && duartno != 1)
panic("scn_attach: bad duartno: %d", duartno);
cpu_intr_establish(duartno, IPL_TTY, scnintr, duart);
if (console) {
DELAY(5 * 10000); /* Let the output go out.... */
}
/*
* Set up the hardware to a base state, in particular:
* o reset transmitter and receiver
* o set speeds and configurations
* o receiver interrupts only (RxRDY and BREAK)
*/
/* No receiver control of RTS. */
ch_base[CH_MR] = 0;
ch_base[CH_MR] = 0;
/* Initialize the uart structure if this is channel A. */
if (first) {
/* Disable all interrupts. */
duart_base[DU_IMR] = duart->imr = 0;
/* Output port config */
duart_base[DU_OPCR] = duart->opcr = 0;
/* Speeds... */
duart->mode = 0;
/*
* Set initial speed to an illegal code that can be changed to
* any other baud.
*/
duart->chan[0].icode = duart->chan[0].ocode = 0x2f;
duart->chan[1].icode = duart->chan[1].ocode = 0x2f;
duart->chan[0].ispeed = duart->chan[0].ospeed = 0;
duart->chan[1].ispeed = duart->chan[1].ospeed = 0;
#ifdef KGDB
major = cdevsw_lookup_major(&scn_cdevsw);
KASSERT(major != NODEVMAJOR);
if (kgdb_dev == makedev(major, unit)) {
if (console)
kgdb_dev = NODEV; /* can't debug over console port */
else {
scninit(kgdb_dev, kgdb_rate);
scn_rxenable(sc);
scn->sc_iskgdb = 1;
kgdb_attach(scncngetc, scncnputc, kgdb_dev);
if (kgdb_debug_init) {
printf("%c ", delim);
kgdb_connect(1);
} else
printf("%c kgdb enabled", delim);
delim = ',';
}
}
#endif
printf("\n");
}
/* ARGSUSED */
int
scnopen(dev_t dev, int flags, int mode, struct lwp *l)
{
struct tty *tp;
int unit = DEV_UNIT(dev);
struct scn_softc *sc;
int error = 0;
if (unit >= scn_cd.cd_ndevs)
return ENXIO;
sc = SOFTC(unit);
if (!sc)
return ENXIO;
#if 0
printf("scn%d: dcd_int ip %x SCN_DCD %x new %x ipcr %x\n",
sc->unit,
sc->sc_duart->base[DU_IP],
SCN_DCD(sc),
new,
sc->sc_duart->base[DU_IPCR]
);
#endif
/* XXX set some flag to have some lower (soft) int call line discipline? */
if (!(*tp->t_linesw->l_modem) (tp, new == 0? 1: 0)) {
SCN_OP_BIC(sc, sc->sc_op_rts | sc->sc_op_dtr);
}
}
/*
* Print out a ring or fifo overrun error message.
*/
static void
scnoverrun(int unit, long *ptime, const char *what)
{
if (*ptime != time_second) {
*ptime = time_second;
log(LOG_WARNING, "scn%d: %s overrun\n", unit, what);
}
}
/*
* Try to block or unblock input using hardware flow-control.
* This is called by kern/tty.c if MDMBUF|CRTSCTS is set, and
* if this function returns non-zero, the TS_TBLOCK flag will
* be set or cleared according to the "stop" arg passed.
*/
int
scnhwiflow(struct tty *tp, int stop)
{
int unit = DEV_UNIT(tp->t_dev);
struct scn_softc *sc = SOFTC(unit);
int s;
s = splrtty();
if (!stop) {
if (sc->sc_rbput - sc->sc_rbget - 1) {
setsoftscn();
}
}
splx(s);
return 1;
}
/*
* Handle rxrdy/ffull interrupt: QUICKLY poll both channels (checking
* status first) and stash data in a ring buffer. Ring buffer scheme
* borowed from sparc/zs.c requires NO interlock on data!
*
* This interrupt should NOT be included in spltty() mask since it
* invokes NO tty code! The whole point is to allow tty input as much
* of the time as possible, while deferring "heavy" character
* processing until later.
*
* see scn.hw.README and scnsoft() for more info.
*
* THIS ROUTINE SHOULD BE KEPT AS CLEAN AS POSSIBLE!!
* IT'S A CANDIDATE FOR RECODING IN ASSEMBLER!!
*/
static inline int
scn_rxintr(struct scn_softc *sc)
{
char sr;
int i, n;
int work;
work = 0;
i = sc->sc_rbput;
while (work <= 10) {
#define SCN_GETCH(SC) \
sr = (SC)->sc_chbase[CH_SR]; \
if ((sr & SR_RX_RDY) == 0) \
break; \
if (sr & (SR_PARITY | SR_FRAME | SR_BREAK | SR_OVERRUN)) \
goto exception; \
work++; \
(SC)->sc_rbuf[i++ & SCN_RING_MASK] = (SC)->sc_chbase[CH_DAT]
SCN_GETCH(sc); SCN_GETCH(sc); SCN_GETCH(sc);
/* XXX more here if 26C92? -plb */
continue;
exception:
#if defined(DDB)
if (sc->sc_isconsole && (sr & SR_BREAK)) {
Debugger();
sr = sc->sc_chbase[CH_SR];
}
#endif
#if defined(KGDB)
if (sc->sc_iskgdb && (sr & SR_RX_RDY)) {
kgdb_connect(1);
sr = sc->sc_chbase[CH_SR];
}
#endif
work++;
sc->sc_rbuf[i++ & SCN_RING_MASK] = (sr << 8) | sc->sc_chbase[CH_DAT];
sc->sc_chbase[CH_CR] = CR_CMD_RESET_ERR; /* resets break? */
RECOVER();
}
/*
* If ring is getting too full, try to block input.
*/
n = i - sc->sc_rbget;
if (sc->sc_rbhiwat && (n > sc->sc_rbhiwat)) {
/* If not CRTSCTS sc_rbhiwat is such that this
* never happens.
* Clear RTS
*/
SCN_OP_BIC(sc, sc->sc_op_rts);
sc->sc_rx_blocked = 1;
}
sc->sc_rbput = i;
return work;
}
static void
scnrxintr(void *arg)
{
struct duart *duart = arg;
int work = 0;
if (duart->chan[0].sc != NULL)
work += scn_rxintr(duart->chan[0].sc);
if (duart->chan[1].sc != NULL)
work += scn_rxintr(duart->chan[1].sc);
if (work > 0) {
setsoftscn(); /* trigger s/w intr */
#ifdef SCN_TIMING
microtime(&tstart);
#endif
}
}
/*
* Here on soft interrupt (at spltty) to empty ring buffers.
*
* Dave's original scheme was to use the DUART receiver timeout
* interrupt. This requires 2692's (which my board doesn't have), and
* I also liked the idea of using the C/T to generate alternate and/or
* arbitrary bauds. -plb
*
* The ringbuffer code comes from Chris Torek's SPARC 44bsd zs driver
* (hence the LBL notice on top of this file), DOES NOT require
* interlocking with interrupt levels!
*
* The 44bsd sparc/zs driver reads the ring buffer from a separate
* zssoftint, while the SunOS 4.x zs driver appears to use
* timeout()'s. timeouts seem to be too slow to deal with high data
* rates. I know, I tried them.
* -plb.
*/
static void
scnsoft(void *arg)
{
int s, unit;
#ifdef SCN_TIMING
struct timeval tend;
u_long t;
microtime(&tend);
t = (tend.tv_sec - tstart.tv_sec) * 1000000 + (tend.tv_usec - tstart.tv_usec);
t = (t + tick / 20) / (tick / 10);
if (t >= NJITTER - 1) {
t = NJITTER - 1;
}
scn_jitter[t]++;
#endif
for (unit = 0; unit < scn_cd.cd_ndevs; unit++) {
struct scn_softc *sc;
struct tty *tp;
int n, get;
/* NOTE: fetch from rbput is atomic */
while (get != (n = sc->sc_rbput)) {
/*
* Compute the number of interrupts in the receive ring.
* If the count is overlarge, we lost some events, and
* must advance to the first valid one. It may get
* overwritten if more data are arriving, but this is
* too expensive to check and gains nothing (we already
* lost out; all we can do at this point is trade one
* kind of loss for another).
*/
n -= get;
if (n > SCN_RING_SIZE) {
scnoverrun(unit, &sc->sc_rotime, "ring");
get += n - SCN_RING_SIZE;
n = SCN_RING_SIZE;
sc->sc_ring_overruns++;
}
while (--n >= 0) {
int c, sr;
if (tp->t_state & TS_TBLOCK) {
sc->sc_rbget = get;
goto done;
}
/* Race to keep ahead of incoming interrupts. */
c = sc->sc_rbuf[get++ & SCN_RING_MASK];
sr = c >> 8; /* extract status */
c &= 0xff; /* leave just character */
if (sr & SR_OVERRUN) {
scnoverrun(unit, &sc->sc_fotime, "fifo");
sc->sc_fifo_overruns++;
}
if (sr & SR_PARITY) {
c |= TTY_PE;
sc->sc_parity_errors++;
}
if (sr & SR_FRAME) {
c |= TTY_FE;
sc->sc_framing_errors++;
}
if (sr & SR_BREAK) {
#if 0
/*
* See DDB_CHECK() comments in
* scnrxintr()
*/
if (sc->sc_isconsole)
Debugger();
#endif
c = TTY_FE | 0;
sc->sc_breaks++;
}
(*tp->t_linesw->l_rint) (c, tp);
if (sc->sc_rx_blocked && n < SCN_RING_THRESH) {
s = splrtty();
sc->sc_rx_blocked = 0;
SCN_OP_BIS(sc, sc->sc_op_rts);
splx(s);
}
}
sc->sc_rbget = get;
}
done: ;
}
}
/* Convert TIOCM_xxx bits to output port bits. */
static unsigned char
opbits(struct scn_softc *sc, int tioc_bits)
{
switch (cmd) {
case TIOCSBRK:
sc->sc_chbase[CH_CR] = CR_CMD_START_BRK;
break;
case TIOCCBRK:
sc->sc_chbase[CH_CR] = CR_CMD_STOP_BRK;
break;
case TIOCSDTR:
SCN_OP_BIS(sc, sc->sc_op_dtr | sc->sc_op_rts);
break;
case TIOCCDTR:
SCN_OP_BIC(sc, sc->sc_op_dtr | sc->sc_op_rts);
break;
case TIOCMSET: {
int s;
unsigned char sbits, cbits;
/* set bits */
sbits = opbits(sc, *(int *) data);
/* get bits to clear */
cbits = ~sbits & (sc->sc_op_dtr | sc->sc_op_rts);
s = spltty();
if (sbits) {
SCN_OP_BIS(sc, sbits);
}
if (cbits) {
SCN_OP_BIC(sc, cbits);
}
splx(s);
break;
}
case TIOCMBIS:
SCN_OP_BIS(sc, opbits(sc, *(int *) data));
break;
case TIOCMBIC:
SCN_OP_BIC(sc, opbits(sc, *(int *) data));
break;
case TIOCMGET: {
int bits;
unsigned char ip;
/* s = spltty(); */
ip = sc->sc_duart->base[DU_IP];
/* splx(s); */
bits = 0;
if (ip & sc->sc_ip_dcd)
bits |= TIOCM_CD;
if (ip & sc->sc_ip_cts)
bits |= TIOCM_CTS;
#if 0
/*
* XXX sigh; cannot get op current state!! even if
* maintained in private, RTS is done in h/w!!
*/
unsigned char op = 0;
if (op & sc->sc_op_dtr)
bits |= TIOCM_DTR;
if (op & sc->sc_op_rts)
bits |= TIOCM_RTS;
#endif
*(int *) data = bits;
break;
}
case TIOCGFLAGS:{
int bits = 0;
if (sc->sc_swflags & SCN_SW_SOFTCAR)
bits |= TIOCFLAG_SOFTCAR;
if (sc->sc_swflags & SCN_SW_CLOCAL)
bits |= TIOCFLAG_CLOCAL;
if (sc->sc_swflags & SCN_SW_CRTSCTS)
bits |= TIOCFLAG_CRTSCTS;
if (sc->sc_swflags & SCN_SW_MDMBUF)
bits |= TIOCFLAG_MDMBUF;
*(int *) data = bits;
break;
}
case TIOCSFLAGS:{
int userbits, driverbits = 0;
userbits = *(int *) data;
if (userbits & TIOCFLAG_SOFTCAR)
driverbits |= SCN_SW_SOFTCAR;
if (userbits & TIOCFLAG_CLOCAL)
driverbits |= SCN_SW_CLOCAL;
if (userbits & TIOCFLAG_CRTSCTS)
driverbits |= SCN_SW_CRTSCTS;
if (userbits & TIOCFLAG_MDMBUF)
driverbits |= SCN_SW_MDMBUF;
sc->sc_swflags = driverbits;
break;
}
default:
return (EPASSTHROUGH);
}
return (0);
}
int
scnparam(struct tty *tp, struct termios *t)
{
int cflag = t->c_cflag;
int unit = DEV_UNIT(tp->t_dev);
char mr1, mr2;
int error;
struct scn_softc *sc = SOFTC(unit);
/* Is this a hang up? */
if (t->c_ospeed == B0) {
SCN_OP_BIC(sc, sc->sc_op_dtr);
/* leave DTR down. see comment in scnclose() -plb */
return (0);
}
mr1 = mr2 = 0;
/* Used by scncninit and kgdb startup. */
int
scninit(dev_t dev, int rate)
{
/* XXX - maintain PROM's settings */
#if 0
volatile u_char *du_base =
(volatile u_char *)MIPS_PHYS_TO_KSEG1(0x1fb80004);
int unit = DEV_UNIT(dev);