com_mainbus.c revision 1.5
11.5Slukem/* $NetBSD: com_mainbus.c,v 1.5 2003/07/15 02:43:44 lukem Exp $ */ 21.1Such 31.1Such/*- 41.1Such * Copyright (c) 2002 The NetBSD Foundation, Inc. 51.1Such * All rights reserved. 61.1Such * 71.1Such * Redistribution and use in source and binary forms, with or without 81.1Such * modification, are permitted provided that the following conditions 91.1Such * are met: 101.1Such * 1. Redistributions of source code must retain the above copyright 111.1Such * notice, this list of conditions and the following disclaimer. 121.1Such * 2. Redistributions in binary form must reproduce the above copyright 131.1Such * notice, this list of conditions and the following disclaimer in the 141.1Such * documentation and/or other materials provided with the distribution. 151.1Such * 3. All advertising materials mentioning features or use of this software 161.1Such * must display the following acknowledgement: 171.1Such * This product includes software developed by the NetBSD 181.1Such * Foundation, Inc. and its contributors. 191.1Such * 4. Neither the name of The NetBSD Foundation nor the names of its 201.1Such * contributors may be used to endorse or promote products derived 211.1Such * from this software without specific prior written permission. 221.1Such * 231.1Such * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 241.1Such * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 251.1Such * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 261.1Such * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 271.1Such * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 281.1Such * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 291.1Such * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 301.1Such * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 311.1Such * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 321.1Such * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 331.1Such * POSSIBILITY OF SUCH DAMAGE. 341.1Such */ 351.5Slukem 361.5Slukem#include <sys/cdefs.h> 371.5Slukem__KERNEL_RCSID(0, "$NetBSD: com_mainbus.c,v 1.5 2003/07/15 02:43:44 lukem Exp $"); 381.1Such 391.1Such#include <sys/param.h> 401.1Such#include <sys/systm.h> 411.1Such#include <sys/device.h> 421.1Such 431.1Such#include <sys/termios.h> 441.1Such#include <dev/cons.h> 451.1Such#include <sys/conf.h> 461.1Such 471.1Such#include <machine/bus.h> 481.1Such#include <machine/intr.h> 491.1Such#include <machine/autoconf.h> 501.1Such#include <machine/mmeye.h> 511.1Such 521.1Such#include <dev/ic/comvar.h> 531.1Such#include <dev/ic/comreg.h> 541.1Such 551.1Such#ifndef COMCN_SPEED 561.1Such#define COMCN_SPEED 19200 571.1Such#endif 581.1Such#ifndef CONADDR 591.1Such#define CONADDR 0xa4000000 601.1Such#endif 611.1Such#ifndef CONMODE 621.1Such#define CONMODE ((TTYDEF_CFLAG & ~(CSIZE | CSTOPB | PARENB)) | CS8) /* 8N1 */ 631.1Such#endif 641.1Such 651.1Suchstruct com_mainbus_softc { 661.1Such struct com_softc sc_com; /* real "com" softc */ 671.1Such}; 681.1Such 691.1Suchint com_mainbus_match(struct device *, struct cfdata *, void *); 701.1Suchvoid com_mainbus_attach(struct device *, struct device *, void *); 711.1Suchvoid comcnprobe(struct consdev *); 721.1Suchvoid comcninit(struct consdev *); 731.1Such 741.3SthorpejCFATTACH_DECL(com_mainbus, sizeof(struct com_mainbus_softc), 751.3Sthorpej com_mainbus_match, com_mainbus_attach, NULL, NULL); 761.1Such 771.1Suchint 781.1Suchcom_mainbus_match(struct device *parent, struct cfdata *match, void *aux) 791.1Such{ 801.1Such extern struct cfdriver com_cd; 811.1Such struct mainbus_attach_args *ma = aux; 821.1Such 831.1Such if (strcmp(ma->ma_name, com_cd.cd_name) == 0) 841.1Such return (1); 851.1Such 861.1Such return (0); 871.1Such} 881.1Such 891.1Suchvoid 901.1Suchcom_mainbus_attach(struct device *parent, struct device *self, void *aux) 911.1Such{ 921.1Such struct mainbus_attach_args *ma = aux; 931.1Such struct com_mainbus_softc *sc = (void *)self; 941.1Such struct com_softc *csc = &sc->sc_com; 951.1Such 961.1Such csc->sc_iot = 0; 971.1Such csc->sc_ioh = ma->ma_addr1; 981.1Such csc->sc_iobase = 0; 991.1Such csc->sc_frequency = COM_FREQ; 1001.1Such 1011.1Such /* sanity check */ 1021.1Such if (!comprobe1(csc->sc_iot, csc->sc_ioh)) { 1031.1Such printf(": device problem. don't attach.\n"); 1041.1Such return; 1051.1Such } 1061.1Such 1071.1Such com_attach_subr(csc); 1081.1Such 1091.1Such mmeye_intr_establish(ma->ma_irq1, IST_LEVEL, IPL_SERIAL, comintr, sc); 1101.1Such} 1111.1Such 1121.1Suchvoid 1131.1Suchcomcnprobe(struct consdev *cp) 1141.1Such{ 1151.1Such 1161.1Such#ifdef COMCONSOLE 1171.1Such cp->cn_pri = CN_REMOTE; /* Force a serial port console */ 1181.1Such#else 1191.1Such cp->cn_pri = CN_NORMAL; 1201.1Such#endif 1211.1Such} 1221.1Such 1231.1Suchvoid 1241.1Suchcomcninit(cp) 1251.1Such struct consdev *cp; 1261.1Such{ 1271.1Such 1281.4Sthorpej comcnattach(0, CONADDR, COMCN_SPEED, COM_FREQ, COM_TYPE_NORMAL, 1291.4Sthorpej CONMODE); 1301.1Such} 131