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