1*1e72df6aStsutsui /* $NetBSD: octeon_dma.c,v 1.3 2019/12/15 16:48:26 tsutsui Exp $ */
2f693c922Shikaru
3f693c922Shikaru /*-
4f693c922Shikaru * Copyright (c) 2001 The NetBSD Foundation, Inc.
5f693c922Shikaru * All rights reserved.
6f693c922Shikaru *
7f693c922Shikaru * This code is derived from software contributed to The NetBSD Foundation
8f693c922Shikaru * by Jason R. Thorpe.
9f693c922Shikaru *
10f693c922Shikaru * Redistribution and use in source and binary forms, with or without
11f693c922Shikaru * modification, are permitted provided that the following conditions
12f693c922Shikaru * are met:
13f693c922Shikaru * 1. Redistributions of source code must retain the above copyright
14f693c922Shikaru * notice, this list of conditions and the following disclaimer.
15f693c922Shikaru * 2. Redistributions in binary form must reproduce the above copyright
16f693c922Shikaru * notice, this list of conditions and the following disclaimer in the
17f693c922Shikaru * documentation and/or other materials provided with the distribution.
18f693c922Shikaru *
19f693c922Shikaru * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
20f693c922Shikaru * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21f693c922Shikaru * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22f693c922Shikaru * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
23f693c922Shikaru * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24f693c922Shikaru * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25f693c922Shikaru * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26f693c922Shikaru * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27f693c922Shikaru * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28f693c922Shikaru * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29f693c922Shikaru * POSSIBILITY OF SUCH DAMAGE.
30f693c922Shikaru */
31f693c922Shikaru
32f693c922Shikaru /*
33f693c922Shikaru * Platform-specific DMA support for the MIPS OCTEON. Copied from MALTA code.
34f693c922Shikaru */
35f693c922Shikaru
36f693c922Shikaru #include <sys/cdefs.h>
37*1e72df6aStsutsui __KERNEL_RCSID(0, "$NetBSD: octeon_dma.c,v 1.3 2019/12/15 16:48:26 tsutsui Exp $");
38f693c922Shikaru
39f693c922Shikaru #include <sys/param.h>
40f693c922Shikaru #include <sys/systm.h>
41f693c922Shikaru
42f693c922Shikaru #include <mips/cpuregs.h>
43f693c922Shikaru
44f693c922Shikaru #define _MIPS_BUS_DMA_PRIVATE
45f693c922Shikaru #include <sys/bus.h>
46f693c922Shikaru
47f693c922Shikaru #include <mips/cavium/octeonvar.h>
48f693c922Shikaru
49f693c922Shikaru void
octeon_dma_init(struct octeon_config * mcp)50f693c922Shikaru octeon_dma_init(struct octeon_config *mcp)
51f693c922Shikaru {
52f693c922Shikaru bus_dma_tag_t t;
53f693c922Shikaru
54f693c922Shikaru /* XXX need 32bit tag? */
55f693c922Shikaru t = &mcp->mc_iobus_dmat;
56f693c922Shikaru t->_cookie = mcp;
57f693c922Shikaru t->_wbase = 0;
58f693c922Shikaru t->_bounce_alloc_lo = 0;
59f693c922Shikaru t->_bounce_alloc_hi = 0;
60f693c922Shikaru t->_dmamap_ops = mips_bus_dmamap_ops;
61f693c922Shikaru t->_dmamem_ops = mips_bus_dmamem_ops;
62f693c922Shikaru t->_dmatag_ops = mips_bus_dmatag_ops;
63f693c922Shikaru
64f693c922Shikaru /* XXX struct copy */
65f693c922Shikaru mcp->mc_bootbus_dmat = mcp->mc_iobus_dmat;
66f693c922Shikaru mcp->mc_core1_dmat = mcp->mc_iobus_dmat;
67d7e78fcfSmatt mcp->mc_fpa_dmat = mcp->mc_iobus_dmat;
68d7e78fcfSmatt
69d7e78fcfSmatt #ifdef __mips_n32
70d7e78fcfSmatt mcp->mc_fpa_dmat._bounce_alloc_hi = round_page(MIPS_PHYS_MASK);
71d7e78fcfSmatt #endif
72f693c922Shikaru }
73