blob: f5d017b31afac26dff07de5f58ef81a62d4e0ff1 [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>
Saravana Kannan7a3768c2020-03-24 12:53:02 -07009#include <linux/of.h>
Pawel Moll220e2a82014-04-16 18:22:59 +010010#include <linux/of_address.h>
11#include <linux/sched_clock.h>
12
13#define SYS_24MHZ 0x05c
14
15static void __iomem *versatile_sys_24mhz;
16
Thomas Gleixner1605abf2014-06-04 12:34:15 +020017static u64 notrace versatile_sys_24mhz_read(void)
Pawel Moll220e2a82014-04-16 18:22:59 +010018{
19 return readl(versatile_sys_24mhz);
20}
21
Daniel Lezcano86de96282016-06-06 23:29:30 +020022static int __init versatile_sched_clock_init(struct device_node *node)
Pawel Moll220e2a82014-04-16 18:22:59 +010023{
24 void __iomem *base = of_iomap(node, 0);
25
Saravana Kannan7a3768c2020-03-24 12:53:02 -070026 of_node_clear_flag(node, OF_POPULATED);
27
Pawel Moll220e2a82014-04-16 18:22:59 +010028 if (!base)
Daniel Lezcano86de96282016-06-06 23:29:30 +020029 return -ENXIO;
Pawel Moll220e2a82014-04-16 18:22:59 +010030
31 versatile_sys_24mhz = base + SYS_24MHZ;
32
Thomas Gleixner1605abf2014-06-04 12:34:15 +020033 sched_clock_register(versatile_sys_24mhz_read, 32, 24000000);
Daniel Lezcano86de96282016-06-06 23:29:30 +020034
35 return 0;
Pawel Moll220e2a82014-04-16 18:22:59 +010036}
Daniel Lezcano17273392017-05-26 16:56:11 +020037TIMER_OF_DECLARE(vexpress, "arm,vexpress-sysreg",
Rob Herringf2fa0292015-01-28 11:56:31 -060038 versatile_sched_clock_init);
Daniel Lezcano17273392017-05-26 16:56:11 +020039TIMER_OF_DECLARE(versatile, "arm,versatile-sysreg",
Thomas Gleixner1605abf2014-06-04 12:34:15 +020040 versatile_sched_clock_init);