|
37 | 37 | #include <linux/usb/otg.h>
|
38 | 38 |
|
39 | 39 | #include "usb.h"
|
| 40 | +#include "phy.h" |
40 | 41 |
|
41 | 42 |
|
42 | 43 | /*-------------------------------------------------------------------------*/
|
@@ -2260,6 +2261,9 @@ int hcd_bus_suspend(struct usb_device *rhdev, pm_message_t msg)
|
2260 | 2261 | usb_set_device_state(rhdev, USB_STATE_SUSPENDED);
|
2261 | 2262 | hcd->state = HC_STATE_SUSPENDED;
|
2262 | 2263 |
|
| 2264 | + if (!PMSG_IS_AUTO(msg)) |
| 2265 | + usb_phy_roothub_power_off(hcd->phy_roothub); |
| 2266 | + |
2263 | 2267 | /* Did we race with a root-hub wakeup event? */
|
2264 | 2268 | if (rhdev->do_remote_wakeup) {
|
2265 | 2269 | char buffer[6];
|
@@ -2296,6 +2300,13 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
|
2296 | 2300 | dev_dbg(&rhdev->dev, "skipped %s of dead bus\n", "resume");
|
2297 | 2301 | return 0;
|
2298 | 2302 | }
|
| 2303 | + |
| 2304 | + if (!PMSG_IS_AUTO(msg)) { |
| 2305 | + status = usb_phy_roothub_power_on(hcd->phy_roothub); |
| 2306 | + if (status) |
| 2307 | + return status; |
| 2308 | + } |
| 2309 | + |
2299 | 2310 | if (!hcd->driver->bus_resume)
|
2300 | 2311 | return -ENOENT;
|
2301 | 2312 | if (HCD_RH_RUNNING(hcd))
|
@@ -2333,6 +2344,7 @@ int hcd_bus_resume(struct usb_device *rhdev, pm_message_t msg)
|
2333 | 2344 | }
|
2334 | 2345 | } else {
|
2335 | 2346 | hcd->state = old_state;
|
| 2347 | + usb_phy_roothub_power_off(hcd->phy_roothub); |
2336 | 2348 | dev_dbg(&rhdev->dev, "bus %s fail, err %d\n",
|
2337 | 2349 | "resume", status);
|
2338 | 2350 | if (status != -ESHUTDOWN)
|
@@ -2769,6 +2781,18 @@ int usb_add_hcd(struct usb_hcd *hcd,
|
2769 | 2781 | }
|
2770 | 2782 | }
|
2771 | 2783 |
|
| 2784 | + if (!hcd->skip_phy_initialization) { |
| 2785 | + hcd->phy_roothub = usb_phy_roothub_init(hcd->self.sysdev); |
| 2786 | + if (IS_ERR(hcd->phy_roothub)) { |
| 2787 | + retval = PTR_ERR(hcd->phy_roothub); |
| 2788 | + goto err_phy_roothub_init; |
| 2789 | + } |
| 2790 | + |
| 2791 | + retval = usb_phy_roothub_power_on(hcd->phy_roothub); |
| 2792 | + if (retval) |
| 2793 | + goto err_usb_phy_roothub_power_on; |
| 2794 | + } |
| 2795 | + |
2772 | 2796 | dev_info(hcd->self.controller, "%s\n", hcd->product_desc);
|
2773 | 2797 |
|
2774 | 2798 | /* Keep old behaviour if authorized_default is not in [0, 1]. */
|
@@ -2933,6 +2957,10 @@ int usb_add_hcd(struct usb_hcd *hcd,
|
2933 | 2957 | err_register_bus:
|
2934 | 2958 | hcd_buffer_destroy(hcd);
|
2935 | 2959 | err_create_buf:
|
| 2960 | + usb_phy_roothub_power_off(hcd->phy_roothub); |
| 2961 | +err_usb_phy_roothub_power_on: |
| 2962 | + usb_phy_roothub_exit(hcd->phy_roothub); |
| 2963 | +err_phy_roothub_init: |
2936 | 2964 | if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
|
2937 | 2965 | phy_power_off(hcd->phy);
|
2938 | 2966 | phy_exit(hcd->phy);
|
@@ -3017,6 +3045,9 @@ void usb_remove_hcd(struct usb_hcd *hcd)
|
3017 | 3045 | usb_deregister_bus(&hcd->self);
|
3018 | 3046 | hcd_buffer_destroy(hcd);
|
3019 | 3047 |
|
| 3048 | + usb_phy_roothub_power_off(hcd->phy_roothub); |
| 3049 | + usb_phy_roothub_exit(hcd->phy_roothub); |
| 3050 | + |
3020 | 3051 | if (IS_ENABLED(CONFIG_GENERIC_PHY) && hcd->remove_phy && hcd->phy) {
|
3021 | 3052 | phy_power_off(hcd->phy);
|
3022 | 3053 | phy_exit(hcd->phy);
|
|
0 commit comments