Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 1 | /* |
| 2 | * This program is free software; you can redistribute it and/or modify |
| 3 | * it under the terms of the GNU General Public License version 2 as |
| 4 | * published by the Free Software Foundation. |
| 5 | * |
| 6 | * This program is distributed in the hope that it will be useful, |
| 7 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 8 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 9 | * GNU General Public License for more details. |
| 10 | * |
| 11 | * Copyright (C) 2014 ARM Limited |
| 12 | */ |
| 13 | |
| 14 | #include <linux/clocksource.h> |
| 15 | #include <linux/io.h> |
| 16 | #include <linux/of_address.h> |
| 17 | #include <linux/sched_clock.h> |
| 18 | |
| 19 | #define SYS_24MHZ 0x05c |
| 20 | |
| 21 | static void __iomem *versatile_sys_24mhz; |
| 22 | |
Thomas Gleixner | 1605abf | 2014-06-04 12:34:15 +0200 | [diff] [blame] | 23 | static u64 notrace versatile_sys_24mhz_read(void) |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 24 | { |
| 25 | return readl(versatile_sys_24mhz); |
| 26 | } |
| 27 | |
Daniel Lezcano | 86de9628 | 2016-06-06 23:29:30 +0200 | [diff] [blame] | 28 | static int __init versatile_sched_clock_init(struct device_node *node) |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 29 | { |
| 30 | void __iomem *base = of_iomap(node, 0); |
| 31 | |
| 32 | if (!base) |
Daniel Lezcano | 86de9628 | 2016-06-06 23:29:30 +0200 | [diff] [blame] | 33 | return -ENXIO; |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 34 | |
| 35 | versatile_sys_24mhz = base + SYS_24MHZ; |
| 36 | |
Thomas Gleixner | 1605abf | 2014-06-04 12:34:15 +0200 | [diff] [blame] | 37 | sched_clock_register(versatile_sys_24mhz_read, 32, 24000000); |
Daniel Lezcano | 86de9628 | 2016-06-06 23:29:30 +0200 | [diff] [blame] | 38 | |
| 39 | return 0; |
Pawel Moll | 220e2a8 | 2014-04-16 18:22:59 +0100 | [diff] [blame] | 40 | } |
Daniel Lezcano | 177cf6e | 2016-06-07 00:27:44 +0200 | [diff] [blame] | 41 | CLOCKSOURCE_OF_DECLARE(vexpress, "arm,vexpress-sysreg", |
Rob Herring | f2fa029 | 2015-01-28 11:56:31 -0600 | [diff] [blame] | 42 | versatile_sched_clock_init); |
Daniel Lezcano | 177cf6e | 2016-06-07 00:27:44 +0200 | [diff] [blame] | 43 | CLOCKSOURCE_OF_DECLARE(versatile, "arm,versatile-sysreg", |
Thomas Gleixner | 1605abf | 2014-06-04 12:34:15 +0200 | [diff] [blame] | 44 | versatile_sched_clock_init); |