usb: dwc2: Remove support for usb cable detection
authorDongwoo Lee <dwoo08.lee@samsung.com>
Tue, 18 Feb 2020 08:51:50 +0000 (17:51 +0900)
committerDongwoo Lee <dwoo08.lee@samsung.com>
Mon, 24 Feb 2020 02:08:55 +0000 (11:08 +0900)
Detection of usb cable is no longer used, thus this eliminates all
relevant codes.

Change-Id: I2dc226bc21dafa486e87e40ccb03b5242af774dc
Signed-off-by: Dongwoo Lee <dwoo08.lee@samsung.com>
arch/arm/boot/dts/s5p4418-artik530-raptor-common.dtsi
arch/arm64/boot/dts/nexell/s5p6818-artik710-raptor-common.dtsi
drivers/usb/dwc2/core.h
drivers/usb/dwc2/gadget.c

index 8364778c1fd8b18c4a920c9cecba7575838c28c1..beed5d96ff5f940e41dc8b11e815455d3fe568e0 100644 (file)
 
                dwc2otg@c0040000 {
                        gpios = <&gpio_a 15 0>;
-                       g-extcon-notify;
                        status = "okay";
                };
 
index 4575418cf5697f4e3f199a17d73cf8f883765ac3..70f58f046e337140a4c520d9a8918868eda3d211 100644 (file)
 
                dwc2otg@c0040000 {
                        gpios = <&gpio_a 15 0>;
-                       g-extcon-notify;
                        status = "okay";
                };
 
index e8285ab110c43f0d9b6b2911480e1c3e1300c022..dfd7d4c9f0f4147bba71855830473ad079283f8b 100644 (file)
@@ -872,12 +872,6 @@ struct dwc2_hsotg {
        u32 g_rx_fifo_sz;
        u32 g_np_g_tx_fifo_sz;
        u32 g_tx_fifo_sz[MAX_EPS_CHANNELS];
-       u32 g_extcon_notify;
-
-#if IS_ENABLED(CONFIG_EXTCON)
-       struct extcon_dev *edev;
-       struct work_struct extcon_work;
-#endif /* CONFIG_EXTCON */
 #endif /* CONFIG_USB_DWC2_PERIPHERAL || CONFIG_USB_DWC2_DUAL_ROLE */
 };
 
index 1da1792a284f7f31710edf6f6d8937c837cf1e00..7b1428cd51a86f3bfd38ba54db2da413dc5ab806 100644 (file)
@@ -26,7 +26,6 @@
 #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>
 #include "core.h"
 #include "hw.h"
 
-#if IS_ENABLED(CONFIG_EXTCON)
-static const unsigned int supported_cable[] = {
-       EXTCON_USB,
-       EXTCON_NONE,
-};
-
-static inline void dwc2_gadget_extcon_notify(struct dwc2_hsotg *hsotg)
-{
-       queue_work(system_power_efficient_wq, &hsotg->extcon_work);
-}
-
-static inline void dwc2_gadget_cancel_extcon_work(struct dwc2_hsotg *hsotg)
-{
-       cancel_work_sync(&hsotg->extcon_work);
-}
-
-static void dwc2_gadget_extcon_work(struct work_struct *work)
-{
-       struct dwc2_hsotg *hsotg = container_of(work, struct dwc2_hsotg,
-                                               extcon_work);
-       u32 usb_status = dwc2_readl(hsotg->regs + GOTGCTL);
-
-       if (usb_status & (GOTGCTL_ASESVLD | GOTGCTL_BSESVLD))
-               extcon_set_cable_state_(hsotg->edev, EXTCON_USB, true);
-       else
-               extcon_set_cable_state_(hsotg->edev, EXTCON_USB, false);
-}
-
-static int dwc2_gadget_extcon_init(struct dwc2_hsotg *hsotg)
-{
-       struct device *dev = hsotg->dev;
-       struct extcon_dev *edev;
-       int ret;
-
-       if (!hsotg->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_WORK(&hsotg->extcon_work, dwc2_gadget_extcon_work);
-
-       return 0;
-}
-#else
-static inline void dwc2_gadget_extcon_notify(struct dwc2_hsotg *hsotg)
-{
-}
-
-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 /* CONFIG_EXTCON */
-
 /* conversion functions */
 static inline struct dwc2_hsotg_req *our_req(struct usb_request *req)
 {
@@ -2571,31 +2504,12 @@ irq_retry:
 
                if (usb_status & GOTGCTL_BSESVLD && connected)
                        dwc2_hsotg_core_init_disconnected(hsotg, true);
-
-               if (hsotg->g_extcon_notify) {
-                       /*
-                        * USBRST interrupt can be generated by not only
-                        * disconnection but also other reason. So, we
-                        * should check the connection state with usb_status.
-                        * Fortunately, GOTGCTL_ASESVLD and GOTGCTL_BSESVLD
-                        * is activated only if the cable is connected. So,
-                        * we can recognize the disconnection situation by
-                        * checking both bits are not set.
-                        */
-                       u32 flags = GOTGCTL_ASESVLD | GOTGCTL_BSESVLD;
-
-                       if (!(usb_status & flags))
-                               dwc2_gadget_extcon_notify(hsotg);
-               }
        }
 
        if (gintsts & GINTSTS_ENUMDONE) {
                dwc2_writel(GINTSTS_ENUMDONE, hsotg->regs + GINTSTS);
 
                dwc2_hsotg_irq_enumdone(hsotg);
-
-               if (hsotg->g_extcon_notify)
-                       dwc2_gadget_extcon_notify(hsotg);
        }
 
        if (gintsts & (GINTSTS_OEPINT | GINTSTS_IEPINT)) {
@@ -3341,22 +3255,11 @@ static int dwc2_hsotg_pullup(struct usb_gadget *gadget, int is_on)
                dwc2_hsotg_core_init_disconnected(hsotg, false);
                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->g_extcon_notify)
-                       goto skip_change;
                dwc2_hsotg_core_disconnect(hsotg);
                dwc2_hsotg_disconnect(hsotg);
                hsotg->enabled = 0;
        }
 
-skip_change:
        hsotg->gadget.speed = USB_SPEED_UNKNOWN;
        spin_unlock_irqrestore(&hsotg->lock, flags);
 
@@ -3606,10 +3509,6 @@ 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_notify = of_property_read_bool(np, "g-extcon-notify");
-#endif
-
        /*
        * Register TX periodic fifo size per endpoint.
        * EP0 is excluded since it has no fifo configuration.
@@ -3680,12 +3579,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
        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;
-       }
-
        /*
         * Force Device mode before initialization.
         * This allows correctly configuring fifo for device mode.
@@ -3782,9 +3675,6 @@ int dwc2_gadget_init(struct dwc2_hsotg *hsotg, int irq)
  */
 int dwc2_hsotg_remove(struct dwc2_hsotg *hsotg)
 {
-       if (hsotg->g_extcon_notify)
-               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);
 
@@ -3808,9 +3698,6 @@ int dwc2_hsotg_suspend(struct dwc2_hsotg *hsotg)
                }
        }
 
-       if (hsotg->g_extcon_notify)
-               dwc2_gadget_cancel_extcon_work(hsotg);
-
        if (hsotg->driver) {
                int ep;