• Thomas Gleixner's avatar
    clocksource: Provide a generic mult/shift factor calculation · 7d2f944a
    Thomas Gleixner authored
    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: default avatarThomas Gleixner <tglx@linutronix.de>
    Tested-by: default avatarMikael Pettersson <mikpe@it.uu.se>
    Acked-by: default avatarRalf Baechle <ralf@linux-mips.org>
    Acked-by: default avatarLinus Walleij <linus.walleij@stericsson.com>
    Cc: John Stultz <johnstul@us.ibm.com>
    LKML-Reference: <20091111134229.766673305@linutronix.de>
    7d2f944a
clocksource.c 20.6 KB