linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Linus Walleij <linus.walleij@linaro.org>
To: Dmitry Torokhov <dmitry.torokhov@gmail.com>,
	Hans Verkuil <hans.verkuil@cisco.com>
Cc: BOUGH CHEN <haibo.chen@nxp.com>,
	Andy Shevchenko <andy@kernel.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	"linux-input@vger.kernel.org" <linux-input@vger.kernel.org>,
	dl-linux-imx <linux-imx@nxp.com>
Subject: Re: [PATCH 2/2] input: egalax_ts: free irq resource before request the line as GPIO
Date: Tue, 28 Apr 2020 13:21:08 +0200	[thread overview]
Message-ID: <CACRpkdaCe5WnYqiCDK-CdAn2fbdRLM4Yh=Mnu=b7mR+3Krq17g@mail.gmail.com> (raw)
In-Reply-To: <20200419181000.GL166864@dtor-ws>

On Sun, Apr 19, 2020 at 8:10 PM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
> On Tue, Mar 10, 2020 at 07:15:35AM +0000, BOUGH CHEN wrote:
> >
> > > From: Dmitry Torokhov <dmitry.torokhov@gmail.com>
> > > Sent: 2020年3月10日 12:27
> > > To: BOUGH CHEN <haibo.chen@nxp.com>
> > > Cc: linux-input@vger.kernel.org; dl-linux-imx <linux-imx@nxp.com>
> > > Subject: Re: [PATCH 2/2] input: egalax_ts: free irq resource before request
> > > the line as GPIO
> > >
> > > On Tue, Feb 11, 2020 at 04:41:12PM +0800, haibo.chen@nxp.com wrote:
> > > > From: Haibo Chen <haibo.chen@nxp.com>
> > > >
> > > > + egalax_free_irq(ts);
> > >
> > > It sounds to me you want simply disable interrupts in suspend. Does not
> > > calling disable_irq() here suffice?
> >
>
> > Here why I want to disable interrupts here is because in the newest
> > gpio system, if the gpio is request as an irq, it can't be request as
> > a gpio anymore.  In the function egalax_wake_up_device(), we need to
> > request the irq pin as a gpio for a while, generate a signal to wake
> > up the device. So before request the pad as gpio, need first free irq
> > resource.
>
> This seems like a fairly common pattern and I wonder if our GPIO
> overlords can help us here.
>
> Linus, Mika, Andy, would it be possible to have an API that would allow
> driver to temporarily "take over" GPIO that is used for interrupts and
> drive it as output without resorting to freeing and re-acquiring irq?
> I.e. something like gpiod_irq_drive_output_start() and
> gpiod_irq_drive_output_end()?

Hans Verkuil had exactly this problem in the CEC GPIO driver,
drivers/media/platform/cec-gpio/cec-gpio.c

If you call disable_irq() on an irqchip implemented in a GPIO
driver using the generic GPIOLIB_IRQCHIP helper library (which
I really recommend) then the line can be switched to output,
used like such, then switched to input and enable_irq() be
called again.

See these commits:
commit 4e9439ddacea06f35acce4d374bf6bd0acf99bc8
"gpiolib: add flag to indicate if the irq is disabled"
commit 461c1a7d4733d1dfd5c47b040cf32a5e7eefbc6c
"gpiolib: override irq_enable/disable"

If your corresponding GPIO driver does not use GPIOLIB_IRQCHIP
then you have a bigger problem and we need to look into that.

Yours,
Linus Walleij

  parent reply	other threads:[~2020-04-28 11:21 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-11  8:41 [PATCH 1/2] input: egalax_ts: switch to i2c interface before wake up haibo.chen
2020-02-11  8:41 ` [PATCH 2/2] input: egalax_ts: free irq resource before request the line as GPIO haibo.chen
2020-03-10  4:26   ` Dmitry Torokhov
2020-03-10  7:15     ` BOUGH CHEN
2020-04-19 18:10       ` Dmitry Torokhov
2020-04-19 21:27         ` Andy Shevchenko
2020-04-28 11:21         ` Linus Walleij [this message]
2020-03-10  1:58 ` [PATCH 1/2] input: egalax_ts: switch to i2c interface before wake up BOUGH CHEN
2020-03-10  4:22 ` Dmitry Torokhov
2020-03-10  7:01   ` BOUGH CHEN

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACRpkdaCe5WnYqiCDK-CdAn2fbdRLM4Yh=Mnu=b7mR+3Krq17g@mail.gmail.com' \
    --to=linus.walleij@linaro.org \
    --cc=andy@kernel.org \
    --cc=dmitry.torokhov@gmail.com \
    --cc=haibo.chen@nxp.com \
    --cc=hans.verkuil@cisco.com \
    --cc=linux-imx@nxp.com \
    --cc=linux-input@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).