Home | History | Annotate | Line # | Download | only in dev
lpt_supio.c revision 1.10.108.2
      1  1.10.108.1      mjf /*	$NetBSD: lpt_supio.c,v 1.10.108.2 2008/06/02 13:21:50 mjf Exp $ */
      2         1.1       is 
      3         1.1       is /*-
      4         1.5       is  * Copyright (c) 1997 The NetBSD Foundation, Inc.
      5         1.4       is  * All rights reserved.
      6         1.4       is  *
      7         1.4       is  * This code is derived from software contributed to The NetBSD Foundation
      8         1.4       is  * by Ignatios Souvatzis.
      9         1.1       is  *
     10         1.1       is  * Redistribution and use in source and binary forms, with or without
     11         1.1       is  * modification, are permitted provided that the following conditions
     12         1.1       is  * are met:
     13         1.1       is  * 1. Redistributions of source code must retain the above copyright
     14         1.1       is  *    notice, this list of conditions and the following disclaimer.
     15         1.1       is  * 2. Redistributions in binary form must reproduce the above copyright
     16         1.1       is  *    notice, this list of conditions and the following disclaimer in the
     17         1.1       is  *    documentation and/or other materials provided with the distribution.
     18         1.1       is  *
     19         1.4       is  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     20         1.4       is  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     21         1.4       is  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     22         1.4       is  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     23         1.4       is  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     24         1.4       is  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     25         1.4       is  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     26         1.4       is  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     27         1.4       is  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     28         1.4       is  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     29         1.4       is  * POSSIBILITY OF SUCH DAMAGE.
     30         1.1       is  */
     31         1.8  aymeric 
     32         1.8  aymeric #include <sys/cdefs.h>
     33  1.10.108.1      mjf __KERNEL_RCSID(0, "$NetBSD: lpt_supio.c,v 1.10.108.2 2008/06/02 13:21:50 mjf Exp $");
     34         1.1       is 
     35         1.1       is #include <sys/param.h>
     36         1.1       is #include <sys/systm.h>
     37         1.1       is #include <sys/ioctl.h>
     38         1.1       is #include <sys/select.h>
     39         1.1       is #include <sys/tty.h>
     40         1.1       is #include <sys/proc.h>
     41         1.1       is #include <sys/user.h>
     42         1.1       is #include <sys/conf.h>
     43         1.1       is #include <sys/file.h>
     44         1.1       is #include <sys/uio.h>
     45         1.1       is #include <sys/kernel.h>
     46         1.1       is #include <sys/syslog.h>
     47         1.1       is #include <sys/types.h>
     48         1.1       is #include <sys/device.h>
     49         1.1       is 
     50         1.1       is #include <machine/intr.h>
     51         1.1       is #include <machine/bus.h>
     52         1.1       is 
     53         1.1       is #include <dev/ic/lptreg.h>
     54         1.1       is #include <dev/ic/lptvar.h>
     55         1.1       is 
     56         1.1       is #include <amiga/dev/supio.h>
     57         1.1       is 
     58         1.1       is struct lptsupio_softc {
     59         1.1       is 	struct lpt_softc sc_lpt;
     60         1.1       is 	struct isr sc_isr;
     61         1.7  aymeric 	void (*sc_intack)(void *);
     62         1.1       is };
     63         1.1       is 
     64  1.10.108.1      mjf int lpt_supio_match(device_t, cfdata_t , void *);
     65  1.10.108.1      mjf void lpt_supio_attach(device_t, device_t, void *);
     66         1.7  aymeric int lpt_supio_intr(void *p);
     67         1.1       is 
     68  1.10.108.1      mjf CFATTACH_DECL_NEW(lpt_supio, sizeof(struct lptsupio_softc),
     69        1.10  thorpej     lpt_supio_match, lpt_supio_attach, NULL, NULL);
     70         1.1       is 
     71         1.1       is int
     72  1.10.108.1      mjf lpt_supio_match(device_t parent, cfdata_t match, void *aux)
     73         1.1       is {
     74         1.1       is 	struct supio_attach_args *supa = aux;
     75         1.1       is 
     76         1.1       is 	if (strcmp(supa->supio_name,"lpt"))
     77         1.1       is 		return 0;
     78         1.1       is 
     79         1.1       is 	return (1);
     80         1.1       is }
     81         1.1       is 
     82         1.1       is int
     83         1.7  aymeric lpt_supio_intr(void *p)
     84         1.1       is {
     85         1.1       is 	struct lptsupio_softc *sc = (void *)p;
     86         1.1       is 	int rc;
     87         1.1       is 
     88         1.1       is 	rc = lptintr(&sc->sc_lpt);
     89         1.1       is 	if (sc->sc_intack)
     90         1.1       is 		(*sc->sc_intack)(p);
     91         1.1       is 	return (rc);
     92         1.1       is }
     93         1.1       is 
     94         1.1       is void
     95  1.10.108.1      mjf lpt_supio_attach(device_t parent, device_t self, void *aux)
     96         1.1       is {
     97  1.10.108.1      mjf 	struct lptsupio_softc *sc = device_private(self);
     98         1.1       is 	struct lpt_softc *lsc = &sc->sc_lpt;
     99         1.1       is 	int iobase;
    100         1.1       is 	bus_space_tag_t iot;
    101         1.1       is 	struct supio_attach_args *supa = aux;
    102         1.1       is 
    103         1.1       is 	/*
    104         1.1       is 	 * We're living on a superio chip.
    105         1.1       is 	 */
    106  1.10.108.1      mjf 	lsc->sc_dev = self;
    107         1.1       is 	iobase = supa->supio_iobase;
    108         1.1       is 	iot = lsc->sc_iot = supa->supio_iot;
    109         1.1       is 	sc->sc_intack = (void *)supa->supio_arg;
    110         1.1       is 
    111  1.10.108.1      mjf 	aprint_normal(" port 0x%04x ipl %d\n", iobase, supa->supio_ipl);
    112  1.10.108.1      mjf         if (bus_space_map(iot, iobase, LPT_NPORTS, 0, &lsc->sc_ioh)) {
    113  1.10.108.1      mjf 		aprint_error_dev(self, "io mapping failed\n");
    114  1.10.108.1      mjf 		return;
    115  1.10.108.1      mjf 	}
    116         1.1       is 
    117         1.1       is 	lpt_attach_subr(lsc);
    118         1.1       is 
    119         1.1       is 	sc->sc_isr.isr_intr = lpt_supio_intr;
    120         1.1       is 	sc->sc_isr.isr_arg = sc;
    121         1.1       is 	sc->sc_isr.isr_ipl = supa->supio_ipl;
    122         1.1       is 	add_isr(&sc->sc_isr);
    123         1.1       is }
    124