1 /* $OpenBSD: necsb.c,v 1.5 2022/04/06 18:59:26 naddy Exp $ */ 2 /* $NecBSD: nec86_isa.c,v 1.9 1998/09/26 11:31:11 kmatsuda Exp $ */ 3 /* $NetBSD$ */ 4 5 /* 6 * [NetBSD for NEC PC-98 series] 7 * Copyright (c) 1995, 1996, 1997, 1998 8 * NetBSD/pc98 porting staff. All rights reserved. 9 * 10 * Redistribution and use in source and binary forms, with or without 11 * modification, are permitted provided that the following conditions 12 * are met: 13 * 1. Redistributions of source code must retain the above copyright 14 * notice, this list of conditions and the following disclaimer. 15 * 2. Redistributions in binary form must reproduce the above copyright 16 * notice, this list of conditions and the following disclaimer in the 17 * documentation and/or other materials provided with the distribution. 18 * 3. The name of the author may not be used to endorse or promote products 19 * derived from this software without specific prior written permission. 20 * 21 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR 22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 23 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 24 * DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, 25 * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 26 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 27 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 29 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN 30 * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 31 * POSSIBILITY OF SUCH DAMAGE. 32 */ 33 34 #include <sys/param.h> 35 #include <sys/systm.h> 36 #include <sys/device.h> 37 38 #include <machine/board.h> /* PC_BASE */ 39 #include <machine/bus.h> 40 41 #include <sys/audioio.h> 42 #include <dev/audio_if.h> 43 44 #include <luna88k/cbus/nec86reg.h> 45 #include <luna88k/cbus/nec86hwvar.h> 46 #include <luna88k/cbus/nec86var.h> 47 48 #include <luna88k/cbus/cbusvar.h> /* cbus_isrlink() */ 49 50 #define PCEXIO_BASE (PC_BASE + 0x1000000) 51 #define NECSB_BASE (PCEXIO_BASE + 0xa460) 52 53 int necsb_match(struct device *, void *, void *); 54 void necsb_attach(struct device *, struct device *, void *); 55 56 const struct cfattach necsb_ca = { 57 sizeof(struct nec86_softc), necsb_match, necsb_attach 58 }; 59 60 struct cfdriver necsb_cd = { 61 NULL, "necsb", DV_DULL 62 }; 63 64 /* bus space tag for necsb */ 65 struct luna88k_bus_space_tag necsb_bst = { 66 0, /* when reading/writing 1 byte, no shift is needed. */ 67 0, 68 0, 69 0, 70 0, /* no offset */ 71 }; 72 73 int 74 necsb_match(struct device *parent, void *cf, void *aux) 75 { 76 struct cbus_attach_args *caa = aux; 77 78 if (strcmp(caa->ca_name, necsb_cd.cd_name)) 79 return 0; 80 81 return 1; 82 } 83 84 void 85 necsb_attach(struct device *parent, struct device *self, void *aux) 86 { 87 struct nec86_softc *nsc = (struct nec86_softc *)self; 88 struct nec86hw_softc *ysc = &nsc->sc_nec86hw; 89 #if 0 90 struct cbus_attach_args *caa = aux; 91 #endif 92 93 bus_space_tag_t iot = &necsb_bst; 94 95 nsc->sc_n86iot = iot; 96 nsc->sc_n86ioh = 97 (bus_space_handle_t)(NECSB_BASE + NEC86_SOUND_ID); 98 99 ysc->sc_iot = iot; 100 ysc->sc_ioh = 101 (bus_space_handle_t)(NECSB_BASE + NEC86_COREOFFSET); 102 ysc->sc_cfgflags = 0; /* original 'PC-9801-86' */ 103 104 nsc->sc_ym_iot = iot; 105 nsc->sc_ym_iobase = (bus_space_handle_t)PCEXIO_BASE; 106 nsc->sc_ym_ioh = (bus_space_handle_t)0; /* default */ 107 108 nec86_attachsubr(nsc); 109 110 if (nsc->sc_intlevel == -1) 111 return; 112 113 if ((nsc->sc_intlevel < 0) || (nsc->sc_intlevel >= NCBUSISR)) 114 panic("necsb_attach: bad INT level"); 115 116 /* XXX: check return value ? */ 117 cbus_isrlink(nec86hw_intr, ysc, nsc->sc_intlevel, IPL_AUDIO, 118 self->dv_xname); 119 } 120