aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/renesas_usbhs/common.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/renesas_usbhs/common.c')
-rw-r--r--drivers/usb/renesas_usbhs/common.c25
1 files changed, 19 insertions, 6 deletions
diff --git a/drivers/usb/renesas_usbhs/common.c b/drivers/usb/renesas_usbhs/common.c
index 371478704899..4cf77d3c3bd2 100644
--- a/drivers/usb/renesas_usbhs/common.c
+++ b/drivers/usb/renesas_usbhs/common.c
@@ -363,6 +363,7 @@ static void usbhsc_hotplug(struct usbhs_priv *priv)
363 struct usbhs_mod *mod = usbhs_mod_get_current(priv); 363 struct usbhs_mod *mod = usbhs_mod_get_current(priv);
364 int id; 364 int id;
365 int enable; 365 int enable;
366 int cable;
366 int ret; 367 int ret;
367 368
368 /* 369 /*
@@ -376,6 +377,16 @@ static void usbhsc_hotplug(struct usbhs_priv *priv)
376 id = usbhs_platform_call(priv, get_id, pdev); 377 id = usbhs_platform_call(priv, get_id, pdev);
377 378
378 if (enable && !mod) { 379 if (enable && !mod) {
380 if (priv->edev) {
381 cable = extcon_get_cable_state(priv->edev, "USB-HOST");
382 if ((cable > 0 && id != USBHS_HOST) ||
383 (!cable && id != USBHS_GADGET)) {
384 dev_info(&pdev->dev,
385 "USB cable plugged in doesn't match the selected role!\n");
386 return;
387 }
388 }
389
379 ret = usbhs_mod_change(priv, id); 390 ret = usbhs_mod_change(priv, id);
380 if (ret < 0) 391 if (ret < 0)
381 return; 392 return;
@@ -514,6 +525,12 @@ static int usbhs_probe(struct platform_device *pdev)
514 if (IS_ERR(priv->base)) 525 if (IS_ERR(priv->base))
515 return PTR_ERR(priv->base); 526 return PTR_ERR(priv->base);
516 527
528 if (of_property_read_bool(pdev->dev.of_node, "extcon")) {
529 priv->edev = extcon_get_edev_by_phandle(&pdev->dev, 0);
530 if (IS_ERR(priv->edev))
531 return PTR_ERR(priv->edev);
532 }
533
517 /* 534 /*
518 * care platform info 535 * care platform info
519 */ 536 */
@@ -615,7 +632,7 @@ static int usbhs_probe(struct platform_device *pdev)
615 */ 632 */
616 ret = usbhs_platform_call(priv, hardware_init, pdev); 633 ret = usbhs_platform_call(priv, hardware_init, pdev);
617 if (ret < 0) { 634 if (ret < 0) {
618 dev_err(&pdev->dev, "platform prove failed.\n"); 635 dev_err(&pdev->dev, "platform init failed.\n");
619 goto probe_end_mod_exit; 636 goto probe_end_mod_exit;
620 } 637 }
621 638
@@ -632,16 +649,12 @@ static int usbhs_probe(struct platform_device *pdev)
632 /* 649 /*
633 * manual call notify_hotplug for cold plug 650 * manual call notify_hotplug for cold plug
634 */ 651 */
635 ret = usbhsc_drvcllbck_notify_hotplug(pdev); 652 usbhsc_drvcllbck_notify_hotplug(pdev);
636 if (ret < 0)
637 goto probe_end_call_remove;
638 653
639 dev_info(&pdev->dev, "probed\n"); 654 dev_info(&pdev->dev, "probed\n");
640 655
641 return ret; 656 return ret;
642 657
643probe_end_call_remove:
644 usbhs_platform_call(priv, hardware_exit, pdev);
645probe_end_mod_exit: 658probe_end_mod_exit:
646 usbhs_mod_remove(priv); 659 usbhs_mod_remove(priv);
647probe_end_fifo_exit: 660probe_end_fifo_exit: