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

📄 cpu.c

📁 Intrisyc 公司的PXA255-bootloader,源码易懂
💻 C
字号:
//////////////////////////////////////////////////////////////////////////////////// Copyright(c) 2002 Intrinsyc Software Inc. All rights reserved.//// Module name:////      cpu_xscale.c//// Description:////      CPU settings.//// Author:////      Dan Fandrich//// Created:////      September 2002//////////////////////////////////////////////////////////////////////////////////#include <c_main.h>#include <types.h>#include <timer.h>#include <cpu.h>extern void freq_change(u32 cccr);typedef struct{	u32 freq;	u32 mult;} freqs_t;#ifdef XSCALE// Value for CCCRstatic freqs_t speed_table_pxa250[] = {        {400, 0x241},        {300, 0x1C1},        {200, 0x141},        {0, 0}  // end of table};static freqs_t speed_table_pxa255[] = {        {400, 0x161},        {398, 0x241},        {300, 0x1C1},        {200, 0x141},        {100, 0x121},        {0, 0}  // end of table};#else// Value for CCFstatic freqs_t speed_table_sa[] = {        {221, 0x0B},        {206, 0x0A},        {192, 0x09},        {177, 0x08},        {162, 0x07},        {148, 0x06},        {133, 0x05},        {118, 0x04},        {103, 0x03},        {89, 0x02},        {74, 0x01},        {59, 0x00},        {0, 0}};#endif////////////////////////////////////////////////////////////////////////////////// get_speed_multiplier// PURPOSE: Return the multiplier value for the given CPU speed// PARAMS:  (IN/OUT) u32 *freq - CPU frequency in MHz//          (OUT) u32 *mul - multiplier// RETURNS: 1 for success, 0 for failure.////////////////////////////////////////////////////////////////////////////////static inline intget_speed_multiplier(u32 *freq, u32 *mult){    int i = 0;    freqs_t *speed_table = 0;#ifdef XSCALE    if( status.processor == pxa255)    {//	itc_printf("Using PXA255 frequency points.\r\n");	speed_table = speed_table_pxa255;    }    else    {//	itc_printf("Using PXA250 frequency points.\r\n");	speed_table = speed_table_pxa250;    }#else    speed_table = speed_table_sa;#endif    for (i=0; speed_table[i].freq > *freq; ++i)        ; // search table    *freq = speed_table[i].freq;    *mult = speed_table[i].mult;    return (*freq > 0);}////////////////////////////////////////////////////////////////////////////////// set_cpu_speed// PURPOSE: Sets the CPU speed// PARAMS:  (IN) int speed - speed in MHz// RETURNS: CPU speed actually set, or < 0 for invalid speed////////////////////////////////////////////////////////////////////////////////intset_cpu_speed(u32 speed){   u32 multiplier;   if (!get_speed_multiplier(&speed, &multiplier))   {       return -1;   }   // Wait for serial port to flush (only needed on SA-1110)   udelay(10000);   freq_change(multiplier);   // Wait for PLL to stabilize before writing to serial port (only   // needed on SA-1110)   udelay(500);   return speed;}

⌨️ 快捷键说明

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