Linux-2.6.12-rc2
[linux-2.6/linux-acpi-2.6/ibm-acpi-2.6.git] / drivers / net / sk98lin / h / skvpd.h
blobbdc1a5eaaae9610533bcbffaffeecd83a01f425d
1 /******************************************************************************
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
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 */
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 */
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
69 #define VPD_SIZE 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
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 */
89 * VPD structs
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 */
96 } SK_VPD_STATUS;
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 */
103 } SK_VPD;
105 typedef struct s_vpd_para {
106 unsigned int p_len; /* parameter length */
107 char *p_val; /* points to the value */
108 } SK_VPD_PARA;
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 */
123 } SK_VPD_KEY;
127 * System specific VPD macros
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); \
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); \
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); \
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); \
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); \
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); \
182 #endif /* nSKDIAG */
184 /* function prototypes ********************************************************/
186 #ifndef SK_KR_PROTO
187 #ifdef SKDIAG
188 extern SK_U32 VpdReadDWord(
189 SK_AC *pAC,
190 SK_IOC IoC,
191 int addr);
192 #endif /* SKDIAG */
194 extern int VpdSetupPara(
195 SK_AC *pAC,
196 const char *key,
197 const char *buf,
198 int len,
199 int type,
200 int op);
202 extern SK_VPD_STATUS *VpdStat(
203 SK_AC *pAC,
204 SK_IOC IoC);
206 extern int VpdKeys(
207 SK_AC *pAC,
208 SK_IOC IoC,
209 char *buf,
210 int *len,
211 int *elements);
213 extern int VpdRead(
214 SK_AC *pAC,
215 SK_IOC IoC,
216 const char *key,
217 char *buf,
218 int *len);
220 extern SK_BOOL VpdMayWrite(
221 char *key);
223 extern int VpdWrite(
224 SK_AC *pAC,
225 SK_IOC IoC,
226 const char *key,
227 const char *buf);
229 extern int VpdDelete(
230 SK_AC *pAC,
231 SK_IOC IoC,
232 char *key);
234 extern int VpdUpdate(
235 SK_AC *pAC,
236 SK_IOC IoC);
238 extern void VpdErrLog(
239 SK_AC *pAC,
240 SK_IOC IoC,
241 char *msg);
243 #ifdef SKDIAG
244 extern int VpdReadBlock(
245 SK_AC *pAC,
246 SK_IOC IoC,
247 char *buf,
248 int addr,
249 int len);
251 extern 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 */
259 extern SK_U32 VpdReadDWord();
260 extern int VpdSetupPara();
261 extern SK_VPD_STATUS *VpdStat();
262 extern int VpdKeys();
263 extern int VpdRead();
264 extern SK_BOOL VpdMayWrite();
265 extern int VpdWrite();
266 extern int VpdDelete();
267 extern int VpdUpdate();
268 extern void VpdErrLog();
269 #endif /* SK_KR_PROTO */
271 #endif /* __INC_SKVPD_H_ */