/*1* DEC I/O ASIC's counter clocksource2*3* Copyright (C) 2008 Yoichi Yuasa <[email protected]>4*5* This program is free software; you can redistribute it and/or modify6* it under the terms of the GNU General Public License as published by7* the Free Software Foundation; either version 2 of the License, or8* (at your option) any later version.9*10* This program is distributed in the hope that it will be useful,11* but WITHOUT ANY WARRANTY; without even the implied warranty of12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13* GNU General Public License for more details.14*15* You should have received a copy of the GNU General Public License16* along with this program; if not, write to the Free Software17* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA18*/19#include <linux/clocksource.h>20#include <linux/init.h>2122#include <asm/ds1287.h>23#include <asm/time.h>24#include <asm/dec/ioasic.h>25#include <asm/dec/ioasic_addrs.h>2627static cycle_t dec_ioasic_hpt_read(struct clocksource *cs)28{29return ioasic_read(IO_REG_FCTR);30}3132static struct clocksource clocksource_dec = {33.name = "dec-ioasic",34.read = dec_ioasic_hpt_read,35.mask = CLOCKSOURCE_MASK(32),36.flags = CLOCK_SOURCE_IS_CONTINUOUS,37};3839void __init dec_ioasic_clocksource_init(void)40{41unsigned int freq;42u32 start, end;43int i = HZ / 10;444546while (!ds1287_timer_state())47;4849start = dec_ioasic_hpt_read(&clocksource_dec);5051while (i--)52while (!ds1287_timer_state())53;5455end = dec_ioasic_hpt_read(&clocksource_dec);5657freq = (end - start) * 10;58printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq);5960clocksource_dec.rating = 200 + freq / 10000000;61clocksource_register_hz(&clocksource_dec, freq);62}636465