blob: 1be34c5a9766e9c0b359afb87c4a51f1262acddc [file] [log] [blame]
wdenk7152b1d2003-09-05 23:19:14 +00001/******************************************************************************
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 *
26 * History:
27 *
28 * $Log: skvpd.h,v $
29 * Revision 1.15 2003/01/13 10:39:38 rschmidt
30 * Replaced define for PCI device Id for YUKON with GENESIS
31 * Editorial changes
wdenk42d1f032003-10-15 23:53:47 +000032 *
wdenk7152b1d2003-09-05 23:19:14 +000033 * Revision 1.14 2002/11/14 15:18:10 gheinig
34 * Added const specifier to key and buf parameters for VpdPara,VpdRead
35 * and VpdWrite. This is necessary for the Diag 7 GUI API
wdenk42d1f032003-10-15 23:53:47 +000036 *
wdenk7152b1d2003-09-05 23:19:14 +000037 * Revision 1.13 2002/10/14 15:58:18 rschmidt
38 * Added entry in rom_size struct s_vpd
39 * Editorial changes
wdenk42d1f032003-10-15 23:53:47 +000040 *
wdenk7152b1d2003-09-05 23:19:14 +000041 * Revision 1.12 2002/09/09 14:43:51 mkarl
42 * added PCI Id of Yukon for reading VPD in diag before the adapter has
43 * been initialized
44 * editorial changes
wdenk42d1f032003-10-15 23:53:47 +000045 *
wdenk7152b1d2003-09-05 23:19:14 +000046 * Revision 1.11 2002/07/26 13:19:16 mkarl
47 * added support for Yukon
48 * added vpd_size to VPD struct
wdenk42d1f032003-10-15 23:53:47 +000049 *
wdenk7152b1d2003-09-05 23:19:14 +000050 * Revision 1.10 2000/08/10 11:29:07 rassmann
51 * Editorial changes.
52 * Preserving 32-bit alignment in structs for the adapter context.
53 * Removed unused function VpdWriteDword() (#if 0).
54 * Made VpdReadKeyword() available for SKDIAG only.
wdenk42d1f032003-10-15 23:53:47 +000055 *
wdenk7152b1d2003-09-05 23:19:14 +000056 * Revision 1.9 1999/11/22 14:02:27 cgoos
57 * Changed license header to GPL.
wdenk42d1f032003-10-15 23:53:47 +000058 *
wdenk7152b1d2003-09-05 23:19:14 +000059 * Revision 1.8 1999/03/11 14:26:40 malthoff
60 * Replace __STDC__ with SK_KR_PROTO.
wdenk42d1f032003-10-15 23:53:47 +000061 *
wdenk7152b1d2003-09-05 23:19:14 +000062 * Revision 1.7 1998/10/28 07:27:17 gklug
63 * rmv: SWAP macros
64 * add: VPD_IN/OUT8 macros
65 * chg: interface definition
wdenk42d1f032003-10-15 23:53:47 +000066 *
wdenk7152b1d2003-09-05 23:19:14 +000067 * Revision 1.6 1998/10/22 10:03:44 gklug
68 * fix: use SK_OUT16 instead of SK_OUTW
wdenk42d1f032003-10-15 23:53:47 +000069 *
wdenk7152b1d2003-09-05 23:19:14 +000070 * Revision 1.5 1998/10/14 07:05:31 cgoos
71 * Changed constants in SK_SWAP_32 to UL.
wdenk42d1f032003-10-15 23:53:47 +000072 *
wdenk7152b1d2003-09-05 23:19:14 +000073 * Revision 1.4 1998/08/19 08:14:09 gklug
74 * fix: remove struct keyword as much as possible from the C-code (see CCC)
wdenk42d1f032003-10-15 23:53:47 +000075 *
wdenk7152b1d2003-09-05 23:19:14 +000076 * Revision 1.3 1998/08/18 08:18:56 malthoff
77 * Modify VPD in and out macros for SK_DIAG
wdenk42d1f032003-10-15 23:53:47 +000078 *
wdenk7152b1d2003-09-05 23:19:14 +000079 * Revision 1.2 1998/07/03 14:49:08 malthoff
80 * Add VPD_INxx() and VPD_OUTxx() macros for the Diagnostics tool.
wdenk42d1f032003-10-15 23:53:47 +000081 *
wdenk7152b1d2003-09-05 23:19:14 +000082 * Revision 1.1 1998/06/19 14:08:03 malthoff
83 * Created.
wdenk42d1f032003-10-15 23:53:47 +000084 *
wdenk7152b1d2003-09-05 23:19:14 +000085 *
86 ******************************************************************************/
87
88/*
89 * skvpd.h contains Diagnostic specific defines for VPD handling
90 */
91
92#ifndef __INC_SKVPD_H_
93#define __INC_SKVPD_H_
94
95/*
96 * Define Resource Type Identifiers and VPD keywords
97 */
98#define RES_ID 0x82 /* Resource Type ID String (Product Name) */
99#define RES_VPD_R 0x90 /* start of VPD read only area */
100#define RES_VPD_W 0x91 /* start of VPD read/write area */
101#define RES_END 0x78 /* Resource Type End Tag */
102
103#ifndef VPD_NAME
104#define VPD_NAME "Name" /* Product Name, VPD name of RES_ID */
105#endif /* VPD_NAME */
106#define VPD_PN "PN" /* Adapter Part Number */
107#define VPD_EC "EC" /* Adapter Engineering Level */
108#define VPD_MN "MN" /* Manufacture ID */
109#define VPD_SN "SN" /* Serial Number */
110#define VPD_CP "CP" /* Extended Capability */
111#define VPD_RV "RV" /* Checksum and Reserved */
112#define VPD_YA "YA" /* Asset Tag Identifier */
113#define VPD_VL "VL" /* First Error Log Message (SK specific) */
114#define VPD_VF "VF" /* Second Error Log Message (SK specific) */
115#define VPD_RW "RW" /* Remaining Read / Write Area */
116
117/* 'type' values for vpd_setup_para() */
118#define VPD_RO_KEY 1 /* RO keys are "PN", "EC", "MN", "SN", "RV" */
119#define VPD_RW_KEY 2 /* RW keys are "Yx", "Vx", and "RW" */
120
121/* 'op' values for vpd_setup_para() */
122#define ADD_KEY 1 /* add the key at the pos "RV" or "RW" */
123#define OWR_KEY 2 /* overwrite key if already exists */
124
125/*
126 * Define READ and WRITE Constants.
127 */
128
129#define VPD_DEV_ID_GENESIS 0x4300
130
131#define VPD_SIZE_YUKON 256
132#define VPD_SIZE_GENESIS 512
133#define VPD_SIZE 512
134#define VPD_READ 0x0000
135#define VPD_WRITE 0x8000
136
137#define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
138
139#define VPD_GET_RES_LEN(p) ((unsigned int) \
140 (* (SK_U8 *)&(p)[1]) |\
141 ((* (SK_U8 *)&(p)[2]) << 8))
142#define VPD_GET_VPD_LEN(p) ((unsigned int)(* (SK_U8 *)&(p)[2]))
143#define VPD_GET_VAL(p) ((char *)&(p)[3])
144
145#define VPD_MAX_LEN 50
146
147/* VPD status */
148 /* bit 7..1 reserved */
149#define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */
150 /* and vpd_free_rw valid */
151
152/*
153 * VPD structs
154 */
155typedef struct s_vpd_status {
156 unsigned short Align01; /* Alignment */
157 unsigned short vpd_status; /* VPD status, description see above */
158 int vpd_free_ro; /* unused bytes in read only area */
159 int vpd_free_rw; /* bytes available in read/write area */
160} SK_VPD_STATUS;
161
162typedef struct s_vpd {
163 SK_VPD_STATUS v; /* VPD status structure */
164 char vpd_buf[VPD_SIZE]; /* VPD buffer */
165 int rom_size; /* VPD ROM Size from PCI_OUR_REG_2 */
166 int vpd_size; /* saved VPD-size */
167} SK_VPD;
168
169typedef struct s_vpd_para {
170 unsigned int p_len; /* parameter length */
171 char *p_val; /* points to the value */
172} SK_VPD_PARA;
173
174/*
175 * structure of Large Resource Type Identifiers
176 */
177
178/* was removed because of alignment problems */
179
180/*
181 * structure of VPD keywords
182 */
183typedef struct s_vpd_key {
184 char p_key[2]; /* 2 bytes ID string */
185 unsigned char p_len; /* 1 byte length */
186 char p_val; /* start of the value string */
187} SK_VPD_KEY;
188
189
190/*
191 * System specific VPD macros
192 */
193#ifndef SKDIAG
194#ifndef VPD_DO_IO
195#define VPD_OUT8(pAC,IoC,Addr,Val) (void)SkPciWriteCfgByte(pAC,Addr,Val)
196#define VPD_OUT16(pAC,IoC,Addr,Val) (void)SkPciWriteCfgWord(pAC,Addr,Val)
197#define VPD_OUT32(pAC,IoC,Addr,Val) (void)SkPciWriteCfgDWord(pAC,Addr,Val)
198#define VPD_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal)
199#define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal)
200#define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal)
201#else /* VPD_DO_IO */
202#define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val)
203#define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val)
204#define VPD_OUT32(pAC,IoC,Addr,Val) SK_OUT32(IoC,PCI_C(Addr),Val)
205#define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal)
206#define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal)
207#define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal)
208#endif /* VPD_DO_IO */
209#else /* SKDIAG */
210#define VPD_OUT8(pAC,Ioc,Addr,Val) { \
211 if ((pAC)->DgT.DgUseCfgCycle) \
212 SkPciWriteCfgByte(pAC,Addr,Val); \
213 else \
214 SK_OUT8(pAC,PCI_C(Addr),Val); \
215 }
216#define VPD_OUT16(pAC,Ioc,Addr,Val) { \
217 if ((pAC)->DgT.DgUseCfgCycle) \
218 SkPciWriteCfgWord(pAC,Addr,Val); \
219 else \
220 SK_OUT16(pAC,PCI_C(Addr),Val); \
221 }
222#define VPD_OUT32(pAC,Ioc,Addr,Val) { \
223 if ((pAC)->DgT.DgUseCfgCycle) \
224 SkPciWriteCfgDWord(pAC,Addr,Val); \
225 else \
226 SK_OUT32(pAC,PCI_C(Addr),Val); \
227 }
228#define VPD_IN8(pAC,Ioc,Addr,pVal) { \
229 if ((pAC)->DgT.DgUseCfgCycle) \
230 SkPciReadCfgByte(pAC,Addr,pVal); \
231 else \
232 SK_IN8(pAC,PCI_C(Addr),pVal); \
233 }
234#define VPD_IN16(pAC,Ioc,Addr,pVal) { \
235 if ((pAC)->DgT.DgUseCfgCycle) \
236 SkPciReadCfgWord(pAC,Addr,pVal); \
237 else \
238 SK_IN16(pAC,PCI_C(Addr),pVal); \
239 }
240#define VPD_IN32(pAC,Ioc,Addr,pVal) { \
241 if ((pAC)->DgT.DgUseCfgCycle) \
242 SkPciReadCfgDWord(pAC,Addr,pVal); \
243 else \
244 SK_IN32(pAC,PCI_C(Addr),pVal); \
245 }
246#endif /* nSKDIAG */
247
248/* function prototypes ********************************************************/
249
250#ifndef SK_KR_PROTO
251#ifdef SKDIAG
252extern SK_U32 VpdReadDWord(
253 SK_AC *pAC,
254 SK_IOC IoC,
255 int addr);
256#endif /* SKDIAG */
257
258extern int VpdSetupPara(
259 SK_AC *pAC,
260 const char *key,
261 const char *buf,
262 int len,
263 int type,
264 int op);
265
266extern SK_VPD_STATUS *VpdStat(
267 SK_AC *pAC,
268 SK_IOC IoC);
269
270extern int VpdKeys(
271 SK_AC *pAC,
272 SK_IOC IoC,
273 char *buf,
274 int *len,
275 int *elements);
276
277extern int VpdRead(
278 SK_AC *pAC,
279 SK_IOC IoC,
280 const char *key,
281 char *buf,
282 int *len);
283
284extern SK_BOOL VpdMayWrite(
285 char *key);
286
287extern int VpdWrite(
288 SK_AC *pAC,
289 SK_IOC IoC,
290 const char *key,
291 const char *buf);
292
293extern int VpdDelete(
294 SK_AC *pAC,
295 SK_IOC IoC,
296 char *key);
297
298extern int VpdUpdate(
299 SK_AC *pAC,
300 SK_IOC IoC);
301
302extern void VpdErrLog(
303 SK_AC *pAC,
304 SK_IOC IoC,
305 char *msg);
306
307#ifdef SKDIAG
308extern int VpdReadBlock(
309 SK_AC *pAC,
310 SK_IOC IoC,
311 char *buf,
312 int addr,
313 int len);
314
315extern int VpdWriteBlock(
316 SK_AC *pAC,
317 SK_IOC IoC,
318 char *buf,
319 int addr,
320 int len);
321#endif /* SKDIAG */
322#else /* SK_KR_PROTO */
323extern SK_U32 VpdReadDWord();
324extern int VpdSetupPara();
325extern SK_VPD_STATUS *VpdStat();
326extern int VpdKeys();
327extern int VpdRead();
328extern SK_BOOL VpdMayWrite();
329extern int VpdWrite();
330extern int VpdDelete();
331extern int VpdUpdate();
332extern void VpdErrLog();
333#endif /* SK_KR_PROTO */
334
335#endif /* __INC_SKVPD_H_ */