aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/clocksource/arm_arch_timer.c
diff options
context:
space:
mode:
authorFu Wei <fu.wei@linaro.org>2017-03-31 13:51:02 -0400
committerMark Rutland <mark.rutland@arm.com>2017-04-19 11:11:49 -0400
commitf79d209405fada700047245ed1a152bab8d6535e (patch)
tree60ee389838f1a83fe442e8332ae07d955c0039f6 /drivers/clocksource/arm_arch_timer.c
parent5f1ae4ebe578319a0cd5dae9591dd426070be106 (diff)
clocksource: arm_arch_timer: simplify ACPI support code.
The patch update arm_arch_timer driver to use the function provided by the new GTDT driver of ACPI. By this way, arm_arch_timer.c can be simplified, and separate all the ACPI GTDT knowledge from this timer driver. Signed-off-by: Fu Wei <fu.wei@linaro.org> Signed-off-by: Hanjun Guo <hanjun.guo@linaro.org> Tested-by: Xiongfeng Wang <wangxiongfeng2@huawei.com> Reviewed-by: Hanjun Guo <hanjun.guo@linaro.org> Tested-by: Hanjun Guo <hanjun.guo@linaro.org> 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.c40
1 files changed, 10 insertions, 30 deletions
diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c
index d87c4035a505..e398228d60b2 100644
--- a/drivers/clocksource/arm_arch_timer.c
+++ b/drivers/clocksource/arm_arch_timer.c
@@ -1385,53 +1385,33 @@ out:
1385CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", 1385CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem",
1386 arch_timer_mem_of_init); 1386 arch_timer_mem_of_init);
1387 1387
1388#ifdef CONFIG_ACPI 1388#ifdef CONFIG_ACPI_GTDT
1389static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags)
1390{
1391 int trigger, polarity;
1392
1393 if (!interrupt)
1394 return 0;
1395
1396 trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE
1397 : ACPI_LEVEL_SENSITIVE;
1398
1399 polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW
1400 : ACPI_ACTIVE_HIGH;
1401
1402 return acpi_register_gsi(NULL, interrupt, trigger, polarity);
1403}
1404
1405/* Initialize per-processor generic timer */ 1389/* Initialize per-processor generic timer */
1406static int __init arch_timer_acpi_init(struct acpi_table_header *table) 1390static int __init arch_timer_acpi_init(struct acpi_table_header *table)
1407{ 1391{
1408 int ret; 1392 int ret;
1409 struct acpi_table_gtdt *gtdt;
1410 1393
1411 if (arch_timers_present & ARCH_TIMER_TYPE_CP15) { 1394 if (arch_timers_present & ARCH_TIMER_TYPE_CP15) {
1412 pr_warn("already initialized, skipping\n"); 1395 pr_warn("already initialized, skipping\n");
1413 return -EINVAL; 1396 return -EINVAL;
1414 } 1397 }
1415 1398
1416 gtdt = container_of(table, struct acpi_table_gtdt, header);
1417
1418 arch_timers_present |= ARCH_TIMER_TYPE_CP15; 1399 arch_timers_present |= ARCH_TIMER_TYPE_CP15;
1419 1400
1420 arch_timer_ppi[ARCH_TIMER_PHYS_SECURE_PPI] = 1401 ret = acpi_gtdt_init(table, NULL);
1421 map_generic_timer_interrupt(gtdt->secure_el1_interrupt, 1402 if (ret) {
1422 gtdt->secure_el1_flags); 1403 pr_err("Failed to init GTDT table.\n");
1404 return ret;
1405 }
1423 1406
1424 arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI] = 1407 arch_timer_ppi[ARCH_TIMER_PHYS_NONSECURE_PPI] =
1425 map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt, 1408 acpi_gtdt_map_ppi(ARCH_TIMER_PHYS_NONSECURE_PPI);
1426 gtdt->non_secure_el1_flags);
1427 1409
1428 arch_timer_ppi[ARCH_TIMER_VIRT_PPI] = 1410 arch_timer_ppi[ARCH_TIMER_VIRT_PPI] =
1429 map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, 1411 acpi_gtdt_map_ppi(ARCH_TIMER_VIRT_PPI);
1430 gtdt->virtual_timer_flags);
1431 1412
1432 arch_timer_ppi[ARCH_TIMER_HYP_PPI] = 1413 arch_timer_ppi[ARCH_TIMER_HYP_PPI] =
1433 map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, 1414 acpi_gtdt_map_ppi(ARCH_TIMER_HYP_PPI);
1434 gtdt->non_secure_el2_flags);
1435 1415
1436 arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI]; 1416 arch_timer_kvm_info.virtual_irq = arch_timer_ppi[ARCH_TIMER_VIRT_PPI];
1437 1417
@@ -1452,7 +1432,7 @@ static int __init arch_timer_acpi_init(struct acpi_table_header *table)
1452 } 1432 }
1453 1433
1454 /* Always-on capability */ 1434 /* Always-on capability */
1455 arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON); 1435 arch_timer_c3stop = acpi_gtdt_c3stop(arch_timer_uses_ppi);
1456 1436
1457 /* Check for globally applicable workarounds */ 1437 /* Check for globally applicable workarounds */
1458 arch_timer_check_ool_workaround(ate_match_acpi_oem_info, table); 1438 arch_timer_check_ool_workaround(ate_match_acpi_oem_info, table);