linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: u.kleine-koenig@pengutronix.de (Uwe Kleine-König)
To: linux-arm-kernel@lists.infradead.org
Subject: triggering an gpio-irq on both edges
Date: Thu, 13 Sep 2012 10:19:20 +0200	[thread overview]
Message-ID: <20120913081920.GF19497@pengutronix.de> (raw)

Hello,

My motivation for this mail is that currently mxs_gpio_set_irq_type
doesn't support type=IRQ_TYPE_EDGE_RISING|IRQ_TYPE_EDGE_FALLING because
the hardware doesn't support it.

The gpio-keys driver on the other hand wants a trigger in both
directions.

The mxc-gpio driver implements the missing hardware functionallity in
software (gpio_set_irq_type):

	set_irq_type:
		if (both edges requested)
			if (current value of gpio == 0)
				trigger on rising edge
			else
				trigger on falling edge

	handle_irq:
		if (both edges requested)
			trigger on other edge


This is racy though: If there is an edge after reading out the gpio
value and completion of the edge direction programming, you miss
interrupts. Also just switching the direction in the irq handler is
also wrong for the same reason.

I guess there are more machines than mxc and mxs that have the same
problem.

In my opinion this calls for a wrapper, something like:

	int gpio_irq_emulate_both_edges_set_irq_type(struct irq_data *d,
		unsigned int type, int (*set_irq_type)(...),
		int (*get_value)(...), struct something *privdata)
	{
		...
	}

	int gpio_irq_emulate_both_edges_handler(...)
	{

	}

Does this sound good and possible? I didn't find something like that
already implemented, but maybe I missed it?

Any thoughts (and be it only "The xyz driver is affected, too.") are
welcome.

Best regards
Uwe

-- 
Pengutronix e.K.                           | Uwe Kleine-K?nig            |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |

             reply	other threads:[~2012-09-13  8:19 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-13  8:19 Uwe Kleine-König [this message]
2012-09-13 10:24 ` triggering an gpio-irq on both edges Philipp Zabel
2012-09-16 22:09 ` Linus Walleij

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=20120913081920.GF19497@pengutronix.de \
    --to=u.kleine-koenig@pengutronix.de \
    --cc=linux-arm-kernel@lists.infradead.org \
    /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).