How to toggle the gpios offered by TCA9539 in TX2

I was trying to configure the TCA9539 chip on the tx2. I was trying to export the pin 252 and it said currently in use. On checking the /sys/kernel/debug/gpio , I got the following output

GPIOs 224-239, i2c/0-0077, tca9539, can sleep:
 gpio-227 (                    |en-vdd-sys          ) out lo    
 gpio-228 (                    |lcd-bias-en-rail    ) out hi    
 gpio-233 (                    |en-vdd-cam          ) out lo    
 gpio-234 (                    |en-vdd-cam-1v2      ) out lo    

GPIOs 240-255, i2c/0-0074, tca9539, can sleep:
 gpio-240 (                    |vdd-usb2-5v         ) out lo    
 gpio-241 (                    |en-vdd-ts-1v8       ) out hi    
 gpio-242 (                    |en-vdd-ts-hv-3v3    ) out hi    
 gpio-243 (                    |en-vdd-disp-3v3     ) out lo    
 gpio-244 (                    |vdd-fan             ) out lo    
 gpio-247 (                    |en-mdm-pwr-3v7      ) out lo    
 gpio-249 (                    |en-vdd-disp-1v8     ) out lo    
 gpio-250 (                    |dis-vdd-1v2         ) out hi    
 gpio-252 (                    |vdd-hdmi            ) out hi    
 gpio-253 (                    |en-vdd-cam-hv-2v8   ) out lo

This tells me that vdd-hdmi i.e.gpio 252 is currently in use.
But, if want to toggle any of the pin on it, then how should I go about it ?
Can anyone help me for the same ?


You might find this of use:

@linuxdev I saw your reply here and you suggested that “ One thing to notice about that file is that it doesn’t list unused GPIOs…it lists the assignment of GPIO which something has claimed use of. You can’t alter these without first removing whatever is using the GPIO ”
Original post here

The above links doesn’t talk about how to toggle gpios which are in use by the system. Can you let me know to approach the tca9539 module in the TX2?


If you look at the various forum threads you will find that “enable” uses an “echo > /sys/whatever…/export”. There is also an “unexport” file in the same directory as the “export” file (don’t recall the full path right now, about to go to sleep). If the GPIO is not in use, then you unexport the number. But, as the comment goes, you can’t unexport if something is using the pin.

Btw, if you want to discover where this is, then on any of the releases:

sudo -s
find /sys -name export | grep gpio

It may be that the device tree has set up something to use this, and in that case, you will need to edit the device tree. So try the echo of the number for the particular GPIO to the unexport file. If it says the device is busy, then we’d need to examine the device tree…but it may be something important is using that GPIO, so it won’t necessarily mean you can free it up.

What I do not know is which GPIO your module is using. You could assign any unused pin, but if it isn’t wired to the tca9539 module it won’t do much good. So the big question is this: How did you choose “252” for the GPIO? Is there a specific pin you have wired to (and is the dev carrier board used)?