1 ../../../ccat/CCatDefinitions.h |
1 /** |
|
2 Network Driver for Beckhoff CCAT communication controller |
|
3 Copyright (C) 2014 Beckhoff Automation GmbH |
|
4 Author: Patrick Bruenn <p.bruenn@beckhoff.com> |
|
5 |
|
6 This program is free software; you can redistribute it and/or modify |
|
7 it under the terms of the GNU General Public License as published by |
|
8 the Free Software Foundation; either version 2 of the License, or |
|
9 (at your option) any later version. |
|
10 |
|
11 This program is distributed in the hope that it will be useful, |
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
14 GNU General Public License for more details. |
|
15 |
|
16 You should have received a copy of the GNU General Public License along |
|
17 with this program; if not, write to the Free Software Foundation, Inc., |
|
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
|
19 */ |
|
20 #ifndef _CCAT_DEFINITIONS_H_ |
|
21 #define _CCAT_DEFINITIONS_H_ |
|
22 |
|
23 #ifndef WINDOWS |
|
24 #include <linux/kernel.h> |
|
25 typedef uint8_t BYTE; |
|
26 typedef uint32_t ULONG; |
|
27 typedef uint16_t USHORT; |
|
28 typedef uint8_t UINT8; |
|
29 typedef uint16_t UINT16; |
|
30 typedef uint32_t UINT32; |
|
31 typedef uint64_t UINT64; |
|
32 |
|
33 #undef pr_fmt |
|
34 #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt |
|
35 #endif |
|
36 |
|
37 typedef struct _ETHERNET_ADDRESS |
|
38 { |
|
39 UINT8 b[6]; |
|
40 }ETHERNET_ADDRESS; |
|
41 |
|
42 |
|
43 typedef uint64_t LIST_ENTRY; |
|
44 |
|
45 typedef enum CCatInfoTypes |
|
46 { |
|
47 CCATINFO_NOTUSED = 0, |
|
48 CCATINFO_BLOCK = 1, |
|
49 CCATINFO_ETHERCAT_SLAVE = 2, |
|
50 CCATINFO_ETHERCAT_MASTER = 3, |
|
51 CCATINFO_ETHERNET_MAC = 4, |
|
52 CCATINFO_ETHERNET_SWITCH = 5, |
|
53 CCATINFO_SERCOS3 = 6, |
|
54 CCATINFO_PROFIBUS = 7, |
|
55 CCATINFO_CAN_CONTROLLER = 8, |
|
56 CCATINFO_KBUS_MASTER = 9, |
|
57 CCATINFO_IP_LINK = 10, |
|
58 CCATINFO_SPI_MASTER = 11, |
|
59 CCATINFO_I2C_MASTER = 12, |
|
60 CCATINFO_GPIO = 13, |
|
61 CCATINFO_DRIVEIP = 14, |
|
62 CCATINFO_EPCS_PROM = 15, |
|
63 CCATINFO_SYSTIME = 16, |
|
64 CCATINFO_INTCTRL = 17, |
|
65 CCATINFO_EEPROM = 18, |
|
66 CCATINFO_DMA = 19, |
|
67 CCATINFO_ETHERCAT_MASTER_DMA = 20, |
|
68 CCATINFO_ETHERNET_MAC_DMA = 21, |
|
69 CCATINFO_SRAM = 22, |
|
70 CCATINFO_COPY_BLOCK = 23, |
|
71 CCATINFO_MAX |
|
72 } _CCatInfoTypes; |
|
73 |
|
74 typedef struct |
|
75 { |
|
76 USHORT eCCatInfoType; |
|
77 USHORT nRevision; |
|
78 union |
|
79 { |
|
80 ULONG nParam; |
|
81 struct |
|
82 { |
|
83 BYTE nMaxEntries; |
|
84 BYTE compileDay; |
|
85 BYTE compileMonth; |
|
86 BYTE compileYear; |
|
87 }; |
|
88 struct |
|
89 { |
|
90 BYTE txDmaChn; |
|
91 BYTE rxDmaChn; |
|
92 }; |
|
93 struct |
|
94 { |
|
95 BYTE nExternalDataSize : 2; |
|
96 BYTE reserved1 : 6; |
|
97 BYTE nRamSize; //size = 2^ramSize |
|
98 USHORT reserved2; |
|
99 }; |
|
100 }; |
|
101 ULONG nAddr; |
|
102 ULONG nSize; |
|
103 } CCatInfoBlock, *PCCatInfoBlock; |
|
104 |
|
105 typedef struct _CCAT_HEADER_TAG |
|
106 { |
|
107 UINT16 length; // not used in header // required for 64 Bit Alignment in CCAT |
|
108 UINT8 port0 : 1; |
|
109 UINT8 port1 : 1; |
|
110 UINT8 reserved1 : 6; |
|
111 UINT8 tsEnable : 1; |
|
112 UINT8 reserved2 : 7; |
|
113 UINT32 sent : 1; |
|
114 UINT32 reserved3 : 31; |
|
115 UINT64 TimeStamp; |
|
116 }CCAT_HEADER_TAG; |
|
117 |
|
118 typedef struct _CCatDmaTxFrame |
|
119 { |
|
120 LIST_ENTRY list; |
|
121 CCAT_HEADER_TAG head; |
|
122 UINT8 data[0x800-sizeof(LIST_ENTRY)-sizeof(CCAT_HEADER_TAG)]; |
|
123 }CCatDmaTxFrame; |
|
124 |
|
125 typedef struct _CCatRxDesc |
|
126 { |
|
127 union |
|
128 { |
|
129 struct |
|
130 { |
|
131 UINT32 nextDesc : 24; |
|
132 UINT32 reserved1 : 7; |
|
133 UINT32 nextValid : 1; |
|
134 UINT32 received : 1; |
|
135 UINT32 reserved2 : 31; |
|
136 }; |
|
137 UINT32 head[2]; |
|
138 }; |
|
139 union |
|
140 { |
|
141 struct |
|
142 { |
|
143 UINT16 length : 12; |
|
144 UINT16 reserved3 : 4; |
|
145 }; |
|
146 UINT16 uLength; |
|
147 }; |
|
148 UINT16 port; |
|
149 UINT32 reserved4; |
|
150 UINT64 timestamp; |
|
151 UINT8 data[0x7e8]; |
|
152 }CCatRxDesc; |
|
153 |
|
154 typedef struct _CCatMacRegs |
|
155 { |
|
156 union |
|
157 { |
|
158 struct |
|
159 { |
|
160 UINT8 frameLenErrCnt; |
|
161 UINT8 rxErrCnt; |
|
162 UINT8 crcErrCnt; |
|
163 UINT8 linkLostErrCnt; |
|
164 }; |
|
165 UINT32 errCnt; |
|
166 }; |
|
167 UINT32 reserved1; |
|
168 UINT8 dropFrameErrCnt; // 0x08 |
|
169 UINT8 reserved2[7]; |
|
170 UINT32 txFrameCnt; // 0x10 |
|
171 UINT32 rxFrameCnt; // 0x14 |
|
172 UINT32 reserved3[2]; |
|
173 UINT8 txFifoLevel : 7; |
|
174 UINT8 reserved4 : 1; |
|
175 UINT8 reserved5[7]; |
|
176 UINT8 txErrMemFull; |
|
177 UINT8 reserved6[7]; |
|
178 UINT32 reserved8[18]; |
|
179 UINT8 miiConnected; |
|
180 }CCatMacRegs; |
|
181 |
|
182 typedef struct _CCatMii |
|
183 { |
|
184 USHORT startMiCycle : 1; |
|
185 USHORT reserved1 : 6; |
|
186 USHORT cmdErr : 1; |
|
187 #define MII_CMD_READ 1 |
|
188 #define MII_CMD_WRITE 2 |
|
189 USHORT cmd : 2; |
|
190 USHORT reserved2 : 6; |
|
191 USHORT phyAddr : 5; |
|
192 USHORT reserved3 : 3; |
|
193 USHORT phyReg : 5; |
|
194 USHORT reserved4 : 3; |
|
195 USHORT phyWriteData; |
|
196 USHORT phyReadData; |
|
197 ETHERNET_ADDRESS macAddr; |
|
198 USHORT macFilterEnabled : 1; |
|
199 USHORT reserved6 : 7; |
|
200 USHORT linkStatus : 1; |
|
201 USHORT reserved7 : 7; |
|
202 ULONG led0; |
|
203 ULONG led1; |
|
204 ULONG led2[2]; |
|
205 ULONG systimeInsertion[4]; |
|
206 ULONG interruptState[2]; |
|
207 ULONG interruptMask[2]; |
|
208 }CCatMii; |
|
209 |
|
210 typedef struct _CCatDmaTxFifo |
|
211 { |
|
212 UINT32 startAddr : 24; |
|
213 UINT32 numQuadWords : 8; |
|
214 UINT32 reserved1; |
|
215 UINT8 fifoReset; |
|
216 UINT8 reserved2[7]; |
|
217 }CCatDmaTxFifo; |
|
218 |
|
219 typedef struct _CCatDmaRxActBuf |
|
220 { |
|
221 union |
|
222 { |
|
223 struct |
|
224 { |
|
225 UINT32 startAddr : 24; |
|
226 UINT32 reserved1 : 7; |
|
227 UINT32 nextValid : 1; |
|
228 UINT32 lastAddr : 24; |
|
229 UINT32 reserved2 : 8; |
|
230 UINT32 FifoLevel : 24; |
|
231 UINT32 bufferLevel : 8; |
|
232 UINT32 nextAddr; |
|
233 }; |
|
234 UINT32 rxActBuf; |
|
235 }; |
|
236 }CCatDmaRxActBuf; |
|
237 |
|
238 typedef struct _CCatInfoBlockOffs |
|
239 { |
|
240 UINT32 reserved; |
|
241 UINT32 nMMIOffs; |
|
242 UINT32 nTxFifoOffs; |
|
243 UINT32 nMacRegOffs; |
|
244 UINT32 nRxMemOffs; |
|
245 UINT32 nTxMemOffs; |
|
246 UINT32 nMiscOffs; |
|
247 } CCatInfoBlockOffs; |
|
248 #endif /* #ifndef _CCAT_DEFINITIONS_H_ */ |
|
249 |