summaryrefslogtreecommitdiff
path: root/src/drivers/pc80
diff options
context:
space:
mode:
Diffstat (limited to 'src/drivers/pc80')
-rw-r--r--src/drivers/pc80/pc/i8254.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/drivers/pc80/pc/i8254.c b/src/drivers/pc80/pc/i8254.c
index 8e15d4ded1..654f84a6d7 100644
--- a/src/drivers/pc80/pc/i8254.c
+++ b/src/drivers/pc80/pc/i8254.c
@@ -11,6 +11,7 @@
* GNU General Public License for more details.
*/
+#include <arch/early_variables.h>
#include <arch/io.h>
#include <commonlib/helpers.h>
#include <cpu/x86/tsc.h>
@@ -122,3 +123,25 @@ unsigned long calibrate_tsc_with_pit(void)
bad_ctc:
return 0;
}
+
+#if CONFIG(UNKNOWN_TSC_RATE)
+static u32 g_timer_tsc CAR_GLOBAL;
+
+unsigned long tsc_freq_mhz(void)
+{
+ u32 tsc;
+
+ tsc = car_get_var(g_timer_tsc);
+ if (tsc > 0)
+ return tsc;
+
+ tsc = calibrate_tsc_with_pit();
+
+ /* Set some semi-ridiculous rate if approximation fails. */
+ if (tsc == 0)
+ tsc = 5000;
+
+ car_set_var(g_timer_tsc, tsc);
+ return tsc;
+}
+#endif