]>
git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/blob - arch/mips/mti-sead3/sead3-time.c
2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * Copyright (C) 2012 MIPS Technologies, Inc. All rights reserved.
8 #include <linux/init.h>
9 #include <linux/irqchip/mips-gic.h>
12 #include <asm/setup.h>
15 #include <asm/mips-boards/generic.h>
17 static void __iomem
*status_reg
= (void __iomem
*)0xbf000410;
20 * Estimate CPU frequency. Sets mips_hpt_frequency as a side-effect.
22 static unsigned int __init
estimate_cpu_frequency(void)
24 unsigned int prid
= read_c0_prid() & (PRID_COMP_MASK
| PRID_IMP_MASK
);
25 unsigned int tick
= 0;
30 local_irq_save(flags
);
32 orig
= readl(status_reg
) & 0x2; /* get original sample */
33 /* wait for transition */
34 while ((readl(status_reg
) & 0x2) == orig
)
36 orig
= orig
^ 0x2; /* flip the bit */
40 /* wait 1 second (the sampling clock transitions every 10ms) */
42 /* wait for transition */
43 while ((readl(status_reg
) & 0x2) == orig
)
45 orig
= orig
^ 0x2; /* flip the bit */
49 freq
= read_c0_count();
51 local_irq_restore(flags
);
53 mips_hpt_frequency
= freq
;
55 /* Adjust for processor */
56 if ((prid
!= (PRID_COMP_MIPS
| PRID_IMP_20KC
)) &&
57 (prid
!= (PRID_COMP_MIPS
| PRID_IMP_25KF
)))
60 freq
+= 5000; /* rounding */
66 void read_persistent_clock(struct timespec
*ts
)
72 int get_c0_perfcount_int(void)
75 return gic_get_c0_perfcount_int();
76 if (cp0_perfcount_irq
>= 0)
77 return MIPS_CPU_IRQ_BASE
+ cp0_perfcount_irq
;
80 EXPORT_SYMBOL_GPL(get_c0_perfcount_int
);
82 unsigned int get_c0_compare_int(void)
85 return gic_get_c0_compare_int();
86 return MIPS_CPU_IRQ_BASE
+ cp0_compare_irq
;
89 void __init
plat_time_init(void)
91 unsigned int est_freq
;
93 est_freq
= estimate_cpu_frequency();
95 pr_debug("CPU frequency %d.%02d MHz\n", (est_freq
/ 1000000),
96 (est_freq
% 1000000) * 100 / 1000000);
98 mips_scroll_message();