I'm trying to get an interrupt whenever the UART line gets data on the BeagleBone Black. However, I'm stuck on figuring out how to register the handler. I can use request_irq()
to register GPIO interrupts for example, but trying to get the irq for the UART doesn't seem to work. I believe 73 is the right number, as after registering it, reading from /dev/ttyO1
(the UART dev file) throws an error, but the handler never triggers.
Am I approaching this right? What I'm currently trying is below. Thanks.
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/interrupt.h>
#include <asm/io.h>
#define KERNEL_NAME "TestKernel"
#define IRQ_NUMBER 73
int id = 8273643;
irq_handler_t handler(int irq, void* dev_id, struct pt_regs* regs)
{
printk(KERN_ALERT KERNEL_NAME ": Handler called, irq: %d\n", irq);
return (irq_handler_t)IRQ_HANDLED;
}
static int __init driver_entry(void)
{
int result = request_irq(IRQ_NUMBER, (irq_handler_t)handler, 0, "test", &id);
printk(KERN_ALERT KERNEL_NAME ": Insert successful, result: %d\n", result);
return result;
}
static void __exit driver_exit(void)
{
free_irq(IRQ_NUMBER, NULL);
printk(KERN_ALERT KERNEL_NAME ": Cleanup\n");
}
module_init(driver_entry);
module_exit(driver_exit);
MODULE_LICENSE("GPL");