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 ******************************************************************************/
25 * skvpd.h contains Diagnostic specific defines for VPD handling
28 #ifndef __INC_SKVPD_H_
29 #define __INC_SKVPD_H_
32 * Define Resource Type Identifiers and VPD keywords
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 */
40 #define VPD_NAME "Name" /* Product Name, VPD name of RES_ID */
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 */
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" */
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 */
62 * Define READ and WRITE Constants.
65 #define VPD_DEV_ID_GENESIS 0x4300
67 #define VPD_SIZE_YUKON 256
68 #define VPD_SIZE_GENESIS 512
70 #define VPD_READ 0x0000
71 #define VPD_WRITE 0x8000
73 #define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
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])
81 #define VPD_MAX_LEN 50
84 /* bit 7..1 reserved */
85 #define VPD_VALID (1<<0) /* VPD data buffer, vpd_free_ro, */
86 /* and vpd_free_rw valid */
91 typedef 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 */
98 typedef 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 */
105 typedef struct s_vpd_para {
106 unsigned int p_len; /* parameter length */
107 char *p_val; /* points to the value */
111 * structure of Large Resource Type Identifiers
114 /* was removed because of alignment problems */
117 * structure of VPD keywords
119 typedef 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 */
127 * System specific VPD macros
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_IN8(pAC,IoC,Addr,pVal) (void)SkPciReadCfgByte(pAC,Addr,pVal)
134 #define VPD_IN16(pAC,IoC,Addr,pVal) (void)SkPciReadCfgWord(pAC,Addr,pVal)
135 #define VPD_IN32(pAC,IoC,Addr,pVal) (void)SkPciReadCfgDWord(pAC,Addr,pVal)
136 #else /* VPD_DO_IO */
137 #define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(Addr),Val)
138 #define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(Addr),Val)
139 #define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(Addr),pVal)
140 #define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(Addr),pVal)
141 #define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(Addr),pVal)
142 #endif /* VPD_DO_IO */
144 #define VPD_OUT8(pAC,Ioc,Addr,Val) { \
145 if ((pAC)->DgT.DgUseCfgCycle) \
146 SkPciWriteCfgByte(pAC,Addr,Val); \
148 SK_OUT8(pAC,PCI_C(Addr),Val); \
150 #define VPD_OUT16(pAC,Ioc,Addr,Val) { \
151 if ((pAC)->DgT.DgUseCfgCycle) \
152 SkPciWriteCfgWord(pAC,Addr,Val); \
154 SK_OUT16(pAC,PCI_C(Addr),Val); \
156 #define VPD_IN8(pAC,Ioc,Addr,pVal) { \
157 if ((pAC)->DgT.DgUseCfgCycle) \
158 SkPciReadCfgByte(pAC,Addr,pVal); \
160 SK_IN8(pAC,PCI_C(Addr),pVal); \
162 #define VPD_IN16(pAC,Ioc,Addr,pVal) { \
163 if ((pAC)->DgT.DgUseCfgCycle) \
164 SkPciReadCfgWord(pAC,Addr,pVal); \
166 SK_IN16(pAC,PCI_C(Addr),pVal); \
168 #define VPD_IN32(pAC,Ioc,Addr,pVal) { \
169 if ((pAC)->DgT.DgUseCfgCycle) \
170 SkPciReadCfgDWord(pAC,Addr,pVal); \
172 SK_IN32(pAC,PCI_C(Addr),pVal); \
176 /* function prototypes ********************************************************/
180 extern SK_U32 VpdReadDWord(
186 extern int VpdSetupPara(
194 extern SK_VPD_STATUS *VpdStat(
212 extern SK_BOOL VpdMayWrite(
221 extern int VpdDelete(
226 extern int VpdUpdate(
230 extern void VpdErrLog(
236 extern int VpdReadBlock(
243 extern int VpdWriteBlock(
250 #else /* SK_KR_PROTO */
251 extern SK_U32 VpdReadDWord();
252 extern int VpdSetupPara();
253 extern SK_VPD_STATUS *VpdStat();
254 extern int VpdKeys();
255 extern int VpdRead();
256 extern SK_BOOL VpdMayWrite();
257 extern int VpdWrite();
258 extern int VpdDelete();
259 extern int VpdUpdate();
260 extern void VpdErrLog();
261 #endif /* SK_KR_PROTO */
263 #endif /* __INC_SKVPD_H_ */