RTEMS
6.1-rc2
Loading...
Searching...
No Matches
bsps
include
grlib
grslink.h
1
/* SPDX-License-Identifier: BSD-2-Clause */
2
3
/*
4
* Header file for RTEMS GRSLINK SLINK master driver
5
*
6
* COPYRIGHT (c) 2009.
7
* Cobham Gaisler AB.
8
*
9
* Redistribution and use in source and binary forms, with or without
10
* modification, are permitted provided that the following conditions
11
* are met:
12
* 1. Redistributions of source code must retain the above copyright
13
* notice, this list of conditions and the following disclaimer.
14
* 2. Redistributions in binary form must reproduce the above copyright
15
* notice, this list of conditions and the following disclaimer in the
16
* documentation and/or other materials provided with the distribution.
17
*
18
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
22
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28
* POSSIBILITY OF SUCH DAMAGE.
29
*/
30
31
#ifndef __GRSLINK_H__
32
#define __GRSLINK_H__
33
34
#ifdef __cplusplus
35
extern
"C"
{
36
#endif
37
38
/**** Configuration ****/
39
/* Collect statistics ? */
40
#define SLINK_COLLECT_STATISTICS
41
42
/* Frequency of SLINK SCLK */
43
#define SLINK_FREQ_HZ 6000000
44
/* Number of queues used in driver */
45
#define SLINK_NUMQUEUES 4
46
47
/* The four values below are only used in the demo software */
48
#define SLINK_CORE_REGBASE 0x80000600
49
#define SLINK_CORE_IRQ 6
50
#define IRQ_CNTRL_REG 0x80000200
51
#define IRQ_CNTRL_MASK_OFFSET 0x40
52
53
/*
54
* Structure returned by SLINK_statistics if SLINK_COLLECT_STATISTCS has
55
* been defined
56
*/
57
typedef
struct
{
58
unsigned
int
parerr;
/* Number of parity errors */
59
unsigned
int
recov;
/* Number of receive overflows */
60
unsigned
int
reads;
/* Number of completed READs */
61
unsigned
int
writes;
/* Number of performed WRITES */
62
unsigned
int
sequences;
/* Number of started SEQUENCEs */
63
unsigned
int
seqcomp;
/* Number of completed SEQUENCEs */
64
unsigned
int
interrupts;
/* Number of INTERRUPT transfers */
65
unsigned
int
lostwords;
/* Number of lost words due to full queue */
66
}
SLINK_stats
;
67
68
/**** SLINK status codes ****/
69
#define SLINK_ABORTED 0
70
#define SLINK_QFULL 1
71
#define SLINK_ACTIVE 2
72
#define SLINK_AMBAERR 3
73
#define SLINK_COMPLETED 4
74
#define SLINK_PARERR 5
75
#define SLINK_ROV 6
/* Only used internally in driver */
76
77
/**** SLINK master register fields *****/
78
/* Control register */
79
#define SLINK_C_SLEN_POS 16
80
#define SLINK_C_SRO (1 << 8)
81
#define SLINK_C_SCN_POS 4
82
#define SLINK_C_PAR (1 << 3)
83
#define SLINK_C_AS (1 << 2)
84
#define SLINK_C_SE (1 << 1)
85
#define SLINK_C_SLE (1 << 0)
86
87
/* Status register fields */
88
#define SLINK_S_SI_POS 16
89
#define SLINK_S_PERR (1 << 7)
90
#define SLINK_S_AERR (1 << 6)
91
#define SLINK_S_ROV (1 << 5)
92
#define SLINK_S_RNE (1 << 4)
93
#define SLINK_S_TNF (1 << 3)
94
#define SLINK_S_SC (1 << 2)
95
#define SLINK_S_SA (1 << 1)
96
#define SLINK_S_SRX (1 << 0)
97
98
/* Mask register fields */
99
#define SLINK_M_PERRE (1 << 7)
100
#define SLINK_M_AERRE (1 << 6)
101
#define SLINK_M_ROVE (1 << 5)
102
#define SLINK_M_RNEE (1 << 4)
103
#define SLINK_M_TNFE (1 << 3)
104
#define SLINK_M_SCE (1 << 2)
105
#define SLINK_M_SAE (1 << 1)
106
#define SLINK_M_SRXE (1 << 0)
107
108
/**** Macros ****/
109
/* Get channel field from received SLINK word */
110
#define SLINK_WRD_CHAN(x) ((x >> 16) & 0xF)
111
/* Get IO card # from received SLINK word */
112
#define SLINK_WRD_CARDNUM(x) ((x >> 21) & 0x3)
113
/* Get data part from SLINK word */
114
#define SLINK_WRD_PAYLOAD(x) (x & 0xFFFF)
115
116
/* Checks status value to see if transmit queue has free slot */
117
#define SLINK_STS_TRANSFREE(x) (x & SLINK_S_TNF)
118
/* Get Sequence Index value */
119
#define SLINK_STS_SI(x) ((x >> 16) & 0xFF)
120
121
/**** Function declarations, driver interface ****/
122
/* Initializes the SLINK core */
123
int
SLINK_init(
unsigned
int
nullwrd,
int
parity,
int
qsize,
124
void
(*interrupt_trans_handler)(
int
),
125
void
(*sequence_callback)(
int
));
126
127
/* Enables the core */
128
void
SLINK_start(
void
);
129
130
/* Disables the core */
131
void
SLINK_stop(
void
);
132
133
/* Reads one word */
134
int
SLINK_read(
int
data,
int
channel,
int
*reply);
135
136
/* Writes one word */
137
int
SLINK_write(
int
data,
int
channel);
138
139
/* Peforms a SEQUENCE */
140
int
SLINK_seqstart(
int
*a,
int
*b,
int
n,
int
channel,
int
reconly);
141
142
/* Aborts a SEQUENCE */
143
void
SLINK_seqabort(
void
);
144
145
/* Status of current or last SEQUENCE */
146
int
SLINK_seqstatus(
void
);
147
148
/* Number of words transferred in last SEQUENCE */
149
int
SLINK_seqwrds(
void
);
150
151
/* Returns value of core's status register */
152
int
SLINK_hwstatus(
void
);
153
154
/* Returns number of elements in queue associated with IO card */
155
int
SLINK_queuestatus(
int
iocard);
156
157
/* Take first element from queue for IO card # 'iocard' */
158
int
SLINK_dequeue(
int
iocard,
int
*elem);
159
160
/* Returns structure containing core driver statistics */
161
SLINK_stats
*SLINK_statistics(
void
);
162
163
#ifdef __cplusplus
164
}
165
#endif
166
167
#endif
/* __GRSLINK_H__ */
SLINK_stats
Definition:
grslink.h:57
Generated by
1.9.6