From 9394826b996640a65f892a4305c32e63b206020e Mon Sep 17 00:00:00 2001 From: Lukasz Majewski Date: Fri, 2 Mar 2012 17:44:56 +0100 Subject: usb:hsotg:samsung: Use new udc_start and udc_stop callbacks Replace of deprecated start and stop callbacks with a udc_start and udc_stop ones. Now the bind from composite driver is NOT called explicitly, so more work needs to be done at s3c_udc_probe. Especially enabling SoC clocks and power for runtime determination of EP number. After probing, those sources are disabled and enabled again at udc_start. Signed-off-by: Lukasz Majewski Signed-off-by: Kyungmin Park --- drivers/usb/gadget/s3c-hsotg.c | 51 +++++++++++++++++++++++++----------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/drivers/usb/gadget/s3c-hsotg.c b/drivers/usb/gadget/s3c-hsotg.c index 7967dbe251ea..c85194942427 100644 --- a/drivers/usb/gadget/s3c-hsotg.c +++ b/drivers/usb/gadget/s3c-hsotg.c @@ -2809,8 +2809,8 @@ static void s3c_hsotg_init(struct s3c_hsotg *hsotg) hsotg->regs + S3C_GAHBCFG); } -static int s3c_hsotg_start(struct usb_gadget_driver *driver, - int (*bind)(struct usb_gadget *)) +static int s3c_hsotg_udc_start(struct usb_gadget *gadget, + struct usb_gadget_driver *driver) { struct s3c_hsotg *hsotg = our_hsotg; int ret; @@ -2828,7 +2828,7 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver, if (driver->max_speed < USB_SPEED_FULL) dev_err(hsotg->dev, "%s: bad speed\n", __func__); - if (!bind || !driver->setup) { + if (!driver->setup) { dev_err(hsotg->dev, "%s: missing entry points\n", __func__); return -EINVAL; } @@ -2841,20 +2841,14 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver, hsotg->gadget.dev.dma_mask = hsotg->dev->dma_mask; hsotg->gadget.speed = USB_SPEED_UNKNOWN; - ret = device_add(&hsotg->gadget.dev); + ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies), + hsotg->supplies); if (ret) { - dev_err(hsotg->dev, "failed to register gadget device\n"); + dev_err(hsotg->dev, "failed to enable supplies: %d\n", ret); goto err; } - ret = bind(&hsotg->gadget); - if (ret) { - dev_err(hsotg->dev, "failed bind %s\n", driver->driver.name); - - hsotg->gadget.dev.driver = NULL; - hsotg->driver = NULL; - goto err; - } + s3c_hsotg_phy_enable(hsotg); s3c_hsotg_core_init(hsotg); hsotg->last_rst = jiffies; @@ -2867,7 +2861,8 @@ err: return ret; } -static int s3c_hsotg_stop(struct usb_gadget_driver *driver) +static int s3c_hsotg_udc_stop(struct usb_gadget *gadget, + struct usb_gadget_driver *driver) { struct s3c_hsotg *hsotg = our_hsotg; int ep; @@ -2885,6 +2880,9 @@ static int s3c_hsotg_stop(struct usb_gadget_driver *driver) call_gadget(hsotg, disconnect); driver->unbind(&hsotg->gadget); + s3c_hsotg_phy_disable(hsotg); + regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); + hsotg->driver = NULL; hsotg->gadget.speed = USB_SPEED_UNKNOWN; @@ -2903,8 +2901,8 @@ static int s3c_hsotg_gadget_getframe(struct usb_gadget *gadget) static struct usb_gadget_ops s3c_hsotg_gadget_ops = { .get_frame = s3c_hsotg_gadget_getframe, - .start = s3c_hsotg_start, - .stop = s3c_hsotg_stop, + .udc_start = s3c_hsotg_udc_start, + .udc_stop = s3c_hsotg_udc_stop, }; /** @@ -3462,6 +3460,23 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) for (epnum = 0; epnum < hsotg->num_of_eps; epnum++) s3c_hsotg_initep(hsotg, &hsotg->eps[epnum], epnum); + /* disable power and clock */ + + ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), + hsotg->supplies); + if (ret) { + dev_err(hsotg->dev, "failed to disable supplies: %d\n", ret); + goto err_ep_mem; + } + + s3c_hsotg_phy_disable(hsotg); + + ret = device_add(&hsotg->gadget.dev); + if (ret) { + put_device(&hsotg->gadget.dev); + goto err_ep_mem; + } + ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget); if (ret) goto err_ep_mem; @@ -3479,7 +3494,6 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev) err_supplies: s3c_hsotg_phy_disable(hsotg); - regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); clk_disable(hsotg->clk); @@ -3515,9 +3529,6 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev) kfree(hsotg->regs_res); s3c_hsotg_phy_disable(hsotg); - - - regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies); clk_disable(hsotg->clk); -- cgit v1.2.3