Commit 27acdea8 authored by Deng-Cheng Zhu's avatar Deng-Cheng Zhu Committed by Ralf Baechle

MIPS: csrc-bcm1480: Implement read_sched_clock

Use the ZBbus cycle counter for sched_clock source. This implementation
will give high resolution cputime accounting.
Signed-off-by: default avatarDeng-Cheng Zhu <dengcheng.zhu@imgtec.com>
Cc: linux-mips@linux-mips.org
Cc: macro@linux-mips.org
Patchwork: https://patchwork.linux-mips.org/patch/9480/Signed-off-by: default avatarRalf Baechle <ralf@linux-mips.org>
parent 788049e2
...@@ -12,6 +12,7 @@ ...@@ -12,6 +12,7 @@
* GNU General Public License for more details. * GNU General Public License for more details.
*/ */
#include <linux/clocksource.h> #include <linux/clocksource.h>
#include <linux/sched_clock.h>
#include <asm/addrspace.h> #include <asm/addrspace.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -37,6 +38,11 @@ struct clocksource bcm1480_clocksource = { ...@@ -37,6 +38,11 @@ struct clocksource bcm1480_clocksource = {
.flags = CLOCK_SOURCE_IS_CONTINUOUS, .flags = CLOCK_SOURCE_IS_CONTINUOUS,
}; };
static u64 notrace sb1480_read_sched_clock(void)
{
return __raw_readq(IOADDR(A_SCD_ZBBUS_CYCLE_COUNT));
}
void __init sb1480_clocksource_init(void) void __init sb1480_clocksource_init(void)
{ {
struct clocksource *cs = &bcm1480_clocksource; struct clocksource *cs = &bcm1480_clocksource;
...@@ -46,4 +52,6 @@ void __init sb1480_clocksource_init(void) ...@@ -46,4 +52,6 @@ void __init sb1480_clocksource_init(void)
plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG))); plldiv = G_BCM1480_SYS_PLL_DIV(__raw_readq(IOADDR(A_SCD_SYSTEM_CFG)));
zbbus = ((plldiv >> 1) * 50000000) + ((plldiv & 1) * 25000000); zbbus = ((plldiv >> 1) * 50000000) + ((plldiv & 1) * 25000000);
clocksource_register_hz(cs, zbbus); clocksource_register_hz(cs, zbbus);
sched_clock_register(sb1480_read_sched_clock, 64, zbbus);
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment