1*4f7c8158Srin /* $NetBSD: zsvar.h,v 1.9 2020/03/13 01:48:16 rin Exp $ */ 2453e503bSfredette 3453e503bSfredette /* 4453e503bSfredette * Copyright (c) 1992, 1993 5453e503bSfredette * The Regents of the University of California. All rights reserved. 6453e503bSfredette * 7453e503bSfredette * This software was developed by the Computer Systems Engineering group 8453e503bSfredette * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 9453e503bSfredette * contributed to Berkeley. 10453e503bSfredette * 11453e503bSfredette * All advertising materials mentioning features or use of this software 12453e503bSfredette * must display the following acknowledgement: 13453e503bSfredette * This product includes software developed by the University of 14453e503bSfredette * California, Lawrence Berkeley Laboratory. 15453e503bSfredette * 16453e503bSfredette * Redistribution and use in source and binary forms, with or without 17453e503bSfredette * modification, are permitted provided that the following conditions 18453e503bSfredette * are met: 19453e503bSfredette * 1. Redistributions of source code must retain the above copyright 20453e503bSfredette * notice, this list of conditions and the following disclaimer. 21453e503bSfredette * 2. Redistributions in binary form must reproduce the above copyright 22453e503bSfredette * notice, this list of conditions and the following disclaimer in the 23453e503bSfredette * documentation and/or other materials provided with the distribution. 24aad01611Sagc * 3. Neither the name of the University nor the names of its contributors 25453e503bSfredette * may be used to endorse or promote products derived from this software 26453e503bSfredette * without specific prior written permission. 27453e503bSfredette * 28453e503bSfredette * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29453e503bSfredette * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30453e503bSfredette * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31453e503bSfredette * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32453e503bSfredette * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33453e503bSfredette * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34453e503bSfredette * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35453e503bSfredette * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36453e503bSfredette * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37453e503bSfredette * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38453e503bSfredette * SUCH DAMAGE. 39453e503bSfredette * 40453e503bSfredette * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 41453e503bSfredette */ 42453e503bSfredette 43453e503bSfredette #include <machine/bus.h> 44453e503bSfredette #include <dev/ic/z8530sc.h> 45453e503bSfredette #include <sun2/dev/zsreg.h> 46453e503bSfredette 47*4f7c8158Srin #ifdef _KERNEL_OPT 48*4f7c8158Srin #include "kbd.h" 49*4f7c8158Srin #endif 50*4f7c8158Srin 51*4f7c8158Srin #if NKBD > 0 52453e503bSfredette /* 53453e503bSfredette * Need to override cn_console_dev() for zstty and zskbd. 54453e503bSfredette */ 55453e503bSfredette extern struct consdev *cn_hw; 56*4f7c8158Srin #undef cn_isconsole 57453e503bSfredette #define cn_isconsole(d) ((d) == cn_tab->cn_dev || (d) == cn_hw->cn_dev) 58*4f7c8158Srin #endif 59453e503bSfredette 60453e503bSfredette struct zsc_softc { 6102cb47caStsutsui device_t zsc_dev; /* base device */ 621ffa7b76Swiz bus_space_tag_t zsc_bustag; /* bus space/DMA tags */ 63453e503bSfredette bus_dma_tag_t zsc_dmatag; 64453e503bSfredette struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ 65453e503bSfredette 66453e503bSfredette /* Machine-dependent part follows... */ 67453e503bSfredette void *zsc_softintr; 68453e503bSfredette int zsc_promunit; /* PROM's view of zs devices */ 69453e503bSfredette int zsc_node; /* PROM node, if any */ 70453e503bSfredette struct evcnt zsc_intrcnt; /* count interrupts */ 71453e503bSfredette struct zs_chanstate zsc_cs_store[2]; 72453e503bSfredette }; 73453e503bSfredette 74453e503bSfredette /* MI function to attach a zs. */ 7510b1a7beSchs void zs_attach(struct zsc_softc *, struct zsdevice *, int); 76453e503bSfredette 77453e503bSfredette /* MD function to get any console flags for a zs. */ 7810b1a7beSchs int zs_console_flags(int, int, int); 79453e503bSfredette 80453e503bSfredette /* MD function that says what is attached to a zs. */ 81453e503bSfredette #define ZS_PERIPHERAL_UNKNOWN 0 82453e503bSfredette #define ZS_PERIPHERAL_SUNKBD 1 83453e503bSfredette #define ZS_PERIPHERAL_SUNMS 2 84453e503bSfredette 85453e503bSfredette /* 86453e503bSfredette * Functions to read and write individual registers in a channel. 87453e503bSfredette * The ZS chip requires a 1.6 uSec. recovery time between accesses. 88453e503bSfredette * On the SparcStation the recovery time is handled in hardware. 89453e503bSfredette * On the older Sun[234] machines it isn't, and software must do it. 90453e503bSfredette * 91453e503bSfredette * However, it *is* a problem on some Sun4m's (i.e. the SS20) (XXX: why?). 92453e503bSfredette * Thus we leave in the delay (done in the functions below). 93453e503bSfredette * XXX: (ABB) Think about this more. 94453e503bSfredette * 95453e503bSfredette * The functions below could be macros instead if we are concerned 96453e503bSfredette * about the function call overhead where ZS_DELAY does nothing. 97453e503bSfredette */ 98453e503bSfredette 9902cb47caStsutsui uint8_t zs_read_reg(struct zs_chanstate *, uint8_t); 10002cb47caStsutsui uint8_t zs_read_csr(struct zs_chanstate *); 10102cb47caStsutsui uint8_t zs_read_data(struct zs_chanstate *); 102453e503bSfredette 10302cb47caStsutsui void zs_write_reg(struct zs_chanstate *, uint8_t, uint8_t); 10402cb47caStsutsui void zs_write_csr(struct zs_chanstate *, uint8_t); 10502cb47caStsutsui void zs_write_data(struct zs_chanstate *, uint8_t); 106453e503bSfredette 1070ed62df7Stsutsui /* Everyone has splzs() in <machine/intr.h> */ 108453e503bSfredette 109453e503bSfredette /* We want to call it "zs" instead of "zsc" (sigh). */ 110453e503bSfredette #ifndef ZSCCF_CHANNEL 111453e503bSfredette #define ZSCCF_CHANNEL 0 112453e503bSfredette #define ZSCCF_CHANNEL_DEFAULT -1 113453e503bSfredette #endif 114