com_obio.c revision 1.1
11.1Smacallan/* $NetBSD: com_obio.c,v 1.1 2019/02/14 21:47:52 macallan Exp $ */ 21.1Smacallan 31.1Smacallan/*- 41.1Smacallan * Copyright (c) 2001 The NetBSD Foundation, Inc. 51.1Smacallan * All rights reserved. 61.1Smacallan * 71.1Smacallan * This code is derived from software contributed to The NetBSD Foundation 81.1Smacallan * by Matt Thomas <matt@3am-software.com>. 91.1Smacallan * 101.1Smacallan * Redistribution and use in source and binary forms, with or without 111.1Smacallan * modification, are permitted provided that the following conditions 121.1Smacallan * are met: 131.1Smacallan * 1. Redistributions of source code must retain the above copyright 141.1Smacallan * notice, this list of conditions and the following disclaimer. 151.1Smacallan * 2. Redistributions in binary form must reproduce the above copyright 161.1Smacallan * notice, this list of conditions and the following disclaimer in the 171.1Smacallan * documentation and/or other materials provided with the distribution. 181.1Smacallan * 191.1Smacallan * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 201.1Smacallan * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 211.1Smacallan * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221.1Smacallan * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 231.1Smacallan * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 241.1Smacallan * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 251.1Smacallan * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 261.1Smacallan * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 271.1Smacallan * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 281.1Smacallan * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 291.1Smacallan * POSSIBILITY OF SUCH DAMAGE. 301.1Smacallan */ 311.1Smacallan 321.1Smacallan#include <sys/cdefs.h> 331.1Smacallan__KERNEL_RCSID(0, "$NetBSD: com_obio.c,v 1.1 2019/02/14 21:47:52 macallan Exp $"); 341.1Smacallan 351.1Smacallan#include <sys/param.h> 361.1Smacallan#include <sys/systm.h> 371.1Smacallan#include <sys/device.h> 381.1Smacallan#include <sys/termios.h> 391.1Smacallan 401.1Smacallan#include <sys/bus.h> 411.1Smacallan 421.1Smacallan#include <arm/xscale/i80321var.h> 431.1Smacallan 441.1Smacallan#include <evbarm/iyonix/obiovar.h> 451.1Smacallan 461.1Smacallan#include <dev/ic/comreg.h> 471.1Smacallan#include <dev/ic/comvar.h> 481.1Smacallan 491.1Smacallanstruct com_obio_softc { 501.1Smacallan struct com_softc sc_com; 511.1Smacallan 521.1Smacallan void *sc_ih; 531.1Smacallan}; 541.1Smacallan 551.1Smacallanint com_obio_match(device_t, cfdata_t , void *); 561.1Smacallanvoid com_obio_attach(device_t, device_t, void *); 571.1Smacallan 581.1SmacallanCFATTACH_DECL_NEW(com_obio, sizeof(struct com_obio_softc), 591.1Smacallan com_obio_match, com_obio_attach, NULL, NULL); 601.1Smacallan 611.1Smacallanint 621.1Smacallancom_obio_match(device_t parent, cfdata_t cf, void *aux) 631.1Smacallan{ 641.1Smacallan /* We take it on faith that the device is there. */ 651.1Smacallan return (1); 661.1Smacallan} 671.1Smacallan 681.1Smacallanvoid 691.1Smacallancom_obio_attach(device_t parent, device_t self, void *aux) 701.1Smacallan{ 711.1Smacallan struct obio_attach_args *oba = aux; 721.1Smacallan struct com_obio_softc *osc = device_private(self); 731.1Smacallan struct com_softc *sc = &osc->sc_com; 741.1Smacallan bus_space_handle_t ioh; 751.1Smacallan int error; 761.1Smacallan 771.1Smacallan sc->sc_dev = self; 781.1Smacallan sc->sc_frequency = COM_FREQ; 791.1Smacallan sc->sc_hwflags = COM_HW_NO_TXPRELOAD; 801.1Smacallan error = bus_space_map(oba->oba_st, oba->oba_addr, 8, 0, &ioh); 811.1Smacallan com_init_regs(&sc->sc_regs, oba->oba_st, ioh, oba->oba_addr); 821.1Smacallan 831.1Smacallan if (error) { 841.1Smacallan aprint_error(": failed to map registers: %d\n", error); 851.1Smacallan return; 861.1Smacallan } 871.1Smacallan 881.1Smacallan com_attach_subr(sc); 891.1Smacallan 901.1Smacallan osc->sc_ih = i80321_intr_establish(oba->oba_irq, IPL_SERIAL, 911.1Smacallan comintr, sc); 921.1Smacallan if (osc->sc_ih == NULL) 931.1Smacallan aprint_error_dev(self, 941.1Smacallan "unable to establish interrupt at irq %d\n", oba->oba_irq); 951.1Smacallan} 96