com_obio.c revision 1.1
11.1Sthorpej/* $NetBSD: com_obio.c,v 1.1 2002/03/27 21:51:29 thorpej Exp $ */ 21.1Sthorpej 31.1Sthorpej/*- 41.1Sthorpej * Copyright (c) 2001 The NetBSD Foundation, Inc. 51.1Sthorpej * All rights reserved. 61.1Sthorpej * 71.1Sthorpej * This code is derived from software contributed to The NetBSD Foundation 81.1Sthorpej * by Matt Thomas <matt@3am-software.com>. 91.1Sthorpej * 101.1Sthorpej * Redistribution and use in source and binary forms, with or without 111.1Sthorpej * modification, are permitted provided that the following conditions 121.1Sthorpej * are met: 131.1Sthorpej * 1. Redistributions of source code must retain the above copyright 141.1Sthorpej * notice, this list of conditions and the following disclaimer. 151.1Sthorpej * 2. Redistributions in binary form must reproduce the above copyright 161.1Sthorpej * notice, this list of conditions and the following disclaimer in the 171.1Sthorpej * documentation and/or other materials provided with the distribution. 181.1Sthorpej * 3. All advertising materials mentioning features or use of this software 191.1Sthorpej * must display the following acknowledgement: 201.1Sthorpej * This product includes software developed by the NetBSD 211.1Sthorpej * Foundation, Inc. and its contributors. 221.1Sthorpej * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sthorpej * contributors may be used to endorse or promote products derived 241.1Sthorpej * from this software without specific prior written permission. 251.1Sthorpej * 261.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sthorpej * POSSIBILITY OF SUCH DAMAGE. 371.1Sthorpej */ 381.1Sthorpej 391.1Sthorpej#include <sys/param.h> 401.1Sthorpej#include <sys/systm.h> 411.1Sthorpej#include <sys/device.h> 421.1Sthorpej#include <sys/termios.h> 431.1Sthorpej 441.1Sthorpej#include <machine/bus.h> 451.1Sthorpej 461.1Sthorpej#include <arm/xscale/i80321var.h> 471.1Sthorpej 481.1Sthorpej#include <evbarm/iq80321/obiovar.h> 491.1Sthorpej 501.1Sthorpej#include <dev/ic/comreg.h> 511.1Sthorpej#include <dev/ic/comvar.h> 521.1Sthorpej 531.1Sthorpejstruct com_obio_softc { 541.1Sthorpej struct com_softc sc_com; 551.1Sthorpej 561.1Sthorpej void *sc_ih; 571.1Sthorpej}; 581.1Sthorpej 591.1Sthorpejint com_obio_match(struct device *, struct cfdata *, void *); 601.1Sthorpejvoid com_obio_attach(struct device *, struct device *, void *); 611.1Sthorpej 621.1Sthorpejstruct cfattach com_obio_ca = { 631.1Sthorpej sizeof(struct com_obio_softc), com_obio_match, com_obio_attach 641.1Sthorpej}; 651.1Sthorpej 661.1Sthorpejint 671.1Sthorpejcom_obio_match(struct device *parent, struct cfdata *cf, void *aux) 681.1Sthorpej{ 691.1Sthorpej struct obio_attach_args *oba = aux; 701.1Sthorpej 711.1Sthorpej if (strcmp(cf->cf_driver->cd_name, oba->oba_name) == 0) 721.1Sthorpej return (1); 731.1Sthorpej 741.1Sthorpej return (0); 751.1Sthorpej} 761.1Sthorpej 771.1Sthorpejvoid 781.1Sthorpejcom_obio_attach(struct device *parent, struct device *self, void *aux) 791.1Sthorpej{ 801.1Sthorpej struct obio_attach_args *oba = aux; 811.1Sthorpej struct com_obio_softc *osc = (void *) self; 821.1Sthorpej struct com_softc *sc = &osc->sc_com; 831.1Sthorpej int error; 841.1Sthorpej 851.1Sthorpej sc->sc_iot = oba->oba_st; 861.1Sthorpej sc->sc_iobase = oba->oba_addr; 871.1Sthorpej sc->sc_frequency = COM_FREQ; 881.1Sthorpej error = bus_space_map(sc->sc_iot, oba->oba_addr, 8, 0, &sc->sc_ioh); 891.1Sthorpej 901.1Sthorpej if (error) { 911.1Sthorpej printf(": failed to map registers: %d\n", error); 921.1Sthorpej return; 931.1Sthorpej } 941.1Sthorpej 951.1Sthorpej com_attach_subr(sc); 961.1Sthorpej 971.1Sthorpej osc->sc_ih = i80321_intr_establish(oba->oba_irq, IPL_SERIAL, 981.1Sthorpej comintr, sc); 991.1Sthorpej if (osc->sc_ih == NULL) 1001.1Sthorpej printf("%s: unable to establish interrupt at irq %d\n", 1011.1Sthorpej sc->sc_dev.dv_xname, oba->oba_irq); 1021.1Sthorpej} 103