Home | History | Annotate | Line # | Download | only in xscale
i80321_aau.c revision 1.12.10.2
      1  1.12.10.2     yamt /*	$NetBSD: i80321_aau.c,v 1.12.10.2 2009/05/04 08:10:45 yamt 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.12.10.2     yamt __KERNEL_RCSID(0, "$NetBSD: i80321_aau.c,v 1.12.10.2 2009/05/04 08:10:45 yamt 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/systm.h>
     48        1.1  thorpej #include <sys/device.h>
     49        1.1  thorpej #include <sys/uio.h>
     50       1.12       ad #include <sys/bus.h>
     51       1.12       ad #include <sys/intr.h>
     52        1.1  thorpej 
     53        1.1  thorpej #include <uvm/uvm.h>
     54        1.1  thorpej 
     55        1.1  thorpej #include <arm/xscale/i80321reg.h>
     56        1.1  thorpej #include <arm/xscale/i80321var.h>
     57        1.1  thorpej 
     58        1.1  thorpej #include <arm/xscale/iopaaureg.h>
     59        1.1  thorpej #include <arm/xscale/iopaauvar.h>
     60        1.1  thorpej 
     61        1.1  thorpej struct aau321_softc {
     62        1.1  thorpej 	/* Shared AAU definitions. */
     63        1.1  thorpej 	struct iopaau_softc sc_iopaau;
     64        1.1  thorpej 
     65        1.1  thorpej 	/* i80321-specific stuff. */
     66        1.1  thorpej 	void *sc_error_ih;
     67        1.1  thorpej 	void *sc_eoc_ih;
     68        1.1  thorpej 	void *sc_eot_ih;
     69        1.1  thorpej };
     70        1.1  thorpej 
     71        1.1  thorpej static struct iopaau_function aau321_func_zero = {
     72  1.12.10.1     yamt 	.af_setup = iopaau_func_zero_setup,
     73        1.1  thorpej };
     74        1.1  thorpej 
     75        1.1  thorpej static struct iopaau_function aau321_func_fill8 = {
     76  1.12.10.1     yamt 	.af_setup = iopaau_func_fill8_setup,
     77        1.1  thorpej };
     78        1.1  thorpej 
     79        1.3  thorpej static struct iopaau_function aau321_func_xor_1_4 = {
     80  1.12.10.1     yamt 	.af_setup = iopaau_func_xor_setup,
     81        1.1  thorpej };
     82        1.1  thorpej 
     83        1.5  thorpej static struct iopaau_function aau321_func_xor_5_8 = {
     84  1.12.10.1     yamt 	.af_setup = iopaau_func_xor_setup,
     85        1.5  thorpej };
     86        1.5  thorpej 
     87        1.1  thorpej static const struct dmover_algdesc aau321_algdescs[] = {
     88        1.1  thorpej 	{
     89  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_ZERO,
     90  1.12.10.1     yamt 	  .dad_data = &aau321_func_zero,
     91  1.12.10.1     yamt 	  .dad_ninputs = 0
     92        1.1  thorpej 	},
     93        1.1  thorpej 	{
     94  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_FILL8,
     95  1.12.10.1     yamt 	  .dad_data = &aau321_func_fill8,
     96  1.12.10.1     yamt 	  .dad_ninputs = 0
     97        1.1  thorpej 	},
     98        1.1  thorpej 	{
     99  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_COPY,
    100  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_1_4,
    101  1.12.10.1     yamt 	  .dad_ninputs = 1
    102        1.3  thorpej 	},
    103        1.3  thorpej 	{
    104  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_XOR2,
    105  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_1_4,
    106  1.12.10.1     yamt 	  .dad_ninputs = 2
    107        1.3  thorpej 	},
    108        1.3  thorpej 	{
    109  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_XOR3,
    110  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_1_4,
    111  1.12.10.1     yamt 	  .dad_ninputs = 3
    112        1.3  thorpej 	},
    113        1.3  thorpej 	{
    114  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_XOR4,
    115  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_1_4,
    116  1.12.10.1     yamt 	  .dad_ninputs = 4
    117        1.5  thorpej 	},
    118        1.5  thorpej 	{
    119  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_XOR5,
    120  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_5_8,
    121        1.5  thorpej 	  5
    122        1.5  thorpej 	},
    123        1.5  thorpej 	{
    124  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_XOR6,
    125  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_5_8,
    126  1.12.10.1     yamt 	  .dad_ninputs = 6
    127        1.5  thorpej 	},
    128        1.5  thorpej 	{
    129  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_XOR7,
    130  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_5_8,
    131  1.12.10.1     yamt 	  .dad_ninputs = 7
    132        1.5  thorpej 	},
    133        1.5  thorpej 	{
    134  1.12.10.1     yamt 	  .dad_name = DMOVER_FUNC_XOR8,
    135  1.12.10.1     yamt 	  .dad_data = &aau321_func_xor_5_8,
    136  1.12.10.1     yamt 	  .dad_ninputs = 8
    137        1.1  thorpej 	},
    138        1.1  thorpej };
    139  1.12.10.1     yamt #define	AAU321_ALGDESC_COUNT	__arraycount(aau321_algdescs)
    140        1.1  thorpej 
    141        1.1  thorpej static int
    142        1.1  thorpej aau321_match(struct device *parent, struct cfdata *match, void *aux)
    143        1.1  thorpej {
    144        1.1  thorpej 	struct iopxs_attach_args *ia = aux;
    145        1.1  thorpej 
    146        1.6  thorpej 	if (strcmp(match->cf_name, ia->ia_name) == 0)
    147        1.1  thorpej 		return (1);
    148        1.1  thorpej 
    149        1.1  thorpej 	return (0);
    150        1.1  thorpej }
    151        1.1  thorpej 
    152        1.1  thorpej static void
    153        1.1  thorpej aau321_attach(struct device *parent, struct device *self, void *aux)
    154        1.1  thorpej {
    155        1.1  thorpej 	struct aau321_softc *sc321 = (void *) self;
    156        1.1  thorpej 	struct iopaau_softc *sc = &sc321->sc_iopaau;
    157        1.1  thorpej 	struct iopxs_attach_args *ia = aux;
    158        1.1  thorpej 	int error;
    159        1.1  thorpej 
    160        1.9  thorpej 	aprint_naive("\n");
    161        1.9  thorpej 	aprint_normal("\n");
    162        1.1  thorpej 
    163        1.1  thorpej 	sc->sc_st = ia->ia_st;
    164        1.1  thorpej 	error = bus_space_subregion(sc->sc_st, ia->ia_sh,
    165        1.1  thorpej 	    ia->ia_offset, ia->ia_size, &sc->sc_sh);
    166        1.1  thorpej 	if (error) {
    167        1.9  thorpej 		aprint_error("%s: unable to subregion registers, error = %d\n",
    168        1.1  thorpej 		    sc->sc_dev.dv_xname, error);
    169        1.1  thorpej 		return;
    170        1.1  thorpej 	}
    171        1.1  thorpej 
    172        1.1  thorpej 	sc->sc_dmat = ia->ia_dmat;
    173        1.1  thorpej 
    174        1.1  thorpej 	sc321->sc_error_ih = i80321_intr_establish(ICU_INT_AAUE, IPL_BIO,
    175        1.1  thorpej 	    iopaau_intr, sc);
    176        1.1  thorpej 	if (sc321->sc_error_ih == NULL) {
    177        1.9  thorpej 		aprint_error("%s: unable to register error interrupt handler\n",
    178        1.1  thorpej 		    sc->sc_dev.dv_xname);
    179        1.1  thorpej 		return;
    180        1.1  thorpej 	}
    181        1.1  thorpej 
    182        1.1  thorpej 	sc321->sc_eoc_ih = i80321_intr_establish(ICU_INT_AAU_EOC, IPL_BIO,
    183        1.1  thorpej 	    iopaau_intr, sc);
    184        1.1  thorpej 	if (sc321->sc_eoc_ih == NULL) {
    185        1.9  thorpej 		aprint_error("%s: unable to register EOC interrupt handler\n",
    186        1.1  thorpej 		    sc->sc_dev.dv_xname);
    187        1.1  thorpej 		return;
    188        1.1  thorpej 	}
    189        1.1  thorpej 
    190        1.1  thorpej 	sc321->sc_eot_ih = i80321_intr_establish(ICU_INT_AAU_EOT, IPL_BIO,
    191        1.1  thorpej 	    iopaau_intr, sc);
    192        1.1  thorpej 	if (sc321->sc_eoc_ih == NULL) {
    193        1.9  thorpej 		aprint_error("%s: unable to register EOT interrupt handler\n",
    194        1.1  thorpej 		    sc->sc_dev.dv_xname);
    195        1.1  thorpej 		return;
    196        1.1  thorpej 	}
    197        1.1  thorpej 
    198        1.1  thorpej 	sc->sc_dmb.dmb_name = sc->sc_dev.dv_xname;
    199        1.1  thorpej 	sc->sc_dmb.dmb_speed = 1638400;			/* XXX */
    200        1.1  thorpej 	sc->sc_dmb.dmb_cookie = sc;
    201        1.1  thorpej 	sc->sc_dmb.dmb_algdescs = aau321_algdescs;
    202        1.1  thorpej 	sc->sc_dmb.dmb_nalgdescs = AAU321_ALGDESC_COUNT;
    203        1.1  thorpej 	sc->sc_dmb.dmb_process = iopaau_process;
    204        1.1  thorpej 
    205        1.1  thorpej 	iopaau_attach(sc);
    206       1.11       ad 
    207  1.12.10.2     yamt 	/*
    208  1.12.10.2     yamt 	 * These must be initialized after iopaau_attach()
    209  1.12.10.2     yamt 	 * because iopaau_desc_[48]_cache is set up there.
    210  1.12.10.2     yamt 	 */
    211  1.12.10.2     yamt 	KASSERT(iopaau_desc_4_cache != NULL);
    212       1.11       ad 	aau321_func_zero.af_desc_cache = iopaau_desc_4_cache;
    213       1.11       ad 	aau321_func_fill8.af_desc_cache = iopaau_desc_4_cache;
    214       1.11       ad 	aau321_func_xor_1_4.af_desc_cache = iopaau_desc_4_cache;
    215  1.12.10.2     yamt 
    216  1.12.10.2     yamt 	KASSERT(iopaau_desc_8_cache != NULL);
    217       1.11       ad 	aau321_func_xor_5_8.af_desc_cache = iopaau_desc_8_cache;
    218        1.1  thorpej }
    219        1.1  thorpej 
    220        1.8  thorpej CFATTACH_DECL(iopaau, sizeof(struct aau321_softc),
    221        1.8  thorpej     aau321_match, aau321_attach, NULL, NULL);
    222