Simple driver for Technologic Systems TS-DIO24 PC104 board. No
userland interface (yet), basically just can detect a TS-DIO24 on a ISA bus and provide an attachment for sub-devices. The TS-DIO24 contains 24 programmable digital input/outputs.
This commit is contained in:
parent
f0e1f44063
commit
43b39c1131
|
@ -0,0 +1,166 @@
|
|||
/* $NetBSD: tsdio.c,v 1.1 2005/08/14 03:50:34 joff Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 2005 The NetBSD Foundation, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This code is derived from software contributed to The NetBSD Foundation
|
||||
* by Jesse Off
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by the NetBSD
|
||||
* Foundation, Inc. and its contributors.
|
||||
* 4. Neither the name of The NetBSD Foundation nor the names of its
|
||||
* contributors may be used to endorse or promote products derived
|
||||
* from this software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
|
||||
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__KERNEL_RCSID(0, "$NetBSD: tsdio.c,v 1.1 2005/08/14 03:50:34 joff Exp $");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/device.h>
|
||||
|
||||
#include <machine/bus.h>
|
||||
#include <machine/intr.h>
|
||||
|
||||
#include <dev/isa/isareg.h>
|
||||
#include <dev/isa/isavar.h>
|
||||
#include <dev/isa/isadmavar.h>
|
||||
#include <dev/isa/tsdiovar.h>
|
||||
|
||||
int tsdio_probe(struct device *, struct cfdata *, void *);
|
||||
void tsdio_attach(struct device *, struct device *, void *);
|
||||
int tsdio_search(struct device *, struct cfdata *, const locdesc_t *, void *);
|
||||
int tsdio_print(void *, const char *);
|
||||
|
||||
CFATTACH_DECL(tsdio, sizeof(struct tsdio_softc),
|
||||
tsdio_probe, tsdio_attach, NULL, NULL);
|
||||
|
||||
int
|
||||
tsdio_probe(parent, cf, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
void *aux;
|
||||
{
|
||||
struct isa_attach_args *ia = aux;
|
||||
bus_space_tag_t iot = ia->ia_iot;
|
||||
bus_space_handle_t dioh;
|
||||
int rv = 0, have_io = 0;
|
||||
|
||||
if (ia->ia_nio < 1)
|
||||
return (0);
|
||||
if (ia->ia_nirq < 1)
|
||||
return (0);
|
||||
|
||||
if (ISA_DIRECT_CONFIG(ia))
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Disallow wildcarded I/O base.
|
||||
*/
|
||||
if (ia->ia_io[0].ir_addr == ISA_UNKNOWN_PORT)
|
||||
return (0);
|
||||
|
||||
/*
|
||||
* Map the I/O space.
|
||||
*/
|
||||
if (bus_space_map(ia->ia_iot, ia->ia_io[0].ir_addr, 8,
|
||||
0, &dioh))
|
||||
goto out;
|
||||
have_io = 1;
|
||||
|
||||
if (bus_space_read_1(ia->ia_iot, dioh, 0) != 0x54) {
|
||||
goto out;
|
||||
}
|
||||
|
||||
rv = 1;
|
||||
ia->ia_nio = 1;
|
||||
ia->ia_io[0].ir_size = 8;
|
||||
ia->ia_niomem = 0;
|
||||
ia->ia_nirq = 0;
|
||||
ia->ia_ndrq = 0;
|
||||
|
||||
out:
|
||||
if (have_io)
|
||||
bus_space_unmap(iot, dioh, 8);
|
||||
|
||||
return (rv);
|
||||
}
|
||||
|
||||
void
|
||||
tsdio_attach(parent, self, aux)
|
||||
struct device *parent, *self;
|
||||
void *aux;
|
||||
{
|
||||
struct tsdio_softc *sc = (struct tsdio_softc *) self;
|
||||
struct isa_attach_args *ia = aux;
|
||||
|
||||
sc->sc_iot = ia->ia_iot;
|
||||
|
||||
aprint_normal(": Technologic Systems TS-DIO24\n");
|
||||
|
||||
/*
|
||||
* Map the device.
|
||||
*/
|
||||
if (bus_space_map(sc->sc_iot, ia->ia_io[0].ir_addr, 8,
|
||||
0, &sc->sc_ioh)) {
|
||||
aprint_error("%s: unable to map i/o space\n", sc->sc_dev.dv_xname);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Attach sub-devices
|
||||
*/
|
||||
config_search_ia(tsdio_search, self, "tsdio", NULL);
|
||||
}
|
||||
|
||||
int
|
||||
tsdio_search(parent, cf, l, aux)
|
||||
struct device *parent;
|
||||
struct cfdata *cf;
|
||||
const locdesc_t *l;
|
||||
void *aux;
|
||||
{
|
||||
struct tsdio_softc *sc = (struct tsdio_softc *)parent;
|
||||
struct tsdio_attach_args sa;
|
||||
|
||||
sa.ta_iot = sc->sc_iot;
|
||||
sa.ta_ioh = sc->sc_ioh;
|
||||
|
||||
if (config_match(parent, cf, &sa) > 0)
|
||||
config_attach(parent, cf, &sa, tsdio_print);
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
tsdio_print(aux, name)
|
||||
void *aux;
|
||||
const char *name;
|
||||
{
|
||||
|
||||
return (UNCONF);
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
/* $NetBSD: tsdioreg.h,v 1.1 2005/08/14 03:50:34 joff Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Jesse Off
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _TSDIOREG_H_
|
||||
#define _TSDIOREG_H_
|
||||
|
||||
#define TSDIO_BOARDID 0x0
|
||||
#define TSDIO_JPSTATUS 0x2
|
||||
#define TSDIO_INTCTL 0x3
|
||||
#define TSDIO_DDR 0x4
|
||||
#define TSDIO_PADR 0x5
|
||||
#define TSDIO_PBDR 0x6
|
||||
#define TSDIO_PCDR 0x7
|
||||
|
||||
#endif /* _TSDIOREG_H_ */
|
|
@ -0,0 +1,50 @@
|
|||
/* $NetBSD: tsdiovar.h,v 1.1 2005/08/14 03:50:34 joff Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 2004 Jesse Off
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed for the NetBSD Project by
|
||||
* Wasabi Systems, Inc.
|
||||
* 4. The name of Wasabi Systems, Inc. may not be used to endorse
|
||||
* or promote products derived from this software without specific prior
|
||||
* written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
|
||||
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _TSDIOVAR_H_
|
||||
#define _TSDIOVAR_H_
|
||||
|
||||
struct tsdio_softc {
|
||||
struct device sc_dev;
|
||||
bus_space_tag_t sc_iot;
|
||||
bus_space_handle_t sc_ioh;
|
||||
};
|
||||
|
||||
struct tsdio_attach_args {
|
||||
bus_space_tag_t ta_iot;
|
||||
bus_space_handle_t ta_ioh;
|
||||
};
|
||||
|
||||
#endif /* _TSDIOVAR_H_ */
|
Loading…
Reference in New Issue