diff options
| -rw-r--r-- | arch/ppc64/kernel/iSeries_setup.c | 5 | ||||
| -rw-r--r-- | arch/ppc64/kernel/maple_setup.c | 2 | ||||
| -rw-r--r-- | arch/ppc64/kernel/maple_time.c | 51 | ||||
| -rw-r--r-- | arch/ppc64/kernel/pSeries_setup.c | 69 | ||||
| -rw-r--r-- | arch/ppc64/kernel/pmac_time.c | 8 | ||||
| -rw-r--r-- | arch/ppc64/kernel/setup.c | 5 | ||||
| -rw-r--r-- | arch/ppc64/kernel/time.c | 63 | ||||
| -rw-r--r-- | include/asm-ppc64/time.h | 9 |
8 files changed, 76 insertions, 136 deletions
diff --git a/arch/ppc64/kernel/iSeries_setup.c b/arch/ppc64/kernel/iSeries_setup.c index b31962436fe3..86966ce76b58 100644 --- a/arch/ppc64/kernel/iSeries_setup.c +++ b/arch/ppc64/kernel/iSeries_setup.c | |||
| @@ -671,9 +671,6 @@ static void __init iSeries_bolt_kernel(unsigned long saddr, unsigned long eaddr) | |||
| 671 | } | 671 | } |
| 672 | } | 672 | } |
| 673 | 673 | ||
| 674 | extern unsigned long ppc_proc_freq; | ||
| 675 | extern unsigned long ppc_tb_freq; | ||
| 676 | |||
| 677 | /* | 674 | /* |
| 678 | * Document me. | 675 | * Document me. |
| 679 | */ | 676 | */ |
| @@ -772,8 +769,6 @@ static void iSeries_halt(void) | |||
| 772 | mf_power_off(); | 769 | mf_power_off(); |
| 773 | } | 770 | } |
| 774 | 771 | ||
| 775 | extern void setup_default_decr(void); | ||
| 776 | |||
| 777 | /* | 772 | /* |
| 778 | * void __init iSeries_calibrate_decr() | 773 | * void __init iSeries_calibrate_decr() |
| 779 | * | 774 | * |
diff --git a/arch/ppc64/kernel/maple_setup.c b/arch/ppc64/kernel/maple_setup.c index 8cf95a27178e..3dabedb8553b 100644 --- a/arch/ppc64/kernel/maple_setup.c +++ b/arch/ppc64/kernel/maple_setup.c | |||
| @@ -235,6 +235,6 @@ struct machdep_calls __initdata maple_md = { | |||
| 235 | .get_boot_time = maple_get_boot_time, | 235 | .get_boot_time = maple_get_boot_time, |
| 236 | .set_rtc_time = maple_set_rtc_time, | 236 | .set_rtc_time = maple_set_rtc_time, |
| 237 | .get_rtc_time = maple_get_rtc_time, | 237 | .get_rtc_time = maple_get_rtc_time, |
| 238 | .calibrate_decr = maple_calibrate_decr, | 238 | .calibrate_decr = generic_calibrate_decr, |
| 239 | .progress = maple_progress, | 239 | .progress = maple_progress, |
| 240 | }; | 240 | }; |
diff --git a/arch/ppc64/kernel/maple_time.c b/arch/ppc64/kernel/maple_time.c index 07ce7895b43d..d65210abcd03 100644 --- a/arch/ppc64/kernel/maple_time.c +++ b/arch/ppc64/kernel/maple_time.c | |||
| @@ -42,11 +42,8 @@ | |||
| 42 | #define DBG(x...) | 42 | #define DBG(x...) |
| 43 | #endif | 43 | #endif |
| 44 | 44 | ||
| 45 | extern void setup_default_decr(void); | ||
| 46 | extern void GregorianDay(struct rtc_time * tm); | 45 | extern void GregorianDay(struct rtc_time * tm); |
| 47 | 46 | ||
| 48 | extern unsigned long ppc_tb_freq; | ||
| 49 | extern unsigned long ppc_proc_freq; | ||
| 50 | static int maple_rtc_addr; | 47 | static int maple_rtc_addr; |
| 51 | 48 | ||
| 52 | static int maple_clock_read(int addr) | 49 | static int maple_clock_read(int addr) |
| @@ -176,51 +173,3 @@ void __init maple_get_boot_time(struct rtc_time *tm) | |||
| 176 | maple_get_rtc_time(tm); | 173 | maple_get_rtc_time(tm); |
| 177 | } | 174 | } |
| 178 | 175 | ||
| 179 | /* XXX FIXME: Some sane defaults: 125 MHz timebase, 1GHz processor */ | ||
| 180 | #define DEFAULT_TB_FREQ 125000000UL | ||
| 181 | #define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8) | ||
| 182 | |||
| 183 | void __init maple_calibrate_decr(void) | ||
| 184 | { | ||
| 185 | struct device_node *cpu; | ||
| 186 | struct div_result divres; | ||
| 187 | unsigned int *fp = NULL; | ||
| 188 | |||
| 189 | /* | ||
| 190 | * The cpu node should have a timebase-frequency property | ||
| 191 | * to tell us the rate at which the decrementer counts. | ||
| 192 | */ | ||
| 193 | cpu = of_find_node_by_type(NULL, "cpu"); | ||
| 194 | |||
| 195 | ppc_tb_freq = DEFAULT_TB_FREQ; | ||
| 196 | if (cpu != 0) | ||
| 197 | fp = (unsigned int *)get_property(cpu, "timebase-frequency", NULL); | ||
| 198 | if (fp != NULL) | ||
| 199 | ppc_tb_freq = *fp; | ||
| 200 | else | ||
| 201 | printk(KERN_ERR "WARNING: Estimating decrementer frequency (not found)\n"); | ||
| 202 | fp = NULL; | ||
| 203 | ppc_proc_freq = DEFAULT_PROC_FREQ; | ||
| 204 | if (cpu != 0) | ||
| 205 | fp = (unsigned int *)get_property(cpu, "clock-frequency", NULL); | ||
| 206 | if (fp != NULL) | ||
| 207 | ppc_proc_freq = *fp; | ||
| 208 | else | ||
| 209 | printk(KERN_ERR "WARNING: Estimating processor frequency (not found)\n"); | ||
| 210 | |||
| 211 | of_node_put(cpu); | ||
| 212 | |||
| 213 | printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n", | ||
| 214 | ppc_tb_freq/1000000, ppc_tb_freq%1000000); | ||
| 215 | printk(KERN_INFO "time_init: processor frequency = %lu.%.6lu MHz\n", | ||
| 216 | ppc_proc_freq/1000000, ppc_proc_freq%1000000); | ||
| 217 | |||
| 218 | tb_ticks_per_jiffy = ppc_tb_freq / HZ; | ||
| 219 | tb_ticks_per_sec = tb_ticks_per_jiffy * HZ; | ||
| 220 | tb_ticks_per_usec = ppc_tb_freq / 1000000; | ||
| 221 | tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000); | ||
| 222 | div128_by_32(1024*1024, 0, tb_ticks_per_sec, &divres); | ||
| 223 | tb_to_xs = divres.result_low; | ||
| 224 | |||
| 225 | setup_default_decr(); | ||
| 226 | } | ||
diff --git a/arch/ppc64/kernel/pSeries_setup.c b/arch/ppc64/kernel/pSeries_setup.c index 6c0d1d58a552..f9a310c0c8d7 100644 --- a/arch/ppc64/kernel/pSeries_setup.c +++ b/arch/ppc64/kernel/pSeries_setup.c | |||
| @@ -84,9 +84,6 @@ extern void generic_find_legacy_serial_ports(u64 *physport, | |||
| 84 | 84 | ||
| 85 | int fwnmi_active; /* TRUE if an FWNMI handler is present */ | 85 | int fwnmi_active; /* TRUE if an FWNMI handler is present */ |
| 86 | 86 | ||
| 87 | extern unsigned long ppc_proc_freq; | ||
| 88 | extern unsigned long ppc_tb_freq; | ||
| 89 | |||
| 90 | extern void pSeries_system_reset_exception(struct pt_regs *regs); | 87 | extern void pSeries_system_reset_exception(struct pt_regs *regs); |
| 91 | extern int pSeries_machine_check_exception(struct pt_regs *regs); | 88 | extern int pSeries_machine_check_exception(struct pt_regs *regs); |
| 92 | 89 | ||
| @@ -482,70 +479,6 @@ static void pSeries_progress(char *s, unsigned short hex) | |||
| 482 | spin_unlock(&progress_lock); | 479 | spin_unlock(&progress_lock); |
| 483 | } | 480 | } |
| 484 | 481 | ||
| 485 | extern void setup_default_decr(void); | ||
| 486 | |||
| 487 | /* Some sane defaults: 125 MHz timebase, 1GHz processor */ | ||
| 488 | #define DEFAULT_TB_FREQ 125000000UL | ||
| 489 | #define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8) | ||
| 490 | |||
| 491 | static void __init pSeries_calibrate_decr(void) | ||
| 492 | { | ||
| 493 | struct device_node *cpu; | ||
| 494 | struct div_result divres; | ||
| 495 | unsigned int *fp; | ||
| 496 | int node_found; | ||
| 497 | |||
| 498 | /* | ||
| 499 | * The cpu node should have a timebase-frequency property | ||
| 500 | * to tell us the rate at which the decrementer counts. | ||
| 501 | */ | ||
| 502 | cpu = of_find_node_by_type(NULL, "cpu"); | ||
| 503 | |||
| 504 | ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */ | ||
| 505 | node_found = 0; | ||
| 506 | if (cpu != 0) { | ||
| 507 | fp = (unsigned int *)get_property(cpu, "timebase-frequency", | ||
| 508 | NULL); | ||
| 509 | if (fp != 0) { | ||
| 510 | node_found = 1; | ||
| 511 | ppc_tb_freq = *fp; | ||
| 512 | } | ||
| 513 | } | ||
| 514 | if (!node_found) | ||
| 515 | printk(KERN_ERR "WARNING: Estimating decrementer frequency " | ||
| 516 | "(not found)\n"); | ||
| 517 | |||
| 518 | ppc_proc_freq = DEFAULT_PROC_FREQ; | ||
| 519 | node_found = 0; | ||
| 520 | if (cpu != 0) { | ||
| 521 | fp = (unsigned int *)get_property(cpu, "clock-frequency", | ||
| 522 | NULL); | ||
| 523 | if (fp != 0) { | ||
| 524 | node_found = 1; | ||
| 525 | ppc_proc_freq = *fp; | ||
| 526 | } | ||
| 527 | } | ||
| 528 | if (!node_found) | ||
| 529 | printk(KERN_ERR "WARNING: Estimating processor frequency " | ||
| 530 | "(not found)\n"); | ||
| 531 | |||
| 532 | of_node_put(cpu); | ||
| 533 | |||
| 534 | printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n", | ||
| 535 | ppc_tb_freq/1000000, ppc_tb_freq%1000000); | ||
| 536 | printk(KERN_INFO "time_init: processor frequency = %lu.%.6lu MHz\n", | ||
| 537 | ppc_proc_freq/1000000, ppc_proc_freq%1000000); | ||
| 538 | |||
| 539 | tb_ticks_per_jiffy = ppc_tb_freq / HZ; | ||
| 540 | tb_ticks_per_sec = tb_ticks_per_jiffy * HZ; | ||
| 541 | tb_ticks_per_usec = ppc_tb_freq / 1000000; | ||
| 542 | tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000); | ||
| 543 | div128_by_32(1024*1024, 0, tb_ticks_per_sec, &divres); | ||
| 544 | tb_to_xs = divres.result_low; | ||
| 545 | |||
| 546 | setup_default_decr(); | ||
| 547 | } | ||
| 548 | |||
| 549 | static int pSeries_check_legacy_ioport(unsigned int baseport) | 482 | static int pSeries_check_legacy_ioport(unsigned int baseport) |
| 550 | { | 483 | { |
| 551 | struct device_node *np; | 484 | struct device_node *np; |
| @@ -604,7 +537,7 @@ struct machdep_calls __initdata pSeries_md = { | |||
| 604 | .get_boot_time = pSeries_get_boot_time, | 537 | .get_boot_time = pSeries_get_boot_time, |
| 605 | .get_rtc_time = pSeries_get_rtc_time, | 538 | .get_rtc_time = pSeries_get_rtc_time, |
| 606 | .set_rtc_time = pSeries_set_rtc_time, | 539 | .set_rtc_time = pSeries_set_rtc_time, |
| 607 | .calibrate_decr = pSeries_calibrate_decr, | 540 | .calibrate_decr = generic_calibrate_decr, |
| 608 | .progress = pSeries_progress, | 541 | .progress = pSeries_progress, |
| 609 | .check_legacy_ioport = pSeries_check_legacy_ioport, | 542 | .check_legacy_ioport = pSeries_check_legacy_ioport, |
| 610 | .system_reset_exception = pSeries_system_reset_exception, | 543 | .system_reset_exception = pSeries_system_reset_exception, |
diff --git a/arch/ppc64/kernel/pmac_time.c b/arch/ppc64/kernel/pmac_time.c index f24827581dd7..3059edb09cc8 100644 --- a/arch/ppc64/kernel/pmac_time.c +++ b/arch/ppc64/kernel/pmac_time.c | |||
| @@ -40,11 +40,6 @@ | |||
| 40 | #define DBG(x...) | 40 | #define DBG(x...) |
| 41 | #endif | 41 | #endif |
| 42 | 42 | ||
| 43 | extern void setup_default_decr(void); | ||
| 44 | |||
| 45 | extern unsigned long ppc_tb_freq; | ||
| 46 | extern unsigned long ppc_proc_freq; | ||
| 47 | |||
| 48 | /* Apparently the RTC stores seconds since 1 Jan 1904 */ | 43 | /* Apparently the RTC stores seconds since 1 Jan 1904 */ |
| 49 | #define RTC_OFFSET 2082844800 | 44 | #define RTC_OFFSET 2082844800 |
| 50 | 45 | ||
| @@ -161,8 +156,7 @@ void __init pmac_get_boot_time(struct rtc_time *tm) | |||
| 161 | 156 | ||
| 162 | /* | 157 | /* |
| 163 | * Query the OF and get the decr frequency. | 158 | * Query the OF and get the decr frequency. |
| 164 | * This was taken from the pmac time_init() when merging the prep/pmac | 159 | * FIXME: merge this with generic_calibrate_decr |
| 165 | * time functions. | ||
| 166 | */ | 160 | */ |
| 167 | void __init pmac_calibrate_decr(void) | 161 | void __init pmac_calibrate_decr(void) |
| 168 | { | 162 | { |
diff --git a/arch/ppc64/kernel/setup.c b/arch/ppc64/kernel/setup.c index 8e439a817642..93b0ee88cda1 100644 --- a/arch/ppc64/kernel/setup.c +++ b/arch/ppc64/kernel/setup.c | |||
| @@ -701,9 +701,6 @@ void machine_halt(void) | |||
| 701 | 701 | ||
| 702 | EXPORT_SYMBOL(machine_halt); | 702 | EXPORT_SYMBOL(machine_halt); |
| 703 | 703 | ||
| 704 | unsigned long ppc_proc_freq; | ||
| 705 | unsigned long ppc_tb_freq; | ||
| 706 | |||
| 707 | static int ppc64_panic_event(struct notifier_block *this, | 704 | static int ppc64_panic_event(struct notifier_block *this, |
| 708 | unsigned long event, void *ptr) | 705 | unsigned long event, void *ptr) |
| 709 | { | 706 | { |
| @@ -1117,7 +1114,7 @@ void ppc64_dump_msg(unsigned int src, const char *msg) | |||
| 1117 | } | 1114 | } |
| 1118 | 1115 | ||
| 1119 | /* This should only be called on processor 0 during calibrate decr */ | 1116 | /* This should only be called on processor 0 during calibrate decr */ |
| 1120 | void setup_default_decr(void) | 1117 | void __init setup_default_decr(void) |
| 1121 | { | 1118 | { |
| 1122 | struct paca_struct *lpaca = get_paca(); | 1119 | struct paca_struct *lpaca = get_paca(); |
| 1123 | 1120 | ||
diff --git a/arch/ppc64/kernel/time.c b/arch/ppc64/kernel/time.c index 33364a7d2cd2..2348a75e050d 100644 --- a/arch/ppc64/kernel/time.c +++ b/arch/ppc64/kernel/time.c | |||
| @@ -107,6 +107,9 @@ void ppc_adjtimex(void); | |||
| 107 | 107 | ||
| 108 | static unsigned adjusting_time = 0; | 108 | static unsigned adjusting_time = 0; |
| 109 | 109 | ||
| 110 | unsigned long ppc_proc_freq; | ||
| 111 | unsigned long ppc_tb_freq; | ||
| 112 | |||
| 110 | static __inline__ void timer_check_rtc(void) | 113 | static __inline__ void timer_check_rtc(void) |
| 111 | { | 114 | { |
| 112 | /* | 115 | /* |
| @@ -472,6 +475,66 @@ int do_settimeofday(struct timespec *tv) | |||
| 472 | 475 | ||
| 473 | EXPORT_SYMBOL(do_settimeofday); | 476 | EXPORT_SYMBOL(do_settimeofday); |
| 474 | 477 | ||
| 478 | #if defined(CONFIG_PPC_PSERIES) || defined(CONFIG_PPC_MAPLE) || defined(CONFIG_PPC_BPA) | ||
| 479 | void __init generic_calibrate_decr(void) | ||
| 480 | { | ||
| 481 | struct device_node *cpu; | ||
| 482 | struct div_result divres; | ||
| 483 | unsigned int *fp; | ||
| 484 | int node_found; | ||
| 485 | |||
| 486 | /* | ||
| 487 | * The cpu node should have a timebase-frequency property | ||
| 488 | * to tell us the rate at which the decrementer counts. | ||
| 489 | */ | ||
| 490 | cpu = of_find_node_by_type(NULL, "cpu"); | ||
| 491 | |||
| 492 | ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */ | ||
| 493 | node_found = 0; | ||
| 494 | if (cpu != 0) { | ||
| 495 | fp = (unsigned int *)get_property(cpu, "timebase-frequency", | ||
| 496 | NULL); | ||
| 497 | if (fp != 0) { | ||
| 498 | node_found = 1; | ||
| 499 | ppc_tb_freq = *fp; | ||
| 500 | } | ||
| 501 | } | ||
| 502 | if (!node_found) | ||
| 503 | printk(KERN_ERR "WARNING: Estimating decrementer frequency " | ||
| 504 | "(not found)\n"); | ||
| 505 | |||
| 506 | ppc_proc_freq = DEFAULT_PROC_FREQ; | ||
| 507 | node_found = 0; | ||
| 508 | if (cpu != 0) { | ||
| 509 | fp = (unsigned int *)get_property(cpu, "clock-frequency", | ||
| 510 | NULL); | ||
| 511 | if (fp != 0) { | ||
| 512 | node_found = 1; | ||
| 513 | ppc_proc_freq = *fp; | ||
| 514 | } | ||
| 515 | } | ||
| 516 | if (!node_found) | ||
| 517 | printk(KERN_ERR "WARNING: Estimating processor frequency " | ||
| 518 | "(not found)\n"); | ||
| 519 | |||
| 520 | of_node_put(cpu); | ||
| 521 | |||
| 522 | printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n", | ||
| 523 | ppc_tb_freq/1000000, ppc_tb_freq%1000000); | ||
| 524 | printk(KERN_INFO "time_init: processor frequency = %lu.%.6lu MHz\n", | ||
| 525 | ppc_proc_freq/1000000, ppc_proc_freq%1000000); | ||
| 526 | |||
| 527 | tb_ticks_per_jiffy = ppc_tb_freq / HZ; | ||
| 528 | tb_ticks_per_sec = tb_ticks_per_jiffy * HZ; | ||
| 529 | tb_ticks_per_usec = ppc_tb_freq / 1000000; | ||
| 530 | tb_to_us = mulhwu_scale_factor(ppc_tb_freq, 1000000); | ||
| 531 | div128_by_32(1024*1024, 0, tb_ticks_per_sec, &divres); | ||
| 532 | tb_to_xs = divres.result_low; | ||
| 533 | |||
| 534 | setup_default_decr(); | ||
| 535 | } | ||
| 536 | #endif | ||
| 537 | |||
| 475 | void __init time_init(void) | 538 | void __init time_init(void) |
| 476 | { | 539 | { |
| 477 | /* This function is only called on the boot processor */ | 540 | /* This function is only called on the boot processor */ |
diff --git a/include/asm-ppc64/time.h b/include/asm-ppc64/time.h index 8d6e3760ee10..c6c762cad8b0 100644 --- a/include/asm-ppc64/time.h +++ b/include/asm-ppc64/time.h | |||
| @@ -34,6 +34,15 @@ struct rtc_time; | |||
| 34 | extern void to_tm(int tim, struct rtc_time * tm); | 34 | extern void to_tm(int tim, struct rtc_time * tm); |
| 35 | extern time_t last_rtc_update; | 35 | extern time_t last_rtc_update; |
| 36 | 36 | ||
| 37 | void generic_calibrate_decr(void); | ||
| 38 | void setup_default_decr(void); | ||
| 39 | |||
| 40 | /* Some sane defaults: 125 MHz timebase, 1GHz processor */ | ||
| 41 | extern unsigned long ppc_proc_freq; | ||
| 42 | #define DEFAULT_PROC_FREQ (DEFAULT_TB_FREQ * 8) | ||
| 43 | extern unsigned long ppc_tb_freq; | ||
| 44 | #define DEFAULT_TB_FREQ 125000000UL | ||
| 45 | |||
| 37 | /* | 46 | /* |
| 38 | * By putting all of this stuff into a single struct we | 47 | * By putting all of this stuff into a single struct we |
| 39 | * reduce the number of cache lines touched by do_gettimeofday. | 48 | * reduce the number of cache lines touched by do_gettimeofday. |
