forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-01-31 f70575805708cabdedea7498aaa3f710fde4d920
kernel/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
....@@ -888,8 +888,10 @@
888888 goto unlock;
889889
890890 ret = property_enable(base, &rport->port_cfg->phy_sus, false);
891
- if (ret)
891
+ if (ret) {
892
+ clk_disable_unprepare(rphy->clk480m);
892893 goto unlock;
894
+ }
893895
894896 /*
895897 * For rk3588, it needs to reset phy when exit from
....@@ -902,8 +904,10 @@
902904 if (rport->port_id == USB2PHY_PORT_OTG &&
903905 of_device_is_compatible(rphy->dev->of_node, "rockchip,rk3588-usb2phy")) {
904906 ret = rockchip_usb2phy_reset(rphy);
905
- if (ret)
907
+ if (ret) {
908
+ clk_disable_unprepare(rphy->clk480m);
906909 goto unlock;
910
+ }
907911 }
908912
909913 /* waiting for the utmi_clk to become stable */
....@@ -1767,8 +1771,12 @@
17671771 if (property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st)) {
17681772 property_enable(rphy->grf, &rport->port_cfg->idfall_det_clr,
17691773 true);
1770
- /* switch to host if id fall det and iddig status is low */
1771
- if (!property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig))
1774
+ /*
1775
+ * if id fall det, switch to host if ID Detector pin is floating
1776
+ * or iddig status is low.
1777
+ */
1778
+ if (!rport->port_cfg->utmi_iddig.enable ||
1779
+ !property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig))
17721780 cable_vbus_state = true;
17731781 } else if (property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st)) {
17741782 property_enable(rphy->grf, &rport->port_cfg->idrise_det_clr,
....@@ -3123,6 +3131,26 @@
31233131 }
31243132 }
31253133
3134
+ /* Enable bvalid detect irq */
3135
+ if (rport->port_id == USB2PHY_PORT_OTG &&
3136
+ (rport->mode == USB_DR_MODE_PERIPHERAL ||
3137
+ rport->mode == USB_DR_MODE_OTG) &&
3138
+ (rport->bvalid_irq > 0 || rport->otg_mux_irq > 0 || rphy->irq > 0) &&
3139
+ !rport->vbus_always_on) {
3140
+ ret = rockchip_usb2phy_enable_vbus_irq(rphy, rport,
3141
+ true);
3142
+ if (ret) {
3143
+ dev_err(rphy->dev,
3144
+ "failed to enable bvalid irq\n");
3145
+ return ret;
3146
+ }
3147
+
3148
+ if (property_enabled(rphy->grf, &rport->port_cfg->utmi_bvalid))
3149
+ schedule_delayed_work(&rport->otg_sm_work,
3150
+ OTG_SCHEDULE_DELAY);
3151
+
3152
+ }
3153
+
31263154 if (rport->port_id == USB2PHY_PORT_OTG && wakeup_enable &&
31273155 rport->bvalid_irq > 0)
31283156 disable_irq_wake(rport->bvalid_irq);
....@@ -3408,7 +3436,6 @@
34083436 .ls_det_clr = { 0x0118, 0, 0, 0, 1 },
34093437 .utmi_avalid = { 0x0120, 10, 10, 0, 1 },
34103438 .utmi_bvalid = { 0x0120, 9, 9, 0, 1 },
3411
- .utmi_iddig = { 0x0120, 6, 6, 0, 1 },
34123439 .utmi_ls = { 0x0120, 5, 4, 0, 1 },
34133440 .vbus_det_en = { 0x001c, 15, 15, 1, 0 },
34143441 },