1 /* 2 * Copyright (C) 2016 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #ifndef _DMA_H 18 #define _DMA_H 19 20 #include <stdint.h> 21 22 typedef void (*DmaCallbackF)(void *cookie, uint16_t bytesLeft, int err); 23 24 struct dmaMode { 25 enum { 26 DMA_SIZE_8_BITS = 0, 27 DMA_SIZE_16_BITS = 1, 28 DMA_SIZE_32_BITS = 2, 29 } psize, msize; 30 31 enum { 32 DMA_BURST_SINGLE = 0, 33 DMA_BURST_INCR4 = 1, 34 DMA_BURST_INCR8 = 2, 35 DMA_BURST_INCR16 = 3, 36 } pburst, mburst; 37 38 enum { 39 DMA_PRIORITY_LOW = 0, 40 DMA_PRIORITY_MEDIUM = 1, 41 DMA_PRIORITY_HIGH = 2, 42 DMA_PRIORITY_VERY_HIGH = 3, 43 } priority; 44 45 enum { 46 DMA_DIRECTION_PERIPH_TO_MEM = 0, 47 DMA_DIRECTION_MEM_TO_PERIPH = 1, 48 } direction; 49 50 bool minc; 51 52 uint32_t periphAddr; 53 uint8_t channel; 54 }; 55 56 int dmaStart(uint8_t busId, uint8_t stream, const void *buf, uint16_t size, 57 const struct dmaMode *mode, DmaCallbackF callback, void *cookie); 58 uint16_t dmaBytesLeft(uint8_t busId, uint8_t stream); 59 void dmaStop(uint8_t busId, uint8_t stream); 60 const enum IRQn dmaIrq(uint8_t busId, uint8_t stream); 61 int dmaStopAll(uint32_t tid); 62 63 #endif /* _DMA_H */ 64