⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 davincihd_psc.c

📁 用于dm6467 开发平台的uboot源码
💻 C
字号:
/*
 *  Copyright 2007 by Spectrum Digital Incorporated.
 *  All rights reserved. Property of Spectrum Digital Incorporated.
 */

/*
 *  Power Sleep Controller
 *
 */

#include "davincihd_psc.h"

static Int32 psc_timeout = ( 0x00010000 );

/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  _PSC_enableAll( )                                                       *
 *      Enable all non reserved power domains                               *
 *                                                                          *
 * ------------------------------------------------------------------------ */
Int16 DAVINCIHD_PSC_enableAll( )
{
    Int16 i;

    for ( i = 1 ; i <= 35 ; i++ )
        DAVINCIHD_PSC_changeState( i, PSC_ENABLE );
    i = 45;
        DAVINCIHD_PSC_changeState( i, PSC_ENABLE );

    return 0;
}

/* ------------------------------------------------------------------------ *
 *                                                                          *
 *  _PSC_changeState( id, state )                                           *
 *      Change power module state to ( ENABLE, DISABLE, SYNCRESET, RESET )  *
 *                                                                          *
 *      Inputs:                                                             *
 *              id    -> PSC id                                             *
 *              state -> End PSC state                                      *
 *                                                                          *
 * ------------------------------------------------------------------------ */
Int16 DAVINCIHD_PSC_changeState( Uint32 id, Uint16 state )
{
    Int32 timeout;
    volatile Uint32* mdstat = ( Uint32* )( PSC_MDSTAT_BASE + ( 4 * id ) );
    volatile Uint32* mdctl  = ( Uint32* )( PSC_MDCTL_BASE  + ( 4 * id ) );

    /*
     *  Step 0 - Ignore request if the state is already set as is
     */
    if ( ( *mdstat & 0x001f ) == state )
        return 0;

    /*
     *  Step 1 - Wait for PTSTAT.GOSTAT to clear
     */
    timeout = psc_timeout;
    while( PSC_PTSTAT & 1 )
        if ( timeout-- < 0 )
            return -1;

    /*
     *  Step 2 - Set MDCTLx.NEXT to new state
     */
    *mdctl &= ~0x001f;
    *mdctl |= state;

    /*
     *  Step 3 - Start power transition ( set PTCMD.GO to 1 )
     */
    PSC_PTCMD = 0x0001;

    /*
     *  Step 4 - Wait for PTSTAT.GOSTAT to clear
     */
    timeout = psc_timeout;
    while( PSC_PTSTAT & 1 )
        if ( timeout-- < 0 )
            return -1;

    /*
     *  Step 5 - Verify state changed
     */
    timeout = psc_timeout;
    while( ( *mdstat & 0x001f ) != state )
        if ( timeout-- < 0 )
            return -1;

    return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -