From patchwork Sun Apr 28 23:01:55 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 16477 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-vc0-f197.google.com (mail-vc0-f197.google.com [209.85.220.197]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 866072395E for ; Sun, 28 Apr 2013 23:03:36 +0000 (UTC) Received: by mail-vc0-f197.google.com with SMTP id hz10sf2414750vcb.8 for ; Sun, 28 Apr 2013 16:02:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:mime-version:x-beenthere:x-received:received-spf :x-received:x-forwarded-to:x-forwarded-for:delivered-to:x-received :received-spf:x-received:from:to:cc:subject:date:message-id:x-mailer :in-reply-to:references:x-gm-message-state:x-original-sender :x-original-authentication-results:precedence:mailing-list:list-id :x-google-group-id:list-post:list-help:list-archive:list-unsubscribe; bh=H5v0mWqVN2GS0yoXz5E52P1Wiqjqcyf4Czf4d1k+cIY=; b=daxTWoRQuS0KqcXDGgW5SfidopdfUAlPlc5pNAZu6jK2WPzrj+ypIzX2oco/iTZtJZ VGIf2VJWagq9VgnqejzR2UKjYNPfh81s8beouNSpMbJbI+xj2ITw/6IH04oG1JC2SyZp 1eP/YtndLpuj9za2wAUjRs8t2v1CG3O3r0NzCn3/lFSuViKpc2c9/1KMyZY9tELeJzlD 3r3g/z13yaY05SV+iYjG0Uma3vGnoL6q4VEN+h7AE4paNXwAR9qKESRHfZ8lJkH4IQRZ dxtHj8F4IBCH287kFDFgVaOluwsj638v6m5dDnrNJ/ifmXE3hPxL5kK+f/1om/zYv8CM cA+g== X-Received: by 10.224.75.137 with SMTP id y9mr16195977qaj.3.1367190155390; Sun, 28 Apr 2013 16:02:35 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.49.127.111 with SMTP id nf15ls2603738qeb.25.gmail; Sun, 28 Apr 2013 16:02:35 -0700 (PDT) X-Received: by 10.59.0.226 with SMTP id bb2mr9898550ved.1.1367190155209; Sun, 28 Apr 2013 16:02:35 -0700 (PDT) Received: from mail-vb0-x236.google.com (mail-vb0-x236.google.com [2607:f8b0:400c:c02::236]) by mx.google.com with ESMTPS id b4si8972259vdw.57.2013.04.28.16.02.35 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Apr 2013 16:02:35 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c02::236 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c02::236; Received: by mail-vb0-f54.google.com with SMTP id w16so4814158vbf.27 for ; Sun, 28 Apr 2013 16:02:35 -0700 (PDT) X-Received: by 10.221.0.199 with SMTP id nn7mr32539621vcb.14.1367190155027; Sun, 28 Apr 2013 16:02:35 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patches@linaro.org Received: by 10.58.127.98 with SMTP id nf2csp33791veb; Sun, 28 Apr 2013 16:02:34 -0700 (PDT) X-Received: by 10.180.107.6 with SMTP id gy6mr14199563wib.22.1367190154090; Sun, 28 Apr 2013 16:02:34 -0700 (PDT) Received: from mail-we0-x22a.google.com (mail-we0-x22a.google.com [2a00:1450:400c:c03::22a]) by mx.google.com with ESMTPS id db10si3451252wib.53.2013.04.28.16.02.33 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Apr 2013 16:02:34 -0700 (PDT) Received-SPF: neutral (google.com: 2a00:1450:400c:c03::22a is neither permitted nor denied by best guess record for domain of julien.grall@linaro.org) client-ip=2a00:1450:400c:c03::22a; Received: by mail-we0-f170.google.com with SMTP id z53so847119wey.1 for ; Sun, 28 Apr 2013 16:02:33 -0700 (PDT) X-Received: by 10.194.8.99 with SMTP id q3mr26049724wja.34.1367190153679; Sun, 28 Apr 2013 16:02:33 -0700 (PDT) Received: from belegaer.uk.xensource.com. (firewall.ctxuk.citrix.com. [46.33.159.2]) by mx.google.com with ESMTPSA id k5sm18711393wiy.5.2013.04.28.16.02.32 for (version=TLSv1.2 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 28 Apr 2013 16:02:33 -0700 (PDT) From: Julien Grall To: xen-devel@lists.xen.org Cc: ian.campbell@citrix.com, patches@linaro.org, anthony.perard@citrix.com, stefano.stabellini@eu.citrix.com, Julien Grall Subject: [RFC 12/29] xen/arm: Introduce gic_irq_xlate Date: Mon, 29 Apr 2013 00:01:55 +0100 Message-Id: X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-Gm-Message-State: ALoCoQlMZ9H3j1NrDoGseG5E3+GHSG8guUp5uqFx906N4zpDbLA5wEOFEo3aJNL1IuNGyCGg3ns5 X-Original-Sender: julien.grall@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c02::236 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Precedence: list Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org List-ID: X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , This function translates an interrupt specifier to an IRQ number and IRQ type (ie: level trigger, edge trigger,...). It's GIC specific. Signed-off-by: Julien Grall --- xen/arch/arm/gic.c | 20 ++++++++++++++++++++ xen/arch/arm/setup.c | 1 + xen/include/asm-arm/gic.h | 4 ++++ 3 files changed, 25 insertions(+) diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c index e03bb67..1f44fea 100644 --- a/xen/arch/arm/gic.c +++ b/xen/arch/arm/gic.c @@ -329,6 +329,26 @@ static void __cpuinit gic_hyp_disable(void) GICH[GICH_HCR] = 0; } +int gic_irq_xlate(const u32 *intspec, unsigned int intsize, + unsigned int *out_hwirq, + unsigned int *out_type) +{ + if ( intsize < 3 ) + return -EINVAL; + + /* Get the interrupt number and add 16 to skip over SGIs */ + *out_hwirq = intspec[1] + 16; + + /* For SPIs, we need to add 16 more to get the GIC irq ID number */ + if ( !intspec[0] ) + *out_hwirq += 16; + + if ( out_type ) + *out_type = intspec[2] & IRQ_TYPE_SENSE_MASK; + + return 0; +} + /* Set up the GIC */ void __init gic_init(void) { diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c index 77d0879..51f4bba 100644 --- a/xen/arch/arm/setup.c +++ b/xen/arch/arm/setup.c @@ -429,6 +429,7 @@ void __init start_xen(unsigned long boot_phys_offset, setup_mm(fdt_paddr, fdt_size); dt_unflatten_host_device_tree(); + dt_irq_xlate = gic_irq_xlate; #ifdef EARLY_UART_ADDRESS /* TODO Need to get device tree or command line for UART address */ diff --git a/xen/include/asm-arm/gic.h b/xen/include/asm-arm/gic.h index 2fac673..945e8db 100644 --- a/xen/include/asm-arm/gic.h +++ b/xen/include/asm-arm/gic.h @@ -187,6 +187,10 @@ extern void send_SGI_allbutself(enum gic_sgi sgi); /* print useful debug info */ extern void gic_dump_info(struct vcpu *v); +/* IRQ translation function for the device tree */ +int gic_irq_xlate(const u32 *intspec, unsigned int intsize, + unsigned int *out_hwirq, unsigned int *out_type); + #endif /* __ASSEMBLY__ */ #endif