How do we allocate virtual floppy irq on sparc64
Hi David / Thomas.
I'm trying to understand how we deal with floppy irq on sparc64.
In arch/sparc/include/asm/floppy_64.h we have:
error = request_irq(FLOPPY_IRQ, sparc_floppy_irq,
IRQF_DISABLED, "floppy", NULL);
FLOPPY_IRQ is set equal op->archdata.irqs[0] in sun_floppy_init(). So FLOPPY_IRQ is the platform irq - and not a virtual irq.
But as I understand request_irq(...) takes a virtual irq as parameter. But I see no-where in the code where we allocate the virtual irq that is equal to op->archdata.irqs[0].
I am looking into this because on sparc32 I need to come up with something to deal with the floppy interrupt.
I was about to write something that allocated a virtual irq for the floppy irq - but wanted to check how other archs deal with the same. And now I am confused as I do not see how it is done...
Can you help sched some light on this?
If there is some other arch I could look at to be inspired then please let me know.
PS. sun4m boots with my latest genirq patchset :-)
But build fails if I eable FDC which I am looking at now.
Sam
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Thu, 17 Feb 2011 21:57:48 +0100
Quoted 9 lines
I'm trying to understand how we deal with floppy irq on sparc64.
In
arch/sparc/include/asm/floppy_64.hwe have:error = request_irq(FLOPPY_IRQ,
sparc_floppy_irq,
IRQF_DISABLED, "floppy", NULL);
FLOPPY_IRQis set equal op->archdata.irqs[0] insun_floppy_init(). SoFLOPPY_IRQis the platform irq - and not a virtual irq.
The archdata IRQ is actually the computed virtual IRQ.
This is the same as how we fetch the IRQ to use in other "OF" platform drivers.
Look at drivers/net/sunhme.c's OF platform driver probing, it uses of->archdata.irqs[0] as the IRQ.
David Miller
maintainerFrom: David Miller <[email protected]>
Date: Thu, 17 Feb 2011 13:05:03 -0800 (PST)
Quoted 13 lines
From: Sam Ravnborg <[email protected]>
Date: Thu, 17 Feb 2011 21:57:48 +0100Quoted 9 lines
I'm trying to understand how we deal with floppy irq on sparc64.
In
arch/sparc/include/asm/floppy_64.hwe have:error = request_irq(FLOPPY_IRQ,
sparc_floppy_irq,
IRQF_DISABLED, "floppy", NULL);
FLOPPY_IRQis set equal op->archdata.irqs[0] insun_floppy_init(). SoFLOPPY_IRQis the platform irq - and not a virtual irq.
Quoted 7 lines
The archdata IRQ is actually the computed virtual IRQ.
This is the same as how we fetch the IRQ to use in other "OF" platform drivers.
Look at drivers/net/sunhme.c's OF platform driver probing, it uses of->archdata.irqs[0] as the IRQ.
BTW, if you're looking for where this is computed, look in arch/sparc/kernel/of_device_64.c:scan_one_device() and build_one_device_irq().
Quoted 13 lines · David Miller
From: Sam Ravnborg <[email protected]>
Date: Thu, 17 Feb 2011 21:57:48 +0100Quoted 9 lines
I'm trying to understand how we deal with floppy irq on sparc64.
In
arch/sparc/include/asm/floppy_64.hwe have:error = request_irq(FLOPPY_IRQ,
sparc_floppy_irq,
IRQF_DISABLED, "floppy", NULL);
FLOPPY_IRQis set equal op->archdata.irqs[0] insun_floppy_init(). SoFLOPPY_IRQis the platform irq - and not a virtual irq.
Quoted 7 lines
The archdata IRQ is actually the computed virtual IRQ.
This is the same as how we fetch the IRQ to use in other "OF" platform drivers.
Look at drivers/net/sunhme.c's OF platform driver probing, it uses of->archdata.irqs[0] as the IRQ.
Obvious - now that you spell it out for me.
For sparc32 I already in my tree call build_device_irq in of_device_32.c:__init scan_one_device().
So I just have to look up the platform_device for floppy in floppy_32.h and pick irq from that.
If I look for "SUNW,fdtwo" it should work on my box at least. And I checked a few of the prtconfs you have in your git repositry - several boxes uses this.
ss2 however name it "fd" - so I need to check for that too. Same for ipx.
So I will look up "SUNW,fdtwo" + "fd" to find the platform_device for floppy.
And in that platform_device I can find the already allocated irq.
Sam
Quoted 4 lines
So I will look up "SUNW,fdtwo" + "fd" to find the
platform_devicefor floppy.
And in thatplatform_deviceI can find the already allocated irq.
Looks like this in patch format.
Not tested yet as I still need to adapt irq_32.c...
Sam
arch/sparc/include/asm/floppy_32.h +23 -1
@@ -303,6 +303,8 @@ static struct linux_prom_registers fd_regs[2];static int sun_floppy_init (void ) { +struct platform_device *op; +struct device_node *dp;char state[128 ];phandle tnode, fd_node;int num_regs;
@@ -310,7 +312,6 @@ static int sun_floppy_init(void) use_virtual_dma =1 ; -FLOPPY_IRQ =11 ;/* Forget it if we aren't on a machine that could possibly * ever have a floppy drive. */
@@ -349,6 +350,26 @@ static int sun_floppy_init(void) sun_fdc = (struct sun_flpy_controller *)of_ioremap (&r,0 , fd_regs[0 ].reg_size,"floppy" ); +/* +* Look up irq in platform_device. +* We try "SUNW,fdtwo" and "fd" +*/ +for_each_node_by_name (dp,"SUNW,fdtwo" ) { + op =of_find_device_by_node (dp); +if (op) +break ; + } +if (!op) { +for_each_node_by_name (dp,"fd" ) { + op =of_find_device_by_node (dp); +if (op) +break ; + } + } +if (!op) + goto no_sun_fdc; + +FLOPPY_IRQ = op->archdata.irqs[0 ]; +/* Last minute sanity check... */ if (sun_fdc->status_82072 =0xff ) {
sun_fdc = NULL;
David Miller
maintainerFrom: Sam Ravnborg <[email protected]>
Date: Thu, 17 Feb 2011 23:17:40 +0100
Quoted 7 lines
Quoted 4 lines
So I will look up "SUNW,fdtwo" + "fd" to find the
platform_devicefor floppy.
And in thatplatform_deviceI can find the already allocated irq.Looks like this in patch format.
Not tested yet as I still need to adaptirq_32.c...
Sure, that'll work.
Eventually both floppy_{32,64}.h should be converted to proper OF probing code.