clocksource: Provide a generic mult/shift factor calculation
authorThomas Gleixner <tglx@linutronix.de>
Wed, 11 Nov 2009 14:05:29 +0000 (14:05 +0000)
committer黄涛 <huangtao@rock-chips.com>
Fri, 11 Mar 2011 04:46:18 +0000 (12:46 +0800)
commitcfc80b68293040b1f06c1fb388d3bd448721aa7b
tree51f199ff3df797258005b2cabd5eba270d05ba27
parentb9d82c9f884847ee45aae7fb845ce8a746bf043f
clocksource: Provide a generic mult/shift factor calculation

MIPS has two functions to calculcate the mult/shift factors for clock
sources and clock events at run time. ARM needs such functions as
well.

Implement a function which calculates the mult/shift factors based on
the frequencies to which and from which is converted. The function
also has a parameter to specify the minimum conversion range in
seconds. This range is guaranteed not to produce a 64bit overflow when
a value is multiplied with the calculated mult factor. The larger the
conversion range the less becomes the conversion accuracy.

Provide two inline wrappers which handle clock events and clock
sources. For clock events the "from" frequency is nano seconds per
second which corresponds to 1GHz and "to" is the device frequency. For
clock sources "from" is the device frequency and "to" is nano seconds
per second.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Mikael Pettersson <mikpe@it.uu.se>
Acked-by: Ralf Baechle <ralf@linux-mips.org>
Acked-by: Linus Walleij <linus.walleij@stericsson.com>
Cc: John Stultz <johnstul@us.ibm.com>
LKML-Reference: <20091111134229.766673305@linutronix.de>
include/linux/clockchips.h
include/linux/clocksource.h
kernel/time/clocksource.c