irongate_dma.c revision 1.1 1 1.1 thorpej /* $NetBSD: irongate_dma.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $ */
2 1.1 thorpej
3 1.1 thorpej /*-
4 1.1 thorpej * Copyright (c) 2000 The NetBSD Foundation, Inc.
5 1.1 thorpej * All rights reserved.
6 1.1 thorpej *
7 1.1 thorpej * This code is derived from software contributed to The NetBSD Foundation
8 1.1 thorpej * by Jason R. Thorpe.
9 1.1 thorpej *
10 1.1 thorpej * Redistribution and use in source and binary forms, with or without
11 1.1 thorpej * modification, are permitted provided that the following conditions
12 1.1 thorpej * are met:
13 1.1 thorpej * 1. Redistributions of source code must retain the above copyright
14 1.1 thorpej * notice, this list of conditions and the following disclaimer.
15 1.1 thorpej * 2. Redistributions in binary form must reproduce the above copyright
16 1.1 thorpej * notice, this list of conditions and the following disclaimer in the
17 1.1 thorpej * documentation and/or other materials provided with the distribution.
18 1.1 thorpej * 3. All advertising materials mentioning features or use of this software
19 1.1 thorpej * must display the following acknowledgement:
20 1.1 thorpej * This product includes software developed by the NetBSD
21 1.1 thorpej * Foundation, Inc. and its contributors.
22 1.1 thorpej * 4. Neither the name of The NetBSD Foundation nor the names of its
23 1.1 thorpej * contributors may be used to endorse or promote products derived
24 1.1 thorpej * from this software without specific prior written permission.
25 1.1 thorpej *
26 1.1 thorpej * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 1.1 thorpej * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 1.1 thorpej * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 1.1 thorpej * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 1.1 thorpej * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 1.1 thorpej * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 1.1 thorpej * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 1.1 thorpej * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 1.1 thorpej * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 1.1 thorpej * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 1.1 thorpej * POSSIBILITY OF SUCH DAMAGE.
37 1.1 thorpej */
38 1.1 thorpej
39 1.1 thorpej /*
40 1.1 thorpej * DMA support for the AMD 751 (``Irongate'') core logic chipset.
41 1.1 thorpej *
42 1.1 thorpej * The AMD 751 is really unlike all of the other Alpha PCI core logic
43 1.1 thorpej * chipsets. Instead, it looks like a normal PC chipset (not surprising,
44 1.1 thorpej * since it is used for Athlon processors).
45 1.1 thorpej *
46 1.1 thorpej * Because of this, it lacks all of the SGMAP hardware normally present
47 1.1 thorpej * on an Alpha system, and there are no DMA windows. Instead, a memory
48 1.1 thorpej * bus address is a PCI DMA address, and ISA DMA above 16M has to be
49 1.1 thorpej * bounced (this is not unlike the Jensen, actually).
50 1.1 thorpej */
51 1.1 thorpej
52 1.1 thorpej #include <sys/cdefs.h> /* RCS ID & Copyright macro defns */
53 1.1 thorpej
54 1.1 thorpej __KERNEL_RCSID(0, "$NetBSD: irongate_dma.c,v 1.1 2000/06/01 20:30:30 thorpej Exp $");
55 1.1 thorpej
56 1.1 thorpej #include <sys/param.h>
57 1.1 thorpej #include <sys/systm.h>
58 1.1 thorpej #include <sys/kernel.h>
59 1.1 thorpej #include <sys/device.h>
60 1.1 thorpej #include <sys/malloc.h>
61 1.1 thorpej #include <vm/vm.h>
62 1.1 thorpej
63 1.1 thorpej #define _ALPHA_BUS_DMA_PRIVATE
64 1.1 thorpej #include <machine/bus.h>
65 1.1 thorpej
66 1.1 thorpej #include <dev/pci/pcireg.h>
67 1.1 thorpej #include <dev/pci/pcivar.h>
68 1.1 thorpej
69 1.1 thorpej #include <alpha/pci/irongatereg.h>
70 1.1 thorpej #include <alpha/pci/irongatevar.h>
71 1.1 thorpej
72 1.1 thorpej #include <dev/isa/isareg.h>
73 1.1 thorpej #include <dev/isa/isavar.h>
74 1.1 thorpej
75 1.1 thorpej bus_dma_tag_t irongate_dma_get_tag(bus_dma_tag_t, alpha_bus_t);
76 1.1 thorpej
77 1.1 thorpej int irongate_bus_dmamap_create_pci_direct(bus_dma_tag_t, bus_size_t, int,
78 1.1 thorpej bus_size_t, bus_size_t, int, bus_dmamap_t *);
79 1.1 thorpej
80 1.1 thorpej int irongate_bus_dmamap_create_isa_direct(bus_dma_tag_t, bus_size_t, int,
81 1.1 thorpej bus_size_t, bus_size_t, int, bus_dmamap_t *);
82 1.1 thorpej
83 1.1 thorpej int irongate_bus_dmamap_create_isa_bounce(bus_dma_tag_t, bus_size_t, int,
84 1.1 thorpej bus_size_t, bus_size_t, int, bus_dmamap_t *);
85 1.1 thorpej
86 1.1 thorpej void
87 1.1 thorpej irongate_dma_init(struct irongate_config *icp)
88 1.1 thorpej {
89 1.1 thorpej bus_dma_tag_t t;
90 1.1 thorpej
91 1.1 thorpej /*
92 1.1 thorpej * Initialize the DMA tag used for PCI DMA.
93 1.1 thorpej */
94 1.1 thorpej t = &icp->ic_dmat_pci;
95 1.1 thorpej t->_cookie = icp;
96 1.1 thorpej t->_wbase = 0;
97 1.1 thorpej t->_wsize = 0x100000000UL;
98 1.1 thorpej t->_next_window = NULL;
99 1.1 thorpej t->_boundary = 0;
100 1.1 thorpej t->_sgmap = NULL;
101 1.1 thorpej t->_get_tag = irongate_dma_get_tag;
102 1.1 thorpej t->_dmamap_create = _bus_dmamap_create;
103 1.1 thorpej t->_dmamap_destroy = _bus_dmamap_destroy;
104 1.1 thorpej t->_dmamap_load = _bus_dmamap_load_direct;
105 1.1 thorpej t->_dmamap_load_mbuf = _bus_dmamap_load_mbuf_direct;
106 1.1 thorpej t->_dmamap_load_uio = _bus_dmamap_load_uio_direct;
107 1.1 thorpej t->_dmamap_load_raw = _bus_dmamap_load_raw_direct;
108 1.1 thorpej t->_dmamap_unload = _bus_dmamap_unload;
109 1.1 thorpej t->_dmamap_sync = _bus_dmamap_sync;
110 1.1 thorpej
111 1.1 thorpej t->_dmamem_alloc = _bus_dmamem_alloc;
112 1.1 thorpej t->_dmamem_free = _bus_dmamem_free;
113 1.1 thorpej t->_dmamem_map = _bus_dmamem_map;
114 1.1 thorpej t->_dmamem_unmap = _bus_dmamem_unmap;
115 1.1 thorpej t->_dmamem_mmap = _bus_dmamem_mmap;
116 1.1 thorpej
117 1.1 thorpej /*
118 1.1 thorpej * Initialize the DMA tag used for ISA DMA.
119 1.1 thorpej */
120 1.1 thorpej t = &icp->ic_dmat_isa;
121 1.1 thorpej t->_cookie = icp;
122 1.1 thorpej t->_wbase = 0;
123 1.1 thorpej t->_wsize = 0x1000000;
124 1.1 thorpej t->_next_window = NULL;
125 1.1 thorpej t->_boundary = 0;
126 1.1 thorpej t->_sgmap = NULL;
127 1.1 thorpej t->_get_tag = irongate_dma_get_tag;
128 1.1 thorpej t->_dmamap_create = isadma_bounce_dmamap_create;
129 1.1 thorpej t->_dmamap_destroy = isadma_bounce_dmamap_destroy;
130 1.1 thorpej t->_dmamap_load = isadma_bounce_dmamap_load;
131 1.1 thorpej t->_dmamap_load_mbuf = isadma_bounce_dmamap_load_mbuf;
132 1.1 thorpej t->_dmamap_load_uio = isadma_bounce_dmamap_load_uio;
133 1.1 thorpej t->_dmamap_load_raw = isadma_bounce_dmamap_load_raw;
134 1.1 thorpej t->_dmamap_unload = isadma_bounce_dmamap_unload;
135 1.1 thorpej t->_dmamap_sync = isadma_bounce_dmamap_sync;
136 1.1 thorpej
137 1.1 thorpej t->_dmamem_alloc = isadma_bounce_dmamem_alloc;
138 1.1 thorpej t->_dmamem_free = _bus_dmamem_free;
139 1.1 thorpej t->_dmamem_map = _bus_dmamem_map;
140 1.1 thorpej t->_dmamem_unmap = _bus_dmamem_unmap;
141 1.1 thorpej t->_dmamem_mmap = _bus_dmamem_mmap;
142 1.1 thorpej
143 1.1 thorpej /* XXX XXX BEGIN XXX XXX */
144 1.1 thorpej { /* XXX */
145 1.1 thorpej extern paddr_t alpha_XXX_dmamap_or; /* XXX */
146 1.1 thorpej alpha_XXX_dmamap_or = 0; /* XXX */
147 1.1 thorpej } /* XXX */
148 1.1 thorpej /* XXX XXX END XXX XXX */
149 1.1 thorpej }
150 1.1 thorpej
151 1.1 thorpej /*
152 1.1 thorpej * Return the bus dma tag to be used for the specified bus type.
153 1.1 thorpej * INTERNAL USE ONLY!
154 1.1 thorpej */
155 1.1 thorpej bus_dma_tag_t
156 1.1 thorpej irongate_dma_get_tag(bus_dma_tag_t t, alpha_bus_t bustype)
157 1.1 thorpej {
158 1.1 thorpej struct irongate_config *icp = t->_cookie;
159 1.1 thorpej
160 1.1 thorpej switch (bustype) {
161 1.1 thorpej case ALPHA_BUS_PCI:
162 1.1 thorpej case ALPHA_BUS_EISA:
163 1.1 thorpej /*
164 1.1 thorpej * Busses capable of 32-bit DMA get the PCI DMA tag.
165 1.1 thorpej */
166 1.1 thorpej return (&icp->ic_dmat_pci);
167 1.1 thorpej
168 1.1 thorpej case ALPHA_BUS_ISA:
169 1.1 thorpej /*
170 1.1 thorpej * Lame 24-bit busses have to bounce.
171 1.1 thorpej */
172 1.1 thorpej return (&icp->ic_dmat_isa);
173 1.1 thorpej
174 1.1 thorpej default:
175 1.1 thorpej panic("irongate_dma_get_tag: shouldn't be here, really...");
176 1.1 thorpej }
177 1.1 thorpej }
178