public inbox for linuxppc-dev@ozlabs.org 
 help / color / mirror / Atom feed
From: Grant Likely <grant.likely@secretlab•ca>
To: sylvain.louchez@g4apps•com
Cc: linuxppc-dev@ozlabs•org
Subject: Re: using IRQ1 in mpc5121ads
Date: Mon, 30 Mar 2009 10:42:30 -0600	[thread overview]
Message-ID: <fa686aa40903300942l585cdbebt2546bb09738e6e32@mail.gmail.com> (raw)
In-Reply-To: <49d0d82a.09038e0a.585d.348b@mx.google.com>

On Mon, Mar 30, 2009 at 8:33 AM, sylvain louchez
<sylvain.louchez@gmail•com> wrote:
> Hello, I=92m a newbie looking for where the documentation and implementat=
ion
> model can be found=85
>
> My custom driver is looking for an interrupt notification from the kernel=
 -
> and it registers in the /proc/interrupts file as expected when installed,
> i.e.
>
> $insmod custom_driver.ko gps_irq=3D<n>

You don't want to do this with PowerPC.  There is no reliable way to
know what the IRQ number is at module load time.  Note that the IRQ
numbers listed in /proc/interrupts are *not* the same as the hardware
interrupt number.  /proc/interrupts on powerpc shows 'virtual IRQ'
numbers which are assigned dynamically as needed.  This is so that the
kernel can handle multiple cascaded IRQ controllers, each with
different hardware IRQ numbering schemes.

> 1. create an entry in the dts file; I think we've got this understood
> through advice already received - for example the new interrupt entry can=
 be
> created in the dts file - something like:
>
>
>
> gps@0 {=A0=A0=A0=A0=A0 // there is no address so just make it 0

There is no address so just make it "gps {", unless you have more than
one of them.

>
> =A0=A0=A0 compatible =3D "gps_interrupt";

Change this to: compatible =3D "<vendor>,<name-of-gps-device>";

Note that this node should describe the whole GPS device, not just IRQ
line for the GPS device.  Is this device addressable in any way?  Does
it have any memory mapped registers?  SPI?  I2C?

>
> =A0=A0=A0 interrupts =3D <17 0x8>;=A0=A0=A0=A0=A0=A0=A0=A0 // 17 is irq1,=
 8 is level low, see
> include/linux/irq.h for others
>
> =A0=A0=A0 interrupt-parent =3D < &ipic >;

This looks correct

> 2. but now we need to relate the actual interrupt to the virtual interrup=
t
> called in the driver... by invoking the function irq_of_parse_and_map - b=
ut
> we don't know how to do it - nor have we found how to do it in browsing
> through the open source documentation

You need to write an of_platform_driver which will bind against the
'compatible' property in your GPS node.

> A secondary question: where to properly add this function call in the fil=
e
> system?

Use of_register_platform_driver() to register your of_platform_driver
in your module's init function.

> Are we on the right track here? Is there sample/ tutorial code you could
> point us to?

Search for of_register_platform_driver() in the kernel source.

g.

--=20
Grant Likely, B.Sc., P.Eng.
Secret Lab Technologies Ltd.

  reply	other threads:[~2009-03-30 16:42 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-03-30 14:33 using IRQ1 in mpc5121ads sylvain louchez
2009-03-30 16:42 ` Grant Likely [this message]
2009-03-31 23:10 ` David Gibson

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=fa686aa40903300942l585cdbebt2546bb09738e6e32@mail.gmail.com \
    --to=grant.likely@secretlab$(echo .)ca \
    --cc=linuxppc-dev@ozlabs$(echo .)org \
    --cc=sylvain.louchez@g4apps$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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