usb: dwc2: gadget: register gadget handle to the phy
authorGregory Herrero <gregory.herrero@intel.com>
Fri, 9 Jan 2015 12:38:41 +0000 (13:38 +0100)
committerFelipe Balbi <balbi@ti.com>
Mon, 12 Jan 2015 21:32:28 +0000 (15:32 -0600)
Bind peripheral controller to the phy on udc_start. Unbind on
udc_stop.

Tested-by: Robert Baldyga <r.baldyga@samsung.com>
Acked-by: Paul Zimmerman <paulz@synopsys.com>
Signed-off-by: Gregory Herrero <gregory.herrero@intel.com>
Signed-off-by: Mian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: Felipe Balbi <balbi@ti.com>
drivers/usb/dwc2/gadget.c

index 1a8e0a6d2ef83ec1cee36a525e869c8c6710af6c..b5332f01be85410931ec922c84e3e82069f0b6eb 100644 (file)
@@ -2878,6 +2878,8 @@ static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
        }
 
        s3c_hsotg_phy_enable(hsotg);
+       if (!IS_ERR_OR_NULL(hsotg->uphy))
+               otg_set_peripheral(hsotg->uphy->otg, &hsotg->gadget);
 
        spin_lock_irqsave(&hsotg->lock, flags);
        s3c_hsotg_init(hsotg);
@@ -2927,6 +2929,8 @@ static int s3c_hsotg_udc_stop(struct usb_gadget *gadget)
 
        spin_unlock_irqrestore(&hsotg->lock, flags);
 
+       if (!IS_ERR_OR_NULL(hsotg->uphy))
+               otg_set_peripheral(hsotg->uphy->otg, NULL);
        s3c_hsotg_phy_disable(hsotg);
 
        regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);