1 /******************************************************************************
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
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.15 2003/01/13 10:39:38 rschmidt
30 * Replaced define for PCI device Id for YUKON with GENESIS
33 * 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
37 * Revision 1.13 2002/10/14 15:58:18 rschmidt
38 * Added entry in rom_size struct s_vpd
41 * 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
46 * Revision 1.11 2002/07/26 13:19:16 mkarl
47 * added support for Yukon
48 * added vpd_size to VPD struct
50 * Revision 1.10 2000/08/10 11:29:07 rassmann
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.
56 * Revision 1.9 1999/11/22 14:02:27 cgoos
57 * Changed license header to GPL.
59 * Revision 1.8 1999/03/11 14:26:40 malthoff
60 * Replace __STDC__ with SK_KR_PROTO.
62 * Revision 1.7 1998/10/28 07:27:17 gklug
64 * add: VPD_IN/OUT8 macros
65 * chg: interface definition
67 * Revision 1.6 1998/10/22 10:03:44 gklug
68 * fix: use SK_OUT16 instead of SK_OUTW
70 * Revision 1.5 1998/10/14 07:05:31 cgoos
71 * Changed constants in SK_SWAP_32 to UL.
73 * 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)
76 * Revision 1.3 1998/08/18 08:18:56 malthoff
77 * Modify VPD in and out macros for SK_DIAG
79 * Revision 1.2 1998/07/03 14:49:08 malthoff
80 * Add VPD_INxx() and VPD_OUTxx() macros for the Diagnostics tool.
82 * Revision 1.1 1998/06/19 14:08:03 malthoff
86 ******************************************************************************/
89 * skvpd.h contains Diagnostic specific defines for VPD handling
92 #ifndef __INC_SKVPD_H_
93 #define __INC_SKVPD_H_
96 * Define Resource Type Identifiers and VPD keywords
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 */
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 */
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" */
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 */
126 * Define READ and WRITE Constants.
129 #define VPD_DEV_ID_GENESIS 0x4300
131 #define VPD_SIZE_YUKON 256
132 #define VPD_SIZE_GENESIS 512
134 #define VPD_READ 0x0000
135 #define VPD_WRITE 0x8000
137 #define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
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])
145 #define VPD_MAX_LEN 50
148 /* bit 7..1 reserved */
149 #define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */
150 /* and vpd_free_rw valid */
155 typedef 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 */
162 typedef 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 */
169 typedef struct s_vpd_para {
170 unsigned int p_len; /* parameter length */
171 char *p_val; /* points to the value */
175 * structure of Large Resource Type Identifiers
178 /* was removed because of alignment problems */
181 * structure of VPD keywords
183 typedef 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 */
191 * System specific VPD macros
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 */
210 #define VPD_OUT8(pAC,Ioc,Addr,Val) { \
211 if ((pAC)->DgT.DgUseCfgCycle) \
212 SkPciWriteCfgByte(pAC,Addr,Val); \
214 SK_OUT8(pAC,PCI_C(Addr),Val); \
216 #define VPD_OUT16(pAC,Ioc,Addr,Val) { \
217 if ((pAC)->DgT.DgUseCfgCycle) \
218 SkPciWriteCfgWord(pAC,Addr,Val); \
220 SK_OUT16(pAC,PCI_C(Addr),Val); \
222 #define VPD_OUT32(pAC,Ioc,Addr,Val) { \
223 if ((pAC)->DgT.DgUseCfgCycle) \
224 SkPciWriteCfgDWord(pAC,Addr,Val); \
226 SK_OUT32(pAC,PCI_C(Addr),Val); \
228 #define VPD_IN8(pAC,Ioc,Addr,pVal) { \
229 if ((pAC)->DgT.DgUseCfgCycle) \
230 SkPciReadCfgByte(pAC,Addr,pVal); \
232 SK_IN8(pAC,PCI_C(Addr),pVal); \
234 #define VPD_IN16(pAC,Ioc,Addr,pVal) { \
235 if ((pAC)->DgT.DgUseCfgCycle) \
236 SkPciReadCfgWord(pAC,Addr,pVal); \
238 SK_IN16(pAC,PCI_C(Addr),pVal); \
240 #define VPD_IN32(pAC,Ioc,Addr,pVal) { \
241 if ((pAC)->DgT.DgUseCfgCycle) \
242 SkPciReadCfgDWord(pAC,Addr,pVal); \
244 SK_IN32(pAC,PCI_C(Addr),pVal); \
248 /* function prototypes ********************************************************/
252 extern SK_U32 VpdReadDWord(
258 extern int VpdSetupPara(
266 extern SK_VPD_STATUS *VpdStat(
284 extern SK_BOOL VpdMayWrite(
293 extern int VpdDelete(
298 extern int VpdUpdate(
302 extern void VpdErrLog(
308 extern int VpdReadBlock(
315 extern int VpdWriteBlock(
322 #else /* SK_KR_PROTO */
323 extern SK_U32 VpdReadDWord();
324 extern int VpdSetupPara();
325 extern SK_VPD_STATUS *VpdStat();
326 extern int VpdKeys();
327 extern int VpdRead();
328 extern SK_BOOL VpdMayWrite();
329 extern int VpdWrite();
330 extern int VpdDelete();
331 extern int VpdUpdate();
332 extern void VpdErrLog();
333 #endif /* SK_KR_PROTO */
335 #endif /* __INC_SKVPD_H_ */