Message ID | 20180907102053.3221-1-hverkuil@xs4all.nl |
---|---|
Headers | show
Return-Path: <linux-gpio-owner@vger.kernel.org> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=vger.kernel.org (client-ip=209.132.180.67; helo=vger.kernel.org; envelope-from=linux-gpio-owner@vger.kernel.org; receiver=<UNKNOWN>) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=xs4all.nl Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by ozlabs.org (Postfix) with ESMTP id 426D3w0bGTz9s3x for <incoming@patchwork.ozlabs.org>; Fri, 7 Sep 2018 20:21:00 +1000 (AEST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728397AbeIGPBP (ORCPT <rfc822;incoming@patchwork.ozlabs.org>); Fri, 7 Sep 2018 11:01:15 -0400 Received: from lb1-smtp-cloud7.xs4all.net ([194.109.24.24]:36207 "EHLO lb1-smtp-cloud7.xs4all.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727975AbeIGPBP (ORCPT <rfc822; linux-gpio@vger.kernel.org>); Fri, 7 Sep 2018 11:01:15 -0400 Received: from tschai.fritz.box ([212.251.195.8]) by smtp-cloud7.xs4all.net with ESMTPA id yDsjfhvc2w2L8yDsmfCuX8; Fri, 07 Sep 2018 12:20:56 +0200 From: Hans Verkuil <hverkuil@xs4all.nl> To: linux-gpio@vger.kernel.org Cc: Linus Walleij <linus.walleij@linaro.org>, ilina@codeaurora.org, Marc Zyngier <marc.zyngier@arm.com>, Thomas Gleixner <tglx@linutronix.de> Subject: [PATCH 0/6] gpiolib: track irq enabled/disabled state Date: Fri, 7 Sep 2018 12:20:47 +0200 Message-Id: <20180907102053.3221-1-hverkuil@xs4all.nl> X-Mailer: git-send-email 2.18.0 X-CMAE-Envelope: MS4wfFue20KSDt2ev876ZmOSxCrAamLmEv+RZhRXYmafaDm6q8zDthf+S42LpitcPvGIj7LitjbdqjYdaPEE/fzfrNd0tIdwrbqRoIqcZTlpHo3iNzNwQRs2 e9/rmFCYS3Gw6pUweS/ZR5a4IFJpnugsGV34L9APMyplEqr0Qy2bSCkr7uFs9njK/3S+d3pEZPxgW6RFffXmViyubp7SOhTf52HVUMk3qrUM09FCiVyGUAOz NvM+tvUOqY2jZaJT1IPVBahHVJIAcx7bU6yNF/Nzt55aO8inCtsLhy8qqXbgAn4sKqMkU37WbVs5495pj2DUCQ== Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: <linux-gpio.vger.kernel.org> X-Mailing-List: linux-gpio@vger.kernel.org |
Series |
gpiolib: track irq enabled/disabled state
|
expand
|
From: Hans Verkuil <hans.verkuil@cisco.com> Hi all, This patch series is based on my RFCv3 patch series: https://www.spinics.net/lists/linux-gpio/msg32168.html The goal is to allow drivers to disable the irq and drive the gpio as an output. Please be gentle with me: I am neither an expert on the gpio internals, nor on the irq internals. The first two patches improve the handling of the irq callbacks irq_request/release_resources(). While drivers often call gpiochip_lock_as_irq() as needed, none called try_module_get(chip->gpiodev->owner) as gpiolib does. To simplify those drivers the first patch adds gpiochip_reqres_irq and gpiochip_relres_irq functions that such drivers can call instead of gpiochip_lock_as_irq() to ensure this happens. The second patch changes the behavior of gpiolib when the irqchip helpers are used: currently gpiolib just overrides any existing irq_chip irq_request/release_resources(), and this patch will remember the original callback and call it. This required changes to two drivers that would otherwise go into an infinite loop. The third patch adds a new flag to remember if the irq is enabled or not, and allows the direction to be changed to output unless both FLAG_USED_AS_IRQ and FLAG_IRQ_IS_ENABLED are set. The fourth patch overrides the irq_disable and irq_enable hooks when using the irqchip helpers so gpiolib will know when the irq is enabled/disabled. Drivers that do not use these helpers will have to call this themselves, and the fifth patch converts one such driver. Drivers that do not use the helpers will need to be updated over time so they call gpiochip_en/disable_irq and gpiochip_reqres/relres_irq, but that can be done one by one. The final patch documents the new gpiochip_en/disable_irq functions. Note: I have not documented gpiochip_reqres/relres_irq yet. I was wondering if gpiochip_reqres/relres_irq() shouldn't completely replace gpiochip_(un)lock_as_irq(). It really does the same, except that reqres/relres also gets/puts the module. So before documenting this I'd like to know what others want. Unfortunately, I could only compile-test this patch series since I don't have access to my BeagleBone Black board for the next two weeks. Linus, as far as I can tell the pinctrl-intel.c and pinctrl-st.c drivers are the only two that override irq_request/release_resources() AND use the gliolib irqchip helpers. If I missed any, please let me know. Regards, Hans Hans Verkuil (6): gpiolib: export gpiochip_irq_reqres/relres() gpiolib: override irq_request/release_resources hooks gpiolib: add flag to indicate if the irq is disabled gpiolib: override irq_enable/disable gpio-bcm-kona: use new req/relres and dis/enable_irq funcs gpio/driver.rst: document gpiochip_disable/enable_irq() Documentation/driver-api/gpio/driver.rst | 23 +++- drivers/gpio/gpio-bcm-kona.c | 14 +- drivers/gpio/gpiolib.c | 162 +++++++++++++++++------ drivers/gpio/gpiolib.h | 1 + drivers/pinctrl/intel/pinctrl-intel.c | 32 ----- drivers/pinctrl/pinctrl-st.c | 11 +- include/linux/gpio/driver.h | 32 +++++ 7 files changed, 179 insertions(+), 96 deletions(-)