The Hardware Connection The MPSoC can receive two sets of interrupt signals from the PL. In Vivado, you can enable this by navigating to PS-PL Configuration → General → Interrupts → PL to PS → IRQ0/IRQ1.
The corresponding hardware interrupt numbers are as follows: PL PS Group 0: 121–128 PL PS Group 1: 136–143
These two interrupt lines can be connected to either an IP’s interrupt signal in IPI or to custom logic written in Verilog. If multiple interrupt sources need to be combined into a single group, you can use the `concat` module to merge them before connecting to the IRQ pin.
If you want to introduce an interrupt signal from a Verilog module, you can right-click in the IPI and select "Create Port." Make sure to set the Port Type to "Interrupt."
Hardware and Software Bridge: Device Tree
How does the hardware information get passed to the software system? The answer for Linux is the Device Tree.
Here is the device tree generated automatically by the Device Tree Generator for the AXI UARTLite in the example:
axi_uartlite_0: serial@a0000000 { clocks = <&misc_clk_0>; compatible = "xlnx,xps-uartlite-1.00.a"; current-speed = <115200>; device_type = "serial"; interrupt-parent = <&gic>; interrupts = <0 89 1>; port-number = <1>; reg = <0x0 0xa0000000 0x0 0x10000>; xlnx,baudrate = <0x2580>; xlnx,data-bits = <0x8>; xlnx,odd-parity = <0x0>; xlnx,s-axi-aclk-freq-hz-d = "99.999"; xlnx,use-parity = <0x0>; };
Creating the Device Tree A device tree is a plain text file with a .dts or .dtsi extension. While it's possible to write one from scratch, Xilinx provides tools to automate the process. One common method is using PetaLinux, which automatically generates the device tree when importing an HDF file during the petalinux-build process. You can then manually adjust the file, but keep in mind that it may be overwritten on regeneration.
Another approach is using the SDK. The SDK can load the Device Tree Generator (DTG) as part of the BSP generation. You can download DTG from [https://github.com/Xilinx/device-tree-xlnx](https://github.com/Xilinx/device-tree-xlnx). Once downloaded, add the folder to the SDK’s Xilinx Tools → Repositories. Then create a new BSP and select the device_tree option.
Note: For SDx users, the DTG loading path is Window → Preference → Xilinx SDK → Repositories.
Interrupt Properties in Device Tree
The interrupt definition in the device tree includes two main properties: interrupts
and interrupt-parent
. The interrupt-parent
points to the interrupt controller, such as GIC, GPIO, or PCIe.
The interrupts
property specifies the interrupt number and type. The exact meaning of these values is defined in the interrupts.txt
binding file. It’s important to note that each interrupt controller defines the number of cells required via the #interrupt-cells
property. For example, the ARM GIC uses 3 cells:
- First cell: indicates the interrupt type (0 for SPI, 1 for PPI).
- Second cell: the actual interrupt number.
- Third cell: the trigger mode (e.g., edge or level triggered).
For SPI interrupts, the first cell should be 0. The second cell contains the interrupt number, and the third specifies the trigger type (e.g., 1 for edge, 4 for level).
Determining the Interrupt Number When specifying the interrupt number in the device tree, subtract 32 from the hardware interrupt number. This gives the virtual interrupt number used by the operating system.
Writing an Interrupt Driver
PetaLinux comes with an example of an interrupt service routine. You can create a sample module using the command: petalinux-create -t modules -n mymodule
.
The code snippet below shows how the driver retrieves the interrupt number from the device tree:
/* Get IRQ for the device */ r_irq = platform_get_resource(pdev, IORESOURCE_IRQ, 0); if (!r_irq) { dev_info(dev, "no IRQ found"); dev_info(dev, "mymodule at 0x%08x mapped to 0x%08x", (unsigned int __force) lp->mem_start, (unsigned int __force) lp->base_addr); return 0; } lp->irq = r_irq->start; rc = request_irq(lp->irq, &mymodule_irq, 0, DRIVER_NAME, lp); if (rc) { dev_err(dev, "testmodule: Could not allocate interrupt %d.", lp->irq); goto error3; }
Note that the code reads the interrupt number from the device tree and assigns the OS a virtual interrupt number. Previously, developers manually hard-coded the interrupt number in C code, but this is no longer recommended. Always use the virtual interrupt number method for better compatibility and flexibility.
MTU Gas Generator Powered by MTU gas engine, alternator, radiator, controller, base frame;
. World Famous diesel engine brand: MTU Gas engine
. World famous AC alternator brand: Stamford, Leroy Somer, Mecc Alte, Marathon, Faraday, SWT
. World famous genset controller brand: Deepsea, ComAp, Deif, SmartGen, Motortech
. Gas Control System: Ignition system, Gas Throttle System, Ga Mixer System, Gas Train Valve System
. Start Battery system
. Optional for Remote Cooling system with CHP & CCHP Control
. CHP- Combine with Heat and Power Electrical system
.CCHP- Combine with Cold, Heat and Power electrical system
Gas Engine,Mtu Gas Genset,Mtu Gas Generator,Mtu Biogas Generato
Guangdong Superwatt Power Equipment Co., Ltd , https://www.swtgenset.com