RTEMS: bsps/include/grlib/gr1553bc.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
gr1553bc.h
1/* GR1553B BC driver
2 *
3 * COPYRIGHT (c) 2010.
4 * Cobham Gaisler AB.
5 *
6 * The license and distribution terms for this file may be
7 * found in the file LICENSE in this distribution or at
8 * http://www.rtems.org/license/LICENSE.
9 *
10 * OVERVIEW
11 * ========
12 * This driver controls the BC device, located at an on-chip AMBA or an
13 * AMBA-over-PCI bus. The driver operates the BC device and provides you
14 * with interrupt services and core control. The driver start execution of
15 * a synchronuos and/or an asynchronous BC descriptor List. The list contains
16 * a descriptor table and a software description to make some operations
17 * possible, for example translate descriptor-address into descriptor-number.
18 *
19 * BC descriptors are generated by the list API, available in gr1553bc_list.h.
20 *
21 * See gr1553bc_list.h for more information.
22 */
23
24#ifndef __GR1553BC_H__
25#define __GR1553BC_H__
26
27#ifdef __cplusplus
28extern "C" {
29#endif
30
31/* Forward declaration */
32struct gr1553bc_list;
33struct gr1553bc_major;
34struct gr1553bc_minor;
35struct gr1553bc_minor_cfg;
36struct gr1553bc_major_cfg;
37
38#ifdef __cplusplus
39}
40#endif
41
42#include <stdint.h>
43#include "gr1553bc_list.h"
44
45#ifdef __cplusplus
46extern "C" {
47#endif
48
49/* Register GR1553B driver needed by BC driver */
50extern void gr1553bc_register(void);
51
52/* A BC descriptor accessed as is */
53 struct gr1553bc_bd_raw {
54 volatile uint32_t words[4];
55};
56
57/* A BC descriptor accessed as a transfer descriptor */
58 struct gr1553bc_bd_tr {
59 volatile uint32_t settings[2];
60 volatile uint32_t dptr;
61 volatile uint32_t status;
62};
63
64/* A BC descriptor accessed as a conditional descriptor */
65 struct gr1553bc_bd_cond {
66 volatile uint32_t cond;
67 volatile uint32_t bdptr;
68 volatile uint32_t padding[2];
69};
70
71/* A BC descriptor accessed any way */
72 union gr1553bc_bd {
73 struct gr1553bc_bd_raw raw;
74 struct gr1553bc_bd_tr tr;
75 struct gr1553bc_bd_cond cond;
76};
77
78/* Current state of the BC hardware */
79 struct gr1553bc_status {
80 unsigned int status;
81 unsigned int time;
82};
83
84#define KEEP_TIMESLOT 0x10
85/* Initialize a BC descriptor. The words written is controllable by
86 * the flags argument.
87 *
88 * flags:
89 * bit[N=0..3]: 1 = set BD wordN according to argument wordN,
90 * 0 = do not modify BD wordN
91 *
92 * If bit KEEP_TIMESLOT is set the time slot of word0 is preserved,
93 * this bit only have an affect when the descriptor is a transfer
94 * descriptor.
95 */
96extern void gr1553bc_bd_init(
97 union gr1553bc_bd *bd,
98 unsigned int flags,
99 uint32_t word0,
100 uint32_t word1,
101 uint32_t word2,
102 uint32_t word3
103 );
104
105/* Initialize a Transfer descriptor
106 *
107 * Arguments:
108 * struct gr1553bc_bd_tr *bd
109 * uint32_t setting0
110 * uint32_t setting1
111 * uint32_t data
112 * uint32_t status
113 */
114#define gr1553bc_bd_tr_init(bd, set0, set1, data, status) \
115 gr1553bc_bd_init((union gr1553bc_bd *)bd,\
116 0xf, set0, set1, data, status)
117/* Initializa a Condition descriptor
118 *
119 * Arguments:
120 * struct gr1553bc_bd_cond *bd
121 * uint32_t cond
122 * uint32_t jump_adr
123 */
124#define gr1553bc_bd_cond_init(bd, cond, jump_adr) \
125 gr1553bc_bd_init((union gr1553bc_bd *)bd, \
126 0xf, cond, jump_adr, 0, 0)
127
128/* Size of a descriptor */
129#define GR1553BC_BD_SIZE sizeof(struct gr1553bc_bd_raw)
130
131/* Alignment of a descriptor */
132#define GR1553BC_BD_ALIGN 16
133
134/* End of list marker */
135#define GR1553BC_TR_EOL 0x80ffffff
136
137#define GR1553BC_BD_TYPE 0x80000000
138
139/* Condition descriptor bits */
140#define GR1553BC_UNCOND_JMP 0x820000ff
141#define GR1553BC_UNCOND_IRQ 0x860000ff
142#define GR1553BC_UNCOND_NOJMP 0x82000000
143
144/* Transfer descriptor bits */
145#define GR1553BC_TR_DUMMY_0 0x00000000
146#define GR1553BC_TR_DUMMY_1 0x80000000
147
148#define GR1553BC_TR_TIME 0x0000ffff
149
150#define GR1553BC_TR_EXTTRIG 0x40000000
151
152/* Take a GR1553BC hardware device identified by instance index (minor).
153 * A pointer is returned that is used internally by the GR1553BC
154 * driver, it is used as an input paramter 'bc' to all other
155 * functions that manipulate the hardware.
156 */
157extern void *gr1553bc_open(int minor);
158
159extern void gr1553bc_close(void *bc);
160
161/* Stores Current Major/Minor frame number and the Slot number executing
162 * into the location indicated by 'mid'. There may be two lists executing
163 * in "parallel", the 'async' argument select for which list the MID is
164 * looked up, the Syncronous (async=0) list or the Asynchronous (async=1)
165 * list.
166 *
167 */
168extern int gr1553bc_indication(void *bc, int async, int *mid);
169
170/* Trigger external time sync by writing to the BC action register.
171 * This may be good for debugging or if the time management is
172 * implemented in software.
173 *
174 * if trig=0 the external trigger memory is cleared.
175 * if trig!=0 the external trigger memory is set.
176 */
177extern void gr1553bc_ext_trig(void *bc, int trig);
178
179/* Configure the GR1553BC driver */
180/*extern int gr1553bc_config(struct gr1553bc_config *cfg);*/
181
182/* Start major frame processing. At least one list pointer must be
183 * non-zero to affect BC operation. The BC communication is enabled
184 * depending on list and Interrupts are enabled. This function can
185 * be called multiple times.
186 *
187 * If a list is already executing it will be replaced with the new
188 * list.
189 *
190 * list - Schedule Transfer List
191 * list_async - Asynchronous list
192 */
193extern int gr1553bc_start
194 (
195 void *bc,
196 struct gr1553bc_list *list,
197 struct gr1553bc_list *list_async
198 );
199
200/* Pause GR1553B BC scheduled transfers.
201 *
202 * Does not affect asynchronous operation.
203 */
204extern int gr1553bc_pause(void *bc);
205
206/* Restart GR1553B BC scheduled transfers, after being paused
207 *
208 * Does not affect asynchronous operation.
209 */
210extern int gr1553bc_restart(void *bc);
211
212/* Stop BC transmission.
213 *
214 * OPTIONS
215 * bit0 - 1=STOP schedule list
216 * bit1 - 1=STOP asynchronous list
217 */
218extern int gr1553bc_stop(void *bc, int options);
219
220/* Standard IRQ function setup. IRQ can be generated by condition descriptors
221 * or by transfer descriptors or by errors.
222 *
223 * Condition descriptors are inserted into the list by user, each condition
224 * may have a custom function and data assigned to it, see
225 * gr1553bc_slot_irq_prepare(). IRQs generated by condition descriptors are
226 * not handled by this function.
227 *
228 * Transfer descriptors can generate IRQ if enabled by user.
229 *
230 * IRQs generated by transfer descriptors or by BC errors (DMA error etc.)
231 * is handled by this standard ISR handler.
232 */
233extern int gr1553bc_irq_setup
234 (
235 void *bc,
236 bcirq_func_t func,
237 void *data
238 );
239
240/* Get Current BC hardware state/status. The Status is stored into the
241 * area pointed to by status. See "struct gr1553bc_status" for more
242 * info.
243 */
244extern void gr1553bc_status(void *bc, struct gr1553bc_status *status);
245
246#ifdef __cplusplus
247}
248#endif
249
250#endif /* __GR1553BC_H__ */
gr1553bc_bd_cond
Definition: gr1553bc.h:65
gr1553bc_bd_raw
Definition: gr1553bc.h:53
gr1553bc_bd_tr
Definition: gr1553bc.h:58
gr1553bc_list
Definition: gr1553bc_list.h:241
gr1553bc_major_cfg
Definition: gr1553bc_list.h:223
gr1553bc_major
Definition: gr1553bc_list.h:333
gr1553bc_minor_cfg
Definition: gr1553bc_list.h:218
gr1553bc_minor
Definition: gr1553bc_list.h:340
gr1553bc_status
Definition: gr1553bc.h:79
gr1553bc_bd
Definition: gr1553bc.h:72