Back to home page

LXR

 
 

    


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

0001 /* SPDX-License-Identifier: BSD-2-Clause */
0002 
0003 /**
0004  * @file
0005  * @ingroup 1553
0006  */
0007 
0008 /*
0009  *  COPYRIGHT (c) 2006.
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 __B1553BRM_H__
0035 #define __B1553BRM_H__
0036 
0037 /**
0038  * @defgroup 1553 B1553BRM
0039  *
0040  * @ingroup RTEMSBSPsSharedGRLIB
0041  *
0042  * @brief B1553BRM device driver
0043  *
0044  * @{
0045  */
0046 
0047 #include <drvmgr/drvmgr.h>
0048 
0049 #ifdef __cplusplus
0050 extern "C" {
0051 #endif
0052 
0053 struct brm_reg {
0054     volatile unsigned int ctrl;            /* 0x00 */
0055     volatile unsigned int oper;            /* 0x04 */
0056     volatile unsigned int cur_cmd;         /* 0x08 */
0057     volatile unsigned int imask;           /* 0x0C */
0058     volatile unsigned int ipend;           /* 0x10 */
0059     volatile unsigned int ipoint;          /* 0x14 */
0060     volatile unsigned int bit_reg;         /* 0x18 */
0061     volatile unsigned int ttag;            /* 0x1C */
0062     volatile unsigned int dpoint;          /* 0x20 */
0063     volatile unsigned int sw;              /* 0x24 */
0064     volatile unsigned int initcount;       /* 0x28 */
0065     volatile unsigned int mcpoint;         /* 0x2C */
0066     volatile unsigned int mdpoint;         /* 0x30 */
0067     volatile unsigned int mbc;             /* 0x34 */
0068     volatile unsigned int mfilta;          /* 0x38 */
0069     volatile unsigned int mfiltb;          /* 0x3C */
0070     volatile unsigned int rt_cmd_leg[16];  /* 0x40-0x80 */
0071     volatile unsigned int enhanced;        /* 0x84 */
0072 
0073     volatile unsigned int dummy[31];
0074 
0075     volatile unsigned int w_ctrl;          /* 0x100 */
0076     volatile unsigned int w_irqctrl;       /* 0x104 */
0077     volatile unsigned int w_ahbaddr;       /* 0x108 */
0078 };
0079 
0080 struct bm_msg {
0081     unsigned short miw;
0082     unsigned short cw1;
0083     unsigned short cw2;
0084     unsigned short sw1;
0085     unsigned short sw2;
0086     unsigned short time;
0087     unsigned short data[32];
0088 };
0089 
0090 struct rt_msg {
0091     unsigned short miw;
0092     unsigned short time;
0093     unsigned short data[32];
0094     unsigned short desc;
0095 };
0096 
0097 /*
0098  * rtaddr[0] and subaddr[0] :  RT address and subaddress (for rt-rt receive addresses)
0099  * rtaddr[1] and subaddr[1] :  Only for RT-RT. Transmit addresses.
0100  *
0101  * wc : word count, or mode code if subaddress 0 or 31.
0102  *
0103  * ctrl, bit 0 (TR)      : 1 - transmit, 0 - receive. Ignored for rt-rt
0104  *       bit 1 (RTRT)    : 1 - rt to rt, 0 - normal
0105  *       bit 2 (AB)      : 1 - Bus B, 0 - Bus A
0106  *       bit 4:3 (Retry) : 1 - 1, 2 - 2, 3 - 3, 0 - 4
0107  *       bit 5 (END)     : End of list
0108  *       bit 15 (BAME)   : Message error. Set by BRM if protocol error is detected
0109  *
0110  * tsw[0] : status word
0111  * tsw[1] : Only for rt-rt, status word 2
0112  *
0113  * data : data to be transmitted, or received data
0114  *
0115  */
0116 struct bc_msg {
0117     unsigned char  rtaddr[2];
0118     unsigned char  subaddr[2];
0119     unsigned short wc;
0120     unsigned short ctrl;
0121     unsigned short tsw[2];
0122     unsigned short data[32];
0123 };
0124 
0125 /* BC control bits */
0126 #define BC_TR     0x0001
0127 #define BC_RTRT   0x0002
0128 #define BC_BUSA   0x0004
0129 #define BC_EOL    0x0020
0130 #define BC_SKIP   0x0040
0131 #define BC_BAME   0x8000
0132 
0133 #define BRM_MBC_IRQ        1                    /* Monitor Block Counter irq */
0134 #define BRM_CBA_IRQ        2                    /* Command Block Accessed irq */
0135 #define BRM_RTF_IRQ        4                    /* Retry Fail irq */
0136 #define BRM_ILLOP_IRQ      8                    /* Illogical Opcode irq */
0137 #define BRM_BC_ILLCMD_IRQ  16                   /* BC Illocigal Command irq */
0138 #define BRM_EOL_IRQ        32                   /* End Of List irq */
0139 #define BRM_RT_ILLCMD_IRQ  128                  /* RT Illegal Command irq */
0140 #define BRM_IXEQ0_IRQ      256                  /* Index Equal Zero irq */
0141 #define BRM_BDRCV_IRQ      512                  /* Broadcast Command Received irq */
0142 #define BRM_SUBAD_IRQ      1024                 /* Subaddress Accessed irq */
0143 #define BRM_MERR_IRQ       2048                 /* Message Error irq */
0144 #define BRM_TAPF_IRQ       8192                 /* Terminal Address Parity Fail irq */
0145 #define BRM_WRAPF_IRQ      16384                /* Wrap Fail irq */
0146 #define BRM_DMAF_IRQ       32768                /* DMA Fail irq */
0147 
0148 
0149 #define BRM_SET_MODE    0
0150 #define BRM_SET_BUS     1
0151 #define BRM_SET_MSGTO   2
0152 #define BRM_SET_RT_ADDR 3
0153 #define BRM_SET_STD     4
0154 #define BRM_SET_BCE     5
0155 #define BRM_TX_BLOCK    7
0156 #define BRM_RX_BLOCK    8
0157 
0158 #define BRM_DO_LIST     10
0159 #define BRM_LIST_DONE   11
0160 
0161 #define BRM_CLR_STATUS  12
0162 #define BRM_GET_STATUS  13
0163 #define BRM_SET_EVENTID 14
0164 
0165 #define GET_ERROR_DESCRIPTOR(event_in) (event_in>>16)
0166 
0167 
0168 #define BRM_MODE_BC 0x0
0169 #define BRM_MODE_RT 0x1
0170 #define BRM_MODE_BM 0x2
0171 #define BRM_MODE_BM_RT 0x3 /* both RT and BM */
0172 
0173 #define BRM_FREQ_12MHZ 0
0174 #define BRM_FREQ_16MHZ 1
0175 #define BRM_FREQ_20MHZ 2
0176 #define BRM_FREQ_24MHZ 3
0177 #define BRM_FREQ_MASK 0x3
0178 
0179 #define CLKDIV_MASK 0xf
0180 
0181 #define CLKSEL_MASK 0x7
0182 
0183 void b1553brm_register_drv(void);
0184 
0185 /* Default initialization of the RT legalization registers. The values in this
0186  * array are written to the registers on boot driver initialization and when
0187  * the user set the mode to RT-mode by calling ioctl(BRM_SET_MODE). Thus,
0188  * update the array first then call ioctl(BRM_SET_MODE) for the changes to have
0189  * an affect. Note that this affects all B1553BRM RTs in the system.
0190  */
0191 extern unsigned short b1553brm_rt_cmd_legalize[16];
0192 
0193 /* Print information about all BRM devices handled by this driver */
0194 void b1553brm_print(int options);
0195 
0196 /* Print information about one BRM device */
0197 void b1553brm_print_dev(struct drvmgr_dev *dev, int options);
0198 
0199 #ifdef __cplusplus
0200 }
0201 #endif
0202 
0203 /** @} */
0204 
0205 #endif /* __BRM_H__ */
0206