From patchwork Tue May 7 16:48:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Javier Martinez Canillas X-Patchwork-Id: 2536121 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by patchwork2.kernel.org (Postfix) with ESMTP id A58D1DF215 for ; Tue, 7 May 2013 16:48:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759157Ab3EGQs2 (ORCPT ); Tue, 7 May 2013 12:48:28 -0400 Received: from mail-wg0-f53.google.com ([74.125.82.53]:51360 "EHLO mail-wg0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1758587Ab3EGQs1 (ORCPT ); Tue, 7 May 2013 12:48:27 -0400 Received: by mail-wg0-f53.google.com with SMTP id y10so888952wgg.32 for ; Tue, 07 May 2013 09:48:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer :x-gm-message-state; bh=KcuBheypNnBhj9KG+7oHK+2kVPTVzZfYlcvttkc5TfE=; b=aDxhwKJdRSViAspMgP7WM3CJwImtsUfcS+nCzucTR6fYckGoATFfmcr4OUhuLt0f5v X2FsnH38EhMfkXliAMqQhLuZXBgp/03Ivvokpd4VMbxgnLm5kcKJyK7ylpi1UHSjiGNX K9Lld3aIr/oAF4Zv7m6+/+8KohGgNh0hA2L9yPrlmHIWx5zrj2cYRUb3HgGRCBckLHv4 /mzYHqakAhUlYyEY2EzwyDmBesnc9+//Jm+5z3aLlC7TkAvgosEAsuTKnwVbpzjgHN3S vmxMjVPduPubZ39iunXvdVE97B1QIYDf2Jxh6gAhhiXXKM/B170xrSayo0tDHiOZBc2P dTvw== X-Received: by 10.194.58.78 with SMTP id o14mr4827810wjq.39.1367945305603; Tue, 07 May 2013 09:48:25 -0700 (PDT) Received: from localhost.localdomain (81.223.77.188.dynamic.jazztel.es. [188.77.223.81]) by mx.google.com with ESMTPSA id eu18sm3937398wid.1.2013.05.07.09.48.23 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 07 May 2013 09:48:25 -0700 (PDT) From: Javier Martinez Canillas To: Thomas Gleixner Cc: Ingo Molnar , Alexander Gordeev , Richard Weinberger , Rob Herring , Stephen Warren , Grant Likely , Jon Hunter , Linus Walleij , devicetree-discuss@lists.ozlabs.org, linux-omap , Javier Martinez Canillas , Javier Martinez Canillas Subject: [PATCH RESEND] genirq: add function to get IRQ edge/level flags Date: Tue, 7 May 2013 18:48:08 +0200 Message-Id: <1367945288-5625-1-git-send-email-javier@dowhile0.org> X-Mailer: git-send-email 1.7.7.6 X-Gm-Message-State: ALoCoQn2hCVZGrDxbdMMkDL0OrSM1G0PctX/VpwC1chKQlv75U/sVKBSgsfdrjhO6LgdIyigrHJP Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org According to Documentation/devicetree/bindings/interrupt-controller/interrupts.txt the "#interrupt-cells" property of an "interrupt-controller" is used to define the number of cells needed to specify a single interrupt. A commonly used variant is two cell on which #interrupt-cells = <2> and the first cell defines the index of the interrupt in the controller while the second cell is used to specify any of the following flags: - bits[3:0] trigger type and level flags 1 = low-to-high edge triggered 2 = high-to-low edge triggered 4 = active high level-sensitive 8 = active low level-sensitive An example of an interrupt controller which use the two cell format is the OMAP GPIO controller that allows GPIO lines to be used as IRQ (Documentation/devicetree/bindings/gpio/gpio-omap.txt) But setting #interrupt-cells = <2> on the OMAP GPIO device node and specifying the GPIO-IRQ type and level flags on the second cell does not store this value on the populated IORESOURCE_IRQ struct resource. This is because when using an IRQ from an interrupt controller and setting both cells (e.g:) interrupt-parent = <&gpio6>; interrupts = <16 8>; A call to of_irq_to_resource() is made and this function calls irq_of_parse_and_map_type() to get the virtual IRQ mapped to the real index for this interrupt controller. This IRQ number is populated on the struct resource: int of_irq_to_resource(struct device_node *dev, int index, struct resource *r) { int irq = irq_of_parse_and_map(dev, index); .. r->start = r->end = irq; } irq_of_parse_and_map() calls to irq_create_of_mapping() which calls to the correct xlate function handler according to "#interrupt-cells" (irq_domain_xlate_onecell or irq_domain_xlate_twocell) and to irq_set_irq_type() to set the IRQ type. But the type is never returned so it can't be saved on the IRQ struct resource flags member. This means that drivers that want to get the IRQ edge/level flags defined in the Device Tree from a struct resource will not be able to get it. Drivers can get the IRQ flags by using irq_get_irq_data(irq) and irqd_get_trigger_type(irq_data) but this will unnecessary expose irq_data to callers and also is more error prone. So, is better to add an irq_get_trigger_type() function to obtain the edge/level flags for an IRQ. Signed-off-by: Javier Martinez Canillas --- include/linux/irq.h | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-) diff --git a/include/linux/irq.h b/include/linux/irq.h index bc4e066..0e8e3a6 100644 --- a/include/linux/irq.h +++ b/include/linux/irq.h @@ -579,6 +579,12 @@ static inline struct msi_desc *irq_data_get_msi(struct irq_data *d) return d->msi_desc; } +static inline u32 irq_get_trigger_type(unsigned int irq) +{ + struct irq_data *d = irq_get_irq_data(irq); + return d ? irqd_get_trigger_type(d) : 0; +} + int __irq_alloc_descs(int irq, unsigned int from, unsigned int cnt, int node, struct module *owner);