blob: e4ebb656d005de1d2f184b018b9e6f5611bcd5dd [file] [log] [blame]
Thomas Gleixner1802d0b2019-05-27 08:55:21 +02001// SPDX-License-Identifier: GPL-2.0-only
Pawel Moll220e2a82014-04-16 18:22:59 +01002/*
Pawel Moll220e2a82014-04-16 18:22:59 +01003 *
4 * Copyright (C) 2014 ARM Limited
5 */
6
7#include <linux/clocksource.h>
8#include <linux/io.h>
9#include <linux/of_address.h>
10#include <linux/sched_clock.h>
11
12#define SYS_24MHZ 0x05c
13
14static void __iomem *versatile_sys_24mhz;
15
Thomas Gleixner1605abf2014-06-04 12:34:15 +020016static u64 notrace versatile_sys_24mhz_read(void)
Pawel Moll220e2a82014-04-16 18:22:59 +010017{
18 return readl(versatile_sys_24mhz);
19}
20
Daniel Lezcano86de96282016-06-06 23:29:30 +020021static int __init versatile_sched_clock_init(struct device_node *node)
Pawel Moll220e2a82014-04-16 18:22:59 +010022{
23 void __iomem *base = of_iomap(node, 0);
24
25 if (!base)
Daniel Lezcano86de96282016-06-06 23:29:30 +020026 return -ENXIO;
Pawel Moll220e2a82014-04-16 18:22:59 +010027
28 versatile_sys_24mhz = base + SYS_24MHZ;
29
Thomas Gleixner1605abf2014-06-04 12:34:15 +020030 sched_clock_register(versatile_sys_24mhz_read, 32, 24000000);
Daniel Lezcano86de96282016-06-06 23:29:30 +020031
32 return 0;
Pawel Moll220e2a82014-04-16 18:22:59 +010033}
Daniel Lezcano17273392017-05-26 16:56:11 +020034TIMER_OF_DECLARE(vexpress, "arm,vexpress-sysreg",
Rob Herringf2fa0292015-01-28 11:56:31 -060035 versatile_sched_clock_init);
Daniel Lezcano17273392017-05-26 16:56:11 +020036TIMER_OF_DECLARE(versatile, "arm,versatile-sysreg",
Thomas Gleixner1605abf2014-06-04 12:34:15 +020037 versatile_sched_clock_init);