Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:43

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  * @ingroup spw
0006  */
0007 
0008 /*
0009  *  COPYRIGHT (c) 2007.
0010  *  Cobham Gaisler AB.
0011  *
0012  * Redistribution and use in source and binary forms, with or without
0013  * modification, are permitted provided that the following conditions
0014  * are met:
0015  * 1. Redistributions of source code must retain the above copyright
0016  *    notice, this list of conditions and the following disclaimer.
0017  * 2. Redistributions in binary form must reproduce the above copyright
0018  *    notice, this list of conditions and the following disclaimer in the
0019  *    documentation and/or other materials provided with the distribution.
0020  *
0021  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0022  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0023  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0024  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0025  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0026  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0027  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0028  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0029  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0030  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0031  * POSSIBILITY OF SUCH DAMAGE.
0032  */
0033 
0034 #ifndef __GRSPW_H__
0035 #define __GRSPW_H__
0036 
0037 /**
0038  * @defgroup spw SpaceWire
0039  *
0040  * @ingroup RTEMSBSPsSharedGRLIB
0041  *
0042  * @brief GRSPW Device Driver
0043  *
0044  * @{
0045  */
0046 
0047 #include <grlib/ambapp.h>
0048 
0049 #ifdef __cplusplus
0050 extern "C" {
0051 #endif
0052 
0053 #define SPW_LINKERR_EVENT RTEMS_EVENT_0
0054 
0055 typedef struct {
0056    unsigned int rxsize;
0057    unsigned int txdsize;
0058    unsigned int txhsize;
0059 } spw_ioctl_packetsize;
0060 
0061 #define GRSPW_PKTSEND_OPTION_HDR_CRC  0x1
0062 #define GRSPW_PKTSEND_OPTION_DATA_CRC 0x2
0063 #define GRSPW_PKTSEND_OPTION_NOCRCLEN(len) ((len & 0xf) << 8)
0064 #define GRSPW_PKTSEND_OPTION_NOCRCLEN_MASK 0xf00
0065 
0066 typedef struct {
0067    unsigned int hlen;
0068    char *hdr;
0069    unsigned int dlen;
0070    char *data;
0071    unsigned int sent;
0072      unsigned int options;
0073 } spw_ioctl_pkt_send;
0074 
0075 typedef struct {
0076    unsigned int tx_link_err;
0077    unsigned int rx_rmap_header_crc_err;
0078    unsigned int rx_rmap_data_crc_err;
0079    unsigned int rx_eep_err;
0080    unsigned int rx_truncated;
0081    unsigned int parity_err;
0082    unsigned int escape_err;
0083    unsigned int credit_err;
0084    unsigned int write_sync_err;
0085    unsigned int disconnect_err;
0086    unsigned int early_ep;
0087    unsigned int invalid_address;
0088    unsigned int packets_sent;
0089    unsigned int packets_received;
0090 } spw_stats;
0091 
0092 typedef struct {
0093    unsigned int nodeaddr;
0094    unsigned int destkey;
0095    unsigned int clkdiv; /* Note: contain both CLKDIVSTART and CLKDIVRUN, but IOCTL_SET_CLKDIV* commands are split into two */
0096    unsigned int rxmaxlen;
0097    unsigned int timer;
0098    unsigned int disconnect;
0099    unsigned int promiscuous;
0100    unsigned int rmapen;
0101    unsigned int rmapbufdis;
0102    unsigned int linkdisabled;
0103    unsigned int linkstart;
0104 
0105    unsigned int check_rmap_err; /* check incoming packets for rmap errors */
0106    unsigned int rm_prot_id; /* remove protocol id from incoming packets */
0107    unsigned int tx_blocking; /* use blocking tx */
0108    unsigned int tx_block_on_full; /* block when all tx_buffers are used */
0109    unsigned int rx_blocking; /* block when no data is available */
0110    unsigned int disable_err; /* disable link automatically when link error is detected */
0111    unsigned int link_err_irq; /* generate an interrupt when link error occurs */
0112    rtems_id event_id; /* task id that should receive link err irq event */
0113 
0114    unsigned int is_rmap;
0115    unsigned int is_rxunaligned;
0116    unsigned int is_rmapcrc;
0117 
0118    unsigned int nodemask;
0119      unsigned int keep_source; /* copy source address to user-buffer in read() operations
0120                               * Note that rm_prot_id has no effect when keep_source is
0121                               * set.
0122                               */
0123      unsigned int rtimeout; /* Read timeout if != 0 */
0124 } spw_config;
0125 
0126 #define SPACEWIRE_IOCTRL_SET_NODEADDR        1
0127 #define SPACEWIRE_IOCTRL_SET_RXBLOCK         2
0128 #define SPACEWIRE_IOCTRL_SET_DESTKEY         4
0129 #define SPACEWIRE_IOCTRL_SET_CLKDIV          5
0130 #define SPACEWIRE_IOCTRL_SET_TIMER           6
0131 #define SPACEWIRE_IOCTRL_SET_DISCONNECT      7
0132 #define SPACEWIRE_IOCTRL_SET_PROMISCUOUS     8
0133 #define SPACEWIRE_IOCTRL_SET_RMAPEN          9
0134 #define SPACEWIRE_IOCTRL_SET_RMAPBUFDIS      10
0135 #define SPACEWIRE_IOCTRL_SET_CHECK_RMAP      11
0136 #define SPACEWIRE_IOCTRL_SET_RM_PROT_ID      12
0137 #define SPACEWIRE_IOCTRL_SET_TXBLOCK         14
0138 #define SPACEWIRE_IOCTRL_SET_DISABLE_ERR     15
0139 #define SPACEWIRE_IOCTRL_SET_LINK_ERR_IRQ    16
0140 #define SPACEWIRE_IOCTRL_SET_EVENT_ID        17
0141 #define SPACEWIRE_IOCTRL_SET_PACKETSIZE      20
0142 #define SPACEWIRE_IOCTRL_GET_LINK_STATUS     23
0143 #define SPACEWIRE_IOCTRL_GET_CONFIG          25
0144 #define SPACEWIRE_IOCTRL_GET_STATISTICS      26
0145 #define SPACEWIRE_IOCTRL_CLR_STATISTICS      27
0146 #define SPACEWIRE_IOCTRL_SEND                28
0147 #define SPACEWIRE_IOCTRL_LINKDISABLE         29
0148 #define SPACEWIRE_IOCTRL_LINKSTART           30
0149 #define SPACEWIRE_IOCTRL_SET_TXBLOCK_ON_FULL 31
0150 #define SPACEWIRE_IOCTRL_SET_COREFREQ        32
0151 #define SPACEWIRE_IOCTRL_SET_CLKDIVSTART     33
0152 #define SPACEWIRE_IOCTRL_SET_NODEMASK        34
0153 #define SPACEWIRE_IOCTRL_SET_KEEP_SOURCE     35
0154 #define SPACEWIRE_IOCTRL_SET_TCODE_CTRL      36
0155 #define SPACEWIRE_IOCTRL_SET_TCODE           37
0156 #define SPACEWIRE_IOCTRL_GET_TCODE           38
0157 #define SPACEWIRE_IOCTRL_SET_READ_TIMEOUT    39
0158 
0159 #define SPACEWIRE_IOCTRL_START               64
0160 #define SPACEWIRE_IOCTRL_STOP                65
0161 
0162 /* Defines what register bits that will be touched 
0163  * for SPACEWIRE_IOCTRL_SET_TCODE_CTRL
0164  */
0165 #define SPACEWIRE_TCODE_CTRL_IE_MSK          0x001
0166 #define SPACEWIRE_TCODE_CTRL_TT_MSK          0x004
0167 #define SPACEWIRE_TCODE_CTRL_TR_MSK          0x008
0168 
0169 /* Defines what register bits that should be set
0170  * for SPACEWIRE_IOCTRL_SET_TCODE_CTRL
0171  */
0172 #define SPACEWIRE_TCODE_CTRL_IE              0x100
0173 #define SPACEWIRE_TCODE_CTRL_TT              0x400
0174 #define SPACEWIRE_TCODE_CTRL_TR              0x800
0175 
0176 /* SPACEWIRE_IOCTRL_SET_TCODE argument mask */
0177 #define SPACEWIRE_TCODE_TCODE                0x0ff
0178 #define SPACEWIRE_TCODE_SET                  0x100 /* Set Timecode register */
0179 #define SPACEWIRE_TCODE_TX                   0x400
0180 
0181 void grspw_register_drv (void);
0182 
0183 void grspw_print(int options);
0184 
0185 /* Global GRSPW Function pointer called upon timecode receive interrupt */
0186 extern void (*grspw_timecode_callback)
0187     (void *pDev, void *regs, int minor, unsigned int tc);
0188 
0189 
0190 #ifdef __cplusplus
0191 }
0192 #endif
0193 
0194 /** @} */
0195 
0196 #endif /* __GRSPW_H__ */