From patchwork Fri Oct 26 19:57:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Fabrizio Castro X-Patchwork-Id: 10657791 X-Patchwork-Delegate: geert@linux-m68k.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5E6B213B5 for ; Fri, 26 Oct 2018 19:57:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 515802CC7E for ; Fri, 26 Oct 2018 19:57:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 459362CC83; Fri, 26 Oct 2018 19:57:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CC9F2CC7E for ; Fri, 26 Oct 2018 19:57:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728000AbeJ0Ef6 (ORCPT ); Sat, 27 Oct 2018 00:35:58 -0400 Received: from relmlor3.renesas.com ([210.160.252.173]:60780 "EHLO relmlie2.idc.renesas.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725965AbeJ0Ef6 (ORCPT ); Sat, 27 Oct 2018 00:35:58 -0400 Received: from unknown (HELO relmlir3.idc.renesas.com) ([10.200.68.153]) by relmlie2.idc.renesas.com with ESMTP; 27 Oct 2018 04:57:36 +0900 Received: from relmlii1.idc.renesas.com (relmlii1.idc.renesas.com [10.200.68.65]) by relmlir3.idc.renesas.com (Postfix) with ESMTP id 19062518FA; Sat, 27 Oct 2018 04:57:36 +0900 (JST) X-IronPort-AV: E=Sophos;i="5.54,429,1534777200"; d="scan'208";a="294548652" Received: from unknown (HELO fabrizio-dev.ree.adwin.renesas.com) ([10.226.36.250]) by relmlii1.idc.renesas.com with ESMTP; 27 Oct 2018 04:57:33 +0900 From: Fabrizio Castro To: Linus Walleij , Geert Uytterhoeven , Simon Horman Cc: Fabrizio Castro , linux-gpio@vger.kernel.org, Chris Paterson , Biju Das , linux-renesas-soc@vger.kernel.org Subject: [RFC] gpio: rcar: Request GPIO before enabling interrupt Date: Fri, 26 Oct 2018 20:57:30 +0100 Message-Id: <1540583850-30825-1-git-send-email-fabrizio.castro@bp.renesas.com> X-Mailer: git-send-email 2.7.4 Sender: linux-renesas-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP There are cases when the bootloader configures a pin to work as a function rather than GPIO, and other cases when the pin is configured as a function at POR. This commit makes sure the pin is configured as a GPIO the moment we need it to work as an interrupt. Signed-off-by: Fabrizio Castro --- Dear All, we have got some issues while trying to bring up the interrupt line of the HDMI transmitter on the iwg23s, as GP2_29 is configured as a function when the kernel starts, and therefore setting up the interrupt from the driver won't have the desired effect. This patch makes sure the pinctrl driver sets GP2[29] to GP-2-29 before enabling the interrupt, but it doesn't addresses the "direction problem", as in the pin will be a GPIO after calling gc->request, but the direction would be whatever was previously configured. There could be the option of moving the additional code added by this patch to the bottom of function gpio_rcar_irq_set_type, but is that going to behave properly on every SoC this driver is supporting? Is configuring every gpio with direction input while probing something that should be looked into to reduce concerns over switching from function to GPIO? Comments very welcome! Thanks, Fab drivers/gpio/gpio-rcar.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/gpio/gpio-rcar.c b/drivers/gpio/gpio-rcar.c index 3c82bb3..8c69431 100644 --- a/drivers/gpio/gpio-rcar.c +++ b/drivers/gpio/gpio-rcar.c @@ -147,6 +147,14 @@ static int gpio_rcar_irq_set_type(struct irq_data *d, unsigned int type) struct gpio_chip *gc = irq_data_get_irq_chip_data(d); struct gpio_rcar_priv *p = gpiochip_get_data(gc); unsigned int hwirq = irqd_to_hwirq(d); + int err; + + err = gc->request(gc, hwirq); + if (err) { + dev_err(&p->pdev->dev, "Can't request GPIO %d from %s\n", hwirq, + gc->label); + return err; + } dev_dbg(&p->pdev->dev, "sense irq = %d, type = %d\n", hwirq, type);