Adding support for PTN3460 edp to lvds bridge

Hello,

We are trying to add support for PTN3460 edp to lvds bridge in out custom carrier. We see there is a driver already available for this device.
We are using below patch. But we dont see this driver taking i2c address or the bridge. Can any one point out what need to be done ?

Patch :

diff --git a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
index 7c6bbc1..18f35f4 100644
--- a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
+++ b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
@@ -87,6 +87,15 @@
 		status = "okay";
 	};
 
+	i2c@3180000 {
+		lvds-bridge@20 {
+			compatible = "nxp,ptn3460";
+			reg = <0x20>;
+			edid-emulation = <5>;
+			status = "okay";
+		};
+	};
+
 #if TEGRA_XUSB_PADCONTROL_VERSION >= DT_VERSION_2
 
 	xusb_padctl: xusb_padctl@3520000 {
@@ -287,11 +296,9 @@

&sor0 {
-	nvidia,typec-port = /bits/ 8 <0>;
 };
 
 &sor1 {
-	nvidia,typec-port = /bits/ 8 <1>;
 };
 
 #if LINUX_VERSION >= 414
diff --git a/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig b/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig
index 0fe686f..c16b63d 100644
--- a/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig
+++ b/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig
@@ -967,3 +967,4 @@ CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
 CONFIG_CRYPTO_AES_ARM64_NEON_BLK=y
 CONFIG_ARCH_TEGRA_18x_SOC=y
 CONFIG_ARCH_TEGRA_19x_SOC=y
+CONFIG_DRM_NXP_PTN3460=y
diff --git a/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c b/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c
index f1a9993..32d8555 100644
--- a/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c
+++ b/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c
@@ -301,6 +301,8 @@ static int ptn3460_probe(struct i2c_client *client,
 	struct ptn3460_bridge *ptn_bridge;
 	struct device_node *endpoint, *panel_node;
 	int ret;
+	
+	printk(KERN_ALERT "#### in ptn3460_probe\n");
 
 	ptn_bridge = devm_kzalloc(dev, sizeof(*ptn_bridge), GFP_KERNEL);
 	if (!ptn_bridge) {

We are able to see device on bus with i2cdetect and can read/write/dump registers into this. So NOT an issue with i2c communication. We are connecting PTN3460 to DP0 (Head1, SOR0).

Thanks,
Don.

Hi Don,

We see there is a driver already available for this device.
Which driver is this one? Do you see any message from this log in dmesg?

Hello WayneWWW,

Sorry for the late reply. We finally got the bridge supported and LVDS display working now.
It seems the kernel configuration options we put in above snippet alone is not enough to get the driver compiled and linked. Below is the bridge driver we are talking about.
/xavier/public_sources/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c

However we got another strange issue now. If we keep the LVDS enabled, and HDMI connected, Jetson wont boot. We are able to connect any one at a time. when we keep HDMI connected and after booting if we connect edp bridge, HDMI display does blank, system hangs and we get the following in serial console.

nvidia@jetson-0424318032561:~$ ▒▒WARNING: pll_d2 has no dyn ramp
▒▒[   45.635820] tegradc 15220000.nvdisplay: tegra_nvdisp_assign_win: cannot assign win 4 to head 2, it owned by 0
[   45.636036] tegradc 15220000.nvdisplay: failed to assign window 4
[   45.636152] tegradc 15220000.nvdisplay: tegra_nvdisp_assign_win: cannot assign win 5 to head 2, it owned by 0
[   45.636329] tegradc 15220000.nvdisplay: failed to assign window 5
[   45.636479] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[   45.636652] Mem abort info:
[   45.636711]   ESR = 0x96000005
[   45.636776]   Exception class = DABT (current EL), IL = 32 bits
[   45.636876]   SET = 0, FnV = 0
[   45.636934]   EA = 0, S1PTW = 0
[   45.636989] Data abort info:
[   45.637042]   ISV = 0, ISS = 0x00000005
[   45.637116]   CM = 0, WnR = 0
[   45.637182] user pgtable: 4k pages, 39-bit VAs, pgd = ffffffc3a0896000
[   45.637575] [0000000000000000] *pgd=0000000000000000, *pud=0000000000000000
[   45.638150] Internal error: Oops: 96000005 [#1] PREEMPT SMP
[   45.638582] Modules linked in: bnep fuse ar1335(O) nvs_bmi160 pwm_pca9685 nvs bluedroid_pm ip_tables x_tables
[   45.643329] CPU: 3 PID: 30 Comm: kworker/3:0 Tainted: G           O    4.9.108 #2
[   45.650686] Hardware name: jetson-xavier (DT)
[   45.655375] Workqueue: events hpd_worker
[   45.659192] task: ffffffc3edb68000 task.stack: ffffffc3edb70000
[   45.665388] PC is at tegra_nvdisp_head_enable+0x864/0x1448
[   45.670803] LR is at tegra_nvdisp_head_enable+0x8e4/0x1448
[   45.676059] pc : [<ffffff800862bf34>] lr : [<ffffff800862bfb4>] pstate: 20c00045
[   45.683404] sp : ffffffc3edb73b30
[   45.687074] x29: ffffffc3edb73b30 x28: ffffffc3c7c4e000
[   45.692587] x27: 0000000000000009 x26: 0000000000010000
[   45.698272] x25: 0000000000020000 x24: 0000000000000000
[   45.703524] x23: 0000000000000000 x22: ffffffc3e9082078
[   45.708597] x21: 00000000ffffffff x20: 0000000000000008
[   45.714120] x19: ffffffc3c7c48000 x18: 0000000000000010
[   45.719808] x17: 0000007f7967eb10 x16: 0000000000001028
[   45.725486] x15: 0000000000000006 x14: 0000000000000002
[   45.731173] x13: 0000000000000000 x12: 0000000000010101
[   45.736947] x11: 000000000000032e x10: 0000000000000000
[   45.742730] x9 : 000000000000032e x8 : 0000000000000006
[   45.748245] x7 : 0000000000000002 x6 : 0000000000000004
[   45.753757] x5 : 000000000000032e x4 : 0000000000000000
[   45.759347] x3 : 0000000000000000 x2 : 0000000000000000
[   45.764432] x1 : 0000000000000000 x0 : 0000000000000000
[   45.770021]

Below is the diff on sources now

diff --git a/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-modules/tegra194-cvb-p2822-0000-a00.dtsi b/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-modules/tegra194-cvb-p2822-0000-a00.dtsi
index f1c5749..27ee5ce 100644
--- a/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-modules/tegra194-cvb-p2822-0000-a00.dtsi
+++ b/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-modules/tegra194-cvb-p2822-0000-a00.dtsi
@@ -51,7 +51,7 @@
 			};
 		};
 	};
-
+	/*
 	i2c@c240000 {
 		ucsi_ccg: ucsi_ccg@8 {
 			compatible = "nvidia,ucsi_ccg";
@@ -60,7 +60,8 @@
 			interrupt-parent = <&tegra_aon_gpio>;
 			interrupts = <TEGRA194_AON_GPIO(BB, 2) 0>;
 			wakeup-source;
-			status = "okay";
+			status = "disabled";
 		};
 	};
+	*/
 };
diff --git a/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-platforms/tegra194-comms.dtsi b/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-platforms/tegra194-comms.dtsi
index 1985c0f..75664dc 100644
--- a/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-platforms/tegra194-comms.dtsi
+++ b/hardware/nvidia/platform/t19x/common/kernel-dts/t19x-common-platforms/tegra194-comms.dtsi
@@ -70,7 +70,7 @@
 
         lvds_pwdn {
             gpio-hog;
-            output-high;
+            output-low;
             label = "lvds_pwdn";
             gpios = <TEGRA194_MAIN_GPIO(Z, 2) 0>;
             status = "okay";
diff --git a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2822-disp.dtsi b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2822-disp.dtsi
index c647bdd..dd2c305 100644
--- a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2822-disp.dtsi
+++ b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2822-disp.dtsi
@@ -92,6 +92,9 @@
 &sor1_dp_display {
 	status = "okay";
 	nvidia,is_ext_dp_panel = <1>;
+	disp-default-out {
+		nvidia,out-flags = <TEGRA_DC_OUT_HOTPLUG_HIGH>;
+	};
 };
 
 &sor2 {
diff --git a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
index 7c6bbc1..6d0550d 100644
--- a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
+++ b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-p2888-0001-p2822-0000-common.dtsi
@@ -258,6 +258,15 @@
 		};
 	};
 
+	i2c@3180000 {
+		lvds-bridge@20 {
+			compatible = "nxp,ptn3460";
+			reg = <0x20>;
+			edid-emulation = <4>;
+			status = "okay";
+		};
+	};
+
 	host1x {
 		dpaux@155F0000 {
 			status = "okay";
@@ -287,11 +296,11 @@
 
 
 &sor0 {
-	nvidia,typec-port = /bits/ 8 <0>;
+	/* nvidia,typec-port = /bits/ 8 <0>; */
 };
 
 &sor1 {
-	nvidia,typec-port = /bits/ 8 <1>;
+	/* nvidia,typec-port = /bits/ 8 <1>; */
 };
 
 #if LINUX_VERSION >= 414
diff --git a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-powermon-p2888.dtsi b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-powermon-p2888.dtsi
index a1c4cb8..3529b39 100644
--- a/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-powermon-p2888.dtsi
+++ b/hardware/nvidia/platform/t19x/galen/kernel-dts/common/tegra194-powermon-p2888.dtsi
@@ -20,7 +20,7 @@
 			offset = <40>;
 		};
 	};
-
+	/*
 	i2c@c240000 {
 		ina3221x_40: ina3221x@40 {
 			compatible = "ti,ina3221x";
@@ -79,4 +79,5 @@
 			};
 		};
 	};
+	*/
 };
diff --git a/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig b/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig
index 0fe686f..7b99162 100644
--- a/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig
+++ b/kernel/kernel-4.9/arch/arm64/configs/tegra_ar1335_defconfig
@@ -967,3 +967,8 @@ CONFIG_CRYPTO_AES_ARM64_CE_BLK=y
 CONFIG_CRYPTO_AES_ARM64_NEON_BLK=y
 CONFIG_ARCH_TEGRA_18x_SOC=y
 CONFIG_ARCH_TEGRA_19x_SOC=y
+CONFIG_VIDEOMODE_HELPERS=y
+CONFIG_DRM=y
+CONFIG_DRM_BRIDGE=y
+CONFIG_DRM_PANEL_SIMPLE=y
+CONFIG_DRM_NXP_PTN3460=y
\ No newline at end of file
diff --git a/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c b/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c
index f1a9993..7545c24 100644
--- a/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c
+++ b/kernel/kernel-4.9/drivers/gpu/drm/bridge/nxp-ptn3460.c
@@ -325,7 +325,7 @@ static int ptn3460_probe(struct i2c_client *client,
 	if (IS_ERR(ptn_bridge->gpio_pd_n)) {
 		ret = PTR_ERR(ptn_bridge->gpio_pd_n);
 		dev_err(dev, "cannot get gpio_pd_n %d\n", ret);
-		return ret;
+		//return ret;
 	}
 
 	/*
@@ -337,7 +337,7 @@ static int ptn3460_probe(struct i2c_client *client,
 	if (IS_ERR(ptn_bridge->gpio_rst_n)) {
 		ret = PTR_ERR(ptn_bridge->gpio_rst_n);
 		DRM_ERROR("cannot get gpio_rst_n %d\n", ret);
-		return ret;
+		//return ret;
 	}
 
 	ret = of_property_read_u32(dev->of_node, "edid-emulation",

As you can guess, USB type C controller disabled, support for bridge added. Are we making any obvious mistakes ?

tegra_nvdisp_assign_win: cannot assign win 4 to head 2, it owned by 0
[   45.636036] tegradc 15220000.nvdisplay: failed to assign window 4
[   45.636152] tegradc 15220000.nvdisplay: tegra_nvdisp_assign_win: cannot assign win 5 to head 2, it owned by 0
[   45.636329] tegradc 15220000.nvdisplay: failed to assign window 5
[   45.636479] Unable to handle kernel NULL pointer dereference at virtual address 00000000

This error looks fatal. I guess this error comes because you set same win-mask for both display head in device tree. Could you confirm?

Hello WayneWWW,

We are using tegra194-p2822-disp.dtsi with minimum changes. I see this set differently from each head.

/*
 * tegra194-p2822-disp.dtsi:
 *
 * Copyright (c) 2017-2018, NVIDIA CORPORATION.  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; version 2 of the License.
 *
 * 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.
 *
 *
 * t194 galen product uses 3 display heads out of the 4 available on t194:
 *	fb0: Head0->SOR2->HDMI
 *	fb1: Head1->SOR0->DP0
 *	fb2: Head2->SOR1->DP1
 * Each display head is assigned two windows each.
 */

#include <dt-bindings/display/tegra-dc.h>
#include <dt-bindings/display/tegra-panel.h>
#include <t19x-common-platforms/tegra194-hdmi.dtsi>
#include <t19x-common-platforms/tegra194-dp.dtsi>
#include "tegra194-fixed-regulator-p2822-1000.dtsi"
#include "tegra194-spmic-p2888-0001.dtsi"

&head0 {
	status = "okay";
	nvidia,fb-bpp = <32>;
	nvidia,fbmem-size = <265420800>; /* 8K (7680*4320) 32bpp double buffered */
	nvidia,fb-flags = <TEGRA_FB_FLIP_ON_PROBE>;
	win-mask = <0x3>;
	nvidia,fb-win = <0>;
	nvidia,dc-connector = <&sor2>;
	nvidia,dc-flags = <TEGRA_DC_FLAG_ENABLED>;
	avdd_hdmi-supply = <&p2888_spmic_sd0>; /* 1v0 */
	avdd_hdmi_pll-supply = <&p2888_spmic_sd1>; /* 1v8 */
	vdd_hdmi_5v0-supply = <&p2822_vdd_hdmi_5v0>; /* 5v0 */
};

&head1 {
	status = "okay";
	nvidia,fb-bpp = <32>;
	nvidia,fbmem-size = <265420800>; /* 8K (7680*4320) 32bpp double buffered */
	nvidia,fb-flags = <TEGRA_FB_FLIP_ON_PROBE>;
	win-mask = <0xC>;
	nvidia,fb-win = <2>;
	nvidia,dc-connector = <&sor0>;
	nvidia,dc-flags = <TEGRA_DC_FLAG_ENABLED>;
	vdd-dp-pwr-supply = <&p2888_spmic_sd0>;
	avdd-dp-pll-supply = <&p2888_spmic_sd1>;
	vdd-edp-sec-mode-supply = <&battery_reg>;
	vdd-dp-pad-supply = <&battery_reg>;
	vdd_hdmi_5v0-supply = <&p2822_vdd_hdmi_5v0>;
};

&head2 {
	status = "okay";
	nvidia,fb-bpp = <32>;
	nvidia,fbmem-size = <265420800>; /* 8K (7680*4320) 32bpp double buffered */
	nvidia,fb-flags = <TEGRA_FB_FLIP_ON_PROBE>;
	win-mask = <0x30>;
	nvidia,fb-win = <4>;
	nvidia,dc-connector = <&sor1>;
	nvidia,dc-flags = <TEGRA_DC_FLAG_ENABLED>;
	vdd-dp-pwr-supply = <&p2888_spmic_sd0>;
	avdd-dp-pll-supply = <&p2888_spmic_sd1>;
	vdd-edp-sec-mode-supply = <&battery_reg>;
	vdd-dp-pad-supply = <&battery_reg>;
	vdd_hdmi_5v0-supply = <&p2822_vdd_hdmi_5v0>;
};


&sor0 {
	status = "okay";
	nvidia,active-panel = <&sor0_dp_display>;
};

&sor0_dp_display {
	status = "okay";
	nvidia,is_ext_dp_panel = <1>;
};

&sor1 {
	status = "okay";
	nvidia,active-panel = <&sor1_dp_display>;
};

&sor1_dp_display {
	status = "okay";
	nvidia,is_ext_dp_panel = <1>;
	disp-default-out {
		nvidia,out-flags = <TEGRA_DC_OUT_HOTPLUG_HIGH>;
	};
};

&sor2 {
	status = "okay";
	nvidia,active-panel = <&sor2_hdmi_display>;
};

&sor2_hdmi_display {
	status = "okay";
	disp-default-out {
		nvidia,out-flags = <TEGRA_DC_OUT_HOTPLUG_LOW>;
	};
};

&dpaux0 {
	status = "okay";
};

&dpaux1 {
	status = "okay";
};

&dpaux2 {
	status = "okay";
};

&tegra_cec {
	status = "okay";
};

Please check the runtime device tree by reading the nodes under “/proc/device-tree”.

This is the real device tree result that is read by system.

Hello WayneWWW,

Thanks for that pointer. One of the other patches we had were overriding tegra194-p2822-disp.dtsi with some custom settings, which made all display windows getting assigned to head 0. Corrected it.

Thanks,
Don.