blob: 97fa0cf695ba2ba96becda5f0673b5ba5aa39a57 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001/* SPDX-License-Identifier: GPL-2.0+ */
Mugunthan V N8c3c9182016-02-15 15:31:37 +05302/*
3 * (C) Copyright 2015
4 * Texas Instruments Incorporated, <www.ti.com>
Mugunthan V N8c3c9182016-02-15 15:31:37 +05305 */
6
7#ifndef _DMA_H_
8#define _DMA_H_
9
10/*
11 * enum dma_direction - dma transfer direction indicator
12 * @DMA_MEM_TO_MEM: Memcpy mode
13 * @DMA_MEM_TO_DEV: From Memory to Device
14 * @DMA_DEV_TO_MEM: From Device to Memory
15 * @DMA_DEV_TO_DEV: From Device to Device
16 */
17enum dma_direction {
18 DMA_MEM_TO_MEM,
19 DMA_MEM_TO_DEV,
20 DMA_DEV_TO_MEM,
21 DMA_DEV_TO_DEV,
22};
23
24#define DMA_SUPPORTS_MEM_TO_MEM BIT(0)
25#define DMA_SUPPORTS_MEM_TO_DEV BIT(1)
26#define DMA_SUPPORTS_DEV_TO_MEM BIT(2)
27#define DMA_SUPPORTS_DEV_TO_DEV BIT(3)
28
29/*
Mugunthan V N8c3c9182016-02-15 15:31:37 +053030 * struct dma_dev_priv - information about a device used by the uclass
31 *
32 * @supported: mode of transfers that DMA can support, should be
33 * one/multiple of DMA_SUPPORTS_*
34 */
35struct dma_dev_priv {
36 u32 supported;
37};
38
39/*
40 * dma_get_device - get a DMA device which supports transfer
41 * type of transfer_type
42 *
43 * @transfer_type - transfer type should be one/multiple of
44 * DMA_SUPPORTS_*
45 * @devp - udevice pointer to return the found device
46 * @return - will return on success and devp will hold the
47 * pointer to the device
48 */
49int dma_get_device(u32 transfer_type, struct udevice **devp);
50
51/*
52 * dma_memcpy - try to use DMA to do a mem copy which will be
53 * much faster than CPU mem copy
54 *
55 * @dst - destination pointer
56 * @src - souce pointer
57 * @len - data length to be copied
58 * @return - on successful transfer returns no of bytes
59 transferred and on failure return error code.
60 */
61int dma_memcpy(void *dst, void *src, size_t len);
62
63#endif /* _DMA_H_ */