diff options
Diffstat (limited to 'arch/powerpc/kernel/time.c')
| -rw-r--r-- | arch/powerpc/kernel/time.c | 57 |
1 files changed, 30 insertions, 27 deletions
diff --git a/arch/powerpc/kernel/time.c b/arch/powerpc/kernel/time.c index 528e7f84cb67..d20907561f46 100644 --- a/arch/powerpc/kernel/time.c +++ b/arch/powerpc/kernel/time.c | |||
| @@ -857,42 +857,50 @@ int do_settimeofday(struct timespec *tv) | |||
| 857 | 857 | ||
| 858 | EXPORT_SYMBOL(do_settimeofday); | 858 | EXPORT_SYMBOL(do_settimeofday); |
| 859 | 859 | ||
| 860 | void __init generic_calibrate_decr(void) | 860 | static int __init get_freq(char *name, int cells, unsigned long *val) |
| 861 | { | 861 | { |
| 862 | struct device_node *cpu; | 862 | struct device_node *cpu; |
| 863 | unsigned int *fp; | 863 | unsigned int *fp; |
| 864 | int node_found; | 864 | int found = 0; |
| 865 | 865 | ||
| 866 | /* | 866 | /* The cpu node should have timebase and clock frequency properties */ |
| 867 | * The cpu node should have a timebase-frequency property | ||
| 868 | * to tell us the rate at which the decrementer counts. | ||
| 869 | */ | ||
| 870 | cpu = of_find_node_by_type(NULL, "cpu"); | 867 | cpu = of_find_node_by_type(NULL, "cpu"); |
| 871 | 868 | ||
| 872 | ppc_tb_freq = DEFAULT_TB_FREQ; /* hardcoded default */ | ||
| 873 | node_found = 0; | ||
| 874 | if (cpu) { | 869 | if (cpu) { |
| 875 | fp = (unsigned int *)get_property(cpu, "timebase-frequency", | 870 | fp = (unsigned int *)get_property(cpu, name, NULL); |
| 876 | NULL); | ||
| 877 | if (fp) { | 871 | if (fp) { |
| 878 | node_found = 1; | 872 | found = 1; |
| 879 | ppc_tb_freq = *fp; | 873 | *val = 0; |
| 874 | while (cells--) | ||
| 875 | *val = (*val << 32) | *fp++; | ||
| 880 | } | 876 | } |
| 877 | |||
| 878 | of_node_put(cpu); | ||
| 881 | } | 879 | } |
| 882 | if (!node_found) | 880 | |
| 881 | return found; | ||
| 882 | } | ||
| 883 | |||
| 884 | void __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 | |||
| 883 | printk(KERN_ERR "WARNING: Estimating decrementer frequency " | 891 | printk(KERN_ERR "WARNING: Estimating decrementer frequency " |
| 884 | "(not found)\n"); | 892 | "(not found)\n"); |
| 893 | } | ||
| 885 | 894 | ||
| 886 | ppc_proc_freq = DEFAULT_PROC_FREQ; | 895 | ppc_proc_freq = DEFAULT_PROC_FREQ; /* hardcoded default */ |
| 887 | node_found = 0; | 896 | |
| 888 | if (cpu) { | 897 | if (!get_freq("ibm,extended-clock-frequency", 2, &ppc_proc_freq) && |
| 889 | fp = (unsigned int *)get_property(cpu, "clock-frequency", | 898 | !get_freq("clock-frequency", 1, &ppc_proc_freq)) { |
| 890 | NULL); | 899 | |
| 891 | if (fp) { | 900 | printk(KERN_ERR "WARNING: Estimating processor frequency " |
| 892 | node_found = 1; | 901 | "(not found)\n"); |
| 893 | ppc_proc_freq = *fp; | ||
| 894 | } | ||
| 895 | } | 902 | } |
| 903 | |||
| 896 | #ifdef CONFIG_BOOKE | 904 | #ifdef CONFIG_BOOKE |
| 897 | /* Set the time base to zero */ | 905 | /* Set the time base to zero */ |
| 898 | mtspr(SPRN_TBWL, 0); | 906 | mtspr(SPRN_TBWL, 0); |
| @@ -904,11 +912,6 @@ void __init generic_calibrate_decr(void) | |||
| 904 | /* Enable decrementer interrupt */ | 912 | /* Enable decrementer interrupt */ |
| 905 | mtspr(SPRN_TCR, TCR_DIE); | 913 | mtspr(SPRN_TCR, TCR_DIE); |
| 906 | #endif | 914 | #endif |
| 907 | if (!node_found) | ||
| 908 | printk(KERN_ERR "WARNING: Estimating processor frequency " | ||
| 909 | "(not found)\n"); | ||
| 910 | |||
| 911 | of_node_put(cpu); | ||
| 912 | } | 915 | } |
| 913 | 916 | ||
| 914 | unsigned long get_boot_time(void) | 917 | unsigned long get_boot_time(void) |
