From patchwork Mon Apr 1 20:05:00 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: 2372691 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 651153FDDA for ; Mon, 1 Apr 2013 20:07:54 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UMkyx-0003Rp-H7; Mon, 01 Apr 2013 20:05:31 +0000 Received: from mail-vc0-f173.google.com ([209.85.220.173]) by merlin.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UMkyu-0003R5-RT for linux-arm-kernel@lists.infradead.org; Mon, 01 Apr 2013 20:05:29 +0000 Received: by mail-vc0-f173.google.com with SMTP id gd11so2783456vcb.32 for ; Mon, 01 Apr 2013 13:05:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:mime-version:in-reply-to:references:from:date:message-id :subject:to:cc:content-type; bh=AeZLZTQEUt2ru9s4bTaFWmDKdcccdQnPDPLwCaikS8M=; b=enHqf7HGmXEvaUB6wTSpBRHpyRcxt848rRzZYBF1D7wCpsvATEnW3Dv6nKvxwwgClX wWXAa1v0mDRJlWjB4aUSsIbCpBxvxDHw7JFAT6WjmglZ+m25lWeXf/EOkBrAc/TRkAwU Bo1epQwwvHjMKvcKHMVBa72QiQ4U8yj0cXXNem/kyCZPDXtdOj2R6As4WxND/bCXW33N F4vv2iBg6c5b5ZPi3iDAmyc570wyTKF/HSWNcN/uqPls6tDIhsW32LAyPiPB3GawJBj9 jEcmWEBOaDNgdekiwKdfu3OB7BeqOtN2QVWMvyscPMBwwWIc3qzzClElcXTrys48QDnq YdHQ== X-Received: by 10.52.20.177 with SMTP id o17mr9140180vde.17.1364846725357; Mon, 01 Apr 2013 13:05:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.58.29.44 with HTTP; Mon, 1 Apr 2013 13:05:00 -0700 (PDT) In-Reply-To: <1364834508.3939.74.camel@mars> References: <1364631689.3767.7.camel@mars> <1364834508.3939.74.camel@mars> From: Javier Martinez Canillas Date: Mon, 1 Apr 2013 22:05:00 +0200 Message-ID: Subject: Re: [RFC][BUG] arm/dts: OMAP3: set #interrupt-cells to two To: Christoph Fritz X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130401_160528_958036_0AE086E3 X-CRM114-Status: GOOD ( 29.32 ) X-Spam-Score: -2.7 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.7 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [209.85.220.173 listed in list.dnswl.org] 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider (martinez.javier[at]gmail.com) -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature Cc: Kevin Hilman , Paul Walmsley , Russell King , =?UTF-8?Q?Beno=C3=AEt_Cousson?= , Tony Lindgren , "devicetree-discuss@lists.ozlabs.org" , Rajendra Nayak , "Hans J. Koch" , Santosh Shilimkar , Daniel Mack , "linux-omap@vger.kernel.org" , "linux-arm-kernel@lists.infradead.org" , Jon Hunter X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org On Mon, Apr 1, 2013 at 6:41 PM, Christoph Fritz wrote: > Hi Javier > > On Sat, 2013-03-30 at 14:18 +0100, Javier Martinez Canillas wrote: >> A call to gpio_request() to enable the GPIO bank is needed before >> using a GPIO as an IRQ source, otherwise accesses to the GPIO bank >> registers fails making the kernel to hang. > > Yes, that is exactly my problem here. I'm using the GPIO as an IRQ > source. > >> Jon's (added as cc)"gpio/omap: warn if bank is not enabled on setting >> irq type" patch [1] fixes the issue by warning and returning -EINVAL. >> >> This patch will make the kernel to boot but the call to request_irq() >> will fail of course. For now, the only solution is to call >> gpio_request() before request_irq() in your platform code or device >> driver. There is an on going discussion about what's the better way to >> address this but we still haven't found a good solution to this >> problem, you can see the last email for this discussion here [2] >> >> Also, even when calling gpio_request() before request_irq() this won't >> work. When specifying the trigger/level flags on the second cell for >> an GPIO-IRQ, this is not set on the IORESOURCE_IRQ struct resource. >> The IRQ flag is set on of_irq_to_resource() but it just does: >> >> r->flags = IORESOURCE_IRQ; >> >> and then the call stack is irq_to_parse_and_map() -> >> irq_set_irq_type() -> __irq_set_trigger() -> chip->irq_set_type() -> >> (drivers/gpio/gpio-omap.c) gpio_irq_type(). >> >> So, even when gpio_irq_type() receive the correct flags, this are not >> returned neither stored on the flags member of the IORESOURCE_IRQ >> struct resource that passed to the drivers in their struct >> platform_device. > > As a quick-fix (hack) I wrote directly to the registers in gpio_probe() > to enable GPIO banks. I now geht this: > >> > [ 0.214630] omap_gpio_probe, 1133, CM_CLKSEL_PER 0x48005040: 0x000000ff >> > [ 0.214660] omap_gpio_probe, 1136, CM_ICLKEN_PER 0x48005010: 0x0007ffff >> > [ 0.214660] omap_gpio_probe, 1139, CM_FCLKEN_PER 0x48005000: 0x0007ffff > > And it works for me. _But_ when I do enable regulator twl4030 > (CONFIG_REGULATOR_TWL4030=y) in my config these registers get reset: > > [ 2.935455] smsc911x_open, 1537, CM_CLKSEL_PER 0x48005040: 0x000000ff > [ 2.942291] smsc911x_open, 1540, CM_ICLKEN_PER 0x48005010: 0x00040fff > [ 2.949066] smsc911x_open, 1543, CM_FCLKEN_PER 0x48005000: 0x00000000 > > And the IRQ source for the network chip (smsc911x) is disabled :-( > > Do you have any idea how to ("quick") fix this? > A quick hack is to call gpio_request() explicitly before calling to irq_set_type() is made. I've this patch just to make it work until we find a clean solution: > -- Christoph > I hope to find some time this week to work on this and at least find a solution for the second issue (IORESOURCE_IRQ struct resource flags not being set). Best regards, Javier diff --git a/arch/arm/mach-omap2/gpmc.c b/arch/arm/mach-omap2/gpmc.c index 90c15ee..d594e1d 100644 --- a/arch/arm/mach-omap2/gpmc.c +++ b/arch/arm/mach-omap2/gpmc.c @@ -14,6 +14,7 @@ */ #undef DEBUG +#include #include #include #include @@ -1528,6 +1529,11 @@ static int gpmc_probe_dt(struct platform_device *pdev) return ret; } + ret = gpio_request_one(176, GPIOF_IN, "smsc911x irq"); + if (ret) { + pr_err("Failed to request IRQ GPIO%d\n", 176); + return ret; + } + for_each_node_by_name(child, "nand") { ret = gpmc_probe_nand_child(pdev, child); if (ret < 0) { This solves the issue of the non-initialized GPIO bank before that makes the kernel to hang. Since I've to configure the IRQ polarity as active low level-sensitive on my board and the flags are not set by the IRQ core, I've another ugly hack that forces this: diff --git a/drivers/net/ethernet/smsc/smsc911x.c b/drivers/net/ethernet/smsc/smsc index da5cc9a..27e46f9 100644 --- a/drivers/net/ethernet/smsc/smsc911x.c +++ b/drivers/net/ethernet/smsc/smsc911x.c @@ -2390,6 +2390,9 @@ static int smsc911x_drv_probe(struct platform_device *pdev) pdata = netdev_priv(dev); dev->irq = irq_res->start; - irq_flags = irq_res->flags & IRQF_TRIGGER_MASK; + irq_flags = IRQF_TRIGGER_LOW; pdata->ioaddr = ioremap_nocache(res->start, res_size); pdata->dev = dev; > Thanks