mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-08-27 11:19:37 +00:00
![Thomas Gleixner](/assets/img/avatar_default.png)
Based on 3 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version [author] [graeme] [gregory] [gg]@[slimlogic] [co] [uk] [author] [kishon] [vijay] [abraham] [i] [kishon]@[ti] [com] [based] [on] [twl6030]_[usb] [c] [author] [hema] [hk] [hemahk]@[ti] [com] this program is distributed in the hope that it will be useful but without any warranty without even the implied warranty of merchantability or fitness for a particular purpose see the gnu general public license for more details extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 1105 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Reviewed-by: Richard Fontana <rfontana@redhat.com> Reviewed-by: Kate Stewart <kstewart@linuxfoundation.org> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070033.202006027@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
65 lines
1.3 KiB
C
65 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
/*
|
|
* DEC I/O ASIC's counter clocksource
|
|
*
|
|
* Copyright (C) 2008 Yoichi Yuasa <yuasa@linux-mips.org>
|
|
*/
|
|
#include <linux/clocksource.h>
|
|
#include <linux/sched_clock.h>
|
|
#include <linux/init.h>
|
|
|
|
#include <asm/ds1287.h>
|
|
#include <asm/time.h>
|
|
#include <asm/dec/ioasic.h>
|
|
#include <asm/dec/ioasic_addrs.h>
|
|
|
|
static u64 dec_ioasic_hpt_read(struct clocksource *cs)
|
|
{
|
|
return ioasic_read(IO_REG_FCTR);
|
|
}
|
|
|
|
static struct clocksource clocksource_dec = {
|
|
.name = "dec-ioasic",
|
|
.read = dec_ioasic_hpt_read,
|
|
.mask = CLOCKSOURCE_MASK(32),
|
|
.flags = CLOCK_SOURCE_IS_CONTINUOUS,
|
|
};
|
|
|
|
static u64 notrace dec_ioasic_read_sched_clock(void)
|
|
{
|
|
return ioasic_read(IO_REG_FCTR);
|
|
}
|
|
|
|
int __init dec_ioasic_clocksource_init(void)
|
|
{
|
|
unsigned int freq;
|
|
u32 start, end;
|
|
int i = HZ / 8;
|
|
|
|
ds1287_timer_state();
|
|
while (!ds1287_timer_state())
|
|
;
|
|
|
|
start = dec_ioasic_hpt_read(&clocksource_dec);
|
|
|
|
while (i--)
|
|
while (!ds1287_timer_state())
|
|
;
|
|
|
|
end = dec_ioasic_hpt_read(&clocksource_dec);
|
|
|
|
freq = (end - start) * 8;
|
|
|
|
/* An early revision of the I/O ASIC didn't have the counter. */
|
|
if (!freq)
|
|
return -ENXIO;
|
|
|
|
printk(KERN_INFO "I/O ASIC clock frequency %dHz\n", freq);
|
|
|
|
clocksource_dec.rating = 200 + freq / 10000000;
|
|
clocksource_register_hz(&clocksource_dec, freq);
|
|
|
|
sched_clock_register(dec_ioasic_read_sched_clock, 32, freq);
|
|
|
|
return 0;
|
|
}
|