|
|
@@ -423,6 +423,42 @@ static void dwc3_omap_set_utmi_mode(struct dwc3_omap *omap)
|
|
|
dwc3_omap_write_utmi_status(omap, reg);
|
|
|
}
|
|
|
|
|
|
+static int dwc3_omap_extcon_register(struct dwc3_omap *omap)
|
|
|
+{
|
|
|
+ u32 ret;
|
|
|
+ struct device_node *node = omap->dev->of_node;
|
|
|
+ struct extcon_dev *edev;
|
|
|
+
|
|
|
+ if (of_property_read_bool(node, "extcon")) {
|
|
|
+ edev = extcon_get_edev_by_phandle(omap->dev, 0);
|
|
|
+ if (IS_ERR(edev)) {
|
|
|
+ dev_vdbg(omap->dev, "couldn't get extcon device\n");
|
|
|
+ return -EPROBE_DEFER;
|
|
|
+ }
|
|
|
+
|
|
|
+ omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
|
|
|
+ ret = extcon_register_interest(&omap->extcon_vbus_dev,
|
|
|
+ edev->name, "USB",
|
|
|
+ &omap->vbus_nb);
|
|
|
+ if (ret < 0)
|
|
|
+ dev_vdbg(omap->dev, "failed to register notifier for USB\n");
|
|
|
+
|
|
|
+ omap->id_nb.notifier_call = dwc3_omap_id_notifier;
|
|
|
+ ret = extcon_register_interest(&omap->extcon_id_dev,
|
|
|
+ edev->name, "USB-HOST",
|
|
|
+ &omap->id_nb);
|
|
|
+ if (ret < 0)
|
|
|
+ dev_vdbg(omap->dev, "failed to register notifier for USB-HOST\n");
|
|
|
+
|
|
|
+ if (extcon_get_cable_state(edev, "USB") == true)
|
|
|
+ dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
|
|
|
+ if (extcon_get_cable_state(edev, "USB-HOST") == true)
|
|
|
+ dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
|
|
|
+ }
|
|
|
+
|
|
|
+ return 0;
|
|
|
+}
|
|
|
+
|
|
|
static int dwc3_omap_probe(struct platform_device *pdev)
|
|
|
{
|
|
|
struct device_node *node = pdev->dev.of_node;
|
|
|
@@ -430,7 +466,6 @@ static int dwc3_omap_probe(struct platform_device *pdev)
|
|
|
struct dwc3_omap *omap;
|
|
|
struct resource *res;
|
|
|
struct device *dev = &pdev->dev;
|
|
|
- struct extcon_dev *edev;
|
|
|
struct regulator *vbus_reg = NULL;
|
|
|
|
|
|
int ret;
|
|
|
@@ -502,31 +537,9 @@ static int dwc3_omap_probe(struct platform_device *pdev)
|
|
|
|
|
|
dwc3_omap_enable_irqs(omap);
|
|
|
|
|
|
- if (of_property_read_bool(node, "extcon")) {
|
|
|
- edev = extcon_get_edev_by_phandle(dev, 0);
|
|
|
- if (IS_ERR(edev)) {
|
|
|
- dev_vdbg(dev, "couldn't get extcon device\n");
|
|
|
- ret = -EPROBE_DEFER;
|
|
|
- goto err2;
|
|
|
- }
|
|
|
-
|
|
|
- omap->vbus_nb.notifier_call = dwc3_omap_vbus_notifier;
|
|
|
- ret = extcon_register_interest(&omap->extcon_vbus_dev,
|
|
|
- edev->name, "USB", &omap->vbus_nb);
|
|
|
- if (ret < 0)
|
|
|
- dev_vdbg(dev, "failed to register notifier for USB\n");
|
|
|
- omap->id_nb.notifier_call = dwc3_omap_id_notifier;
|
|
|
- ret = extcon_register_interest(&omap->extcon_id_dev, edev->name,
|
|
|
- "USB-HOST", &omap->id_nb);
|
|
|
- if (ret < 0)
|
|
|
- dev_vdbg(dev,
|
|
|
- "failed to register notifier for USB-HOST\n");
|
|
|
-
|
|
|
- if (extcon_get_cable_state(edev, "USB") == true)
|
|
|
- dwc3_omap_set_mailbox(omap, OMAP_DWC3_VBUS_VALID);
|
|
|
- if (extcon_get_cable_state(edev, "USB-HOST") == true)
|
|
|
- dwc3_omap_set_mailbox(omap, OMAP_DWC3_ID_GROUND);
|
|
|
- }
|
|
|
+ ret = dwc3_omap_extcon_register(omap);
|
|
|
+ if (ret < 0)
|
|
|
+ goto err2;
|
|
|
|
|
|
ret = of_platform_populate(node, NULL, NULL, dev);
|
|
|
if (ret) {
|