/*
* Copyright 2005 by Spectrum Digital Incorporated.
* All rights reserved. Property of Spectrum Digital Incorporated.
*
* Not for distribution.
*/
/*
* Board Setup ( for ARM and/or DSP )
*
*/
#include "davincievm_psc.h"
#ifdef ARM_SIDE
#include "csl_psc.h"
CSL_PscHandle psc_handle;
CSL_PscObj psc_obj;
#elif DSP_SIDE
#endif
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_initPsc( ) *
* *
* *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_initPsc( )
{
#ifdef ARM_SIDE
CSL_Status status;
CSL_pscInit( );
psc_handle = CSL_pscOpen( &psc_obj, 0, 0, &status );
return 0;
#elif DSP_SIDE
return 0;
#endif
}
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_enableDspPowerDomain( ) *
* *
* The "Power Domain" controls all the modules below it. There are *
* only 2 domains ALWAYSON and DSP. This function will only be able *
* to affect the DSP power domain. *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_enableDspPowerDomain( )
{
#ifdef ARM_SIDE
if ( CSL_pscHwControl( psc_handle, CSL_PSC_CMD_DSP_PWR_ON, 0 ) == CSL_SOK )
return 0;
else
return 1;
#elif DSP_SIDE
Uint32 dspdomainbit = 0x0002;
while( ( PSC_PTSTAT & dspdomainbit ) != 0 ); // Wait for state transtion to finish
PSC_PDCTL1 |= 0x0001; // Turn ON power domain
PSC_PTCMD = dspdomainbit; // Start state transition
while( ( PSC_EPCPR & dspdomainbit ) == 0 ); // Wait for external power request
/*
* Apply External Power if needed.
*/
PSC_PDCTL1 |= 0x0100; // Turn ON external power
while( ( PSC_PTSTAT & dspdomainbit ) != 0 ); // Wait for state transtion to finish
return 0;
#endif
}
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_disableDspPowerDomain( ) *
* *
* The "Power Domain" controls all the modules below it. There are *
* only 2 domains ALWAYSON and DSP. This function will only be able *
* to affect the DSP power domain. *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_disableDspPowerDomain( )
{
#ifdef ARM_SIDE
if ( CSL_pscHwControl( psc_handle, CSL_PSC_CMD_DSP_PWR_OFF, 0 ) == CSL_SOK )
return 0;
else
return 1;
#elif DSP_SIDE
Uint32 dspdomainbit = 0x0002;
while( ( PSC_PTSTAT & dspdomainbit ) != 0 ); // Wait for state transtion to finish
PSC_PDCTL1 &= ~0x0001; // Turn OFF power domain
PSC_PTCMD = dspdomainbit; // Start state transition
while( ( PSC_EPCPR & dspdomainbit ) == 0 ); // Wait for external power request
/*
* Remove External Power if needed ???
*/
PSC_PDCTL1 &= ~0x0100; // Turn ON external power
while( ( PSC_PTSTAT & dspdomainbit ) != 0 ); // Wait for state transtion to finish
return 0;
#endif
}
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_enableAllPowerModules( ) *
* *
* This turns on all clocks in ALWAYSON and DSP power domains. *
* Note this function assumes that the Power Domains are already on. *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_enableAllPowerModules( )
{
#ifdef ARM_SIDE
if ( CSL_pscHwControl( psc_handle, CSL_PSC_CMD_MD_STATE_ENABLE_ALL, 0 ) == CSL_SOK )
return 0;
else
return 1;
#elif DSP_SIDE
Int16 i;
volatile Uint32* mdctl = ( Uint32* )PSC_MDCTL_BASE;
Uint8 module_intr_list[15] = { 1,5,6,7,9,10,11,12,13,14,15,16,17,26,40 } ;
for ( i = 0 ; i < 41 ; i++ ) // Enable all 41 power modules
*mdctl++ |= 0x0003;
for ( i = 0 ; i < 15 ; i++ ) // Enable Interrupts for these modules
*( Uint32* )( PSC_MDCTL_BASE + 4 * module_intr_list[i] ) |= 0x0200;
*( Uint32* )( PSC_MDCTL_BASE + 4 * 8 ) = 0x000; // IEEE1394A - OFF
PSC_PTCMD = 0x0001; // ALWAYSON domain state transition
while( ( PSC_PTSTAT & 0x0001 ) != 0 );
PSC_PTCMD = 0x0002; // DSP domain state transition
while( ( PSC_PTSTAT & 0x0002 ) != 0 );
for ( i = 0 ; i < 15 ; i++ ) // Clear Interrupts for these modules
*( Uint32* )( PSC_MDCTL_BASE + 4 * module_intr_list[i] ) &= 0xFDFF;
return 0;
#endif
}
/* ------------------------------------------------------------------------ *
* *
* DAVINCIEVM_enablePowerModule( domain, id ) *
* *
* *
* *
* *
* ------------------------------------------------------------------------ */
Int16 DAVINCIEVM_enablePowerModule( Uint32 domain, Uint32 id )
{
#ifdef ARM_SIDE
CSL_PscMdCfg psc_mdcfg;
psc_mdcfg.mdId = ( CSL_PscMdId* )&id; // Module ID(s)
psc_mdcfg.numMds = 1; // # Modules
psc_mdcfg.mdState = 0; // Module State(s)
psc_mdcfg.mdIntEnable = 0; // Module Interrupt(s)
psc_mdcfg.mdStateRecord = 0; // Current state
if ( CSL_pscHwControl( psc_handle, CSL_PSC_CMD_MD_STATE_ENABLE, &psc_mdcfg ) == CSL_SOK )
return 0;
else
return 1;
#elif DSP_SIDE
Uint32 domainbit = ( 1 << ( domain & 1 ) );
Uint8 enableinterrupts = 0;
volatile Uint32* mdstat = ( Uint32* )( PSC_MDSTAT_BASE + 4 * id );
volatile Uint32* mdctl = ( Uint32* )( PSC_MDCTL_BASE + 4 * id );
if ( domain == DSP_POWER_DOMAIN )