Home | History | Annotate | Line # | Download | only in xscale
i80321_aau.c revision 1.1
      1 /*	$NetBSD: i80321_aau.c,v 1.1 2002/08/02 00:35:48 thorpej Exp $	*/
      2 
      3 /*
      4  * Copyright (c) 2002 Wasabi Systems, Inc.
      5  * All rights reserved.
      6  *
      7  * Written by Jason R. Thorpe for Wasabi Systems, Inc.
      8  *
      9  * Redistribution and use in source and binary forms, with or without
     10  * modification, are permitted provided that the following conditions
     11  * are met:
     12  * 1. Redistributions of source code must retain the above copyright
     13  *    notice, this list of conditions and the following disclaimer.
     14  * 2. Redistributions in binary form must reproduce the above copyright
     15  *    notice, this list of conditions and the following disclaimer in the
     16  *    documentation and/or other materials provided with the distribution.
     17  * 3. All advertising materials mentioning features or use of this software
     18  *    must display the following acknowledgement:
     19  *	This product includes software developed for the NetBSD Project by
     20  *	Wasabi Systems, Inc.
     21  * 4. The name of Wasabi Systems, Inc. may not be used to endorse
     22  *    or promote products derived from this software without specific prior
     23  *    written permission.
     24  *
     25  * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
     26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
     27  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
     28  * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL WASABI SYSTEMS, INC
     29  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
     30  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
     31  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
     32  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
     33  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
     34  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
     35  * POSSIBILITY OF SUCH DAMAGE.
     36  */
     37 
     38 /*
     39  * Intel i80321 I/O Processor application accelerator unit support.
     40  */
     41 
     42 #include <sys/cdefs.h>
     43 __KERNEL_RCSID(0, "$NetBSD");
     44 
     45 #include <sys/param.h>
     46 #include <sys/pool.h>
     47 #include <sys/lock.h>
     48 #include <sys/systm.h>
     49 #include <sys/device.h>
     50 #include <sys/uio.h>
     51 
     52 #include <uvm/uvm.h>
     53 
     54 #include <machine/bus.h>
     55 #include <machine/intr.h>
     56 
     57 #include <arm/xscale/i80321reg.h>
     58 #include <arm/xscale/i80321var.h>
     59 
     60 #include <arm/xscale/iopaaureg.h>
     61 #include <arm/xscale/iopaauvar.h>
     62 
     63 struct aau321_softc {
     64 	/* Shared AAU definitions. */
     65 	struct iopaau_softc sc_iopaau;
     66 
     67 	/* i80321-specific stuff. */
     68 	void *sc_error_ih;
     69 	void *sc_eoc_ih;
     70 	void *sc_eot_ih;
     71 };
     72 
     73 static struct iopaau_function aau321_func_zero = {
     74 	iopaau_func_zero_setup,
     75 	iopaau_desc_4_free,
     76 };
     77 
     78 static struct iopaau_function aau321_func_fill8 = {
     79 	iopaau_func_fill8_setup,
     80 	iopaau_desc_4_free,
     81 };
     82 
     83 static struct iopaau_function aau321_func_copy = {
     84 	iopaau_func_copy_setup,
     85 	iopaau_desc_4_free,
     86 };
     87 
     88 static const struct dmover_algdesc aau321_algdescs[] = {
     89 	{
     90 	  DMOVER_FUNC_ZERO,
     91 	  &aau321_func_zero,
     92 	  0
     93 	},
     94 	{
     95 	  DMOVER_FUNC_FILL8,
     96 	  &aau321_func_fill8,
     97 	  0
     98 	},
     99 	{
    100 	  DMOVER_FUNC_COPY,
    101 	  &aau321_func_copy,
    102 	  1
    103 	},
    104 };
    105 #define	AAU321_ALGDESC_COUNT \
    106 	(sizeof(aau321_algdescs) / sizeof(aau321_algdescs[0]))
    107 
    108 static int
    109 aau321_match(struct device *parent, struct cfdata *match, void *aux)
    110 {
    111 	struct iopxs_attach_args *ia = aux;
    112 
    113 	if (strcmp(match->cf_driver->cd_name, ia->ia_name) == 0)
    114 		return (1);
    115 
    116 	return (0);
    117 }
    118 
    119 static void
    120 aau321_attach(struct device *parent, struct device *self, void *aux)
    121 {
    122 	struct aau321_softc *sc321 = (void *) self;
    123 	struct iopaau_softc *sc = &sc321->sc_iopaau;
    124 	struct iopxs_attach_args *ia = aux;
    125 	int error;
    126 
    127 	printf("\n");
    128 
    129 	sc->sc_st = ia->ia_st;
    130 	error = bus_space_subregion(sc->sc_st, ia->ia_sh,
    131 	    ia->ia_offset, ia->ia_size, &sc->sc_sh);
    132 	if (error) {
    133 		printf("%s: unable to subregion registers, error = %d\n",
    134 		    sc->sc_dev.dv_xname, error);
    135 		return;
    136 	}
    137 
    138 	sc->sc_dmat = ia->ia_dmat;
    139 
    140 	sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
    141 	    iopaau_intr, sc);
    142 	if (sc321->sc_error_ih == NULL) {
    143 		printf("%s: unable to register error interrupt handler\n",
    144 		    sc->sc_dev.dv_xname);
    145 		return;
    146 	}
    147 
    148 	sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
    149 	    iopaau_intr, sc);
    150 	if (sc321->sc_eoc_ih == NULL) {
    151 		printf("%s: unable to register EOC interrupt handler\n",
    152 		    sc->sc_dev.dv_xname);
    153 		return;
    154 	}
    155 
    156 	sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
    157 	    iopaau_intr, sc);
    158 	if (sc321->sc_eoc_ih == NULL) {
    159 		printf("%s: unable to register EOT interrupt handler\n",
    160 		    sc->sc_dev.dv_xname);
    161 		return;
    162 	}
    163 
    164 	sc->sc_dmb.dmb_name = sc->sc_dev.dv_xname;
    165 	sc->sc_dmb.dmb_speed = 1638400;			/* XXX */
    166 	sc->sc_dmb.dmb_cookie = sc;
    167 	sc->sc_dmb.dmb_algdescs = aau321_algdescs;
    168 	sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
    169 	sc->sc_dmb.dmb_process = iopaau_process;
    170 
    171 	iopaau_attach(sc);
    172 }
    173 
    174 struct cfattach iopaau_ca = {
    175 	sizeof(struct aau321_softc), aau321_match, aau321_attach,
    176 };
    177