com_obio.c revision 1.1
11.1Smatt/*- 21.1Smatt * Copyright (c) 2001 The NetBSD Foundation, Inc. 31.1Smatt * All rights reserved. 41.1Smatt * 51.1Smatt * This code is derived from software contributed to The NetBSD Foundation 61.1Smatt * by Matt Thomas <matt@3am-software.com>. 71.1Smatt * 81.1Smatt * Redistribution and use in source and binary forms, with or without 91.1Smatt * modification, are permitted provided that the following conditions 101.1Smatt * are met: 111.1Smatt * 1. Redistributions of source code must retain the above copyright 121.1Smatt * notice, this list of conditions and the following disclaimer. 131.1Smatt * 2. Redistributions in binary form must reproduce the above copyright 141.1Smatt * notice, this list of conditions and the following disclaimer in the 151.1Smatt * documentation and/or other materials provided with the distribution. 161.1Smatt * 3. All advertising materials mentioning features or use of this software 171.1Smatt * must display the following acknowledgement: 181.1Smatt * This product includes software developed by the NetBSD 191.1Smatt * Foundation, Inc. and its contributors. 201.1Smatt * 4. Neither the name of The NetBSD Foundation nor the names of its 211.1Smatt * contributors may be used to endorse or promote products derived 221.1Smatt * from this software without specific prior written permission. 231.1Smatt * 241.1Smatt * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 251.1Smatt * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 261.1Smatt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 271.1Smatt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 281.1Smatt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 291.1Smatt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 301.1Smatt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 311.1Smatt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 321.1Smatt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 331.1Smatt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 341.1Smatt * POSSIBILITY OF SUCH DAMAGE. 351.1Smatt */ 361.1Smatt 371.1Smatt#include <sys/param.h> 381.1Smatt#include <sys/systm.h> 391.1Smatt#include <sys/device.h> 401.1Smatt#include <sys/termios.h> 411.1Smatt 421.1Smatt#include <machine/autoconf.h> 431.1Smatt 441.1Smatt#include <dev/ic/comreg.h> 451.1Smatt#include <dev/ic/comvar.h> 461.1Smatt 471.1Smattstatic int com_obio_match (struct device *, struct cfdata *, void *); 481.1Smattstatic void com_obio_attach (struct device *, struct device *, void *); 491.1Smatt 501.1Smattstruct cfattach com_obio_ca = { 511.1Smatt sizeof(struct com_softc), com_obio_match, com_obio_attach 521.1Smatt}; 531.1Smatt 541.1Smattextern struct cfdriver com_cd; 551.1Smatt 561.1Smattstatic int 571.1Smattcom_obio_match(struct device *parent, struct cfdata *cf, void *aux) 581.1Smatt{ 591.1Smatt struct obio_attach_args *oa = aux; 601.1Smatt return strcmp(com_cd.cd_name, oa->oa_name) == 0 && 611.1Smatt cf->obiocf_instance == oa->oa_instance; 621.1Smatt} 631.1Smatt 641.1Smattstatic void 651.1Smattcom_obio_attach(struct device *parent, struct device *self, void *aux) 661.1Smatt{ 671.1Smatt struct obio_attach_args *oa = aux; 681.1Smatt struct com_softc *sc = (struct com_softc *) self; 691.1Smatt int error; 701.1Smatt 711.1Smatt KASSERT(oa->oa_nregions > 0); 721.1Smatt 731.1Smatt sc->sc_iot = oa->oa_memt; 741.1Smatt sc->sc_iobase = oa->oa_addrs[0]; 751.1Smatt sc->sc_frequency = COM_FREQ; 761.1Smatt error = bus_space_map(sc->sc_iot, oa->oa_addrs[0], 771.1Smatt oa->oa_lens[0], 0, &sc->sc_ioh); 781.1Smatt 791.1Smatt if (error) { 801.1Smatt printf(": failed to map registers: %d\n", error); 811.1Smatt return; 821.1Smatt } 831.1Smatt 841.1Smatt com_attach_subr(sc); 851.1Smatt obio_intr_establish(oa, comintr, sc); 861.1Smatt} 87