aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/arm_arch_timer.c
diff options
context:
space:
mode:
authorFu Wei <fu.wei@linaro.org>2017-03-21 12:31:14 -0400
committerMark Rutland <mark.rutland@arm.com>2017-04-19 11:11:47 -0400
commit13bf6992fe5496d56101b5d57fbdae2ee91184f2 (patch)
treed8601a68755171cef42256c03cdba9f5113f3832 /drivers/clocksource/arm_arch_timer.c
parent5d3dfa96c7a202f3a70ebeb6f8bb5005c1547250 (diff)
clocksource: arm_arch_timer: refactor arch_timer_needs_probing
When booting with DT, it's possible for timer nodes to be probed in any order. Some common initialisation needs to occur after all nodes have been probed, and arch_timer_common_init() has code to detect when this has happened. This logic is DT-specific, and it would be best to factor it out of the common code that will be shared with ACPI. This patch folds this into the existing arch_timer_needs_probing(), which is renamed to arch_timer_needs_of_probing(), and no longer takes any arguments. This is only called when using DT, and not when using ACPI, which will have a deterministic probe order. Signed-off-by: Fu Wei <fu.wei@linaro.org> Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org> [Mark: reword commit message] Signed-off-by: Mark Rutland <mark.rutland@arm.com>
Diffstat (limited to 'drivers/clocksource/arm_arch_timer.c')
-rw-r--r--drivers/clocksource/arm_arch_timer.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index 02c5cb86ca83..e38f4d4290ad 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -1076,15 +1076,28 @@ static const struct of_device_id arch_timer_mem_of_match[] __initconst = {
1076 {}, 1076 {},
1077}; 1077};
1078 1078
1079static bool __init 1079static bool __init arch_timer_needs_of_probing(void)
1080arch_timer_needs_probing(int type, const struct of_device_id *matches)
1081{ 1080{
1082 struct device_node *dn; 1081 struct device_node *dn;
1083 bool needs_probing = false; 1082 bool needs_probing = false;
1083 unsigned int mask = ARCH_TIMER_TYPE_CP15 | ARCH_TIMER_TYPE_MEM;
1084 1084
1085 dn = of_find_matching_node(NULL, matches); 1085 /* We have two timers, and both device-tree nodes are probed. */
1086 if (dn && of_device_is_available(dn) && !(arch_timers_present & type)) 1086 if ((arch_timers_present & mask) == mask)
1087 return false;
1088
1089 /*
1090 * Only one type of timer is probed,
1091 * check if we have another type of timer node in device-tree.
1092 */
1093 if (arch_timers_present & ARCH_TIMER_TYPE_CP15)
1094 dn = of_find_matching_node(NULL, arch_timer_mem_of_match);
1095 else
1096 dn = of_find_matching_node(NULL, arch_timer_of_match);
1097
1098 if (dn && of_device_is_available(dn))
1087 needs_probing = true; 1099 needs_probing = true;
1100
1088 of_node_put(dn); 1101 of_node_put(dn);
1089 1102
1090 return needs_probing; 1103 return needs_probing;
@@ -1092,17 +1105,8 @@ arch_timer_needs_probing(int type, const struct of_device_id *matches)
1092 1105
1093static int __init arch_timer_common_init(void) 1106static int __init arch_timer_common_init(void)
1094{ 1107{
1095 unsigned mask = ARCH_TIMER_TYPE_CP15 | ARCH_TIMER_TYPE_MEM; 1108 if (acpi_disabled && arch_timer_needs_of_probing())
1096 1109 return 0;
1097 /* Wait until both nodes are probed if we have two timers */
1098 if ((arch_timers_present & mask) != mask) {
1099 if (arch_timer_needs_probing(ARCH_TIMER_TYPE_MEM,
1100 arch_timer_mem_of_match))
1101 return 0;
1102 if (arch_timer_needs_probing(ARCH_TIMER_TYPE_CP15,
1103 arch_timer_of_match))
1104 return 0;
1105 }
1106 1110
1107 arch_timer_banner(arch_timers_present); 1111 arch_timer_banner(arch_timers_present);
1108 arch_counter_register(arch_timers_present); 1112 arch_counter_register(arch_timers_present);