简体   繁体   中英

Mapping DMA interrupts in the linux kernel

I'm writing a kernel module for a powerpc SoC which contains a DMA controller. I want to map the DMA interrupts in the linux kernel. my DMA structure has two interrupts:

struct dma
{
  u32 dma1;
  u32 dma2;
}*dma;

I have memory mapped the DMA structure in the Kernel. I have used the function irq_of_parse_and_map() to get the virq number to the corresponding interrupts.

dma->dma1=irq_of_parse_and_map(ofdev->node,0);
dma->dma2=irq_of_parse_and_map(ofdev->node,1);

but i cant get the virq numbers for the above interrupts. What APIs might be available to access the VIRQ numbers?

PowerPC based system uses a Device Tree Blob (DTB) , also referred as Device Tree Source (DTS) , which is a database that represents the hardware components (Processor Configuration, Buses, Peripherals etc...) on a given board. Linux kernel during its bootup expects certain information on the hardware that it runs on. Hardware information is passed from DTB to kernel by the bootloader software (eg: u-boot) as per Open Firmware standard. Once kernel get the hardware information, it will do all the software setup as a part of the kernel initilization routine.

From here on if any kernel software component (eg: device driver) needs hardware detail, it should get it from the kernel by using a set of Open Firmware Standard Binary Interfaces . Some of them are listed below:

of_register_platform_driver()   - Register driver for device
of_unregister_platform_driver() - Unregister driver for device 
of_address_to_resource()    - Obtain physical address of peripheral
of_get_property()           - Find property with a given name for a given node
of_find_node_by_phandle()   - Find a node given a phandle
irq_of_parse_and_map()      - Parse and map an interrupt into linux virq space
of_irq_to_resourse()        - Obtain virtual IRQ of peripheral
...
...

Now coming to the problem raised here. irq_of_parse_and_map() is used to parse and map an interrupt into linux virq space. Usually this will be done by the Interrupt Controller device driver of the system. Once the interrupt mapping is done, you can get the Interrupt Source virq by referring to of_irq_to_resource() call. This step will be required for registering interrupt handler to the interrupt source. So try using of_irq_to_resource() instead of irq_of_parse_and_map() .

Ref:

Device Tree Blob: http://www.informit.com/articles/article.aspx?p=1647051&seqNum=5

Open Firmware: http://www.openfirmware.org/

OF IRQ Interface: linux-2.6/drivers/of/irq.c

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM