Skip to main content
Sign in
Snippets Groups Projects
Select Git revision
  • 7e2592fd5ac3dce73aceb11e1526629840e52797
  • sige5-dev default
  • rk3576-sige5-kwiboo-mainline
3 results

speed.c

Blame
  • speed.c 7.39 KiB
    /*
     *
     * Copyright (C) 2004-2007, 2012 Freescale Semiconductor, Inc.
     * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
     *
     * See file CREDITS for list of people who contributed to this
     * project.
     *
     * This program is free software; you can redistribute it and/or
     * modify it under the terms of the GNU General Public License as
     * published by the Free Software Foundation; either version 2 of
     * the License, or (at your option) any later version.
     *
     * This program is distributed in the hope that it will be useful,
     * but WITHOUT ANY WARRANTY; without even the implied warranty of
     * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     * GNU General Public License for more details.
     *
     * You should have received a copy of the GNU General Public License
     * along with this program; if not, write to the Free Software
     * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
     * MA 02111-1307 USA
     */
    
    #include <common.h>
    #include <asm/processor.h>
    
    #include <asm/immap.h>
    #include <asm/io.h>
    
    DECLARE_GLOBAL_DATA_PTR;
    
    /*
     * Low Power Divider specifications
     */
    #define CLOCK_LPD_MIN		(1 << 0)	/* Divider (decoded) */
    #define CLOCK_LPD_MAX		(1 << 15)	/* Divider (decoded) */
    
    #define CLOCK_PLL_FVCO_MAX	540000000
    #define CLOCK_PLL_FVCO_MIN	300000000
    
    #define CLOCK_PLL_FSYS_MAX	266666666
    #define CLOCK_PLL_FSYS_MIN	100000000
    #define MHZ			1000000
    
    void clock_enter_limp(int lpdiv)
    {
    	ccm_t *ccm = (ccm_t *)MMAP_CCM;
    	int i, j;
    
    	/* Check bounds of divider */
    	if (lpdiv < CLOCK_LPD_MIN)
    		lpdiv = CLOCK_LPD_MIN;
    	if (lpdiv > CLOCK_LPD_MAX)
    		lpdiv = CLOCK_LPD_MAX;
    
    	/* Round divider down to nearest power of two */
    	for (i = 0, j = lpdiv; j != 1; j >>= 1, i++) ;
    
    #ifdef CONFIG_MCF5445x
    	/* Apply the divider to the system clock */
    	clrsetbits_be16(&ccm->cdr, 0x0f00, CCM_CDR_LPDIV(i));
    #endif
    
    	/* Enable Limp Mode */
    	setbits_be16(&ccm->misccr, CCM_MISCCR_LIMP);
    }
    
    /*
     * brief   Exit Limp mode