From: Dongwoo Lee Date: Tue, 18 Feb 2020 04:36:40 +0000 (+0900) Subject: usb: dwc2: gadget: Set extcon state for usb cable as always true X-Git-Tag: accepted/tizen/unified/20230814.120944~215 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8319e62c24fd46cec1fa784e5c66baf6b52dbaf7;p=platform%2Fkernel%2Flinux-rpi.git 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: I5bcc1b7560278dab8bde6fc80549bc145179574c Signed-off-by: Dongwoo Lee --- diff --git a/drivers/usb/dwc2/core.h b/drivers/usb/dwc2/core.h index 71e62b3..93d7078 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -523,6 +523,9 @@ struct dwc2_core_params { u32 g_rx_fifo_size; u32 g_np_tx_fifo_size; u32 g_tx_fifo_size[MAX_EPS_CHANNELS]; +#if IS_ENABLED(CONFIG_EXTCON) + bool g_extcon_always_on; +#endif bool change_speed_quirk; }; diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 519bb82..8599837 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -5060,6 +5061,25 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg) 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; } diff --git a/drivers/usb/dwc2/params.c b/drivers/usb/dwc2/params.c index 59e1193..fb0f27b 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -454,6 +454,11 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg) &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,