?? cpvsystemconfig.c
字號(hào):
/* cpvSystemConfig.c - Motorola CPV3060 board sytem configuration *//* Copyright 1998-2001 Wind River Systems, Inc. *//* Copyright 1998,2000 Motorola, Inc., All Rights Reserved *//*modification history--------------------01m,16sep01,dat Use of WRS_ASM macro01l,05dec00,rhk cleanup to comply with WRS coding standards.01k,06jun99,krp 'bclr' short circuits stack cleanup with optimization turned off01j,09aug99,rhk modified the file to support the standardized Motorola VPD routines, only the cpvMemcConfig routine is necessary.01i,16jul99,rhk modified code for SDRAM sizing.01h,15jul99,rhk code review cleanup.01g,09jul99,rhk removed DIMM code from file, updated setup of global variables for cpv3060 (in both DPRAM and system globals), added code to init SDRAM and configure the memory banks. Added sysCpvMsDelay routine.01f,09jun99,srr changed to support cpv3060.01e,02oct98,rhk changed large case statements for setting DIMM size, banks to if-then-else usage due to possible HW problem.01d,30sep98,rhk added masking of bits when setting up the BR/OR 1-3 registers in cpvMemcConfig. Added code to reconfigure the MAMR register value based on # of memory banks.01c,18sep98,rhk modified parsing algorithm in cpdVpdValueGet01b,16sep98,rhk added default DRAM speed setup tp cpvConfigParamsGet01a,01sep98,rhk written.*//*DESCRIPTIONSystem configuration routines written in C that are called from romInit.sand sysMotVpdCpv3060.c. *//* includes */#include "vxWorks.h"/* defines */#ifndef SYNC# define SYNC WRS_ASM("sync")#endif /* SYNC *//* typedefs *//* globals */LOCAL UINT32 sysCpvGetDec(void);void sysCpvMsDelay (UINT mSeconds);/* externals */IMPORT int abs ();/* locals *//********************************************************************************* cpvMemcConfig - configure the MEMC registers** This routine will perform the final adjustments to the Memory* Controller Bank/Option registers.** RETURNS: N/A*/void cpvMemcConfig(void) { UINT32 temp; UINT32 banks; /* determine the number of SDRAM banks present */ banks = 1; if (sysConfigOptions.sdram) banks = 2; if (banks == 2) *MAMR( INTERNAL_MEM_MAP_ADDR ) = (0x0c000000 | MAMR_PTBE | MAMR_RLFB_2X | MAMR_WLFB_8X | MAMR_TLFB_1X ); /* finish initializing the SDRAM, do the second bank if present */ if (banks == 2) { *MCR( INTERNAL_MEM_MAP_ADDR ) = (MCR_OP_RUN | MCR_MB_CS1 | MCR_MCLF_1X | UPMA_READ_OFFSET); SYNC; *MCR( INTERNAL_MEM_MAP_ADDR ) = (MCR_OP_RUN | MCR_MB_CS1 | MCR_MCLF_1X | UPMA_BURST_WR_OFFSET); SYNC; *MAR( INTERNAL_MEM_MAP_ADDR ) = 0x00000088; *MCR( INTERNAL_MEM_MAP_ADDR ) = (MCR_OP_RUN | MCR_MB_CS1 | MCR_MCLF_1X | UPMA_WRITE_OFFSET); SYNC; } /* resize and enable the SDRAM memory banks */ if (sysSdramSize == MEM_SIZE_32MB) { if (banks == 1) { *OR2( INTERNAL_MEM_MAP_ADDR ) = ((~(MEM_SIZE_32MB)+1) | OR_ACS_DIV4); *BR2( INTERNAL_MEM_MAP_ADDR ) = (BR_MS_UPMA | BR_V); } else { *OR1( INTERNAL_MEM_MAP_ADDR ) = ((~(MEM_SIZE_16MB)+1) | OR_ACS_DIV4); *BR1( INTERNAL_MEM_MAP_ADDR ) = (MEM_SIZE_16MB | BR_MS_UPMA | BR_V); } } else if (sysSdramSize == MEM_SIZE_64MB) { if (banks == 1) { *OR2( INTERNAL_MEM_MAP_ADDR ) = ((~(MEM_SIZE_64MB)+1) | OR_ACS_DIV4); *BR2( INTERNAL_MEM_MAP_ADDR ) = (BR_MS_UPMA | BR_V); } else { *OR2( INTERNAL_MEM_MAP_ADDR ) = ((~(MEM_SIZE_32MB)+1) | OR_ACS_DIV4); *OR1( INTERNAL_MEM_MAP_ADDR ) = ((~(MEM_SIZE_32MB)+1) | OR_ACS_DIV4); *BR2( INTERNAL_MEM_MAP_ADDR ) = (BR_MS_UPMA | BR_V); *BR1( INTERNAL_MEM_MAP_ADDR ) = (MEM_SIZE_32MB | BR_MS_UPMA | BR_V); } } else if (sysSdramSize == MEM_SIZE_128MB) { *OR2( INTERNAL_MEM_MAP_ADDR ) = ((~(MEM_SIZE_64MB)+1) | OR_ACS_DIV4); *OR1( INTERNAL_MEM_MAP_ADDR ) = ((~(MEM_SIZE_64MB)+1) | OR_ACS_DIV4); *BR2( INTERNAL_MEM_MAP_ADDR ) = (BR_MS_UPMA | BR_V); *BR1( INTERNAL_MEM_MAP_ADDR ) = (MEM_SIZE_64MB | BR_MS_UPMA | BR_V); } /* if QSPAN is present, then enable the valid bits for the PCI banks */ if (sysConfigOptions.pci) { temp = *BR5(INTERNAL_MEM_MAP_ADDR) | BR_V; *BR5(INTERNAL_MEM_MAP_ADDR) = temp; temp = *BR6(INTERNAL_MEM_MAP_ADDR) | BR_V; *BR6(INTERNAL_MEM_MAP_ADDR) = temp; } /* * delay for 10MS to allow SDRAM to settle * Enable the decrementer before the delay. * Disable the decrementer after the delay. */ * TBSCR(INTERNAL_MEM_MAP_ADDR) = TBSCR_TBE | TBSCR_TBF; sysCpvMsDelay (10); * TBSCR(INTERNAL_MEM_MAP_ADDR) &= ~TBSCR_TBE; }/******************************************************************************** sysCpvMsDelay - delay for the specified amount of time (MS)** This routine will delay for the specified amount of time by counting* decrementer ticks.** This routine is not dependent on a particular rollover value for* the decrementer, it should work no matter what the rollover* value is.** A small amount of count may be lost at the rollover point resulting in* the sysCpvMsDelay() causing a slightly longer delay than requested.** This routine will produce incorrect results if the delay time requested* requires a count larger than 0xffffffff to hold the decrementer* elapsed tick count. For a System Bus Speed of 67 MHZ this amounts to* about 258 seconds.** RETURNS: N/A*/void sysCpvMsDelay ( UINT delay /* length of time in MS to delay */ ) { register UINT32 oldval; /* decrementer value */ register UINT32 newval; /* decrementer value */ register UINT32 totalDelta; /* Dec. delta for entire delay period */ register UINT32 decElapsed; /* cumulative decrementer ticks */ /* Calculate delta of decrementer ticks for desired elapsed time. */ totalDelta = ((sysCpuSpeed / DEC_CLK_TO_INC) / 1000) *delay; /* * Now keep grabbing decrementer value and incrementing "decElapsed" until * we hit the desired delay value. Compensate for the fact that we may * read the decrementer at 0xffffffff before the interrupt service * routine has a chance to set in the rollover value. */ decElapsed = 0; oldval = sysCpvGetDec(); while (decElapsed < totalDelta) { newval = sysCpvGetDec(); if ( DELTA(oldval,newval) < 1000 ) decElapsed += DELTA(oldval,newval); /* no rollover */ else if (newval > oldval) decElapsed += abs((int)oldval); /* rollover */ oldval = newval; } }/******************************************************************************** sysCpvGetDec - read from the Decrementer register SPR22.** This routine will read the contents the decrementer (SPR22)** RETURNS: value of SPR22 (in r3)*/LOCAL UINT32 sysCpvGetDec(void) { return vxDecGet(); }
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -