1258945Sroberto/* $NetBSD: z8530var.h,v 1.12 2008/03/29 19:15:35 tsutsui Exp $ */ 2258945Sroberto 3258945Sroberto/* 4258945Sroberto * Copyright (c) 1992, 1993 5258945Sroberto * The Regents of the University of California. All rights reserved. 6258945Sroberto * 7258945Sroberto * This software was developed by the Computer Systems Engineering group 8258945Sroberto * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66 and 9258945Sroberto * contributed to Berkeley. 10258945Sroberto * 11258945Sroberto * All advertising materials mentioning features or use of this software 12258945Sroberto * must display the following acknowledgement: 13258945Sroberto * This product includes software developed by the University of 14258945Sroberto * California, Lawrence Berkeley Laboratory. 15258945Sroberto * 16258945Sroberto * Redistribution and use in source and binary forms, with or without 17258945Sroberto * modification, are permitted provided that the following conditions 18258945Sroberto * are met: 19258945Sroberto * 1. Redistributions of source code must retain the above copyright 20258945Sroberto * notice, this list of conditions and the following disclaimer. 21258945Sroberto * 2. Redistributions in binary form must reproduce the above copyright 22258945Sroberto * notice, this list of conditions and the following disclaimer in the 23258945Sroberto * documentation and/or other materials provided with the distribution. 24258945Sroberto * 3. Neither the name of the University nor the names of its contributors 25258945Sroberto * may be used to endorse or promote products derived from this software 26330567Sgordon * without specific prior written permission. 27258945Sroberto * 28258945Sroberto * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 29258945Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 30258945Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 31258945Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 32258945Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 33258945Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 34258945Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 35258945Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 36280849Scy * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 37280849Scy * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 38280849Scy * SUCH DAMAGE. 39280849Scy * 40258945Sroberto * @(#)zsvar.h 8.1 (Berkeley) 6/11/93 41280849Scy */ 42258945Sroberto 43258945Sroberto#include <sys/bus.h> 44258945Sroberto#include <dev/ic/z8530sc.h> 45258945Sroberto 46258945Sroberto#include "kbd.h" /* NKBD */ 47258945Sroberto 48258945Sroberto#if (NKBD > 0) 49258945Sroberto/* 50258945Sroberto * Need to override cn_console_dev() for zstty and zskbd. 51258945Sroberto */ 52258945Sroberto#ifdef cn_isconsole 53258945Sroberto#undef cn_isconsole 54258945Sroberto#endif 55258945Srobertoextern struct consdev *cn_hw; 56258945Srobertoextern struct consdev *cn_tab; 57258945Sroberto#define cn_isconsole(d) ((d) == cn_tab->cn_dev || (d) == cn_hw->cn_dev) 58258945Sroberto#endif 59258945Sroberto 60258945Srobertostruct zsc_softc { 61258945Sroberto device_t zsc_dev; /* base device */ 62258945Sroberto bus_space_tag_t zsc_bustag; /* bus space/DMA tags */ 63258945Sroberto bus_dma_tag_t zsc_dmatag; 64258945Sroberto struct zs_chanstate *zsc_cs[2]; /* channel A and B soft state */ 65258945Sroberto 66258945Sroberto /* Machine-dependent part follows... */ 67258945Sroberto void *zsc_softintr; 68258945Sroberto int zsc_promunit; /* PROM's view of zs devices */ 69258945Sroberto int zsc_node; /* PROM node, if any */ 70258945Sroberto struct evcnt zsc_intrcnt; /* count interrupts */ 71258945Sroberto struct zs_chanstate zsc_cs_store[2]; 72258945Sroberto}; 73258945Sroberto 74258945Sroberto/* 75258945Sroberto * Functions to read and write individual registers in a channel. 76258945Sroberto * The ZS chip requires a 1.6 uSec. recovery time between accesses. 77258945Sroberto * On the SparcStation the recovery time is handled in hardware. 78258945Sroberto * On the older Sun4 machine it isn't, and software must do it. 79258945Sroberto * 80258945Sroberto * However, it *is* a problem on some Sun4m's (i.e. the SS20) (XXX: why?). 81258945Sroberto * Thus we leave in the delay (done in the functions below). 82258945Sroberto * XXX: (ABB) Think about this more. 83258945Sroberto * 84258945Sroberto * The functions below could be macros instead if we are concerned 85258945Sroberto * about the function call overhead where ZS_DELAY does nothing. 86258945Sroberto */ 87258945Sroberto 88258945Srobertouint8_t zs_read_reg(struct zs_chanstate *cs, uint8_t reg); 89258945Srobertouint8_t zs_read_csr(struct zs_chanstate *cs); 90258945Srobertouint8_t zs_read_data(struct zs_chanstate *cs); 91258945Sroberto 92258945Srobertovoid zs_write_reg(struct zs_chanstate *cs, uint8_t reg, uint8_t val); 93258945Srobertovoid zs_write_csr(struct zs_chanstate *cs, uint8_t val); 94258945Srobertovoid zs_write_data(struct zs_chanstate *cs, uint8_t val); 95258945Sroberto 96258945Sroberto/* The sparc has splzs() in psl.h */ 97258945Sroberto 98258945Sroberto/* We want to call it "zs" instead of "zsc" (sigh). */ 99258945Sroberto#ifndef ZSCCF_CHANNEL 100258945Sroberto#define ZSCCF_CHANNEL 0 101258945Sroberto#define ZSCCF_CHANNEL_DEFAULT -1 102258945Sroberto#endif 103258945Sroberto 104258945Sroberto#undef cn_trap 105258945Sroberto#define cn_trap() zs_abort(NULL) 106280849Scy 107258945Sroberto#define IPL_ZS IPL_SERIAL 108258945Sroberto