1 /* $NetBSD: jensenio_dma.c,v 1.1 2000/07/12 20:36:09 thorpej Exp $ */
4 * Copyright (c) 2000 The NetBSD Foundation, Inc.
7 * This code is derived from software contributed to The NetBSD Foundation
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
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.
19 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29 * POSSIBILITY OF SUCH DAMAGE.
33 * DMA support for the Jensen system.
35 * The Jensen uses direct-mapped DMA with a window base of 0, i.e.
36 * a page of phyical memory has the same PCI address as CPU address.
37 * There is no support for SGMAPs on the Jensen. This means that for
38 * ISA DMA, we must employ bounce buffers for DMA transactions over
39 * 16MB ISA limit (due to ISA's 24-bit address space limitation).
41 * Furthermore, the H_BUS will not respond to DMA transactions between
42 * 512KB and 1MB. This is to allow for the ISA `hole'. However, the
43 * ISA `hole' typically exists only between 640KB and 1MB. We must
44 * therefore bounce transactions that fall within this region, as well.
45 * XXX Should we prevent having managed memory in this region, instead?
48 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
50 __KERNEL_RCSID(0, "$NetBSD: jensenio_dma.c,v 1.1 2000/07/12 20:36:09 thorpej Exp $");
52 #include <sys/param.h>
53 #include <sys/systm.h>
54 #include <sys/kernel.h>
55 #include <sys/device.h>
56 #include <sys/malloc.h>
59 #define _ALPHA_BUS_DMA_PRIVATE
60 #include <machine/bus.h>
62 #include <dev/eisa/eisavar.h>
64 #include <dev/isa/isavar.h>
66 #include <alpha/jensenio/jenseniovar.h>
68 bus_dma_tag_t
jensenio_dma_get_tag(bus_dma_tag_t
, alpha_bus_t
);
71 jensenio_dma_init(struct jensenio_config
*jcp
)
76 * Initialize the DMA tag used for EISA DMA.
78 t
= &jcp
->jc_dmat_eisa
;
81 t
->_wsize
= 0x100000000UL
;
82 t
->_next_window
= NULL
;
85 t
->_get_tag
= jensenio_dma_get_tag
;
86 t
->_dmamap_create
= _bus_dmamap_create
;
87 t
->_dmamap_destroy
= _bus_dmamap_destroy
;
88 t
->_dmamap_load
= _bus_dmamap_load_direct
;
89 t
->_dmamap_load_mbuf
= _bus_dmamap_load_mbuf_direct
;
90 t
->_dmamap_load_uio
= _bus_dmamap_load_uio_direct
;
91 t
->_dmamap_load_raw
= _bus_dmamap_load_raw_direct
;
92 t
->_dmamap_unload
= _bus_dmamap_unload
;
93 t
->_dmamap_sync
= _bus_dmamap_sync
;
95 t
->_dmamem_alloc
= _bus_dmamem_alloc
;
96 t
->_dmamem_free
= _bus_dmamem_free
;
97 t
->_dmamem_map
= _bus_dmamem_map
;
98 t
->_dmamem_unmap
= _bus_dmamem_unmap
;
99 t
->_dmamem_mmap
= _bus_dmamem_mmap
;
102 * Initialize the DMA tag used for ISA DMA.
104 t
= &jcp
->jc_dmat_isa
;
107 t
->_wsize
= 0x1000000;
108 t
->_next_window
= NULL
;
111 t
->_get_tag
= jensenio_dma_get_tag
;
112 t
->_dmamap_create
= isadma_bounce_dmamap_create
;
113 t
->_dmamap_destroy
= isadma_bounce_dmamap_destroy
;
114 t
->_dmamap_load
= isadma_bounce_dmamap_load
;
115 t
->_dmamap_load_mbuf
= isadma_bounce_dmamap_load_mbuf
;
116 t
->_dmamap_load_uio
= isadma_bounce_dmamap_load_uio
;
117 t
->_dmamap_load_raw
= isadma_bounce_dmamap_load_raw
;
118 t
->_dmamap_unload
= isadma_bounce_dmamap_unload
;
119 t
->_dmamap_sync
= isadma_bounce_dmamap_sync
;
121 t
->_dmamem_alloc
= isadma_bounce_dmamem_alloc
;
122 t
->_dmamem_free
= _bus_dmamem_free
;
123 t
->_dmamem_map
= _bus_dmamem_map
;
124 t
->_dmamem_unmap
= _bus_dmamem_unmap
;
125 t
->_dmamem_mmap
= _bus_dmamem_mmap
;
127 /* XXX XXX BEGIN XXX XXX */
129 extern paddr_t alpha_XXX_dmamap_or
; /* XXX */
130 alpha_XXX_dmamap_or
= 0; /* XXX */
135 * Return the bus dma tag to be used fo rthe specified bus type.
139 jensenio_dma_get_tag(bus_dma_tag_t t
, alpha_bus_t bustype
)
141 struct jensenio_config
*jcp
= t
->_cookie
;
146 * Busses capable of 32-bit DMA get the EISA DMA tag.
148 return (&jcp
->jc_dmat_eisa
);
152 * Lame 24-bit busses have to bounce.
154 return (&jcp
->jc_dmat_isa
);
157 panic("jensenio_dma_get_tag: shouldn't be here, really...");