Re: [RFC PATCH 1/2] usb: dwc2: add clock manage for hcd

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

On Wed, Oct 15, 2014 at 10:46:17PM -0700, Kever Yang wrote:
> This patch move clock init out of gadget into platform,
> make both hcd and gadget can use the clock
> 
> Signed-off-by: Kever Yang <kever.yang@xxxxxxxxxxxxxx>
> ---
> 
>  drivers/usb/dwc2/gadget.c   | 16 ++--------------
>  drivers/usb/dwc2/hcd.c      |  3 +++
>  drivers/usb/dwc2/platform.c | 30 ++++++++++++++++++------------
>  3 files changed, 23 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
> index 6ffbfc2..1943e52 100644
> --- a/drivers/usb/dwc2/gadget.c
> +++ b/drivers/usb/dwc2/gadget.c
> @@ -3408,20 +3408,12 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>  			hsotg->phyif = GUSBCFG_PHYIF8;
>  	}
>  
> -	hsotg->clk = devm_clk_get(dev, "otg");
> -	if (IS_ERR(hsotg->clk)) {
> -		dev_err(dev, "cannot get otg clock\n");
> -		return PTR_ERR(hsotg->clk);
> -	}
> -
>  	hsotg->gadget.max_speed = USB_SPEED_HIGH;
>  	hsotg->gadget.ops = &s3c_hsotg_gadget_ops;
>  	hsotg->gadget.name = dev_name(dev);
>  
>  	/* reset the system */
>  
> -	clk_prepare_enable(hsotg->clk);
> -
>  	/* regulators */
>  
>  	for (i = 0; i < ARRAY_SIZE(hsotg->supplies); i++)
> @@ -3431,7 +3423,7 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
>  				 hsotg->supplies);
>  	if (ret) {
>  		dev_err(dev, "failed to request supplies: %d\n", ret);
> -		goto err_clk;
> +		goto out;
>  	}
>  
>  	ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
> @@ -3510,9 +3502,7 @@ err_ep_mem:
>  	kfree(eps);
>  err_supplies:
>  	s3c_hsotg_phy_disable(hsotg);
> -err_clk:
> -	clk_disable_unprepare(hsotg->clk);
> -
> +out:
>  	return ret;
>  }
>  EXPORT_SYMBOL_GPL(dwc2_gadget_init);
> @@ -3532,8 +3522,6 @@ int s3c_hsotg_remove(struct dwc2_hsotg *hsotg)
>  		usb_gadget_unregister_driver(hsotg->driver);
>  	}
>  
> -	clk_disable_unprepare(hsotg->clk);
> -
>  	return 0;
>  }
>  EXPORT_SYMBOL_GPL(s3c_hsotg_remove);
> diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c
> index fa49c72..fddd923 100644
> --- a/drivers/usb/dwc2/hcd.c
> +++ b/drivers/usb/dwc2/hcd.c
> @@ -46,6 +46,7 @@
>  #include <linux/delay.h>
>  #include <linux/io.h>
>  #include <linux/slab.h>
> +#include <linux/clk.h>
>  #include <linux/usb.h>
>  
>  #include <linux/usb/hcd.h>
> @@ -2266,6 +2267,7 @@ static int _dwc2_hcd_start(struct usb_hcd *hcd)
>  	spin_lock_irqsave(&hsotg->lock, flags);
>  
>  	hcd->state = HC_STATE_RUNNING;
> +	clk_enable(hsotg->clk);

with this you're moving clk_enable() from gadget to HCD. You might want
to leave this completely to the glue; at least for now.

-- 
balbi

Attachment: signature.asc
Description: Digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux