Blame view

include/dma-uclass.h 4.27 KB
10b4dc520   Álvaro Fernández Rojas   dma: move dma_ops...
1
2
3
  /* SPDX-License-Identifier: GPL-2.0+ */
  /*
   * Copyright (C) 2018 Álvaro Fernández Rojas <noltari@gmail.com>
27ab27f85   Álvaro Fernández Rojas   dma: add channels...
4
   * Copyright (C) 2015 - 2018 Texas Instruments Incorporated <www.ti.com>
10b4dc520   Álvaro Fernández Rojas   dma: move dma_ops...
5
6
7
8
9
10
11
12
13
14
   * Written by Mugunthan V N <mugunthanvnm@ti.com>
   *
   */
  
  #ifndef _DMA_UCLASS_H
  #define _DMA_UCLASS_H
  
  /* See dma.h for background documentation. */
  
  #include <dma.h>
27ab27f85   Álvaro Fernández Rojas   dma: add channels...
15
  struct ofnode_phandle_args;
10b4dc520   Álvaro Fernández Rojas   dma: move dma_ops...
16
17
18
19
20
21
22
  /*
   * struct dma_ops - Driver model DMA operations
   *
   * The uclass interface is implemented by all DMA devices which use
   * driver model.
   */
  struct dma_ops {
27ab27f85   Álvaro Fernández Rojas   dma: add channels...
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
  #ifdef CONFIG_DMA_CHANNELS
  	/**
  	 * of_xlate - Translate a client's device-tree (OF) DMA specifier.
  	 *
  	 * The DMA core calls this function as the first step in implementing
  	 * a client's dma_get_by_*() call.
  	 *
  	 * If this function pointer is set to NULL, the DMA core will use a
  	 * default implementation, which assumes #dma-cells = <1>, and that
  	 * the DT cell contains a simple integer DMA Channel.
  	 *
  	 * At present, the DMA API solely supports device-tree. If this
  	 * changes, other xxx_xlate() functions may be added to support those
  	 * other mechanisms.
  	 *
  	 * @dma: The dma struct to hold the translation result.
  	 * @args:	The dma specifier values from device tree.
  	 * @return 0 if OK, or a negative error code.
  	 */
  	int (*of_xlate)(struct dma *dma,
  			struct ofnode_phandle_args *args);
  	/**
  	 * request - Request a translated DMA.
  	 *
  	 * The DMA core calls this function as the second step in
  	 * implementing a client's dma_get_by_*() call, following a successful
  	 * xxx_xlate() call, or as the only step in implementing a client's
  	 * dma_request() call.
  	 *
  	 * @dma: The DMA struct to request; this has been filled in by
  	 *   a previoux xxx_xlate() function call, or by the caller of
  	 *   dma_request().
  	 * @return 0 if OK, or a negative error code.
  	 */
  	int (*request)(struct dma *dma);
  	/**
aae958822   Simon Glass   dma: Rename free(...
59
  	 * rfree - Free a previously requested dma.
27ab27f85   Álvaro Fernández Rojas   dma: add channels...
60
61
62
63
64
65
  	 *
  	 * This is the implementation of the client dma_free() API.
  	 *
  	 * @dma: The DMA to free.
  	 * @return 0 if OK, or a negative error code.
  	 */
aae958822   Simon Glass   dma: Rename free(...
66
  	int (*rfree)(struct dma *dma);
27ab27f85   Álvaro Fernández Rojas   dma: add channels...
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
  	/**
  	 * enable() - Enable a DMA Channel.
  	 *
  	 * @dma: The DMA Channel to manipulate.
  	 * @return zero on success, or -ve error code.
  	 */
  	int (*enable)(struct dma *dma);
  	/**
  	 * disable() - Disable a DMA Channel.
  	 *
  	 * @dma: The DMA Channel to manipulate.
  	 * @return zero on success, or -ve error code.
  	 */
  	int (*disable)(struct dma *dma);
  	/**
  	 * prepare_rcv_buf() - Prepare/Add receive DMA buffer.
  	 *
  	 * @dma: The DMA Channel to manipulate.
  	 * @dst: The receive buffer pointer.
  	 * @size: The receive buffer size
  	 * @return zero on success, or -ve error code.
  	 */
  	int (*prepare_rcv_buf)(struct dma *dma, void *dst, size_t size);
  	/**
  	 * receive() - Receive a DMA transfer.
  	 *
  	 * @dma: The DMA Channel to manipulate.
  	 * @dst: The destination pointer.
  	 * @metadata: DMA driver's specific data
  	 * @return zero on success, or -ve error code.
  	 */
  	int (*receive)(struct dma *dma, void **dst, void *metadata);
  	/**
  	 * send() - Send a DMA transfer.
  	 *
  	 * @dma: The DMA Channel to manipulate.
  	 * @src: The source pointer.
  	 * @len: Length of the data to be sent (number of bytes).
  	 * @metadata: DMA driver's specific data
  	 * @return zero on success, or -ve error code.
  	 */
  	int (*send)(struct dma *dma, void *src, size_t len, void *metadata);
b8a4dd28f   Vignesh Raghavendra   dma: Introduce dm...
109
110
111
112
113
114
115
116
117
118
119
  	/**
  	 * get_cfg() - Get DMA channel configuration for client's use
  	 *
  	 * @dma:    The DMA Channel to manipulate
  	 * @cfg_id: DMA provider specific ID to identify what
  	 *          configuration data client needs
  	 * @data:   Pointer to store pointer to DMA driver specific
  	 *          configuration data for the given cfg_id (output param)
  	 * @return zero on success, or -ve error code.
  	 */
  	int (*get_cfg)(struct dma *dma, u32 cfg_id, void **data);
27ab27f85   Álvaro Fernández Rojas   dma: add channels...
120
  #endif /* CONFIG_DMA_CHANNELS */
10b4dc520   Álvaro Fernández Rojas   dma: move dma_ops...
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
  	/**
  	 * transfer() - Issue a DMA transfer. The implementation must
  	 *   wait until the transfer is done.
  	 *
  	 * @dev: The DMA device
  	 * @direction: direction of data transfer (should be one from
  	 *   enum dma_direction)
  	 * @dst: The destination pointer.
  	 * @src: The source pointer.
  	 * @len: Length of the data to be copied (number of bytes).
  	 * @return zero on success, or -ve error code.
  	 */
  	int (*transfer)(struct udevice *dev, int direction, void *dst,
  			void *src, size_t len);
  };
  
  #endif /* _DMA_UCLASS_H */