LogoLogo
Auvidea.euDocumentationImprint
  • 📓MANUAL
    • J20 Overview
    • Pinout Description
    • Camera adaptation
  • 🔗RELEVANT LINKS
    • 🎛️Software setup - Guide
    • 🚦GPIO - Guide
    • 📷CSI Camera - Guide
Powered by GitBook
On this page
  • Implementing GPIO extender
  • CSI-Routing
  • Example CSI/VI implementation

Was this helpful?

Export as PDF
  1. MANUAL

Camera adaptation

PreviousPinout Description

Last updated 1 year ago

Was this helpful?

This page is only for experienced users. It requires knowledge and experience about the following topics:

  • Kernel development

  • Devicetree syntax

The and its documentation about the Jetson family is a good way to get started with those kinds of work. You may start with taking a look at the Guide from Nvidia.

Auvidea can also provide a quote, if you need a custom devicetree for your CSI camera on the J20, if needed. Contact sales@auvidea.eu or support@auvidea.eu for more information.

Implementing GPIO extender

The GPIO expander populated on the J20 is used to control the mclock and power-down GPIO's on each CSI connector. Auvidea recommends implementing this chip in the Devicetree as GPIO-Chip in order to use those GPIO's directly as reset-gpio in the camera device node.

GPIO
Note

P15

CAM_A_PWDN

P14

CAM_B_PWDN

P13

CAM_A_MCLK

P12

CAM_B_MCLK

P11

CAM_C_PWDN

P10

CAM_D_PWDN

P9

CAM_C_MCLK

P8

CAM_D_MCLK

P7

CAM_E_PWDN

P6

CAM_F_PWDN

P5

CAM_E_MCLK

P4

CAM_F_MCLK

P3

Not connected

P2

Not connected

P1

Not connected

P0

LED_GPIO

Represented in the device tree for the AGX Orin would look like this:

j20_port_extender.dtsi
/*
 * Copyright (c) 2023, AUVIDEA. All rights reserved.
 * 
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or any
 * later version.
 * 
 * This program is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
 * more details.
 */

/ {
	i2c@3180000 {
		tca6416_cam: cam_gpio_expander@20 {
			compatible = "ti,tca6416";
			reg = <0x20>;
			gpio-controller;
			#gpio-cells = <2>;
 
			led {
				gpio-hog;
				gpios = <0 0>;
				output-low;
				line-name = "led";
			};

			cam_g_rst {
				gpio-hog;
				gpios = <6 0>;
				output-high;
				line-name = "cam_g_mclk";
			};
			cam_g_pwdn {
				gpio-hog;
				gpios = <4 0>;
				output-low;
				line-name = "cam_g_pwdn";
			};
			cam_e_rst {
				gpio-hog;
				gpios = <7 0>;
				output-high;
				line-name = "cam_e_mclk";
			};
			cam_e_pwdn {
				gpio-hog;
				gpios = <5 0>;
				output-low;
				line-name = "cam_e_pwdn";
			};
			cam_d_rst {
				gpio-hog;
				gpios = <10 0>;
				output-high;
				line-name = "cam_d_mclk";
			};
			cam_d_pwdn {
				gpio-hog;
				gpios = <8 0>;
				output-low;
				line-name = "cam_d_pwdn";
			};
			cam_c_rst {
				gpio-hog;
				gpios = <11 0>;
				output-high;
				line-name = "cam_c_mclk";
			};
			cam_c_pwdn {
				gpio-hog;
				gpios = <9 0>;
				output-low;
				line-name = "cam_c_pwdn";
			};
			cam_b_rst {
				gpio-hog;
				gpios = <14 0>;
				output-high;
				line-name = "cam_b_mclk";
			};
			cam_b_pwdn {
				gpio-hog;
				gpios = <12 0>;
				output-low;
				line-name = "cam_b_pwdn";
			};
			cam_a_rst {
				gpio-hog;
				gpios = <15 0>;
				output-high;
				line-name = "cam_a_mclk";
			};
			cam_a_pwdn {
				gpio-hog;
				gpios = <13 0>;
				output-low;
				line-name = "cam_a_pwdn";
			};
		};
	};
};

Each camera node (if the driver supports this feature) contains a reset-gpio that can be assinged to one of the implemented GPIO's in the code above. An example usage of one of those GPIO's can be found in the following code in the reset-gpio property.

imx219.dtsi
[...]
	i2c@31e0000 {
		rbpcv2_imx219_a@10 {
			status="okay";
			compatible = "sony,imx219";
			reg = <0x10>;
			
			// Here is the GPIO of the gpio epander used as reset-gpio
			reset-gpios = <&tca6416_cam 15 GPIO_ACTIVE_HIGH>;

			devnode = "video0";

			physical_w = "3.680";
			physical_h = "2.760";

			sensor_model = "imx219";

			use_sensor_mode_id = "true";

			mode0 { // IMX219_MODE_3280x2464_21FPS //
				mclk_khz = "24000";
				num_lanes = "2";
				tegra_sinterface = "serial_a";
[...]

Port configuration register

0: Output 1: Input

P7
P6
P5
P4
P3
P2
P1
P0

0

0

0

0

1

1

1

0

i2cset -y -f 2 0x20 0x06 0x0e

P8
P9
P10
P12
P11
P10
P9
P8

0

0

0

0

0

0

0

0

i2cset -y -f 2 0x20 0x07 0x00

Port output register

0: Logical HIGH 1: Logical LOW

Input pins will be ignored by this setting

P7
P6
P5
P4
P3
P2
P1
P0

1

1

1

1

1

1

1

1

i2cset -y -f 2 0x20 0x02 0xff

P8
P9
P10
P12
P11
P10
P9
P8

1

1

1

1

1

1

1

1

i2cset -y -f 2 0x20 0x03 0xff

Script

enable_imx219.sh
#!/bin/bash

# Port configuration register

# 0: Output
# 1: Input

# | P7  | P6  | P5  | P4  | P3  | P2  | P1  | P0  |
# | --- | --- | --- | --- | --- | --- | --- | --- |
# | 0   | 0   | 0   | 0   | 1   | 1   | 1   | 0   |

i2cset -y -f 2 0x20 0x06 0x0e

# | P8  | P9  | P10 | P12 | P11 | P10 | P9  | P8  |
# | --- | --- | --- | --- | --- | --- | --- | --- |
# | 0   | 0   | 0   | 0   | 0   | 0   | 0   | 0   |

i2cset -y -f 2 0x20 0x07 0x00

# Port output register

# 0: Logical HIGH
# 1: Logical LOW

# (Input pins will be ignored)

# | P7  | P6  | P5  | P4  | P3  | P2  | P1  | P0  |
# | --- | --- | --- | --- | --- | --- | --- | --- |
# | 1   | 1   | 1   | 1   | 1   | 1   | 1    | 1  |

i2cset -y -f 2 0x20 0x02 0xff

# | P8  | P9  | P10 | P12 | P11 | P10 | P9  | P8  |
# | --- | --- | --- | --- | --- | --- | --- | --- |
# | 1   | 1   | 1   | 1   | 1   | 1   | 1    | 1  |

i2cset -y -f 2 0x20 0x03 0xff

CSI-Routing

The following documentation assumes that you are comfortable with the CSI/VI interface from the Nvidia Jetson family

Example CSI/VI implementation

The following example CSI/VI devicetree would implement the J20 on the AGX Orin Devkit

The TX1-Devkit uses a different CSI-Lanes than the AGX-Xavier and AGX-Orin Devkit as shown above. -> There might be some differences in the Devicetree implementation for the AGX-Orin Devkit.

tegra234-p3737-0000-camera-vicsi-imx219-J20.dtsi
/ {
	tegra-capture-vi {
		status = "okay";
		num-channels = <6>;
		ports {
			status = "okay";
			#address-cells = <1>;
			#size-cells = <0>;
			port@0 { // CSI A
				status="okay";
				reg = <0>;
				imx219_vi_in0: endpoint {
					status="okay";
					port-index = <0>;
					bus-width = <2>;
					remote-endpoint = <&imx219_csi_out0>;
				};
			};
			port@1 { // CSI B
				status="okay";
				reg = <1>;
				imx219_vi_in1: endpoint {
					status="okay";
					port-index = <1>;
					bus-width = <2>;
					remote-endpoint = <&imx219_csi_out1>;
				};
			};
			port@2 { // CSI C
				status="okay";
				reg = <2>;
				imx219_vi_in2: endpoint {
					status="okay";
					port-index = <2>;
					bus-width = <2>;
					remote-endpoint = <&imx219_csi_out2>;
				};
			};
			port@3 { // CSI D
				status="okay";
				reg = <3>;
				imx219_vi_in3: endpoint {
					status="okay";
					port-index = <3>;
					bus-width = <2>;
					remote-endpoint = <&imx219_csi_out3>;
				};
			};
			port@4 { // CSI E
				status="okay";
				reg = <4>;
				imx219_vi_in4: endpoint {
					status="okay";
					port-index = <4>;
					bus-width = <2>;
					remote-endpoint = <&imx219_csi_out4>;
				};
			};
			port@5 { // CSI G
				status="okay";
				reg = <5>;
				imx219_vi_in6: endpoint {
					status="okay";
					port-index = <5>;
					bus-width = <2>;
					remote-endpoint = <&imx219_csi_out6>;
				};
			};
		};
	};

	host1x@13e00000 {
		nvcsi@15a00000 {
			status = "okay";
			num-channels = <6>;
			#address-cells = <1>;
			#size-cells = <0>;
			channel@0 { // CSI A
				reg = <0>;
				ports {
					status="okay";
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						status="okay";
						imx219_csi_in0: endpoint@0 {
							port-index = <0>;
							bus-width = <2>;
							remote-endpoint = <&imx219_out0>;
							status="okay";
						};
					};
					port@1 {
						reg = <1>;
						status="okay";
						imx219_csi_out0: endpoint@1 {
							remote-endpoint = <&imx219_vi_in0>;
							status="okay";
						};
					};
				};
			};
			channel@1 {// CSI B
				reg = <1>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						imx219_csi_in1: endpoint@2 {
							port-index = <1>;
							bus-width = <2>;
							remote-endpoint = <&imx219_out1>;
						};
					};
					port@1 {
						reg = <1>;
						imx219_csi_out1: endpoint@3 {
							remote-endpoint = <&imx219_vi_in1>;
						};
					};
				};
			};
			channel@2 { // CSI C
				reg = <2>;
				ports {
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						imx219_csi_in2: endpoint@4 {
							port-index = <2>;
							bus-width = <2>;
							remote-endpoint = <&imx219_out2>;
						};
					};
					port@1 {
						reg = <1>;
						imx219_csi_out2: endpoint@5 {
							remote-endpoint = <&imx219_vi_in2>;
						};
					};
				};
			};
			channel@3 { // CSI D
				reg = <3>;
				ports {
					status="okay";
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						status="okay";
						imx219_csi_in3: endpoint@6 {
							port-index = <3>;
							bus-width = <2>;
							remote-endpoint = <&imx219_out3>;
							status="okay";
						};
					};
					port@1 {
						reg = <1>;
						status="okay";
						imx219_csi_out3: endpoint@7 {
							remote-endpoint = <&imx219_vi_in3>;
							status="okay";
						};
					};
				};
			};
			channel@4 { // CSI E
				reg = <4>;
				ports {
					status="okay";
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						status="okay";
						imx219_csi_in4: endpoint@8 {
							port-index = <4>;
							bus-width = <2>;
							remote-endpoint = <&imx219_out4>;
							status="okay";
						};
					};
					port@1 {
						reg = <1>;
						status="okay";
						imx219_csi_out4: endpoint@9 {
							remote-endpoint = <&imx219_vi_in4>;
							status="okay";
						};
					};
				};
			};
			channel@5 { // CSI G
				reg = <5>;
				ports {
					status="okay";
					#address-cells = <1>;
					#size-cells = <0>;
					port@0 {
						reg = <0>;
						status="okay";
						imx219_csi_in6: endpoint@10 {
							port-index = <6>;
							bus-width = <2>;
							remote-endpoint = <&imx219_out6>;
							status="okay";
						};
					};
					port@1 {
						reg = <1>;
						status="okay";
						imx219_csi_out6: endpoint@11 {
							remote-endpoint = <&imx219_vi_in6>;
							status="okay";
						};
					};
				};
			};
		};
	};
};
📓
Nvidia forum
Camera Adaption