How can I use the GPIO 148 on the TX1 with L4T R28.1?

I’d like to control the GPIO 148 by sysfs on the TX1 with L4T R28.1 as below.
But an error occurs.

$ sudo su
$ echo 148 > /sys/class/gpio/export
$ bash: echo: write error: Device or resource busy

I can do it with L4T R24.1.
How can I use it with L4T R28.1?

Best Regards,

I don’t know which GPIO that corresponds to, but the numbers differ between R24.1 and R28.1. It’s unlikely you’re using the same GPIO despite the number being the same.

In the case of a GPIO which does exist the refusal to export tends to imply either the GPIO has already been assigned. There might be a similar error for controllers which are powered down for energy savings, but I am thinking of some of the non-GPIO controllers.

hi linuxdev,
Thanks for your generic comment.

In more details, I’d like to control the GPIO2/CAM0_RST# and the GPIO3/CAM1_RST# from the TX1 flashed by JetPack310 (L4T R28.1).

On the spreadsheet “Jetson_TX1_Generic_Customer_Pinmux_Customer_Release.xlsm”,
the GPIO2/CAM0_RST# is defined as GPIO3_PS_04 and
the GPIO3/CAM1_RST# is defined as GPIO3_PS_05.

I downloaded the source of L4T R28.1 and I refered to /hardware/nvidia/platform/t210/jetson/kernel-dts/jetson-platforms/tegra210-jetson-e-gpio-p2530-0930-e03.dtsi.
This file includes following.

:
TEGRA_GPIO(S, 4) 0
TEGRA_GPIO(S, 5) 0
:

The macro TEGRA_GPIO() is defined in the /hardware/nvidia/soc/tegra/kernel-include/dt-bindings/gpio/tegra-gpio.h.

:
#define TEGRA_GPIO_BANK_ID_S 18
:
#define TEGRA_GPIO(bank, offset) \
	((TEGRA_GPIO_BANK_ID_##bank * 8) + offset)

So, I think the GPIO number is correct…
GPIO2/CAM0_RST# is (188 + 4) = 148
GPIO3/CAM1_RST# is (18
8 + 5) = 149

In act, the CAM1_RST# can be controlled by GPIO149.

I hope NVIDIA give me something information.

Best Regards,

hello nanoto,

had you connect any camera sensor board to the Jetson platform?
your kernel message shown CAM0_RST pin is occupied.

hi JerryChang

Thanks for your reply.
No. I don’t connect any camera sensor board now.

Best Regards,

hi JerryChang

The file “Jetson_TX1_Generic_Customer_Pinmux_Customer_Release.xlsm” which I have was released on 2015-11-10.
If it is the old information, please give me the updated information corresponding to L4T R28.1.

Or …, if there is another way to control GPIO2/CAM0_RST# on the TX1 with the L4T R28.1, please tell me it.

Best Regards,

hello nanoto,

CAM0_RST pin is used for all camera reset.
you could also check camera device tree for reference.
r28.1/hardware/nvidia/platform/t210/jetson/kernel-dts/jetson-platforms/

looking for TEGRA_GPIO(S, 4) for more details.
thanks

hi JerryChang,

Thanks for your reply.
But, I already checked it. please see third posted message in this thread.

Is there any method to control the gpio 148 by us on TX1 with L4T R28.1?

Best Regards,

hello nanoto,

you can use the kernel APIs to control the gpio pins, please check the reference camera driver for example.

if (pw->reset_gpio) {
                 gpio_set_value(pw->reset_gpio, 0);
                 usleep_range(30, 50);
                 gpio_set_value(pw->reset_gpio, 1);
                 usleep_range(30, 50);
         }

hi JerryChang

Thanks for your comment.
I will try the APIs from a kernel module.

Best Regards,

hi JerryChang

Thank you very much.
I can change gpio 148 from kernel module.

Best Regards,

I think the gpio 148 can’t be used since are being used by other drivers/device (see en-vdd-vcm-2v8)

nvidia@tegra-ubuntu:~$ sudo cat /sys/kernel/debug/gpio
GPIOs 0-255, platform/6000d000.gpio, tegra-gpio:
gpio-2 ( |pcie_wake ) in hi
gpio-56 ( |wlan-default-output-) out hi
gpio-57 ( |rtl-5v0 ) out hi
gpio-58 ( |wlan-default-input-h) in lo IRQ
gpio-64 ( |wlan-default-output-) out hi
gpio-65 ( |wlan-default-input-i) in hi
gpio-67 ( |vdd-disp-3v0 ) out lo
gpio-148 ( |en-vdd-vcm-2v8 ) out lo
gpio-169 ( |lcd-bl-en ) out lo
gpio-188 ( |temp_alert ) in hi IRQ
gpio-189 ( |Power ) in hi IRQ
gpio-190 ( |Volume Up ) in hi IRQ
gpio-192 ( |Volume Down ) in hi IRQ
gpio-200 ( |extcon:extcon@1 ) in hi IRQ
gpio-201 ( |cd ) in hi IRQ
gpio-203 ( |en-vdd-sd ) out lo
gpio-204 ( |wp ) in lo
gpio-225 ( |hdmi2.0_hpd ) in lo IRQ
gpio-228 ( |usb-vbus1 ) in hi
gpio-229 ( |en-usb-vbus2 ) in hi

GPIOs 504-511, platform/max77620-gpio, max77620-gpio, can sleep:
gpio-504 ( |extcon:extcon@1 ) in lo
gpio-505 ( |vdd-sys-boost ) out hi
gpio-506 ( |spmic-default-output) out hi
gpio-507 ( |vdd-3v3 ) out hi
gpio-510 ( |enable ) out lo
gpio-511 ( |max77620-gpio7 ) out lo

Hi nanoto,

I am having the same issue as you with the Jetpack 3.3 installation for Jetson TX1 with Auvidea J106 as the carrier board. I want to use the GPIO 148 pin but I get the same error as you. Also, I checked the output of /sys/kernel/debug/gpio and found that GPIO 148 was being used by en-vdd-vcm-2v8 as can be seen in the output provided by ManuelLeiva.

Could you please elaborate on how you changed the GPIO using the kernel? I have never used any kernel API directly. Any help will be appreciated.

I can’t answer your question, but did you install the board support package from Auvidea? GPIO and other carrier board related setup may be completely different on the Auvidea board (which implies GPIO 148 might not even be available to you because of going to some other function which is different on the dev carrier board).

Hi linuxdev,

I did install BSP from Auvidea in the right way and infact GPIO 148 is available to me. It is in their manual that I need to toggle this pin for CSI cameras to work with their board.

The website of Ridgerun tells the same for the board I am using (J106). All I want to know is how to do something like this:

Basically the C/C++ code to control the GPIO. Could you help me with that?

I don’t have this board to test with and my camera knowledge is lacking. I don’t have the ability to tell you if this is the correct way to set up GPIO for this camera. Someone who has set up a camera on Auvidea can probably answer without guessing.

Hi ar13pit,

I created a kernel module and called gpio_set_value() in it.

Hi ar13pit,

I am using the J90LC.

Can you please advise which version of the firmware provided by AUVidea for the TX1 had you installed on your J106 carrier board when the GPIO 148 became available to you?

Maybe I can try the same on my J90LC just in case it works (even though the AUVidea pages say that the firmware available for TX1 is for the 100 series.)

Regards,
Ritvik