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