From patchwork Wed Sep 24 22:17:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hauke Mehrtens X-Patchwork-Id: 4971271 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 51EF8BEEA6 for ; Wed, 24 Sep 2014 22:20:10 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 4025320270 for ; Wed, 24 Sep 2014 22:20:09 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3B6E92026F for ; Wed, 24 Sep 2014 22:20:08 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWusr-0005Jp-2U; Wed, 24 Sep 2014 22:18:01 +0000 Received: from hauke-m.de ([5.39.93.123]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XWusn-00053u-El for linux-arm-kernel@lists.infradead.org; Wed, 24 Sep 2014 22:17:58 +0000 Received: from hauke-desktop.lan (spit-414.wohnheim.uni-bremen.de [134.102.133.158]) by hauke-m.de (Postfix) with ESMTPSA id AA11A200FB; Thu, 25 Sep 2014 00:17:35 +0200 (CEST) From: Hauke Mehrtens To: linville@tuxdriver.com, linux-wireless@vger.kernel.org Subject: [PATCH v5 2/2] bcma: get IRQ numbers from dt Date: Thu, 25 Sep 2014 00:17:28 +0200 Message-Id: <1411597048-25470-2-git-send-email-hauke@hauke-m.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1411597048-25470-1-git-send-email-hauke@hauke-m.de> References: <1411597048-25470-1-git-send-email-hauke@hauke-m.de> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140924_151757_835104_86A233A1 X-CRM114-Status: GOOD ( 13.65 ) X-Spam-Score: -0.7 (/) Cc: devicetree@vger.kernel.org, zajec5@gmail.com, arnd@arndb.de, Hauke Mehrtens , varkabhadram@gmail.com, arend@broadcom.com, linux-arm-kernel@lists.infradead.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP It is not possible to auto detect the irq numbers used by the cores on an arm SoC. If bcma was registered with device tree it will search for some device tree nodes with the irq number and add it to the core configuration. Signed-off-by: Hauke Mehrtens --- Documentation/devicetree/bindings/bus/bcma.txt | 24 +++++++++++++++ drivers/bcma/main.c | 42 ++++++++++++++++++++++++++ 2 files changed, 66 insertions(+) This is based on wireless-testing and should go into that tree. changes since: v4: - make use of interrupt-map - only do the irq stuff here v2: - use of_translate_address() to support ranges RFC: - add #ifdef CONFIG_OF diff --git a/Documentation/devicetree/bindings/bus/bcma.txt b/Documentation/devicetree/bindings/bus/bcma.txt index e9070c1..1dc75d3 100644 --- a/Documentation/devicetree/bindings/bus/bcma.txt +++ b/Documentation/devicetree/bindings/bus/bcma.txt @@ -8,6 +8,10 @@ Required properties: The cores on the AXI bus are automatically detected by bcma with the memory ranges they are using and they get registered afterwards. +Automatic detection of the IRQ number is not reliable on +BCM47xx/BCM53xx ARM SoCs. To assign IRQ numbers to the cores, provide +them manually through device tree. The IRQ number and the device tree +child entry will get assigned to the core with the matching reg address. Example: @@ -17,4 +21,24 @@ Example: ranges = <0x00000000 0x18000000 0x00100000>; #address-cells = <1>; #size-cells = <1>; + + #interrupt-cells = <0>; + interrupt-map-mask = <0x000fffff>; + interrupt-map = + /* Ethernet Controller 0 */ + <0x00024000 &gic GIC_SPI 147 IRQ_TYPE_LEVEL_HIGH>, + + /* Ethernet Controller 1 */ + <0x00025000 &gic GIC_SPI 148 IRQ_TYPE_LEVEL_HIGH>; + + pcie@12000 { + interrupt-parent = <&gic>; + reg = <0x00012000 0x1000>; + interrupts = , + , + , + , + , + ; + }; }; diff --git a/drivers/bcma/main.c b/drivers/bcma/main.c index d1656c2..870f01d 100644 --- a/drivers/bcma/main.c +++ b/drivers/bcma/main.c @@ -11,6 +11,7 @@ #include #include #include +#include MODULE_DESCRIPTION("Broadcom's specific AMBA driver"); MODULE_LICENSE("GPL"); @@ -153,6 +154,45 @@ static struct device_node *bcma_of_find_child_device(struct platform_device *par return NULL; } +static int bcma_of_irq_parse(struct platform_device *parent, + struct bcma_device *core, + struct of_phandle_args *out_irq) +{ + __be32 laddr[1]; + int rc; + + if (core->dev.of_node) { + rc = of_irq_parse_one(core->dev.of_node, 0, out_irq); + if (!rc) + return rc; + } + + out_irq->np = parent->dev.of_node; + out_irq->args_count = 0; + + laddr[0] = cpu_to_be32(core->addr); + return of_irq_parse_raw(laddr, out_irq); +} + +static int bcma_of_get_irq(struct platform_device *parent, + struct bcma_device *core) +{ + struct of_phandle_args out_irq; + int ret; + + if (!parent || !parent->dev.of_node) + return 0; + + ret = bcma_of_irq_parse(parent, core, &out_irq); + if (ret) { + bcma_debug(core->bus, "bcma_of_get_irq() failed with rc=%d\n", + ret); + return 0; + } + + return irq_create_of_mapping(&out_irq); +} + static void bcma_of_fill_device(struct platform_device *parent, struct bcma_device *core) { @@ -161,6 +201,8 @@ static void bcma_of_fill_device(struct platform_device *parent, node = bcma_of_find_child_device(parent, core); if (node) core->dev.of_node = node; + + core->irq = bcma_of_get_irq(parent, core); } #else static void bcma_of_fill_device(struct platform_device *parent,