1 // SPDX-License-Identifier: GPL-2.0-only 2 /* 3 * 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 14 static void __iomem *versatile_sys_24mhz; 15 versatile_sys_24mhz_read(void)16static u64 notrace versatile_sys_24mhz_read(void) 17 { 18 return readl(versatile_sys_24mhz); 19 } 20 versatile_sched_clock_init(struct device_node * node)21static int __init versatile_sched_clock_init(struct device_node *node) 22 { 23 void __iomem *base = of_iomap(node, 0); 24 25 if (!base) 26 return -ENXIO; 27 28 versatile_sys_24mhz = base + SYS_24MHZ; 29 30 sched_clock_register(versatile_sys_24mhz_read, 32, 24000000); 31 32 return 0; 33 } 34 TIMER_OF_DECLARE(vexpress, "arm,vexpress-sysreg", 35 versatile_sched_clock_init); 36 TIMER_OF_DECLARE(versatile, "arm,versatile-sysreg", 37 versatile_sched_clock_init); 38