tsdio.c revision 1.1
11.1Sjoff/* $NetBSD: tsdio.c,v 1.1 2005/08/14 03:50:34 joff Exp $ */ 21.1Sjoff 31.1Sjoff/*- 41.1Sjoff * Copyright (c) 2005 The NetBSD Foundation, Inc. 51.1Sjoff * All rights reserved. 61.1Sjoff * 71.1Sjoff * This code is derived from software contributed to The NetBSD Foundation 81.1Sjoff * by Jesse Off 91.1Sjoff * 101.1Sjoff * Redistribution and use in source and binary forms, with or without 111.1Sjoff * modification, are permitted provided that the following conditions 121.1Sjoff * are met: 131.1Sjoff * 1. Redistributions of source code must retain the above copyright 141.1Sjoff * notice, this list of conditions and the following disclaimer. 151.1Sjoff * 2. Redistributions in binary form must reproduce the above copyright 161.1Sjoff * notice, this list of conditions and the following disclaimer in the 171.1Sjoff * documentation and/or other materials provided with the distribution. 181.1Sjoff * 3. All advertising materials mentioning features or use of this software 191.1Sjoff * must display the following acknowledgement: 201.1Sjoff * This product includes software developed by the NetBSD 211.1Sjoff * Foundation, Inc. and its contributors. 221.1Sjoff * 4. Neither the name of The NetBSD Foundation nor the names of its 231.1Sjoff * contributors may be used to endorse or promote products derived 241.1Sjoff * from this software without specific prior written permission. 251.1Sjoff * 261.1Sjoff * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 271.1Sjoff * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 281.1Sjoff * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 291.1Sjoff * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 301.1Sjoff * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 311.1Sjoff * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 321.1Sjoff * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 331.1Sjoff * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 341.1Sjoff * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 351.1Sjoff * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 361.1Sjoff * POSSIBILITY OF SUCH DAMAGE. 371.1Sjoff */ 381.1Sjoff 391.1Sjoff#include <sys/cdefs.h> 401.1Sjoff__KERNEL_RCSID(0, "$NetBSD: tsdio.c,v 1.1 2005/08/14 03:50:34 joff Exp $"); 411.1Sjoff 421.1Sjoff#include <sys/param.h> 431.1Sjoff#include <sys/systm.h> 441.1Sjoff#include <sys/device.h> 451.1Sjoff 461.1Sjoff#include <machine/bus.h> 471.1Sjoff#include <machine/intr.h> 481.1Sjoff 491.1Sjoff#include <dev/isa/isareg.h> 501.1Sjoff#include <dev/isa/isavar.h> 511.1Sjoff#include <dev/isa/isadmavar.h> 521.1Sjoff#include <dev/isa/tsdiovar.h> 531.1Sjoff 541.1Sjoffint tsdio_probe(struct device *, struct cfdata *, void *); 551.1Sjoffvoid tsdio_attach(struct device *, struct device *, void *); 561.1Sjoffint tsdio_search(struct device *, struct cfdata *, const locdesc_t *, void *); 571.1Sjoffint tsdio_print(void *, const char *); 581.1Sjoff 591.1SjoffCFATTACH_DECL(tsdio, sizeof(struct tsdio_softc), 601.1Sjoff tsdio_probe, tsdio_attach, NULL, NULL); 611.1Sjoff 621.1Sjoffint 631.1Sjofftsdio_probe(parent, cf, aux) 641.1Sjoff struct device *parent; 651.1Sjoff struct cfdata *cf; 661.1Sjoff void *aux; 671.1Sjoff{ 681.1Sjoff struct isa_attach_args *ia = aux; 691.1Sjoff bus_space_tag_t iot = ia->ia_iot; 701.1Sjoff bus_space_handle_t dioh; 711.1Sjoff int rv = 0, have_io = 0; 721.1Sjoff 731.1Sjoff if (ia->ia_nio < 1) 741.1Sjoff return (0); 751.1Sjoff if (ia->ia_nirq < 1) 761.1Sjoff return (0); 771.1Sjoff 781.1Sjoff if (ISA_DIRECT_CONFIG(ia)) 791.1Sjoff return (0); 801.1Sjoff 811.1Sjoff /* 821.1Sjoff * Disallow wildcarded I/O base. 831.1Sjoff */ 841.1Sjoff if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT) 851.1Sjoff return (0); 861.1Sjoff 871.1Sjoff /* 881.1Sjoff * Map the I/O space. 891.1Sjoff */ 901.1Sjoff if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 8, 911.1Sjoff 0, &dioh)) 921.1Sjoff goto out; 931.1Sjoff have_io = 1; 941.1Sjoff 951.1Sjoff if (bus_space_read_1(ia->ia_iot, dioh, 0) != 0x54) { 961.1Sjoff goto out; 971.1Sjoff } 981.1Sjoff 991.1Sjoff rv = 1; 1001.1Sjoff ia->ia_nio = 1; 1011.1Sjoff ia->ia_io[0].ir_size = 8; 1021.1Sjoff ia->ia_niomem = 0; 1031.1Sjoff ia->ia_nirq = 0; 1041.1Sjoff ia->ia_ndrq = 0; 1051.1Sjoff 1061.1Sjoff out: 1071.1Sjoff if (have_io) 1081.1Sjoff bus_space_unmap(iot, dioh, 8); 1091.1Sjoff 1101.1Sjoff return (rv); 1111.1Sjoff} 1121.1Sjoff 1131.1Sjoffvoid 1141.1Sjofftsdio_attach(parent, self, aux) 1151.1Sjoff struct device *parent, *self; 1161.1Sjoff void *aux; 1171.1Sjoff{ 1181.1Sjoff struct tsdio_softc *sc = (struct tsdio_softc *) self; 1191.1Sjoff struct isa_attach_args *ia = aux; 1201.1Sjoff 1211.1Sjoff sc->sc_iot = ia->ia_iot; 1221.1Sjoff 1231.1Sjoff aprint_normal(": Technologic Systems TS-DIO24\n"); 1241.1Sjoff 1251.1Sjoff /* 1261.1Sjoff * Map the device. 1271.1Sjoff */ 1281.1Sjoff if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, 8, 1291.1Sjoff 0, &sc->sc_ioh)) { 1301.1Sjoff aprint_error("%s: unable to map i/o space\n", sc->sc_dev.dv_xname); 1311.1Sjoff return; 1321.1Sjoff } 1331.1Sjoff 1341.1Sjoff /* 1351.1Sjoff * Attach sub-devices 1361.1Sjoff */ 1371.1Sjoff config_search_ia(tsdio_search, self, "tsdio", NULL); 1381.1Sjoff} 1391.1Sjoff 1401.1Sjoffint 1411.1Sjofftsdio_search(parent, cf, l, aux) 1421.1Sjoff struct device *parent; 1431.1Sjoff struct cfdata *cf; 1441.1Sjoff const locdesc_t *l; 1451.1Sjoff void *aux; 1461.1Sjoff{ 1471.1Sjoff struct tsdio_softc *sc = (struct tsdio_softc *)parent; 1481.1Sjoff struct tsdio_attach_args sa; 1491.1Sjoff 1501.1Sjoff sa.ta_iot = sc->sc_iot; 1511.1Sjoff sa.ta_ioh = sc->sc_ioh; 1521.1Sjoff 1531.1Sjoff if (config_match(parent, cf, &sa) > 0) 1541.1Sjoff config_attach(parent, cf, &sa, tsdio_print); 1551.1Sjoff 1561.1Sjoff return (0); 1571.1Sjoff} 1581.1Sjoff 1591.1Sjoffint 1601.1Sjofftsdio_print(aux, name) 1611.1Sjoff void *aux; 1621.1Sjoff const char *name; 1631.1Sjoff{ 1641.1Sjoff 1651.1Sjoff return (UNCONF); 1661.1Sjoff} 167