devices/ccat/CCatDefinitions.h
branchstable-1.5
changeset 2556 674fcdccc0f3
parent 2551 000da5069f1a
child 2567 d70aad2f131f
equal deleted inserted replaced
2540:fca12d7035d1 2556:674fcdccc0f3
       
     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 #endif
       
    33 
       
    34 #define CCAT_DMA_FRAME_HEADER_LENGTH (196 / 8) // 196 bit
       
    35 
       
    36 typedef struct _ETHERNET_ADDRESS
       
    37 {
       
    38 	UINT8 b[6];
       
    39 }ETHERNET_ADDRESS;
       
    40 
       
    41 typedef enum CCatInfoTypes
       
    42 {
       
    43 	CCATINFO_NOTUSED				= 0,
       
    44 	CCATINFO_BLOCK					= 1,
       
    45 	CCATINFO_ETHERCAT_SLAVE		= 2,
       
    46 	CCATINFO_ETHERCAT_MASTER	= 3,
       
    47 	CCATINFO_ETHERNET_MAC		= 4,
       
    48 	CCATINFO_ETHERNET_SWITCH	= 5,
       
    49 	CCATINFO_SERCOS3				= 6,
       
    50 	CCATINFO_PROFIBUS				= 7,
       
    51 	CCATINFO_CAN_CONTROLLER		= 8,
       
    52 	CCATINFO_KBUS_MASTER			= 9,
       
    53 	CCATINFO_IP_LINK				= 10,
       
    54 	CCATINFO_SPI_MASTER			= 11,
       
    55 	CCATINFO_I2C_MASTER			= 12,
       
    56 	CCATINFO_GPIO					= 13,
       
    57 	CCATINFO_DRIVEIP				= 14,
       
    58 	CCATINFO_EPCS_PROM			= 15,
       
    59 	CCATINFO_SYSTIME				= 16,
       
    60 	CCATINFO_INTCTRL				= 17,
       
    61 	CCATINFO_EEPROM				= 18,
       
    62 	CCATINFO_DMA					= 19,
       
    63 	CCATINFO_ETHERCAT_MASTER_DMA	= 20,
       
    64 	CCATINFO_ETHERNET_MAC_DMA		= 21,
       
    65 	CCATINFO_SRAM					= 22,
       
    66 	CCATINFO_COPY_BLOCK			= 23,
       
    67 	CCATINFO_MAX
       
    68 } _CCatInfoTypes;
       
    69 
       
    70 typedef struct
       
    71 {
       
    72 	USHORT	eCCatInfoType;
       
    73 	USHORT	nRevision;
       
    74 	union
       
    75 	{
       
    76 		ULONG		nParam;
       
    77 		struct
       
    78 		{
       
    79 			BYTE nMaxEntries;
       
    80 			BYTE compileDay;
       
    81 			BYTE compileMonth;
       
    82 			BYTE compileYear;
       
    83 		};
       
    84 		struct
       
    85 		{
       
    86 			BYTE txDmaChn;
       
    87 			BYTE rxDmaChn;
       
    88 		};
       
    89 		struct
       
    90 		{
       
    91 			BYTE		nExternalDataSize	: 2;
       
    92 			BYTE		reserved1			: 6;
       
    93 			BYTE		nRamSize; //size = 2^ramSize
       
    94 			USHORT	reserved2;
       
    95 		};
       
    96 	};
       
    97 	ULONG		nAddr;
       
    98 	ULONG		nSize;
       
    99 } CCatInfoBlock, *PCCatInfoBlock;
       
   100 
       
   101 typedef struct _CCatMacRegs
       
   102 {
       
   103 	union
       
   104 	{
       
   105 		struct
       
   106 		{
       
   107 			UINT8			frameLenErrCnt;
       
   108 			UINT8			rxErrCnt;
       
   109 			UINT8			crcErrCnt;
       
   110 			UINT8			linkLostErrCnt;
       
   111 		};
       
   112 		UINT32 errCnt;
       
   113 	};
       
   114 	UINT32			reserved1;
       
   115 	UINT8				dropFrameErrCnt; // 0x08
       
   116 	UINT8				reserved2[7];
       
   117 	UINT32			txFrameCnt;		  // 0x10
       
   118 	UINT32			rxFrameCnt;		  // 0x14
       
   119 	UINT32   reserved3[2];
       
   120 	UINT8    txFifoLevel  : 7;
       
   121 	UINT8    reserved4    : 1;
       
   122 	UINT8    reserved5[7];
       
   123 	UINT8    txErrMemFull;
       
   124 	UINT8    reserved6[7];
       
   125 	UINT32   reserved8[18];
       
   126 	UINT8    miiConnected;
       
   127 }CCatMacRegs;
       
   128 
       
   129 typedef struct _CCatMii
       
   130 {
       
   131 	USHORT		startMiCycle	: 1;
       
   132 	USHORT		reserved1		: 6;
       
   133 	USHORT		cmdErr			: 1;
       
   134 #define MII_CMD_READ 1
       
   135 #define MII_CMD_WRITE 2
       
   136 	USHORT		cmd				: 2;
       
   137 	USHORT		reserved2		: 6;
       
   138 	USHORT		phyAddr			: 5;
       
   139 	USHORT		reserved3		: 3;
       
   140 	USHORT		phyReg			: 5;
       
   141 	USHORT		reserved4		: 3;
       
   142 	USHORT		phyWriteData;
       
   143 	USHORT		phyReadData;
       
   144 	ETHERNET_ADDRESS	macAddr;
       
   145 	USHORT		macFilterEnabled		: 1;
       
   146 	USHORT		reserved6				: 7;
       
   147 	USHORT		linkStatus				: 1;
       
   148 	USHORT		reserved7				: 7;
       
   149 	ULONG       led0;
       
   150 	ULONG       led1;
       
   151 	ULONG       led2[2];
       
   152 	ULONG       systimeInsertion[4];
       
   153 	ULONG		interruptState[2];
       
   154 	ULONG		interruptMask[2];
       
   155 }CCatMii;
       
   156 
       
   157 typedef struct _CCatDmaTxFifo
       
   158 {
       
   159 	UINT32   startAddr      : 24;
       
   160 	UINT32   numQuadWords   : 8;
       
   161 	UINT32   reserved1;
       
   162 	UINT8    fifoReset;
       
   163 	UINT8    reserved2[7];
       
   164 }CCatDmaTxFifo;
       
   165 
       
   166 typedef union _CCatDmaRxActBuf
       
   167 {
       
   168 	struct
       
   169 	{
       
   170 		UINT32			startAddr	: 24;
       
   171 		UINT32			reserved1	: 7;
       
   172 		UINT32			nextValid	: 1;
       
   173 		UINT32			lastAddr		: 24;
       
   174 		UINT32			reserved2	: 8;
       
   175 		UINT32			FifoLevel	: 24;
       
   176 		UINT32			bufferLevel	: 8;
       
   177 		UINT32			nextAddr;
       
   178 	};
       
   179 	UINT32			rxActBuf;
       
   180 }CCatDmaRxActBuf;
       
   181 
       
   182 typedef struct _CCatInfoBlockOffs
       
   183 {
       
   184 	UINT32			reserved;
       
   185 	UINT32			nMMIOffs;
       
   186 	UINT32			nTxFifoOffs;
       
   187 	UINT32			nMacRegOffs;
       
   188 	UINT32			nRxMemOffs;
       
   189 	UINT32			nTxMemOffs;
       
   190 	UINT32			nMiscOffs;
       
   191 } CCatInfoBlockOffs;
       
   192 #endif /* #ifndef _CCAT_DEFINITIONS_H_ */
       
   193