How can I use GPIO used by "kernel"?

Hi,

I’m on JP6.1, testing original image on a devkit. I need to control GPIO PM.00, but it seems that it already has an owner: “kernel”:

nvidia@ubuntu:~$ sudo gpioinfo | grep -i PM.00
	line  76:      "PM.00"       kernel   input  active-high [used]

I checked the DT files and found this:

	display@13800000 {
		/* os_gpio_hotplug_a is used for hotplug */
		os_gpio_hotplug_a = <&gpio TEGRA234_MAIN_GPIO(M, 0) GPIO_ACTIVE_HIGH>;
		status = "okay";
	};

As I don’t need the display, I disabled that node: (status=“disabled”). However, after re-compiling and updating the DT, the GPIO owner is still “kernel”.
On JP5, the GPIO is free to be used.

Is there something else that is defining the owner? I’m curious because, usually if a driver owns the GPIO we see the selected gpio name instead of just “kernel”, for example:

nvidia@ubuntu:~$ sudo gpioinfo | grep -i PH.03
	line  46:      "PH.03" "camera-control-output-low" output active-high [used]

Could you help me disable that kernel owning on JP6 to be able to use it?
Thank you!

I am not sure how you updated the device tree. Everything related to display must go with full reflash because there is another DCE firmware to handle display request. If you don’t do full reflash, then DCE side won’t get updated.

Hi @WayneWWW

Thank you for your answer! However, I tried reflashing the board and I still see the same problem.
I already tried disabling the nodes related to the display from the device-tree: I removed the display@13800000 and dce@d800000 nodes from the device-tree. I also removed the tegra234-dcb-p3737-0000-p3701-0000.dtsi include.

Do you think am I missing something?

I still see the resource being used by “kernel” and I noticed some others gpios are also used by kernel:

	line  56:      "PI.05"       kernel   input  active-high [used]
	line  76:      "PM.00"       kernel   input  active-high [used]
	line  114:      "PX.00"       kernel   input  active-high [used]
	line  115:      "PX.01"       kernel   input  active-high [used]

I checked that on JP5, all of those gpios are unused. So, it looks like until JP6, this kernel owner appears.

Is there a way to know which controls these resources when they are labeled as “kernel”?
I would like to track the right owner of the gpio to disable it and be able to control it myself.

Thanks

Instead of “remove them”, could you try to do it by “disable them”? Set the status to disabled.

Thanks but I already tried that. However, as it didn’t work I tried to remove the whole nodes.
Do you have more ideas?

Thank you!

Could you try to remove DCE and display related overlay in the board config files?

Well, according to the log from the sdkmanager when I flashed, the board name is “jetson-orin-nano-devkit”. So, checking the jetson-orin-nano-devkit.conf, I just see one overlay:

OVERLAY_DTB_FILE+=",tegra234-p3768-0000+p3767-0000-dynamic.dtbo";

I de-compiled that dtbo and it doesn’t have anything related to the display.

Just to clarify on my previous test I could disable the display, but the PM.00 gpio was still used by “kernel”.

Make sure DCE_OVERLAY_DTB_FILE field is empty.

Also, please rmmod nvidia.ko and nvidia-modeset.ko.

I verified that DCE_OVERLAY_DTB_FILE is empty.
I also tried removing all the kernel modules that I could leaving just these:

Module                  Size  Used by
lzo_rle                16384  36
lzo_compress           16384  1 lzo_rle
zram                   32768  12
zsmalloc               36864  1 zram
usb_f_ncm              28672  2
usb_f_mass_storage     53248  2
usb_f_acm              16384  2
u_serial               20480  3 usb_f_acm
usb_f_rndis            32768  2
u_ether                32768  2 usb_f_rndis,usb_f_ncm
libcomposite           65536  16 usb_f_rndis,usb_f_mass_storage,usb_f_acm,usb_f_ncm
crct10dif_ce           20480  1
fuse                  143360  5
ipv6                  503808  90
nvme                   49152  2
nvme_core             106496  3 nvme
phy_tegra194_p2u       16384  9
pcie_tegra194          40960  0

I also tried disabling the much services that I could, leaving just these:

nvidia@ubuntu:~$ systemctl --type=service --state=running
  UNIT                     LOAD   ACTIVE SUB     DESCRIPTION                
  dbus.service             loaded active running D-Bus System Message Bus
  rsyslog.service          loaded active running System Logging Service
  ssh.service              loaded active running OpenBSD Secure Shell server
  systemd-journald.service loaded active running Journal Service

I’m wondering if this kernel owning is defined by a binary file used at bootime or something different than a device-tree or kernel driver.

Hi,

Some queries here

  1. Did you try toggling in spite of status “used” ? does this work ?
  2. Did you try rebooting after rmmod ?
  3. Does cat /sys/kernel/debug/gpio shows as occupied or free state of this GPIO?

Hi @WayneWWW

Here are my comments:

  1. Yes, I tried changing it’s value but I get this:
gpioset --mode=wait `gpiofind "PM.00"`=0
gpioset: error setting the GPIO line values: Invalid argument

That didn’t happend for example PM.01, which is not used:

gpioset --mode=wait `gpiofind "PM.01"`=0
# No error, it hangs
  1. What’s the point of rebooting after doing an rmmod, if after rebooting the board, the driver will be automatically loaded again? I tried removing the .ko files from the /lib directory to avoid the loading at all and I still seeing the problem. I also checked that the modules are not loaded at all with my first DTB changes removing the display nodes.

  2. I already checked that, and it’s weird because the state of that is free. However gpioinfo says that is busy, so there’s a contradiction:

sudo cat /sys/kernel/debug/gpio | grep -i PM.00
gpio-424 (PM.00               )
sudo gpioinfo | grep -i PM.00
	line  76:      "PM.00"       kernel   input  active-high [used]

The result of /sys/kernel/debug/gpio is a weird one. I will need some further check for what is going on there.

Yes, it’s very strange. Thank you, please let me know if you find something I can try.