RE: 83xx: requesting external interrupts

2007-06-30 Thread Joakim Tjernlund
 

 -Original Message-
 From: Andy Fleming [mailto:[EMAIL PROTECTED] 
 Sent: den 30 juni 2007 01:55
 To: Joakim Tjernlund
 Cc: [EMAIL PROTECTED]; linuxppc-embedded@ozlabs.org
 Subject: Re: 83xx: requesting external interrupts
 
 
 On Jun 29, 2007, at 06:34, Joakim Tjernlund wrote:
  [EMAIL PROTECTED] {
  #address-cells = 1;
  #size-cells = 0;
  reg = 2320 18;
  device_type = mdio;
  compatible = ucc_geth_phy;
 
  phy1: [EMAIL PROTECTED] {
  interrupt-parent = ipic;
  interrupts = 12 2; //EXT IRQ2
  reg = 0; // 0
  device_type = ethernet-phy;
  interface = 3; //ENET_100_MII
  };
 
  Now the things is that the IRQ works with and without the
   /* All external IRQs + Generic timer IRQs must be initialized by  
  BSP */
   const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78,  
  84, 72};
   for (i=0;isizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
  virq = irq_create_mapping(NULL, bsp_irqs[i]);
 
 
 This isn't how to use the device tree.  That is, you *aren't* using  
 the device tree.  You want to read the node of every device you want  
 to set up, and create the mapping.  Look at irq_of_parse_and_map().   
 Look in include/asm-powerpc/prom.h, at of_irq_to_resource(), which  
 maps an irq in the device tree.

I use both!
I see that ipic.c does all the work for me, so I should just drop
the above code. It is strange though that the virq # changes if
I keep the code.

hmm, maybe if I sort the bsp_irqs[] list numerically it will be the same?
Am at home ATM so I can't verify.

 Jocke

___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-06-29 Thread Joakim Tjernlund
On Fri, 2007-05-11 at 10:12 -0400, Ben Warren wrote:
 Alex,
 
 On Fri, 2007-05-11 at 10:29 +0100, Alex Zeffertt wrote:
  Hi,
  
  Thanks for your reply Ben, but I think my problem is slightly different.  
  It is not
  that the sense (high/low/rising/falling) of the interrupt is wrong, but 
  that the
  kernel will not allow me to register the handler.
  
  I've changed my code to:
  
   struct device_node *np = of_find_node_by_type(NULL, ipic);
   struct irq_host *host = irq_find_host(np);
   int rc;
  
   unsigned int virq = irq_find_mapping(host, 5);
   set_irq_type(virq, IRQ_TYPE_EDGE_FALLING);
   rc = request_irq(virq, mpc832xemds_phy_interrupt, IRQF_SHARED, 
  pm5384, dev);
  
  but the last line still returns a non-zero error code.
  
  Is there a new way of requesting to install a handler for external 
  interrupts?  I
  can't find any powerpc examples in the kernel tree
  
 Sorry, I missed a bit of the implementation.  You need to register the
 IRQs before attempting to attach an ISR. Here's some sample code that
 works for me.  You'll probably need different IRQs, based on what your
 board does:
 
 /* All external IRQs + Generic timer IRQs must be initialized by BSP */
 const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84, 72};
 
 Add this to your BSP IRQ init code (void __init xxx_init_IRQs())
 
 
   for (i=0;isizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
   virq = irq_create_mapping(NULL, bsp_irqs[i]);
 
 That should do it.
 
 regards,
 Ben

Hi Ben

I too am adding such a IRQ for my PHY connected to external IRQ2.
The PHY is connetced to UCC2.
I have this in my DTS for the PHY:
[EMAIL PROTECTED] {
#address-cells = 1;
#size-cells = 0;
reg = 2320 18;
device_type = mdio;
compatible = ucc_geth_phy;

phy1: [EMAIL PROTECTED] {
interrupt-parent = ipic;
interrupts = 12 2; //EXT IRQ2
reg = 0; // 0
device_type = ethernet-phy;
interface = 3; //ENET_100_MII
};

Now the things is that the IRQ works with and without the
 /* All external IRQs + Generic timer IRQs must be initialized by BSP */
 const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84, 72};
 for (i=0;isizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
virq = irq_create_mapping(NULL, bsp_irqs[i]);
code in my bsp. There is one difference though.
Printing the irq num in phy_interrupt:
static irqreturn_t phy_interrupt(int irq, void *dev_id)
{
struct net_device *dev = (struct net_device *)dev_id;
struct ucc_geth_private *ugeth = netdev_priv(dev);

ugeth_vdbg(%s: IN, __FUNCTION__);
printk(KERN_ERR PHY IRQ:%d \n, irq);

Shows a difference:
with the bsp code added it prints:
PHY IRQ:18
and when I remove the bsp code it prints:
PHY IRQ:19

So what is correct, should I add the bsp code or not?

 Jocke


___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-06-29 Thread Ben Warren
Hi Jocke,

On Fri, 2007-06-29 at 13:34 +0200, Joakim Tjernlund wrote:
snip
 I too am adding such a IRQ for my PHY connected to external IRQ2.
 The PHY is connetced to UCC2.
 I have this in my DTS for the PHY:
   [EMAIL PROTECTED] {
   #address-cells = 1;
   #size-cells = 0;
   reg = 2320 18;
   device_type = mdio;
   compatible = ucc_geth_phy;
 
   phy1: [EMAIL PROTECTED] {
   interrupt-parent = ipic;
   interrupts = 12 2; //EXT IRQ2
   reg = 0; // 0
   device_type = ethernet-phy;
   interface = 3; //ENET_100_MII
   };
 
 Now the things is that the IRQ works with and without the
  /* All external IRQs + Generic timer IRQs must be initialized by BSP */
  const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84, 72};
  for (i=0;isizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
   virq = irq_create_mapping(NULL, bsp_irqs[i]);
 code in my bsp. There is one difference though.
 Printing the irq num in phy_interrupt:
 static irqreturn_t phy_interrupt(int irq, void *dev_id)
 {
   struct net_device *dev = (struct net_device *)dev_id;
   struct ucc_geth_private *ugeth = netdev_priv(dev);
 
   ugeth_vdbg(%s: IN, __FUNCTION__);
   printk(KERN_ERR PHY IRQ:%d \n, irq);
 
 Shows a difference:
 with the bsp code added it prints:
 PHY IRQ:18
 and when I remove the bsp code it prints:
 PHY IRQ:19
 
 So what is correct, should I add the bsp code or not?
 
  Jocke
I had to add this board initialization code because on my CPU (8349),
certain interrupts weren't automatically mapped by built-in kernel code.
Interrupts simply weren't firing, because they hadn't been enabled in
the IPIC.  Your case is different, because the MDIO device tree entry is
parsed by common code (arch/powerpc/sysdev/something).  

You probably don't need to explicitly map IRQs unless they're being used
by custom device drivers.  I don't know why you'd get a different
virtual mapping, though.  I guess you're effectively mapping the same
IRQ twice, and I don't know what that does.  Part of me wants to say if
it works properly, who cares, but that's how we get into trouble...

Somebody like Kumar Gala could probably provide a real answer. 

regards,
Ben

___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-06-29 Thread Andy Fleming

On Jun 29, 2007, at 06:34, Joakim Tjernlund wrote:
 [EMAIL PROTECTED] {
   #address-cells = 1;
   #size-cells = 0;
   reg = 2320 18;
   device_type = mdio;
   compatible = ucc_geth_phy;

   phy1: [EMAIL PROTECTED] {
   interrupt-parent = ipic;
   interrupts = 12 2; //EXT IRQ2
   reg = 0; // 0
   device_type = ethernet-phy;
   interface = 3; //ENET_100_MII
   };

 Now the things is that the IRQ works with and without the
  /* All external IRQs + Generic timer IRQs must be initialized by  
 BSP */
  const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78,  
 84, 72};
  for (i=0;isizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
   virq = irq_create_mapping(NULL, bsp_irqs[i]);


This isn't how to use the device tree.  That is, you *aren't* using  
the device tree.  You want to read the node of every device you want  
to set up, and create the mapping.  Look at irq_of_parse_and_map().   
Look in include/asm-powerpc/prom.h, at of_irq_to_resource(), which  
maps an irq in the device tree.


Andy
___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-05-11 Thread Ben Warren
Alex,

On Fri, 2007-05-11 at 10:29 +0100, Alex Zeffertt wrote:
 Hi,
 
 Thanks for your reply Ben, but I think my problem is slightly different.  It 
 is not
 that the sense (high/low/rising/falling) of the interrupt is wrong, but that 
 the
 kernel will not allow me to register the handler.
 
 I've changed my code to:
 
  struct device_node *np = of_find_node_by_type(NULL, ipic);
  struct irq_host *host = irq_find_host(np);
  int rc;
 
  unsigned int virq = irq_find_mapping(host, 5);
  set_irq_type(virq, IRQ_TYPE_EDGE_FALLING);
  rc = request_irq(virq, mpc832xemds_phy_interrupt, IRQF_SHARED, pm5384, 
 dev);
 
 but the last line still returns a non-zero error code.
 
 Is there a new way of requesting to install a handler for external 
 interrupts?  I
 can't find any powerpc examples in the kernel tree
 
Sorry, I missed a bit of the implementation.  You need to register the
IRQs before attempting to attach an ISR. Here's some sample code that
works for me.  You'll probably need different IRQs, based on what your
board does:

/* All external IRQs + Generic timer IRQs must be initialized by BSP */
const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84, 72};

Add this to your BSP IRQ init code (void __init xxx_init_IRQs())


for (i=0;isizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
virq = irq_create_mapping(NULL, bsp_irqs[i]);

That should do it.

regards,
Ben

___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-05-11 Thread Kumar Gala

On May 11, 2007, at 9:12 AM, Ben Warren wrote:

 Alex,

 On Fri, 2007-05-11 at 10:29 +0100, Alex Zeffertt wrote:
 Hi,

 Thanks for your reply Ben, but I think my problem is slightly  
 different.  It is not
 that the sense (high/low/rising/falling) of the interrupt is  
 wrong, but that the
 kernel will not allow me to register the handler.

 I've changed my code to:

  struct device_node *np = of_find_node_by_type(NULL, ipic);
  struct irq_host *host = irq_find_host(np);
  int rc;

  unsigned int virq = irq_find_mapping(host, 5);
  set_irq_type(virq, IRQ_TYPE_EDGE_FALLING);
  rc = request_irq(virq, mpc832xemds_phy_interrupt,  
 IRQF_SHARED, pm5384, dev);

 but the last line still returns a non-zero error code.

 Is there a new way of requesting to install a handler for external  
 interrupts?  I
 can't find any powerpc examples in the kernel tree

 Sorry, I missed a bit of the implementation.  You need to register the
 IRQs before attempting to attach an ISR. Here's some sample code that
 works for me.  You'll probably need different IRQs, based on what your
 board does:

 /* All external IRQs + Generic timer IRQs must be initialized by  
 BSP */
 const int bsp_irqs[] = {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84,  
 72};

 Add this to your BSP IRQ init code (void __init xxx_init_IRQs())


   for (i=0;isizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++)
   virq = irq_create_mapping(NULL, bsp_irqs[i]);

I assume you're code doesn't look exactly like this.  You'll need to  
use the virq in the request_irq()... its most likely just random luck  
if things are working and you aren't using the virq returned from  
irq_create_mapping()

(Well its more than random luck, its because most 83xx systems only  
have one PIC and this hw_irq # == virq)

- k
___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-05-11 Thread Ben Warren
On Fri, 2007-05-11 at 15:15 -0500, Kumar Gala wrote:

 
 I assume you're code doesn't look exactly like this.  You'll need to  
 use the virq in the request_irq()... its most likely just random luck  
 if things are working and you aren't using the virq returned from  
 irq_create_mapping()
 
 (Well its more than random luck, its because most 83xx systems only  
 have one PIC and this hw_irq # == virq)
 
 - k

In the code that registers the ISR I do this:

virq = irq_find_mapping(NULL, MY_IRQ);
request_irq(virq ...)

Since I only have one interrupt controller, host is NULL, right?

regards,
Ben

___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-05-11 Thread Kumar Gala

On May 11, 2007, at 3:29 PM, Ben Warren wrote:

 On Fri, 2007-05-11 at 15:15 -0500, Kumar Gala wrote:


 I assume you're code doesn't look exactly like this.  You'll need to
 use the virq in the request_irq()... its most likely just random luck
 if things are working and you aren't using the virq returned from
 irq_create_mapping()

 (Well its more than random luck, its because most 83xx systems only
 have one PIC and this hw_irq # == virq)

 - k

 In the code that registers the ISR I do this:

 virq = irq_find_mapping(NULL, MY_IRQ);
 request_irq(virq ...)

 Since I only have one interrupt controller, host is NULL, right?

Should be ok.  I've been doing the irq_create_mapping() in _init_IRQ 
() and saving off the return.

- k
___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded


Re: 83xx: requesting external interrupts

2007-05-10 Thread Ben Warren
Alex,

Follow this thread...
http://marc.info/?l=linuxppc-embeddedm=116849062702002w=2

On Thu, 2007-05-10 at 17:45 +0100, Alex Zeffertt wrote:
 Hi list,
 
 I'm trying to port a driver from 2.6.11 to 2.6.21 and I'm stuck on the 
 following line:
 
   request_irq(MPC83xx_IRQ_EXT5, mpc832xemds_phy_interrupt, SA_SHIRQ, 
 pm5384, dev);
 
 The first problem is that MPC83xx_IRQ_EXT5 is no longer defined.  If I hard 
 code this to
 what I think is the right value (i.e. 21) then request_irq fails on insmod.
 
 I obviously need to do something different now that ARCH=powerpc, but I can't 
 find any
 examples of code which requests 83xx external interrupts.  Can anybody help?
 
 TIA,
 
 Alex
 ___
 Linuxppc-embedded mailing list
 Linuxppc-embedded@ozlabs.org
 https://ozlabs.org/mailman/listinfo/linuxppc-embedded

___
Linuxppc-embedded mailing list
Linuxppc-embedded@ozlabs.org
https://ozlabs.org/mailman/listinfo/linuxppc-embedded