source: rtems/c/src/lib/libbsp/sparc/shared/include/spwcuc.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: 6.7 KB
Line 
1/*  SPWCUC - SpaceWire - CCSDS unsegmented Code Transfer Protocol GRLIB core
2 *  register driver interface.
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 __SPWCUC_H__
13#define __SPWCUC_H__
14
15#define PKT_INIT_IRQ       0x1
16#define PKT_ERR_IRQ        0x2
17#define PKT_RX_IRQ         0x4
18#define WRAP_ERR_IRQ       0x8
19#define WRAP_IRQ           0x10
20#define SYNC_ERR_IRQ       0x20
21#define SYNC_IRQ           0x40
22#define TOL_ERR_IRQ        0x80
23#define TICK_RX_ERR_IRQ    0x100
24#define TICK_RX_WRAP_IRQ   0x200
25#define TICK_RX_IRQ        0x400
26#define TICK_TX_WRAP_IRQ   0x800
27#define TICK_TX_IRQ        0x1000
28
29/* SPWCUC Register layout */
30struct spwcuc_regs {
31        volatile unsigned int config;        /* 00 */
32        volatile unsigned int status;        /* 04 */
33        volatile unsigned int control;       /* 08 */
34        volatile unsigned int unused0;       /* 0c */
35        volatile unsigned int dla;           /* 10 */
36        volatile unsigned int pid;           /* 14 */
37        volatile unsigned int offset;        /* 18 */
38        volatile unsigned int unused1;       /* 1c */
39        volatile unsigned int pkt_ct;        /* 20 */
40        volatile unsigned int pkt_ft;        /* 24 */   
41        volatile unsigned int pkt_pf_crc;    /* 28 */
42        volatile unsigned int unused2;       /* 2c */
43        volatile unsigned int etct;          /* 30 */
44        volatile unsigned int etft;          /* 34 */
45        volatile unsigned int etct_next;     /* 38 */
46        volatile unsigned int etft_next;     /* 3c */
47        volatile unsigned int unused3[8];    /* 40-5c */
48        volatile unsigned int pimsr;         /* 60 */
49        volatile unsigned int pimr;          /* 64 */
50        volatile unsigned int pisr;          /* 68 */
51        volatile unsigned int pir;           /* 6c */
52        volatile unsigned int imr;           /* 70 */
53        volatile unsigned int picr;          /* 74 */
54};
55
56struct spwcuc_cfg {
57        unsigned char sel_out;         /* Bits 3-0 enable time code transmission on respective output */
58        unsigned char sel_in;          /* Select SpW to receive time codes on, 0-3 */
59        unsigned char mapping;         /* Define mapping of time code time info into T-field, 0-31 */
60        unsigned char tolerance;       /* Define SpaceWire time code reception tolerance, 0-31 */
61        unsigned char tid;             /* Define CUC P-Field time code identification, 1 = Level 1, 2 = Level 2 */
62        unsigned char ctf;             /* If 1 check time code flags to be all zero */
63        unsigned char cp;              /* If 1 check P-Field time code id against tid */
64
65        unsigned char txen;            /* Enable SpaceWire time code transmission */
66        unsigned char rxen;            /* Enable SpaceWire time code reception */
67        unsigned char pktsyncen;       /* Enable SpaceWire time CUC packet sync */
68        unsigned char pktiniten;       /* Enable SpaceWire time CUC packet init */
69        unsigned char pktrxen;         /* Enable SpaceWire time CUC packet reception */
70
71        unsigned char dla;             /* SpaceWire destination logical address */ 
72        unsigned char dla_mask;        /* SpaceWire destination logical address mask */ 
73        unsigned char pid;             /* SpaceWire protocol ID */
74       
75        unsigned int offset;           /* Packet reception offset */
76};
77
78/* SPWCUC Statistics gathered by driver */
79struct spwcuc_stats {
80
81        /* IRQ Stats */
82        unsigned int nirqs;
83        unsigned int tick_tx;
84        unsigned int tick_tx_wrap;
85        unsigned int tick_rx;
86        unsigned int tick_rx_wrap;
87        unsigned int tick_rx_error;
88        unsigned int tolerr;
89        unsigned int sync;
90        unsigned int syncerr;
91        unsigned int wrap;
92        unsigned int wraperr;
93        unsigned int pkt_rx;
94        unsigned int pkt_err;
95        unsigned int pkt_init;
96};
97
98/* Function ISR callback prototype
99 *
100 * pimr    - PIMR/PIR register of the SPWCUC core read by ISR
101 * data    - Custom data provided by user
102 */
103typedef void (*spwcuc_isr_t)(unsigned int pimr, void *data);
104
105/* Open a SPWCUC device by minor number. A SPWCUC device can only by opened
106 * once. The handle returned must be used as the input parameter 'spwcuc' in
107 * the rest of the calls in the function interface.
108 */
109extern void *spwcuc_open(int minor);
110
111/* Close a previously opened SPWCUC device */
112extern void spwcuc_close(void *spwcuc);
113
114/* Reset SPWCUC Core */
115extern int spwcuc_reset(void *spwcuc);
116
117/* Enable Interrupts at Interrupt controller */
118extern void spwcuc_int_enable(void *spwcuc);
119
120/* Disable Interrupts at Interrupt controller */
121extern void spwcuc_int_disable(void *spwcuc);
122
123/* Clear Statistics gathered by the driver */
124extern void spwcuc_clr_stats(void *spwcuc);
125
126/* Get Statistics gathered by the driver. The statistics are stored into
127 * the location pointed to by 'stats'.
128 */
129extern void spwcuc_get_stats(void *spwcuc, struct spwcuc_stats *stats);
130
131/* Register an Interrupt handler and custom data, the function call is
132 * removed by setting func to NULL.
133 *
134 * The driver's interrupt handler is installed on open(), however the user
135 * callback called from the driver's ISR is installed using this function.
136 */
137extern void spwcuc_int_register(void *spwcuc, spwcuc_isr_t func, void *data);
138
139/* Configure the spwcuc core. The configuration is taken from the data
140 * structure pointed to by 'cfg'. See data structure spwcuc_cfg fields.
141 */
142extern void spwcuc_config(void *spwcuc, struct spwcuc_cfg *cfg);
143
144/* Return elapsed coarse time */
145extern unsigned int spwcuc_get_et_coarse(void *spwcuc);
146
147/* Return elapsed fine time */
148extern unsigned int spwcuc_get_et_fine(void *spwcuc);
149
150/* Return elapsed time (coarse and fine) 64-bit value */
151extern unsigned long long spwcuc_get_et(void *spwcuc);
152
153/* Return next elapsed coarse time (for use when sending SpW time packet) */
154extern unsigned int spwcuc_get_next_et_coarse(void *spwcuc);
155
156/* Return next elapsed fine time (for use when sending SpW time packet) */
157extern unsigned int spwcuc_get_next_et_fine(void *spwcuc);
158
159/* Return next elapsed time (for use when sending SpW time packet) */
160extern unsigned long long spwcuc_get_next_et(void *spwcuc);
161
162/* Force/Set the elapsed time (coarse 32-bit and fine 24-bit) by writing the
163 * T-Field Time Packet Registers then the FORCE bit.
164 */
165extern void spwcuc_force_et(void *spwcuc, unsigned long long time);
166
167/* Return received (from time packet) elapsed coarse time */
168extern unsigned int spwcuc_get_tp_et_coarse(void *spwcuc);
169
170/* Return received (from time packet) elapsed fine time */
171extern unsigned int spwcuc_get_tp_et_fine(void *spwcuc);
172
173/* Return received (from time packet) elapsed time (coarse and fine) */
174extern unsigned long long spwcuc_get_tp_et(void *spwcuc);
175
176/* Clear interrupts */
177extern void spwcuc_clear_irqs(void *spwcuc, int irqs);
178
179/* Enable interrupts */
180extern void spwcuc_enable_irqs(void *spwcuc, int irqs);
181
182/* Get Register */
183extern struct spwcuc_regs *spwcuc_get_regs(void *spwcuc);
184
185/* Register the SPWCUC Driver to the Driver Manager */
186extern void spwcuc_register(void);
187
188#endif
Note: See TracBrowser for help on using the repository browser.