1 /*- 2 * SPDX-License-Identifier: BSD-2-Clause 3 * 4 * Copyright (c) 2011 5 * Ben Gray <ben.r.gray@gmail.com>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: 11 * 1. Redistributions of source code must retain the above copyright 12 * notice, this list of conditions and the following disclaimer. 13 * 2. Redistributions in binary form must reproduce the above copyright 14 * notice, this list of conditions and the following disclaimer in the 15 * documentation and/or other materials provided with the distribution. 16 * 17 * THIS SOFTWARE IS PROVIDED BY AUTHOR AND CONTRIBUTORS ``AS IS'' AND 18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 * ARE DISCLAIMED. IN NO EVENT SHALL AUTHOR OR CONTRIBUTORS BE LIABLE 21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 * SUCH DAMAGE. 28 * 29 * $FreeBSD$ 30 */ 31 32 /** 33 * sDMA device driver interface for the TI SoC 34 * 35 * See the ti_sdma.c file for implementation details. 36 * 37 * Reference: 38 * OMAP35x Applications Processor 39 * Technical Reference Manual 40 * (omap35xx_techref.pdf) 41 */ 42 #ifndef _TI_DMA_H_ 43 #define _TI_DMA_H_ 44 45 #define TI_SDMA_ENDIAN_BIG 0x1 46 #define TI_SDMA_ENDIAN_LITTLE 0x0 47 48 #define TI_SDMA_BURST_NONE 0x0 49 #define TI_SDMA_BURST_16 0x1 50 #define TI_SDMA_BURST_32 0x2 51 #define TI_SDMA_BURST_64 0x3 52 53 #define TI_SDMA_DATA_8BITS_SCALAR 0x0 54 #define TI_SDMA_DATA_16BITS_SCALAR 0x1 55 #define TI_SDMA_DATA_32BITS_SCALAR 0x2 56 57 #define TI_SDMA_ADDR_CONSTANT 0x0 58 #define TI_SDMA_ADDR_POST_INCREMENT 0x1 59 #define TI_SDMA_ADDR_SINGLE_INDEX 0x2 60 #define TI_SDMA_ADDR_DOUBLE_INDEX 0x3 61 62 /** 63 * Status flags for the DMA callback 64 * 65 */ 66 #define TI_SDMA_STATUS_DROP (1UL << 1) 67 #define TI_SDMA_STATUS_HALF (1UL << 2) 68 #define TI_SDMA_STATUS_FRAME (1UL << 3) 69 #define TI_SDMA_STATUS_LAST (1UL << 4) 70 #define TI_SDMA_STATUS_BLOCK (1UL << 5) 71 #define TI_SDMA_STATUS_SYNC (1UL << 6) 72 #define TI_SDMA_STATUS_PKT (1UL << 7) 73 #define TI_SDMA_STATUS_TRANS_ERR (1UL << 8) 74 #define TI_SDMA_STATUS_SECURE_ERR (1UL << 9) 75 #define TI_SDMA_STATUS_SUPERVISOR_ERR (1UL << 10) 76 #define TI_SDMA_STATUS_MISALIGNED_ADRS_ERR (1UL << 11) 77 #define TI_SDMA_STATUS_DRAIN_END (1UL << 12) 78 79 #define TI_SDMA_SYNC_FRAME (1UL << 0) 80 #define TI_SDMA_SYNC_BLOCK (1UL << 1) 81 #define TI_SDMA_SYNC_PACKET (TI_SDMA_SYNC_FRAME | TI_SDMA_SYNC_BLOCK) 82 #define TI_SDMA_SYNC_TRIG_ON_SRC (1UL << 8) 83 #define TI_SDMA_SYNC_TRIG_ON_DST (1UL << 9) 84 85 #define TI_SDMA_IRQ_FLAG_DROP (1UL << 1) 86 #define TI_SDMA_IRQ_FLAG_HALF_FRAME_COMPL (1UL << 2) 87 #define TI_SDMA_IRQ_FLAG_FRAME_COMPL (1UL << 3) 88 #define TI_SDMA_IRQ_FLAG_START_LAST_FRAME (1UL << 4) 89 #define TI_SDMA_IRQ_FLAG_BLOCK_COMPL (1UL << 5) 90 #define TI_SDMA_IRQ_FLAG_ENDOF_PKT (1UL << 7) 91 #define TI_SDMA_IRQ_FLAG_DRAIN (1UL << 12) 92 93 int ti_sdma_activate_channel(unsigned int *ch, 94 void (*callback)(unsigned int ch, uint32_t status, void *data), void *data); 95 int ti_sdma_deactivate_channel(unsigned int ch); 96 int ti_sdma_start_xfer(unsigned int ch, unsigned int src_paddr, 97 unsigned long dst_paddr, unsigned int frmcnt, unsigned int elmcnt); 98 int ti_sdma_start_xfer_packet(unsigned int ch, unsigned int src_paddr, 99 unsigned long dst_paddr, unsigned int frmcnt, unsigned int elmcnt, 100 unsigned int pktsize); 101 int ti_sdma_stop_xfer(unsigned int ch); 102 int ti_sdma_enable_channel_irq(unsigned int ch, uint32_t flags); 103 int ti_sdma_disable_channel_irq(unsigned int ch); 104 int ti_sdma_get_channel_status(unsigned int ch, uint32_t *status); 105 int ti_sdma_set_xfer_endianess(unsigned int ch, unsigned int src, unsigned int dst); 106 int ti_sdma_set_xfer_burst(unsigned int ch, unsigned int src, unsigned int dst); 107 int ti_sdma_set_xfer_data_type(unsigned int ch, unsigned int type); 108 int ti_sdma_set_callback(unsigned int ch, 109 void (*callback)(unsigned int ch, uint32_t status, void *data), void *data); 110 int ti_sdma_sync_params(unsigned int ch, unsigned int trigger, unsigned int mode); 111 int ti_sdma_set_addr_mode(unsigned int ch, unsigned int src_mode, unsigned int dst_mode); 112 113 #endif /* _TI_SDMA_H_ */ 114