diff options
author | Fu Wei <fu.wei@linaro.org> | 2017-03-21 12:31:15 -0400 |
---|---|---|
committer | Mark Rutland <mark.rutland@arm.com> | 2017-04-19 11:11:47 -0400 |
commit | ca0e1b5214eee56a7fc4c7a5399323ab0bad73ef (patch) | |
tree | 47d1f3ea607f8d12781848f9ef0e6f95db5c81c5 /drivers/clocksource/arm_arch_timer.c | |
parent | 13bf6992fe5496d56101b5d57fbdae2ee91184f2 (diff) |
clocksource: arm_arch_timer: move arch_timer_needs_of_probing into DT init call
To cleanly split code paths specific to ACPI or DT at a higher level,
this patch removes arch_timer_init(), folding the relevant
parts of its logic into existing callers.
This pathes the way for further rework, and saves a few lines.
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.c | 46 |
1 files changed, 21 insertions, 25 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index e38f4d4290ad..ac6fd00c98ba 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c | |||
@@ -1105,9 +1105,6 @@ static bool __init arch_timer_needs_of_probing(void) | |||
1105 | 1105 | ||
1106 | static int __init arch_timer_common_init(void) | 1106 | static int __init arch_timer_common_init(void) |
1107 | { | 1107 | { |
1108 | if (acpi_disabled && arch_timer_needs_of_probing()) | ||
1109 | return 0; | ||
1110 | |||
1111 | arch_timer_banner(arch_timers_present); | 1108 | arch_timer_banner(arch_timers_present); |
1112 | arch_counter_register(arch_timers_present); | 1109 | arch_counter_register(arch_timers_present); |
1113 | return arch_timer_arch_init(); | 1110 | return arch_timer_arch_init(); |
@@ -1145,26 +1142,9 @@ static enum arch_timer_ppi_nr __init arch_timer_select_ppi(void) | |||
1145 | return ARCH_TIMER_PHYS_SECURE_PPI; | 1142 | return ARCH_TIMER_PHYS_SECURE_PPI; |
1146 | } | 1143 | } |
1147 | 1144 | ||
1148 | static int __init arch_timer_init(void) | ||
1149 | { | ||
1150 | int ret; | ||
1151 | |||
1152 | ret = arch_timer_register(); | ||
1153 | if (ret) | ||
1154 | return ret; | ||
1155 | |||
1156 | ret = arch_timer_common_init(); | ||
1157 | if (ret) | ||
1158 | return ret; | ||
1159 | |||
1160 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; | ||
1161 | |||
1162 | return 0; | ||
1163 | } | ||
1164 | |||
1165 | static int __init arch_timer_of_init(struct device_node *np) | 1145 | static int __init arch_timer_of_init(struct device_node *np) |
1166 | { | 1146 | { |
1167 | int i; | 1147 | int i, ret; |
1168 | u32 rate; | 1148 | u32 rate; |
1169 | 1149 | ||
1170 | if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { | 1150 | if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { |
@@ -1176,6 +1156,8 @@ static int __init arch_timer_of_init(struct device_node *np) | |||
1176 | for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) | 1156 | for (i = ARCH_TIMER_PHYS_SECURE_PPI; i < ARCH_TIMER_MAX_TIMER_PPI; i++) |
1177 | arch_timer_ppi[i] = irq_of_parse_and_map(np, i); | 1157 | arch_timer_ppi[i] = irq_of_parse_and_map(np, i); |
1178 | 1158 | ||
1159 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; | ||
1160 | |||
1179 | rate = arch_timer_get_cntfrq; | 1161 | rate = arch_timer_get_cntfrq; |
1180 | arch_timer_of_configure_rate(rate, np); | 1162 | arch_timer_of_configure_rate(rate, np); |
1181 | 1163 | ||
@@ -1203,7 +1185,14 @@ static int __init arch_timer_of_init(struct device_node *np) | |||
1203 | arch_counter_suspend_stop = of_property_read_bool(np, | 1185 | arch_counter_suspend_stop = of_property_read_bool(np, |
1204 | "arm,no-tick-in-suspend"); | 1186 | "arm,no-tick-in-suspend"); |
1205 | 1187 | ||
1206 | return arch_timer_init(); | 1188 | ret = arch_timer_register(); |
1189 | if (ret) | ||
1190 | return ret; | ||
1191 | |||
1192 | if (arch_timer_needs_of_probing()) | ||
1193 | return 0; | ||
1194 | |||
1195 | return arch_timer_common_init(); | ||
1207 | } | 1196 | } |
1208 | CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init); | 1197 | CLOCKSOURCE_OF_DECLARE(armv7_arch_timer, "arm,armv7-timer", arch_timer_of_init); |
1209 | CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init); | 1198 | CLOCKSOURCE_OF_DECLARE(armv8_arch_timer, "arm,armv8-timer", arch_timer_of_init); |
@@ -1285,7 +1274,8 @@ static int __init arch_timer_mem_init(struct device_node *np) | |||
1285 | if (ret) | 1274 | if (ret) |
1286 | goto out; | 1275 | goto out; |
1287 | 1276 | ||
1288 | return arch_timer_common_init(); | 1277 | if (!arch_timer_needs_of_probing()) |
1278 | ret = arch_timer_common_init(); | ||
1289 | out: | 1279 | out: |
1290 | iounmap(cntctlbase); | 1280 | iounmap(cntctlbase); |
1291 | of_node_put(best_frame); | 1281 | of_node_put(best_frame); |
@@ -1314,6 +1304,7 @@ static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags) | |||
1314 | /* Initialize per-processor generic timer */ | 1304 | /* Initialize per-processor generic timer */ |
1315 | static int __init arch_timer_acpi_init(struct acpi_table_header *table) | 1305 | static int __init arch_timer_acpi_init(struct acpi_table_header *table) |
1316 | { | 1306 | { |
1307 | int ret; | ||
1317 | struct acpi_table_gtdt *gtdt; | 1308 | struct acpi_table_gtdt *gtdt; |
1318 | 1309 | ||
1319 | if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { | 1310 | if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { |
@@ -1341,6 +1332,8 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table) | |||
1341 | map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, | 1332 | map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, |
1342 | gtdt->non_secure_el2_flags); | 1333 | gtdt->non_secure_el2_flags); |
1343 | 1334 | ||
1335 | arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; | ||
1336 | |||
1344 | /* | 1337 | /* |
1345 | * When probing via ACPI, we have no mechanism to override the sysreg | 1338 | * When probing via ACPI, we have no mechanism to override the sysreg |
1346 | * CNTFRQ value. This *must* be correct. | 1339 | * CNTFRQ value. This *must* be correct. |
@@ -1363,8 +1356,11 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table) | |||
1363 | /* Check for globally applicable workarounds */ | 1356 | /* Check for globally applicable workarounds */ |
1364 | arch_timer_check_ool_workaround(ate_match_acpi_oem_info, table); | 1357 | arch_timer_check_ool_workaround(ate_match_acpi_oem_info, table); |
1365 | 1358 | ||
1366 | arch_timer_init(); | 1359 | ret = arch_timer_register(); |
1367 | return 0; | 1360 | if (ret) |
1361 | return ret; | ||
1362 | |||
1363 | return arch_timer_common_init(); | ||
1368 | } | 1364 | } |
1369 | CLOCKSOURCE_ACPI_DECLARE(arch_timer, ACPI_SIG_GTDT, arch_timer_acpi_init); | 1365 | CLOCKSOURCE_ACPI_DECLARE(arch_timer, ACPI_SIG_GTDT, arch_timer_acpi_init); |
1370 | #endif | 1366 | #endif |