blob: dda1946e84dd4f52f0555aad4ab1a81bf4fa7c03 [file] [log] [blame]
Thomas Gleixner9952f692019-05-28 10:10:04 -07001// SPDX-License-Identifier: GPL-2.0-only
Stephen Warrenae278a92012-11-19 16:41:20 -07002/*
3 * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved.
Stephen Warrenae278a92012-11-19 16:41:20 -07004 */
5
Marc Zyngierc625f762015-09-28 15:49:15 +01006#include <linux/acpi.h>
Stephen Warrenae278a92012-11-19 16:41:20 -07007#include <linux/init.h>
8#include <linux/of.h>
Arnd Bergmann3d5a9652013-03-19 15:38:50 +01009#include <linux/clocksource.h>
Stephen Warrenae278a92012-11-19 16:41:20 -070010
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020011extern struct of_device_id __timer_of_table[];
Stephen Warrenae278a92012-11-19 16:41:20 -070012
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020013static const struct of_device_id __timer_of_table_sentinel
14 __used __section(__timer_of_table_end);
Stephen Warrenae278a92012-11-19 16:41:20 -070015
Daniel Lezcanoba5d08c2017-05-26 17:40:46 +020016void __init timer_probe(void)
Stephen Warrenae278a92012-11-19 16:41:20 -070017{
18 struct device_node *np;
19 const struct of_device_id *match;
Daniel Lezcanob7c4db82016-05-31 16:25:59 +020020 of_init_fn_1_ret init_func_ret;
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020021 unsigned timers = 0;
Daniel Lezcanob7c4db82016-05-31 16:25:59 +020022 int ret;
Stephen Warrenae278a92012-11-19 16:41:20 -070023
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020024 for_each_matching_node_and_match(np, __timer_of_table, &match) {
Sebastian Hesselbartheeb93d02013-09-26 02:08:17 +020025 if (!of_device_is_available(np))
26 continue;
27
Daniel Lezcanob7c4db82016-05-31 16:25:59 +020028 init_func_ret = match->data;
29
30 ret = init_func_ret(np);
31 if (ret) {
Rob Herring469869d2017-07-18 16:42:53 -050032 pr_err("Failed to initialize '%pOF': %d\n", np, ret);
Daniel Lezcanob7c4db82016-05-31 16:25:59 +020033 continue;
34 }
35
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020036 timers++;
Daniel Lezcanob7c4db82016-05-31 16:25:59 +020037 }
38
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020039 timers += acpi_probe_device_table(timer);
Marc Zyngierc625f762015-09-28 15:49:15 +010040
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020041 if (!timers)
42 pr_crit("%s: no matching timers found\n", __func__);
Stephen Warrenae278a92012-11-19 16:41:20 -070043}