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