linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* using general IRQs
@ 2015-08-10  7:48 Ran Shalit
  2015-08-10 10:40 ` Ran Shalit
  2015-08-17 10:37 ` Laurentiu Tudor
  0 siblings, 2 replies; 7+ messages in thread
From: Ran Shalit @ 2015-08-10  7:48 UTC (permalink / raw)
  To: linuxppc-dev

Hello,

MPC8349 has general IRQ numbered 0-7,
It is required to bind these IRQs with some routine , i.e. they are
not used with any specific driver.

- Should they be configured as gpios in device tree so that we can use
the gpio as irq in linux ? Is there any example ?
- After configuration, can the gpios be used in linux using the
standard /sys/class/gpio ?

Regards,
Ran

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

* Re: using general IRQs
  2015-08-10  7:48 using general IRQs Ran Shalit
@ 2015-08-10 10:40 ` Ran Shalit
  2015-08-11  2:29   ` Scott Wood
  2015-08-17 10:37 ` Laurentiu Tudor
  1 sibling, 1 reply; 7+ messages in thread
From: Ran Shalit @ 2015-08-10 10:40 UTC (permalink / raw)
  To: linuxppc-dev

On Mon, Aug 10, 2015 at 10:48 AM, Ran Shalit <ranshalit@gmail.com> wrote:
> Hello,
>
> MPC8349 has general IRQ numbered 0-7,
> It is required to bind these IRQs with some routine , i.e. they are
> not used with any specific driver.
>
> - Should they be configured as gpios in device tree so that we can use
> the gpio as irq in linux ? Is there any example ?
> - After configuration, can the gpios be used in linux using the
> standard /sys/class/gpio ?
>
> Regards,
> Ran

I am trying to use only IRQ4, so I have tried to configure it as
following in device tree:

device tree:

  intc@0{
 compatible = "intc";
 #address-cells = <1>;
 #size-cells = <0>;
 reg = <0 0x1000>;
 interrupts = <4 0x8>;
  };

But I don't see IRQ4 listed in the interrupt list:
# cat /proc/interrupts
           CPU0
 16:         93      IPIC   9 Level     serial
 18:          0      IPIC  14 Level     i2c-mpc
 19:          0      IPIC  15 Level     i2c-mpc
 21:          0      IPIC  18 Level     phy_interrupt
 32:          0      IPIC  32 Level     eth0_g0_tx
 33:         14      IPIC  33 Level     eth0_g0_rx
 34:          0      IPIC  34 Level     eth0_g0_er
 35:          0      IPIC  35 Level     eth1_g0_tx
 36:          0      IPIC  36 Level     eth1_g0_rx
 37:          0      IPIC  37 Level     eth1_g0_er
LOC:      60756   Local timer interrupts for timer event device
LOC:          1   Local timer interrupts for others
SPU:          0   Spurious interrupts
PMI:          0   Performance monitoring interrupts
MCE:          0   Machine check exceptions


Regards,
Ran

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

* Re: using general IRQs
  2015-08-10 10:40 ` Ran Shalit
@ 2015-08-11  2:29   ` Scott Wood
  2015-08-11  3:45     ` Ran Shalit
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Wood @ 2015-08-11  2:29 UTC (permalink / raw)
  To: Ran Shalit; +Cc: linuxppc-dev

On Mon, 2015-08-10 at 13:40 +0300, Ran Shalit wrote:
> On Mon, Aug 10, 2015 at 10:48 AM, Ran Shalit <ranshalit@gmail.com> wrote:
> > Hello,
> > 
> > MPC8349 has general IRQ numbered 0-7,
> > It is required to bind these IRQs with some routine , i.e. they are
> > not used with any specific driver.
> > 
> > - Should they be configured as gpios in device tree so that we can use
> > the gpio as irq in linux ? Is there any example ?
> > - After configuration, can the gpios be used in linux using the
> > standard /sys/class/gpio ?
> > 
> > Regards,
> > Ran

What do you mean by "general IRQ"?  Do you mean external IRQs?

> I am trying to use only IRQ4, so I have tried to configure it as
> following in device tree:
> 
> device tree:
> 
>   intc@0{
>  compatible = "intc";
>  #address-cells = <1>;
>  #size-cells = <0>;
>  reg = <0 0x1000>;
>  interrupts = <4 0x8>;
>   };
> 
> But I don't see IRQ4 listed in the interrupt list:
> # cat /proc/interrupts

/proc/interrupts shows virtual interrupts, which do not necessarily 
correspond to anything in the device tree.  In particular, virtual interrupts 
under 16 are reserved for ISA interrupts, and thus any mpic interrupts in 
that range will be remapped.

Additionally, putting an interrupt in the device tree does not make it show 
up in /proc/interrupts.  Only interrupts for which a driver has registered a 
handler will show up in /proc/interrupts.

-Scott

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

* Re: using general IRQs
  2015-08-11  2:29   ` Scott Wood
@ 2015-08-11  3:45     ` Ran Shalit
  2015-08-11  3:47       ` Scott Wood
  0 siblings, 1 reply; 7+ messages in thread
From: Ran Shalit @ 2015-08-11  3:45 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

On Tue, Aug 11, 2015 at 5:29 AM, Scott Wood <scottwood@freescale.com> wrote:
> On Mon, 2015-08-10 at 13:40 +0300, Ran Shalit wrote:
>> On Mon, Aug 10, 2015 at 10:48 AM, Ran Shalit <ranshalit@gmail.com> wrote:
>> > Hello,
>> >
>> > MPC8349 has general IRQ numbered 0-7,
>> > It is required to bind these IRQs with some routine , i.e. they are
>> > not used with any specific driver.
>> >
>> > - Should they be configured as gpios in device tree so that we can use
>> > the gpio as irq in linux ? Is there any example ?
>> > - After configuration, can the gpios be used in linux using the
>> > standard /sys/class/gpio ?
>> >
>> > Regards,
>> > Ran
>
> What do you mean by "general IRQ"?  Do you mean external IRQs?
>
>> I am trying to use only IRQ4, so I have tried to configure it as
>> following in device tree:
>>
>> device tree:
>>
>>   intc@0{
>>  compatible = "intc";
>>  #address-cells = <1>;
>>  #size-cells = <0>;
>>  reg = <0 0x1000>;
>>  interrupts = <4 0x8>;
>>   };
>>
>> But I don't see IRQ4 listed in the interrupt list:
>> # cat /proc/interrupts
>
> /proc/interrupts shows virtual interrupts, which do not necessarily
> correspond to anything in the device tree.  In particular, virtual interrupts
> under 16 are reserved for ISA interrupts, and thus any mpic interrupts in
> that range will be remapped.
>
> Additionally, putting an interrupt in the device tree does not make it show
> up in /proc/interrupts.  Only interrupts for which a driver has registered a
> handler will show up in /proc/interrupts.
>
> -Scott
>
>
Hi Scott,

I meant  external IRQ.
I am actually trying to use irq 4 interrupt.

I've added the above in device tree, and in kernel code I do:
np = of_find_node_by_name(NULL,"hello");
  if (np == NULL)
    {
    printk("Error node not found\n");
    }
  printk("Node np = 0x%0x\n",np);                     <-- Node np = 0xdfffe2f0
  virq = irq_of_parse_and_map(np,0);

  printk(" VIRQ: %d \n" , virq);                              <-- virq = 0 !!??
  if (0 > (error=request_irq(virq, &hello_IRQHandler, IRQF_SHARED,
"hello", &value))) {
      printk(KERN_WARNING"hello_IRQHandler: Init: Unable to allocate
IRQ error = %d\n\n", error);
    return -1;
  <-- request_irq return -22 ....
  }


 But it fails in request_irq (it return -22).
Also, irq_of_parse_and_map(np,0) returns 0. I think it should have returned 4.

Regards,
Ran

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

* Re: using general IRQs
  2015-08-11  3:45     ` Ran Shalit
@ 2015-08-11  3:47       ` Scott Wood
  2015-08-11  6:27         ` Ran Shalit
  0 siblings, 1 reply; 7+ messages in thread
From: Scott Wood @ 2015-08-11  3:47 UTC (permalink / raw)
  To: Ran Shalit; +Cc: linuxppc-dev

On Tue, 2015-08-11 at 06:45 +0300, Ran Shalit wrote:
> On Tue, Aug 11, 2015 at 5:29 AM, Scott Wood <scottwood@freescale.com> wrote:
> > On Mon, 2015-08-10 at 13:40 +0300, Ran Shalit wrote:
> > > On Mon, Aug 10, 2015 at 10:48 AM, Ran Shalit <ranshalit@gmail.com> 
> > > wrote:
> > > > Hello,
> > > > 
> > > > MPC8349 has general IRQ numbered 0-7,
> > > > It is required to bind these IRQs with some routine , i.e. they are
> > > > not used with any specific driver.
> > > > 
> > > > - Should they be configured as gpios in device tree so that we can use
> > > > the gpio as irq in linux ? Is there any example ?
> > > > - After configuration, can the gpios be used in linux using the
> > > > standard /sys/class/gpio ?
> > > > 
> > > > Regards,
> > > > Ran
> > 
> > What do you mean by "general IRQ"?  Do you mean external IRQs?
> > 
> > > I am trying to use only IRQ4, so I have tried to configure it as
> > > following in device tree:
> > > 
> > > device tree:
> > > 
> > >   intc@0{
> > >  compatible = "intc";
> > >  #address-cells = <1>;
> > >  #size-cells = <0>;
> > >  reg = <0 0x1000>;
> > >  interrupts = <4 0x8>;
> > >   };
> > > 
> > > But I don't see IRQ4 listed in the interrupt list:
> > > # cat /proc/interrupts
> > 
> > /proc/interrupts shows virtual interrupts, which do not necessarily
> > correspond to anything in the device tree.  In particular, virtual 
> > interrupts
> > under 16 are reserved for ISA interrupts, and thus any mpic interrupts in
> > that range will be remapped.
> > 
> > Additionally, putting an interrupt in the device tree does not make it 
> > show
> > up in /proc/interrupts.  Only interrupts for which a driver has 
> > registered a
> > handler will show up in /proc/interrupts.
> > 
> > -Scott
> > 
> > 
> Hi Scott,
> 
> I meant  external IRQ.
> I am actually trying to use irq 4 interrupt.
> 
> I've added the above in device tree, and in kernel code I do:
> np = of_find_node_by_name(NULL,"hello");

Why are you looking for a node named "hello" when your node is named "intc"?

>   if (np == NULL)
>     {
>     printk("Error node not found\n");
>     }
>   printk("Node np = 0x%0x\n",np);                     <-- Node np = 
> 0xdfffe2f0

How could you possibly have gotten a non-NULL value for np, with the above 
code and node, unless there's something you're not showing?

>   virq = irq_of_parse_and_map(np,0);
> 
>   printk(" VIRQ: %d \n" , virq);                              <-- virq = 0 
> !!??

virq = 0 means the lookup failed.  Either there was no interrupt in the node, 
or it couldn't be mapped for some reason.

>   if (0 > (error=request_irq(virq, &hello_IRQHandler, IRQF_SHARED,
> "hello", &value))) {
>       printk(KERN_WARNING"hello_IRQHandler: Init: Unable to allocate
> IRQ error = %d\n\n", error);
>     return -1;
>   <-- request_irq return -22 ....
>   }
> 
> 
>  But it fails in request_irq (it return -22).
> Also, irq_of_parse_and_map(np,0) returns 0. I think it should have returned 
> 4.

I already explained why it won't return 4 (see the part about virtual 
interrupts).

-Scott

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

* Re: using general IRQs
  2015-08-11  3:47       ` Scott Wood
@ 2015-08-11  6:27         ` Ran Shalit
  0 siblings, 0 replies; 7+ messages in thread
From: Ran Shalit @ 2015-08-11  6:27 UTC (permalink / raw)
  To: Scott Wood; +Cc: linuxppc-dev

On Tue, Aug 11, 2015 at 6:47 AM, Scott Wood <scottwood@freescale.com> wrote:
> On Tue, 2015-08-11 at 06:45 +0300, Ran Shalit wrote:
>> On Tue, Aug 11, 2015 at 5:29 AM, Scott Wood <scottwood@freescale.com> wrote:
>> > On Mon, 2015-08-10 at 13:40 +0300, Ran Shalit wrote:
>> > > On Mon, Aug 10, 2015 at 10:48 AM, Ran Shalit <ranshalit@gmail.com>
>> > > wrote:
>> > > > Hello,
>> > > >
>> > > > MPC8349 has general IRQ numbered 0-7,
>> > > > It is required to bind these IRQs with some routine , i.e. they are
>> > > > not used with any specific driver.
>> > > >
>> > > > - Should they be configured as gpios in device tree so that we can use
>> > > > the gpio as irq in linux ? Is there any example ?
>> > > > - After configuration, can the gpios be used in linux using the
>> > > > standard /sys/class/gpio ?
>> > > >
>> > > > Regards,
>> > > > Ran
>> >
>> > What do you mean by "general IRQ"?  Do you mean external IRQs?
>> >
>> > > I am trying to use only IRQ4, so I have tried to configure it as
>> > > following in device tree:
>> > >
>> > > device tree:
>> > >
>> > >   intc@0{
>> > >  compatible = "intc";
>> > >  #address-cells = <1>;
>> > >  #size-cells = <0>;
>> > >  reg = <0 0x1000>;
>> > >  interrupts = <4 0x8>;
>> > >   };
>> > >
>> > > But I don't see IRQ4 listed in the interrupt list:
>> > > # cat /proc/interrupts
>> >
>> > /proc/interrupts shows virtual interrupts, which do not necessarily
>> > correspond to anything in the device tree.  In particular, virtual
>> > interrupts
>> > under 16 are reserved for ISA interrupts, and thus any mpic interrupts in
>> > that range will be remapped.
>> >
>> > Additionally, putting an interrupt in the device tree does not make it
>> > show
>> > up in /proc/interrupts.  Only interrupts for which a driver has
>> > registered a
>> > handler will show up in /proc/interrupts.
>> >
>> > -Scott
>> >
>> >
>> Hi Scott,
>>
>> I meant  external IRQ.
>> I am actually trying to use irq 4 interrupt.
>>
>> I've added the above in device tree, and in kernel code I do:
>> np = of_find_node_by_name(NULL,"hello");
>
> Why are you looking for a node named "hello" when your node is named "intc"?
I apologyze, this is the node I'm using

hello@0{
 compatible = "hello";
  #address-cells = <1>;
  #size-cells = <0>;
  reg = <0 0x1000>;
  interrupts = <4 0x8>;
};

>
>>   if (np == NULL)
>>     {
>>     printk("Error node not found\n");
>>     }
>>   printk("Node np = 0x%0x\n",np);                     <-- Node np =
>> 0xdfffe2f0
>
> How could you possibly have gotten a non-NULL value for np, with the above
> code and node, unless there's something you're not showing?
You are right, The node is named hello in my device

>
>>   virq = irq_of_parse_and_map(np,0);
>>
>>   printk(" VIRQ: %d \n" , virq);                              <-- virq = 0
>> !!??
>
> virq = 0 means the lookup failed.  Either there was no interrupt in the node,
> or it couldn't be mapped for some reason.
>
>>   if (0 > (error=request_irq(virq, &hello_IRQHandler, IRQF_SHARED,
>> "hello", &value))) {
>>       printk(KERN_WARNING"hello_IRQHandler: Init: Unable to allocate
>> IRQ error = %d\n\n", error);
>>     return -1;
>>   <-- request_irq return -22 ....
>>   }
>>
>>
>>  But it fails in request_irq (it return -22).
>> Also, irq_of_parse_and_map(np,0) returns 0. I think it should have returned
>> 4.
>
> I already explained why it won't return 4 (see the part about virtual
> interrupts).

Thank you very much,
I now have success with the request_irq code.

Best Regards,
Ran

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

* Re: using general IRQs
  2015-08-10  7:48 using general IRQs Ran Shalit
  2015-08-10 10:40 ` Ran Shalit
@ 2015-08-17 10:37 ` Laurentiu Tudor
  1 sibling, 0 replies; 7+ messages in thread
From: Laurentiu Tudor @ 2015-08-17 10:37 UTC (permalink / raw)
  To: linuxppc-dev, Ran Shalit

On 08/10/2015 10:48 AM, Ran Shalit wrote:
> Hello,
> 
> MPC8349 has general IRQ numbered 0-7,
> It is required to bind these IRQs with some routine , i.e. they are
> not used with any specific driver.
> 
> - Should they be configured as gpios in device tree so that we can use
> the gpio as irq in linux ? Is there any example ?

If it's a gpio then yes, you need to use it as a gpio. Not familiar with MPC8349,
but newer FSL chips can select between gpio or irq through a RCW field (IRQ_BASE?).

Note that for gpios there's special apis, such as:  of_get_gpio(), gpio_request_one() a.s.o.
Also you'll need to update your device tree node to something like:

  intc2@0{
   compatible = "intc2";
   reg = <0 0x1000>;
   gpios = <&gpio0 4 0>;
  };

See Documentation/gpio.txt for more info.

---
Best Regards, Laurentiu

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

end of thread, other threads:[~2015-08-17 14:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-08-10  7:48 using general IRQs Ran Shalit
2015-08-10 10:40 ` Ran Shalit
2015-08-11  2:29   ` Scott Wood
2015-08-11  3:45     ` Ran Shalit
2015-08-11  3:47       ` Scott Wood
2015-08-11  6:27         ` Ran Shalit
2015-08-17 10:37 ` Laurentiu Tudor

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