I’m just writing my understanding of how it works and maybe somebody can tell me if I’m wrong somewhere and post some expansions of it.
The Orin NX has four CSI interfaces that are exposed on the edge connector, named CSI_0-CSI_3. They correspond to the Verilog names CSI_A-CSI_D. (CSI_E to H exist, probably because the AGX uses the same silicon). Each of those has two lanes, D0 and D1. Those can be configured into four (15-pin) 2 lane socket, or two (22-pin) 4-lane socket (A+B and C+D).
The DevKit connects CSI_B on socket CSI0 (2-lanes) and CSI_C+CSI_D on socket CSI1(4-lanes).
For some reason there is a pin crossover in CSI_0_D1 and CSI_1_D0, so you have to do the lane polarity configuration, unless your carrier board is fixing that. Depending on that and what CSI port you use you will have to set lane polarity. See Design Guide Figure 10-1.
Based on the camera connector pin.
* CSIx_D0 | CSIx_D1 | CSI(X+1)_D0 | CSI(X+1)CSIx_D1
* LSB | BIT1 | BIT2 | MSB
* if there is a polarity swap on any lane, the bit corrsponding
* to the lane should be set
* e.g. polarity swap on CSIx_D0 only -> lane_polarity = "1"; 0001
* e.g. polarity swap on CSIx_D1 and CSI(X+1)_D0 -> lane_polarity = "6"; 0110
So in a CAM that is using only CSI_0 you need to set bit 1 aka polarity=2, in one that us using only CSI_1 you need to set bit 0 aka polarity=1 and in one that uses both you need bits 1 and 2, so polarity=6, or your carrier board has fixed that for you, look at the layout you are using. Apparently it should be set to 6 for all cameras that use CSI_A and/or CSI_B.
In the device tree entry of the camera you have to specify in the mode node what serial interface you are using, serial_a to serial_d. Those correspond to CSI_A to CSI_D.
What serial you have to use for a two lane camera on a 4 lane port depends on how the sockets are connected to the camera.
The device tree for the camera also needs a ports node with an endpoint, the data out for the camera. In this endpoint you set the number of lanes your camera needs in the bus-width property, a port index that corresponds to the used CSI port and a remote-endpoint that points to the nvcsi input node.
If you go by this graphic the relation ship between them is quite clear, at least the BSP uses serial_b->port-index =1 and serial_c->port-index=2.
Again, all this means what serial and port-index is used depends on your specific hardware, maybe your board use two lane sockets, they could be connected to any of the CSI lanes.
The last property of this endpoint is a reference to the CSI input endpoint in the nvcsi component.
The nvcsi node has multiple channels. I’m not sure if the index of the channel (channel@0, channel@1) does anything besides make them unique). Each channel node has two ports, one input and one output. Each of them has an endpoint node. The input node must have the same port-index and bus-width as the output endpoint of the camera and remote-endpoint that points to the output node of the camera. The output port has an endpoint node with a remote-endpoint that points to the corresponding node in tegra-capture-vi.
In tegra-capture-vi you have to specify the number of channels you want to capture. It has a ports node with a number of port sub-nodes. In each of them resides an endpoint that again has port-index, bus-width like before and a remote-endpoint that points to the output node of nvcsi.
The last part that has to be configured is the tegra-camera-platform. It has modules, every module representing a camera. It has a badge, position and orientation property, that have to be set according to this (the documentation specifies cases for 2, 3 and 6 cameras, the BSP device tree with 4 cameras uses bottomleft, bottomright, centerleft, centerright and orientation=1 for all of them) and a drivernode(s). drivernode0 corresponds with the camera. Here you set pcl_id = “v4l2_sensor” and sysfs-device-tree to wherever your camera is in /sys/firmware/devicetree/base/, usually something like /sys/firmware/devicetree/base/bus@0/i2c@3180000/rbpcv2_imx219_a@10, maybe with an mux in between the I2c and the camera. You can also have other drivernodes that reference other components, like a lens.
