armadillo9_com.c revision 1.2
11.2Shamajima/* $NetBSD: armadillo9_com.c,v 1.2 2006/02/13 12:24:21 hamajima Exp $ */ 21.1Shamajima/* 31.1Shamajima * Copyright (c) 2002 41.1Shamajima * Ichiro FUKUHARA <ichiro@ichiro.org>. 51.1Shamajima * All rights reserved. 61.1Shamajima * 71.1Shamajima * Redistribution and use in source and binary forms, with or without 81.1Shamajima * modification, are permitted provided that the following conditions 91.1Shamajima * are met: 101.1Shamajima * 1. Redistributions of source code must retain the above copyright 111.1Shamajima * notice, this list of conditions and the following disclaimer. 121.1Shamajima * 2. Redistributions in binary form must reproduce the above copyright 131.1Shamajima * notice, this list of conditions and the following disclaimer in the 141.1Shamajima * documentation and/or other materials provided with the distribution. 151.1Shamajima * 3. All advertising materials mentioning features or use of this software 161.1Shamajima * must display the following acknowledgement: 171.1Shamajima * This product includes software developed by Ichiro FUKUHARA. 181.1Shamajima * 4. The name of the company nor the name of the author may be used to 191.1Shamajima * endorse or promote products derived from this software without specific 201.1Shamajima * prior written permission. 211.1Shamajima * 221.1Shamajima * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR 231.1Shamajima * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 241.1Shamajima * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. 251.1Shamajima * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR 261.1Shamajima * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 271.1Shamajima * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 281.1Shamajima * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 291.1Shamajima * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 301.1Shamajima * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 311.1Shamajima * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 321.1Shamajima * SUCH DAMAGE. 331.1Shamajima */ 341.1Shamajima 351.1Shamajima#include <sys/cdefs.h> 361.2Shamajima__KERNEL_RCSID(0, "$NetBSD: armadillo9_com.c,v 1.2 2006/02/13 12:24:21 hamajima Exp $"); 371.1Shamajima 381.1Shamajima/* Front-end of epcom */ 391.1Shamajima 401.1Shamajima#include <sys/types.h> 411.1Shamajima#include <sys/device.h> 421.1Shamajima#include <sys/systm.h> 431.1Shamajima#include <sys/param.h> 441.1Shamajima#include <sys/malloc.h> 451.1Shamajima 461.1Shamajima#include <sys/termios.h> 471.1Shamajima 481.1Shamajima#include <machine/intr.h> 491.1Shamajima#include <machine/bus.h> 501.1Shamajima 511.1Shamajima#include <arm/ep93xx/epcomreg.h> 521.1Shamajima#include <arm/ep93xx/epcomvar.h> 531.1Shamajima#include <arm/ep93xx/ep93xxreg.h> 541.1Shamajima#include <arm/ep93xx/ep93xxvar.h> 551.1Shamajima#include <arm/ep93xx/epsocvar.h> 561.1Shamajima#include "epled.h" 571.1Shamajima#if NEPLED > 0 581.1Shamajima#include <arm/ep93xx/epledvar.h> 591.1Shamajima#endif 601.2Shamajima#include <evbarm/armadillo/armadillo9var.h> 611.1Shamajima 621.1Shamajimastatic int armadillo9com_match(struct device *, struct cfdata *, void *); 631.1Shamajimastatic void armadillo9com_attach(struct device *, struct device *, void *); 641.1Shamajimastatic int armadillo9com_intr(void *); 651.1Shamajima 661.1ShamajimaCFATTACH_DECL(armadillo9com, sizeof(struct epcom_softc), 671.1Shamajima armadillo9com_match, armadillo9com_attach, NULL, NULL); 681.1Shamajima 691.1Shamajimastatic int 701.1Shamajimaarmadillo9com_match(struct device *parent, struct cfdata *match, void *aux) 711.1Shamajima{ 721.1Shamajima if (strcmp(match->cf_name, "epcom") == 0) 731.1Shamajima return 1; 741.1Shamajima return 0; 751.1Shamajima} 761.1Shamajima 771.1Shamajimastatic void 781.1Shamajimaarmadillo9com_attach(struct device *parent, struct device *self, void *aux) 791.1Shamajima{ 801.1Shamajima struct epcom_softc *sc = (struct epcom_softc *)self; 811.1Shamajima struct epsoc_attach_args *sa = aux; 821.1Shamajima u_int32_t pwrcnt; 831.1Shamajima bus_space_handle_t ioh; 841.1Shamajima 851.1Shamajima sc->sc_iot = sa->sa_iot; 861.1Shamajima sc->sc_hwbase = sa->sa_addr; 871.1Shamajima 881.1Shamajima printf("\n"); 891.1Shamajima 901.1Shamajima bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0, &sc->sc_ioh); 911.1Shamajima 921.1Shamajima bus_space_map(sa->sa_iot, EP93XX_APB_HWBASE + EP93XX_APB_SYSCON, 931.1Shamajima EP93XX_APB_SYSCON_SIZE, 0, &ioh); 941.1Shamajima pwrcnt = bus_space_read_4(sa->sa_iot, ioh, EP93XX_SYSCON_PwrCnt); 951.1Shamajima pwrcnt &= ~(PwrCnt_UARTBAUD); 961.1Shamajima bus_space_write_4(sa->sa_iot, ioh, EP93XX_SYSCON_PwrCnt, pwrcnt); 971.1Shamajima bus_space_unmap(sa->sa_iot, ioh, EP93XX_APB_SYSCON_SIZE); 981.1Shamajima 991.1Shamajima epcom_attach_subr(sc); 1001.1Shamajima ep93xx_intr_establish(sa->sa_intr, IPL_SERIAL, armadillo9com_intr, sc); 1011.1Shamajima#if NEPLED > 0 1021.2Shamajima if (armadillo_model->devcfg == DEVCFG_ARMADILLO210) 1031.2Shamajima epled_red_off(); 1041.1Shamajima#endif 1051.1Shamajima} 1061.1Shamajima 1071.1Shamajimastatic int 1081.1Shamajimaarmadillo9com_intr(void *arg) 1091.1Shamajima{ 1101.1Shamajima int n; 1111.1Shamajima 1121.1Shamajima#if NEPLED > 0 1131.2Shamajima if (armadillo_model->devcfg == DEVCFG_ARMADILLO210) 1141.2Shamajima epled_red_on(); 1151.1Shamajima#endif 1161.1Shamajima n = epcomintr(arg); 1171.1Shamajima#if NEPLED > 0 1181.2Shamajima if (armadillo_model->devcfg == DEVCFG_ARMADILLO210) 1191.2Shamajima epled_red_off(); 1201.1Shamajima#endif 1211.1Shamajima return n; 1221.1Shamajima} 123