[][MT7986 enbale ice debug clock]

[Description]
Fix ice debug clock,enable jtag sel clock.

[Release-log]
N/A

Change-Id: Iee61ef4ddd04c520a71a0dbdf677e84e15a39050
Reviewed-on: https://gerrit.mediatek.inc/c/openwrt/feeds/mtk_openwrt_feeds/+/4762113
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986-clkitg.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986-clkitg.dtsi
index a6dc69e..0970ab4 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986-clkitg.dtsi
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986-clkitg.dtsi
@@ -184,7 +184,7 @@
 			<&topckgen CK_TOP_SYSAXI_SEL>,
 			<&topckgen CK_TOP_SYSAPB_SEL>,
 			<&topckgen CK_TOP_ARM_DB_MAIN_SEL>,
-			<&topckgen CK_TOP_ARM_DB_JTSEL>,
+			<&clk40m>,
 			<&topckgen CK_TOP_NETSYS_SEL>,
 			<&topckgen CK_TOP_NETSYS_500M_SEL>,
 			<&topckgen CK_TOP_NETSYS_MCU_SEL>,
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
index a592af9..611893e 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986a.dtsi
@@ -728,8 +728,9 @@
 	ice: ice_debug {
 		compatible = "mediatek,mt7986-ice_debug",
 			"mediatek,mt2701-ice_debug";
-		clocks = <&infracfg_ao CK_INFRA_DBG_CK>;
-		clock-names = "ice_dbg";
+		clocks = <&infracfg_ao CK_INFRA_DBG_CK>,
+			 <&topckgen CK_TOP_ARM_DB_JTSEL>;
+		clock-names = "ice_dbg", "dbg_jtsel";
 	};
 
 	efuse: efuse@11d00000 {
diff --git a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b.dtsi b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b.dtsi
index fa1df5e..b5b840b 100644
--- a/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b.dtsi
+++ b/target/linux/mediatek/files-5.4/arch/arm64/boot/dts/mediatek/mt7986b.dtsi
@@ -659,8 +659,9 @@
 	ice: ice_debug {
 		compatible = "mediatek,mt8512-ice_debug",
 			"mediatek,mt2701-ice_debug";
-		clocks = <&infracfg_ao CK_INFRA_DBG_CK>;
-		clock-names = "ice_dbg";
+		clocks = <&infracfg_ao CK_INFRA_DBG_CK>,
+			 <&topckgen CK_TOP_ARM_DB_JTSEL>;
+		clock-names = "ice_dbg", "dbg_jtsel";
 	};
 
 	efuse: efuse@11d00000 {
diff --git a/target/linux/mediatek/files-5.4/drivers/misc/mediatek/ice_debug/ice_debug.c b/target/linux/mediatek/files-5.4/drivers/misc/mediatek/ice_debug/ice_debug.c
index 1d005e4..b677a45 100644
--- a/target/linux/mediatek/files-5.4/drivers/misc/mediatek/ice_debug/ice_debug.c
+++ b/target/linux/mediatek/files-5.4/drivers/misc/mediatek/ice_debug/ice_debug.c
@@ -34,7 +34,19 @@
 
 	clk_icedbg = devm_clk_get(&pdev->dev, "ice_dbg");
 	if (IS_ERR(clk_icedbg)) {
-		dev_err(&pdev->dev, "get clock fail: %ld\n",
+		dev_err(&pdev->dev, "get ice_dbg clock fail: %ld\n",
+				PTR_ERR(clk_icedbg));
+		return PTR_ERR(clk_icedbg);
+	}
+
+	ret = clk_prepare_enable(clk_icedbg);
+	if (ret)
+		return ret;
+
+	/*enable CK_TOP_ARM_DB_JTSEL clk*/
+	clk_icedbg = devm_clk_get(&pdev->dev, "dbg_jtsel");
+	if (IS_ERR(clk_icedbg)) {
+		dev_err(&pdev->dev, "get dbg_sel clock fail: %ld\n",
 				PTR_ERR(clk_icedbg));
 		return PTR_ERR(clk_icedbg);
 	}