18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-only
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright (c) 2012, NVIDIA CORPORATION.  All rights reserved.
48c2ecf20Sopenharmony_ci */
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/acpi.h>
78c2ecf20Sopenharmony_ci#include <linux/init.h>
88c2ecf20Sopenharmony_ci#include <linux/of.h>
98c2ecf20Sopenharmony_ci#include <linux/clocksource.h>
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciextern struct of_device_id __timer_of_table[];
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cistatic const struct of_device_id __timer_of_table_sentinel
148c2ecf20Sopenharmony_ci	__used __section("__timer_of_table_end");
158c2ecf20Sopenharmony_ci
168c2ecf20Sopenharmony_civoid __init timer_probe(void)
178c2ecf20Sopenharmony_ci{
188c2ecf20Sopenharmony_ci	struct device_node *np;
198c2ecf20Sopenharmony_ci	const struct of_device_id *match;
208c2ecf20Sopenharmony_ci	of_init_fn_1_ret init_func_ret;
218c2ecf20Sopenharmony_ci	unsigned timers = 0;
228c2ecf20Sopenharmony_ci	int ret;
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ci	for_each_matching_node_and_match(np, __timer_of_table, &match) {
258c2ecf20Sopenharmony_ci		if (!of_device_is_available(np))
268c2ecf20Sopenharmony_ci			continue;
278c2ecf20Sopenharmony_ci
288c2ecf20Sopenharmony_ci		init_func_ret = match->data;
298c2ecf20Sopenharmony_ci
308c2ecf20Sopenharmony_ci		ret = init_func_ret(np);
318c2ecf20Sopenharmony_ci		if (ret) {
328c2ecf20Sopenharmony_ci			if (ret != -EPROBE_DEFER)
338c2ecf20Sopenharmony_ci				pr_err("Failed to initialize '%pOF': %d\n", np,
348c2ecf20Sopenharmony_ci				       ret);
358c2ecf20Sopenharmony_ci			continue;
368c2ecf20Sopenharmony_ci		}
378c2ecf20Sopenharmony_ci
388c2ecf20Sopenharmony_ci		timers++;
398c2ecf20Sopenharmony_ci	}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_ci	timers += acpi_probe_device_table(timer);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	if (!timers)
448c2ecf20Sopenharmony_ci		pr_crit("%s: no matching timers found\n", __func__);
458c2ecf20Sopenharmony_ci}
46