.. | .. |
---|
888 | 888 | goto unlock; |
---|
889 | 889 | |
---|
890 | 890 | ret = property_enable(base, &rport->port_cfg->phy_sus, false); |
---|
891 | | - if (ret) |
---|
| 891 | + if (ret) { |
---|
| 892 | + clk_disable_unprepare(rphy->clk480m); |
---|
892 | 893 | goto unlock; |
---|
| 894 | + } |
---|
893 | 895 | |
---|
894 | 896 | /* |
---|
895 | 897 | * For rk3588, it needs to reset phy when exit from |
---|
.. | .. |
---|
902 | 904 | if (rport->port_id == USB2PHY_PORT_OTG && |
---|
903 | 905 | of_device_is_compatible(rphy->dev->of_node, "rockchip,rk3588-usb2phy")) { |
---|
904 | 906 | ret = rockchip_usb2phy_reset(rphy); |
---|
905 | | - if (ret) |
---|
| 907 | + if (ret) { |
---|
| 908 | + clk_disable_unprepare(rphy->clk480m); |
---|
906 | 909 | goto unlock; |
---|
| 910 | + } |
---|
907 | 911 | } |
---|
908 | 912 | |
---|
909 | 913 | /* waiting for the utmi_clk to become stable */ |
---|
.. | .. |
---|
1767 | 1771 | if (property_enabled(rphy->grf, &rport->port_cfg->idfall_det_st)) { |
---|
1768 | 1772 | property_enable(rphy->grf, &rport->port_cfg->idfall_det_clr, |
---|
1769 | 1773 | 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)) |
---|
1772 | 1780 | cable_vbus_state = true; |
---|
1773 | 1781 | } else if (property_enabled(rphy->grf, &rport->port_cfg->idrise_det_st)) { |
---|
1774 | 1782 | property_enable(rphy->grf, &rport->port_cfg->idrise_det_clr, |
---|
.. | .. |
---|
3123 | 3131 | } |
---|
3124 | 3132 | } |
---|
3125 | 3133 | |
---|
| 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 | + |
---|
3126 | 3154 | if (rport->port_id == USB2PHY_PORT_OTG && wakeup_enable && |
---|
3127 | 3155 | rport->bvalid_irq > 0) |
---|
3128 | 3156 | disable_irq_wake(rport->bvalid_irq); |
---|
.. | .. |
---|
3408 | 3436 | .ls_det_clr = { 0x0118, 0, 0, 0, 1 }, |
---|
3409 | 3437 | .utmi_avalid = { 0x0120, 10, 10, 0, 1 }, |
---|
3410 | 3438 | .utmi_bvalid = { 0x0120, 9, 9, 0, 1 }, |
---|
3411 | | - .utmi_iddig = { 0x0120, 6, 6, 0, 1 }, |
---|
3412 | 3439 | .utmi_ls = { 0x0120, 5, 4, 0, 1 }, |
---|
3413 | 3440 | .vbus_det_en = { 0x001c, 15, 15, 1, 0 }, |
---|
3414 | 3441 | }, |
---|