source: rtems/c/src/lib/libbsp/sparc/shared/include/grslink.h @ 4a7d1026

4.11
Last change on this file since 4a7d1026 was 4a7d1026, checked in by Daniel Hellstrom <daniel@…>, on Apr 13, 2015 at 8:25:52 AM

sparc bsps: updated license to rtems.org

  • Property mode set to 100644
File size: 4.0 KB
Line 
1/*
2 * Header file for RTEMS GRSLINK SLINK master driver
3 *
4 * COPYRIGHT (c) 2009.
5 * Cobham Gaisler AB.
6 *
7 * The license and distribution terms for this file may be
8 * found in the file LICENSE in this distribution or at
9 * http://www.rtems.org/license/LICENSE.
10 */
11
12#ifndef __GRSLINK_H__
13#define __GRSLINK_H__
14
15#ifdef __cplusplus
16extern "C" {
17#endif
18
19/**** Configuration ****/
20/* Collect statistics ? */
21#define SLINK_COLLECT_STATISTICS
22
23/* Frequency of SLINK SCLK */
24#define SLINK_FREQ_HZ 6000000
25/* Number of queues used in driver */
26#define SLINK_NUMQUEUES 4
27
28/* The four values below are only used in the demo software */
29#define SLINK_CORE_REGBASE 0x80000600
30#define SLINK_CORE_IRQ 6
31#define IRQ_CNTRL_REG 0x80000200
32#define IRQ_CNTRL_MASK_OFFSET 0x40
33
34/*
35 * Structure returned by SLINK_statistics if SLINK_COLLECT_STATISTCS has
36 * been defined
37 */
38typedef struct {
39        unsigned int parerr;     /* Number of parity errors */
40        unsigned int recov;      /* Number of receive overflows */
41        unsigned int reads;      /* Number of completed READs */
42        unsigned int writes;     /* Number of performed WRITES */
43        unsigned int sequences;  /* Number of started SEQUENCEs */
44        unsigned int seqcomp;    /* Number of completed SEQUENCEs */
45        unsigned int interrupts; /* Number of INTERRUPT transfers */
46        unsigned int lostwords;  /* Number of lost words due to full queue */
47} SLINK_stats;
48
49/**** SLINK status codes ****/
50#define SLINK_ABORTED   0
51#define SLINK_QFULL     1
52#define SLINK_ACTIVE    2
53#define SLINK_AMBAERR   3
54#define SLINK_COMPLETED 4
55#define SLINK_PARERR    5
56#define SLINK_ROV       6 /* Only used internally in driver */
57
58/**** SLINK master register fields *****/
59/* Control register */
60#define SLINK_C_SLEN_POS 16
61#define SLINK_C_SRO  (1 << 8)
62#define SLINK_C_SCN_POS 4
63#define SLINK_C_PAR  (1 << 3)
64#define SLINK_C_AS   (1 << 2)
65#define SLINK_C_SE   (1 << 1)
66#define SLINK_C_SLE  (1 << 0)
67
68/* Status register fields */
69#define SLINK_S_SI_POS 16
70#define SLINK_S_PERR (1 << 7)
71#define SLINK_S_AERR (1 << 6)
72#define SLINK_S_ROV  (1 << 5)
73#define SLINK_S_RNE  (1 << 4)
74#define SLINK_S_TNF  (1 << 3)
75#define SLINK_S_SC   (1 << 2)
76#define SLINK_S_SA   (1 << 1)
77#define SLINK_S_SRX  (1 << 0)
78
79/* Mask register fields */
80#define SLINK_M_PERRE (1 << 7)
81#define SLINK_M_AERRE (1 << 6)
82#define SLINK_M_ROVE  (1 << 5)
83#define SLINK_M_RNEE  (1 << 4)
84#define SLINK_M_TNFE  (1 << 3)
85#define SLINK_M_SCE   (1 << 2)
86#define SLINK_M_SAE   (1 << 1)
87#define SLINK_M_SRXE  (1 << 0)
88
89/**** Macros ****/
90/* Get channel field from received SLINK word */
91#define SLINK_WRD_CHAN(x) ((x >> 16) & 0xF)
92/* Get IO card # from received SLINK word */
93#define SLINK_WRD_CARDNUM(x) ((x >> 21) & 0x3)
94/* Get data part from SLINK word */
95#define SLINK_WRD_PAYLOAD(x) (x & 0xFFFF)
96
97/* Checks status value to see if transmit queue has free slot */
98#define SLINK_STS_TRANSFREE(x) (x & SLINK_S_TNF)
99/* Get Sequence Index value */
100#define SLINK_STS_SI(x) ((x >> 16) & 0xFF)
101
102/**** Function declarations, driver interface ****/
103/* Initializes the SLINK core */
104int SLINK_init(unsigned int nullwrd, int parity, int qsize,
105               void (*interrupt_trans_handler)(int),
106               void (*sequence_callback)(int));
107
108/* Enables the core */
109void SLINK_start(void);
110
111/* Disables the core */
112void SLINK_stop(void);
113
114/* Reads one word */
115int SLINK_read(int data, int channel, int *reply);
116
117/* Writes one word */
118int SLINK_write(int data, int channel);
119
120/* Peforms a SEQUENCE */
121int SLINK_seqstart(int *a, int *b, int n, int channel, int reconly);
122
123/* Aborts a SEQUENCE */
124void SLINK_seqabort(void);
125
126/* Status of current or last SEQUENCE */
127int SLINK_seqstatus(void);
128
129/* Number of words transferred in last SEQUENCE */
130int SLINK_seqwrds(void);
131
132/* Returns value of core's status register */
133int SLINK_hwstatus(void);
134
135/* Returns number of elements in queue associated with IO card */
136int SLINK_queuestatus(int iocard);
137
138/* Take first element from queue for IO card # 'iocard' */
139int SLINK_dequeue(int iocard, int *elem);
140
141/* Returns structure containing core driver statistics */
142SLINK_stats *SLINK_statistics(void);
143
144#ifdef __cplusplus
145}
146#endif
147
148#endif /* __GRSLINK_H__ */
Note: See TracBrowser for help on using the repository browser.