Skip to content
Snippets Groups Projects
Commit 022f1216 authored by Kumar Gala's avatar Kumar Gala Committed by Wolfgang Denk
Browse files

85xx: Round up frequency calculations to get reasonable output


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: default avatarDejan Minic <minic@freescale.com>
Signed-off-by: default avatarSrikanth Srinivasan <srikanth.srinivasan@freescale.com>
Signed-off-by: default avatarKumar Gala <galak@kernel.crashing.org>
Acked-by: default avatarAndy Fleming <afleming@freescale.com>
parent 0aa88c82
No related branches found
No related tags found
No related merge requests found
...@@ -116,22 +116,21 @@ int checkcpu (void) ...@@ -116,22 +116,21 @@ int checkcpu (void)
get_sys_info(&sysinfo); get_sys_info(&sysinfo);
puts("Clock Configuration:\n"); puts("Clock Configuration:\n");
printf(" CPU:%4lu MHz, ", sysinfo.freqProcessor / 1000000); printf(" CPU:%4lu MHz, ", DIV_ROUND_UP(sysinfo.freqProcessor,1000000));
printf("CCB:%4lu MHz,\n", sysinfo.freqSystemBus / 1000000); printf("CCB:%4lu MHz,\n", DIV_ROUND_UP(sysinfo.freqSystemBus,1000000));
ddr_ratio = ((gur->porpllsr) & 0x00003e00) >> 9; ddr_ratio = ((gur->porpllsr) & 0x00003e00) >> 9;
switch (ddr_ratio) { switch (ddr_ratio) {
case 0x0: case 0x0:
printf(" DDR:%4lu MHz (%lu MT/s data rate), ", 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; break;
case 0x7: case 0x7:
printf(" DDR:%4lu MHz (%lu MT/s data rate) (Synchronous), ", 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; break;
default: default:
printf(" DDR:%4lu MHz (%lu MT/s data rate) (Asynchronous), ", 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; break;
} }
...@@ -154,7 +153,7 @@ int checkcpu (void) ...@@ -154,7 +153,7 @@ int checkcpu (void)
clkdiv *= 2; clkdiv *= 2;
#endif #endif
printf("LBC:%4lu MHz\n", printf("LBC:%4lu MHz\n",
sysinfo.freqSystemBus / 1000000 / clkdiv); DIV_ROUND_UP(sysinfo.freqSystemBus, 1000000) / clkdiv);
} else { } else {
printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr); printf("LBC: unknown (lcrr: 0x%08x)\n", lcrr);
} }
......
...@@ -670,6 +670,9 @@ void inline show_boot_progress (int val); ...@@ -670,6 +670,9 @@ void inline show_boot_progress (int val);
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0])) #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 */ /* Multicore arch functions */
#ifdef CONFIG_MP #ifdef CONFIG_MP
int cpu_status(int nr); int cpu_status(int nr);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment