]> git.sur5r.net Git - u-boot/blobdiff - cpu/mpc85xx/speed.c
Merge git://www.denx.de/git/u-boot into merge
[u-boot] / cpu / mpc85xx / speed.c
index 787f7fadc981b9dd0998e7dae4ed54e51d04aa8b..12359a2d64b0e7d40faae1d524c132aba2c2e9b2 100644 (file)
 #include <ppc_asm.tmpl>
 #include <asm/processor.h>
 
+DECLARE_GLOBAL_DATA_PTR;
+
 /* --------------------------------------------------------------- */
 
 void get_sys_info (sys_info_t * sysInfo)
 {
        volatile immap_t    *immap = (immap_t *)CFG_IMMR;
        volatile ccsr_gur_t *gur = &immap->im_gur;
-       uint plat_ratio,e500_ratio;
+       uint plat_ratio,e500_ratio,half_freqSystemBus;
 
        plat_ratio = (gur->porpllsr) & 0x0000003e;
        plat_ratio >>= 1;
-       switch(plat_ratio) {
-       case 0x02:
-       case 0x03:
-       case 0x04:
-       case 0x05:
-       case 0x06:
-       case 0x08:
-       case 0x09:
-       case 0x0a:
-       case 0x0c:
-       case 0x10:
-               sysInfo->freqSystemBus = plat_ratio * CONFIG_SYS_CLK_FREQ;
-               break;
-       default:
-               sysInfo->freqSystemBus = 0;
-               break;
-       }
-
+       sysInfo->freqSystemBus = plat_ratio * CONFIG_SYS_CLK_FREQ;
        e500_ratio = (gur->porpllsr) & 0x003f0000;
        e500_ratio >>= 16;
-       switch(e500_ratio) {
-       case 0x04:
-               sysInfo->freqProcessor = 2*sysInfo->freqSystemBus;
-               break;
-       case 0x05:
-               sysInfo->freqProcessor = 5*sysInfo->freqSystemBus/2;
-               break;
-       case 0x06:
-               sysInfo->freqProcessor = 3*sysInfo->freqSystemBus;
-               break;
-       case 0x07:
-               sysInfo->freqProcessor = 7*sysInfo->freqSystemBus/2;
-               break;
-       default:
-               sysInfo->freqProcessor = 0;
-               break;
-       }
+
+       /* Divide before multiply to avoid integer
+        * overflow for processor speeds above 2GHz */
+       half_freqSystemBus = sysInfo->freqSystemBus/2;
+       sysInfo->freqProcessor = e500_ratio*half_freqSystemBus;
 }
 
+
 int get_clocks (void)
 {
-       DECLARE_GLOBAL_DATA_PTR;
        sys_info_t sys_info;
-#if defined(CONFIG_MPC8560)
+#if defined(CONFIG_CPM2)
        volatile immap_t *immap = (immap_t *) CFG_IMMR;
        uint sccr, dfbrg;
 
@@ -94,7 +67,7 @@ int get_clocks (void)
        get_sys_info (&sys_info);
        gd->cpu_clk = sys_info.freqProcessor;
        gd->bus_clk = sys_info.freqSystemBus;
-#if defined(CONFIG_MPC8560)
+#if defined(CONFIG_CPM2)
        gd->vco_out = 2*sys_info.freqSystemBus;
        gd->cpm_clk = gd->vco_out / 2;
        gd->scc_clk = gd->vco_out / 4;