Hi Scott,
Thanks for your and Yiping's reply. I have gotten the driver to work and access IRQ2. I hope what I have is correct. I'm posting answers to your questions as well as my updated code below.
Thanks!
Scott Wood wrote:
Your node has a compatible of "fsl,hello", but your code is looking for a node with a compatible of "hello". Are you seeing the "Error node not found" print?
I was not seeing the error message despite this being incorrect. Thanks for the note about the use of fsl, that was helpful. I changed it to hello, however it still did not work. I ended up having to change of_find_compatible_node(NULL,NULL,"hello"); to of_find_node_by_name(NULL,"hello"); for the node to be found.
Scott Wood wrote:
What is the virq value printed? If it's zero, that means that irq_of_parse_and_map() failed.
The value of virq was zero until the change above, and dts change below.
Scott Wood wrote:
Why are you casting the interrupt handler to int?
This was carried over, accidently, from the xbmd driver that we are using for Xilinx hardware. I missed that and have changed the interrupt handler to "irqreturn_t" which I have used in the past. I'm really not sure why the xbmd driver sets the interrupt handler to a static int fuction rather than irqreturn_t.
Update code:
DTS File:
I modified and moved this to pq3-mpic.dtsi. Note that IRQ2 is not a GPIO line.
I found these website helpful:
Device Tree Usage - FDTWiki
A Tutorial on the Device Tree (Zynq) -- Part I | xillybus.com
hello@1,0{
compatible = "hello";
#address-cells = <1>;
#size-cells = <0>;
reg = <1 0 0x1000>;
interrupts = <2 0 0 0>;
};
Driver:
np = of_find_node_by_name(NULL,"hello");
if (np == NULL)
{
printk("Error node not found\n");
}
printk("Node np = 0x%0x\n",np);
virq = irq_of_parse_and_map(np,0);
printk(KERN_INFO"hello_IRQHandler: ISR Setup VIRQ: %d \n" , virq);
if (0 > (error=request_irq(virq, &hello_IRQHandler, IRQF_SHARED, gDrvrName, "hello_label"))) {
printk(KERN_WARNING"hello_IRQHandler: Init: Unable to allocate IRQ error = %dd\n\n", error);
return -1;
}