diff options
author | stroese <stroese> | 2004-12-16 18:13:53 +0000 |
---|---|---|
committer | stroese <stroese> | 2004-12-16 18:13:53 +0000 |
commit | b39392a98b6df7de221fadfdac07ecfd1497732e (patch) | |
tree | 73ecc1d695f1dc6b5695450fa2b58c731657a427 /cpu/ppc4xx/speed.c | |
parent | 0912e483eb5b9ab5978887245acd0a098ce8780c (diff) | |
download | u-boot-imx-b39392a98b6df7de221fadfdac07ecfd1497732e.zip u-boot-imx-b39392a98b6df7de221fadfdac07ecfd1497732e.tar.gz u-boot-imx-b39392a98b6df7de221fadfdac07ecfd1497732e.tar.bz2 |
CPU speed calculation updated (fixed a rounding problem)
Diffstat (limited to 'cpu/ppc4xx/speed.c')
-rw-r--r-- | cpu/ppc4xx/speed.c | 48 |
1 files changed, 14 insertions, 34 deletions
diff --git a/cpu/ppc4xx/speed.c b/cpu/ppc4xx/speed.c index be0de0c..0d6d88a 100644 --- a/cpu/ppc4xx/speed.c +++ b/cpu/ppc4xx/speed.c @@ -132,10 +132,10 @@ void get_sys_info (PPC405_SYS_INFO * sysInfo) m = sysInfo->pllFbkDiv * sysInfo->pllFwdDivB * sysInfo->pllPlbDiv; } - sysInfo->freqVCOMhz = (1000000 * m) / sysClkPeriodPs; - sysInfo->freqProcessor = (sysInfo->freqVCOMhz * 1000000) / sysInfo->pllFwdDiv; - sysInfo->freqPLB = (sysInfo->freqVCOMhz * 1000000) / - (sysInfo->pllFwdDivB * sysInfo->pllPlbDiv); + sysInfo->freqVCOHz = (1000000000000LL * (unsigned long long)m) / + (unsigned long long)sysClkPeriodPs; + sysInfo->freqProcessor = sysInfo->freqVCOHz / sysInfo->pllFwdDiv; + sysInfo->freqPLB = sysInfo->freqVCOHz / (sysInfo->pllFwdDivB * sysInfo->pllPlbDiv); } else { /* * Check pllFwdDiv to see if running in bypass mode where the CPU speed @@ -148,26 +148,14 @@ void get_sys_info (PPC405_SYS_INFO * sysInfo) sysInfo->freqProcessor = CONFIG_SYS_CLK_FREQ; sysInfo->freqPLB = CONFIG_SYS_CLK_FREQ / sysInfo->pllPlbDiv; } else { - sysInfo->freqVCOMhz = ( 1000000 * - sysInfo->pllFwdDiv * - sysInfo->pllFbkDiv * - sysInfo->pllPlbDiv - ) / sysClkPeriodPs; - if (sysInfo->freqVCOMhz >= VCO_MIN - && sysInfo->freqVCOMhz <= VCO_MAX) { - sysInfo->freqPLB = (ONE_BILLION / - ((sysClkPeriodPs * 10) / - sysInfo->pllFbkDiv)) * 10000; - sysInfo->freqProcessor = sysInfo->freqPLB * sysInfo->pllPlbDiv; - } else { - printf ("\nInvalid VCO frequency calculated : %ld MHz \a\n", - sysInfo->freqVCOMhz); - printf ("It must be between %d-%d MHz \a\n", - VCO_MIN, VCO_MAX); - printf ("PLL Mode reg : %8.8lx\a\n", - pllmr); - hang (); - } + sysInfo->freqVCOHz = ( 1000000000000LL * + (unsigned long long)sysInfo->pllFwdDiv * + (unsigned long long)sysInfo->pllFbkDiv * + (unsigned long long)sysInfo->pllPlbDiv + ) / (unsigned long long)sysClkPeriodPs; + sysInfo->freqPLB = (ONE_BILLION / ((sysClkPeriodPs * 10) / + sysInfo->pllFbkDiv)) * 10000; + sysInfo->freqProcessor = sysInfo->freqPLB * sysInfo->pllPlbDiv; } } } @@ -376,7 +364,8 @@ void get_sys_info (PPC405_SYS_INFO * sysInfo) /* * Determine VCO clock frequency */ - sysInfo->freqVCOMhz = (1000000 * m) / sysClkPeriodPs; + sysInfo->freqVCOHz = (1000000000000LL * (unsigned long long)m) / + (unsigned long long)sysClkPeriodPs; /* * Determine CPU clock frequency @@ -398,15 +387,6 @@ void get_sys_info (PPC405_SYS_INFO * sysInfo) * Determine PLB clock frequency */ sysInfo->freqPLB = sysInfo->freqProcessor / sysInfo->pllPlbDiv; - - if (!((sysInfo->freqVCOMhz >= VCO_MIN) && (sysInfo->freqVCOMhz <= VCO_MAX))) { - printf ("\nInvalid VCO frequency calculated : %ld MHz \a\n", - sysInfo->freqVCOMhz); - printf ("It must be between %d-%d MHz \a\n", VCO_MIN, VCO_MAX); - printf ("PLL Mode reg 0 : %8.8lx\a\n", pllmr0); - printf ("PLL Mode reg 1 : %8.8lx\a\n", pllmr1); - hang (); - } } |