Right way to get the gpio values from the device tree in the device driver for BeagleboneBlack

124 views
Skip to first unread message

Jane

unread,
Aug 19, 2016, 12:03:56 AM8/19/16
to BeagleBoard
Hello,

This topic is not solely related to beagleboneBlack , still posting on this group .

With reference to the example below what is the correct way to get the gpio values from the device tree :

I modified the existing leds-ns2 device tree as below(slow1 ,cmd1) :


          blue-sata {

                   label = "ns2:blue:sata";

                   slow-gpio = <&gpio0 29 0>;

                   cmd-gpio = <&gpio0 30 0>;

+                 slow1-gpio=<&gpio 31 0>;

+                 cmd1-gpio=<&gpio 32 0>;

                   modes-map = <NS_V2_LED_OFF  0 1

                                NS_V2_LED_ON   1 0

                                NS_V2_LED_ON   0 0

                                NS_V2_LED_SATA 1 1>;

           };

 

 

And modified the driver by adding slow1 and cmd1 in all the structure (just like slow and cmd) in the attached leds-ns2.c driver

But when I am trying to get the gpio number for slow1 and cmd1 I am getting the below error(number gpio #31 and 32 are random numbers of gpio for testing, does it matters?) :

error : leds-ns2:probe of ns2-leds failed with error -2.What does error code -2 represents ?Is this a device tree parsing error?

ret = of_get_named_gpio(child, "slow1-gpio", 0);

                 if (ret < 0)

                         return ret;

same error if I try to get the cmd1-gpio . 
 

Thanks in advance !

Regards,

Rp
leds-ns2.c

William Hermans

unread,
Aug 19, 2016, 5:15:03 AM8/19/16
to beagl...@googlegroups.com

--
For more options, visit http://beagleboard.org/discuss
---
You received this message because you are subscribed to the Google Groups "BeagleBoard" group.
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/beagleboard/4f1ce45b-5a75-4152-a93d-ea33f2df87bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Raulp

unread,
Aug 19, 2016, 7:52:04 AM8/19/16
to BeagleBoard
Thanks , I figured it out ! I was not putting the valid gpio in the <&gpio0 <here> 0> 
To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages