83xx: requesting external interrupts

Joakim Tjernlund joakim.tjernlund at transmode.se
Fri Jun 29 21:34:52 EST 2007


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;i<sizeof(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:
	mdio at 2320 {
			#address-cells = <1>;
			#size-cells = <0>;
			reg = <2320 18>;
			device_type = "mdio";
			compatible = "ucc_geth_phy";

			phy1: ethernet-phy at 0 {
				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;i<sizeof(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





More information about the Linuxppc-embedded mailing list