* 83xx: requesting external interrupts @ 2007-05-10 16:45 Alex Zeffertt 2007-05-10 17:07 ` Ben Warren 0 siblings, 1 reply; 10+ messages in thread From: Alex Zeffertt @ 2007-05-10 16:45 UTC (permalink / raw) To: linuxppc-embedded 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 83xx: requesting external interrupts 2007-05-10 16:45 83xx: requesting external interrupts Alex Zeffertt @ 2007-05-10 17:07 ` Ben Warren [not found] ` <46443784.3060600@cambridgebroadband.com> 0 siblings, 1 reply; 10+ messages in thread From: Ben Warren @ 2007-05-10 17:07 UTC (permalink / raw) To: Alex Zeffertt; +Cc: linuxppc-embedded Alex, Follow this thread... http://marc.info/?l=linuxppc-embedded&m=116849062702002&w=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 ^ permalink raw reply [flat|nested] 10+ messages in thread
[parent not found: <46443784.3060600@cambridgebroadband.com>]
* Re: 83xx: requesting external interrupts [not found] ` <46443784.3060600@cambridgebroadband.com> @ 2007-05-11 14:12 ` Ben Warren 2007-05-11 20:15 ` Kumar Gala 2007-06-29 11:34 ` Joakim Tjernlund 0 siblings, 2 replies; 10+ messages in thread From: Ben Warren @ 2007-05-11 14:12 UTC (permalink / raw) To: Alex Zeffertt; +Cc: linuxppc-embedded 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 83xx: requesting external interrupts 2007-05-11 14:12 ` Ben Warren @ 2007-05-11 20:15 ` Kumar Gala 2007-05-11 20:29 ` Ben Warren 2007-06-29 11:34 ` Joakim Tjernlund 1 sibling, 1 reply; 10+ messages in thread From: Kumar Gala @ 2007-05-11 20:15 UTC (permalink / raw) To: bwarren; +Cc: linuxppc-embedded 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;i<sizeof(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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 83xx: requesting external interrupts 2007-05-11 20:15 ` Kumar Gala @ 2007-05-11 20:29 ` Ben Warren 2007-05-11 20:37 ` Kumar Gala 0 siblings, 1 reply; 10+ messages in thread From: Ben Warren @ 2007-05-11 20:29 UTC (permalink / raw) To: Kumar Gala; +Cc: linuxppc-embedded 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 83xx: requesting external interrupts 2007-05-11 20:29 ` Ben Warren @ 2007-05-11 20:37 ` Kumar Gala 0 siblings, 0 replies; 10+ messages in thread From: Kumar Gala @ 2007-05-11 20:37 UTC (permalink / raw) To: bwarren; +Cc: linuxppc-embedded 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 83xx: requesting external interrupts 2007-05-11 14:12 ` Ben Warren 2007-05-11 20:15 ` Kumar Gala @ 2007-06-29 11:34 ` Joakim Tjernlund 2007-06-29 16:43 ` Ben Warren 2007-06-29 23:54 ` Andy Fleming 1 sibling, 2 replies; 10+ messages in thread From: Joakim Tjernlund @ 2007-06-29 11:34 UTC (permalink / raw) To: bwarren; +Cc: linuxppc-embedded On Fri, 2007-05-11 at 10:12 -0400, Ben Warren wrote: > Alex, >=20 > On Fri, 2007-05-11 at 10:29 +0100, Alex Zeffertt wrote: > > Hi, > >=20 > > 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. > >=20 > > I've changed my code to: > >=20 > > struct device_node *np =3D of_find_node_by_type(NULL, "ipic"); > > struct irq_host *host =3D irq_find_host(np); > > int rc; > >=20 > > unsigned int virq =3D irq_find_mapping(host, 5); > > set_irq_type(virq, IRQ_TYPE_EDGE_FALLING); > > rc =3D request_irq(virq, mpc832xemds_phy_interrupt, = IRQF_SHARED, "pm5384", dev); > >=20 > > but the last line still returns a non-zero error code. > >=20 > > 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.... > >=20 > 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: >=20 > /* All external IRQs + Generic timer IRQs must be initialized by BSP = */ > const int bsp_irqs[] =3D {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84, = 72}; >=20 > Add this to your BSP IRQ init code (void __init xxx_init_IRQs()) >=20 >=20 > for (i=3D0;i<sizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++) > virq =3D irq_create_mapping(NULL, bsp_irqs[i]); >=20 > That should do it. >=20 > 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@2320 { #address-cells =3D <1>; #size-cells =3D <0>; reg =3D <2320 18>; device_type =3D "mdio"; compatible =3D "ucc_geth_phy"; phy1: ethernet-phy@0 { interrupt-parent =3D <&ipic>; interrupts =3D <12 2>; //EXT IRQ2 reg =3D <0>; // 0 device_type =3D "ethernet-phy"; interface =3D <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[] =3D {48, 17, 18, 19, 20, 21, 22, 23, 90, 78, 84, = 72}; for (i=3D0;i<sizeof(bsp_irqs)/sizeof(bsp_irqs[0]);i++) virq =3D 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 =3D (struct net_device *)dev_id; struct ucc_geth_private *ugeth =3D 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 83xx: requesting external interrupts 2007-06-29 11:34 ` Joakim Tjernlund @ 2007-06-29 16:43 ` Ben Warren 2007-06-29 23:54 ` Andy Fleming 1 sibling, 0 replies; 10+ messages in thread From: Ben Warren @ 2007-06-29 16:43 UTC (permalink / raw) To: joakim.tjernlund; +Cc: linuxppc-embedded 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: > mdio@2320 { > #address-cells = <1>; > #size-cells = <0>; > reg = <2320 18>; > device_type = "mdio"; > compatible = "ucc_geth_phy"; > > phy1: ethernet-phy@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 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* Re: 83xx: requesting external interrupts 2007-06-29 11:34 ` Joakim Tjernlund 2007-06-29 16:43 ` Ben Warren @ 2007-06-29 23:54 ` Andy Fleming 2007-06-30 14:02 ` Joakim Tjernlund 1 sibling, 1 reply; 10+ messages in thread From: Andy Fleming @ 2007-06-29 23:54 UTC (permalink / raw) To: Joakim Tjernlund; +Cc: linuxppc-embedded On Jun 29, 2007, at 06:34, Joakim Tjernlund wrote: > mdio@2320 { > #address-cells = <1>; > #size-cells = <0>; > reg = <2320 18>; > device_type = "mdio"; > compatible = "ucc_geth_phy"; > > phy1: ethernet-phy@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]); 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
* RE: 83xx: requesting external interrupts 2007-06-29 23:54 ` Andy Fleming @ 2007-06-30 14:02 ` Joakim Tjernlund 0 siblings, 0 replies; 10+ messages in thread From: Joakim Tjernlund @ 2007-06-30 14:02 UTC (permalink / raw) To: 'Andy Fleming'; +Cc: linuxppc-embedded > -----Original Message----- > From: Andy Fleming [mailto:afleming@freescale.com] > Sent: den 30 juni 2007 01:55 > To: Joakim Tjernlund > Cc: bwarren@qstreams.com; linuxppc-embedded@ozlabs.org > Subject: Re: 83xx: requesting external interrupts > > > On Jun 29, 2007, at 06:34, Joakim Tjernlund wrote: > > mdio@2320 { > > #address-cells = <1>; > > #size-cells = <0>; > > reg = <2320 18>; > > device_type = "mdio"; > > compatible = "ucc_geth_phy"; > > > > phy1: ethernet-phy@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]); > > > 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 ^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2007-06-30 14:02 UTC | newest] Thread overview: 10+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2007-05-10 16:45 83xx: requesting external interrupts Alex Zeffertt 2007-05-10 17:07 ` Ben Warren [not found] ` <46443784.3060600@cambridgebroadband.com> 2007-05-11 14:12 ` Ben Warren 2007-05-11 20:15 ` Kumar Gala 2007-05-11 20:29 ` Ben Warren 2007-05-11 20:37 ` Kumar Gala 2007-06-29 11:34 ` Joakim Tjernlund 2007-06-29 16:43 ` Ben Warren 2007-06-29 23:54 ` Andy Fleming 2007-06-30 14:02 ` Joakim Tjernlund
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).