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