From f70575805708cabdedea7498aaa3f710fde4d920 Mon Sep 17 00:00:00 2001
From: hc <hc@nodka.com>
Date: Wed, 31 Jan 2024 03:29:01 +0000
Subject: [PATCH] add lvds1024*800

---
 kernel/drivers/phy/rockchip/phy-rockchip-inno-usb2.c |   37 ++++++++++++++++++++++++++++++++-----
 1 files changed, 32 insertions(+), 5 deletions(-)

diff --git a/kernel/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/kernel/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
index fe928d9..b75f14b 100644
--- a/kernel/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
+++ b/kernel/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
@@ -888,8 +888,10 @@
 		goto unlock;
 
 	ret = property_enable(base, &rport->port_cfg->phy_sus, false);
-	if (ret)
+	if (ret) {
+		clk_disable_unprepare(rphy->clk480m);
 		goto unlock;
+	}
 
 	/*
 	 * For rk3588, it needs to reset phy when exit from
@@ -902,8 +904,10 @@
 	if (rport->port_id == USB2PHY_PORT_OTG &&
 	    of_device_is_compatible(rphy->dev->of_node, "rockchip,rk3588-usb2phy")) {
 		ret = rockchip_usb2phy_reset(rphy);
-		if (ret)
+		if (ret) {
+			clk_disable_unprepare(rphy->clk480m);
 			goto unlock;
+		}
 	}
 
 	/* waiting for the utmi_clk to become stable */
@@ -1767,8 +1771,12 @@
 	if (property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st)) {
 		property_enable(rphy->grf, &rport->port_cfg->idfall_det_clr,
 				true);
-		/* switch to host if id fall det and iddig status is low */
-		if (!property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig))
+		/*
+		 * if id fall det, switch to host if ID Detector pin is floating
+		 * or iddig status is low.
+		 */
+		if (!rport->port_cfg->utmi_iddig.enable ||
+		    !property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig))
 			cable_vbus_state = true;
 	} else if (property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st)) {
 		property_enable(rphy->grf, &rport->port_cfg->idrise_det_clr,
@@ -3123,6 +3131,26 @@
 			}
 		}
 
+		/* Enable bvalid detect irq */
+		if (rport->port_id == USB2PHY_PORT_OTG &&
+		    (rport->mode == USB_DR_MODE_PERIPHERAL ||
+		     rport->mode == USB_DR_MODE_OTG) &&
+		    (rport->bvalid_irq > 0 || rport->otg_mux_irq > 0 || rphy->irq > 0) &&
+		    !rport->vbus_always_on) {
+			ret = rockchip_usb2phy_enable_vbus_irq(rphy, rport,
+							       true);
+			if (ret) {
+				dev_err(rphy->dev,
+					"failed to enable bvalid irq\n");
+				return ret;
+			}
+
+			if (property_enabled(rphy->grf, &rport->port_cfg->utmi_bvalid))
+				schedule_delayed_work(&rport->otg_sm_work,
+						      OTG_SCHEDULE_DELAY);
+
+		}
+
 		if (rport->port_id == USB2PHY_PORT_OTG && wakeup_enable &&
 		    rport->bvalid_irq > 0)
 			disable_irq_wake(rport->bvalid_irq);
@@ -3408,7 +3436,6 @@
 				.ls_det_clr	= { 0x0118, 0, 0, 0, 1 },
 				.utmi_avalid	= { 0x0120, 10, 10, 0, 1 },
 				.utmi_bvalid	= { 0x0120, 9, 9, 0, 1 },
-				.utmi_iddig	= { 0x0120, 6, 6, 0, 1 },
 				.utmi_ls	= { 0x0120, 5, 4, 0, 1 },
 				.vbus_det_en	= { 0x001c, 15, 15, 1, 0 },
 			},

--
Gitblit v1.6.2