Home | History | Annotate | Line # | Download | only in pci
atppc_puc.c revision 1.1
      1 /* $NetBSD: atppc_puc.c,v 1.1 2004/01/25 11:50:51 jdolecek Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2004 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jaromir Dolecek.
      9  *
     10  * Redistribution and use in source and binary forms, with or without
     11  * modification, are permitted provided that the following conditions
     12  * are met:
     13  * 1. Redistributions of source code must retain the above copyright
     14  *    notice, this list of conditions and the following disclaimer.
     15  * 2. Redistributions in binary form must reproduce the above copyright
     16  *    notice, this list of conditions and the following disclaimer in the
     17  *    documentation and/or other materials provided with the distribution.
     18  * 3. All advertising materials mentioning features or use of this software
     19  *    must display the following acknowledgement:
     20  *        This product includes software developed by the NetBSD
     21  *        Foundation, Inc. and its contributors.
     22  * 4. Neither the name of The NetBSD Foundation nor the names of its
     23  *    contributors may be used to endorse or promote products derived
     24  *    from this software without specific prior written permission.
     25  *
     26  * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
     27  * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     28  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     29  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
     30  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     31  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     32  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     33  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     34  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     35  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     36  * POSSIBILITY OF SUCH DAMAGE.
     37  */
     38 
     39 #include "opt_atppc.h"
     40 
     41 #include <sys/cdefs.h>
     42 __KERNEL_RCSID(0, "$NetBSD: atppc_puc.c,v 1.1 2004/01/25 11:50:51 jdolecek Exp $");
     43 
     44 #include <sys/param.h>
     45 #include <sys/systm.h>
     46 #include <sys/errno.h>
     47 #include <sys/ioctl.h>
     48 #include <sys/syslog.h>
     49 #include <sys/device.h>
     50 #include <sys/proc.h>
     51 #include <sys/termios.h>
     52 
     53 #include <machine/bus.h>
     54 
     55 #include <dev/pci/pcivar.h>
     56 #include <dev/pci/pucvar.h>
     57 
     58 #include <dev/ic/atppcvar.h>
     59 
     60 static int	atppc_puc_match(struct device *, struct cfdata *, void *);
     61 static void	atppc_puc_attach(struct device *, struct device *, void *);
     62 
     63 CFATTACH_DECL(atppc_puc, sizeof(struct atppc_softc), atppc_puc_match,
     64     atppc_puc_attach, NULL, NULL);
     65 
     66 static int atppc_puc_dma_start(struct atppc_softc *, void *, u_int,
     67 	u_int8_t);
     68 static int atppc_puc_dma_finish(struct atppc_softc *);
     69 static int atppc_puc_dma_abort(struct atppc_softc *);
     70 static int atppc_puc_dma_malloc(struct device *, caddr_t *, bus_addr_t *,
     71 	bus_size_t);
     72 static void atppc_puc_dma_free(struct device *, caddr_t *, bus_addr_t *,
     73 	bus_size_t);
     74 
     75 /*
     76  * atppc_acpi_match: autoconf(9) match routine
     77  */
     78 static int
     79 atppc_puc_match(struct device *parent, struct cfdata *match, void *aux)
     80 {
     81 	struct puc_attach_args *aa = aux;
     82 
     83 	/*
     84 	 * Locators already matched, just check the type.
     85 	 */
     86 	if (aa->type != PUC_PORT_TYPE_LPT)
     87 		return (0);
     88 
     89 	return (1);
     90 }
     91 
     92 static void
     93 atppc_puc_attach(struct device *parent, struct device *self, void *aux)
     94 {
     95 	struct atppc_softc *sc = (struct atppc_softc *) self;
     96 	struct puc_attach_args *aa = aux;
     97 	const char *intrstr;
     98 
     99 	sc->sc_dev_ok = ATPPC_NOATTACH;
    100 
    101 	printf(": AT Parallel Port\n");
    102 
    103 	/* Attach */
    104 	sc->sc_iot = aa->t;
    105 	sc->sc_ioh = aa->h;
    106 	sc->sc_dmat = aa->dmat;
    107 	sc->sc_has = 0;
    108 
    109 	intrstr = pci_intr_string(aa->pc, aa->intrhandle);
    110 	sc->sc_ieh = pci_intr_establish(aa->pc, aa->intrhandle, IPL_TTY,
    111 	    atppcintr, sc);
    112 	if (sc->sc_ieh == NULL) {
    113 		printf("%s: couldn't establish interrupt",
    114 		    sc->sc_dev.dv_xname);
    115 		if (intrstr != NULL)
    116 			printf(" at %s", intrstr);
    117 		printf("\n");
    118 		return;
    119 	}
    120 	printf("%s: interrupting at %s\n", sc->sc_dev.dv_xname, intrstr);
    121 	sc->sc_has |= ATPPC_HAS_INTR;
    122 
    123 	/* setup DMA hooks */
    124 	/* XXX setup dma maps */
    125 	sc->sc_dma_start = atppc_puc_dma_start;
    126 	sc->sc_dma_finish = atppc_puc_dma_finish;
    127 	sc->sc_dma_abort = atppc_puc_dma_abort;
    128 	sc->sc_dma_malloc = atppc_puc_dma_malloc;
    129 	sc->sc_dma_free = atppc_puc_dma_free;
    130 	//sc->sc_has |= ATPPC_HAS_DMA;
    131 
    132 	/* Finished attach */
    133 	sc->sc_dev_ok = ATPPC_ATTACHED;
    134 
    135 	/* Run soft configuration attach */
    136 	atppc_sc_attach(sc);
    137 }
    138 
    139 /* Start DMA operation over PCI bus */
    140 static int
    141 atppc_puc_dma_start(struct atppc_softc *lsc, void *buf, u_int nbytes,
    142 	u_int8_t mode)
    143 {
    144 
    145 	/* Nothing to do */
    146 	return (0);
    147 }
    148 
    149 /* Stop DMA operation over PCI bus */
    150 static int
    151 atppc_puc_dma_finish(struct atppc_softc * lsc)
    152 {
    153 
    154 	/* Nothing to do */
    155 	return (0);
    156 }
    157 
    158 /* Abort DMA operation over PCI bus */
    159 int
    160 atppc_puc_dma_abort(struct atppc_softc * lsc)
    161 {
    162 
    163 	/* Nothing to do */
    164 	return (0);
    165 }
    166 
    167 /* Allocate memory for DMA over PCI bus */
    168 int
    169 atppc_puc_dma_malloc(struct device * dev, caddr_t * buf, bus_addr_t * bus_addr,
    170 	bus_size_t size)
    171 {
    172 	return 0;
    173 /*
    174 	struct atppc_puc_softc * sc = (struct atppc_acpi_softc *) dev;
    175 
    176 	return atppc_isadma_malloc(sc->sc_ic, sc->sc_drq, buf, bus_addr, size);
    177 */
    178 }
    179 
    180 /* Free memory allocated by atppc_isa_dma_malloc() */
    181 void
    182 atppc_puc_dma_free(struct device * dev, caddr_t * buf, bus_addr_t * bus_addr,
    183 	bus_size_t size)
    184 {
    185 /*
    186 	struct atppc_acpi_softc * sc = (struct atppc_acpi_softc *) dev;
    187 
    188 	return atppc_isadma_free(sc->sc_ic, sc->sc_drq, buf, bus_addr, size);
    189 */
    190 }
    191