summaryrefslogtreecommitdiffstats
path: root/drivers/net/sk98lin/h/skvpd.h
blob: fdd9e48e80408da4c899a43732d6c7c970fe3c71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
/******************************************************************************
 *
 * Name:	skvpd.h
 * Project:	GEnesis, PCI Gigabit Ethernet Adapter
 * Version:	$Revision: 1.15 $
 * Date:	$Date: 2003/01/13 10:39:38 $
 * Purpose:	Defines and Macros for VPD handling
 *
 ******************************************************************************/

/******************************************************************************
 *
 *	(C)Copyright 1998-2003 SysKonnect GmbH.
 *
 *	This program is free software; you can redistribute it and/or modify
 *	it under the terms of the GNU General Public License as published by
 *	the Free Software Foundation; either version 2 of the License, or
 *	(at your option) any later version.
 *
 *	The information in this file is provided "AS IS" without warranty.
 *
 ******************************************************************************/

/*
 * skvpd.h	contains Diagnostic specific defines for VPD handling
 */

#ifndef __INC_SKVPD_H_
#define __INC_SKVPD_H_

/*
 * Define Resource Type Identifiers and VPD keywords
 */
#define	RES_ID		0x82	/* Resource Type ID String (Product Name) */
#define RES_VPD_R	0x90	/* start of VPD read only area */
#define RES_VPD_W	0x91	/* start of VPD read/write area */
#define RES_END		0x78	/* Resource Type End Tag */

#ifndef VPD_NAME
#define VPD_NAME	"Name"	/* Product Name, VPD name of RES_ID */
#endif	/* VPD_NAME */
#define VPD_PN		"PN"	/* Adapter Part Number */
#define	VPD_EC		"EC"	/* Adapter Engineering Level */
#define VPD_MN		"MN"	/* Manufacture ID */
#define VPD_SN		"SN"	/* Serial Number */
#define VPD_CP		"CP"	/* Extended Capability */
#define VPD_RV		"RV"	/* Checksum and Reserved */
#define	VPD_YA		"YA"	/* Asset Tag Identifier */
#define VPD_VL		"VL"	/* First Error Log Message (SK specific) */
#define VPD_VF		"VF"	/* Second Error Log Message (SK specific) */
#define VPD_RW		"RW"	/* Remaining Read / Write Area */

/* 'type' values for vpd_setup_para() */
#define VPD_RO_KEY	1	/* RO keys are "PN", "EC", "MN", "SN", "RV" */
#define VPD_RW_KEY	2	/* RW keys are "Yx", "Vx", and "RW" */

/* 'op' values for vpd_setup_para() */
#define	ADD_KEY		1	/* add the key at the pos "RV" or "RW" */
#define OWR_KEY		2	/* overwrite key if already exists */

/*
 * Define READ and WRITE Constants.
 */

#define VPD_DEV_ID_GENESIS 	0x4300

#define	VPD_SIZE_YUKON		256
#define	VPD_SIZE_GENESIS	512
#define	VPD_SIZE			512
#define VPD_READ	0x0000
#define VPD_WRITE	0x8000

#define VPD_STOP(pAC,IoC)	VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)

#define VPD_GET_RES_LEN(p)	((unsigned int) \
					(* (SK_U8 *)&(p)[1]) |\
					((* (SK_U8 *)&(p)[2]) << 8))
#define VPD_GET_VPD_LEN(p)	((unsigned int)(* (SK_U8 *)&(p)[2]))
#define VPD_GET_VAL(p)		((char *)&(p)[3])

#define VPD_MAX_LEN	50

/* VPD status */
	/* bit 7..1 reserved */
#define VPD_VALID	(1<<0)	/* VPD data buffer, vpd_free_ro, */
							/* and vpd_free_rw valid	 */

/*
 * VPD structs
 */
typedef	struct s_vpd_status {
	unsigned short	Align01;			/* Alignment */
	unsigned short	vpd_status;			/* VPD status, description see above */
	int				vpd_free_ro;		/* unused bytes in read only area */
	int				vpd_free_rw;		/* bytes available in read/write area */
} SK_VPD_STATUS;

typedef	struct s_vpd {
	SK_VPD_STATUS	v;					/* VPD status structure */
	char			vpd_buf[VPD_SIZE];	/* VPD buffer */
	int				rom_size;			/* VPD ROM Size from PCI_OUR_REG_2 */
	int				vpd_size;			/* saved VPD-size */
} SK_VPD;

typedef	struct s_vpd_para {
	unsigned int	p_len;	/* parameter length */
	char			*p_val;	/* points to the value */
} SK_VPD_PARA;

/*
 * structure of Large Resource Type Identifiers
 */

/* was removed because of alignment problems */

/*
 * structure of VPD keywords
 */
typedef	struct s_vpd_key {
	char			p_key[2];	/* 2 bytes ID string */
	unsigned char	p_len;		/* 1 byte length */
	char			p_val;		/* start of the value string */
} SK_VPD_KEY;


/*
 * System specific VPD macros
 */
#ifndef SKDIAG
#ifndef VPD_DO_IO
#define VPD_OUT8(pAC,IoC,Addr,Val)	(void)SkPciWriteCfgByte(pAC,Addr,Val)
#define VPD_OUT16(pAC,IoC,Addr,Val)	(void)SkPciWriteCfgWord(pAC,Addr,Val)
#define VPD_IN8(pAC,IoC,Addr,pVal)	(void)SkPciReadCfgByte(pAC,Addr,pVal)
#define VPD_IN16(pAC,IoC,Addr,pVal)	(void)SkPciReadCfgWord(pAC,Addr,pVal)
#define VPD_IN32(pAC,IoC,Addr,pVal)	(void)SkPciReadCfgDWord(pAC,Addr,pVal)
#else	/* VPD_DO_IO */
#define VPD_OUT8(pAC,IoC,Addr,Val)	SK_OUT8(IoC,PCI_C(Addr),Val)
#define VPD_OUT16(pAC,IoC,Addr,Val)	SK_OUT16(IoC,PCI_C(Addr),Val)
#define VPD_IN8(pAC,IoC,Addr,pVal)	SK_IN8(IoC,PCI_C(Addr),pVal)
#define VPD_IN16(pAC,IoC,Addr,pVal)	SK_IN16(IoC,PCI_C(Addr),pVal)
#define VPD_IN32(pAC,IoC,Addr,pVal)	SK_IN32(IoC,PCI_C(Addr),pVal)
#endif	/* VPD_DO_IO */
#else	/* SKDIAG */
#define VPD_OUT8(pAC,Ioc,Addr,Val) {			\
		if ((pAC)->DgT.DgUseCfgCycle)			\
			SkPciWriteCfgByte(pAC,Addr,Val);	\
		else									\
			SK_OUT8(pAC,PCI_C(Addr),Val);		\
		}
#define VPD_OUT16(pAC,Ioc,Addr,Val) {			\
		if ((pAC)->DgT.DgUseCfgCycle)			\
			SkPciWriteCfgWord(pAC,Addr,Val);	\
		else						\
			SK_OUT16(pAC,PCI_C(Addr),Val);		\
		}
#define VPD_IN8(pAC,Ioc,Addr,pVal) {			\
		if ((pAC)->DgT.DgUseCfgCycle) 			\
			SkPciReadCfgByte(pAC,Addr,pVal);	\
		else						\
			SK_IN8(pAC,PCI_C(Addr),pVal); 		\
		}
#define VPD_IN16(pAC,Ioc,Addr,pVal) {			\
		if ((pAC)->DgT.DgUseCfgCycle) 			\
			SkPciReadCfgWord(pAC,Addr,pVal);	\
		else						\
			SK_IN16(pAC,PCI_C(Addr),pVal); 		\
		}
#define VPD_IN32(pAC,Ioc,Addr,pVal) {			\
		if ((pAC)->DgT.DgUseCfgCycle)			\
			SkPciReadCfgDWord(pAC,Addr,pVal);	\
		else						\
			SK_IN32(pAC,PCI_C(Addr),pVal);		\
		}
#endif	/* nSKDIAG */

/* function prototypes ********************************************************/

#ifndef	SK_KR_PROTO
#ifdef SKDIAG
extern SK_U32	VpdReadDWord(
	SK_AC		*pAC,
	SK_IOC		IoC,
	int			addr);
#endif	/* SKDIAG */

extern SK_VPD_STATUS	*VpdStat(
	SK_AC		*pAC,
	SK_IOC		IoC);

extern int	VpdKeys(
	SK_AC		*pAC,
	SK_IOC		IoC,
	char		*buf,
	int			*len,
	int			*elements);

extern int	VpdRead(
	SK_AC		*pAC,
	SK_IOC		IoC,
	const char	*key,
	char		*buf,
	int			*len);

extern SK_BOOL	VpdMayWrite(
	char		*key);

extern int	VpdWrite(
	SK_AC		*pAC,
	SK_IOC		IoC,
	const char	*key,
	const char	*buf);

extern int	VpdDelete(
	SK_AC		*pAC,
	SK_IOC		IoC,
	char		*key);

extern int	VpdUpdate(
	SK_AC		*pAC,
	SK_IOC		IoC);

#ifdef	SKDIAG
extern int	VpdReadBlock(
	SK_AC		*pAC,
	SK_IOC		IoC,
	char		*buf,
	int			addr,
	int			len);

extern int	VpdWriteBlock(
	SK_AC		*pAC,
	SK_IOC		IoC,
	char		*buf,
	int			addr,
	int			len);
#endif	/* SKDIAG */
#else	/* SK_KR_PROTO */
extern SK_U32	VpdReadDWord();
extern SK_VPD_STATUS	*VpdStat();
extern int	VpdKeys();
extern int	VpdRead();
extern SK_BOOL	VpdMayWrite();
extern int	VpdWrite();
extern int	VpdDelete();
extern int	VpdUpdate();
#endif	/* SK_KR_PROTO */

#endif	/* __INC_SKVPD_H_ */