From 8d39ff3b7c4a5170061cd4930387a4f351ea04f2 Mon Sep 17 00:00:00 2001 From: Seung-Woo Kim Date: Thu, 3 Dec 2020 12:53:43 +0900 Subject: [PATCH] usb: dwc_otg: 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. Note: ported from https://git.tizen.org/cgit/profile/common/platform/kernel/linux-artik7/commit/?h=tizen&id=f7e1e93b230f61d66d6a3bc58d09c53dcd305e21 Change-Id: I16fb629ccec54f0ae46e697b56750c3021f01ccb Signed-off-by: Dongwoo Lee Signed-off-by: Seung-Woo Kim --- drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c | 29 ++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c index 263ed2c..df2746f 100644 --- a/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c +++ b/drivers/amlogic/usb/dwc_otg/310/dwc_otg_driver.c @@ -75,6 +75,7 @@ #ifdef CONFIG_AMLOGIC_LEGACY_EARLY_SUSPEND #include #endif +#include #define DWC_DRIVER_VERSION "3.10a 12-MAY-2014" #define DWC_DRIVER_DESC "HS OTG USB Controller driver" @@ -968,6 +969,9 @@ static int dwc_otg_driver_probe(struct platform_device *pdev) struct dwc_otg_driver_module_params *pcore_para; static int dcount; int controller_type = USB_NORMAL; +#if IS_ENABLED(CONFIG_EXTCON) + bool g_extcon_always_on = false; +#endif dev_dbg(&pdev->dev, "dwc_otg_driver_probe(%p)\n", pdev); @@ -1069,6 +1073,11 @@ static int dwc_otg_driver_probe(struct platform_device *pdev) phy_interface = 2; } +#if IS_ENABLED(CONFIG_EXTCON) + g_extcon_always_on = + of_property_read_bool(of_node, "g-extcon-always-on"); +#endif + dwc_otg_module_params.host_rx_fifo_size = dwc_otg_module_params.data_fifo_size / 2; DWC_PRINTF("dwc_otg: %s: type: %d speed: %d, ", s_clock_name, port_type, port_speed); @@ -1099,6 +1108,26 @@ static int dwc_otg_driver_probe(struct platform_device *pdev) memset(dwc_otg_device, 0, sizeof(*dwc_otg_device)); dwc_otg_device->os_dep.reg_offset = 0xFFFFFFFF; +#if IS_ENABLED(CONFIG_EXTCON) + if (g_extcon_always_on) { + struct extcon_dev *edev; + static const unsigned int supported_cable[] = { + EXTCON_USB, + EXTCON_NONE, + }; + + edev = devm_extcon_dev_allocate(&pdev->dev, supported_cable); + if (IS_ERR(edev)) + return PTR_ERR(edev); + + retval = devm_extcon_dev_register(&pdev->dev, edev); + if (retval) + return retval; + + extcon_set_cable_state_(edev, EXTCON_USB, true); + } +#endif + /* * Map the DWC_otg Core memory into virtual address space. */ -- 2.7.4