Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753298Ab1DUNp2 (ORCPT ); Thu, 21 Apr 2011 09:45:28 -0400 Received: from mail-pw0-f46.google.com ([209.85.160.46]:64397 "EHLO mail-pw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750981Ab1DUNp1 (ORCPT ); Thu, 21 Apr 2011 09:45:27 -0400 Date: Thu, 21 Apr 2011 07:45:24 -0600 From: Grant Likely To: Lars-Peter Clausen Cc: Tomoya MORINAGA , linux-kernel@vger.kernel.org, toshiharu-linux@dsn.okisemi.com Subject: Re: Question: GPIO driver how to get irq_base Message-ID: <20110421134524.GA32725@ponder.secretlab.ca> References: <4DAFE62A.105@metafoo.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4DAFE62A.105@metafoo.de> User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1818 Lines: 48 On Thu, Apr 21, 2011 at 10:09:14AM +0200, Lars-Peter Clausen wrote: > On 04/21/2011 09:32 AM, Tomoya MORINAGA wrote: > > Hi GPIO maintainer, > > > > Need your help. > > I want to add interrupt function to gpio/pch_gpio.c > > > > According to other upstreamed GPIO driver, (e.g. pl061, langwell, etc...) > > 2 IRQs(irq, irq_base) are used. irq and irq_base are two different things. irq is the irq number that the gpio expander is wired up to. irq_base is the starting range for any irqs generated by the gpio expender. Essentially, turning the gpio controller into an irq controller. > > > > I can get "irq" from (struct pci_dev *)pdev->irq. > > However I can't understand where can I get the "irq_base". > > Let me know how to get. > > > > Thanks, > > ----------------------------------------- > > Tomoya MORINAGA > > OKI SEMICONDUCTOR CO., LTD. > > In my opinion the best option for expander chips is to allocate a new irq_desc > range by calling irq_alloc_descs. It will return the first irq number in the > newly allocated range, which will be your irq_base. Yes, irq_alloc_descs() will give you a range of irqs that the gpio expander can use. In many drivers, the irq_base is hard coded in the board file and passed in via pdata, but as much as possible I recommend avoiding that and letting Linux dynamically allocate the irq_base for you. Setting gpio_base to -1 will do this. The ->to_irq() hook in your driver can translate from a gpio number to an irq number for a specific gpio. > But be aware that this will require SPARSE_IRQ to work. Why? g. -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/