aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/kernel/time.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/powerpc/kernel/time.c')
-rw-r--r--arch/powerpc/kernel/time.c67
1 files changed, 33 insertions, 34 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c
index 24e3ad756de0..d20907561f46 100644
--- a/arch/powerpc/kernel/time.c
+++ b/arch/powerpc/kernel/time.c
@@ -76,7 +76,6 @@
76 76
77/* keep track of when we need to update the rtc */ 77/* keep track of when we need to update the rtc */
78time_t last_rtc_update; 78time_t last_rtc_update;
79extern int piranha_simulator;
80#ifdef CONFIG_PPC_ISERIES 79#ifdef CONFIG_PPC_ISERIES
81unsigned long iSeries_recal_titan = 0; 80unsigned long iSeries_recal_titan = 0;
82unsigned long iSeries_recal_tb = 0; 81unsigned long iSeries_recal_tb = 0;
@@ -858,42 +857,50 @@ int do_settimeofday(struct timespec *tv)
858 857
859EXPORT_SYMBOL(do_settimeofday); 858EXPORT_SYMBOL(do_settimeofday);
860 859
861void __init generic_calibrate_decr(void) 860static int __init get_freq(char *name, int cells, unsigned long *val)
862{ 861{
863 struct device_node *cpu; 862 struct device_node *cpu;
864 unsigned int *fp; 863 unsigned int *fp;
865 int node_found; 864 int found = 0;
866 865
867 /* 866 /* The cpu node should have timebase and clock frequency properties */
868 * The cpu node should have a timebase-frequency property
869 * to tell us the rate at which the decrementer counts.
870 */
871 cpu = of_find_node_by_type(NULL, "cpu"); 867 cpu = of_find_node_by_type(NULL, "cpu");
872 868
873 ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
874 node_found = 0;
875 if (cpu) { 869 if (cpu) {
876 fp = (unsigned int *)get_property(cpu, "timebase-frequency", 870 fp = (unsigned int *)get_property(cpu, name, NULL);
877 NULL);
878 if (fp) { 871 if (fp) {
879 node_found = 1; 872 found = 1;
880 ppc_tb_freq = *fp; 873 *val = 0;
874 while (cells--)
875 *val = (*val << 32) | *fp++;
881 } 876 }
877
878 of_node_put(cpu);
882 } 879 }
883 if (!node_found) 880
881 return found;
882}
883
884void __init generic_calibrate_decr(void)
885{
886 ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */
887
888 if (!get_freq("ibm,extended-timebase-frequency", 2, &ppc_tb_freq) &&
889 !get_freq("timebase-frequency", 1, &ppc_tb_freq)) {
890
884 printk(KERN_ERR "WARNING: Estimating decrementer frequency " 891 printk(KERN_ERR "WARNING: Estimating decrementer frequency "
885 "(not found)\n"); 892 "(not found)\n");
893 }
886 894
887 ppc_proc_freq = DEFAULT_PROC_FREQ; 895 ppc_proc_freq = DEFAULT_PROC_FREQ; /* hardcoded default */
888 node_found = 0; 896
889 if (cpu) { 897 if (!get_freq("ibm,extended-clock-frequency", 2, &ppc_proc_freq) &&
890 fp = (unsigned int *)get_property(cpu, "clock-frequency", 898 !get_freq("clock-frequency", 1, &ppc_proc_freq)) {
891 NULL); 899
892 if (fp) { 900 printk(KERN_ERR "WARNING: Estimating processor frequency "
893 node_found = 1; 901 "(not found)\n");
894 ppc_proc_freq = *fp;
895 }
896 } 902 }
903
897#ifdef CONFIG_BOOKE 904#ifdef CONFIG_BOOKE
898 /* Set the time base to zero */ 905 /* Set the time base to zero */
899 mtspr(SPRN_TBWL, 0); 906 mtspr(SPRN_TBWL, 0);
@@ -905,11 +912,6 @@ void __init generic_calibrate_decr(void)
905 /* Enable decrementer interrupt */ 912 /* Enable decrementer interrupt */
906 mtspr(SPRN_TCR, TCR_DIE); 913 mtspr(SPRN_TCR, TCR_DIE);
907#endif 914#endif
908 if (!node_found)
909 printk(KERN_ERR "WARNING: Estimating processor frequency "
910 "(not found)\n");
911
912 of_node_put(cpu);
913} 915}
914 916
915unsigned long get_boot_time(void) 917unsigned long get_boot_time(void)
@@ -945,9 +947,9 @@ void __init time_init(void)
945 } else { 947 } else {
946 /* Normal PowerPC with timebase register */ 948 /* Normal PowerPC with timebase register */
947 ppc_md.calibrate_decr(); 949 ppc_md.calibrate_decr();
948 printk(KERN_INFO "time_init: decrementer frequency = %lu.%.6lu MHz\n", 950 printk(KERN_DEBUG "time_init: decrementer frequency = %lu.%.6lu MHz\n",
949 ppc_tb_freq / 1000000, ppc_tb_freq % 1000000); 951 ppc_tb_freq / 1000000, ppc_tb_freq % 1000000);
950 printk(KERN_INFO "time_init: processor frequency = %lu.%.6lu MHz\n", 952 printk(KERN_DEBUG "time_init: processor frequency = %lu.%.6lu MHz\n",
951 ppc_proc_freq / 1000000, ppc_proc_freq % 1000000); 953 ppc_proc_freq / 1000000, ppc_proc_freq % 1000000);
952 tb_last_stamp = tb_last_jiffy = get_tb(); 954 tb_last_stamp = tb_last_jiffy = get_tb();
953 } 955 }
@@ -1010,10 +1012,7 @@ void __init time_init(void)
1010 tb_to_ns_scale = scale; 1012 tb_to_ns_scale = scale;
1011 tb_to_ns_shift = shift; 1013 tb_to_ns_shift = shift;
1012 1014
1013#ifdef CONFIG_PPC_ISERIES 1015 tm = get_boot_time();
1014 if (!piranha_simulator)
1015#endif
1016 tm = get_boot_time();
1017 1016
1018 write_seqlock_irqsave(&xtime_lock, flags); 1017 write_seqlock_irqsave(&xtime_lock, flags);
1019 1018