Thomas Gleixner | 9952f69 | 2019-05-28 10:10:04 -0700 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0-only |
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 2 | /* |
3 | * Copyright (c) 2012, NVIDIA CORPORATION. All rights reserved. | ||||
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 4 | */ |
5 | |||||
Marc Zyngier | c625f76 | 2015-09-28 15:49:15 +0100 | [diff] [blame] | 6 | #include <linux/acpi.h> |
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 7 | #include <linux/init.h> |
8 | #include <linux/of.h> | ||||
Arnd Bergmann | 3d5a965 | 2013-03-19 15:38:50 +0100 | [diff] [blame] | 9 | #include <linux/clocksource.h> |
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 10 | |
Daniel Lezcano | 2fcc112a | 2017-05-26 18:33:27 +0200 | [diff] [blame] | 11 | extern struct of_device_id __timer_of_table[]; |
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 12 | |
Daniel Lezcano | 2fcc112a | 2017-05-26 18:33:27 +0200 | [diff] [blame] | 13 | static const struct of_device_id __timer_of_table_sentinel |
14 | __used __section(__timer_of_table_end); | ||||
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 15 | |
Daniel Lezcano | ba5d08c | 2017-05-26 17:40:46 +0200 | [diff] [blame] | 16 | void __init timer_probe(void) |
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 17 | { |
18 | struct device_node *np; | ||||
19 | const struct of_device_id *match; | ||||
Daniel Lezcano | b7c4db8 | 2016-05-31 16:25:59 +0200 | [diff] [blame] | 20 | of_init_fn_1_ret init_func_ret; |
Daniel Lezcano | 2fcc112a | 2017-05-26 18:33:27 +0200 | [diff] [blame] | 21 | unsigned timers = 0; |
Daniel Lezcano | b7c4db8 | 2016-05-31 16:25:59 +0200 | [diff] [blame] | 22 | int ret; |
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 23 | |
Daniel Lezcano | 2fcc112a | 2017-05-26 18:33:27 +0200 | [diff] [blame] | 24 | for_each_matching_node_and_match(np, __timer_of_table, &match) { |
Sebastian Hesselbarth | eeb93d0 | 2013-09-26 02:08:17 +0200 | [diff] [blame] | 25 | if (!of_device_is_available(np)) |
26 | continue; | ||||
27 | |||||
Daniel Lezcano | b7c4db8 | 2016-05-31 16:25:59 +0200 | [diff] [blame] | 28 | init_func_ret = match->data; |
29 | |||||
30 | ret = init_func_ret(np); | ||||
31 | if (ret) { | ||||
Rob Herring | 469869d | 2017-07-18 16:42:53 -0500 | [diff] [blame] | 32 | pr_err("Failed to initialize '%pOF': %d\n", np, ret); |
Daniel Lezcano | b7c4db8 | 2016-05-31 16:25:59 +0200 | [diff] [blame] | 33 | continue; |
34 | } | ||||
35 | |||||
Daniel Lezcano | 2fcc112a | 2017-05-26 18:33:27 +0200 | [diff] [blame] | 36 | timers++; |
Daniel Lezcano | b7c4db8 | 2016-05-31 16:25:59 +0200 | [diff] [blame] | 37 | } |
38 | |||||
Daniel Lezcano | 2fcc112a | 2017-05-26 18:33:27 +0200 | [diff] [blame] | 39 | timers += acpi_probe_device_table(timer); |
Marc Zyngier | c625f76 | 2015-09-28 15:49:15 +0100 | [diff] [blame] | 40 | |
Daniel Lezcano | 2fcc112a | 2017-05-26 18:33:27 +0200 | [diff] [blame] | 41 | if (!timers) |
42 | pr_crit("%s: no matching timers found\n", __func__); | ||||
Stephen Warren | ae278a9 | 2012-11-19 16:41:20 -0700 | [diff] [blame] | 43 | } |