mirror of
https://github.com/torvalds/linux.git
synced 2024-11-10 14:11:52 +00:00
177cf6e52b
All the clocksource drivers's init function are now converted to return an error code. CLOCKSOURCE_OF_DECLARE is no longer used as well as the clksrc-of table. Let's convert back the names: - CLOCKSOURCE_OF_DECLARE_RET => CLOCKSOURCE_OF_DECLARE - clksrc-of-ret => clksrc-of Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> For exynos_mct and samsung_pwm_timer: Acked-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> For arch/arc: Acked-by: Vineet Gupta <vgupta@synopsys.com> For mediatek driver: Acked-by: Matthias Brugger <matthias.bgg@gmail.com> For the Rockchip-part Acked-by: Heiko Stuebner <heiko@sntech.de> For STi : Acked-by: Patrice Chotard <patrice.chotard@st.com> For the mps2-timer.c and versatile.c changes: Acked-by: Liviu Dudau <Liviu.Dudau@arm.com> For the OXNAS part : Acked-by: Neil Armstrong <narmstrong@baylibre.com> For LPC32xx driver: Acked-by: Sylvain Lemieux <slemieux.tyco@gmail.com> For Broadcom Kona timer change: Acked-by: Ray Jui <ray.jui@broadcom.com> For Sun4i and Sun5i: Acked-by: Chen-Yu Tsai <wens@csie.org> For Meson6: Acked-by: Carlo Caione <carlo@caione.org> For Keystone: Acked-by: Santosh Shilimkar <ssantosh@kernel.org> For NPS: Acked-by: Noam Camus <noamca@mellanox.com> For bcm2835: Acked-by: Eric Anholt <eric@anholt.net>
57 lines
1.3 KiB
C
57 lines
1.3 KiB
C
#include <linux/clocksource.h>
|
|
#include <linux/sched_clock.h>
|
|
#include <linux/of_address.h>
|
|
#include <linux/printk.h>
|
|
#include <linux/delay.h>
|
|
#include <linux/init.h>
|
|
#include <linux/clk.h>
|
|
|
|
static void __iomem *xtal_in_cnt;
|
|
static struct delay_timer delay_timer;
|
|
|
|
static unsigned long notrace read_xtal_counter(void)
|
|
{
|
|
return readl_relaxed(xtal_in_cnt);
|
|
}
|
|
|
|
static u64 notrace read_sched_clock(void)
|
|
{
|
|
return read_xtal_counter();
|
|
}
|
|
|
|
static int __init tango_clocksource_init(struct device_node *np)
|
|
{
|
|
struct clk *clk;
|
|
int xtal_freq, ret;
|
|
|
|
xtal_in_cnt = of_iomap(np, 0);
|
|
if (xtal_in_cnt == NULL) {
|
|
pr_err("%s: invalid address\n", np->full_name);
|
|
return -ENXIO;
|
|
}
|
|
|
|
clk = of_clk_get(np, 0);
|
|
if (IS_ERR(clk)) {
|
|
pr_err("%s: invalid clock\n", np->full_name);
|
|
return PTR_ERR(clk);
|
|
}
|
|
|
|
xtal_freq = clk_get_rate(clk);
|
|
delay_timer.freq = xtal_freq;
|
|
delay_timer.read_current_timer = read_xtal_counter;
|
|
|
|
ret = clocksource_mmio_init(xtal_in_cnt, "tango-xtal", xtal_freq, 350,
|
|
32, clocksource_mmio_readl_up);
|
|
if (ret) {
|
|
pr_err("%s: registration failed\n", np->full_name);
|
|
return ret;
|
|
}
|
|
|
|
sched_clock_register(read_sched_clock, 32, xtal_freq);
|
|
register_current_timer_delay(&delay_timer);
|
|
|
|
return 0;
|
|
}
|
|
|
|
CLOCKSOURCE_OF_DECLARE(tango, "sigma,tick-counter", tango_clocksource_init);
|