11.17Sisaki/* $NetBSD: mpu_cmpci.c,v 1.17 2019/05/08 13:40:19 isaki Exp $ */ 21.1Sitohy 31.1Sitohy/* 41.16Sjmcneill * Copyright (c) 1998, 2008 The NetBSD Foundation, Inc. 51.1Sitohy * All rights reserved. 61.1Sitohy * 71.1Sitohy * This code is derived from software contributed to The NetBSD Foundation 81.6Skeihan * by Lennart Augustsson (augustss@NetBSD.org). 91.1Sitohy * 101.1Sitohy * Redistribution and use in source and binary forms, with or without 111.1Sitohy * modification, are permitted provided that the following conditions 121.1Sitohy * are met: 131.1Sitohy * 1. Redistributions of source code must retain the above copyright 141.1Sitohy * notice, this list of conditions and the following disclaimer. 151.1Sitohy * 2. Redistributions in binary form must reproduce the above copyright 161.1Sitohy * notice, this list of conditions and the following disclaimer in the 171.1Sitohy * documentation and/or other materials provided with the distribution. 181.1Sitohy * 191.1Sitohy * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sitohy * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sitohy * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sitohy * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sitohy * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sitohy * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sitohy * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sitohy * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sitohy * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sitohy * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sitohy * POSSIBILITY OF SUCH DAMAGE. 301.1Sitohy */ 311.2Slukem 321.2Slukem#include <sys/cdefs.h> 331.17Sisaki__KERNEL_RCSID(0, "$NetBSD: mpu_cmpci.c,v 1.17 2019/05/08 13:40:19 isaki Exp $"); 341.1Sitohy 351.1Sitohy#include <sys/param.h> 361.1Sitohy#include <sys/systm.h> 371.1Sitohy#include <sys/kernel.h> 381.1Sitohy#include <sys/errno.h> 391.1Sitohy#include <sys/device.h> 401.1Sitohy#include <sys/proc.h> 411.1Sitohy#include <sys/conf.h> 421.1Sitohy#include <sys/audioio.h> 431.1Sitohy#include <sys/midiio.h> 441.1Sitohy 451.13Sad#include <sys/bus.h> 461.1Sitohy 471.17Sisaki#include <dev/audio/audio_if.h> 481.1Sitohy#include <dev/midi_if.h> 491.1Sitohy 501.1Sitohy#include <dev/pci/pcivar.h> 511.1Sitohy 521.1Sitohy#include <dev/ic/mpuvar.h> 531.1Sitohy#include <dev/pci/cmpcivar.h> 541.1Sitohy 551.1Sitohystatic int 561.14Sxtraemempu_cmpci_match(device_t parent, cfdata_t match, void *aux) 571.1Sitohy{ 581.14Sxtraeme struct audio_attach_args *aa = aux; 591.14Sxtraeme struct cmpci_softc *ysc = device_private(parent); 601.1Sitohy struct mpu_softc sc; 611.1Sitohy 621.1Sitohy if (aa->type != AUDIODEV_TYPE_MPU) 631.14Sxtraeme return 0; 641.1Sitohy memset(&sc, 0, sizeof sc); 651.1Sitohy sc.iot = ysc->sc_iot; 661.1Sitohy sc.ioh = ysc->sc_mpu_ioh; 671.14Sxtraeme return mpu_find(&sc); 681.1Sitohy} 691.1Sitohy 701.1Sitohystatic void 711.14Sxtraemempu_cmpci_attach(device_t parent, device_t self, void *aux) 721.1Sitohy{ 731.14Sxtraeme struct cmpci_softc *ysc = device_private(parent); 741.14Sxtraeme struct mpu_softc *sc = device_private(self); 751.1Sitohy 761.14Sxtraeme aprint_normal("\n"); 771.7Sxtraeme 781.1Sitohy sc->iot = ysc->sc_iot; 791.1Sitohy sc->ioh = ysc->sc_mpu_ioh; 801.1Sitohy sc->model = "CMPCI MPU-401 MIDI UART"; 811.14Sxtraeme sc->sc_dev = self; 821.16Sjmcneill sc->lock = &ysc->sc_intr_lock; 831.1Sitohy 841.1Sitohy mpu_attach(sc); 851.1Sitohy} 861.9Sthorpej 871.14SxtraemeCFATTACH_DECL_NEW(mpu_cmpci, sizeof (struct mpu_softc), 881.9Sthorpej mpu_cmpci_match, mpu_cmpci_attach, NULL, NULL); 89