Thomas Gleixner | 1802d0b | 2019-05-27 08:55:21 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 2 | /* |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 2014 ARM Limited |
| 5 | */ |
| 6 | |
| 7 | #include <linux/clocksource.h> |
| 8 | #include <linux/io.h> |
Saravana Kannan | 7a3768c | 2020-03-24 12:53:02 -0700 | [diff] [blame] | 9 | #include <linux/of.h> |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 10 | #include <linux/of_address.h> |
| 11 | #include <linux/sched_clock.h> |
| 12 | |
| 13 | #define SYS_24MHZ 0x05c |
| 14 | |
| 15 | static void __iomem *versatile_sys_24mhz; |
| 16 | |
Thomas Gleixner | 1605abf | 2014-06-04 12:34:15 +0200 | [diff] [blame] | 17 | static u64 notrace versatile_sys_24mhz_read(void) |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 18 | { |
| 19 | return readl(versatile_sys_24mhz); |
| 20 | } |
| 21 | |
Daniel Lezcano | 86de9628 | 2016-06-06 23:29:30 +0200 | [diff] [blame] | 22 | static int __init versatile_sched_clock_init(struct device_node *node) |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 23 | { |
| 24 | void __iomem *base = of_iomap(node, 0); |
| 25 | |
Saravana Kannan | 7a3768c | 2020-03-24 12:53:02 -0700 | [diff] [blame] | 26 | of_node_clear_flag(node, OF_POPULATED); |
| 27 | |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 28 | if (!base) |
Daniel Lezcano | 86de9628 | 2016-06-06 23:29:30 +0200 | [diff] [blame] | 29 | return -ENXIO; |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 30 | |
| 31 | versatile_sys_24mhz = base + SYS_24MHZ; |
| 32 | |
Thomas Gleixner | 1605abf | 2014-06-04 12:34:15 +0200 | [diff] [blame] | 33 | sched_clock_register(versatile_sys_24mhz_read, 32, 24000000); |
Daniel Lezcano | 86de9628 | 2016-06-06 23:29:30 +0200 | [diff] [blame] | 34 | |
| 35 | return 0; |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 36 | } |
Daniel Lezcano | 1727339 | 2017-05-26 16:56:11 +0200 | [diff] [blame] | 37 | TIMER_OF_DECLARE(vexpress, "arm,vexpress-sysreg", |
Rob Herring | f2fa029 | 2015-01-28 11:56:31 -0600 | [diff] [blame] | 38 | versatile_sched_clock_init); |
Daniel Lezcano | 1727339 | 2017-05-26 16:56:11 +0200 | [diff] [blame] | 39 | TIMER_OF_DECLARE(versatile, "arm,versatile-sysreg", |
Thomas Gleixner | 1605abf | 2014-06-04 12:34:15 +0200 | [diff] [blame] | 40 | versatile_sched_clock_init); |