CSI driver - interfere with gpio cells

Hi

We have a custom carrier board for Jetson TX2.
A CSI-2 camera from Allied Vision is connected to board.

We have downloaded the source code from AlliedVision github page, and integrated our changes to device tree with it, build the kernel and install driver module on Jetson.

All changes to device tree works correctly.

Only one of them interfere (in my opinion) with CSI driver.

I have defined a gpio-key in device tree:

gpio-keys {
		compatible = "gpio-keys";
		gpio-keys,name = "gpio-keys";
		status = "okay";

		
		can_wake {
			label = "CAN WAKE";
			gpios = <0x28 0x2c 0x1>;
			linux,code = <0x8f>;
			gpio-key,wakeup;
		};

	};

It works fine when flashed to Jetson without CSI driver installed.

But, when integrated to CSI driver source code and installed, the following error appears in serial console during boot time:

OF: /gpio-keys/can_wake: could not get #gpio-cells for /host1x/nvcsi@150c0000/channel@1/ports/port@0/endpoint@2
[    1.467610] gpio-keys gpio-keys: Failed to get gpio flags, error: -22

I dumped the device tree from /proc/device-tree and see the nvcsi@150c0000 section:

		nvcsi@150c0000 {
			num-channels = <0x3>;
			power-domains = <0x1f 0xb>;
			compatible = "nvidia,tegra186-nvcsi";
			clocks = <0x10 0xb4 0x10 0xb5 0x10 0x20e 0x10 0x10d>;
			resets = <0x10 0x58>;
			num-ports = <0x6>;
			clock-names = "nvcsi", "nvcsilp", "nvcsi_parent", "nvcsilp_parent";
			status = "okay";
			#address-cells = <0x1>;
			interrupts = <0x0 0x77 0x4>;
			#size-cells = <0x0>;
			iommu-group-id = <0x1>;
			reg = <0x0 0x150c0000 0x0 0x40000>;
			iommus = <0x11 0x2>;
			nvidia,csi_regulator = "avdd_dsi_csi";

			channel@2 {
				status = "okay";
				reg = <0x2>;

				ports {
					#address-cells = <0x1>;
					#size-cells = <0x0>;

					port@1 {
						status = "okay";
						reg = <0x1>;

						endpoint@5 {
							remote-endpoint = <0x5f>;
							status = "okay";
							phandle = <0x62>;
							linux,phandle = <0x62>;
						};
					};

					port@0 {
						status = "okay";
						reg = <0x0>;

						endpoint@4 {
							port-index = <0x2>;
							remote-endpoint = <0x5e>;
							status = "okay";
							bus-width = <0x4>;
							phandle = <0x2a>;
							linux,phandle = <0x2a>;
						};
					};
				};
			};

			channel@0 {
				status = "okay";
				reg = <0x0>;

				ports {
					#address-cells = <0x1>;
					#size-cells = <0x0>;

					port@1 {
						status = "okay";
						reg = <0x1>;

						endpoint@1 {
							remote-endpoint = <0x5b>;
							status = "okay";
							phandle = <0x60>;
							linux,phandle = <0x60>;
						};
					};

					port@0 {
						status = "okay";
						reg = <0x0>;

						endpoint@0 {
							port-index = <0x0>;
							remote-endpoint = <0x5a>;
							status = "okay";
							bus-width = <0x4>;
							phandle = <0x2d>;
							linux,phandle = <0x2d>;
						};
					};
				};
			};

			channel@1 {
				status = "okay";
				reg = <0x1>;

				ports {
					#address-cells = <0x1>;
					#size-cells = <0x0>;

					port@1 {
						status = "okay";
						reg = <0x1>;

						endpoint@3 {
							remote-endpoint = <0x5d>;
							status = "okay";
							phandle = <0x61>;
							linux,phandle = <0x61>;
						};
					};

					port@0 {
						status = "okay";
						reg = <0x0>;

						endpoint@2 {
							port-index = <0x1>;
							remote-endpoint = <0x5c>;
							status = "okay";
							bus-width = <0x4>;
							phandle = <0x28>;
							linux,phandle = <0x28>;
						};
					};
				};
			};
		};

Looks the problem is related to channel@1/ports/port@0/endpoint@2 of the nvcsi@150c0000 node.

Would you please help to solve this problem?

Thanks in advance for your help.

hello AliHaeri,

what’s the field of your gpio-keys {} definition, is it within the same scope of your camera i2c? for example, i2c@3180000 {}.
please see-also reference camera driver to obtain the camera control gpio.
for example, IMX274, reset-gpios.
$public_sources/kernel_src/hardware/nvidia/platform/t18x/common/kernel-dts/t18x-common-platforms/tegra186-quill-camera-imx274-a00.dtsi

Hello JerryChang,

I checked the i2c@3180000{}

I found the cause of my problem.

before installing the driver, I de-compiled the dtb file in Linux_for_Tegra/kernel/dtb directory, and add my own gpio-key node:

gpio-keys {
		compatible = "gpio-keys";
		gpio-keys,name = "gpio-keys";
		status = "okay";

		
		can_wake {
			label = "CAN WAKE";
			gpios = <0x28 0x2c 0x1>;
			linux,code = <0x8f>;
			gpio-key,wakeup;
		};

	};

The first value in this line : gpios = <0x28 0x2c 0x1>; (0x28) is similar to other gpio-key nodes, and 0x2c is the hex value of the gpio number offset.

But, when de-compile the dtb file resulting from building the driver source, the above value is 0x29 in all gpio-key nodes.

My problem was due to defining my node with 0x28, as in original dtb file…

I don’t know what exactly this value is. I found no information in this link:

https://www.kernel.org/doc/Documentation/devicetree/bindings/input/gpio-keys.txt

Anyway, my problem is solved.

Thanks.

hello AliHaeri,

the gpio definition in device tree looks like below… gpios = <field, number, state>
here’s an other example, gpios = <&tegra_aon_gpio TEGRA_AON_GPIO(FF, 0) GPIO_ACTIVE_LOW>;

1 Like

Thanks JerryChang!
Got it!

I searched the dts file for tegra_aon_gpio. In __symbols__ section, there is a line like this:

tegra_aon_gpio = "/gpio@c2f0000";

And then, looked at the gpio@c2f0000 node in device tree:

gpio@c2f0000 {
        .........
        .........
		compatible = "nvidia,tegra186-gpio-aon";
		reg-names = "security", "gpio";
		gpio-controller;
		status = "okay";
		#interrupt-cells = <0x2>;
		interrupts = <0x0 0x3c 0x4>;
		phandle = <0x29>;
		linux,phandle = <0x29>;
	};

the phandle and linux,phandle fields show the correct value…

So, I conclude that if I define my gpio node as you mentioned (using & and related symbols, instead of “hard” values), there will be no problem.

Thanks JerryChang.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.