#include <linux/io.h>
#include <linux/slab.h>
#include <linux/of_platform.h>
+#include <linux/extcon-provider.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
dwc2_hsotg_dump(hsotg);
+#if IS_ENABLED(CONFIG_EXTCON)
+ if (hsotg->params.g_extcon_always_on) {
+ struct extcon_dev *edev;
+ static const unsigned int supported_cable[] = {
+ EXTCON_USB,
+ EXTCON_NONE,
+ };
+
+ edev = devm_extcon_dev_allocate(dev, supported_cable);
+ if (IS_ERR(edev))
+ return PTR_ERR(edev);
+
+ ret = devm_extcon_dev_register(dev, edev);
+ if (ret)
+ return ret;
+
+ extcon_set_state_sync(edev, EXTCON_USB, true);
+ }
+#endif
return 0;
}
&p->g_np_tx_fifo_size);
num = device_property_count_u32(hsotg->dev, "g-tx-fifo-size");
+#if IS_ENABLED(CONFIG_EXTCON)
+ if (of_find_property(hsotg->dev->of_node,
+ "g-extcon-always-on", NULL))
+ p->g_extcon_always_on = 1;
+#endif
if (num > 0) {
num = min(num, 15);
memset(p->g_tx_fifo_size, 0,