1af3dc4a7SPedro F. Giffuni /*- 2*4d846d26SWarner Losh * SPDX-License-Identifier: BSD-2-Clause 3af3dc4a7SPedro F. Giffuni * 4cdafe74eSOleksandr Tymoshenko * Copyright (c) 2013 Daisuke Aoyama <aoyama@peach.ne.jp> 5cdafe74eSOleksandr Tymoshenko * Copyright (c) 2013 Oleksandr Tymoshenko <gonzo@bluezbox.com> 6cdafe74eSOleksandr Tymoshenko * 7cdafe74eSOleksandr Tymoshenko * Redistribution and use in source and binary forms, with or without 8cdafe74eSOleksandr Tymoshenko * modification, are permitted provided that the following conditions 9cdafe74eSOleksandr Tymoshenko * are met: 10cdafe74eSOleksandr Tymoshenko * 1. Redistributions of source code must retain the above copyright 11cdafe74eSOleksandr Tymoshenko * notice, this list of conditions and the following disclaimer. 12cdafe74eSOleksandr Tymoshenko * 2. Redistributions in binary form must reproduce the above copyright 13cdafe74eSOleksandr Tymoshenko * notice, this list of conditions and the following disclaimer in the 14cdafe74eSOleksandr Tymoshenko * documentation and/or other materials provided with the distribution. 15cdafe74eSOleksandr Tymoshenko * 16cdafe74eSOleksandr Tymoshenko * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 17cdafe74eSOleksandr Tymoshenko * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18cdafe74eSOleksandr Tymoshenko * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 19cdafe74eSOleksandr Tymoshenko * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 20cdafe74eSOleksandr Tymoshenko * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21cdafe74eSOleksandr Tymoshenko * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 22cdafe74eSOleksandr Tymoshenko * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 23cdafe74eSOleksandr Tymoshenko * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 24cdafe74eSOleksandr Tymoshenko * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 25cdafe74eSOleksandr Tymoshenko * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 26cdafe74eSOleksandr Tymoshenko * SUCH DAMAGE. 27cdafe74eSOleksandr Tymoshenko */ 28cdafe74eSOleksandr Tymoshenko 29cdafe74eSOleksandr Tymoshenko #ifndef _BCM2835_DMA_H_ 30cdafe74eSOleksandr Tymoshenko #define _BCM2835_DMA_H_ 31cdafe74eSOleksandr Tymoshenko 32cdafe74eSOleksandr Tymoshenko #define BCM_DMA_BLOCK_SIZE 512 33cdafe74eSOleksandr Tymoshenko 34cdafe74eSOleksandr Tymoshenko /* DMA0-DMA15 but DMA15 is special */ 35cdafe74eSOleksandr Tymoshenko #define BCM_DMA_CH_MAX 12 36cdafe74eSOleksandr Tymoshenko 37cdafe74eSOleksandr Tymoshenko /* request CH for any nubmer */ 38cdafe74eSOleksandr Tymoshenko #define BCM_DMA_CH_INVALID (-1) 39cdafe74eSOleksandr Tymoshenko #define BCM_DMA_CH_ANY (-1) 40cdafe74eSOleksandr Tymoshenko 41cdafe74eSOleksandr Tymoshenko /* Peripheral DREQ Signals (4.2.1.3) */ 42cdafe74eSOleksandr Tymoshenko #define BCM_DMA_DREQ_NONE 0 43d7399dfdSKyle Evans /* 44d7399dfdSKyle Evans * XXX This doesn't seem to work for the Raspberry Pi 4, but the peripheral 45d7399dfdSKyle Evans * documentation still lists it at 11. 46d7399dfdSKyle Evans */ 47cdafe74eSOleksandr Tymoshenko #define BCM_DMA_DREQ_EMMC 11 48cdafe74eSOleksandr Tymoshenko #define BCM_DMA_DREQ_SDHOST 13 49cdafe74eSOleksandr Tymoshenko 50cdafe74eSOleksandr Tymoshenko #define BCM_DMA_SAME_ADDR 0 51cdafe74eSOleksandr Tymoshenko #define BCM_DMA_INC_ADDR 1 52cdafe74eSOleksandr Tymoshenko 53cdafe74eSOleksandr Tymoshenko #define BCM_DMA_32BIT 0 54cdafe74eSOleksandr Tymoshenko #define BCM_DMA_128BIT 1 55cdafe74eSOleksandr Tymoshenko 56cdafe74eSOleksandr Tymoshenko int bcm_dma_allocate(int req_ch); 57cdafe74eSOleksandr Tymoshenko int bcm_dma_free(int ch); 58cdafe74eSOleksandr Tymoshenko int bcm_dma_setup_intr(int ch, void (*func)(int, void *), void *arg); 59cdafe74eSOleksandr Tymoshenko int bcm_dma_setup_src(int ch, int dreq, int inc_addr, int width); 60cdafe74eSOleksandr Tymoshenko int bcm_dma_setup_dst(int ch, int dreq, int inc_addr, int width); 61cdafe74eSOleksandr Tymoshenko int bcm_dma_start(int ch, vm_paddr_t src, vm_paddr_t dst, int len); 62cdafe74eSOleksandr Tymoshenko uint32_t bcm_dma_length(int ch); 63cdafe74eSOleksandr Tymoshenko 64cdafe74eSOleksandr Tymoshenko #endif /* _BCM2835_DMA_H_ */ 65