summaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/arm_architected_timer.c
blob: 16e40a1a0b3b153730c67e38425e12c1cf6cc18b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: GPL-2.0-or-later
/*
 * Copyright (C) 2018 Sascha Hauer <s.hauer@pengutronix.de>
 */

#include <common.h>
#include <init.h>
#include <clock.h>
#include <linux/clk.h>
#include <io.h>
#include <asm/system.h>

static uint64_t arm_arch_clocksource_read(void)
{
	return get_cntpct();
}

static struct clocksource cs = {
	.read	= arm_arch_clocksource_read,
	.mask	= CLOCKSOURCE_MASK(64),
	.shift	= 0,
};

static int arm_arch_timer_probe(struct device_d *dev)
{
	cs.mult = clocksource_hz2mult(get_cntfrq(), cs.shift);

	return init_clock(&cs);
}

static struct of_device_id arm_arch_timer_dt_ids[] = {
	{ .compatible = "arm,armv7-timer", },
	{ .compatible = "arm,armv8-timer", },
	{ }
};

static struct driver_d arm_arch_timer_driver = {
	.name = "arm-architected-timer",
	.probe = arm_arch_timer_probe,
	.of_compatible = DRV_OF_COMPAT(arm_arch_timer_dt_ids),
};
postcore_platform_driver(arm_arch_timer_driver);