hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/drivers/phy/rockchip/phy-rockchip-inno-usb2.c
....@@ -1767,8 +1767,12 @@
17671767 if (property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st)) {
17681768 property_enable(rphy->grf, &rport->port_cfg->idfall_det_clr,
17691769 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))
1770
+ /*
1771
+ * if id fall det, switch to host if ID Detector pin is floating
1772
+ * or iddig status is low.
1773
+ */
1774
+ if (!rport->port_cfg->utmi_iddig.enable ||
1775
+ !property_enabled(rphy->grf, &rport->port_cfg->utmi_iddig))
17721776 cable_vbus_state = true;
17731777 } else if (property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st)) {
17741778 property_enable(rphy->grf, &rport->port_cfg->idrise_det_clr,
....@@ -3123,6 +3127,26 @@
31233127 }
31243128 }
31253129
3130
+ /* Enable bvalid detect irq */
3131
+ if (rport->port_id == USB2PHY_PORT_OTG &&
3132
+ (rport->mode == USB_DR_MODE_PERIPHERAL ||
3133
+ rport->mode == USB_DR_MODE_OTG) &&
3134
+ (rport->bvalid_irq > 0 || rport->otg_mux_irq > 0 || rphy->irq > 0) &&
3135
+ !rport->vbus_always_on) {
3136
+ ret = rockchip_usb2phy_enable_vbus_irq(rphy, rport,
3137
+ true);
3138
+ if (ret) {
3139
+ dev_err(rphy->dev,
3140
+ "failed to enable bvalid irq\n");
3141
+ return ret;
3142
+ }
3143
+
3144
+ if (property_enabled(rphy->grf, &rport->port_cfg->utmi_bvalid))
3145
+ schedule_delayed_work(&rport->otg_sm_work,
3146
+ OTG_SCHEDULE_DELAY);
3147
+
3148
+ }
3149
+
31263150 if (rport->port_id == USB2PHY_PORT_OTG && wakeup_enable &&
31273151 rport->bvalid_irq > 0)
31283152 disable_irq_wake(rport->bvalid_irq);
....@@ -3408,7 +3432,6 @@
34083432 .ls_det_clr = { 0x0118, 0, 0, 0, 1 },
34093433 .utmi_avalid = { 0x0120, 10, 10, 0, 1 },
34103434 .utmi_bvalid = { 0x0120, 9, 9, 0, 1 },
3411
- .utmi_iddig = { 0x0120, 6, 6, 0, 1 },
34123435 .utmi_ls = { 0x0120, 5, 4, 0, 1 },
34133436 .vbus_det_en = { 0x001c, 15, 15, 1, 0 },
34143437 },