aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/sk98lin/h/skvpd.h
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/sk98lin/h/skvpd.h')
-rw-r--r--drivers/net/sk98lin/h/skvpd.h271
1 files changed, 271 insertions, 0 deletions
diff --git a/drivers/net/sk98lin/h/skvpd.h b/drivers/net/sk98lin/h/skvpd.h
new file mode 100644
index 000000000000..bdc1a5eaaae9
--- /dev/null
+++ b/drivers/net/sk98lin/h/skvpd.h
@@ -0,0 +1,271 @@
1/******************************************************************************
2 *
3 * Name: skvpd.h
4 * Project: GEnesis, PCI Gigabit Ethernet Adapter
5 * Version: $Revision: 1.15 $
6 * Date: $Date: 2003/01/13 10:39:38 $
7 * Purpose: Defines and Macros for VPD handling
8 *
9 ******************************************************************************/
10
11/******************************************************************************
12 *
13 * (C)Copyright 1998-2003 SysKonnect GmbH.
14 *
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.
19 *
20 * The information in this file is provided "AS IS" without warranty.
21 *
22 ******************************************************************************/
23
24/*
25 * skvpd.h contains Diagnostic specific defines for VPD handling
26 */
27
28#ifndef __INC_SKVPD_H_
29#define __INC_SKVPD_H_
30
31/*
32 * Define Resource Type Identifiers and VPD keywords
33 */
34#define RES_ID 0x82 /* Resource Type ID String (Product Name) */
35#define RES_VPD_R 0x90 /* start of VPD read only area */
36#define RES_VPD_W 0x91 /* start of VPD read/write area */
37#define RES_END 0x78 /* Resource Type End Tag */
38
39#ifndef VPD_NAME
40#define VPD_NAME "Name" /* Product Name, VPD name of RES_ID */
41#endif /* VPD_NAME */
42#define VPD_PN "PN" /* Adapter Part Number */
43#define VPD_EC "EC" /* Adapter Engineering Level */
44#define VPD_MN "MN" /* Manufacture ID */
45#define VPD_SN "SN" /* Serial Number */
46#define VPD_CP "CP" /* Extended Capability */
47#define VPD_RV "RV" /* Checksum and Reserved */
48#define VPD_YA "YA" /* Asset Tag Identifier */
49#define VPD_VL "VL" /* First Error Log Message (SK specific) */
50#define VPD_VF "VF" /* Second Error Log Message (SK specific) */
51#define VPD_RW "RW" /* Remaining Read / Write Area */
52
53/* 'type' values for vpd_setup_para() */
54#define VPD_RO_KEY 1 /* RO keys are "PN", "EC", "MN", "SN", "RV" */
55#define VPD_RW_KEY 2 /* RW keys are "Yx", "Vx", and "RW" */
56
57/* 'op' values for vpd_setup_para() */
58#define ADD_KEY 1 /* add the key at the pos "RV" or "RW" */
59#define OWR_KEY 2 /* overwrite key if already exists */
60
61/*
62 * Define READ and WRITE Constants.
63 */
64
65#define VPD_DEV_ID_GENESIS 0x4300
66
67#define VPD_SIZE_YUKON 256
68#define VPD_SIZE_GENESIS 512
69#define VPD_SIZE 512
70#define VPD_READ 0x0000
71#define VPD_WRITE 0x8000
72
73#define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
74
75#define VPD_GET_RES_LEN(p) ((unsigned int) \
76 (* (SK_U8 *)&(p)[1]) |\
77 ((* (SK_U8 *)&(p)[2]) << 8))
78#define VPD_GET_VPD_LEN(p) ((unsigned int)(* (SK_U8 *)&(p)[2]))
79#define VPD_GET_VAL(p) ((char *)&(p)[3])
80
81#define VPD_MAX_LEN 50
82
83/* VPD status */
84 /* bit 7..1 reserved */
85#define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */
86 /* and vpd_free_rw valid */
87
88/*
89 * VPD structs
90 */
91typedef struct s_vpd_status {
92 unsigned short Align01; /* Alignment */
93 unsigned short vpd_status; /* VPD status, description see above */
94 int vpd_free_ro; /* unused bytes in read only area */
95 int vpd_free_rw; /* bytes available in read/write area */
96} SK_VPD_STATUS;
97
98typedef struct s_vpd {
99 SK_VPD_STATUS v; /* VPD status structure */
100 char vpd_buf[VPD_SIZE]; /* VPD buffer */
101 int rom_size; /* VPD ROM Size from PCI_OUR_REG_2 */
102 int vpd_size; /* saved VPD-size */
103} SK_VPD;
104
105typedef struct s_vpd_para {
106 unsigned int p_len; /* parameter length */
107 char *p_val; /* points to the value */
108} SK_VPD_PARA;
109
110/*
111 * structure of Large Resource Type Identifiers
112 */
113
114/* was removed because of alignment problems */
115
116/*
117 * structure of VPD keywords
118 */
119typedef struct s_vpd_key {
120 char p_key[2]; /* 2 bytes ID string */
121 unsigned char p_len; /* 1 byte length */
122 char p_val; /* start of the value string */
123} SK_VPD_KEY;
124
125
126/*
127 * System specific VPD macros
128 */
129#ifndef SKDIAG
130#ifndef VPD_DO_IO
131#define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val)
132#define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val)
133#define VPD_OUT32(pAC,IoC,Addr,Val) (void)SkPciWriteCfgDWord(pAC,Addr,Val)
134#define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal)
135#define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal)
136#define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal)
137#else /* VPD_DO_IO */
138#define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val)
139#define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val)
140#define VPD_OUT32(pAC,IoC,Addr,Val) SK_OUT32(IoC,PCI_C(Addr),Val)
141#define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal)
142#define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal)
143#define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal)
144#endif /* VPD_DO_IO */
145#else /* SKDIAG */
146#define VPD_OUT8(pAC,Ioc,Addr,Val) { \
147 if ((pAC)->DgT.DgUseCfgCycle) \
148 SkPciWriteCfgByte(pAC,Addr,Val); \
149 else \
150 SK_OUT8(pAC,PCI_C(Addr),Val); \
151 }
152#define VPD_OUT16(pAC,Ioc,Addr,Val) { \
153 if ((pAC)->DgT.DgUseCfgCycle) \
154 SkPciWriteCfgWord(pAC,Addr,Val); \
155 else \
156 SK_OUT16(pAC,PCI_C(Addr),Val); \
157 }
158#define VPD_OUT32(pAC,Ioc,Addr,Val) { \
159 if ((pAC)->DgT.DgUseCfgCycle) \
160 SkPciWriteCfgDWord(pAC,Addr,Val); \
161 else \
162 SK_OUT32(pAC,PCI_C(Addr),Val); \
163 }
164#define VPD_IN8(pAC,Ioc,Addr,pVal) { \
165 if ((pAC)->DgT.DgUseCfgCycle) \
166 SkPciReadCfgByte(pAC,Addr,pVal); \
167 else \
168 SK_IN8(pAC,PCI_C(Addr),pVal); \
169 }
170#define VPD_IN16(pAC,Ioc,Addr,pVal) { \
171 if ((pAC)->DgT.DgUseCfgCycle) \
172 SkPciReadCfgWord(pAC,Addr,pVal); \
173 else \
174 SK_IN16(pAC,PCI_C(Addr),pVal); \
175 }
176#define VPD_IN32(pAC,Ioc,Addr,pVal) { \
177 if ((pAC)->DgT.DgUseCfgCycle) \
178 SkPciReadCfgDWord(pAC,Addr,pVal); \
179 else \
180 SK_IN32(pAC,PCI_C(Addr),pVal); \
181 }
182#endif /* nSKDIAG */
183
184/* function prototypes ********************************************************/
185
186#ifndef SK_KR_PROTO
187#ifdef SKDIAG
188extern SK_U32 VpdReadDWord(
189 SK_AC *pAC,
190 SK_IOC IoC,
191 int addr);
192#endif /* SKDIAG */
193
194extern int VpdSetupPara(
195 SK_AC *pAC,
196 const char *key,
197 const char *buf,
198 int len,
199 int type,
200 int op);
201
202extern SK_VPD_STATUS *VpdStat(
203 SK_AC *pAC,
204 SK_IOC IoC);
205
206extern int VpdKeys(
207 SK_AC *pAC,
208 SK_IOC IoC,
209 char *buf,
210 int *len,
211 int *elements);
212
213extern int VpdRead(
214 SK_AC *pAC,
215 SK_IOC IoC,
216 const char *key,
217 char *buf,
218 int *len);
219
220extern SK_BOOL VpdMayWrite(
221 char *key);
222
223extern int VpdWrite(
224 SK_AC *pAC,
225 SK_IOC IoC,
226 const char *key,
227 const char *buf);
228
229extern int VpdDelete(
230 SK_AC *pAC,
231 SK_IOC IoC,
232 char *key);
233
234extern int VpdUpdate(
235 SK_AC *pAC,
236 SK_IOC IoC);
237
238extern void VpdErrLog(
239 SK_AC *pAC,
240 SK_IOC IoC,
241 char *msg);
242
243#ifdef SKDIAG
244extern int VpdReadBlock(
245 SK_AC *pAC,
246 SK_IOC IoC,
247 char *buf,
248 int addr,
249 int len);
250
251extern int VpdWriteBlock(
252 SK_AC *pAC,
253 SK_IOC IoC,
254 char *buf,
255 int addr,
256 int len);
257#endif /* SKDIAG */
258#else /* SK_KR_PROTO */
259extern SK_U32 VpdReadDWord();
260extern int VpdSetupPara();
261extern SK_VPD_STATUS *VpdStat();
262extern int VpdKeys();
263extern int VpdRead();
264extern SK_BOOL VpdMayWrite();
265extern int VpdWrite();
266extern int VpdDelete();
267extern int VpdUpdate();
268extern void VpdErrLog();
269#endif /* SK_KR_PROTO */
270
271#endif /* __INC_SKVPD_H_ */