📄 sysmotvpdcpv3060.c
字号:
/* sysMotVpdCpv3060.c - Board-Specified Vital Product Data Routines. *//* Copyright 1998-2000 Wind River Systems, Inc. *//* Copyright 1998-2000 Motorola, Inc., All Rights Reserved *//*modification history--------------------01c,05jan01,rhk Changed name from sysMotVpd.c to sysMotVpdCpv3060.c.01b,07dec00,rhk Cleanup to comply with WRS coding standards.01a,09aug99,rhk ported to cpv3060 BSP.*//*DESCRIPTIONThis file contains the Board-Specific Vital Product Data utility routines.These routines extract or provide access to various parameters stored in theboard's Vital Product Data (VPD). In general, a board's VPD is stored in aserial EEPROM device wired to the I2C bus and replaces the functions formerlyprovided by system registers. A lower-level access library provides the basicVPD read, validate and parse operations while the routines in this file extractand save commonly used VPD parameters for faster access.CAVEATSThese routines are needed before the kernel is un-compressed. For properoperation, this file must be added to the BOOT_EXTRA list in the Makefile toprevent it from being compressed during kernel generation.*/#include "vxWorks.h"#include "string.h"#include "sysMotVpdCpv3060.h"#include "cpv3060.h"/* defines *//* locals *//* globals */VPD sysVpd; /* board vital product data */VPD_PACKET * sysVpdPkts[VPD_PKT_LIMIT] = { 0 }; /* board vpd packets */VPD_PACKET * pSysBrdOpts = NULL; /* board options packet */UINT32 sysBusSpeed = DEFAULT_CLOCK_SPEED; /* bus speed in Hz. */UINT32 sysCpuSpeed = DEFAULT_CLOCK_SPEED; /* internal cpu speed in Hz. */UINT32 sysPciSpeed = DEFAULT_PCI_CLOCK; /* PCI bus speed in Hz. */int sysFlashSize = DEFAULT_FLASH_SIZE; /* Flash memory size */int sysBootType = BOOTROM_STARTUP; /* where boot takes place */UINT sysSdramSize = DEFAULT_SDRAM_SIZE; /* total SDRAM size */UINT sysSbramSize = DEFAULT_SBRAM_SIZE; /* size of burst ram */int sysSdramSpd = MEM_SPEED_60NS; /* On-board SDRAM speed */UINT sysRefClkFrq = DEFAULT_CLOCK_SPEED; /* Reference clock for CPU */UCHAR sysProductStr[VPD_MAX_ITEM_SIZE] = DEFAULT_PROD_IDFR;UCHAR sysFactoryNum[VPD_MAX_ITEM_SIZE] = DEFAULT_NULL_STRING;UCHAR sysSerialNum[VPD_MAX_ITEM_SIZE] = DEFAULT_NULL_STRING;UCHAR sysMpuType[VPD_MAX_ITEM_SIZE] = DEFAULT_MPU_TYPE;unsigned char tempEnetAddr [6];PRODUCT_CONFIG_DATA sysConfigOptions;/* externals */IMPORT STATUS sysVpdPktParse ( VPD *, VPD_PACKET **, UINT32);IMPORT STATUS sysVpdPktGet ( UCHAR, UINT32, VPD_PACKET **, VPD_PACKET **);IMPORT UINT cpvI2cEepromRead (UINT, UCHAR *, UINT);IMPORT UINT cpvI2cSromRead (UINT, UCHAR *, UINT, UINT);#include "cpvSystemConfig.c"/******************************************************************************** sysGetBusSpd - routine to get the speed of the 60x processor bus** This routine returns the speed (in Hz) of the 60x system bus.** RETURNS: The bus speed (inHz).*/UINT sysGetBusSpd (void) { return (sysBusSpeed); }/******************************************************************************** sysGetPciSpd - routine to get the speed of the PCI bus** This routine returns the speed (in Hz) of the PCI bus.** RETURNS: The bus speed (inHz).*/UINT sysGetPciSpd (void) { return (sysPciSpeed); }/******************************************************************************** sysGetMpuSpd - routine to get the speed of the 60x processor bus** This routine returns the speed (in Hz) of the 60x system bus.** RETURNS: The bus speed (inHz).*/UINT sysGetMpuSpd (void) { return (sysCpuSpeed); }/********************************************************************************* sysVpdInit - initialize the board vital product data structures.** This routine reads the VPD and extracts the commonly used data.** RETURNS: OK, if successful or ERROR if unsuccessful.** SEE ALSO: N/A()*/STATUS sysVpdInit(void) { VPD_PACKET * pVpdPkt; /* VPD packet pointer */ UINT32 idx; /* index loop counter */ UINT immrVal; /* Base address of IMMR */ UINT32 buffer[8]; UCHAR * dataPtr; immrVal = INTERNAL_MEM_MAP_ADDR; /* read the vpd from the serial eeprom. */ dataPtr = (UCHAR *)(&sysVpd); if ( cpvI2cSromRead (I2C_VPD_DATA, dataPtr, 0, DPRAM_VPD_BUF_SIZE) != OK) return (ERROR); if ( sysVpdPktParse (&sysVpd, &sysVpdPkts[0], VPD_PKT_LIMIT) != OK) return (ERROR); /* get the product configuration options */ if (sysVpdPktGet (VPD_PID_PCO, 0, &sysVpdPkts[0], &pVpdPkt) == OK) bcopy((const char *)(pVpdPkt->data), (char *)&sysConfigOptions, 16); /* get the PCI bus speed */ if ( (sysVpdPktGet (VPD_PID_PCS, 0, &sysVpdPkts[0], &pVpdPkt) == OK) && (pVpdPkt->size == sizeof (UINT32)) ) sysPciSpeed = *(UINT32 *)&pVpdPkt->data[0]; else sysPciSpeed = DEFAULT_PCI_CLOCK; /* get the bus speed */ if ( (sysVpdPktGet (VPD_PID_ECS, 0, &sysVpdPkts[0], &pVpdPkt) == OK) && (pVpdPkt->size == sizeof (UINT32)) ) sysBusSpeed = *(UINT32 *)&pVpdPkt->data[0]; else sysBusSpeed = DEFAULT_CLOCK_SPEED; /* get the internal cpu speed */ if ( (sysVpdPktGet (VPD_PID_ICS, 0, &sysVpdPkts[0], &pVpdPkt) == OK) && (pVpdPkt->size == sizeof (UINT32)) ) sysCpuSpeed = *(UINT32 *)&pVpdPkt->data[0]; else sysCpuSpeed = DEFAULT_CLOCK_SPEED; /* get the ethernet address of the board and save it */ if (sysVpdPktGet (VPD_PID_EA, 0, &sysVpdPkts[0], &pVpdPkt) == OK) /* store the boards ethernet address into a temp Ethernet array */ for (idx = 0; idx < pVpdPkt->size; idx++) tempEnetAddr[idx] = pVpdPkt->data[idx]; /* get the board product identifier */ if ( (sysVpdPktGet (VPD_PID_PID, 0, &sysVpdPkts[0], &pVpdPkt) == OK) && ((pVpdPkt->size + 1) < sizeof (sysProductStr)) ) { for (idx = 0; idx < pVpdPkt->size; idx++) sysProductStr[idx] = pVpdPkt->data[idx]; sysProductStr[idx] = '\0'; } /* get the factory number from the VPD buffer */ if ( (sysVpdPktGet (VPD_PID_FAN, 0, &sysVpdPkts[0], &pVpdPkt) == OK) && ((pVpdPkt->size + 1) < sizeof (sysFactoryNum)) ) { for (idx = 0; idx < pVpdPkt->size; idx++) sysFactoryNum[idx] = pVpdPkt->data[idx]; sysFactoryNum[idx] = '\0'; } /* get the boards serial number */ if ( (sysVpdPktGet (VPD_PID_SN, 0, &sysVpdPkts[0], &pVpdPkt) == OK) && ((pVpdPkt->size + 1) < sizeof (sysSerialNum)) ) { for (idx = 0; idx < pVpdPkt->size; idx++) sysSerialNum[idx] = pVpdPkt->data[idx]; sysSerialNum[idx] = '\0'; } /* get the MPU type */ if ( (sysVpdPktGet (VPD_PID_MT, 0, &sysVpdPkts[0], &pVpdPkt) == OK) && ((pVpdPkt->size + 1) < sizeof (sysMpuType)) ) { for (idx = 0; idx < pVpdPkt->size; idx++) sysMpuType[idx] = pVpdPkt->data[idx]; sysMpuType[idx] = '\0'; } /* get size of SDRAM */ sysSdramSize = cpvI2cEepromRead (I2C_DRAM_DATA, (UCHAR *)&buffer[0], 0); if ((sysSdramSize != MEM_SIZE_16MB) && (sysSdramSize != MEM_SIZE_32MB) && (sysSdramSize != MEM_SIZE_64MB) && (sysSdramSize != MEM_SIZE_128MB)) sysSdramSize = DEFAULT_SDRAM_SIZE; sysSdramSpd = MEM_SPEED_60NS; if ((*PLPRCR(immrVal) & PLPRCR_MF_MSK) == 0) sysRefClkFrq = sysCpuSpeed; else sysRefClkFrq = 32768; /* 32768 Hz */ sysFlashSize = DEFAULT_FLASH_SIZE; return (OK); }/********************************************************************************* sysProdConfigGet - initialize the board vital product data structures.** This routine tests the presence of a caller specified product configuration* option using the contents of the product configuration option vpd packet.** RETURNS: TRUE if the option is present or FALSE if the product configuration* option is not present or if the product configuration option packet is* missing.** SEE ALSO: N/A*/BOOL sysProdConfigGet ( UINT32 optionId /* packet type to match */ ) { UCHAR mask; UINT32 byteIdx;#ifdef TOLERATE_CONFIG_ERRORS /* console and first ethernet are alway present */ if ( (optionId == PCO_SERIAL1_CONN) || (optionId == PCO_ENET1_CONN) ) return (TRUE);#endif /* TOLERATE_CONFIG_ERRORS */ /* see if we have a valid board option vpd packet and option id. */ if (pSysBrdOpts == NULL) return (FALSE); /* calculate the bit mask and byte index */ mask = 0x80 >> (optionId % 8); byteIdx = optionId / 8; /* if byte index is off the end of the data array, return false. */ if (byteIdx >= pSysBrdOpts->size) return (FALSE); return ( (pSysBrdOpts->data[byteIdx] & mask) != 0 ); }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -