summaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/dummy.c
blob: 96f9b6efca55ed9ab28bf8b3ba7540330381b2d4 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
/*
 * Copyright (C) 2013 Antony Pavlov <antonynpavlov@gmail.com>
 *
 * This file is part of barebox.
 * See file CREDITS for list of people who contributed to this project.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2
 * as published by the Free Software Foundation.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 */

#include <common.h>
#include <init.h>
#include <clock.h>

static uint64_t dummy_counter;

static uint64_t dummy_cs_read(void)
{
	static int first;

	if (!first) {
		pr_warn("Warning: Using dummy clocksource\n");
		first = 1;
	}

	dummy_counter += CONFIG_CLOCKSOURCE_DUMMY_RATE;

	return dummy_counter;
}

static struct clocksource dummy_cs = {
	.read	= dummy_cs_read,
	.mask   = CLOCKSOURCE_MASK(32),
};

static int clocksource_init(void)
{
	dummy_counter = 0;

	clocks_calc_mult_shift(&dummy_cs.mult, &dummy_cs.shift,
		100000000, NSEC_PER_SEC, 10);

	pr_debug("clocksource_init: mult=%08x, shift=%08x\n",
			dummy_cs.mult, dummy_cs.shift);

	return init_clock(&dummy_cs);
}
pure_initcall(clocksource_init);