Skip to content

Commit f65f0f1

Browse files
Lukasz MajewskiFelipe Balbi
authored andcommitted
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 and pullup afterwards. Signed-off-by: Lukasz Majewski <[email protected]> Signed-off-by: Sangwook Lee <[email protected]> Signed-off-by: Kyungmin Park <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent b3f489b commit f65f0f1

File tree

1 file changed

+36
-25
lines changed

1 file changed

+36
-25
lines changed

drivers/usb/gadget/s3c-hsotg.c

Lines changed: 36 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -2822,8 +2822,8 @@ static void s3c_hsotg_init(struct s3c_hsotg *hsotg)
28222822
hsotg->regs + S3C_GAHBCFG);
28232823
}
28242824

2825-
static int s3c_hsotg_start(struct usb_gadget_driver *driver,
2826-
int (*bind)(struct usb_gadget *))
2825+
static int s3c_hsotg_udc_start(struct usb_gadget *gadget,
2826+
struct usb_gadget_driver *driver)
28272827
{
28282828
struct s3c_hsotg *hsotg = our_hsotg;
28292829
int ret;
@@ -2841,7 +2841,7 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver,
28412841
if (driver->max_speed < USB_SPEED_FULL)
28422842
dev_err(hsotg->dev, "%s: bad speed\n", __func__);
28432843

2844-
if (!bind || !driver->setup) {
2844+
if (!driver->setup) {
28452845
dev_err(hsotg->dev, "%s: missing entry points\n", __func__);
28462846
return -EINVAL;
28472847
}
@@ -2854,20 +2854,14 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver,
28542854
hsotg->gadget.dev.dma_mask = hsotg->dev->dma_mask;
28552855
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
28562856

2857-
ret = device_add(&hsotg->gadget.dev);
2857+
ret = regulator_bulk_enable(ARRAY_SIZE(hsotg->supplies),
2858+
hsotg->supplies);
28582859
if (ret) {
2859-
dev_err(hsotg->dev, "failed to register gadget device\n");
2860+
dev_err(hsotg->dev, "failed to enable supplies: %d\n", ret);
28602861
goto err;
28612862
}
28622863

2863-
ret = bind(&hsotg->gadget);
2864-
if (ret) {
2865-
dev_err(hsotg->dev, "failed bind %s\n", driver->driver.name);
2866-
2867-
hsotg->gadget.dev.driver = NULL;
2868-
hsotg->driver = NULL;
2869-
goto err;
2870-
}
2864+
s3c_hsotg_phy_enable(hsotg);
28712865

28722866
s3c_hsotg_core_init(hsotg);
28732867
hsotg->last_rst = jiffies;
@@ -2880,7 +2874,8 @@ static int s3c_hsotg_start(struct usb_gadget_driver *driver,
28802874
return ret;
28812875
}
28822876

2883-
static int s3c_hsotg_stop(struct usb_gadget_driver *driver)
2877+
static int s3c_hsotg_udc_stop(struct usb_gadget *gadget,
2878+
struct usb_gadget_driver *driver)
28842879
{
28852880
struct s3c_hsotg *hsotg = our_hsotg;
28862881
int ep;
@@ -2895,13 +2890,12 @@ static int s3c_hsotg_stop(struct usb_gadget_driver *driver)
28952890
for (ep = 0; ep < hsotg->num_of_eps; ep++)
28962891
s3c_hsotg_ep_disable(&hsotg->eps[ep].ep);
28972892

2898-
call_gadget(hsotg, disconnect);
2893+
s3c_hsotg_phy_disable(hsotg);
2894+
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
28992895

2900-
driver->unbind(&hsotg->gadget);
29012896
hsotg->driver = NULL;
29022897
hsotg->gadget.speed = USB_SPEED_UNKNOWN;
2903-
2904-
device_del(&hsotg->gadget.dev);
2898+
hsotg->gadget.dev.driver = NULL;
29052899

29062900
dev_info(hsotg->dev, "unregistered gadget driver '%s'\n",
29072901
driver->driver.name);
@@ -2916,8 +2910,8 @@ static int s3c_hsotg_gadget_getframe(struct usb_gadget *gadget)
29162910

29172911
static struct usb_gadget_ops s3c_hsotg_gadget_ops = {
29182912
.get_frame = s3c_hsotg_gadget_getframe,
2919-
.start = s3c_hsotg_start,
2920-
.stop = s3c_hsotg_stop,
2913+
.udc_start = s3c_hsotg_udc_start,
2914+
.udc_stop = s3c_hsotg_udc_stop,
29212915
};
29222916

29232917
/**
@@ -3479,6 +3473,23 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
34793473
for (epnum = 0; epnum < hsotg->num_of_eps; epnum++)
34803474
s3c_hsotg_initep(hsotg, &hsotg->eps[epnum], epnum);
34813475

3476+
/* disable power and clock */
3477+
3478+
ret = regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies),
3479+
hsotg->supplies);
3480+
if (ret) {
3481+
dev_err(hsotg->dev, "failed to disable supplies: %d\n", ret);
3482+
goto err_ep_mem;
3483+
}
3484+
3485+
s3c_hsotg_phy_disable(hsotg);
3486+
3487+
ret = device_add(&hsotg->gadget.dev);
3488+
if (ret) {
3489+
put_device(&hsotg->gadget.dev);
3490+
goto err_ep_mem;
3491+
}
3492+
34823493
ret = usb_add_gadget_udc(&pdev->dev, &hsotg->gadget);
34833494
if (ret)
34843495
goto err_ep_mem;
@@ -3496,7 +3507,6 @@ static int __devinit s3c_hsotg_probe(struct platform_device *pdev)
34963507
err_supplies:
34973508
s3c_hsotg_phy_disable(hsotg);
34983509

3499-
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
35003510
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
35013511

35023512
clk_disable(hsotg->clk);
@@ -3523,7 +3533,10 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
35233533

35243534
s3c_hsotg_delete_debug(hsotg);
35253535

3526-
usb_gadget_unregister_driver(hsotg->driver);
3536+
if (hsotg->driver) {
3537+
/* should have been done already by driver model core */
3538+
usb_gadget_unregister_driver(hsotg->driver);
3539+
}
35273540

35283541
free_irq(hsotg->irq, hsotg);
35293542
iounmap(hsotg->regs);
@@ -3532,14 +3545,12 @@ static int __devexit s3c_hsotg_remove(struct platform_device *pdev)
35323545
kfree(hsotg->regs_res);
35333546

35343547
s3c_hsotg_phy_disable(hsotg);
3535-
3536-
3537-
regulator_bulk_disable(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
35383548
regulator_bulk_free(ARRAY_SIZE(hsotg->supplies), hsotg->supplies);
35393549

35403550
clk_disable(hsotg->clk);
35413551
clk_put(hsotg->clk);
35423552

3553+
device_unregister(&hsotg->gadget.dev);
35433554
kfree(hsotg);
35443555
return 0;
35453556
}

0 commit comments

Comments
 (0)