From patchwork Wed Jun 10 13:41:53 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fu Wei Fu X-Patchwork-Id: 49695 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 09A6920C81 for ; Wed, 10 Jun 2015 13:45:11 +0000 (UTC) Received: by lbbqq2 with SMTP id qq2sf12562071lbb.0 for ; Wed, 10 Jun 2015 06:45:10 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:in-reply-to:references:sender:precedence:list-id :x-original-sender:x-original-authentication-results:mailing-list :list-post:list-help:list-archive:list-unsubscribe; bh=0vC3AW8MLYyQxVX+eaj3Btw3IKtzKjtOGOF3TiwerSU=; b=GjYOiaiu4K/ev6D6rTgy5UnFbdfLkj904/yq0Uhj5tU27gxVoB2REEIhYO2G/+VASX nBR7tODlK2xL7zwLfEPEpw6lIQnrYN7Wd+r4mYbn8NFp1ehO7/mm9RkDs85kTP5EPSQk 2dd8osDbqeb/I1xC63NjzK5RQSvP6ydelzEvwYPMcE9GkYsBh2shcshzcbfchJ5D+32b t2wG3K+hJVG7+kvAJTvqiYWY1H50kSimVWtRgNiE0AiEE7nW1oG49ZIWvHx5eXOa5At7 xEiHWiYAxxc5kbbmp+nqbAfpl6RbF6bYAWtT6khpKm4sjER6dYSrj3mxwFdtynA5G+Mt aR+Q== X-Gm-Message-State: ALoCoQlGxB+SagY+CuAwii7R5xOJcej/8XjyfNVHtb3M2QoeKAdXPpz1ZAgowUKD0F//L0Uos96k X-Received: by 10.194.158.134 with SMTP id wu6mr3081608wjb.6.1433943909955; Wed, 10 Jun 2015 06:45:09 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.29.36 with SMTP id g4ls240107lah.33.gmail; Wed, 10 Jun 2015 06:45:09 -0700 (PDT) X-Received: by 10.152.44.225 with SMTP id h1mr4095611lam.5.1433943909790; Wed, 10 Jun 2015 06:45:09 -0700 (PDT) Received: from mail-la0-f41.google.com (mail-la0-f41.google.com. [209.85.215.41]) by mx.google.com with ESMTPS id li2si9082303lab.51.2015.06.10.06.45.09 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jun 2015 06:45:09 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) client-ip=209.85.215.41; Received: by laar3 with SMTP id r3so33333149laa.3 for ; Wed, 10 Jun 2015 06:45:09 -0700 (PDT) X-Received: by 10.152.4.137 with SMTP id k9mr4059927lak.29.1433943909669; Wed, 10 Jun 2015 06:45:09 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.108.230 with SMTP id hn6csp3347796lbb; Wed, 10 Jun 2015 06:45:08 -0700 (PDT) X-Received: by 10.67.24.65 with SMTP id ig1mr5882926pad.61.1433943907842; Wed, 10 Jun 2015 06:45:07 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id fn10si14128748pab.103.2015.06.10.06.45.07; Wed, 10 Jun 2015 06:45:07 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of devicetree-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S964930AbbFJNpF (ORCPT + 7 others); Wed, 10 Jun 2015 09:45:05 -0400 Received: from mail-pd0-f177.google.com ([209.85.192.177]:32819 "EHLO mail-pd0-f177.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S964859AbbFJNoa (ORCPT ); Wed, 10 Jun 2015 09:44:30 -0400 Received: by pdjn11 with SMTP id n11so38351891pdj.0 for ; Wed, 10 Jun 2015 06:44:29 -0700 (PDT) X-Received: by 10.66.129.161 with SMTP id nx1mr6062314pab.84.1433943869672; Wed, 10 Jun 2015 06:44:29 -0700 (PDT) Received: from localhost.localdomain (li400-65.members.linode.com. [106.187.50.65]) by mx.google.com with ESMTPSA id je4sm8739085pbb.17.2015.06.10.06.44.19 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Jun 2015 06:44:28 -0700 (PDT) From: fu.wei@linaro.org To: Suravee.Suthikulpanit@amd.com, linaro-acpi@lists.linaro.org, linux-watchdog@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Cc: tekkamanninja@gmail.com, graeme.gregory@linaro.org, al.stone@linaro.org, hanjun.guo@linaro.org, timur@codeaurora.org, ashwin.chaugule@linaro.org, arnd@arndb.de, linux@roeck-us.net, vgandhi@codeaurora.org, wim@iguana.be, jcm@redhat.com, leo.duran@amd.com, corbet@lwn.net, mark.rutland@arm.com, catalin.marinas@arm.com, will.deacon@arm.com, rjw@rjwysocki.net, Fu Wei Subject: [PATCH v5 8/8] clocksource: simplify ACPI code in arm_arch_timer.c Date: Wed, 10 Jun 2015 21:41:53 +0800 Message-Id: <1433943713-32466-9-git-send-email-fu.wei@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1433943713-32466-1-git-send-email-fu.wei@linaro.org> References: <=fu.wei@linaro.org> <1433943713-32466-1-git-send-email-fu.wei@linaro.org> Sender: devicetree-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: devicetree@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: fu.wei@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.41 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , 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 --- arch/arm64/kernel/time.c | 4 +-- drivers/acpi/gtdt.c | 43 ++++++++++++++++++++++++++ drivers/clocksource/Kconfig | 1 + drivers/clocksource/arm_arch_timer.c | 60 +++++++----------------------------- include/clocksource/arm_arch_timer.h | 8 +++++ include/linux/acpi.h | 5 +++ include/linux/clocksource.h | 4 +-- 7 files changed, 72 insertions(+), 53 deletions(-) diff --git a/arch/arm64/kernel/time.c b/arch/arm64/kernel/time.c index 42f9195..2cabea6 100644 --- a/arch/arm64/kernel/time.c +++ b/arch/arm64/kernel/time.c @@ -75,9 +75,9 @@ void __init time_init(void) /* * Since ACPI or FDT will only one be available in the system, - * we can use acpi_generic_timer_init() here safely + * we can use arch_timer_acpi_init() here safely */ - acpi_generic_timer_init(); + arch_timer_acpi_init(); arch_timer_rate = arch_timer_get_rate(); if (!arch_timer_rate) diff --git a/drivers/acpi/gtdt.c b/drivers/acpi/gtdt.c index a92abf2..699c9fd 100644 --- a/drivers/acpi/gtdt.c +++ b/drivers/acpi/gtdt.c @@ -17,6 +17,8 @@ #include #include +#include + static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags) { int trigger, polarity; @@ -33,6 +35,47 @@ static int __init map_generic_timer_interrupt(u32 interrupt, u32 flags) return acpi_register_gsi(NULL, interrupt, trigger, polarity); } +struct arch_timer_data __initdata *arch_timer_data_p; + +static int __init arch_timer_data_init(struct acpi_table_header *table) +{ + struct acpi_table_gtdt *gtdt; + + gtdt = container_of(table, struct acpi_table_gtdt, header); + + arch_timer_data_p->phys_secure_ppi = + map_generic_timer_interrupt(gtdt->secure_el1_interrupt, + gtdt->secure_el1_flags); + + arch_timer_data_p->phys_nonsecure_ppi = + map_generic_timer_interrupt(gtdt->non_secure_el1_interrupt, + gtdt->non_secure_el1_flags); + + arch_timer_data_p->virt_ppi = + map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, + gtdt->virtual_timer_flags); + + arch_timer_data_p->hyp_ppi = + map_generic_timer_interrupt(gtdt->non_secure_el2_interrupt, + gtdt->non_secure_el2_flags); + + arch_timer_data_p->c3stop = !(gtdt->non_secure_el1_flags & + ACPI_GTDT_ALWAYS_ON); + + return 0; +} + +/* Initialize the arch_timer_data struct for arm_arch_timer by GTDT info */ +int __init gtdt_arch_timer_data_init(struct arch_timer_data *data) +{ + if (acpi_disabled || !data) + return -EINVAL; + + arch_timer_data_p = data; + + return acpi_table_parse(ACPI_SIG_GTDT, arch_timer_data_init); +} + /* * Initialize a SBSA generic Watchdog platform device info from GTDT * According to SBSA specification the size of refresh and control diff --git a/drivers/clocksource/Kconfig b/drivers/clocksource/Kconfig index 51d7865f..ea94a6f 100644 --- a/drivers/clocksource/Kconfig +++ b/drivers/clocksource/Kconfig @@ -109,6 +109,7 @@ config CLKSRC_EFM32 config ARM_ARCH_TIMER bool select CLKSRC_OF if OF + select ACPI_GTDT if ACPI config ARM_ARCH_TIMER_EVTSTREAM bool "Support for ARM architected timer event stream generation" diff --git a/drivers/clocksource/arm_arch_timer.c b/drivers/clocksource/arm_arch_timer.c index 0aa135d..99505bb 100644 --- a/drivers/clocksource/arm_arch_timer.c +++ b/drivers/clocksource/arm_arch_timer.c @@ -817,68 +817,30 @@ 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); -} - /* Initialize per-processor generic timer */ -static int __init arch_timer_acpi_init(struct acpi_table_header *table) +void __init arch_timer_acpi_init(void) { - struct acpi_table_gtdt *gtdt; + struct arch_timer_data data; if (arch_timers_present & ARCH_CP15_TIMER) { pr_warn("arch_timer: already initialized, skipping\n"); - return -EINVAL; + return; } - 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); - - arch_timer_ppi[VIRT_PPI] = - map_generic_timer_interrupt(gtdt->virtual_timer_interrupt, - gtdt->virtual_timer_flags); + if (gtdt_arch_timer_data_init(&data)) + return; - 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] = data.phys_secure_ppi; + arch_timer_ppi[PHYS_NONSECURE_PPI] = data.phys_nonsecure_ppi; + arch_timer_ppi[VIRT_PPI] = data.virt_ppi; + arch_timer_ppi[HYP_PPI] = data.hyp_ppi; + /* Always-on capability */ + arch_timer_c3stop = data.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); - arch_timer_init(); - return 0; -} - -/* Initialize all the generic timers presented in GTDT */ -void __init acpi_generic_timer_init(void) -{ - if (acpi_disabled) - return; - - acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init); } #endif diff --git a/include/clocksource/arm_arch_timer.h b/include/clocksource/arm_arch_timer.h index 9916d0e..5deed9d 100644 --- a/include/clocksource/arm_arch_timer.h +++ b/include/clocksource/arm_arch_timer.h @@ -43,6 +43,14 @@ enum arch_timer_reg { #define ARCH_TIMER_EVT_STREAM_FREQ 10000 /* 100us */ +struct arch_timer_data { + int phys_secure_ppi; + int phys_nonsecure_ppi; + int virt_ppi; + int hyp_ppi; + bool c3stop; +}; + #ifdef CONFIG_ARM_ARCH_TIMER extern u32 arch_timer_get_rate(void); diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 598f0f1..7213c0d 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -458,6 +458,11 @@ void acpi_walk_dep_device_list(acpi_handle handle); struct platform_device *acpi_create_platform_device(struct acpi_device *); #define ACPI_PTR(_ptr) (_ptr) +#ifdef CONFIG_ACPI_GTDT +struct arch_timer_data; +int __init gtdt_arch_timer_data_init(struct arch_timer_data *data); +#endif + #else /* !CONFIG_ACPI */ #define acpi_disabled 1 diff --git a/include/linux/clocksource.h b/include/linux/clocksource.h index d27d015..264e553 100644 --- a/include/linux/clocksource.h +++ b/include/linux/clocksource.h @@ -254,9 +254,9 @@ static inline void clocksource_of_init(void) {} #endif #ifdef CONFIG_ACPI -void acpi_generic_timer_init(void); +void arch_timer_acpi_init(void); #else -static inline void acpi_generic_timer_init(void) { } +static inline void arch_timer_acpi_init(void) { } #endif #endif /* _LINUX_CLOCKSOURCE_H */