1 /* $NetBSD: irongate_dma.c,v 1.3 2000/06/29 08:58:47 mrg 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 AMD 751 (``Irongate'') core logic chipset.
35 * The AMD 751 is really unlike all of the other Alpha PCI core logic
36 * chipsets. Instead, it looks like a normal PC chipset (not surprising,
37 * since it is used for Athlon processors).
39 * Because of this, it lacks all of the SGMAP hardware normally present
40 * on an Alpha system, and there are no DMA windows. Instead, a memory
41 * bus address is a PCI DMA address, and ISA DMA above 16M has to be
42 * bounced (this is not unlike the Jensen, actually).
45 #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
47 __KERNEL_RCSID(0, "$NetBSD: irongate_dma.c,v 1.3 2000/06/29 08:58:47 mrg Exp $");
49 #include <sys/param.h>
50 #include <sys/systm.h>
51 #include <sys/kernel.h>
52 #include <sys/device.h>
53 #include <sys/malloc.h>
55 #include <uvm/uvm_extern.h>
57 #define _ALPHA_BUS_DMA_PRIVATE
58 #include <machine/bus.h>
60 #include <dev/pci/pcireg.h>
61 #include <dev/pci/pcivar.h>
63 #include <alpha/pci/irongatereg.h>
64 #include <alpha/pci/irongatevar.h>
66 #include <dev/isa/isareg.h>
67 #include <dev/isa/isavar.h>
69 bus_dma_tag_t
irongate_dma_get_tag(bus_dma_tag_t
, alpha_bus_t
);
72 irongate_dma_init(struct irongate_config
*icp
)
77 * Initialize the DMA tag used for PCI DMA.
79 t
= &icp
->ic_dmat_pci
;
82 t
->_wsize
= 0x100000000UL
;
83 t
->_next_window
= NULL
;
86 t
->_get_tag
= irongate_dma_get_tag
;
87 t
->_dmamap_create
= _bus_dmamap_create
;
88 t
->_dmamap_destroy
= _bus_dmamap_destroy
;
89 t
->_dmamap_load
= _bus_dmamap_load_direct
;
90 t
->_dmamap_load_mbuf
= _bus_dmamap_load_mbuf_direct
;
91 t
->_dmamap_load_uio
= _bus_dmamap_load_uio_direct
;
92 t
->_dmamap_load_raw
= _bus_dmamap_load_raw_direct
;
93 t
->_dmamap_unload
= _bus_dmamap_unload
;
94 t
->_dmamap_sync
= _bus_dmamap_sync
;
96 t
->_dmamem_alloc
= _bus_dmamem_alloc
;
97 t
->_dmamem_free
= _bus_dmamem_free
;
98 t
->_dmamem_map
= _bus_dmamem_map
;
99 t
->_dmamem_unmap
= _bus_dmamem_unmap
;
100 t
->_dmamem_mmap
= _bus_dmamem_mmap
;
103 * Initialize the DMA tag used for ISA DMA.
105 t
= &icp
->ic_dmat_isa
;
108 t
->_wsize
= 0x1000000;
109 t
->_next_window
= NULL
;
112 t
->_get_tag
= irongate_dma_get_tag
;
113 t
->_dmamap_create
= isadma_bounce_dmamap_create
;
114 t
->_dmamap_destroy
= isadma_bounce_dmamap_destroy
;
115 t
->_dmamap_load
= isadma_bounce_dmamap_load
;
116 t
->_dmamap_load_mbuf
= isadma_bounce_dmamap_load_mbuf
;
117 t
->_dmamap_load_uio
= isadma_bounce_dmamap_load_uio
;
118 t
->_dmamap_load_raw
= isadma_bounce_dmamap_load_raw
;
119 t
->_dmamap_unload
= isadma_bounce_dmamap_unload
;
120 t
->_dmamap_sync
= isadma_bounce_dmamap_sync
;
122 t
->_dmamem_alloc
= isadma_bounce_dmamem_alloc
;
123 t
->_dmamem_free
= _bus_dmamem_free
;
124 t
->_dmamem_map
= _bus_dmamem_map
;
125 t
->_dmamem_unmap
= _bus_dmamem_unmap
;
126 t
->_dmamem_mmap
= _bus_dmamem_mmap
;
128 /* XXX XXX BEGIN XXX XXX */
130 extern paddr_t alpha_XXX_dmamap_or
; /* XXX */
131 alpha_XXX_dmamap_or
= 0; /* XXX */
133 /* XXX XXX END XXX XXX */
137 * Return the bus dma tag to be used for the specified bus type.
141 irongate_dma_get_tag(bus_dma_tag_t t
, alpha_bus_t bustype
)
143 struct irongate_config
*icp
= t
->_cookie
;
149 * Busses capable of 32-bit DMA get the PCI DMA tag.
151 return (&icp
->ic_dmat_pci
);
155 * Lame 24-bit busses have to bounce.
157 return (&icp
->ic_dmat_isa
);
160 panic("irongate_dma_get_tag: shouldn't be here, really...");