1 | /** |
---|
2 | * @file |
---|
3 | * @ingroup sparc_bsp |
---|
4 | * @defgroup 1553 B1553BRM |
---|
5 | * @ingroup 1553 |
---|
6 | * @brief B1553BRM device driver |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * COPYRIGHT (c) 2006. |
---|
11 | * Cobham Gaisler AB. |
---|
12 | * |
---|
13 | * The license and distribution terms for this file may be |
---|
14 | * found in the file LICENSE in this distribution or at |
---|
15 | * http://www.rtems.org/license/LICENSE. |
---|
16 | */ |
---|
17 | |
---|
18 | #ifndef __B1553BRM_H__ |
---|
19 | #define __B1553BRM_H__ |
---|
20 | |
---|
21 | #include <drvmgr/drvmgr.h> |
---|
22 | |
---|
23 | #ifdef __cplusplus |
---|
24 | extern "C" { |
---|
25 | #endif |
---|
26 | |
---|
27 | struct brm_reg { |
---|
28 | volatile unsigned int ctrl; /* 0x00 */ |
---|
29 | volatile unsigned int oper; /* 0x04 */ |
---|
30 | volatile unsigned int cur_cmd; /* 0x08 */ |
---|
31 | volatile unsigned int imask; /* 0x0C */ |
---|
32 | volatile unsigned int ipend; /* 0x10 */ |
---|
33 | volatile unsigned int ipoint; /* 0x14 */ |
---|
34 | volatile unsigned int bit_reg; /* 0x18 */ |
---|
35 | volatile unsigned int ttag; /* 0x1C */ |
---|
36 | volatile unsigned int dpoint; /* 0x20 */ |
---|
37 | volatile unsigned int sw; /* 0x24 */ |
---|
38 | volatile unsigned int initcount; /* 0x28 */ |
---|
39 | volatile unsigned int mcpoint; /* 0x2C */ |
---|
40 | volatile unsigned int mdpoint; /* 0x30 */ |
---|
41 | volatile unsigned int mbc; /* 0x34 */ |
---|
42 | volatile unsigned int mfilta; /* 0x38 */ |
---|
43 | volatile unsigned int mfiltb; /* 0x3C */ |
---|
44 | volatile unsigned int rt_cmd_leg[16]; /* 0x40-0x80 */ |
---|
45 | volatile unsigned int enhanced; /* 0x84 */ |
---|
46 | |
---|
47 | volatile unsigned int dummy[31]; |
---|
48 | |
---|
49 | volatile unsigned int w_ctrl; /* 0x100 */ |
---|
50 | volatile unsigned int w_irqctrl; /* 0x104 */ |
---|
51 | volatile unsigned int w_ahbaddr; /* 0x108 */ |
---|
52 | }; |
---|
53 | |
---|
54 | struct bm_msg { |
---|
55 | unsigned short miw; |
---|
56 | unsigned short cw1; |
---|
57 | unsigned short cw2; |
---|
58 | unsigned short sw1; |
---|
59 | unsigned short sw2; |
---|
60 | unsigned short time; |
---|
61 | unsigned short data[32]; |
---|
62 | }; |
---|
63 | |
---|
64 | struct rt_msg { |
---|
65 | unsigned short miw; |
---|
66 | unsigned short time; |
---|
67 | unsigned short data[32]; |
---|
68 | unsigned short desc; |
---|
69 | }; |
---|
70 | |
---|
71 | /* |
---|
72 | * rtaddr[0] and subaddr[0] : RT address and subaddress (for rt-rt receive addresses) |
---|
73 | * rtaddr[1] and subaddr[1] : Only for RT-RT. Transmit addresses. |
---|
74 | * |
---|
75 | * wc : word count, or mode code if subaddress 0 or 31. |
---|
76 | * |
---|
77 | * ctrl, bit 0 (TR) : 1 - transmit, 0 - receive. Ignored for rt-rt |
---|
78 | * bit 1 (RTRT) : 1 - rt to rt, 0 - normal |
---|
79 | * bit 2 (AB) : 1 - Bus B, 0 - Bus A |
---|
80 | * bit 4:3 (Retry) : 1 - 1, 2 - 2, 3 - 3, 0 - 4 |
---|
81 | * bit 5 (END) : End of list |
---|
82 | * bit 15 (BAME) : Message error. Set by BRM if protocol error is detected |
---|
83 | * |
---|
84 | * tsw[0] : status word |
---|
85 | * tsw[1] : Only for rt-rt, status word 2 |
---|
86 | * |
---|
87 | * data : data to be transmitted, or received data |
---|
88 | * |
---|
89 | */ |
---|
90 | struct bc_msg { |
---|
91 | unsigned char rtaddr[2]; |
---|
92 | unsigned char subaddr[2]; |
---|
93 | unsigned short wc; |
---|
94 | unsigned short ctrl; |
---|
95 | unsigned short tsw[2]; |
---|
96 | unsigned short data[32]; |
---|
97 | }; |
---|
98 | |
---|
99 | /* BC control bits */ |
---|
100 | #define BC_TR 0x0001 |
---|
101 | #define BC_RTRT 0x0002 |
---|
102 | #define BC_BUSA 0x0004 |
---|
103 | #define BC_EOL 0x0020 |
---|
104 | #define BC_SKIP 0x0040 |
---|
105 | #define BC_BAME 0x8000 |
---|
106 | |
---|
107 | #define BRM_MBC_IRQ 1 /* Monitor Block Counter irq */ |
---|
108 | #define BRM_CBA_IRQ 2 /* Command Block Accessed irq */ |
---|
109 | #define BRM_RTF_IRQ 4 /* Retry Fail irq */ |
---|
110 | #define BRM_ILLOP_IRQ 8 /* Illogical Opcode irq */ |
---|
111 | #define BRM_BC_ILLCMD_IRQ 16 /* BC Illocigal Command irq */ |
---|
112 | #define BRM_EOL_IRQ 32 /* End Of List irq */ |
---|
113 | #define BRM_RT_ILLCMD_IRQ 128 /* RT Illegal Command irq */ |
---|
114 | #define BRM_IXEQ0_IRQ 256 /* Index Equal Zero irq */ |
---|
115 | #define BRM_BDRCV_IRQ 512 /* Broadcast Command Received irq */ |
---|
116 | #define BRM_SUBAD_IRQ 1024 /* Subaddress Accessed irq */ |
---|
117 | #define BRM_MERR_IRQ 2048 /* Message Error irq */ |
---|
118 | #define BRM_TAPF_IRQ 8192 /* Terminal Address Parity Fail irq */ |
---|
119 | #define BRM_WRAPF_IRQ 16384 /* Wrap Fail irq */ |
---|
120 | #define BRM_DMAF_IRQ 32768 /* DMA Fail irq */ |
---|
121 | |
---|
122 | |
---|
123 | #define BRM_SET_MODE 0 |
---|
124 | #define BRM_SET_BUS 1 |
---|
125 | #define BRM_SET_MSGTO 2 |
---|
126 | #define BRM_SET_RT_ADDR 3 |
---|
127 | #define BRM_SET_STD 4 |
---|
128 | #define BRM_SET_BCE 5 |
---|
129 | #define BRM_TX_BLOCK 7 |
---|
130 | #define BRM_RX_BLOCK 8 |
---|
131 | |
---|
132 | #define BRM_DO_LIST 10 |
---|
133 | #define BRM_LIST_DONE 11 |
---|
134 | |
---|
135 | #define BRM_CLR_STATUS 12 |
---|
136 | #define BRM_GET_STATUS 13 |
---|
137 | #define BRM_SET_EVENTID 14 |
---|
138 | |
---|
139 | #define GET_ERROR_DESCRIPTOR(event_in) (event_in>>16) |
---|
140 | |
---|
141 | |
---|
142 | #define BRM_MODE_BC 0x0 |
---|
143 | #define BRM_MODE_RT 0x1 |
---|
144 | #define BRM_MODE_BM 0x2 |
---|
145 | #define BRM_MODE_BM_RT 0x3 /* both RT and BM */ |
---|
146 | |
---|
147 | #define BRM_FREQ_12MHZ 0 |
---|
148 | #define BRM_FREQ_16MHZ 1 |
---|
149 | #define BRM_FREQ_20MHZ 2 |
---|
150 | #define BRM_FREQ_24MHZ 3 |
---|
151 | #define BRM_FREQ_MASK 0x3 |
---|
152 | |
---|
153 | #define CLKDIV_MASK 0xf |
---|
154 | |
---|
155 | #define CLKSEL_MASK 0x7 |
---|
156 | |
---|
157 | void b1553brm_register_drv(void); |
---|
158 | |
---|
159 | /* Default initialization of the RT legalization registers. The values in this |
---|
160 | * array are written to the registers on boot driver initialization and when |
---|
161 | * the user set the mode to RT-mode by calling ioctl(BRM_SET_MODE). Thus, |
---|
162 | * update the array first then call ioctl(BRM_SET_MODE) for the changes to have |
---|
163 | * an affect. Note that this affects all B1553BRM RTs in the system. |
---|
164 | */ |
---|
165 | extern unsigned short b1553brm_rt_cmd_legalize[16]; |
---|
166 | |
---|
167 | /* Print information about all BRM devices handled by this driver */ |
---|
168 | void b1553brm_print(int options); |
---|
169 | |
---|
170 | /* Print information about one BRM device */ |
---|
171 | void b1553brm_print_dev(struct drvmgr_dev *dev, int options); |
---|
172 | |
---|
173 | #ifdef __cplusplus |
---|
174 | } |
---|
175 | #endif |
---|
176 | |
---|
177 | #endif /* __BRM_H__ */ |
---|
178 | |
---|