Home | History | Annotate | Line # | Download | only in xscale
i80321_aau.c revision 1.5
      1  1.5  thorpej /*	$NetBSD: i80321_aau.c,v 1.5 2002/08/04 02:26:18 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.5  thorpej __KERNEL_RCSID(0, "$NetBSD: i80321_aau.c,v 1.5 2002/08/04 02:26:18 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.4  thorpej 	&iopaau_desc_4_cache,
     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.4  thorpej 	&iopaau_desc_4_cache,
     81  1.1  thorpej };
     82  1.1  thorpej 
     83  1.3  thorpej static struct iopaau_function aau321_func_xor_1_4 = {
     84  1.5  thorpej 	iopaau_func_xor_setup,
     85  1.4  thorpej 	&iopaau_desc_4_cache,
     86  1.1  thorpej };
     87  1.1  thorpej 
     88  1.5  thorpej static struct iopaau_function aau321_func_xor_5_8 = {
     89  1.5  thorpej 	iopaau_func_xor_setup,
     90  1.5  thorpej 	&iopaau_desc_8_cache,
     91  1.5  thorpej };
     92  1.5  thorpej 
     93  1.1  thorpej static const struct dmover_algdesc aau321_algdescs[] = {
     94  1.1  thorpej 	{
     95  1.1  thorpej 	  DMOVER_FUNC_ZERO,
     96  1.1  thorpej 	  &aau321_func_zero,
     97  1.1  thorpej 	  0
     98  1.1  thorpej 	},
     99  1.1  thorpej 	{
    100  1.1  thorpej 	  DMOVER_FUNC_FILL8,
    101  1.1  thorpej 	  &aau321_func_fill8,
    102  1.1  thorpej 	  0
    103  1.1  thorpej 	},
    104  1.1  thorpej 	{
    105  1.1  thorpej 	  DMOVER_FUNC_COPY,
    106  1.3  thorpej 	  &aau321_func_xor_1_4,
    107  1.1  thorpej 	  1
    108  1.3  thorpej 	},
    109  1.3  thorpej 	{
    110  1.3  thorpej 	  DMOVER_FUNC_XOR2,
    111  1.3  thorpej 	  &aau321_func_xor_1_4,
    112  1.3  thorpej 	  2
    113  1.3  thorpej 	},
    114  1.3  thorpej 	{
    115  1.3  thorpej 	  DMOVER_FUNC_XOR3,
    116  1.3  thorpej 	  &aau321_func_xor_1_4,
    117  1.3  thorpej 	  3
    118  1.3  thorpej 	},
    119  1.3  thorpej 	{
    120  1.3  thorpej 	  DMOVER_FUNC_XOR4,
    121  1.3  thorpej 	  &aau321_func_xor_1_4,
    122  1.3  thorpej 	  4
    123  1.5  thorpej 	},
    124  1.5  thorpej 	{
    125  1.5  thorpej 	  DMOVER_FUNC_XOR5,
    126  1.5  thorpej 	  &aau321_func_xor_5_8,
    127  1.5  thorpej 	  5
    128  1.5  thorpej 	},
    129  1.5  thorpej 	{
    130  1.5  thorpej 	  DMOVER_FUNC_XOR6,
    131  1.5  thorpej 	  &aau321_func_xor_5_8,
    132  1.5  thorpej 	  6
    133  1.5  thorpej 	},
    134  1.5  thorpej 	{
    135  1.5  thorpej 	  DMOVER_FUNC_XOR7,
    136  1.5  thorpej 	  &aau321_func_xor_5_8,
    137  1.5  thorpej 	  7
    138  1.5  thorpej 	},
    139  1.5  thorpej 	{
    140  1.5  thorpej 	  DMOVER_FUNC_XOR8,
    141  1.5  thorpej 	  &aau321_func_xor_5_8,
    142  1.5  thorpej 	  8
    143  1.1  thorpej 	},
    144  1.1  thorpej };
    145  1.1  thorpej #define	AAU321_ALGDESC_COUNT \
    146  1.1  thorpej 	(sizeof(aau321_algdescs) / sizeof(aau321_algdescs[0]))
    147  1.1  thorpej 
    148  1.1  thorpej static int
    149  1.1  thorpej aau321_match(struct device *parent, struct cfdata *match, void *aux)
    150  1.1  thorpej {
    151  1.1  thorpej 	struct iopxs_attach_args *ia = aux;
    152  1.1  thorpej 
    153  1.1  thorpej 	if (strcmp(match->cf_driver->cd_name, ia->ia_name) == 0)
    154  1.1  thorpej 		return (1);
    155  1.1  thorpej 
    156  1.1  thorpej 	return (0);
    157  1.1  thorpej }
    158  1.1  thorpej 
    159  1.1  thorpej static void
    160  1.1  thorpej aau321_attach(struct device *parent, struct device *self, void *aux)
    161  1.1  thorpej {
    162  1.1  thorpej 	struct aau321_softc *sc321 = (void *) self;
    163  1.1  thorpej 	struct iopaau_softc *sc = &sc321->sc_iopaau;
    164  1.1  thorpej 	struct iopxs_attach_args *ia = aux;
    165  1.1  thorpej 	int error;
    166  1.1  thorpej 
    167  1.1  thorpej 	printf("\n");
    168  1.1  thorpej 
    169  1.1  thorpej 	sc->sc_st = ia->ia_st;
    170  1.1  thorpej 	error = bus_space_subregion(sc->sc_st, ia->ia_sh,
    171  1.1  thorpej 	    ia->ia_offset, ia->ia_size, &sc->sc_sh);
    172  1.1  thorpej 	if (error) {
    173  1.1  thorpej 		printf("%s: unable to subregion registers, error = %d\n",
    174  1.1  thorpej 		    sc->sc_dev.dv_xname, error);
    175  1.1  thorpej 		return;
    176  1.1  thorpej 	}
    177  1.1  thorpej 
    178  1.1  thorpej 	sc->sc_dmat = ia->ia_dmat;
    179  1.1  thorpej 
    180  1.1  thorpej 	sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
    181  1.1  thorpej 	    iopaau_intr, sc);
    182  1.1  thorpej 	if (sc321->sc_error_ih == NULL) {
    183  1.1  thorpej 		printf("%s: unable to register error interrupt handler\n",
    184  1.1  thorpej 		    sc->sc_dev.dv_xname);
    185  1.1  thorpej 		return;
    186  1.1  thorpej 	}
    187  1.1  thorpej 
    188  1.1  thorpej 	sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
    189  1.1  thorpej 	    iopaau_intr, sc);
    190  1.1  thorpej 	if (sc321->sc_eoc_ih == NULL) {
    191  1.1  thorpej 		printf("%s: unable to register EOC interrupt handler\n",
    192  1.1  thorpej 		    sc->sc_dev.dv_xname);
    193  1.1  thorpej 		return;
    194  1.1  thorpej 	}
    195  1.1  thorpej 
    196  1.1  thorpej 	sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
    197  1.1  thorpej 	    iopaau_intr, sc);
    198  1.1  thorpej 	if (sc321->sc_eoc_ih == NULL) {
    199  1.1  thorpej 		printf("%s: unable to register EOT interrupt handler\n",
    200  1.1  thorpej 		    sc->sc_dev.dv_xname);
    201  1.1  thorpej 		return;
    202  1.1  thorpej 	}
    203  1.1  thorpej 
    204  1.1  thorpej 	sc->sc_dmb.dmb_name = sc->sc_dev.dv_xname;
    205  1.1  thorpej 	sc->sc_dmb.dmb_speed = 1638400;			/* XXX */
    206  1.1  thorpej 	sc->sc_dmb.dmb_cookie = sc;
    207  1.1  thorpej 	sc->sc_dmb.dmb_algdescs = aau321_algdescs;
    208  1.1  thorpej 	sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
    209  1.1  thorpej 	sc->sc_dmb.dmb_process = iopaau_process;
    210  1.1  thorpej 
    211  1.1  thorpej 	iopaau_attach(sc);
    212  1.1  thorpej }
    213  1.1  thorpej 
    214  1.1  thorpej struct cfattach iopaau_ca = {
    215  1.1  thorpej 	sizeof(struct aau321_softc), aau321_match, aau321_attach,
    216  1.1  thorpej };
    217