11.8Sthorpej/* $NetBSD: com_obio.c,v 1.8 2018/12/08 17:46:10 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 * 191.1Sthorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Sthorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Sthorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Sthorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Sthorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Sthorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Sthorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Sthorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Sthorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Sthorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Sthorpej * POSSIBILITY OF SUCH DAMAGE. 301.1Sthorpej */ 311.2Slukem 321.2Slukem#include <sys/cdefs.h> 331.8Sthorpej__KERNEL_RCSID(0, "$NetBSD: com_obio.c,v 1.8 2018/12/08 17:46:10 thorpej Exp $"); 341.1Sthorpej 351.1Sthorpej#include <sys/param.h> 361.1Sthorpej#include <sys/systm.h> 371.1Sthorpej#include <sys/device.h> 381.1Sthorpej#include <sys/termios.h> 391.1Sthorpej 401.7Sdyoung#include <sys/bus.h> 411.1Sthorpej 421.1Sthorpej#include <arm/xscale/beccreg.h> 431.1Sthorpej#include <arm/xscale/beccvar.h> 441.1Sthorpej 451.1Sthorpej#include <evbarm/adi_brh/brhreg.h> 461.1Sthorpej#include <evbarm/adi_brh/obiovar.h> 471.1Sthorpej 481.1Sthorpej#include <dev/ic/comreg.h> 491.1Sthorpej#include <dev/ic/comvar.h> 501.1Sthorpej 511.1Sthorpejstruct com_obio_softc { 521.1Sthorpej struct com_softc sc_com; 531.1Sthorpej 541.1Sthorpej void *sc_ih; 551.1Sthorpej}; 561.1Sthorpej 571.5Scubeint com_obio_match(device_t, cfdata_t , void *); 581.5Scubevoid com_obio_attach(device_t, device_t, void *); 591.1Sthorpej 601.5ScubeCFATTACH_DECL_NEW(com_obio, sizeof(struct com_obio_softc), 611.1Sthorpej com_obio_match, com_obio_attach, NULL, NULL); 621.1Sthorpej 631.1Sthorpejint 641.5Scubecom_obio_match(device_t parent, cfdata_t cf, void *aux) 651.1Sthorpej{ 661.1Sthorpej 671.1Sthorpej /* We take it on faith that the device is there. */ 681.1Sthorpej return (1); 691.1Sthorpej} 701.1Sthorpej 711.1Sthorpejvoid 721.5Scubecom_obio_attach(device_t parent, device_t self, void *aux) 731.1Sthorpej{ 741.1Sthorpej struct obio_attach_args *oba = aux; 751.5Scube struct com_obio_softc *osc = device_private(self); 761.1Sthorpej struct com_softc *sc = &osc->sc_com; 771.4Sgdamore bus_space_handle_t ioh; 781.1Sthorpej int error; 791.1Sthorpej 801.5Scube sc->sc_dev = self; 811.1Sthorpej sc->sc_frequency = BECC_PERIPH_CLOCK; 821.1Sthorpej sc->sc_hwflags = COM_HW_NO_TXPRELOAD; 831.4Sgdamore error = bus_space_map(oba->oba_st, oba->oba_addr, 8, 0, &ioh); 841.1Sthorpej 851.1Sthorpej if (error) { 861.5Scube aprint_error(": failed to map registers: %d\n", error); 871.1Sthorpej return; 881.1Sthorpej } 891.8Sthorpej com_init_regs(&sc->sc_regs, oba->oba_st, ioh, oba->oba_addr); 901.1Sthorpej 911.1Sthorpej com_attach_subr(sc); 921.1Sthorpej 931.1Sthorpej osc->sc_ih = becc_intr_establish(oba->oba_irq, IPL_SERIAL, 941.1Sthorpej comintr, sc); 951.1Sthorpej if (osc->sc_ih == NULL) 961.5Scube aprint_error_dev(self, 971.5Scube "unable to establish interrupt at irq %d\n", oba->oba_irq); 981.1Sthorpej} 99