From patchwork Wed Sep 14 20:09:38 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: fu.wei@linaro.org X-Patchwork-Id: 9332443 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 71A7C6077A for ; Wed, 14 Sep 2016 20:16:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 608F629FAA for ; Wed, 14 Sep 2016 20:16:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 54D8A29FC1; Wed, 14 Sep 2016 20:16:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED, T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0947B29FAA for ; Wed, 14 Sep 2016 20:16:58 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkGaZ-0000ES-JA; Wed, 14 Sep 2016 20:15:23 +0000 Received: from mail-wm0-x235.google.com ([2a00:1450:400c:c09::235]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bkGXc-0005Rp-Vx for linux-arm-kernel@lists.infradead.org; Wed, 14 Sep 2016 20:12:25 +0000 Received: by mail-wm0-x235.google.com with SMTP id k186so28883646wmd.0 for ; Wed, 14 Sep 2016 13:12:00 -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=DzuLhePB46bkQRFk1IgLd2ZNNG9Dt3D3STGOu5ebPg4=; b=B+2BYcJKdoC8J4tsZowGwyHqxwOBHckl518dT6V02PUT9ZtK1hw3yUUGL/y5yUSP1x QyZ+U+drWI7IvNeA2x7qtk+OuSS/N7MMGs7f4Fs4idZWB80KQnEhqaK/Dx2W/c8Nrjir 14jGZrZ/xlMleis3/UQOe1JPITurlAJ3p456I= 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=DzuLhePB46bkQRFk1IgLd2ZNNG9Dt3D3STGOu5ebPg4=; b=Y3u0HVaE0M9BMtpqWTbGAgP5pfBgeqHUjQCcNhXSIU6TGEvwa1sLETW+Gw7YDBaciE b+thn1Y3BmcpbSyE+N3AzjcWDomDBptnJLOr2wCJH0fhj6PFSTRXzTZWxOf/9LEtt5ez F5W0gMUhG2vpQP2Cb9nOxa5s8MFbxx8a9Kap4C/dVcSVkDbk4CbExECWaUDNvJahmGI4 K9fEwtCNqSZse6rSh0qFnKCW/M3vr+2e0skDBAHu+3xXIDv+XmWtfCIN5GQ829Mc4yxo R0XcWggIdMs4RrJBwnzdsnRJUpog16OZe/HF7fNssYaXp52X37q5OBNV7UGn/tO8iA4b uwqw== X-Gm-Message-State: AE9vXwPSpITVlgvuv4XtzEcxd71kOdi02T2sHe9oxE4ZOIjgnnJu8fV3tHb+gT+ETgtBicXk X-Received: by 10.194.52.3 with SMTP id p3mr4345537wjo.55.1473883918915; Wed, 14 Sep 2016 13:11:58 -0700 (PDT) Received: from Rei-Ayanami.localdomain.com ([59.58.254.106]) by smtp.googlemail.com with ESMTPSA id ab9sm1233449wjc.7.2016.09.14.13.11.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 Sep 2016 13:11:58 -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 Subject: [PATCH v13 5/8] clocksource/drivers/arm_arch_timer: Simplify ACPI support code. Date: Thu, 15 Sep 2016 04:09:38 +0800 Message-Id: <1473883781-9571-6-git-send-email-fu.wei@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473883781-9571-1-git-send-email-fu.wei@linaro.org> References: <1473883781-9571-1-git-send-email-fu.wei@linaro.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160914_131221_321106_C7B3EAD3 X-CRM114-Status: GOOD ( 13.37 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linaro-acpi@lists.linaro.org, catalin.marinas@arm.com, will.deacon@arm.com, linux-kernel@vger.kernel.org, wim@iguana.be, Fu Wei , wei@redhat.com, al.stone@linaro.org, tn@semihalf.com, timur@codeaurora.org, linux-acpi@vger.kernel.org, linux@roeck-us.net, harba@codeaurora.org, julien.grall@arm.com, linux-watchdog@vger.kernel.org, arnd@arndb.de, jcm@redhat.com, cov@codeaurora.org, linux-arm-kernel@lists.infradead.org, graeme.gregory@linaro.org, rruigrok@codeaurora.org, leo.duran@amd.com, Suravee.Suthikulpanit@amd.com, christoffer.dall@linaro.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP 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(-) 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 7d48349..0197ef9 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