p@2550: /**
p@2550: Network Driver for Beckhoff CCAT communication controller
p@2550: Copyright (C) 2014 Beckhoff Automation GmbH
p@2550: Author: Patrick Bruenn
p@2550:
p@2550: This program is free software; you can redistribute it and/or modify
p@2550: it under the terms of the GNU General Public License as published by
p@2550: the Free Software Foundation; either version 2 of the License, or
p@2550: (at your option) any later version.
p@2550:
p@2550: This program is distributed in the hope that it will be useful,
p@2550: but WITHOUT ANY WARRANTY; without even the implied warranty of
p@2550: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
p@2550: GNU General Public License for more details.
p@2550:
p@2550: You should have received a copy of the GNU General Public License along
p@2550: with this program; if not, write to the Free Software Foundation, Inc.,
p@2550: 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
p@2550: */
p@2550: #ifndef _CCAT_DEFINITIONS_H_
p@2550: #define _CCAT_DEFINITIONS_H_
p@2550:
p@2550: #ifndef WINDOWS
p@2550: #include
p@2550: typedef uint8_t BYTE;
p@2550: typedef uint32_t ULONG;
p@2550: typedef uint16_t USHORT;
p@2550: typedef uint8_t UINT8;
p@2550: typedef uint16_t UINT16;
p@2550: typedef uint32_t UINT32;
p@2550: typedef uint64_t UINT64;
p@2550:
p@2550: #undef pr_fmt
p@2550: #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
p@2550: #endif
p@2550:
p@2550: typedef struct _ETHERNET_ADDRESS
p@2550: {
p@2550: UINT8 b[6];
p@2550: }ETHERNET_ADDRESS;
p@2550:
p@2550:
p@2550: typedef uint64_t LIST_ENTRY;
p@2550:
p@2550: typedef enum CCatInfoTypes
p@2550: {
p@2550: CCATINFO_NOTUSED = 0,
p@2550: CCATINFO_BLOCK = 1,
p@2550: CCATINFO_ETHERCAT_SLAVE = 2,
p@2550: CCATINFO_ETHERCAT_MASTER = 3,
p@2550: CCATINFO_ETHERNET_MAC = 4,
p@2550: CCATINFO_ETHERNET_SWITCH = 5,
p@2550: CCATINFO_SERCOS3 = 6,
p@2550: CCATINFO_PROFIBUS = 7,
p@2550: CCATINFO_CAN_CONTROLLER = 8,
p@2550: CCATINFO_KBUS_MASTER = 9,
p@2550: CCATINFO_IP_LINK = 10,
p@2550: CCATINFO_SPI_MASTER = 11,
p@2550: CCATINFO_I2C_MASTER = 12,
p@2550: CCATINFO_GPIO = 13,
p@2550: CCATINFO_DRIVEIP = 14,
p@2550: CCATINFO_EPCS_PROM = 15,
p@2550: CCATINFO_SYSTIME = 16,
p@2550: CCATINFO_INTCTRL = 17,
p@2550: CCATINFO_EEPROM = 18,
p@2550: CCATINFO_DMA = 19,
p@2550: CCATINFO_ETHERCAT_MASTER_DMA = 20,
p@2550: CCATINFO_ETHERNET_MAC_DMA = 21,
p@2550: CCATINFO_SRAM = 22,
p@2550: CCATINFO_COPY_BLOCK = 23,
p@2550: CCATINFO_MAX
p@2550: } _CCatInfoTypes;
p@2550:
p@2550: typedef struct
p@2550: {
p@2550: USHORT eCCatInfoType;
p@2550: USHORT nRevision;
p@2550: union
p@2550: {
p@2550: ULONG nParam;
p@2550: struct
p@2550: {
p@2550: BYTE nMaxEntries;
p@2550: BYTE compileDay;
p@2550: BYTE compileMonth;
p@2550: BYTE compileYear;
p@2550: };
p@2550: struct
p@2550: {
p@2550: BYTE txDmaChn;
p@2550: BYTE rxDmaChn;
p@2550: };
p@2550: struct
p@2550: {
p@2550: BYTE nExternalDataSize : 2;
p@2550: BYTE reserved1 : 6;
p@2550: BYTE nRamSize; //size = 2^ramSize
p@2550: USHORT reserved2;
p@2550: };
p@2550: };
p@2550: ULONG nAddr;
p@2550: ULONG nSize;
p@2550: } CCatInfoBlock, *PCCatInfoBlock;
p@2550:
p@2550: typedef struct _CCAT_HEADER_TAG
p@2550: {
p@2550: UINT16 length; // not used in header // required for 64 Bit Alignment in CCAT
p@2550: UINT8 port0 : 1;
p@2550: UINT8 port1 : 1;
p@2550: UINT8 reserved1 : 6;
p@2550: UINT8 tsEnable : 1;
p@2550: UINT8 reserved2 : 7;
p@2550: UINT32 sent : 1;
p@2550: UINT32 reserved3 : 31;
p@2550: UINT64 TimeStamp;
p@2550: }CCAT_HEADER_TAG;
p@2550:
p@2550: typedef struct _CCatDmaTxFrame
p@2550: {
p@2550: LIST_ENTRY list;
p@2550: CCAT_HEADER_TAG head;
p@2550: UINT8 data[0x800-sizeof(LIST_ENTRY)-sizeof(CCAT_HEADER_TAG)];
p@2550: }CCatDmaTxFrame;
p@2550:
p@2550: typedef struct _CCatRxDesc
p@2550: {
p@2550: union
p@2550: {
p@2550: struct
p@2550: {
p@2550: UINT32 nextDesc : 24;
p@2550: UINT32 reserved1 : 7;
p@2550: UINT32 nextValid : 1;
p@2550: UINT32 received : 1;
p@2550: UINT32 reserved2 : 31;
p@2550: };
p@2550: UINT32 head[2];
p@2550: };
p@2550: union
p@2550: {
p@2550: struct
p@2550: {
p@2550: UINT16 length : 12;
p@2550: UINT16 reserved3 : 4;
p@2550: };
p@2550: UINT16 uLength;
p@2550: };
p@2550: UINT16 port;
p@2550: UINT32 reserved4;
p@2550: UINT64 timestamp;
p@2550: UINT8 data[0x7e8];
p@2550: }CCatRxDesc;
p@2550:
p@2550: typedef struct _CCatMacRegs
p@2550: {
p@2550: union
p@2550: {
p@2550: struct
p@2550: {
p@2550: UINT8 frameLenErrCnt;
p@2550: UINT8 rxErrCnt;
p@2550: UINT8 crcErrCnt;
p@2550: UINT8 linkLostErrCnt;
p@2550: };
p@2550: UINT32 errCnt;
p@2550: };
p@2550: UINT32 reserved1;
p@2550: UINT8 dropFrameErrCnt; // 0x08
p@2550: UINT8 reserved2[7];
p@2550: UINT32 txFrameCnt; // 0x10
p@2550: UINT32 rxFrameCnt; // 0x14
p@2550: UINT32 reserved3[2];
p@2550: UINT8 txFifoLevel : 7;
p@2550: UINT8 reserved4 : 1;
p@2550: UINT8 reserved5[7];
p@2550: UINT8 txErrMemFull;
p@2550: UINT8 reserved6[7];
p@2550: UINT32 reserved8[18];
p@2550: UINT8 miiConnected;
p@2550: }CCatMacRegs;
p@2550:
p@2550: typedef struct _CCatMii
p@2550: {
p@2550: USHORT startMiCycle : 1;
p@2550: USHORT reserved1 : 6;
p@2550: USHORT cmdErr : 1;
p@2550: #define MII_CMD_READ 1
p@2550: #define MII_CMD_WRITE 2
p@2550: USHORT cmd : 2;
p@2550: USHORT reserved2 : 6;
p@2550: USHORT phyAddr : 5;
p@2550: USHORT reserved3 : 3;
p@2550: USHORT phyReg : 5;
p@2550: USHORT reserved4 : 3;
p@2550: USHORT phyWriteData;
p@2550: USHORT phyReadData;
p@2550: ETHERNET_ADDRESS macAddr;
p@2550: USHORT macFilterEnabled : 1;
p@2550: USHORT reserved6 : 7;
p@2550: USHORT linkStatus : 1;
p@2550: USHORT reserved7 : 7;
p@2550: ULONG led0;
p@2550: ULONG led1;
p@2550: ULONG led2[2];
p@2550: ULONG systimeInsertion[4];
p@2550: ULONG interruptState[2];
p@2550: ULONG interruptMask[2];
p@2550: }CCatMii;
p@2550:
p@2550: typedef struct _CCatDmaTxFifo
p@2550: {
p@2550: UINT32 startAddr : 24;
p@2550: UINT32 numQuadWords : 8;
p@2550: UINT32 reserved1;
p@2550: UINT8 fifoReset;
p@2550: UINT8 reserved2[7];
p@2550: }CCatDmaTxFifo;
p@2550:
p@2550: typedef struct _CCatDmaRxActBuf
p@2550: {
p@2550: union
p@2550: {
p@2550: struct
p@2550: {
p@2550: UINT32 startAddr : 24;
p@2550: UINT32 reserved1 : 7;
p@2550: UINT32 nextValid : 1;
p@2550: UINT32 lastAddr : 24;
p@2550: UINT32 reserved2 : 8;
p@2550: UINT32 FifoLevel : 24;
p@2550: UINT32 bufferLevel : 8;
p@2550: UINT32 nextAddr;
p@2550: };
p@2550: UINT32 rxActBuf;
p@2550: };
p@2550: }CCatDmaRxActBuf;
p@2550:
p@2550: typedef struct _CCatInfoBlockOffs
p@2550: {
p@2550: UINT32 reserved;
p@2550: UINT32 nMMIOffs;
p@2550: UINT32 nTxFifoOffs;
p@2550: UINT32 nMacRegOffs;
p@2550: UINT32 nRxMemOffs;
p@2550: UINT32 nTxMemOffs;
p@2550: UINT32 nMiscOffs;
p@2550: } CCatInfoBlockOffs;
p@2550: #endif /* #ifndef _CCAT_DEFINITIONS_H_ */
p@2550: