linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Gary Thomas <gary@mlbassoc.com>
Cc: linuxppc-dev@ozlabs.org
Subject: Re: MPC5200 VIRQ question
Date: Mon, 08 Dec 2008 19:03:42 +1100	[thread overview]
Message-ID: <1228723422.7101.35.camel@pasglop> (raw)
In-Reply-To: <4937E048.90206@mlbassoc.com>

On Thu, 2008-12-04 at 06:51 -0700, Gary Thomas wrote:
> I have a MPC5200 based board which has an FPGA for external
> I/O, etc.  This FPGA also funnels interrupts from the various
> external devices through to the CPU.
> 
> I've defined this structure in my DTS:
> 
> 	fpga@f8000000 {
> 		device_type = "board-control";
> 		#address-cells = <1>;
> 		#size-cells = <1>;
> 		// Note: includes sub-devices like CAN, A/D, etc
> 		reg = <0xf8000000 0x100000>;
> 
> 		fpga_ic: fpga_ic@f8000000 {
> 			device_type = "fpga-int-ctlr";
> 			interrupt-controller;
> 			#address-cells = <0>;
> 			#interrupt-cells = <2>;
> 			interrupts = <2 26 3>; // IRQ2
> 			interrupt-parent = <&mpc5200_pic>;
> 		};
> 		can@f8010000 {
> 			compatible = "am,can";
> 			device_type = "can";
> 			interrupts = <0 0>;
> 			interrupt_parent = <&fpga_ic>;
> 			reg = <0xf8010000 0x200>;
> 		};
> 	};
> 
> Of course, there will be more devices and interrupts later on,
> this is just the first of many.

Nothing obviously wrong so far other than you should use "compatible"
properties to identify your devices, including (especially) the fpga &
its pic, and maybe use slightly more verbose entries than "am,can" :-)

> Now the questions:
>  * How do I choose the VIRQ range supported by my FPGA?

You don't. Linux virtual numbers are allocated sparsely and on the fly.

You basically create an irq_host data structure, specifying what kind of
reverse mapping you want (typically in your case I suspect linear since
your HW interrupt space won't be huge), provide the appropriate
callbacks, all I can suggest here is to look at what others do.

>    I'm interested in this in particular for the MPC5200, but
>    also for other chips (I have many such board configurations).
>  * How do I pass this information along to my drivers?  I would
>    think that the interrupts value for the can interface above
>    would use a [logical] IRQ (an offset from the base VIRQ),
>    so how does the driver get the actual number (VIRQ+offset)
>    when probing the tree?

Depends on the driver. But if they use an OF node, they can do
of_irq_parse_and_map() or something like that. It will walk the tree,
find the controller, map it to an irq_host (via the callbacks your
provided), allocate a virq if not done yet, establish a virq->hw mapping
etc... all for you, and return the virq.

If they are PCI devices, the PCI code does it all for you.

>  * I know how to define the interrupt controller using irq_alloc_host()
>    (once I have the VIRQ range) but it's not clear to me where to stick
>    this initialization when bringing up my platform.

You don't provide a virq range to irq_alloc_host. You provide a type of
reverse mapping (depending on how sparse your HW numbering scheme is)
and for a linear map, how many entries it contains (which is the size of
your -physical- range).

virqs are allocated on the fly.

> Thanks for any pointers/ideas
> 
> n.b. I've read all the arguments about not using "device_type"
> and this will be resolved.  At the moment, I'm basing my
> code on a slightly older kernel codebase (2.6.26), so those
> entries remain.
> 
Cheers,
Ben.

  reply	other threads:[~2008-12-08  8:03 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-12-04 13:51 MPC5200 VIRQ question Gary Thomas
2008-12-08  8:03 ` Benjamin Herrenschmidt [this message]
2008-12-11  1:04   ` Gary Thomas
2008-12-11  1:59     ` Benjamin Herrenschmidt
2008-12-11 14:59       ` Gary Thomas
2008-12-11 21:00         ` Benjamin Herrenschmidt
2008-12-11  2:01     ` Jon Smirl
2008-12-11  2:04     ` Jon Smirl
2008-12-11  7:16     ` Grant Likely

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=1228723422.7101.35.camel@pasglop \
    --to=benh@kernel.crashing.org \
    --cc=gary@mlbassoc.com \
    --cc=linuxppc-dev@ozlabs.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).