Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  *  Cobalt time initialization.
0004  *
0005  *  Copyright (C) 2007  Yoichi Yuasa <yuasa@linux-mips.org>
0006  */
0007 #include <linux/i8253.h>
0008 #include <linux/init.h>
0009 
0010 #include <asm/gt64120.h>
0011 #include <asm/time.h>
0012 
0013 #define GT641XX_BASE_CLOCK  50000000    /* 50MHz */
0014 
0015 void __init plat_time_init(void)
0016 {
0017     u32 start, end;
0018     int i = HZ / 10;
0019 
0020     setup_pit_timer();
0021 
0022     gt641xx_set_base_clock(GT641XX_BASE_CLOCK);
0023 
0024     /*
0025      * MIPS counter frequency is measured during a 100msec interval
0026      * using GT64111 timer0.
0027      */
0028     while (!gt641xx_timer0_state())
0029         ;
0030 
0031     start = read_c0_count();
0032 
0033     while (i--)
0034         while (!gt641xx_timer0_state())
0035             ;
0036 
0037     end = read_c0_count();
0038 
0039     mips_hpt_frequency = (end - start) * 10;
0040     printk(KERN_INFO "MIPS counter frequency %dHz\n", mips_hpt_frequency);
0041 }