Revert "usb: dwc2: override PHY input signals with usb role switch support"
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jul 2020 13:34:15 +0000 (15:34 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 27 Jul 2020 13:34:15 +0000 (15:34 +0200)
This reverts commit bc0f0d4a5853e32ba97a0318f774570428fc5634.

It was not meant to be applied yet.

Cc: Minas Harutyunyan <hminas@synopsys.com>
Cc: Amelie Delaunay <amelie.delaunay@st.com>
Cc: Felipe Balbi <balbi@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/usb/dwc2/Kconfig
drivers/usb/dwc2/Makefile
drivers/usb/dwc2/core.h
drivers/usb/dwc2/drd.c [deleted file]
drivers/usb/dwc2/gadget.c
drivers/usb/dwc2/platform.c

index dceb8f32414e7703cfd4c32603b30e3c4e318856..16e1aa304edc402d3565429c29ae48648a54b2c2 100644 (file)
@@ -47,7 +47,6 @@ config USB_DWC2_PERIPHERAL
 config USB_DWC2_DUAL_ROLE
        bool "Dual Role mode"
        depends on (USB=y && USB_GADGET=y) || (USB_DWC2=m && USB && USB_GADGET)
-       select USB_ROLE_SWITCH
        help
          Select this option if you want the driver to work in a dual-role
          mode. In this mode both host and gadget features are enabled, and
index 2bcd6945df461adc790810ef268be754bf12a53f..440320cc20a4704eff1b507fab656fa52bb5881f 100644 (file)
@@ -3,7 +3,7 @@ ccflags-$(CONFIG_USB_DWC2_DEBUG)        += -DDEBUG
 ccflags-$(CONFIG_USB_DWC2_VERBOSE)     += -DVERBOSE_DEBUG
 
 obj-$(CONFIG_USB_DWC2)                 += dwc2.o
-dwc2-y                                 := core.o core_intr.o platform.o drd.o
+dwc2-y                                 := core.o core_intr.o platform.o
 dwc2-y                                 += params.o
 
 ifneq ($(filter y,$(CONFIG_USB_DWC2_HOST) $(CONFIG_USB_DWC2_DUAL_ROLE)),)
index 33e790ccefb3606abd739b7e5293323f4802dad6..9deff0400a92280e6200737269589b76d6e45fc9 100644 (file)
@@ -860,7 +860,6 @@ struct dwc2_hregs_backup {
  *                      - USB_DR_MODE_PERIPHERAL
  *                      - USB_DR_MODE_HOST
  *                      - USB_DR_MODE_OTG
- * @role_sw:           usb_role_switch handle
  * @hcd_enabled:       Host mode sub-driver initialization indicator.
  * @gadget_enabled:    Peripheral mode sub-driver initialization indicator.
  * @ll_hw_enabled:     Status of low-level hardware resources.
@@ -1055,7 +1054,6 @@ struct dwc2_hsotg {
        struct dwc2_core_params params;
        enum usb_otg_state op_state;
        enum usb_dr_mode dr_mode;
-       struct usb_role_switch *role_sw;
        unsigned int hcd_enabled:1;
        unsigned int gadget_enabled:1;
        unsigned int ll_hw_enabled:1;
@@ -1378,11 +1376,6 @@ static inline int dwc2_is_device_mode(struct dwc2_hsotg *hsotg)
        return (dwc2_readl(hsotg, GINTSTS) & GINTSTS_CURMODE_HOST) == 0;
 }
 
-int dwc2_drd_init(struct dwc2_hsotg *hsotg);
-void dwc2_drd_suspend(struct dwc2_hsotg *hsotg);
-void dwc2_drd_resume(struct dwc2_hsotg *hsotg);
-void dwc2_drd_exit(struct dwc2_hsotg *hsotg);
-
 /*
  * Dump core registers and SPRAM
  */
@@ -1399,7 +1392,6 @@ int dwc2_hsotg_resume(struct dwc2_hsotg *dwc2);
 int dwc2_gadget_init(struct dwc2_hsotg *hsotg);
 void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *dwc2,
                                       bool reset);
-void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg);
 void dwc2_hsotg_core_connect(struct dwc2_hsotg *hsotg);
 void dwc2_hsotg_disconnect(struct dwc2_hsotg *dwc2);
 int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
diff --git a/drivers/usb/dwc2/drd.c b/drivers/usb/dwc2/drd.c
deleted file mode 100644 (file)
index 032efff..0000000
+++ /dev/null
@@ -1,190 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-/*
- * drd.c - DesignWare USB2 DRD Controller Dual-role support
- *
- * Copyright (C) 2020 STMicroelectronics
- *
- * Author(s): Amelie Delaunay <amelie.delaunay@st.com>
- */
-
-#include <linux/iopoll.h>
-#include <linux/platform_device.h>
-#include <linux/usb/role.h>
-#include "core.h"
-
-static void dwc2_ovr_init(struct dwc2_hsotg *hsotg)
-{
-       unsigned long flags;
-       u32 gotgctl;
-
-       spin_lock_irqsave(&hsotg->lock, flags);
-
-       gotgctl = dwc2_readl(hsotg, GOTGCTL);
-       gotgctl |= GOTGCTL_BVALOEN | GOTGCTL_AVALOEN | GOTGCTL_VBVALOEN;
-       gotgctl |= GOTGCTL_DBNCE_FLTR_BYPASS;
-       gotgctl &= ~(GOTGCTL_BVALOVAL | GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL);
-       dwc2_writel(hsotg, gotgctl, GOTGCTL);
-
-       dwc2_force_mode(hsotg, false);
-
-       spin_unlock_irqrestore(&hsotg->lock, flags);
-}
-
-static int dwc2_ovr_avalid(struct dwc2_hsotg *hsotg, bool valid)
-{
-       u32 gotgctl = dwc2_readl(hsotg, GOTGCTL);
-
-       /* Check if A-Session is already in the right state */
-       if ((valid && (gotgctl & GOTGCTL_ASESVLD)) ||
-           (!valid && !(gotgctl & GOTGCTL_ASESVLD)))
-               return -EALREADY;
-
-       if (valid)
-               gotgctl |= GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL;
-       else
-               gotgctl &= ~(GOTGCTL_AVALOVAL | GOTGCTL_VBVALOVAL);
-       dwc2_writel(hsotg, gotgctl, GOTGCTL);
-
-       return 0;
-}
-
-static int dwc2_ovr_bvalid(struct dwc2_hsotg *hsotg, bool valid)
-{
-       u32 gotgctl = dwc2_readl(hsotg, GOTGCTL);
-
-       /* Check if B-Session is already in the right state */
-       if ((valid && (gotgctl & GOTGCTL_BSESVLD)) ||
-           (!valid && !(gotgctl & GOTGCTL_BSESVLD)))
-               return -EALREADY;
-
-       if (valid)
-               gotgctl |= GOTGCTL_BVALOVAL | GOTGCTL_VBVALOVAL;
-       else
-               gotgctl &= ~(GOTGCTL_BVALOVAL | GOTGCTL_VBVALOVAL);
-       dwc2_writel(hsotg, gotgctl, GOTGCTL);
-
-       return 0;
-}
-
-static int dwc2_drd_role_sw_set(struct usb_role_switch *sw, enum usb_role role)
-{
-       struct dwc2_hsotg *hsotg = usb_role_switch_get_drvdata(sw);
-       unsigned long flags;
-
-       /* Skip session not in line with dr_mode */
-       if ((role == USB_ROLE_DEVICE && hsotg->dr_mode == USB_DR_MODE_HOST) ||
-           (role == USB_ROLE_HOST && hsotg->dr_mode == USB_DR_MODE_PERIPHERAL))
-               return -EINVAL;
-
-       /* Skip session if core is in test mode */
-       if (role == USB_ROLE_NONE && hsotg->test_mode) {
-               dev_dbg(hsotg->dev, "Core is in test mode\n");
-               return -EBUSY;
-       }
-
-       spin_lock_irqsave(&hsotg->lock, flags);
-
-       if (role == USB_ROLE_HOST) {
-               if (dwc2_ovr_avalid(hsotg, true))
-                       goto unlock;
-
-               if (hsotg->dr_mode == USB_DR_MODE_OTG)
-                       /*
-                        * This will raise a Connector ID Status Change
-                        * Interrupt - connID A
-                        */
-                       dwc2_force_mode(hsotg, true);
-       } else if (role == USB_ROLE_DEVICE) {
-               if (dwc2_ovr_bvalid(hsotg, true))
-                       goto unlock;
-
-               if (hsotg->dr_mode == USB_DR_MODE_OTG)
-                       /*
-                        * This will raise a Connector ID Status Change
-                        * Interrupt - connID B
-                        */
-                       dwc2_force_mode(hsotg, false);
-
-               /* This clear DCTL.SFTDISCON bit */
-               dwc2_hsotg_core_connect(hsotg);
-       } else {
-               if (dwc2_is_device_mode(hsotg)) {
-                       if (!dwc2_ovr_bvalid(hsotg, false))
-                               /* This set DCTL.SFTDISCON bit */
-                               dwc2_hsotg_core_disconnect(hsotg);
-               } else {
-                       dwc2_ovr_avalid(hsotg, false);
-               }
-       }
-
-unlock:
-       spin_unlock_irqrestore(&hsotg->lock, flags);
-
-       dev_dbg(hsotg->dev, "%s-session valid\n",
-               role == USB_ROLE_NONE ? "No" :
-               role == USB_ROLE_HOST ? "A" : "B");
-
-       return 0;
-}
-
-int dwc2_drd_init(struct dwc2_hsotg *hsotg)
-{
-       struct usb_role_switch_desc role_sw_desc = {0};
-       struct usb_role_switch *role_sw;
-       int ret;
-
-       if (!device_property_read_bool(hsotg->dev, "usb-role-switch"))
-               return 0;
-
-       role_sw_desc.driver_data = hsotg;
-       role_sw_desc.fwnode = dev_fwnode(hsotg->dev);
-       role_sw_desc.set = dwc2_drd_role_sw_set;
-       role_sw_desc.allow_userspace_control = true;
-
-       role_sw = usb_role_switch_register(hsotg->dev, &role_sw_desc);
-       if (IS_ERR(role_sw)) {
-               ret = PTR_ERR(role_sw);
-               dev_err(hsotg->dev,
-                       "failed to register role switch: %d\n", ret);
-               return ret;
-       }
-
-       hsotg->role_sw = role_sw;
-
-       /* Enable override and initialize values */
-       dwc2_ovr_init(hsotg);
-
-       return 0;
-}
-
-void dwc2_drd_suspend(struct dwc2_hsotg *hsotg)
-{
-       u32 gintsts, gintmsk;
-
-       if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) {
-               gintmsk = dwc2_readl(hsotg, GINTMSK);
-               gintmsk &= ~GINTSTS_CONIDSTSCHNG;
-               dwc2_writel(hsotg, gintmsk, GINTMSK);
-               gintsts = dwc2_readl(hsotg, GINTSTS);
-               dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS);
-       }
-}
-
-void dwc2_drd_resume(struct dwc2_hsotg *hsotg)
-{
-       u32 gintsts, gintmsk;
-
-       if (hsotg->role_sw && !hsotg->params.external_id_pin_ctl) {
-               gintsts = dwc2_readl(hsotg, GINTSTS);
-               dwc2_writel(hsotg, gintsts | GINTSTS_CONIDSTSCHNG, GINTSTS);
-               gintmsk = dwc2_readl(hsotg, GINTMSK);
-               gintmsk |= GINTSTS_CONIDSTSCHNG;
-               dwc2_writel(hsotg, gintmsk, GINTMSK);
-       }
-}
-
-void dwc2_drd_exit(struct dwc2_hsotg *hsotg)
-{
-       if (hsotg->role_sw)
-               usb_role_switch_unregister(hsotg->role_sw);
-}
index 16c5f976f1413af2fbb75d7e5fe3948a3cb44256..5b9d23991c99dd2b6fa242f49ab8d322e4c341a7 100644 (file)
@@ -3530,7 +3530,7 @@ void dwc2_hsotg_core_init_disconnected(struct dwc2_hsotg *hsotg,
                dwc2_readl(hsotg, DOEPCTL0));
 }
 
-void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg)
+static void dwc2_hsotg_core_disconnect(struct dwc2_hsotg *hsotg)
 {
        /* set the soft-disconnect bit */
        dwc2_set_bit(hsotg, DCTL, DCTL_SFTDISCON);
index 68b56b43a45e6c2a051ee2f5d89e56553bf1990e..db9fd4bd1a38cd9647401e8961d6e0bb3650d96c 100644 (file)
@@ -317,8 +317,6 @@ static int dwc2_driver_remove(struct platform_device *dev)
        if (hsotg->params.activate_stm_id_vb_detection)
                regulator_disable(hsotg->usb33d);
 
-       dwc2_drd_exit(hsotg);
-
        if (hsotg->ll_hw_enabled)
                dwc2_lowlevel_hw_disable(hsotg);
 
@@ -535,13 +533,6 @@ static int dwc2_driver_probe(struct platform_device *dev)
                dwc2_writel(hsotg, ggpio, GGPIO);
        }
 
-       retval = dwc2_drd_init(hsotg);
-       if (retval) {
-               if (retval != -EPROBE_DEFER)
-                       dev_err(hsotg->dev, "failed to initialize dual-role\n");
-               goto error_init;
-       }
-
        if (hsotg->dr_mode != USB_DR_MODE_HOST) {
                retval = dwc2_gadget_init(hsotg);
                if (retval)
@@ -617,8 +608,6 @@ static int __maybe_unused dwc2_suspend(struct device *dev)
        if (is_device_mode)
                dwc2_hsotg_suspend(dwc2);
 
-       dwc2_drd_suspend(dwc2);
-
        if (dwc2->params.activate_stm_id_vb_detection) {
                unsigned long flags;
                u32 ggpio, gotgctl;
@@ -699,8 +688,6 @@ static int __maybe_unused dwc2_resume(struct device *dev)
        /* Need to restore FORCEDEVMODE/FORCEHOSTMODE */
        dwc2_force_dr_mode(dwc2);
 
-       dwc2_drd_resume(dwc2);
-
        if (dwc2_is_device_mode(dwc2))
                ret = dwc2_hsotg_resume(dwc2);