From patchwork Wed Feb 4 14:02:00 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Parth Dixit X-Patchwork-Id: 44355 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f71.google.com (mail-la0-f71.google.com [209.85.215.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id A26812029F for ; Wed, 4 Feb 2015 14:06:29 +0000 (UTC) Received: by mail-la0-f71.google.com with SMTP id hs14sf1493625lab.2 for ; Wed, 04 Feb 2015 06:06:28 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:cc:subject:precedence:list-id:list-unsubscribe:list-post :list-help:list-subscribe:mime-version:content-type :content-transfer-encoding:sender:errors-to:x-original-sender :x-original-authentication-results:mailing-list:list-archive; bh=gF/FINBoOYeLZUmwMFzW/7Yd3cl1XfTQLv2CFhmo6Fk=; b=VS+MwNNly41241dC8JsFDgfI7MpBYsCquRFc4S3AE5pqg/11Af4a+M6THU2MtdnM7w ZKUMnGHPzPciuMyFL1Oh7v2ud5SMfaTJ865Zd19dyOOXVz52Tan98DA022zzvPMXH9/m NVHmZJOPow22C8kQHHk3MVs/PPMwBN0eLbNsXOX3tdByutUzJ9W3FEGv/CJspn1HKGjN KHzx0nP62hxepCYIX6wddMoesFdvWNcJ8GLa+lINMCMbsdUgf8SltnhAmaJh5k1kmd0i q8S6muht7YfFmdWDb5HVx1XFow/9UcwXGdwJPJDmoefQsGt8aeIB8oilGi4EiAVHBKJz +jKQ== X-Gm-Message-State: ALoCoQkhphgUZFHPddizODeUmSWLm8h2+cjfrjBoU7F+y7U/o9NravHxMhqDpZxkZ1EgnHwBCsdz X-Received: by 10.152.121.65 with SMTP id li1mr3902593lab.0.1423058788696; Wed, 04 Feb 2015 06:06:28 -0800 (PST) X-BeenThere: patchwork-forward@linaro.org Received: by 10.153.7.162 with SMTP id dd2ls41451lad.81.gmail; Wed, 04 Feb 2015 06:06:28 -0800 (PST) X-Received: by 10.152.20.4 with SMTP id j4mr13735797lae.29.1423058788548; Wed, 04 Feb 2015 06:06:28 -0800 (PST) Received: from mail-lb0-f172.google.com (mail-lb0-f172.google.com. [209.85.217.172]) by mx.google.com with ESMTPS id az6si1410412lbc.84.2015.02.04.06.06.28 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Feb 2015 06:06:28 -0800 (PST) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.217.172 as permitted sender) client-ip=209.85.217.172; Received: by mail-lb0-f172.google.com with SMTP id l4so1665182lbv.3 for ; Wed, 04 Feb 2015 06:06:28 -0800 (PST) X-Received: by 10.112.176.236 with SMTP id cl12mr11328283lbc.3.1423058788450; Wed, 04 Feb 2015 06:06:28 -0800 (PST) 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.35.133 with SMTP id h5csp507717lbj; Wed, 4 Feb 2015 06:06:27 -0800 (PST) X-Received: by 10.140.94.213 with SMTP id g79mr14803724qge.70.1423058786909; Wed, 04 Feb 2015 06:06:26 -0800 (PST) Received: from lists.xen.org (lists.xen.org. [50.57.142.19]) by mx.google.com with ESMTPS id x4si2040229qai.103.2015.02.04.06.06.26 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 04 Feb 2015 06:06:26 -0800 (PST) Received-SPF: none (google.com: xen-devel-bounces@lists.xen.org does not designate permitted sender hosts) client-ip=50.57.142.19; Received: from localhost ([127.0.0.1] helo=lists.xen.org) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0ZT-0007Rq-Jd; Wed, 04 Feb 2015 14:04:47 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xen.org with esmtp (Exim 4.72) (envelope-from ) id 1YJ0ZS-0007QQ-LO for xen-devel@lists.xen.org; Wed, 04 Feb 2015 14:04:46 +0000 Received: from [85.158.137.68] by server-8.bemta-3.messagelabs.com id 97/18-03710-DF622D45; Wed, 04 Feb 2015 14:04:45 +0000 X-Env-Sender: parth.dixit@linaro.org X-Msg-Ref: server-11.tower-31.messagelabs.com!1423058682!12004634!1 X-Originating-IP: [209.85.192.174] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 6.12.5; banners=-,-,- X-VirusChecked: Checked Received: (qmail 23857 invoked from network); 4 Feb 2015 14:04:43 -0000 Received: from mail-pd0-f174.google.com (HELO mail-pd0-f174.google.com) (209.85.192.174) by server-11.tower-31.messagelabs.com with RC4-SHA encrypted SMTP; 4 Feb 2015 14:04:43 -0000 Received: by pdjz10 with SMTP id z10so876654pdj.13 for ; Wed, 04 Feb 2015 06:04:42 -0800 (PST) X-Received: by 10.70.36.99 with SMTP id p3mr46029353pdj.81.1423058682084; Wed, 04 Feb 2015 06:04:42 -0800 (PST) Received: from parthd-ubunutu.qualcomm.com ([202.46.23.62]) by mx.google.com with ESMTPSA id kg12sm2161881pbb.44.2015.02.04.06.04.37 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 04 Feb 2015 06:04:40 -0800 (PST) From: parth.dixit@linaro.org To: xen-devel@lists.xen.org Date: Wed, 4 Feb 2015 19:32:00 +0530 Message-Id: <1423058539-26403-17-git-send-email-parth.dixit@linaro.org> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> References: <1423058539-26403-1-git-send-email-parth.dixit@linaro.org> Cc: ian.campbell@citrix.com, Naresh Bhat , julien.grall@linaro.org, tim@xen.org, stefano.stabellini@citrix.com, jbeulich@suse.com, Parth Dixit , christoffer.dall@linaro.org Subject: [Xen-devel] [PATCH RFC 16/35] ARM64 / ACPI: Parse GTDT to initialize timer X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: List-Unsubscribe: , List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Sender: xen-devel-bounces@lists.xen.org Errors-To: xen-devel-bounces@lists.xen.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: parth.dixit@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.217.172 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-Archive: From: Naresh Bhat Parse GTDT (Generic Timer Descriptor Table) to initialize timer. Using the information presented by GTDT to initialize the arch timer (not momery-mapped). Signed-off-by: Naresh Bhat Signed-off-by: Parth Dixit --- xen/arch/arm/setup.c | 6 +++++ xen/arch/arm/time.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++ xen/include/xen/time.h | 1 + 3 files changed, 73 insertions(+) diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 569b2da..af9f429 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -775,7 +775,12 @@ void __init start_xen(unsigned long boot_phys_offset, smp_init_cpus(); cpus = smp_get_max_cpus(); +/* Comment for now take it after GIC initialization */ +#if defined(CONFIG_ACPI) && defined(CONFIG_ARM_64) + init_xen_acpi_time(); +#else init_xen_time(); +#endif gic_init(); @@ -789,6 +794,7 @@ void __init start_xen(unsigned long boot_phys_offset, xsm_dt_init(); init_maintenance_interrupt(); + init_timer_interrupt(); timer_init(); diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c index 0add494..0d4c26d 100644 --- a/xen/arch/arm/time.c +++ b/xen/arch/arm/time.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -239,6 +240,71 @@ struct tm wallclock_time(uint64_t *ns) return (struct tm) { 0 }; } +#if defined(CONFIG_ARM_64) && defined(CONFIG_ACPI) + +#define ACPI_GTDT_INTR_MASK 0x3 + +static int GTDT_INTRL_TAB[] ={ DT_IRQ_TYPE_LEVEL_HIGH, DT_IRQ_TYPE_EDGE_RISING, + DT_IRQ_TYPE_LEVEL_LOW ,DT_IRQ_TYPE_EDGE_FALLING}; + +/* Initialize per-processor generic timer */ +static int __init arch_timer_acpi_init(struct acpi_table_header *table) +{ + int res; + int type; + struct acpi_table_gtdt *gtdt; + + gtdt = (struct acpi_table_gtdt *)table; + + /* Initialize all the generic timer IRQ variable from GTDT table */ + + type = GTDT_INTRL_TAB[gtdt->non_secure_el1_flags & ACPI_GTDT_INTR_MASK]; + acpi_set_irq(gtdt->non_secure_el1_interrupt, type); + timer_irq[TIMER_PHYS_NONSECURE_PPI] = gtdt->non_secure_el1_interrupt; + + type = GTDT_INTRL_TAB[gtdt->secure_el1_flags & ACPI_GTDT_INTR_MASK]; + acpi_set_irq(gtdt->secure_el1_interrupt, type); + timer_irq[TIMER_PHYS_SECURE_PPI] = gtdt->secure_el1_interrupt; + + type = GTDT_INTRL_TAB[gtdt->non_secure_el2_flags & ACPI_GTDT_INTR_MASK]; + acpi_set_irq(gtdt->non_secure_el2_interrupt, type); + timer_irq[TIMER_HYP_PPI] = gtdt->non_secure_el2_interrupt; + + type = GTDT_INTRL_TAB[gtdt->virtual_timer_flags & ACPI_GTDT_INTR_MASK]; + acpi_set_irq(gtdt->virtual_timer_interrupt, type); + timer_irq[TIMER_VIRT_PPI] = gtdt->virtual_timer_interrupt; + + printk("Generic Timer IRQ from ACPI GTDT: phys=%u hyp=%u virt=%u\n", + timer_irq[TIMER_PHYS_NONSECURE_PPI], + timer_irq[TIMER_HYP_PPI], + timer_irq[TIMER_VIRT_PPI]); + + res = platform_init_time(); + if ( res ) + printk("Timer: Cannot initialize platform timer"); + + /* Check that this CPU supports the Generic Timer interface */ + if ( !cpu_has_gentimer ) + printk("CPU does not support the Generic Timer v1 interface"); + + cpu_khz = READ_SYSREG32(CNTFRQ_EL0) / 1000; + + boot_count = READ_SYSREG64(CNTPCT_EL0); + + printk("Using generic timer at %lu KHz\n", cpu_khz); + + return 0; +} + +int __init init_xen_acpi_time(void) +{ + /* Initialize all the generic timers presented in GTDT */ + acpi_table_parse(ACPI_SIG_GTDT, arch_timer_acpi_init); + return 0; +} + +#endif + /* * Local variables: * mode: C diff --git a/xen/include/xen/time.h b/xen/include/xen/time.h index 709501f..4598a0c 100644 --- a/xen/include/xen/time.h +++ b/xen/include/xen/time.h @@ -11,6 +11,7 @@ #include #include +extern int init_xen_acpi_time(void); extern int init_xen_time(void); extern void cstate_restore_tsc(void);