]> git.ipfire.org Git - people/ms/u-boot.git/commitdiff
85xx: Round up frequency calculations to get reasonable output
authorKumar Gala <galak@kernel.crashing.org>
Mon, 21 Apr 2008 14:28:36 +0000 (09:28 -0500)
committerWolfgang Denk <wd@denx.de>
Thu, 24 Apr 2008 13:42:35 +0000 (15:42 +0200)
eg. because of rounding error we can get 799Mhz instead of 800Mhz.

Introduced DIV_ROUND_UP and roundup taken from linux kernel.

Signed-off-by: Dejan Minic <minic@freescale.com>
Signed-off-by: Srikanth Srinivasan <srikanth.srinivasan@freescale.com>
Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
Acked-by: Andy Fleming <afleming@freescale.com>
cpu/mpc85xx/cpu.c
include/common.h

index dcd88173782b4f8d51d2278475cde6d20e7196eb..74b210cd108232fd34fd30734eb87463c45ccbee 100644 (file)
@@ -116,22 +116,21 @@ int checkcpu (void)
        get_sys_info(&sysinfo);
 
        puts("Clock Configuration:\n");
-       printf("       CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000);
-       printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000);
-
+       printf("       CPU:%4lu MHz, ", DIV_ROUND_UP(sysinfo.freqProcessor,1000000));
+       printf("CCB:%4lu MHz,\n", DIV_ROUND_UP(sysinfo.freqSystemBus,1000000));
        ddr_ratio = ((gur->porpllsr) & 0x00003e00) >> 9;
        switch (ddr_ratio) {
        case 0x0:
                printf("       DDR:%4lu MHz (%lu MT/s data rate), ",
-               sysinfo.freqDDRBus / 2000000, sysinfo.freqDDRBus / 1000000);
+               DIV_ROUND_UP(sysinfo.freqDDRBus,2000000), DIV_ROUND_UP(sysinfo.freqDDRBus,1000000));
                break;
        case 0x7:
                printf("       DDR:%4lu MHz (%lu MT/s data rate) (Synchronous), ",
-               sysinfo.freqDDRBus / 2000000, sysinfo.freqDDRBus / 1000000);
+               DIV_ROUND_UP(sysinfo.freqDDRBus, 2000000), DIV_ROUND_UP(sysinfo.freqDDRBus, 1000000));
                break;
        default:
                printf("       DDR:%4lu MHz (%lu MT/s data rate) (Asynchronous), ",
-               sysinfo.freqDDRBus / 2000000, sysinfo.freqDDRBus / 1000000);
+               DIV_ROUND_UP(sysinfo.freqDDRBus, 2000000), DIV_ROUND_UP(sysinfo.freqDDRBus,1000000));
                break;
        }
 
@@ -154,7 +153,7 @@ int checkcpu (void)
                 clkdiv *= 2;
 #endif
                printf("LBC:%4lu MHz\n",
-                      sysinfo.freqSystemBus / 1000000 / clkdiv);
+                      DIV_ROUND_UP(sysinfo.freqSystemBus, 1000000) / clkdiv);
        } else {
                printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
        }
index aea181e2ab366715e07e699af3e285f83918fed7..11b7d31c45ce89a794624b4111fac1338838732b 100644 (file)
@@ -670,6 +670,9 @@ void inline show_boot_progress (int val);
 
 #define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
 
+#define DIV_ROUND_UP(n,d) (((n) + (d) - 1) / (d))
+#define roundup(x, y) ((((x) + ((y) - 1)) / (y)) * (y))
+
 /* Multicore arch functions */
 #ifdef CONFIG_MP
 int cpu_status(int nr);