Verdin IMX8MP + ADV7281A-M

Hi David,

There is a race condition between the imx8 CSI receive hardware becoming ready and the ADV driver enabling the chip’s CSI output. The fix was to delay enabling of the CSI output of the ADV chip.

I had to hack up adv7180.c to get it working. I also added some code to allow switching of the video inputs via IOCTL.

I can share what I did, but use at your own risk. This is based on Linux 5.15.77 from Toradex.

I’ve attached my modified driver file; you will want diff with your version and take the parts related to csi_start_delayed (Maybe also the input mux switching). I changed some other register values from memory which you probably don’t want.

adv7180.c (42.7 KB)

Here is how you can then select the input from user space.

struct v4l2_control control;
control.id = V4L2_CID_USER_ADV7180_BASE + 1; // Input mux
control.value = input;
if (-1 == xioctl(fdSubdev, VIDIOC_S_CTRL, &control)) {
            fprintf(stderr, "Failed to switch input channel");
}

Also, device tree:


&i2c3 {
	status = "okay";

	clock-frequency = <10000>;

	adv7281a-m@21 {
		status = "okay";
		compatible = "adi,adv7281-m";
		reg = <0x21>;

		reset-gpios = <&gpio1 7 GPIO_ACTIVE_LOW>;
		powerdown-gpios = <&gpio1 8 GPIO_ACTIVE_LOW>;
		interrupt-parent = <&gpio4>;
		interrupts = <3 IRQ_TYPE_LEVEL_LOW>;

		pinctrl-names = "default";
		pinctrl-0 = <&pinctrl_gpio5>, <&pinctrl_gpio6>, <&pinctrl_gpio7>;

		port {
			adv7281a_mipi_0_ep: endpoint {
				remote-endpoint = <&mipi_csi0_ep>;
			};
		};
	};
};

&isi_0 {
	status = "okay";

	cap_device {
		status = "okay";
	};

	m2m_device {
		status = "disabled";
	};
};

&mipi_csi_0 {
	#address-cells = <1>;
	#size-cells = <0>;
	status = "okay";
	bus-width = <1>;

	clock-frequency = <108000000>;

	port@0 {
		reg = <0>;

		mipi_csi0_ep: endpoint {
			csis-hs-settle = <13>;
			csis-clk-settle = <2>;
			csis-wclk;
			data-lanes = <1>;
			remote-endpoint = <&adv7281a_mipi_0_ep>;
		};
	};
};

&cameradev {
	status = "okay";
};

And then there is making sure the drivers are enabled in the kernel config.

If I’ve missed anything or you have any other questions don’t hesitate to ask. This took ages to work out and I’m happy to save someone else the pain.

Cheers,
Phil