Home | History | Annotate | Line # | Download | only in jensenio
jensenio_dma.c revision 1.1
      1 /* $NetBSD: jensenio_dma.c,v 1.1 2000/07/12 20:36:09 thorpej Exp $ */
      2 
      3 /*-
      4  * Copyright (c) 2000 The NetBSD Foundation, Inc.
      5  * All rights reserved.
      6  *
      7  * This code is derived from software contributed to The NetBSD Foundation
      8  * by Jason R. Thorpe.
      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 /*
     40  * DMA support for the Jensen system.
     41  *
     42  * The Jensen uses direct-mapped DMA with a window base of 0, i.e.
     43  * a page of phyical memory has the same PCI address as CPU address.
     44  * There is no support for SGMAPs on the Jensen.  This means that for
     45  * ISA DMA, we must employ bounce buffers for DMA transactions over
     46  * 16MB ISA limit (due to ISA's 24-bit address space limitation).
     47  *
     48  * Furthermore, the H_BUS will not respond to DMA transactions between
     49  * 512KB and 1MB.  This is to allow for the ISA `hole'.  However, the
     50  * ISA `hole' typically exists only between 640KB and 1MB.  We must
     51  * therefore bounce transactions that fall within this region, as well.
     52  * XXX Should we prevent having managed memory in this region, instead?
     53  */
     54 
     55 #include <sys/cdefs.h>			/* RCS ID & Copyright macro defns */
     56 
     57 __KERNEL_RCSID(0, "$NetBSD: jensenio_dma.c,v 1.1 2000/07/12 20:36:09 thorpej Exp $");
     58 
     59 #include <sys/param.h>
     60 #include <sys/systm.h>
     61 #include <sys/kernel.h>
     62 #include <sys/device.h>
     63 #include <sys/malloc.h>
     64 #include <sys/mbuf.h>
     65 
     66 #define _ALPHA_BUS_DMA_PRIVATE
     67 #include <machine/bus.h>
     68 
     69 #include <dev/eisa/eisavar.h>
     70 
     71 #include <dev/isa/isavar.h>
     72 
     73 #include <alpha/jensenio/jenseniovar.h>
     74 
     75 bus_dma_tag_t jensenio_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
     76 
     77 void
     78 jensenio_dma_init(struct jensenio_config *jcp)
     79 {
     80 	bus_dma_tag_t t;
     81 
     82 	/*
     83 	 * Initialize the DMA tag used for EISA DMA.
     84 	 */
     85 	t = &jcp->jc_dmat_eisa;
     86 	t->_cookie = jcp;
     87 	t->_wbase = 0;
     88 	t->_wsize = 0x100000000UL;
     89 	t->_next_window = NULL;
     90 	t->_boundary = 0;
     91 	t->_sgmap = NULL;
     92 	t->_get_tag = jensenio_dma_get_tag;
     93 	t->_dmamap_create = _bus_dmamap_create;
     94 	t->_dmamap_destroy = _bus_dmamap_destroy;
     95 	t->_dmamap_load = _bus_dmamap_load_direct;
     96 	t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
     97 	t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
     98 	t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
     99 	t->_dmamap_unload = _bus_dmamap_unload;
    100 	t->_dmamap_sync = _bus_dmamap_sync;
    101 
    102 	t->_dmamem_alloc = _bus_dmamem_alloc;
    103 	t->_dmamem_free = _bus_dmamem_free;
    104 	t->_dmamem_map = _bus_dmamem_map;
    105 	t->_dmamem_unmap = _bus_dmamem_unmap;
    106 	t->_dmamem_mmap = _bus_dmamem_mmap;
    107 
    108 	/*
    109 	 * Initialize the DMA tag used for ISA DMA.
    110 	 */
    111 	t = &jcp->jc_dmat_isa;
    112 	t->_cookie = jcp;
    113 	t->_wbase = 0;
    114 	t->_wsize = 0x1000000;
    115 	t->_next_window = NULL;
    116 	t->_boundary = 0;
    117 	t->_sgmap = NULL;
    118 	t->_get_tag = jensenio_dma_get_tag;
    119 	t->_dmamap_create = isadma_bounce_dmamap_create;
    120 	t->_dmamap_destroy = isadma_bounce_dmamap_destroy;
    121 	t->_dmamap_load = isadma_bounce_dmamap_load;
    122 	t->_dmamap_load_mbuf = isadma_bounce_dmamap_load_mbuf;
    123 	t->_dmamap_load_uio = isadma_bounce_dmamap_load_uio;
    124 	t->_dmamap_load_raw = isadma_bounce_dmamap_load_raw;
    125 	t->_dmamap_unload = isadma_bounce_dmamap_unload;
    126 	t->_dmamap_sync = isadma_bounce_dmamap_sync;
    127 
    128 	t->_dmamem_alloc = isadma_bounce_dmamem_alloc;
    129 	t->_dmamem_free = _bus_dmamem_free;
    130 	t->_dmamem_map = _bus_dmamem_map;
    131 	t->_dmamem_unmap = _bus_dmamem_unmap;
    132 	t->_dmamem_mmap = _bus_dmamem_mmap;
    133 
    134 	/* XXX XXX BEGIN XXX XXX */
    135 	{							/* XXX */
    136 		extern paddr_t alpha_XXX_dmamap_or;		/* XXX */
    137 		alpha_XXX_dmamap_or = 0;			/* XXX */
    138 	}
    139 }
    140 
    141 /*
    142  * Return the bus dma tag to be used fo rthe specified bus type.
    143  * INTERNAL USE ONLY!
    144  */
    145 bus_dma_tag_t
    146 jensenio_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
    147 {
    148 	struct jensenio_config *jcp = t->_cookie;
    149 
    150 	switch (bustype) {
    151 	case ALPHA_BUS_EISA:
    152 		/*
    153 		 * Busses capable of 32-bit DMA get the EISA DMA tag.
    154 		 */
    155 		return (&jcp->jc_dmat_eisa);
    156 
    157 	case ALPHA_BUS_ISA:
    158 		/*
    159 		 * Lame 24-bit busses have to bounce.
    160 		 */
    161 		return (&jcp->jc_dmat_isa);
    162 
    163 	default:
    164 		panic("jensenio_dma_get_tag: shouldn't be here, really...");
    165 	}
    166 }
    167