blob: b7860bc0db4bb7ddea4980b9525449f50b2ac153 [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
Joe Perches33def842020-10-21 19:36:07 -070014 __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) {
Jon Hunter14e019df2019-08-21 16:02:41 +010032 if (ret != -EPROBE_DEFER)
33 pr_err("Failed to initialize '%pOF': %d\n", np,
34 ret);
Daniel Lezcanob7c4db82016-05-31 16:25:59 +020035 continue;
36 }
37
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020038 timers++;
Daniel Lezcanob7c4db82016-05-31 16:25:59 +020039 }
40
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020041 timers += acpi_probe_device_table(timer);
Marc Zyngierc625f762015-09-28 15:49:15 +010042
Daniel Lezcano2fcc112a2017-05-26 18:33:27 +020043 if (!timers)
44 pr_crit("%s: no matching timers found\n", __func__);
Stephen Warrenae278a92012-11-19 16:41:20 -070045}