1 /******************************************************************************
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
7 * Purpose: First header file for driver and all other modules
9 ******************************************************************************/
11 /******************************************************************************
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
15 * This program is free software; you can redistribute it and/or modify
16 * it under the terms of the GNU General Public License as published by
17 * the Free Software Foundation; either version 2 of the License, or
18 * (at your option) any later version.
20 * The information in this file is provided "AS IS" without warranty.
22 ******************************************************************************/
24 /******************************************************************************
29 * Revision 1.1.1.1 2011-02-28 14:37:53 lothar
30 * imported U-Boot Release 2009.08 from Freescale BSP L2.6.31_10.08.01
32 * Revision 1.11 2003/02/25 14:16:40 mlindner
33 * Fix: Copyright statement
35 * Revision 1.10 2002/10/02 12:46:02 mlindner
36 * Add: Support for Yukon
38 * Revision 1.9.2.2 2001/12/07 12:06:42 mlindner
39 * Fix: malloc -> slab changes
41 * Revision 1.9.2.1 2001/03/12 16:50:59 mlindner
42 * chg: kernel 2.4 adaption
44 * Revision 1.9 2001/01/22 14:16:04 mlindner
45 * added ProcFs functionality
46 * Dual Net functionality integrated
49 * Revision 1.8 2000/02/21 12:19:18 cgoos
50 * Added default for SK_DEBUG_CHKMOD/_CHKCAT
52 * Revision 1.7 1999/11/22 13:50:00 cgoos
53 * Changed license header to GPL.
54 * Added overwrite for several functions.
55 * Removed linux 2.0.x definitions.
56 * Removed PCI vendor ID definition (now in kernel).
58 * Revision 1.6 1999/07/27 08:03:33 cgoos
59 * Changed SK_IN/OUT macros to readX/writeX instead of memory
60 * accesses (necessary for ALPHA).
62 * Revision 1.5 1999/07/23 12:10:21 cgoos
63 * Removed SK_RLMT_SLOW_LOOKAHEAD define.
65 * Revision 1.4 1999/07/14 12:31:13 cgoos
66 * Added SK_RLMT_SLOW_LOOKAHEAD define.
68 * Revision 1.3 1999/04/07 10:12:54 cgoos
69 * Added check for KERNEL and OPTIMIZATION defines.
71 * Revision 1.2 1999/03/01 08:51:47 cgoos
72 * Fixed pcibios_read/write definitions.
74 * Revision 1.1 1999/02/16 07:40:49 cgoos
79 ******************************************************************************/
81 /******************************************************************************
85 * This is the first include file of the driver, which includes all
86 * neccessary system header files and some of the GEnesis header files.
87 * It also defines some basic items.
89 * Include File Hierarchy:
93 ******************************************************************************/
95 #ifndef __INC_SKDRV1ST_H
96 #define __INC_SKDRV1ST_H
99 /* Check kernel version */
100 #include <linux/version.h>
101 #if (LINUX_VERSION_CODE > 0x020300)
105 typedef struct s_AC SK_AC;
107 /* override some default functions with optimized linux functions */
109 #define SK_PNMI_STORE_U16(p,v) memcpy((char*)(p),(char*)&(v),2)
110 #define SK_PNMI_STORE_U32(p,v) memcpy((char*)(p),(char*)&(v),4)
111 #define SK_PNMI_STORE_U64(p,v) memcpy((char*)(p),(char*)&(v),8)
112 #define SK_PNMI_READ_U16(p,v) memcpy((char*)&(v),(char*)(p),2)
113 #define SK_PNMI_READ_U32(p,v) memcpy((char*)&(v),(char*)(p),2)
114 #define SK_PNMI_READ_U64(p,v) memcpy((char*)&(v),(char*)(p),2)
116 #define SkCsCalculateChecksum(p,l) ((~ip_compute_csum(p, l)) & 0xffff)
118 #define SK_ADDR_EQUAL(a1,a2) (!memcmp(a1,a2,6))
121 #if !defined(__OPTIMIZE__) || !defined(__KERNEL__)
122 #warning You must compile this file with the correct options!
123 #warning See the last lines of the source file.
124 #error You must compile this driver with "-O".
128 #include <linux/version.h>
130 #include <linux/types.h>
132 #include <linux/kernel.h>
134 #include <linux/string.h>
136 #include <linux/errno.h>
137 #include <linux/ioport.h>
138 #include <linux/slab.h>
139 #include <linux/interrupt.h>
140 #include <linux/pci.h>
142 #include <asm/byteorder.h>
143 #include <asm/bitops.h>
146 #include <linux/netdevice.h>
147 #include <linux/etherdevice.h>
148 #include <linux/skbuff.h>
150 #include <linux/init.h>
151 #include <asm/uaccess.h>
152 #include <net/checksum.h>
155 #include "h/sktypes.h"
156 #include "h/skerror.h"
157 #include "h/skdebug.h"
159 #include "h/xmac_ii.h"
161 #include "u-boot_compat.h"
163 #ifdef __LITTLE_ENDIAN
164 #define SK_LITTLE_ENDIAN
166 #define SK_BIG_ENDIAN
170 #define SK_NET_DEVICE net_device
172 #define SK_NET_DEVICE eth_device
176 /* we use gethrtime(), return unit: nanoseconds */
178 #define SK_TICKS_PER_SEC HZ
180 #define SK_TICKS_PER_SEC CONFIG_SYS_HZ
183 #define SK_MEM_MAPPED_IO
185 /* #define SK_RLMT_SLOW_LOOKAHEAD */
187 #define SK_MAX_MACS 2
188 #define SK_MAX_NETS 2
192 typedef struct s_DrvRlmtMbuf SK_MBUF;
194 #define SK_CONST64 INT64_C
195 #define SK_CONSTU64 UINT64_C
197 #define SK_MEMCPY(dest,src,size) memcpy(dest,src,size)
198 #define SK_MEMCMP(s1,s2,size) memcmp(s1,s2,size)
199 #define SK_MEMSET(dest,val,size) memset(dest,val,size)
200 #define SK_STRLEN(pStr) strlen((char*)(pStr))
201 #define SK_STRNCPY(pDest,pSrc,size) strncpy((char*)(pDest),(char*)(pSrc),size)
202 #define SK_STRCMP(pStr1,pStr2) strcmp((char*)(pStr1),(char*)(pStr2))
204 /* macros to access the adapter */
205 #define SK_OUT8(b,a,v) writeb((v), ((b)+(a)))
206 #define SK_OUT16(b,a,v) writew((v), ((b)+(a)))
207 #define SK_OUT32(b,a,v) writel((v), ((b)+(a)))
208 #define SK_IN8(b,a,pv) (*(pv) = readb((b)+(a)))
209 #define SK_IN16(b,a,pv) (*(pv) = readw((b)+(a)))
210 #define SK_IN32(b,a,pv) (*(pv) = readl((b)+(a)))
213 #define int16_t short
215 #define int64_t long long
216 #define uint8_t u_char
217 #define uint16_t u_short
218 #define uint32_t u_long
219 #define uint64_t unsigned long long
220 #define t_scalar_t int
221 #define t_uscalar_t unsigned int
222 #define uintptr_t unsigned long
224 #define __CONCAT__(A,B) A##B
226 #define INT32_C(a) __CONCAT__(a,L)
227 #define INT64_C(a) __CONCAT__(a,LL)
228 #define UINT32_C(a) __CONCAT__(a,UL)
229 #define UINT64_C(a) __CONCAT__(a,ULL)
232 #define SK_DBG_PRINTF printk
233 #ifndef SK_DEBUG_CHKMOD
234 #define SK_DEBUG_CHKMOD 0
236 #ifndef SK_DEBUG_CHKCAT
237 #define SK_DEBUG_CHKCAT 0
239 /* those come from the makefile */
240 #define SK_DBG_CHKMOD(pAC) (SK_DEBUG_CHKMOD)
241 #define SK_DBG_CHKCAT(pAC) (SK_DEBUG_CHKCAT)
243 extern void SkDbgPrintf(const char *format,...);
245 #define SK_DBGMOD_DRV 0x00010000
247 /**** possible driver debug categories ********************************/
248 #define SK_DBGCAT_DRV_ENTRY 0x00010000
249 #define SK_DBGCAT_DRV_SAP 0x00020000
250 #define SK_DBGCAT_DRV_MCA 0x00040000
251 #define SK_DBGCAT_DRV_TX_PROGRESS 0x00080000
252 #define SK_DBGCAT_DRV_RX_PROGRESS 0x00100000
253 #define SK_DBGCAT_DRV_PROGRESS 0x00200000
254 #define SK_DBGCAT_DRV_MSG 0x00400000
255 #define SK_DBGCAT_DRV_PROM 0x00800000
256 #define SK_DBGCAT_DRV_TX_FRAME 0x01000000
257 #define SK_DBGCAT_DRV_ERROR 0x02000000
258 #define SK_DBGCAT_DRV_INT_SRC 0x04000000
259 #define SK_DBGCAT_DRV_EVENT 0x08000000
263 #define SK_ERR_LOG SkErrorLog
265 extern void SkErrorLog(SK_AC*, int, int, char*);