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  * Header file for RTEMS SATCAN FPGA driver
0005  *
0006  * COPYRIGHT (c) 2009.
0007  * Cobham Gaisler AB.
0008  *
0009  * Redistribution and use in source and binary forms, with or without
0010  * modification, are permitted provided that the following conditions
0011  * are met:
0012  * 1. Redistributions of source code must retain the above copyright
0013  *    notice, this list of conditions and the following disclaimer.
0014  * 2. Redistributions in binary form must reproduce the above copyright
0015  *    notice, this list of conditions and the following disclaimer in the
0016  *    documentation and/or other materials provided with the distribution.
0017  *
0018  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
0019  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
0020  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
0021  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
0022  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
0023  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
0024  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
0025  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
0026  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
0027  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
0028  * POSSIBILITY OF SUCH DAMAGE.
0029  */
0030 
0031 #ifndef __SATCAN_H__
0032 #define __SATCAN_H__
0033 
0034 #ifdef __cplusplus
0035 extern "C" {
0036 #endif
0037 
0038 /* Config structure passed to SatCAN_init(..) */
0039 typedef struct {
0040     /* Configuration */
0041     int nodeno;
0042     int dps;
0043     /* Callback functions */
0044     void (*ahb_irq_callback)(void);
0045     void (*pps_irq_callback)(void);
0046     void (*m5_irq_callback)(void);
0047     void (*m4_irq_callback)(void);
0048     void (*m3_irq_callback)(void);
0049     void (*m2_irq_callback)(void);
0050     void (*m1_irq_callback)(void);
0051     void (*sync_irq_callback)(void);
0052     void (*can_irq_callback)(unsigned int fifo);
0053 } satcan_config;
0054 
0055 #define SATCAN_HEADER_SIZE    4
0056 #define SATCAN_HEADER_NMM_POS 3
0057 #define SATCAN_PAYLOAD_SIZE   8
0058 
0059 /* SatCAN message */
0060 typedef struct {
0061     unsigned char header[SATCAN_HEADER_SIZE];   /* Header of SatCAN message */
0062     unsigned char payload[SATCAN_PAYLOAD_SIZE]; /* Payload of SatCAN message */
0063 } satcan_msg;
0064 
0065 /* SatCAN modify register structure */
0066 typedef struct {
0067     unsigned int reg;
0068     unsigned int val;
0069 } satcan_regmod;
0070 
0071 /* Driver interface */
0072 int satcan_register(satcan_config *conf);
0073 
0074 /* SatCAN interrupt IDs */
0075 #define SATCAN_IRQ_NONACT_TO_ACT    0
0076 #define SATCAN_IRQ_ACTIVE_TO_NONACT 1
0077 #define SATCAN_IRQ_STR1_TO_DPS      2
0078 #define SATCAN_IRQ_DPS_TO_STR1      3
0079 #define SATCAN_IRQ_STR2_TO_DPS      4
0080 #define SATCAN_IRQ_DPS_TO_STR2      5
0081 #define SATCAN_IRQ_STR3_TO_DPS      6
0082 #define SATCAN_IRQ_DPS_TO_STR3      7
0083 #define SATCAN_IRQ_PLD1_TO_DPS      8
0084 #define SATCAN_IRQ_DPS_TO_PLD1      9
0085 #define SATCAN_IRQ_PLD2_TO_DPS      10
0086 #define SATCAN_IRQ_DPS_TO_PLD2      11
0087 #define SATCAN_IRQ_SYNC             16
0088 #define SATCAN_IRQ_TIME_MARKER1     17
0089 #define SATCAN_IRQ_TIME_MARKER2     18
0090 #define SATCAN_IRQ_TIME_MARKER3     19
0091 #define SATCAN_IRQ_TIME_MARKER4     20
0092 #define SATCAN_IRQ_TIME_MARKER5     21
0093 #define SATCAN_IRQ_EOD1             22
0094 #define SATCAN_IRQ_EOD2             23
0095 #define SATCAN_IRQ_TOD              24
0096 #define SATCAN_IRQ_CRITICAL         25
0097 
0098 /* IOC */
0099 #define SATCAN_IOC_DMA_2K           1  /* Use DMA area for 2K messages */
0100 #define SATCAN_IOC_DMA_8K           2  /* Use DMA area for 8K messages */
0101 #define SATCAN_IOC_GET_REG          3  /* Provides direct read access to all core registers */
0102 #define SATCAN_IOC_SET_REG          4  /* Provides direct write access to all core registers */
0103 #define SATCAN_IOC_OR_REG           5  /* Provides direct read access to all core registers */
0104 #define SATCAN_IOC_AND_REG          6  /* Provides direct write access to all core registers */
0105 #define SATCAN_IOC_EN_TX1_DIS_TX2   7  /* Enable DMA TX channel 1, Disable DMA TX channel 2 */
0106 #define SATCAN_IOC_EN_TX2_DIS_TX1   8  /* Enable DMA TX channel 2, Disable DMA TX channel 1 */
0107 #define SATCAN_IOC_GET_DMA_MODE     9  /* Returns the current DMA mode */
0108 #define SATCAN_IOC_SET_DMA_MODE     10 /* Sets the DMA mode  */
0109 #define SATCAN_IOC_ACTIVATE_DMA     11 /* Directly activate DMA channel */
0110 #define SATCAN_IOC_DEACTIVATE_DMA   12 /* Directly deactivate DMA channel */
0111 #define SATCAN_IOC_DMA_STATUS       13 /* Returns status of directly activated DMA */
0112 #define SATCAN_IOC_GET_DOFFSET      14 /* Get TX DMA offset */ 
0113 #define SATCAN_IOC_SET_DOFFSET      15 /* Set TX DMA offset */
0114 #define SATCAN_IOC_GET_TIMEOUT      16 /* Set TX DMA timeout */
0115 #define SATCAN_IOC_SET_TIMEOUT      17 /* Get TX DMA timeout */
0116 
0117 
0118 /* Values used to select core register with IOC_SET_REG/IOC_GET_REG */ 
0119 #define SATCAN_SWRES        0  /* Software reset */
0120 #define SATCAN_INT_EN       1  /* Interrupt enable */
0121 #define SATCAN_FIFO         3  /* FIFO read */
0122 #define SATCAN_FIFO_RES     4  /* FIFO reset */
0123 #define SATCAN_TSTAMP       5  /* Current time stamp */
0124 #define SATCAN_CMD0         6  /* Command register 0 */
0125 #define SATCAN_CMD1         7  /* Command register 1 */
0126 #define SATCAN_START_CTC    8  /* Start cycle time counter */
0127 #define SATCAN_RAM_BASE     9  /* RAM offset address */
0128 #define SATCAN_STOP_CTC     10 /* Stop cycle time counter / DPS active status */
0129 #define SATCAN_DPS_ACT      10 /* Stop cycle time counter / DPS active status */
0130 #define SATCAN_PLL_RST      11 /* DPLL reset */
0131 #define SATCAN_PLL_CMD      12 /* DPLL command */
0132 #define SATCAN_PLL_STAT     13 /* DPLL status */
0133 #define SATCAN_PLL_OFF      14 /* DPLL offset */
0134 #define SATCAN_DMA          15 /* DMA channel enable */
0135 #define SATCAN_DMA_TX_1_CUR 16 /* DMA channel 1 TX current address */
0136 #define SATCAN_DMA_TX_1_END 17 /* DMA channel 1 TX end address */
0137 #define SATCAN_DMA_TX_2_CUR 18 /* DMA channel 2 TX current address */
0138 #define SATCAN_DMA_TX_2_END 19 /* DMA channel 2 TX end address */
0139 #define SATCAN_RX           20 /* CAN RX enable / Filter start ID */
0140 #define SATCAN_FILTER_START 20 /* CAN RX enable / Filter start ID */
0141 #define SATCAN_FILTER_SETUP 21 /* Filter setup / Filter stop ID */
0142 #define SATCAN_FILTER_STOP  21 /* Filter setup / Filter stop ID */
0143 #define SATCAN_WCTRL        32 /* Wrapper status/control register */
0144 #define SATCAN_WIPEND       33 /* Wrapper interrupt pending register */
0145 #define SATCAN_WIMASK       34 /* Wrapper interrupt mask register */
0146 #define SATCAN_WAHBADDR     35 /* Wrapper AHB address register */
0147 
0148 
0149 /* Values used to communicate DMA mode */
0150 #define SATCAN_DMA_MODE_USER   0
0151 #define SATCAN_DMA_MODE_SYSTEM 1
0152 
0153 /* Values used to directly activate DMA channel */
0154 #define SATCAN_DMA_ENABLE_TX1  1
0155 #define SATCAN_DMA_ENABLE_TX2  2
0156 
0157 #ifdef __cplusplus
0158 }
0159 #endif
0160 
0161 #endif /* __SATCAN_H__ */