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

📄 initfuncs.c

📁 ST5100 driver files for ST chipset
💻 C
📖 第 1 页 / 共 3 页
字号:
}



static void STi7710InitDLL(int Step) 
{
    volatile unsigned long temp;
    if (Step == 1) {
    /*
        #####################################################
        ## STEP 1 = Synchronous Mode                       ## 
        #####################################################
        ##  At this step, LMI has been configured !!! 
   */
   /*     write DLL setup*/
        /*
	## check that DLL1 and DLL2 are locked 
        ## LMI_CIC = 0xCC000040   
	*/
        temp = *(volatile unsigned long*)STI7710_LMI_CIC;
        temp = temp >> 9 ;
        temp &= 0x1 ;
        if (temp){
	/*
            ##write DLL1 Locked 
            ##temp = STSYS_ReadRegDev32LE (STI7710_LMI_CIC) 
            ##temp = temp & 0x1FF ; 
            ##write DLL1_command  = -x (temp)
	    */
        }else {   
	/*
            write Warning - DLL1 NOT Locked*/
        }

        /*## DLL 2*/
        temp = *(volatile unsigned long*)STI7710_LMI_CIC;
        temp = temp >> 19 ;
        temp &= 0x1 ;
        if (temp){
	/*
            ##write DLL2 Locked 
            ##temp = STSYS_ReadRegDev32LE (STI7710_LMI_CIC) 
            ##temp = temp >> 10 ; 
            ##temp = temp & 0x1FF ; 
            ##write DLL2_command  = -x (temp)
	    */
        }else {  
            /*write warning DLL2 NOT Locked*/
        }
 
        /*## switch to lower freq (Imipl Clk) */
        temp = *(volatile unsigned long*)STI7710_PLL_CLOCKGEN_CTRL_0;
        temp &= 0x0000FFFF ;
        temp |= 0x5aa50000 ;
        temp &= 0xffffffef ;
        *(volatile unsigned long*)STI7710_PLL_CLOCKGEN_CTRL_0 = temp;
 	/*     
        ## Ensure that : 
        ##      - dll3_bypass = 0  
        ##      - dll3_nrst   = 1 
	*/
        temp &= 0xfffffff7 ;
        temp |= 0x00000040 ;
        *(volatile unsigned long*) STI7710_PLL_CLOCKGEN_CTRL_0 = temp;
/*
        ## enable HW to reset DLL3 when clocks are generated with the crystal clock  
        ##  => avoid to hang the device
        ##  ( no delay between releasing the reset and switching to 200Mhz )    
	*/
        temp |= 0x00000100;
        *(volatile unsigned long*) STI7710_PLL_CLOCKGEN_CTRL_0 = temp;
         
        /*## Reset DLL */
        Delay(10);

        /*## switch back to normal clk source      */
        temp |= 0x00000010;
        *(volatile unsigned long*) STI7710_PLL_CLOCKGEN_CTRL_0 =  temp;
        
        Delay(10);

        /*## Check for DLL (test value in a minute)*/
        temp = *(volatile unsigned long*) STI7710_PLL_CLOCKGEN_CTRL_1;
        temp = temp >> 6;  
        temp &= 0x1 ; 
        
        if (temp == 0 ){
/*            write [invert polarity]  */
        } 
        
        /*## push not(lock_status) in dll3_invert bit */
        temp = ((~temp)&0x1) << 7  ;
        temp |= 0x5aa50000;
        
        /*## invert clock if we need to*/
        temp |= *(volatile unsigned long*) STI7710_PLL_CLOCKGEN_CTRL_0 ;
        *(volatile unsigned long*)STI7710_PLL_CLOCKGEN_CTRL_0 = temp;

        Delay(5);

        /*## 2nd Check for lock*/
        temp = *(volatile unsigned long*) STI7710_PLL_CLOCKGEN_CTRL_1;
        temp = temp >> 6;  
        temp &= 0x1 ; 
        if (temp){
/*            write DLL3 Locked OK*/
            /*##temp = STSYS_ReadRegDev32LE (STI7710_PLL_CLOCKGEN_CTRL_1) 
            ##temp = temp >> 7 ; 
            ##temp = temp & 0x1FF ; 
            ##write DLL3_command  = -x (temp)*/
            /*$$ = 0*/
	    /*return(0);*/
        } else {
/*            write DLL3 NOT Locked */
            /*$$ = 1;*/
	    /*return(1);*/
        } 

        /*write DLL Done*/
    } 

    if (Step == 2) {
    /*
        ################################################################
        ## STEP 3 = Asynchronous Mode                                 ## 
        ## Use Async mode if you wish to change LMI frequency without ##
        ## changing CPU frequency                                     ##
        ################################################################
          
        write Using Asyncronous Clock Setup */

        
	/*$$ = 0*/
	/*return(0);*/
    }   
}


 
static void STi7710InitFrequencySynths(void)
{
	volatile unsigned long temp;
/*    
    #####################################################
    ## STEP 4 = Start Frequency Synths                 ## 
    #####################################################
*/    
    /*write Frequency Synthesizer Setup*/
/*       
    ## Stop clocks (avoid possible glitch) except pad_aux_clock bit 2 
    ## (in case we are in async mode)
*/    
    *(volatile unsigned long*) STI7710_FS_CLOCKGEN_CFG_0 = 0x5aa5FFFb ;

	/*******************************/
	/* following reset required for GNBvd47259, cold-boot problem */

	/* FS0 FS1 & PCM CLK power OFF */
	temp = *(volatile unsigned long*)  STI7710_FS_0_CTRL;
    temp |= 0x5AA50001;
    *(volatile unsigned long*)   STI7710_FS_0_CTRL = temp;
	*(volatile unsigned long*)   STI7710_FS_1_CTRL = temp;
	*(volatile unsigned long*)   (0x38210600)      = 0x00000028;

    /* wait around 1 ms */
    Delay(200);

    /* FS0 FS1 & PCM CLK power ON */
	temp &= 0xFFFFFFFE;
	*(volatile unsigned long*)   STI7710_FS_0_CTRL = temp;
	*(volatile unsigned long*)   STI7710_FS_1_CTRL = temp;
	*(volatile unsigned long*)   (0x38210600)      = 0x00000008;

	/**********************************/

/*    ## FS01 */
    temp = *(volatile unsigned long*)  STI7710_FS_01_CONFIG_0;
    temp |= 0x5AA50000;
    temp &= 0xFFFFFFFC;
    *(volatile unsigned long*)   STI7710_FS_01_CONFIG_0 =temp;
    temp |= 0x00000003;
    *(volatile unsigned long*)   STI7710_FS_01_CONFIG_0 =temp;
    temp &= 0xFFFFFFFE;
    *(volatile unsigned long*)   STI7710_FS_01_CONFIG_0 =temp;

    /*## FS02*/
    temp = *(volatile unsigned long*)  STI7710_FS_02_CONFIG_0;
    temp |= 0x5AA50000;
    temp &= 0xFFFFFFFC;
    *(volatile unsigned long*)   STI7710_FS_02_CONFIG_0= temp;
    temp |= 0x00000003;
    *(volatile unsigned long*)   STI7710_FS_02_CONFIG_0= temp;
    temp &= 0xFFFFFFFE;
    *(volatile unsigned long*)   STI7710_FS_02_CONFIG_0= temp;

    /*## FS04*/
    temp = *(volatile unsigned long*)  STI7710_FS_04_CONFIG_0;
    temp |= 0x5AA50000;
    temp &= 0xFFFFFFFC;
    *(volatile unsigned long*)   STI7710_FS_04_CONFIG_0= temp;
    temp |= 0x00000003;
    *(volatile unsigned long*)   STI7710_FS_04_CONFIG_0= temp;
    temp &= 0xFFFFFFFE;
    *(volatile unsigned long*)   STI7710_FS_04_CONFIG_0= temp;

    /*## FS11*/
    temp = *(volatile unsigned long*)  STI7710_FS_11_CONFIG_0;
    temp |= 0x5AA50000;
    temp &= 0xFFFFFFFC;
    *(volatile unsigned long*)   STI7710_FS_11_CONFIG_0 =temp;
    temp |= 0x00000003;
    *(volatile unsigned long*)   STI7710_FS_11_CONFIG_0 =temp;
    temp &= 0xFFFFFFFE;
    *(volatile unsigned long*)   STI7710_FS_11_CONFIG_0 =temp;

    /*## FS12*/
    temp = *(volatile unsigned long*)  STI7710_FS_12_CONFIG_0;
    temp |= 0x5AA50000;
    temp &= 0xFFFFFFFC;
    *(volatile unsigned long*)   STI7710_FS_12_CONFIG_0 =temp;
    temp |= 0x00000003;
    *(volatile unsigned long*)   STI7710_FS_12_CONFIG_0 =temp;
    temp &= 0xFFFFFFFE;
    *(volatile unsigned long*)   STI7710_FS_12_CONFIG_0 =temp;

    /*## FS13*/
    temp = *(volatile unsigned long*)  STI7710_FS_13_CONFIG_0;
    temp |= 0x5AA50000;
    temp &= 0xFFFFFFFC;
    *(volatile unsigned long*)   STI7710_FS_13_CONFIG_0 =temp;
    temp |= 0x00000003;
    *(volatile unsigned long*)   STI7710_FS_13_CONFIG_0 =temp;
    temp &= 0xFFFFFFFE;
    *(volatile unsigned long*)   STI7710_FS_13_CONFIG_0 =temp;

    /*## FS14*/
    temp = *(volatile unsigned long*)  STI7710_FS_14_CONFIG_0;
    temp |= 0x5AA50000;
    temp &= 0xFFFFFFFC;
    *(volatile unsigned long*)   STI7710_FS_14_CONFIG_0 =temp;
    temp |= 0x00000003;
    *(volatile unsigned long*)   STI7710_FS_14_CONFIG_0 =temp;
    temp &= 0xFFFFFFFE;
    *(volatile unsigned long*)   STI7710_FS_14_CONFIG_0 =temp;

    /*## PCM CLK (registers are mapped in Audio-ADSC ) */
    /*
    STI7710_CKG_CFG  =  0x38210600 ;
    STI7710_CKG_MD   =  0x38210604 ;
    STI7710_CKG_PE   =  0x38210608 ;
    STI7710_CKG_SDIV =  0x3821060c ;
    STI7710_CKG_PSEL =  0x38210610 ;
    STI7710_CKG_PROG =  0x38210614 ;
    */
    *(volatile unsigned long*)   (0x38210600)/*STI7710_CKG_CFG*/ = 0x00000018 ;/*### CFG[8:0] : Reset Assert*/ 
    *(volatile unsigned long*)   (0x38210600)/*STI7710_CKG_CFG*/ = 0x00000008 ;/*### CFG[8:0] : Reset De-assert sel27 =0*/
    *(volatile unsigned long*)   (0x38210604)/*STI7710_CKG_MD*/  = 0x0000001c ;/*### MD[4:0]  */
    *(volatile unsigned long*)   (0x38210608)/*STI7710_CKG_PE*/  = 0x0000199a ;/*### PE[15:0] */
    *(volatile unsigned long*)   (0x3821060c)/*STI7710_CKG_SDIV*/= 0x00000003 ;/*### SDIV[2:0] */
    *(volatile unsigned long*)   (0x38210610)/*STI7710_CKG_PSEL*/= 0x00000001 ;/*### PSEL[0] */
    *(volatile unsigned long*)   (0x38210614)/*STI7710_CKG_PROG*/= 0x00000001 ;/*### PRG_EN[0] */

    /*## Rejection PLL2  
    ## Stop PLL2 ( nreset = 0  ) */
    temp  = *(volatile unsigned long*) STI7710_PLL2_CONFIG_2; 
    temp &= 0x0000FFFB;
    temp |= 0x5aa50000;
    *(volatile unsigned long*) STI7710_PLL2_CONFIG_2 = temp;
    temp  = 0x5aa50004; 
    *(volatile unsigned long*) STI7710_PLL2_CONFIG_2 = temp;

    /*## Restart FS clocks   */
    *(volatile unsigned long*)   STI7710_FS_CLOCKGEN_CFG_0 = 0x5aa50000 ;


}

⌨️ 快捷键说明

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