linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* Question on setting up external interrupt for P1020 (MPC8xxx) with device tree
@ 2011-02-11 19:07 Kenny Ho
  2011-02-11 21:56 ` Scott Wood
  0 siblings, 1 reply; 4+ messages in thread
From: Kenny Ho @ 2011-02-11 19:07 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 651 bytes --]

Hi,

 

I am trying to write a device driver that uses an external interrupt
(one of the 16 irq lines) for the Freescale P1020 processor and I hope
some of you can help.  Am I suppose to setup a separate node in the dts
and look for that node in my driver to setup the interrupt?  Or does the
dts interrupt declaration belong to the interrupt-controller
declaration?  I noticed the mpc8xxx_gpio driver defined its own irq_chip
but I thought that may be because each gpio pin can trigger an
interrupt.  Do I need to define my own irq_chip structure for my device
even if I am using one of the hard irq lines?  

 

Regards,

Kenny


[-- Attachment #2: Type: text/html, Size: 2555 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on setting up external interrupt for P1020 (MPC8xxx) with device tree
  2011-02-11 19:07 Question on setting up external interrupt for P1020 (MPC8xxx) with device tree Kenny Ho
@ 2011-02-11 21:56 ` Scott Wood
  2011-02-11 22:15   ` Kenny Ho
  0 siblings, 1 reply; 4+ messages in thread
From: Scott Wood @ 2011-02-11 21:56 UTC (permalink / raw)
  To: Kenny Ho; +Cc: linuxppc-dev

On Fri, 11 Feb 2011 14:07:26 -0500
Kenny Ho <kho@belairnetworks.com> wrote:

> Hi,
> 
>  
> 
> I am trying to write a device driver that uses an external interrupt
> (one of the 16 irq lines) for the Freescale P1020 processor and I hope
> some of you can help.  Am I suppose to setup a separate node in the dts
> and look for that node in my driver to setup the interrupt? 

Ideally, yes.  It's good to describe your device with a node even if it
doesn't have interrupts.

> Or does the > dts interrupt declaration belong to the interrupt-controller
> declaration?  I noticed the mpc8xxx_gpio driver defined its own irq_chip
> but I thought that may be because each gpio pin can trigger an
> interrupt.

Right, it's because gpio is an interrupt controller, not just a user of one.

> Do I need to define my own irq_chip structure for my device
> even if I am using one of the hard irq lines?  

No.  If the device's node describes the interrupt correctly, you can use
irq_of_parse_and_map() on the device node to get a virtual irq that you can
pass to request_irq().

-Scott

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Question on setting up external interrupt for P1020 (MPC8xxx) with device tree
  2011-02-11 21:56 ` Scott Wood
@ 2011-02-11 22:15   ` Kenny Ho
  2011-02-11 22:19     ` Scott Wood
  0 siblings, 1 reply; 4+ messages in thread
From: Kenny Ho @ 2011-02-11 22:15 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

Thanks Scott.

Do you know the logic of the hwirq <-> virq mapping?  When I was digging
into the GPIO interrupt, the hwirq seems to be the same as the virq
(both are 47 which is 16 (external interrupt) + 31 (internal interrupt).
If I want to use external interrupt 7 and 8, should the virq also be 7
and 8?  For some reason I am getting 41 for virq... may be I am still
doing something wrong.

This is the node definition I created:
rpcl {
	compatible =3D "ba,rpcl";
	interrupts =3D <0x7 2 0x8 2>;
	interrupt-parent =3D <&mpic>;
};

Kenny

-----Original Message-----
From: Scott Wood [mailto:scottwood@freescale.com]=20
Sent: Friday, February 11, 2011 4:57 PM
To: Kenny Ho
Cc: linuxppc-dev@lists.ozlabs.org
Subject: Re: Question on setting up external interrupt for P1020
(MPC8xxx) with device tree

On Fri, 11 Feb 2011 14:07:26 -0500
Kenny Ho <kho@belairnetworks.com> wrote:

> Hi,
>=20
> =20
>=20
> I am trying to write a device driver that uses an external interrupt
> (one of the 16 irq lines) for the Freescale P1020 processor and I hope
> some of you can help.  Am I suppose to setup a separate node in the
dts
> and look for that node in my driver to setup the interrupt?=20

Ideally, yes.  It's good to describe your device with a node even if it
doesn't have interrupts.

> Or does the > dts interrupt declaration belong to the
interrupt-controller
> declaration?  I noticed the mpc8xxx_gpio driver defined its own
irq_chip
> but I thought that may be because each gpio pin can trigger an
> interrupt.

Right, it's because gpio is an interrupt controller, not just a user of
one.

> Do I need to define my own irq_chip structure for my device
> even if I am using one of the hard irq lines? =20

No.  If the device's node describes the interrupt correctly, you can use
irq_of_parse_and_map() on the device node to get a virtual irq that you
can
pass to request_irq().

-Scott

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Question on setting up external interrupt for P1020 (MPC8xxx) with device tree
  2011-02-11 22:15   ` Kenny Ho
@ 2011-02-11 22:19     ` Scott Wood
  0 siblings, 0 replies; 4+ messages in thread
From: Scott Wood @ 2011-02-11 22:19 UTC (permalink / raw)
  To: Kenny Ho; +Cc: linuxppc-dev

On Fri, 11 Feb 2011 17:15:47 -0500
Kenny Ho <kho@belairnetworks.com> wrote:

> Thanks Scott.
> 
> Do you know the logic of the hwirq <-> virq mapping?

It's dynamic.

> When I was digging into the GPIO interrupt, the hwirq seems to be the same as the virq

The allocator tries that if it's available, but if that virq is already
taken, or is in the legacy ISA region under 16, you'll get a different
number.

> (both are 47 which is 16 (external interrupt) + 31 (internal interrupt).
> If I want to use external interrupt 7 and 8, should the virq also be 7
> and 8?

No.

> For some reason I am getting 41 for virq... may be I am still
> doing something wrong.

It's correct.  Pass what you receive into request_irq().

-Scott

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-02-11 22:19 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-02-11 19:07 Question on setting up external interrupt for P1020 (MPC8xxx) with device tree Kenny Ho
2011-02-11 21:56 ` Scott Wood
2011-02-11 22:15   ` Kenny Ho
2011-02-11 22:19     ` Scott Wood

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).