From patchwork Wed Sep 28 18:17:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fu Wei Fu X-Patchwork-Id: 77090 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp577573qgf; Wed, 28 Sep 2016 11:19:04 -0700 (PDT) X-Received: by 10.98.24.71 with SMTP id 68mr59042428pfy.65.1475086744239; Wed, 28 Sep 2016 11:19:04 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ix8si9608655pac.139.2016.09.28.11.19.04; Wed, 28 Sep 2016 11:19:04 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-acpi-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-acpi-owner@vger.kernel.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753716AbcI1SS4 (ORCPT + 6 others); Wed, 28 Sep 2016 14:18:56 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:33797 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752980AbcI1SSj (ORCPT ); Wed, 28 Sep 2016 14:18:39 -0400 Received: by mail-pf0-f174.google.com with SMTP id l25so19878058pfb.1 for ; Wed, 28 Sep 2016 11:18:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1wj2cksao3WsKHki8sYCzuZyoBi7W/9JtQBywivtK1E=; b=emHp/71AfyaTu1Q3s91LDiPwX3BXzsJSZFcT88SEEnz+u1S1goAmyhB321g4GZpUed OATkp5DbdIOaTtCmWLFsG+qIrxJWljCXLEuBtlK2GNIu5wEf83+yoXqP2MGstZEND7XE DFPzKSToVCQFfVr1y8NEAcjOudbqwgWawfHfM= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=1wj2cksao3WsKHki8sYCzuZyoBi7W/9JtQBywivtK1E=; b=B6zvrQcG39NZpKZ2S95jMmn/o7jIc2c8Qp+VUCN5hEBEy6z0apnpGCma87eo/t0dhw 7zoyRp523pmvRP2j7fl6QR54CHPM+wbNrQvwjk8qlMNeR4wQrJijhU2w0f+ca4GAgJTY UN8cAkOwD1duHDM9bdyEI3U9xT28vxHmlJVP+mdDbZwgTZgo8v85pG6EawwEfPaErPby BI0PPXvwT+9nN49qJvJUqUUiUs89gplH86JwyUPB2Y2N3Aeee2LYrninOTzWF2MPyV9C KGl6tOhsQj+gLrA2ysqPgvo2oJYaGxJS/n9lZ3oBSoXnvljlwgHbldtBKvMc+D0uCcwx sJBw== X-Gm-Message-State: AE9vXwNd5XLDev6Ssb6QKsQqwHfRxtGA+3FMAJA3Z5sZa5jv9cwmtja5R2+hJ3XY5JPwUUfP X-Received: by 10.98.196.206 with SMTP id h75mr59616016pfk.156.1475086718576; Wed, 28 Sep 2016 11:18:38 -0700 (PDT) Received: from Rei-Ayanami.localdomain.localdomain ([67.238.99.186]) by smtp.googlemail.com with ESMTPSA id ak3sm14226365pad.19.2016.09.28.11.18.36 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 28 Sep 2016 11:18:38 -0700 (PDT) From: fu.wei@linaro.org To: rjw@rjwysocki.net, lenb@kernel.org, daniel.lezcano@linaro.org, tglx@linutronix.de, marc.zyngier@arm.com, mark.rutland@arm.com, lorenzo.pieralisi@arm.com, sudeep.holla@arm.com, hanjun.guo@linaro.org Cc: linux-arm-kernel@lists.infradead.org, linaro-acpi@lists.linaro.org, linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, rruigrok@codeaurora.org, harba@codeaurora.org, cov@codeaurora.org, timur@codeaurora.org, graeme.gregory@linaro.org, al.stone@linaro.org, jcm@redhat.com, wei@redhat.com, arnd@arndb.de, catalin.marinas@arm.com, will.deacon@arm.com, Suravee.Suthikulpanit@amd.com, leo.duran@amd.com, wim@iguana.be, linux@roeck-us.net, linux-watchdog@vger.kernel.org, tn@semihalf.com, christoffer.dall@linaro.org, julien.grall@arm.com, Fu Wei Subject: [PATCH v14 5/9] clocksource/drivers/arm_arch_timer: Simplify ACPI support code. Date: Thu, 29 Sep 2016 02:17:13 +0800 Message-Id: <1475086637-1914-6-git-send-email-fu.wei@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1475086637-1914-1-git-send-email-fu.wei@linaro.org> References: <1475086637-1914-1-git-send-email-fu.wei@linaro.org> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org From: Fu Wei 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 Signed-off-by: Hanjun Guo --- drivers/clocksource/Kconfig | 1 + drivers/clocksource/arm_arch_timer.c | 50 +++++++++--------------------------- 2 files changed, 13 insertions(+), 38 deletions(-) -- 2.7.4 -- To unsubscribe from this list: send the line "unsubscribe linux-acpi" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index b58d259..a63bf12 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -8,6 +8,7 @@ config CLKSRC_OF config CLKSRC_ACPI bool select CLKSRC_PROBE + select ACPI_GTDT if ARM64 config CLKSRC_PROBE bool diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 84be023..c7b0040 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -887,61 +887,35 @@ out: CLOCKSOURCE_OF_DECLARE(armv7_arch_timer_mem, "arm,armv7-timer-mem", arch_timer_mem_init); -#ifdef CONFIG_ACPI -static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags) -{ - int trigger, polarity; - - if (!interrupt) - return 0; - - trigger = (flags & ACPI_GTDT_INTERRUPT_MODE) ? ACPI_EDGE_SENSITIVE - : ACPI_LEVEL_SENSITIVE; - - polarity = (flags & ACPI_GTDT_INTERRUPT_POLARITY) ? ACPI_ACTIVE_LOW - : ACPI_ACTIVE_HIGH; - - return acpi_register_gsi(NULL, interrupt, trigger, polarity); -} - +#ifdef CONFIG_ACPI_GTDT /* Initialize per-processor generic timer */ static int __init arch_timer_acpi_init(struct acpi_table_header *table) { - struct acpi_table_gtdt *gtdt; + int timer_count; if (arch_timers_present & ARCH_CP15_TIMER) { pr_warn("already initialized, skipping\n"); return -EINVAL; } - gtdt = container_of(table, struct acpi_table_gtdt, header); - arch_timers_present |= ARCH_CP15_TIMER; - arch_timer_ppi[PHYS_SECURE_PPI] = - map_generic_timer_interrupt(gtdt->secure_el1_interrupt, - gtdt->secure_el1_flags); - - arch_timer_ppi[PHYS_NONSECURE_PPI] = - map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt, - gtdt->non_secure_el1_flags); + timer_count = acpi_gtdt_init(table); - arch_timer_ppi[VIRT_PPI] = - map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, - gtdt->virtual_timer_flags); - - arch_timer_ppi[HYP_PPI] = - map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, - gtdt->non_secure_el2_flags); + arch_timer_ppi[PHYS_SECURE_PPI] = acpi_gtdt_map_ppi(PHYS_SECURE_PPI); + arch_timer_ppi[PHYS_NONSECURE_PPI] = acpi_gtdt_map_ppi(PHYS_NONSECURE_PPI); + arch_timer_ppi[VIRT_PPI] = acpi_gtdt_map_ppi(VIRT_PPI); + arch_timer_ppi[HYP_PPI] = acpi_gtdt_map_ppi(HYP_PPI); + /* Always-on capability */ + arch_timer_c3stop = acpi_gtdt_c3stop(); /* Get the frequency from CNTFRQ */ arch_timer_detect_rate(NULL, NULL); - /* Always-on capability */ - arch_timer_c3stop = !(gtdt->non_secure_el1_flags & ACPI_GTDT_ALWAYS_ON); + if (timer_count < 0) + pr_err("Failed to get platform timer info.\n"); - arch_timer_init(); - return 0; + return arch_timer_init(); } CLOCKSOURCE_ACPI_DECLARE(arch_timer, ACPI_SIG_GTDT, arch_timer_acpi_init); #endif