armadillo9_com.c revision 1.1
11.1Shamajima/* $NetBSD: armadillo9_com.c,v 1.1 2006/02/06 14:03:22 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.1Shamajima__KERNEL_RCSID(0, "$NetBSD: armadillo9_com.c,v 1.1 2006/02/06 14:03:22 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#ifdef ARMADILLO210 571.1Shamajima#include "epled.h" 581.1Shamajima#if NEPLED > 0 591.1Shamajima#include <arm/ep93xx/epledvar.h> 601.1Shamajima#endif 611.1Shamajima#endif 621.1Shamajima 631.1Shamajimastatic int armadillo9com_match(struct device *, struct cfdata *, void *); 641.1Shamajimastatic void armadillo9com_attach(struct device *, struct device *, void *); 651.1Shamajima#ifdef ARMADILLO210 661.1Shamajimastatic int armadillo9com_intr(void *); 671.1Shamajima#endif 681.1Shamajima 691.1ShamajimaCFATTACH_DECL(armadillo9com, sizeof(struct epcom_softc), 701.1Shamajima armadillo9com_match, armadillo9com_attach, NULL, NULL); 711.1Shamajima 721.1Shamajimastatic int 731.1Shamajimaarmadillo9com_match(struct device *parent, struct cfdata *match, void *aux) 741.1Shamajima{ 751.1Shamajima if (strcmp(match->cf_name, "epcom") == 0) 761.1Shamajima return 1; 771.1Shamajima return 0; 781.1Shamajima} 791.1Shamajima 801.1Shamajimastatic void 811.1Shamajimaarmadillo9com_attach(struct device *parent, struct device *self, void *aux) 821.1Shamajima{ 831.1Shamajima struct epcom_softc *sc = (struct epcom_softc *)self; 841.1Shamajima struct epsoc_attach_args *sa = aux; 851.1Shamajima u_int32_t pwrcnt; 861.1Shamajima bus_space_handle_t ioh; 871.1Shamajima 881.1Shamajima sc->sc_iot = sa->sa_iot; 891.1Shamajima sc->sc_hwbase = sa->sa_addr; 901.1Shamajima 911.1Shamajima printf("\n"); 921.1Shamajima 931.1Shamajima bus_space_map(sa->sa_iot, sa->sa_addr, sa->sa_size, 0, &sc->sc_ioh); 941.1Shamajima 951.1Shamajima bus_space_map(sa->sa_iot, EP93XX_APB_HWBASE + EP93XX_APB_SYSCON, 961.1Shamajima EP93XX_APB_SYSCON_SIZE, 0, &ioh); 971.1Shamajima pwrcnt = bus_space_read_4(sa->sa_iot, ioh, EP93XX_SYSCON_PwrCnt); 981.1Shamajima pwrcnt &= ~(PwrCnt_UARTBAUD); 991.1Shamajima bus_space_write_4(sa->sa_iot, ioh, EP93XX_SYSCON_PwrCnt, pwrcnt); 1001.1Shamajima bus_space_unmap(sa->sa_iot, ioh, EP93XX_APB_SYSCON_SIZE); 1011.1Shamajima 1021.1Shamajima epcom_attach_subr(sc); 1031.1Shamajima#ifdef ARMADILLO210 1041.1Shamajima ep93xx_intr_establish(sa->sa_intr, IPL_SERIAL, armadillo9com_intr, sc); 1051.1Shamajima#if NEPLED > 0 1061.1Shamajima epled_red_off(); 1071.1Shamajima#endif 1081.1Shamajima#else 1091.1Shamajima ep93xx_intr_establish(sa->sa_intr, IPL_SERIAL, epcomintr, sc); 1101.1Shamajima#endif 1111.1Shamajima} 1121.1Shamajima 1131.1Shamajima#ifdef ARMADILLO210 1141.1Shamajimastatic int 1151.1Shamajimaarmadillo9com_intr(void *arg) 1161.1Shamajima{ 1171.1Shamajima int n; 1181.1Shamajima 1191.1Shamajima#if NEPLED > 0 1201.1Shamajima epled_red_on(); 1211.1Shamajima#endif 1221.1Shamajima n = epcomintr(arg); 1231.1Shamajima#if NEPLED > 0 1241.1Shamajima epled_red_off(); 1251.1Shamajima#endif 1261.1Shamajima return n; 1271.1Shamajima} 1281.1Shamajima#endif 129