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/20210330.111217~123 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=7da838d3a98f39724d1c6b3414d913cfa6ba2389;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 7161344..a8c6ba2 100644 --- a/drivers/usb/dwc2/core.h +++ b/drivers/usb/dwc2/core.h @@ -514,6 +514,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 ad4c943..7ceb151 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #include @@ -4940,6 +4941,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 267543c..afb0dc8 100644 --- a/drivers/usb/dwc2/params.c +++ b/drivers/usb/dwc2/params.c @@ -439,6 +439,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,