The problem of interrupt number in REQUST_IRQ function parameter in Linux

Source: Internet
Author: User

Pit bit:

Hardware colleague gave me a bit, told me that Spi-contrler's interrupt number is 89, let me check whether this spi-controler can be used. After three days, the read-write function was tested, but the interruption was impossible to enter. I am such a fool to do it recklessly:

REQUST_IRQ (89,spi_int_hander, irq_triger_rising, NULL, NULL);

Later asked my mentor, he said that the parameters in this function can not directly transmit the hardware interrupt number, obtained from the device tree, obtained when the core layer function mapping will break the corresponding index in the array as the parameter of this function. To this, such as clairvoyant, so I dispel enlightened.

Positive solution:

In the device tree:

Interrupt-parent = <&intc>;interrupt = <0 1>;  Shared interrupt, 57+32=89, trigger mode: rising edge. Shared interrupts in the device tree are reduced by 32, and private interrupts are reduced by 16  

  

In the driver code:

void Spi_controler_init (void) {int id,version;    Writel (0, SSIENR);    Writel (ten, BAUDR);    Writel (1, TXFTLR);    Writel (1, RXFTLR);    Writel (0x11, IMR);    Writel (0X4C7, CTRLR0);    Writel (0x02, CTRLR1);    id = READL (IDR);    Version = Readl (ssi_comp_version); PRINTK ("id=% #x, version=% #x \ n", ID, version);}    int irq;static int rf9808_probe (struct platform_device *dev) {struct Device_node *node; node = Of_find_compatible_node (Null,null, "SYSNOPSYS,SPI-PL");//spi_base_addr = Ioremap (ssi_base_addr, 0xff);//en_    SWICH_ADDR = Ioremap (0x4001001c, 4);    SPI_BASE_ADDR = of_iomap (node, 0);    EN_SWICH_ADDR = Of_iomap (node, 1);    IRQ = Of_irq_get (node,0);    PRINTK ("irq=%d \ n", IRQ);    Misc_dev = Kzalloc (sizeof (*misc_dev), Gfp_kernel);    Misc_dev->fops = &miscdev_fops;    Misc_dev->name = "Rf9808-test";    The main device number is constant 10, automatically assigned secondary device number Misc_dev->minor = Misc_dynamic_minor;    3. Register Misc Equipment Misc_register (Misc_dev); if (REQUEST_IRQ (irq,spiint_irq_handler, 0, "RF9808-test ", Misc_dev->this_device)) {PRINTK (kern_debug" requst IRQ failled \ n ");    } spi_controler_init (); return 0;}    static int rf9808_remove (struct platform_device *dev) {iounmap (SPI_BASE_ADDR);    Iounmap (EN_SWICH_ADDR);    FREE_IRQ (Irq,misc_dev->this_device);    Misc_deregister (Misc_dev);    Kfree (Misc_dev); return 0;} struct of_device_id dts_table[] = {{. compatible = ' SYSNOPSYS,SPI-PL '}, {},};struct platform_driver spi_pl = {. P Robe = rf9808_probe,. remove = Rf9808_remove,. Driver = {. Name = "Rf9808_test_driver",. of_match_tabl    E = dts_table,},};static int __init test_rf9808_init (void) {platform_driver_register (&AMP;SPI_PL); return 0;} /** * Nufront_cap_cleanup-driver un-registration call */static void __exit test_rf9808_cleanup (void) {Platform_driver _unregister (&AMP;SPI_PL);} Module_init (Test_rf9808_init); Module_exit (Test_rf9808_cleanup); Module_author ("Nufront,inc."); Module_license ("GPL"); Module_alias ("Spi:rf9808 "); 

  

Use the Of_irq_get () function to take the interrupt number from the device tree and then REQUEST_IRQ ().

The problem of interrupt number in REQUST_IRQ function parameter in Linux

Related Article

E-Commerce Solutions

Leverage the same tools powering the Alibaba Ecosystem

Learn more >

Apsara Conference 2019

The Rise of Data Intelligence, September 25th - 27th, Hangzhou, China

Learn more >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.