summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDongwoo Lee <dwoo08.lee@samsung.com>2020-02-18 18:23:43 +0900
committerDongwoo Lee <dwoo08.lee@samsung.com>2020-02-18 18:31:54 +0900
commitf7e1e93b230f61d66d6a3bc58d09c53dcd305e21 (patch)
tree2ac6e76f683cbe5fb33d272aba2f5ac169ea2f0e
parented40fe9345b964997aaaaf1618a89b2981c8a706 (diff)
downloadlinux-artik7-f7e1e93b230f61d66d6a3bc58d09c53dcd305e21.tar.gz
linux-artik7-f7e1e93b230f61d66d6a3bc58d09c53dcd305e21.tar.bz2
linux-artik7-f7e1e93b230f61d66d6a3bc58d09c53dcd305e21.zip
usb: dwc2: gadget: Set extcon state for usb cable as always true
To inform to userspace as enable usb features always, set extcon state for usb cable as connected permanently. To enable this, add "g-extcon-always-on" property on dt. Change-Id: I687ca1b098d007a5d0ca7ddf6d552605195cafcf Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
-rw-r--r--drivers/usb/dwc2/core.h3
-rw-r--r--drivers/usb/dwc2/gadget.c24
2 files changed, 27 insertions, 0 deletions
diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h
index dfd7d4c9f0f4..b3e4c21323d8 100644
--- a/drivers/usb/dwc2/core.h
+++ b/drivers/usb/dwc2/core.h
@@ -872,6 +872,9 @@ struct dwc2_hsotg {
u32 g_rx_fifo_sz;
u32 g_np_g_tx_fifo_sz;
u32 g_tx_fifo_sz[MAX_EPS_CHANNELS];
+#if IS_ENABLED(CONFIG_EXTCON)
+ bool g_extcon_always_on;
+#endif
#endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
};
diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c
index 7b1428cd51a8..856ba0603d1c 100644
--- a/drivers/usb/dwc2/gadget.c
+++ b/drivers/usb/dwc2/gadget.c
@@ -26,6 +26,7 @@
#include <linux/io.h>
#include <linux/slab.h>
#include <linux/of_platform.h>
+#include <linux/extcon.h>
#include <linux/usb/ch9.h>
#include <linux/usb/gadget.h>
@@ -3509,6 +3510,10 @@ static void dwc2_hsotg_of_probe(struct dwc2_hsotg *hsotg)
/* Enable dma if requested in device tree */
hsotg->g_using_dma = of_property_read_bool(np, "g-use-dma");
+#if IS_ENABLED(CONFIG_EXTCON)
+ hsotg->g_extcon_always_on =
+ of_property_read_bool(np, "g-extcon-always-on");
+#endif
/*
* Register TX periodic fifo size per endpoint.
* EP0 is excluded since it has no fifo configuration.
@@ -3666,6 +3671,25 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
}
dwc2_hsotg_dump(hsotg);
+#if IS_ENABLED(CONFIG_EXTCON)
+ if (hsotg->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_cable_state_(edev, EXTCON_USB, true);
+ }
+#endif
return 0;
}