Home > OS >  Obtained from the device tree gpio its numerical represent what mean
Obtained from the device tree gpio its numerical represent what mean

Time:09-17

Such as the following this device tree node
{
buttonsCompatible="jz2440_button";
Eint - pins=& lt; & GPF 0 0 & gt; , & lt; & GPF 2 0 & gt; , & lt; & GPG 3 0 & gt; , & lt; & GPG 11 0 & gt;;
Interrupts - extended=& lt; & Id 0 0 0 3 & gt; ,
<& Id 0 0, 2, 3, & gt; ,
<& GPG 3 3 & gt; ,
<& GPG 11 3 & gt;;
};

I use the following code in the drive for gpio and interrupt
 for (I=0; i<(sizeof (pins_desc)/sizeof (pins_desc [0])); I++) 
{
Res=platform_get_resource (pdev IORESOURCE_IRQ, I);//get irq resource
If (res)
{
Pins_desc [I] irq=res - & gt; The start;
Printk (" get irq: % d \ n ", pins_desc [I] irq);
}
The else
{
Printk (" can 't get irq: % d \ n ", I);
return -1;
}
Pins_desc [I]. Pin=of_get_named_gpio (dev_node, "eint - pins", I);//to look for in the node name for eint - pins attribute
Printk (" pins_desc [% d] pin=% d \ n ", I, pins_desc [I] pin);
}


Print out the following fields
Get an irq: 1
Pins_desc [0]. Pin=84
Get an irq: 2
Pins_desc [1]. The pin=86
Get an irq: 3
Pins_desc [2]. Pin=95
Get an irq: 15
Pins_desc [3]. The pin=103

The pin Numbers and gpio is actually how a corresponding relationship?
  • Related