OpenCores
URL https://opencores.org/ocsvn/ao486/ao486/trunk

Subversion Repositories ao486

[/] [ao486/] [trunk/] [syn/] [components/] [sd_card/] [firmware/] [bsp/] [HAL/] [inc/] [sys/] [alt_dma_dev.h] - Blame information for rev 8

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 8 alfik
#ifndef __ALT_DMA_DEV_H__
2
#define __ALT_DMA_DEV_H__
3
 
4
/******************************************************************************
5
*                                                                             *
6
* License Agreement                                                           *
7
*                                                                             *
8
* Copyright (c) 2004-2005 Altera Corporation, San Jose, California, USA.      *
9
* All rights reserved.                                                        *
10
*                                                                             *
11
* Permission is hereby granted, free of charge, to any person obtaining a     *
12
* copy of this software and associated documentation files (the "Software"),  *
13
* to deal in the Software without restriction, including without limitation   *
14
* the rights to use, copy, modify, merge, publish, distribute, sublicense,    *
15
* and/or sell copies of the Software, and to permit persons to whom the       *
16
* Software is furnished to do so, subject to the following conditions:        *
17
*                                                                             *
18
* The above copyright notice and this permission notice shall be included in  *
19
* all copies or substantial portions of the Software.                         *
20
*                                                                             *
21
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR  *
22
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,    *
23
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE *
24
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER      *
25
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING     *
26
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER         *
27
* DEALINGS IN THE SOFTWARE.                                                   *
28
*                                                                             *
29
* This agreement shall be governed in all respects by the laws of the State   *
30
* of California and by the laws of the United States of America.              *
31
*                                                                             *
32
* Altera does not recommend, suggest or require that this reference design    *
33
* file be used in conjunction or combination with any other product.          *
34
******************************************************************************/
35
 
36
/******************************************************************************
37
*                                                                             *
38
* THIS IS A LIBRARY READ-ONLY SOURCE FILE. DO NOT EDIT.                       *
39
*                                                                             *
40
******************************************************************************/
41
 
42
#include "priv/alt_dev_llist.h"
43
 
44
#include "alt_types.h"
45
 
46
#ifdef __cplusplus
47
extern "C"
48
{
49
#endif /* __cplusplus */
50
 
51
/*
52
 * This header contains the device driver interface for accessing DMA
53
 * resources. See alt_dma.h for the DMA application side interface.
54
 *
55
 * The interface model treats a DMA transaction as being composed of two
56
 * halves (read and write).
57
 *
58
 * An "alt_dma_txchan_dev" is used to describe the device associated with a
59
 * DMA transmit channel. An "alt_dma_rxchan_dev" is used to describe the
60
 * device associated with a DMA receive channel.
61
 */
62
 
63
/*
64
 * List of generic ioctl requests that may be supported by a DMA device.
65
 *
66
 * ALT_DMA_RX_ONLY_ON:    This causes a DMA channel to operate in a mode
67
 *                        where only the receiver is under software control.
68
 *                        The other side reads continously from a single
69
 *                        location. The address to read is the argument to
70
 *                        this request.
71
 * ALT_DMA_RX_ONLY_OFF:   Return to the default mode where both the receive
72
 *                        and transmit sides of the DMA can be under software
73
 *                        control.
74
 * ALT_DMA_TX_ONLY_ON:    This causes a DMA channel to operate in a mode
75
 *                        where only the transmitter is under software control.
76
 *                        The other side writes continously to a single
77
 *                        location. The address to write to is the argument to
78
 *                        this request.
79
 * ALT_DMA_TX_ONLY_OFF:   Return to the default mode where both the receive
80
 *                        and transmit sides of the DMA can be under software
81
 *                        control.
82
 * ALT_DMA_SET_MODE_8:    Transfer data in units of 8 bits.
83
 * ALT_DMA_SET_MODE_16:   Transfer data in units of 16 bits.
84
 * ALT_DMA_SET_MODE_32:   Transfer data in units of 32 bits.
85
 * ALT_DMA_SET_MODE_64:   Transfer data in units of 64 bits.
86
 * ALT_DMA_SET_MODE_128:  Transfer data in units of 128 bits.
87
 * ALT_DMA_GET_MODE:      Get the current transfer mode.
88
 *
89
 * The use of the macros: ALT_DMA_TX_STREAM_ON, ALT_DMA_TX_STREAM_OFF
90
 * ALT_DMA_RX_STREAM_OFF and ALT_DMA_RX_STREAM_ON are depreciated. You should
91
 * instead use the macros: ALT_DMA_RX_ONLY_ON, ALT_DMA_RX_ONLY_OFF,
92
 * ALT_DMA_TX_ONLY_ON and ALT_DMA_TX_ONLY_OFF.
93
 */
94
 
95
#define ALT_DMA_TX_STREAM_ON  (0x1)
96
#define ALT_DMA_TX_STREAM_OFF (0x2)
97
#define ALT_DMA_RX_STREAM_ON  (0x3)
98
#define ALT_DMA_RX_STREAM_OFF (0x4)
99
#define ALT_DMA_SET_MODE_8    (0x5)
100
#define ALT_DMA_SET_MODE_16   (0x6)
101
#define ALT_DMA_SET_MODE_32   (0x7)
102
#define ALT_DMA_SET_MODE_64   (0x8)
103
#define ALT_DMA_SET_MODE_128  (0x9)
104
#define ALT_DMA_GET_MODE      (0xa)
105
 
106
#define ALT_DMA_RX_ONLY_ON    ALT_DMA_TX_STREAM_ON
107
#define ALT_DMA_RX_ONLY_OFF   ALT_DMA_TX_STREAM_OFF
108
#define ALT_DMA_TX_ONLY_ON    ALT_DMA_RX_STREAM_ON
109
#define ALT_DMA_TX_ONLY_OFF   ALT_DMA_RX_STREAM_OFF
110
 
111
/*
112
 *
113
 */
114
 
115
typedef struct alt_dma_txchan_dev_s alt_dma_txchan_dev;
116
typedef struct alt_dma_rxchan_dev_s alt_dma_rxchan_dev;
117
 
118
typedef alt_dma_txchan_dev* alt_dma_txchan;
119
typedef alt_dma_rxchan_dev* alt_dma_rxchan;
120
 
121
typedef void (alt_txchan_done)(void* handle);
122
typedef void (alt_rxchan_done)(void* handle, void* data);
123
 
124
/*
125
 * devices that provide a DMA transmit channel are required to provide an
126
 * instance of the "alt_dma_txchan_dev" structure.
127
 */
128
 
129
struct alt_dma_txchan_dev_s {
130
  alt_llist  llist;                  /* for internal use */
131
  const char* name;                  /* name of the device instance
132
                                      * (e.g. "/dev/dma_0").
133
                                      */
134
  int (*space) (alt_dma_txchan dma); /* returns the maximum number of
135
                                      * transmit requests that can be posted
136
              */
137
  int (*dma_send) (alt_dma_txchan dma,
138
         const void* from,
139
         alt_u32 len,
140
         alt_txchan_done* done,
141
         void* handle);        /* post a transmit request */
142
  int (*ioctl) (alt_dma_txchan dma, int req, void* arg); /* perform device
143
              * specific I/O control.
144
                                      */
145
};
146
 
147
/*
148
 * devices that provide a DMA receive channel are required to provide an
149
 * instance of the "alt_dma_rxchan_dev" structure.
150
 */
151
 
152
struct alt_dma_rxchan_dev_s {
153
  alt_llist list;                    /* for internal use */
154
  const char* name;                  /* name of the device instance
155
                                      * (e.g. "/dev/dma_0").
156
                                      */
157
  alt_u32        depth;              /* maximum number of receive requests that
158
                                      * can be posted.
159
                                      */
160
  int (*prepare) (alt_dma_rxchan   dma,
161
                  void*            data,
162
                  alt_u32          len,
163
                  alt_rxchan_done* done,
164
                  void*            handle); /* post a receive request */
165
  int (*ioctl) (alt_dma_rxchan dma, int req, void* arg);  /* perform device
166
              * specific I/O control.
167
                                      */
168
};
169
 
170
/*
171
 * Register a DMA transmit channel with the system.
172
 */
173
 
174
static ALT_INLINE int alt_dma_txchan_reg (alt_dma_txchan_dev* dev)
175
{
176
  extern alt_llist alt_dma_txchan_list;
177
 
178
  return alt_dev_llist_insert((alt_dev_llist*) dev, &alt_dma_txchan_list);
179
}
180
 
181
/*
182
 * Register a DMA receive channel with the system.
183
 */
184
 
185
static ALT_INLINE int alt_dma_rxchan_reg (alt_dma_rxchan_dev* dev)
186
{
187
  extern alt_llist alt_dma_rxchan_list;
188
 
189
  return alt_dev_llist_insert((alt_dev_llist*) dev, &alt_dma_rxchan_list);
190
}
191
 
192
/*
193
 *
194
 */
195
 
196
#ifdef __cplusplus
197
}
198
#endif /* __cplusplus */
199
 
200
#endif /* __ALT_DMA_DEV_H__ */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.