From: Gilles Chanteperdrix <gilles.chanteperdrix@xenomai.org>
To: Chris Stone <chris.stone@optelian.com>
Cc: "xenomai@xenomai.org" <xenomai@xenomai.org>
Subject: Re: [Xenomai] GPIO irq handler on powerpc.
Date: Fri, 08 Jun 2012 09:15:21 +0200 [thread overview]
Message-ID: <4FD1A689.8050107@xenomai.org> (raw)
In-Reply-To: <623784B6C75D274389918D358E89E8BB0B7FF136@OPTELIAN5.optelian.local>
On 06/07/2012 11:16 PM, Chris Stone wrote:
> I am using Xenomai 2.6.0 on kernel 3.0.13, with adeos-ipipe-3.0.13-powerpc-2.13-06 applied. My target CPU
> is Freescale MPC8378.
>
> On a powerpc, GPIO's are mapped to virtual irqs. Thus, in order to install an irq handler for a gpio
> interrupt, one must do the following in the kernel:
>
> err = gpio_request(HYPHY_IRQ_GPIO, NULL);
> if (err<0) {
> printk(KERN_ERR "%s: could not request gpio %d, rc %d\n", __func__, HYPHY_IRQ_GPIO, err);
> return err;
> }
> err = gpio_direction_input(HYPHY_IRQ_GPIO);
> if (err<0) {
> printk(KERN_ERR "%s: could not set gpio %d to input, rc %d\n", __func__, HYPHY_IRQ_GPIO, err);
> return err;
> }
>
> virq = __gpio_to_irq(HYPHY_IRQ_GPIO);
> if (virq < 0) {
> printk(KERN_ERR "%s: could not map gpio %d to virq \n", __func__, HYPHY_IRQ_GPIO);
> return virq;
> }
> err = request_irq(virq, hyphy20G_irq, 0, hyphy20G_dev.name, &hyphy20G_dev);
>
> In other words, you install the irq handler on the virtual irq number returned from __gpio_to_irq. The above
> code works in my system, i.e., the hyphy20G_irq handler is called on an interrupt.
>
> However, if I use:
>
> err = rt_intr_create(intrObj, "HyPhyIRQ", virq, hyphy20G_irq, NULL, 0);
> rt_intr_enable(intrObj);
>
> then the hyphy20G_irq handler is not called on an interrupt.
This is a bug.
> I realize that interrupt handlers are
> recommended to be implemented in user space, but a user space implementation does not work either,
Definitely not. Interrupts handlers in user-space are not recommended.
At all.
> so I moved into the kernel to see if I could get something to work.
>
> Is it possible to install an Xenomai ISR on a powerpc virtual irq?
Normally it should be. If the GPIO interrupts are multiplexed (several
GPIOs on the same parent irq), you should look for the parent irq
handler and see that:
- its code is safe to be called from xenomai domain
- it calls ipipe_handle_chained_irq for the individual demultiplexed
gpio interrupts instead of generic_handle_irq
Note that a bug in multiplexed GPIO interrupts has been fixed very
recently. You may want to upgrade to the I-pipe core for linux 3.2,
currently only available as a git repository:
git://git.denx.de/ipipe.git branch core-3.2
Which also requires xenomai sources from the git repository:
git://git.xenomai.org/xenomai-2.6.git branch master
--
Gilles.
next prev parent reply other threads:[~2012-06-08 7:15 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-06-07 21:16 [Xenomai] GPIO irq handler on powerpc Chris Stone
2012-06-08 7:15 ` Gilles Chanteperdrix [this message]
2012-06-08 14:50 ` Chris Stone
2012-06-08 15:14 ` Philippe Gerum
2012-06-08 15:18 ` Chris Stone
2012-06-08 15:22 ` Philippe Gerum
2012-06-08 15:00 ` Chris Stone
2012-06-08 7:31 ` Philippe Gerum
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=4FD1A689.8050107@xenomai.org \
--to=gilles.chanteperdrix@xenomai.org \
--cc=chris.stone@optelian.com \
--cc=xenomai@xenomai.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.