From: Lina Iyer Subject: [PATCH v5 02/11] gpio: allow gpio_to_irq to use OF variants for gpiochips Date: Tue, 7 May 2019 14:37:40 -0600 Message-ID: <20190507203749.3384-3-ilina@codeaurora.org> References: <20190507203749.3384-1-ilina@codeaurora.org> Mime-Version: 1.0 Content-Transfer-Encoding: 8bit Return-path: In-Reply-To: <20190507203749.3384-1-ilina@codeaurora.org> Sender: linux-kernel-owner@vger.kernel.org To: swboyd@chromium.org, evgreen@chromium.org, marc.zyngier@arm.com, linus.walleij@linaro.org Cc: linux-kernel@vger.kernel.org, rplsssn@codeaurora.org, linux-arm-msm@vger.kernel.org, thierry.reding@gmail.com, bjorn.andersson@linaro.org, dianders@chromium.org, Lina Iyer List-Id: linux-arm-msm@vger.kernel.org The chip may define additional information in the DT that may be useful for translating and allocting a linux interrupt for the GPIO. When drivers do not specify a .to_irq function, the gpiolib defaults to gpiochip_to_irq() function. The defalt function uses creates an IRQ without referencing the OF definition of the gpiochip. Let's add this OF support to the default gpiochip_to_irq function. When requesting an interrupt for the GPIO, let's stick to IRQ_TYPE_NONE for the trigger type, for we don't have the information what trigger type the driver may set when requesting the IRQ. Signed-off-by: Lina Iyer --- drivers/gpio/gpiolib.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c index 4a9a6d4afe6e..77317435e2b2 100644 --- a/drivers/gpio/gpiolib.c +++ b/drivers/gpio/gpiolib.c @@ -1825,6 +1825,19 @@ EXPORT_SYMBOL_GPL(gpiochip_irq_domain_deactivate); static int gpiochip_to_irq(struct gpio_chip *chip, unsigned offset) { +#ifdef CONFIG_OF_GPIO + struct irq_fwspec fwspec; + + if (chip->of_node) { + fwspec.fwnode = of_node_to_fwnode(chip->of_node); + fwspec.param[0] = offset; + fwspec.param[1] = IRQ_TYPE_NONE; + fwspec.param_count = 2; + + return irq_create_fwspec_mapping(&fwspec); + } +#endif + if (!gpiochip_irqchip_irq_valid(chip, offset)) return -ENXIO; -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project