1
0
uboot-1.1.4-kirkwood/drivers/sk98lin/h/skvpd.h

282 lines
7.5 KiB
C
Raw Permalink Normal View History

2024-01-07 23:57:24 +01:00
/******************************************************************************
*
* Name: skvpd.h
2024-01-07 23:58:22 +01:00
* Project: Gigabit Ethernet Adapters, VPD-Module
* Version: $Revision: 1.1.1.1 $
2024-01-08 00:07:02 +01:00
* Date: $Date: 2008/12/15 11:39:21 $
2024-01-07 23:57:24 +01:00
* Purpose: Defines and Macros for VPD handling
*
******************************************************************************/
/******************************************************************************
*
2024-01-07 23:58:22 +01:00
* (C)Copyright 1998-2002 SysKonnect.
* (C)Copyright 2002-2004 Marvell.
2024-01-07 23:57:24 +01:00
*
* 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
*/
2024-01-07 23:58:22 +01:00
#define RES_ID 0x82 /* Resource Type ID String (Product Name) */
2024-01-07 23:57:24 +01:00
#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 */
2024-01-07 23:58:22 +01:00
#define VPD_EC "EC" /* Adapter Engineering Level */
2024-01-07 23:57:24 +01:00
#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 */
2024-01-07 23:58:22 +01:00
#define VPD_YA "YA" /* Asset Tag Identifier */
2024-01-07 23:57:24 +01:00
#define VPD_VL "VL" /* First Error Log Message (SK specific) */
#define VPD_VF "VF" /* Second Error Log Message (SK specific) */
2024-01-07 23:58:22 +01:00
#define VPD_VB "VB" /* Boot Agent ROM Configuration (SK specific) */
#define VPD_VE "VE" /* EFI UNDI Configuration (SK specific) */
2024-01-07 23:57:24 +01:00
#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() */
2024-01-07 23:58:22 +01:00
#define ADD_KEY 1 /* add the key at the pos "RV" or "RW" */
2024-01-07 23:57:24 +01:00
#define OWR_KEY 2 /* overwrite key if already exists */
/*
* Define READ and WRITE Constants.
*/
#define VPD_DEV_ID_GENESIS 0x4300
2024-01-07 23:58:22 +01:00
#define VPD_SIZE_YUKON 256
#define VPD_SIZE_GENESIS 512
#define VPD_SIZE 512
2024-01-07 23:57:24 +01:00
#define VPD_READ 0x0000
#define VPD_WRITE 0x8000
#define VPD_STOP(pAC,IoC) VPD_OUT16(pAC,IoC,PCI_VPD_ADR_REG,VPD_WRITE)
2024-01-07 23:58:22 +01:00
#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]))
2024-01-07 23:57:24 +01:00
#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
*/
2024-01-07 23:58:22 +01:00
#ifndef SK_DIAG
2024-01-07 23:57:24 +01:00
#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_OUT32(pAC,IoC,Addr,Val) (void)SkPciWriteCfgDWord(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 */
2024-01-07 23:58:22 +01:00
#define VPD_OUT8(pAC,IoC,Addr,Val) SK_OUT8(IoC,PCI_C(pAC,Addr),Val)
#define VPD_OUT16(pAC,IoC,Addr,Val) SK_OUT16(IoC,PCI_C(pAC,Addr),Val)
#define VPD_OUT32(pAC,IoC,Addr,Val) SK_OUT32(IoC,PCI_C(pAC,Addr),Val)
#define VPD_IN8(pAC,IoC,Addr,pVal) SK_IN8(IoC,PCI_C(pAC,Addr),pVal)
#define VPD_IN16(pAC,IoC,Addr,pVal) SK_IN16(IoC,PCI_C(pAC,Addr),pVal)
#define VPD_IN32(pAC,IoC,Addr,pVal) SK_IN32(IoC,PCI_C(pAC,Addr),pVal)
2024-01-07 23:57:24 +01:00
#endif /* VPD_DO_IO */
2024-01-07 23:58:22 +01:00
#else /* SK_DIAG */
2024-01-07 23:57:24 +01:00
#define VPD_OUT8(pAC,Ioc,Addr,Val) { \
if ((pAC)->DgT.DgUseCfgCycle) \
SkPciWriteCfgByte(pAC,Addr,Val); \
else \
2024-01-07 23:58:22 +01:00
SK_OUT8(pAC,PCI_C(pAC,Addr),Val); \
2024-01-07 23:57:24 +01:00
}
#define VPD_OUT16(pAC,Ioc,Addr,Val) { \
if ((pAC)->DgT.DgUseCfgCycle) \
SkPciWriteCfgWord(pAC,Addr,Val); \
else \
2024-01-07 23:58:22 +01:00
SK_OUT16(pAC,PCI_C(pAC,Addr),Val); \
2024-01-07 23:57:24 +01:00
}
#define VPD_OUT32(pAC,Ioc,Addr,Val) { \
if ((pAC)->DgT.DgUseCfgCycle) \
SkPciWriteCfgDWord(pAC,Addr,Val); \
else \
2024-01-07 23:58:22 +01:00
SK_OUT32(pAC,PCI_C(pAC,Addr),Val); \
2024-01-07 23:57:24 +01:00
}
#define VPD_IN8(pAC,Ioc,Addr,pVal) { \
2024-01-07 23:58:22 +01:00
if ((pAC)->DgT.DgUseCfgCycle) \
2024-01-07 23:57:24 +01:00
SkPciReadCfgByte(pAC,Addr,pVal); \
else \
2024-01-07 23:58:22 +01:00
SK_IN8(pAC,PCI_C(pAC,Addr),pVal); \
2024-01-07 23:57:24 +01:00
}
#define VPD_IN16(pAC,Ioc,Addr,pVal) { \
2024-01-07 23:58:22 +01:00
if ((pAC)->DgT.DgUseCfgCycle) \
2024-01-07 23:57:24 +01:00
SkPciReadCfgWord(pAC,Addr,pVal); \
else \
2024-01-07 23:58:22 +01:00
SK_IN16(pAC,PCI_C(pAC,Addr),pVal); \
2024-01-07 23:57:24 +01:00
}
#define VPD_IN32(pAC,Ioc,Addr,pVal) { \
if ((pAC)->DgT.DgUseCfgCycle) \
SkPciReadCfgDWord(pAC,Addr,pVal); \
else \
2024-01-07 23:58:22 +01:00
SK_IN32(pAC,PCI_C(pAC,Addr),pVal); \
2024-01-07 23:57:24 +01:00
}
2024-01-07 23:58:22 +01:00
#endif /* SK_DIAG */
2024-01-07 23:57:24 +01:00
/* function prototypes ********************************************************/
#ifndef SK_KR_PROTO
2024-01-07 23:58:22 +01:00
#ifdef SK_DIAG
2024-01-07 23:57:24 +01:00
extern SK_U32 VpdReadDWord(
SK_AC *pAC,
SK_IOC IoC,
int addr);
2024-01-07 23:58:22 +01:00
#endif /* SK_DIAG */
2024-01-07 23:57:24 +01:00
extern int VpdSetupPara(
SK_AC *pAC,
const char *key,
const char *buf,
int len,
int type,
int op);
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);
extern void VpdErrLog(
SK_AC *pAC,
SK_IOC IoC,
char *msg);
2024-01-07 23:58:22 +01:00
int VpdInit(
SK_AC *pAC,
SK_IOC IoC);
#if defined(SK_DIAG) || defined(SK_ASF)
2024-01-07 23:57:24 +01:00
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);
2024-01-07 23:58:22 +01:00
#endif /* SK_DIAG || SK_ASF */
2024-01-07 23:57:24 +01:00
#else /* SK_KR_PROTO */
extern SK_U32 VpdReadDWord();
extern int VpdSetupPara();
extern SK_VPD_STATUS *VpdStat();
extern int VpdKeys();
extern int VpdRead();
extern SK_BOOL VpdMayWrite();
extern int VpdWrite();
extern int VpdDelete();
extern int VpdUpdate();
extern void VpdErrLog();
#endif /* SK_KR_PROTO */
#endif /* __INC_SKVPD_H_ */
2024-01-07 23:58:22 +01:00