usb: dwc2: Eliminate support for usb cable detection 80/225180/1
authorDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 18 Feb 2020 04:20:31 +0000 (13:20 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 18 Feb 2020 04:20:31 +0000 (13:20 +0900)
Detection of usb cable is no longer used in rpi4, thus this eliminates
all relevant code.

Change-Id: Id5e8c68886b3edc352fb85d8509df7890d41d28d
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
arch/arm/boot/dts/bcm2711-rpi-4-b.dts
arch/arm/configs/tizen_bcm2711_defconfig
drivers/usb/dwc2/Kconfig
drivers/usb/dwc2/Makefile
drivers/usb/dwc2/core.h
drivers/usb/dwc2/extcon.c [deleted file]
drivers/usb/dwc2/gadget.c
drivers/usb/dwc2/params.c

index 9431157..bf6bb86 100644 (file)
        g-np-tx-fifo-size = <32>;
        g-rx-fifo-size = <256>;
        g-tx-fifo-size = <512 512 512 512 512 256 256>;
-       g-extcon-notify;
        status = "okay";
 };
 
index d721379..bb34512 100644 (file)
@@ -376,7 +376,6 @@ CONFIG_USB_ACM=m
 CONFIG_USB_STORAGE=y
 CONFIG_USB_UAS=y
 CONFIG_USB_DWC2=y
-CONFIG_USB_DWC2_EXTCON_NOTIFY=y
 CONFIG_USB_SERIAL=y
 CONFIG_USB_SERIAL_GENERIC=y
 CONFIG_USB_SERIAL_CP210X=m
index 4b54f47..b6a495e 100644 (file)
@@ -52,15 +52,6 @@ config USB_DWC2_DUAL_ROLE
          option requires USB_GADGET to be enabled.
 endchoice
 
-config USB_DWC2_EXTCON_NOTIFY
-       bool "Enable Extcon Notification"
-       depends on USB_DWC2_PERIPHERAL || USB_DWC2_DUAL_ROLE
-       default n
-       select EXTCON
-       help
-         Say Y here to enable extcon notification using dwc2 gadget irq for
-         the target without port gpio interrupt support or external detector.
-
 config USB_DWC2_PCI
        tristate "DWC2 PCI"
        depends on USB_PCI
index bde2e43..440320c 100644 (file)
@@ -13,7 +13,6 @@ endif
 
 ifneq ($(filter y,$(CONFIG_USB_DWC2_PERIPHERAL) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
        dwc2-y                          += gadget.o
-       dwc2-$(CONFIG_USB_DWC2_EXTCON_NOTIFY)   += extcon.o
 endif
 
 ifneq ($(CONFIG_DEBUG_FS),)
index fc390f9..5ed6eeb 100644 (file)
@@ -43,7 +43,6 @@
 #include <linux/usb/gadget.h>
 #include <linux/usb/otg.h>
 #include <linux/usb/phy.h>
-#include <linux/extcon-provider.h>
 #include "hw.h"
 
 /*
@@ -488,9 +487,6 @@ 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_USB_DWC2_EXTCON_NOTIFY)
-       u32 g_extcon_notify;
-#endif
 
        bool change_speed_quirk;
 };
@@ -1165,11 +1161,6 @@ struct dwc2_hsotg {
        struct dwc2_hsotg_ep *eps_in[MAX_EPS_CHANNELS];
        struct dwc2_hsotg_ep *eps_out[MAX_EPS_CHANNELS];
 
-#if IS_ENABLED(CONFIG_USB_DWC2_EXTCON_NOTIFY)
-       struct extcon_dev *edev;
-       struct delayed_work extcon_work;
-       unsigned int extcon_state;
-#endif /* CONFIG_DWC2_EXTCON_NOTIFY */
 #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
 };
 
@@ -1364,17 +1355,6 @@ int dwc2_hsotg_tx_fifo_count(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_total_depth(struct dwc2_hsotg *hsotg);
 int dwc2_hsotg_tx_fifo_average_depth(struct dwc2_hsotg *hsotg);
 void dwc2_gadget_init_lpm(struct dwc2_hsotg *hsotg);
-#if IS_ENABLED(CONFIG_USB_DWC2_EXTCON_NOTIFY)
-void dwc2_gadget_extcon_notify(struct dwc2_hsotg *hsotg, bool on);
-void dwc2_gadget_cancel_extcon_work(struct dwc2_hsotg *hsotg);
-int dwc2_gadget_extcon_init(struct dwc2_hsotg *hsotg);
-#else
-static inline void dwc2_gadget_extcon_notify(struct dwc2_hsotg *hsotg,
-                                            bool on) {}
-static inline void dwc2_gadget_cancel_extcon_work(struct dwc2_hsotg *hsotg) {}
-static inline int dwc2_gadget_extcon_init(struct dwc2_hsotg *hsotg)
-{ return 0; }
-#endif
 #else
 static inline int dwc2_hsotg_remove(struct dwc2_hsotg *dwc2)
 { return 0; }
diff --git a/drivers/usb/dwc2/extcon.c b/drivers/usb/dwc2/extcon.c
deleted file mode 100644 (file)
index dae7ef3..0000000
+++ /dev/null
@@ -1,89 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd.
- *             http://www.samsung.com
- *
- * Copyright 2008 Openmoko, Inc.
- * Copyright 2008 Simtec Electronics
- *      Ben Dooks <ben@simtec.co.uk>
- *      http://armlinux.simtec.co.uk/
- *
- * S3C USB2.0 High-speed / Extcon Notification Driver
- */
-
-#include <linux/kernel.h>
-#include <linux/module.h>
-
-#include "core.h"
-#include "hw.h"
-
-#define DWC2_EXTCON_NOTIFY_DELAY       10 /* msec */
-
-static const unsigned int supported_cable[] = {
-       EXTCON_USB,
-       EXTCON_NONE,
-};
-
-void dwc2_gadget_extcon_notify(struct dwc2_hsotg *hsotg, bool on)
-{
-       if (!hsotg->params.g_extcon_notify)
-               return;
-
-       hsotg->extcon_state = on;
-
-       if (delayed_work_pending(&hsotg->extcon_work))
-               cancel_delayed_work(&hsotg->extcon_work);
-
-       queue_delayed_work(system_power_efficient_wq, &hsotg->extcon_work,
-                          msecs_to_jiffies(DWC2_EXTCON_NOTIFY_DELAY));
-}
-
-void dwc2_gadget_cancel_extcon_work(struct dwc2_hsotg *hsotg)
-{
-       if (!hsotg->params.g_extcon_notify)
-               return;
-
-       cancel_delayed_work_sync(&hsotg->extcon_work);
-}
-
-static void dwc2_gadget_extcon_work(struct work_struct *work)
-{
-       struct dwc2_hsotg *hsotg = container_of(to_delayed_work(work),
-                                               struct dwc2_hsotg,
-                                               extcon_work);
-
-       extcon_set_state_sync(hsotg->edev, EXTCON_USB, hsotg->extcon_state);
-}
-
-int dwc2_gadget_extcon_init(struct dwc2_hsotg *hsotg)
-{
-       struct device *dev = hsotg->dev;
-       struct extcon_dev *edev;
-       int ret;
-
-       if (!hsotg->params.g_extcon_notify)
-               return 0;
-
-       edev = devm_extcon_dev_allocate(dev, supported_cable);
-       if (IS_ERR(edev))
-               return -ENODEV;
-
-       ret = devm_extcon_dev_register(dev, edev);
-       if (ret)
-               return ret;
-
-       hsotg->edev = edev;
-
-       INIT_DELAYED_WORK(&hsotg->extcon_work, dwc2_gadget_extcon_work);
-
-       /*
-        * HACK: In order to give chance to setup gadget for user-space
-        * daemon, force extcon state as connected initially. After udc is
-        * successfully binded, the state will be updated as following
-        * the cable connection state.
-        */
-       dwc2_gadget_extcon_notify(hsotg, true);
-       hsotg->connected = 1;
-
-       return 0;
-}
index 71f89ff..3f68edd 100644 (file)
@@ -3559,8 +3559,6 @@ irq_retry:
                dwc2_writel(hsotg, GINTSTS_ENUMDONE, GINTSTS);
 
                dwc2_hsotg_irq_enumdone(hsotg);
-
-               dwc2_gadget_extcon_notify(hsotg, true);
        }
 
        if (gintsts & (GINTSTS_OEPINT | GINTSTS_IEPINT)) {
@@ -3625,13 +3623,6 @@ irq_retry:
        if (gintsts & GINTSTS_ERLYSUSP) {
                dev_dbg(hsotg->dev, "GINTSTS_ErlySusp\n");
                dwc2_writel(hsotg, GINTSTS_ERLYSUSP, GINTSTS);
-
-               /*
-                * we assume early suspend interrupt as disconnection
-                * signal when connected state is true.
-                */
-               if (hsotg->connected)
-                       dwc2_gadget_extcon_notify(hsotg, false);
        }
 
        /*
@@ -4418,22 +4409,11 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, int is_on)
                dwc2_enable_acg(hsotg);
                dwc2_hsotg_core_connect(hsotg);
        } else {
-               /*
-                * If gadget disconnection makes also PHY pullup
-                * disconnection, usb controller cannot generate
-                * interrupt for usb connection and thus extcon
-                * notification won't be working. In order to prevent
-                * this situation, we have to keep PHY pullup alive
-                * when extcon notification is activated.
-                */
-               if (hsotg->params.g_extcon_notify)
-                       goto skip_disconnect;
                dwc2_hsotg_core_disconnect(hsotg);
                dwc2_hsotg_disconnect(hsotg);
                hsotg->enabled = 0;
        }
 
-skip_disconnect:
        hsotg->gadget.speed = USB_SPEED_UNKNOWN;
        spin_unlock_irqrestore(&hsotg->lock, flags);
 
@@ -4711,12 +4691,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
        else if (hsotg->dr_mode == USB_DR_MODE_PERIPHERAL)
                hsotg->op_state = OTG_STATE_B_PERIPHERAL;
 
-       ret = dwc2_gadget_extcon_init(hsotg);
-       if (ret) {
-               dev_err(dev, "failed to initialize extcon device");
-               return ret;
-       }
-
        ret = dwc2_hsotg_hw_cfg(hsotg);
        if (ret) {
                dev_err(hsotg->dev, "Hardware configuration failed: %d\n", ret);
@@ -4795,7 +4769,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg)
  */
 int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
 {
-       dwc2_gadget_cancel_extcon_work(hsotg);
        usb_del_gadget_udc(&hsotg->gadget);
        dwc2_hsotg_ep_free_request(&hsotg->eps_out[0]->ep, hsotg->ctrl_req);
 
@@ -4809,8 +4782,6 @@ int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg)
        if (hsotg->lx_state != DWC2_L0)
                return 0;
 
-       dwc2_gadget_cancel_extcon_work(hsotg);
-
        if (hsotg->driver) {
                int ep;
 
index 540e9b3..dff2c6e 100644 (file)
@@ -378,11 +378,6 @@ static void dwc2_get_device_properties(struct dwc2_hsotg *hsotg)
                                                       &p->g_tx_fifo_size[1],
                                                       num);
                }
-#if IS_ENABLED(CONFIG_USB_DWC2_EXTCON_NOTIFY)
-               if (of_find_property(hsotg->dev->of_node,
-                                       "g-extcon-notify", NULL))
-                       p->g_extcon_notify = true;
-#endif
        }
 
        if (of_find_property(hsotg->dev->of_node, "disable-over-current", NULL))