ixp12x0_pci_dma.c revision 1.10 1 1.10 skrll /* $NetBSD: ixp12x0_pci_dma.c,v 1.10 2022/09/27 06:36:42 skrll Exp $ */
2 1.1 ichiro /*
3 1.5 ichiro * Copyright (c) 2002, 2003
4 1.1 ichiro * Ichiro FUKUHARA <ichiro (at) ichiro.org>.
5 1.1 ichiro * All rights reserved.
6 1.1 ichiro *
7 1.1 ichiro * Redistribution and use in source and binary forms, with or without
8 1.1 ichiro * modification, are permitted provided that the following conditions
9 1.1 ichiro * are met:
10 1.1 ichiro * 1. Redistributions of source code must retain the above copyright
11 1.1 ichiro * notice, this list of conditions and the following disclaimer.
12 1.1 ichiro * 2. Redistributions in binary form must reproduce the above copyright
13 1.1 ichiro * notice, this list of conditions and the following disclaimer in the
14 1.1 ichiro * documentation and/or other materials provided with the distribution.
15 1.1 ichiro *
16 1.1 ichiro * THIS SOFTWARE IS PROVIDED BY ICHIRO FUKUHARA ``AS IS'' AND ANY EXPRESS OR
17 1.1 ichiro * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
18 1.1 ichiro * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19 1.1 ichiro * IN NO EVENT SHALL ICHIRO FUKUHARA OR THE VOICES IN HIS HEAD BE LIABLE FOR
20 1.1 ichiro * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 1.1 ichiro * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 1.1 ichiro * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 1.1 ichiro * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 1.1 ichiro * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 1.1 ichiro * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 1.1 ichiro * SUCH DAMAGE.
27 1.1 ichiro */
28 1.6 igy
29 1.6 igy #include <sys/cdefs.h>
30 1.10 skrll __KERNEL_RCSID(0, "$NetBSD: ixp12x0_pci_dma.c,v 1.10 2022/09/27 06:36:42 skrll Exp $");
31 1.1 ichiro
32 1.1 ichiro #include <sys/param.h>
33 1.1 ichiro #include <sys/systm.h>
34 1.1 ichiro #include <sys/device.h>
35 1.1 ichiro #include <sys/mbuf.h>
36 1.1 ichiro
37 1.1 ichiro #include <uvm/uvm_extern.h>
38 1.1 ichiro
39 1.1 ichiro #define _ARM32_BUS_DMA_PRIVATE
40 1.8 dyoung #include <sys/bus.h>
41 1.4 thorpej
42 1.5 ichiro #include <arm/ixp12x0/ixp12x0_pcireg.h>
43 1.4 thorpej #include <arm/ixp12x0/ixp12x0var.h>
44 1.1 ichiro
45 1.1 ichiro void
46 1.5 ichiro ixp12x0_pci_dma_init(struct ixp12x0_softc *sc)
47 1.1 ichiro {
48 1.5 ichiro extern paddr_t physical_start, physical_end;
49 1.5 ichiro
50 1.5 ichiro bus_dma_tag_t dmat = &sc->ia_pci_dmat;
51 1.5 ichiro struct arm32_dma_range *dr = &sc->ia_pci_dma_range;
52 1.5 ichiro
53 1.5 ichiro dmat->_ranges = dr;
54 1.5 ichiro dmat->_nranges = 1;
55 1.5 ichiro
56 1.5 ichiro dr->dr_sysbase = physical_start;
57 1.5 ichiro dr->dr_busbase = PCI_MAPREG_MEM_ADDR(IXP1200_PCI_MEM_BAR +
58 1.5 ichiro physical_start);
59 1.5 ichiro dr->dr_len = physical_end - physical_start;
60 1.1 ichiro
61 1.1 ichiro dmat->_dmamap_create = _bus_dmamap_create;
62 1.1 ichiro dmat->_dmamap_destroy = _bus_dmamap_destroy;
63 1.2 thorpej dmat->_dmamap_load = _bus_dmamap_load;
64 1.2 thorpej dmat->_dmamap_load_mbuf = _bus_dmamap_load_mbuf;
65 1.2 thorpej dmat->_dmamap_load_uio = _bus_dmamap_load_uio;
66 1.2 thorpej dmat->_dmamap_load_raw = _bus_dmamap_load_raw;
67 1.1 ichiro dmat->_dmamap_unload = _bus_dmamap_unload;
68 1.3 thorpej dmat->_dmamap_sync_pre = _bus_dmamap_sync;
69 1.3 thorpej dmat->_dmamap_sync_post = NULL;
70 1.5 ichiro
71 1.2 thorpej dmat->_dmamem_alloc = _bus_dmamem_alloc;
72 1.1 ichiro dmat->_dmamem_free = _bus_dmamem_free;
73 1.1 ichiro dmat->_dmamem_map = _bus_dmamem_map;
74 1.1 ichiro dmat->_dmamem_unmap = _bus_dmamem_unmap;
75 1.1 ichiro dmat->_dmamem_mmap = _bus_dmamem_mmap;
76 1.9 matt
77 1.9 matt dmat->_dmatag_subregion = _bus_dmatag_subregion;
78 1.9 matt dmat->_dmatag_destroy = _bus_dmatag_destroy;
79 1.1 ichiro }
80