@@ -11,6 +11,7 @@
#include <linux/of_graph.h>
#include <linux/platform_device.h>
#include <linux/property.h>
+#include <linux/of_platform.h>
#include "debug.h"
#include "core.h"
@@ -539,9 +540,30 @@ static int dwc3_setup_role_switch(struct dwc3 *dwc)
dwc3_set_mode(dwc, DWC3_GCTL_PRTCAP_DEVICE);
return 0;
}
+
+static int dwc3_register_gpio_usb_connector(struct dwc3 *dwc)
+{
+ struct device *dev = dwc->dev;
+ struct device_node *np = dev->of_node, *conn_np;
+ int ret = 0;
+
+ conn_np = of_get_child_by_name(np, "connector");
+ if (!conn_np) {
+ dev_dbg(dev, "no connector child node specified\n");
+ goto done;
+ }
+
+ if (of_device_is_compatible(conn_np, "gpio-usb-b-connector"))
+ ret = of_platform_populate(np, NULL, NULL, dev);
+done:
+ of_node_put(conn_np);
+ return ret;
+}
+
#else
#define ROLE_SWITCH 0
#define dwc3_setup_role_switch(x) 0
+#define dwc3_register_gpio_usb_connector(x) 0
#endif
int dwc3_drd_init(struct dwc3 *dwc)
@@ -557,6 +579,9 @@ int dwc3_drd_init(struct dwc3 *dwc)
ret = dwc3_setup_role_switch(dwc);
if (ret < 0)
return ret;
+ ret = dwc3_register_gpio_usb_connector(dwc);
+ if (ret < 0)
+ return ret;
} else if (dwc->edev) {
dwc->edev_nb.notifier_call = dwc3_drd_notifier;
ret = extcon_register_notifier(dwc->edev, EXTCON_USB_HOST,