Home | History | Annotate | Line # | Download | only in dev
zs_hb.c revision 1.4.6.2
      1  1.4.6.2  bouyer /*	$NetBSD: zs_hb.c,v 1.4.6.2 2000/11/20 20:17:22 bouyer Exp $	*/
      2  1.4.6.2  bouyer 
      3  1.4.6.2  bouyer /*-
      4  1.4.6.2  bouyer  * Copyright (c) 1996 The NetBSD Foundation, Inc.
      5  1.4.6.2  bouyer  * All rights reserved.
      6  1.4.6.2  bouyer  *
      7  1.4.6.2  bouyer  * This code is derived from software contributed to The NetBSD Foundation
      8  1.4.6.2  bouyer  * by Gordon W. Ross.
      9  1.4.6.2  bouyer  *
     10  1.4.6.2  bouyer  * Redistribution and use in source and binary forms, with or without
     11  1.4.6.2  bouyer  * modification, are permitted provided that the following conditions
     12  1.4.6.2  bouyer  * are met:
     13  1.4.6.2  bouyer  * 1. Redistributions of source code must retain the above copyright
     14  1.4.6.2  bouyer  *    notice, this list of conditions and the following disclaimer.
     15  1.4.6.2  bouyer  * 2. Redistributions in binary form must reproduce the above copyright
     16  1.4.6.2  bouyer  *    notice, this list of conditions and the following disclaimer in the
     17  1.4.6.2  bouyer  *    documentation and/or other materials provided with the distribution.
     18  1.4.6.2  bouyer  * 3. All advertising materials mentioning features or use of this software
     19  1.4.6.2  bouyer  *    must display the following acknowledgement:
     20  1.4.6.2  bouyer  *        This product includes software developed by the NetBSD
     21  1.4.6.2  bouyer  *        Foundation, Inc. and its contributors.
     22  1.4.6.2  bouyer  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  1.4.6.2  bouyer  *    contributors may be used to endorse or promote products derived
     24  1.4.6.2  bouyer  *    from this software without specific prior written permission.
     25  1.4.6.2  bouyer  *
     26  1.4.6.2  bouyer  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  1.4.6.2  bouyer  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  1.4.6.2  bouyer  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  1.4.6.2  bouyer  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  1.4.6.2  bouyer  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  1.4.6.2  bouyer  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  1.4.6.2  bouyer  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  1.4.6.2  bouyer  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  1.4.6.2  bouyer  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  1.4.6.2  bouyer  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  1.4.6.2  bouyer  * POSSIBILITY OF SUCH DAMAGE.
     37  1.4.6.2  bouyer  */
     38  1.4.6.2  bouyer 
     39  1.4.6.2  bouyer /*
     40  1.4.6.2  bouyer  * Zilog Z8530 Dual UART driver (machine-dependent part)
     41  1.4.6.2  bouyer  *
     42  1.4.6.2  bouyer  * Runs two serial lines per chip using slave drivers.
     43  1.4.6.2  bouyer  * Plain tty/async lines use the zs_async slave.
     44  1.4.6.2  bouyer  * Sun keyboard/mouse uses the zs_kbd/zs_ms slaves.
     45  1.4.6.2  bouyer  */
     46  1.4.6.2  bouyer 
     47  1.4.6.2  bouyer #include <sys/param.h>
     48  1.4.6.2  bouyer #include <sys/systm.h>
     49  1.4.6.2  bouyer #include <sys/device.h>
     50  1.4.6.2  bouyer #include <sys/tty.h>
     51  1.4.6.2  bouyer 
     52  1.4.6.2  bouyer #include <machine/adrsmap.h>
     53  1.4.6.2  bouyer #include <machine/autoconf.h>
     54  1.4.6.2  bouyer #include <machine/cpu.h>
     55  1.4.6.2  bouyer #include <machine/z8530var.h>
     56  1.4.6.2  bouyer 
     57  1.4.6.2  bouyer #include <dev/cons.h>
     58  1.4.6.2  bouyer #include <dev/ic/z8530reg.h>
     59  1.4.6.2  bouyer 
     60  1.4.6.2  bouyer #include "zsc.h"	/* NZSC */
     61  1.4.6.2  bouyer #define NZS NZSC
     62  1.4.6.2  bouyer 
     63  1.4.6.2  bouyer /* Make life easier for the initialized arrays here. */
     64  1.4.6.2  bouyer #if NZS < 2
     65  1.4.6.2  bouyer #undef  NZS
     66  1.4.6.2  bouyer #define NZS 2
     67  1.4.6.2  bouyer #endif
     68  1.4.6.2  bouyer 
     69  1.4.6.2  bouyer #define ZSCFLAG_EX	0x01	/* expansion board */
     70  1.4.6.2  bouyer 
     71  1.4.6.2  bouyer /*
     72  1.4.6.2  bouyer  * The news3400 provides a 4.9152 MHz clock to the ZS chips.
     73  1.4.6.2  bouyer  */
     74  1.4.6.2  bouyer #define PCLK	(9600 * 512)	/* PCLK pin input clock rate */
     75  1.4.6.2  bouyer #define PCLK_EX	(9600 * 384)
     76  1.4.6.2  bouyer 
     77  1.4.6.2  bouyer /*
     78  1.4.6.2  bouyer  * Define interrupt levels.
     79  1.4.6.2  bouyer  */
     80  1.4.6.2  bouyer #define ZSHARD_PRI 64
     81  1.4.6.2  bouyer 
     82  1.4.6.2  bouyer #define ZS_DELAY() {(void)*(volatile char *)INTEN1; delay(2);}
     83  1.4.6.2  bouyer 
     84  1.4.6.2  bouyer /* The layout of this is hardware-dependent (padding, order). */
     85  1.4.6.2  bouyer struct zschan {
     86  1.4.6.2  bouyer 	volatile u_char	zc_csr;		/* ctrl,status, and indirect access */
     87  1.4.6.2  bouyer 	volatile u_char	zc_data;	/* data */
     88  1.4.6.2  bouyer };
     89  1.4.6.2  bouyer struct zsdevice {
     90  1.4.6.2  bouyer 	/* Yes, they are backwards. */
     91  1.4.6.2  bouyer 	struct	zschan zs_chan_b;
     92  1.4.6.2  bouyer 	struct	zschan zs_chan_a;
     93  1.4.6.2  bouyer };
     94  1.4.6.2  bouyer 
     95  1.4.6.2  bouyer extern int zs_def_cflag;
     96  1.4.6.2  bouyer extern void (*zs_delay) __P((void));
     97  1.4.6.2  bouyer 
     98  1.4.6.2  bouyer static struct zsdevice *zsaddr[NZS];
     99  1.4.6.2  bouyer 
    100  1.4.6.2  bouyer /* Flags from cninit() */
    101  1.4.6.2  bouyer static int zs_hwflags[NZS][2];
    102  1.4.6.2  bouyer 
    103  1.4.6.2  bouyer /* Default speed for all channels */
    104  1.4.6.2  bouyer static int zs_defspeed = 9600;
    105  1.4.6.2  bouyer 
    106  1.4.6.2  bouyer static u_char zs_init_reg[16] = {
    107  1.4.6.2  bouyer 	0,	/* 0: CMD (reset, etc.) */
    108  1.4.6.2  bouyer 	0,	/* 1: No interrupts yet. */
    109  1.4.6.2  bouyer 	ZSHARD_PRI,	/* IVECT */
    110  1.4.6.2  bouyer 	ZSWR3_RX_8 | ZSWR3_RX_ENABLE,
    111  1.4.6.2  bouyer 	ZSWR4_CLK_X16 | ZSWR4_ONESB | ZSWR4_EVENP,
    112  1.4.6.2  bouyer 	ZSWR5_TX_8 | ZSWR5_TX_ENABLE,
    113  1.4.6.2  bouyer 	0,	/* 6: TXSYNC/SYNCLO */
    114  1.4.6.2  bouyer 	0,	/* 7: RXSYNC/SYNCHI */
    115  1.4.6.2  bouyer 	0,	/* 8: alias for data port */
    116  1.4.6.2  bouyer 	ZSWR9_MASTER_IE,
    117  1.4.6.2  bouyer 	0,	/*10: Misc. TX/RX control bits */
    118  1.4.6.2  bouyer 	ZSWR11_TXCLK_BAUD | ZSWR11_RXCLK_BAUD,
    119  1.4.6.2  bouyer 	((PCLK/32)/9600)-2,	/*12: BAUDLO (default=9600) */
    120  1.4.6.2  bouyer 	0,			/*13: BAUDHI (default=9600) */
    121  1.4.6.2  bouyer 	ZSWR14_BAUD_ENA | ZSWR14_BAUD_FROM_PCLK,
    122  1.4.6.2  bouyer 	ZSWR15_BREAK_IE,
    123  1.4.6.2  bouyer };
    124  1.4.6.2  bouyer 
    125  1.4.6.2  bouyer static struct zschan * zs_get_chan_addr __P((int, int));
    126  1.4.6.2  bouyer static void zs_hb_delay __P((void));
    127  1.4.6.2  bouyer static int zshard_hb __P((void *));
    128  1.4.6.2  bouyer static int zs_getc __P((void *));
    129  1.4.6.2  bouyer static void zs_putc __P((void *, int));
    130  1.4.6.2  bouyer int zshard __P((void *));
    131  1.4.6.2  bouyer int zs_get_speed __P((struct zs_chanstate *));
    132  1.4.6.2  bouyer 
    133  1.4.6.2  bouyer struct zschan *
    134  1.4.6.2  bouyer zs_get_chan_addr(zs_unit, channel)
    135  1.4.6.2  bouyer 	int zs_unit, channel;
    136  1.4.6.2  bouyer {
    137  1.4.6.2  bouyer 	struct zsdevice *addr;
    138  1.4.6.2  bouyer 	struct zschan *zc;
    139  1.4.6.2  bouyer 
    140  1.4.6.2  bouyer 	if (zs_unit >= NZS)
    141  1.4.6.2  bouyer 		return NULL;
    142  1.4.6.2  bouyer 	addr = zsaddr[zs_unit];
    143  1.4.6.2  bouyer 	if (addr == NULL)
    144  1.4.6.2  bouyer 		return NULL;
    145  1.4.6.2  bouyer 	if (channel == 0) {
    146  1.4.6.2  bouyer 		zc = &addr->zs_chan_a;
    147  1.4.6.2  bouyer 	} else {
    148  1.4.6.2  bouyer 		zc = &addr->zs_chan_b;
    149  1.4.6.2  bouyer 	}
    150  1.4.6.2  bouyer 	return (zc);
    151  1.4.6.2  bouyer }
    152  1.4.6.2  bouyer 
    153  1.4.6.2  bouyer void
    154  1.4.6.2  bouyer zs_hb_delay()
    155  1.4.6.2  bouyer {
    156  1.4.6.2  bouyer 	ZS_DELAY();
    157  1.4.6.2  bouyer }
    158  1.4.6.2  bouyer 
    159  1.4.6.2  bouyer /****************************************************************
    160  1.4.6.2  bouyer  * Autoconfig
    161  1.4.6.2  bouyer  ****************************************************************/
    162  1.4.6.2  bouyer 
    163  1.4.6.2  bouyer /* Definition of the driver for autoconfig. */
    164  1.4.6.2  bouyer int zs_hb_match __P((struct device *, struct cfdata *, void *));
    165  1.4.6.2  bouyer void zs_hb_attach __P((struct device *, struct device *, void *));
    166  1.4.6.2  bouyer int zs_print __P((void *, const char *name));
    167  1.4.6.2  bouyer 
    168  1.4.6.2  bouyer struct cfattach zsc_hb_ca = {
    169  1.4.6.2  bouyer 	sizeof(struct zsc_softc), zs_hb_match, zs_hb_attach
    170  1.4.6.2  bouyer };
    171  1.4.6.2  bouyer 
    172  1.4.6.2  bouyer /*
    173  1.4.6.2  bouyer  * Is the zs chip present?
    174  1.4.6.2  bouyer  */
    175  1.4.6.2  bouyer int
    176  1.4.6.2  bouyer zs_hb_match(parent, cf, aux)
    177  1.4.6.2  bouyer 	struct device *parent;
    178  1.4.6.2  bouyer 	struct cfdata *cf;
    179  1.4.6.2  bouyer 	void *aux;
    180  1.4.6.2  bouyer {
    181  1.4.6.2  bouyer 	struct confargs *ca = aux;
    182  1.4.6.2  bouyer 
    183  1.4.6.2  bouyer 	if (strcmp(ca->ca_name, "zsc"))
    184  1.4.6.2  bouyer 		return 0;
    185  1.4.6.2  bouyer 
    186  1.4.6.2  bouyer 	/* This returns -1 on a fault (bus error). */
    187  1.4.6.2  bouyer 	if (badaddr((char *)cf->cf_addr, 1))
    188  1.4.6.2  bouyer 		return 0;
    189  1.4.6.2  bouyer 
    190  1.4.6.2  bouyer 	return 1;
    191  1.4.6.2  bouyer }
    192  1.4.6.2  bouyer 
    193  1.4.6.2  bouyer /*
    194  1.4.6.2  bouyer  * Attach a found zs.
    195  1.4.6.2  bouyer  *
    196  1.4.6.2  bouyer  * Match slave number to zs unit number, so that misconfiguration will
    197  1.4.6.2  bouyer  * not set up the keyboard as ttya, etc.
    198  1.4.6.2  bouyer  */
    199  1.4.6.2  bouyer void
    200  1.4.6.2  bouyer zs_hb_attach(parent, self, aux)
    201  1.4.6.2  bouyer 	struct device *parent;
    202  1.4.6.2  bouyer 	struct device *self;
    203  1.4.6.2  bouyer 	void *aux;
    204  1.4.6.2  bouyer {
    205  1.4.6.2  bouyer 	struct zsc_softc *zsc = (void *)self;
    206  1.4.6.2  bouyer 	/* struct confargs *ca = aux; */
    207  1.4.6.2  bouyer 	struct zsc_attach_args zsc_args;
    208  1.4.6.2  bouyer 	volatile struct zschan *zc;
    209  1.4.6.2  bouyer 	struct zs_chanstate *cs;
    210  1.4.6.2  bouyer 	int s, zs_unit, channel, intlevel;
    211  1.4.6.2  bouyer 	static int didintr;
    212  1.4.6.2  bouyer 
    213  1.4.6.2  bouyer 	zs_unit = zsc->zsc_dev.dv_unit;
    214  1.4.6.2  bouyer 	intlevel = zsc->zsc_dev.dv_cfdata->cf_level;
    215  1.4.6.2  bouyer 	zsaddr[zs_unit] = (void *)zsc->zsc_dev.dv_cfdata->cf_addr;
    216  1.4.6.2  bouyer 
    217  1.4.6.2  bouyer 	if (intlevel == -1) {
    218  1.4.6.2  bouyer #if 0
    219  1.4.6.2  bouyer 		printf(": interrupt level not configured\n");
    220  1.4.6.2  bouyer 		return;
    221  1.4.6.2  bouyer #else
    222  1.4.6.2  bouyer 		printf(": interrupt level not configured; using");
    223  1.4.6.2  bouyer 		intlevel = 1;
    224  1.4.6.2  bouyer #endif
    225  1.4.6.2  bouyer 	}
    226  1.4.6.2  bouyer 
    227  1.4.6.2  bouyer 	printf(" level %d\n", intlevel);
    228  1.4.6.2  bouyer 
    229  1.4.6.2  bouyer 	zs_delay = zs_hb_delay;
    230  1.4.6.2  bouyer 
    231  1.4.6.2  bouyer 	/*
    232  1.4.6.2  bouyer 	 * Initialize software state for each channel.
    233  1.4.6.2  bouyer 	 */
    234  1.4.6.2  bouyer 	for (channel = 0; channel < 2; channel++) {
    235  1.4.6.2  bouyer 		zsc_args.channel = channel;
    236  1.4.6.2  bouyer 		zsc_args.hwflags = zs_hwflags[zs_unit][channel];
    237  1.4.6.2  bouyer 		cs = &zsc->zsc_cs_store[channel];
    238  1.4.6.2  bouyer 		zsc->zsc_cs[channel] = cs;
    239  1.4.6.2  bouyer 
    240  1.4.6.2  bouyer 		cs->cs_channel = channel;
    241  1.4.6.2  bouyer 		cs->cs_private = NULL;
    242  1.4.6.2  bouyer 		cs->cs_ops = &zsops_null;
    243  1.4.6.2  bouyer 		if ((zsc->zsc_dev.dv_cfdata->cf_flags & ZSCFLAG_EX) == 0)
    244  1.4.6.2  bouyer 			cs->cs_brg_clk = PCLK / 16;
    245  1.4.6.2  bouyer 		else
    246  1.4.6.2  bouyer 			cs->cs_brg_clk = PCLK_EX / 16;
    247  1.4.6.2  bouyer 
    248  1.4.6.2  bouyer 		zc = zs_get_chan_addr(zs_unit, channel);
    249  1.4.6.2  bouyer 		cs->cs_reg_csr  = &zc->zc_csr;
    250  1.4.6.2  bouyer 		cs->cs_reg_data = &zc->zc_data;
    251  1.4.6.2  bouyer 
    252  1.4.6.2  bouyer 		bcopy(zs_init_reg, cs->cs_creg, 16);
    253  1.4.6.2  bouyer 		bcopy(zs_init_reg, cs->cs_preg, 16);
    254  1.4.6.2  bouyer 
    255  1.4.6.2  bouyer 		/* XXX: Get these from the EEPROM instead? */
    256  1.4.6.2  bouyer 		/* XXX: See the mvme167 code.  Better. */
    257  1.4.6.2  bouyer 		if (zsc_args.hwflags & ZS_HWFLAG_CONSOLE)
    258  1.4.6.2  bouyer 			cs->cs_defspeed = zs_get_speed(cs);
    259  1.4.6.2  bouyer 		else
    260  1.4.6.2  bouyer 			cs->cs_defspeed = zs_defspeed;
    261  1.4.6.2  bouyer 		cs->cs_defcflag = zs_def_cflag;
    262  1.4.6.2  bouyer 
    263  1.4.6.2  bouyer 		/* Make these correspond to cs_defcflag (-crtscts) */
    264  1.4.6.2  bouyer 		cs->cs_rr0_dcd = ZSRR0_DCD;
    265  1.4.6.2  bouyer 		cs->cs_rr0_cts = 0;
    266  1.4.6.2  bouyer 		cs->cs_wr5_dtr = ZSWR5_DTR | ZSWR5_RTS;
    267  1.4.6.2  bouyer 		cs->cs_wr5_rts = 0;
    268  1.4.6.2  bouyer 
    269  1.4.6.2  bouyer 		/*
    270  1.4.6.2  bouyer 		 * Clear the master interrupt enable.
    271  1.4.6.2  bouyer 		 * The INTENA is common to both channels,
    272  1.4.6.2  bouyer 		 * so just do it on the A channel.
    273  1.4.6.2  bouyer 		 */
    274  1.4.6.2  bouyer 		if (channel == 0) {
    275  1.4.6.2  bouyer 			zs_write_reg(cs, 9, 0);
    276  1.4.6.2  bouyer 		}
    277  1.4.6.2  bouyer 
    278  1.4.6.2  bouyer 		/*
    279  1.4.6.2  bouyer 		 * Look for a child driver for this channel.
    280  1.4.6.2  bouyer 		 * The child attach will setup the hardware.
    281  1.4.6.2  bouyer 		 */
    282  1.4.6.2  bouyer 		if (!config_found(self, (void *)&zsc_args, zs_print)) {
    283  1.4.6.2  bouyer 			/* No sub-driver.  Just reset it. */
    284  1.4.6.2  bouyer 			u_char reset = (channel == 0) ?
    285  1.4.6.2  bouyer 				ZSWR9_A_RESET : ZSWR9_B_RESET;
    286  1.4.6.2  bouyer 			s = splhigh();
    287  1.4.6.2  bouyer 			zs_write_reg(cs, 9, reset);
    288  1.4.6.2  bouyer 			splx(s);
    289  1.4.6.2  bouyer 		}
    290  1.4.6.2  bouyer 	}
    291  1.4.6.2  bouyer 
    292  1.4.6.2  bouyer 	/*
    293  1.4.6.2  bouyer 	 * Now safe to install interrupt handlers.  Note the arguments
    294  1.4.6.2  bouyer 	 * to the interrupt handlers aren't used.  Note, we only do this
    295  1.4.6.2  bouyer 	 * once since both SCCs interrupt at the same level and vector.
    296  1.4.6.2  bouyer 	 */
    297  1.4.6.2  bouyer 	if (!didintr) {
    298  1.4.6.2  bouyer 		didintr = 1;
    299  1.4.6.2  bouyer 
    300  1.4.6.2  bouyer 		hb_intr_establish(intlevel, IPL_SERIAL, zshard_hb, NULL);
    301  1.4.6.2  bouyer 	}
    302  1.4.6.2  bouyer 	/* XXX; evcnt_attach() ? */
    303  1.4.6.2  bouyer 
    304  1.4.6.2  bouyer 	/*
    305  1.4.6.2  bouyer 	 * Set the master interrupt enable and interrupt vector.
    306  1.4.6.2  bouyer 	 * (common to both channels, do it on A)
    307  1.4.6.2  bouyer 	 */
    308  1.4.6.2  bouyer 	cs = zsc->zsc_cs[0];
    309  1.4.6.2  bouyer 	s = splhigh();
    310  1.4.6.2  bouyer 	/* interrupt vector */
    311  1.4.6.2  bouyer 	zs_write_reg(cs, 2, zs_init_reg[2]);
    312  1.4.6.2  bouyer 	/* master interrupt control (enable) */
    313  1.4.6.2  bouyer 	zs_write_reg(cs, 9, zs_init_reg[9]);
    314  1.4.6.2  bouyer 	splx(s);
    315  1.4.6.2  bouyer }
    316  1.4.6.2  bouyer 
    317  1.4.6.2  bouyer /*
    318  1.4.6.2  bouyer  * Our ZS chips all share a common, autovectored interrupt,
    319  1.4.6.2  bouyer  * so we have to look at all of them on each interrupt.
    320  1.4.6.2  bouyer  */
    321  1.4.6.2  bouyer static int
    322  1.4.6.2  bouyer zshard_hb(arg)
    323  1.4.6.2  bouyer 	void *arg;
    324  1.4.6.2  bouyer {
    325  1.4.6.2  bouyer 	(void) *(volatile u_char *)SCCVECT;
    326  1.4.6.2  bouyer 
    327  1.4.6.2  bouyer 	return zshard(arg);
    328  1.4.6.2  bouyer }
    329  1.4.6.2  bouyer 
    330  1.4.6.2  bouyer /*
    331  1.4.6.2  bouyer  * Polled input char.
    332  1.4.6.2  bouyer  */
    333  1.4.6.2  bouyer int
    334  1.4.6.2  bouyer zs_getc(arg)
    335  1.4.6.2  bouyer 	void *arg;
    336  1.4.6.2  bouyer {
    337  1.4.6.2  bouyer 	register volatile struct zschan *zc = arg;
    338  1.4.6.2  bouyer 	register int s, c, rr0;
    339  1.4.6.2  bouyer 
    340  1.4.6.2  bouyer 	s = splhigh();
    341  1.4.6.2  bouyer 	/* Wait for a character to arrive. */
    342  1.4.6.2  bouyer 	do {
    343  1.4.6.2  bouyer 		rr0 = zc->zc_csr;
    344  1.4.6.2  bouyer 		ZS_DELAY();
    345  1.4.6.2  bouyer 	} while ((rr0 & ZSRR0_RX_READY) == 0);
    346  1.4.6.2  bouyer 
    347  1.4.6.2  bouyer 	c = zc->zc_data;
    348  1.4.6.2  bouyer 	ZS_DELAY();
    349  1.4.6.2  bouyer 	splx(s);
    350  1.4.6.2  bouyer 
    351  1.4.6.2  bouyer 	/*
    352  1.4.6.2  bouyer 	 * This is used by the kd driver to read scan codes,
    353  1.4.6.2  bouyer 	 * so don't translate '\r' ==> '\n' here...
    354  1.4.6.2  bouyer 	 */
    355  1.4.6.2  bouyer 	return (c);
    356  1.4.6.2  bouyer }
    357  1.4.6.2  bouyer 
    358  1.4.6.2  bouyer /*
    359  1.4.6.2  bouyer  * Polled output char.
    360  1.4.6.2  bouyer  */
    361  1.4.6.2  bouyer void
    362  1.4.6.2  bouyer zs_putc(arg, c)
    363  1.4.6.2  bouyer 	void *arg;
    364  1.4.6.2  bouyer 	int c;
    365  1.4.6.2  bouyer {
    366  1.4.6.2  bouyer 	register volatile struct zschan *zc = arg;
    367  1.4.6.2  bouyer 	register int s, rr0;
    368  1.4.6.2  bouyer 
    369  1.4.6.2  bouyer 	s = splhigh();
    370  1.4.6.2  bouyer 	/* Wait for transmitter to become ready. */
    371  1.4.6.2  bouyer 	do {
    372  1.4.6.2  bouyer 		rr0 = zc->zc_csr;
    373  1.4.6.2  bouyer 		ZS_DELAY();
    374  1.4.6.2  bouyer 	} while ((rr0 & ZSRR0_TX_READY) == 0);
    375  1.4.6.2  bouyer 
    376  1.4.6.2  bouyer 	zc->zc_data = c;
    377  1.4.6.2  bouyer 	ZS_DELAY();
    378  1.4.6.2  bouyer 	splx(s);
    379  1.4.6.2  bouyer }
    380  1.4.6.2  bouyer 
    381  1.4.6.2  bouyer /*****************************************************************/
    382  1.4.6.2  bouyer 
    383  1.4.6.2  bouyer static void zscnprobe __P((struct consdev *));
    384  1.4.6.2  bouyer static void zscninit __P((struct consdev *));
    385  1.4.6.2  bouyer static int  zscngetc __P((dev_t));
    386  1.4.6.2  bouyer static void zscnputc __P((dev_t, int));
    387  1.4.6.2  bouyer static void zscnpollc __P((dev_t, int));
    388  1.4.6.2  bouyer 
    389  1.4.6.2  bouyer struct consdev consdev_zs = {
    390  1.4.6.2  bouyer 	zscnprobe,
    391  1.4.6.2  bouyer 	zscninit,
    392  1.4.6.2  bouyer 	zscngetc,
    393  1.4.6.2  bouyer 	zscnputc,
    394  1.4.6.2  bouyer 	zscnpollc,
    395  1.4.6.2  bouyer 	NULL,
    396  1.4.6.2  bouyer };
    397  1.4.6.2  bouyer 
    398  1.4.6.2  bouyer void
    399  1.4.6.2  bouyer zscnprobe(cn)
    400  1.4.6.2  bouyer 	struct consdev *cn;
    401  1.4.6.2  bouyer {
    402  1.4.6.2  bouyer }
    403  1.4.6.2  bouyer 
    404  1.4.6.2  bouyer void
    405  1.4.6.2  bouyer zscninit(cn)
    406  1.4.6.2  bouyer 	struct consdev *cn;
    407  1.4.6.2  bouyer {
    408  1.4.6.2  bouyer 	cn->cn_dev = makedev(zs_major, 0);
    409  1.4.6.2  bouyer 	cn->cn_pri = CN_REMOTE;
    410  1.4.6.2  bouyer 	zs_hwflags[0][0] = ZS_HWFLAG_CONSOLE;
    411  1.4.6.2  bouyer }
    412  1.4.6.2  bouyer 
    413  1.4.6.2  bouyer int
    414  1.4.6.2  bouyer zscngetc(dev)
    415  1.4.6.2  bouyer 	dev_t dev;
    416  1.4.6.2  bouyer {
    417  1.4.6.2  bouyer 	return zs_getc((void *)SCCPORT0A);
    418  1.4.6.2  bouyer }
    419  1.4.6.2  bouyer 
    420  1.4.6.2  bouyer void
    421  1.4.6.2  bouyer zscnputc(dev, c)
    422  1.4.6.2  bouyer 	dev_t dev;
    423  1.4.6.2  bouyer 	int c;
    424  1.4.6.2  bouyer {
    425  1.4.6.2  bouyer 	zs_putc((void *)SCCPORT0A, c);
    426  1.4.6.2  bouyer }
    427  1.4.6.2  bouyer 
    428  1.4.6.2  bouyer void
    429  1.4.6.2  bouyer zscnpollc(dev, on)
    430  1.4.6.2  bouyer 	dev_t dev;
    431  1.4.6.2  bouyer 	int on;
    432  1.4.6.2  bouyer {
    433  1.4.6.2  bouyer }
    434